DayZ 1.29
DayZ Explorer by KGB
 
Загрузка...
Поиск...
Не найдено

◆ GetAgents()

override int SpawnItemOnLocation::GetAgents ( )
protected

См. определение в файле ItemBase.c строка 8910

8915{
8916 override bool CanPutAsAttachment(EntityAI parent)
8917 {
8918 return true;
8919 }
8920};
8921
8923{
8924
8925};
8926
8927//const bool QUANTITY_DEBUG_REMOVE_ME = false;
8928
8929class ItemBase extends InventoryItem
8930{
8934
8936
8937 static int m_DebugActionsMask;
8939 // ============================================
8940 // Variable Manipulation System
8941 // ============================================
8942 // Quantity
8943
8944 float m_VarQuantity;
8945 float m_VarQuantityPrev;//for client to know quantity changed during synchronization
8947 int m_VarQuantityMin;
8948 int m_VarQuantityMax;
8949 int m_Count;
8950 float m_VarStackMax;
8951 float m_StoreLoadedQuantity = float.LOWEST;
8952 // Wet
8953 float m_VarWet;
8954 float m_VarWetPrev;//for client to know wetness changed during synchronization
8955 float m_VarWetInit;
8956 float m_VarWetMin;
8957 float m_VarWetMax;
8958 // Cleanness
8959 int m_Cleanness;
8960 int m_CleannessInit;
8961 int m_CleannessMin;
8962 int m_CleannessMax;
8963 // impact sounds
8965 bool m_CanPlayImpactSound = true;
8966 float m_ImpactSpeed;
8968 //
8969 float m_HeatIsolation;
8970 float m_ItemModelLength;
8971 float m_ItemAttachOffset; // Offset length for when the item is attached e.g. to weapon
8973 int m_VarLiquidType;
8974 int m_ItemBehaviour; // -1 = not specified; 0 = heavy item; 1= onehanded item; 2 = twohanded item
8975 int m_QuickBarBonus;
8976 bool m_IsBeingPlaced;
8977 bool m_IsHologram;
8978 bool m_IsTakeable;
8979 bool m_ThrowItemOnDrop;
8982 bool m_FixDamageSystemInit = false; //can be changed on storage version check
8983 bool can_this_be_combined; //Check if item can be combined
8984 bool m_CanThisBeSplit; //Check if item can be split
8985 bool m_IsStoreLoad = false;
8986 bool m_CanShowQuantity;
8987 bool m_HasQuantityBar;
8988 protected bool m_CanBeDigged;
8989 protected bool m_IsResultOfSplit
8990
8991 string m_SoundAttType;
8992 // items color variables
8997 //-------------------------------------------------------
8998
8999 // light source managing
9001
9005
9006 //==============================================
9007 // agent system
9008 private int m_AttachedAgents;
9009
9011 void TransferModifiers(PlayerBase reciever);
9012
9013
9014 // Weapons & suppressors particle effects
9018 ref static map<string, int> m_WeaponTypeToID;
9019 static int m_LastRegisteredWeaponID = 0;
9020
9021 // Overheating effects
9023 float m_OverheatingShots;
9024 ref Timer m_CheckOverheating;
9025 int m_ShotsToStartOverheating = 0; // After these many shots, the overheating effect begins
9026 int m_MaxOverheatingValue = 0; // Limits the number of shots that will be tracked
9027 float m_OverheatingDecayInterval = 1; // Timer's interval for decrementing overheat effect's lifespan
9028 ref array <ref OverheatingParticle> m_OverheatingParticles;
9029
9031 protected bool m_HideSelectionsBySlot;
9032
9033 // Admin Log
9034 PluginAdminLog m_AdminLog;
9035
9036 // misc
9037 ref Timer m_PhysDropTimer;
9038
9039 // Attachment Locking variables
9040 ref array<int> m_CompatibleLocks;
9041 protected int m_LockType;
9042 protected ref EffectSound m_LockingSound;
9043 protected string m_LockSoundSet;
9044
9045 // ItemSoundHandler variables
9046 protected const int ITEM_SOUNDS_MAX = 63; // optimize network synch
9047 protected int m_SoundSyncPlay; // id for sound to play
9048 protected int m_SoundSyncStop; // id for sound to stop
9049 protected int m_SoundSyncSlotID = InventorySlots.INVALID; // slot id for attach/detach sound based on slot
9050
9052
9053 //temperature
9054 private float m_TemperaturePerQuantityWeight;
9055
9056 // -------------------------------------------------------------------------
9057 void ItemBase()
9058 {
9059 SetEventMask(EntityEvent.INIT); // Enable EOnInit event
9063
9064 if (!g_Game.IsDedicatedServer())
9065 {
9066 if (HasMuzzle())
9067 {
9069
9071 {
9073 }
9074 }
9075
9077 m_ActionsInitialize = false;
9078 }
9079
9080 m_OldLocation = null;
9081
9082 if (g_Game.IsServer())
9083 {
9084 m_AdminLog = PluginAdminLog.Cast(GetPlugin(PluginAdminLog));
9085 }
9086
9087 if (ConfigIsExisting("headSelectionsToHide"))
9088 {
9090 ConfigGetTextArray("headSelectionsToHide",m_HeadHidingSelections);
9091 }
9092
9093 m_HideSelectionsBySlot = false;
9094 if (ConfigIsExisting("hideSelectionsByinventorySlot"))
9095 {
9096 m_HideSelectionsBySlot = ConfigGetBool("hideSelectionsByinventorySlot");
9097 }
9098
9099 m_QuickBarBonus = Math.Max(0, ConfigGetInt("quickBarBonus"));
9100
9101 m_IsResultOfSplit = false;
9102
9104 }
9105
9106 override void InitItemVariables()
9107 {
9108 super.InitItemVariables();
9109
9110 m_VarQuantityInit = ConfigGetInt("varQuantityInit");
9111 m_VarQuantity = m_VarQuantityInit;//should be by the CE, this is just a precaution
9112 m_VarQuantityMin = ConfigGetInt("varQuantityMin");
9113 m_VarQuantityMax = ConfigGetInt("varQuantityMax");
9114 m_VarStackMax = ConfigGetFloat("varStackMax");
9115 m_Count = ConfigGetInt("count");
9116
9117 m_CanShowQuantity = ConfigGetBool("quantityShow");
9118 m_HasQuantityBar = ConfigGetBool("quantityBar");
9119
9120 m_CleannessInit = ConfigGetInt("varCleannessInit");
9122 m_CleannessMin = ConfigGetInt("varCleannessMin");
9123 m_CleannessMax = ConfigGetInt("varCleannessMax");
9124
9125 m_WantPlayImpactSound = false;
9126 m_ImpactSpeed = 0.0;
9127
9128 m_VarWetInit = ConfigGetFloat("varWetInit");
9130 m_VarWetMin = ConfigGetFloat("varWetMin");
9131 m_VarWetMax = ConfigGetFloat("varWetMax");
9132
9133 m_LiquidContainerMask = ConfigGetInt("liquidContainerType");
9134 if (IsLiquidContainer() && GetQuantity() != 0)
9136 m_IsBeingPlaced = false;
9137 m_IsHologram = false;
9138 m_IsTakeable = true;
9139 m_CanBeMovedOverride = false;
9143 m_CanBeDigged = ConfigGetBool("canBeDigged");
9144
9145 m_CompatibleLocks = new array<int>();
9146 ConfigGetIntArray("compatibleLocks", m_CompatibleLocks);
9147 m_LockType = ConfigGetInt("lockType");
9148
9149 //Define if item can be split and set ability to be combined accordingly
9150 m_CanThisBeSplit = false;
9151 can_this_be_combined = false;
9152 if (ConfigIsExisting("canBeSplit"))
9153 {
9154 can_this_be_combined = ConfigGetBool("canBeSplit");
9156 }
9157
9158 m_ItemBehaviour = -1;
9159 if (ConfigIsExisting("itemBehaviour"))
9160 m_ItemBehaviour = ConfigGetInt("itemBehaviour");
9161
9162 //RegisterNetSyncVariableInt("m_VariablesMask");
9163 if (HasQuantity()) RegisterNetSyncVariableFloat("m_VarQuantity", GetQuantityMin(), m_VarQuantityMax);
9164 RegisterNetSyncVariableFloat("m_VarWet", GetWetMin(), GetWetMax(), 2);
9165 RegisterNetSyncVariableInt("m_VarLiquidType");
9166 RegisterNetSyncVariableInt("m_Cleanness",0,1);
9167
9168 RegisterNetSyncVariableBoolSignal("m_WantPlayImpactSound");
9169 RegisterNetSyncVariableFloat("m_ImpactSpeed");
9170 RegisterNetSyncVariableInt("m_ImpactSoundSurfaceHash");
9171
9172 RegisterNetSyncVariableInt("m_ColorComponentR", 0, 255);
9173 RegisterNetSyncVariableInt("m_ColorComponentG", 0, 255);
9174 RegisterNetSyncVariableInt("m_ColorComponentB", 0, 255);
9175 RegisterNetSyncVariableInt("m_ColorComponentA", 0, 255);
9176
9177 RegisterNetSyncVariableBool("m_IsBeingPlaced");
9178 RegisterNetSyncVariableBool("m_IsTakeable");
9179 RegisterNetSyncVariableBool("m_IsHologram");
9180
9183 {
9184 RegisterNetSyncVariableInt("m_SoundSyncPlay", 0, ITEM_SOUNDS_MAX);
9185 RegisterNetSyncVariableInt("m_SoundSyncStop", 0, ITEM_SOUNDS_MAX);
9186 RegisterNetSyncVariableInt("m_SoundSyncSlotID", int.MIN, int.MAX);
9187 }
9188
9189 m_LockSoundSet = ConfigGetString("lockSoundSet");
9190
9192 if (ConfigIsExisting("temperaturePerQuantityWeight"))
9193 m_TemperaturePerQuantityWeight = ConfigGetFloat("temperaturePerQuantityWeight");
9194
9195 m_SoundSyncSlotID = -1;
9196 }
9197
9198 override int GetQuickBarBonus()
9199 {
9200 return m_QuickBarBonus;
9201 }
9202
9203 void InitializeActions()
9204 {
9206 if (!m_InputActionMap)
9207 {
9209 m_InputActionMap = iam;
9210 SetActions();
9212 }
9213 }
9214
9215 override void GetActions(typename action_input_type, out array<ActionBase_Basic> actions)
9216 {
9218 {
9219 m_ActionsInitialize = true;
9221 }
9222
9223 actions = m_InputActionMap.Get(action_input_type);
9224 }
9225
9226 void SetActions()
9227 {
9228 AddAction(ActionTakeItem);
9229 AddAction(ActionTakeItemToHands);
9230 AddAction(ActionWorldCraft);
9232 AddAction(ActionAttachWithSwitch);
9233 }
9234
9235 void SetActionAnimOverrides(); // Override action animation for specific item
9236
9237 void AddAction(typename actionName)
9238 {
9239 ActionBase action = ActionManagerBase.GetAction(actionName);
9240
9241 if (!action)
9242 {
9243 Debug.LogError("Action " + actionName + " dosn't exist!");
9244 return;
9245 }
9246
9247 typename ai = action.GetInputType();
9248 if (!ai)
9249 {
9250 m_ActionsInitialize = false;
9251 return;
9252 }
9253
9254 array<ActionBase_Basic> action_array = m_InputActionMap.Get(ai);
9255 if (!action_array)
9256 {
9257 action_array = new array<ActionBase_Basic>;
9258 m_InputActionMap.Insert(ai, action_array);
9259 }
9260 if (LogManager.IsActionLogEnable())
9261 {
9262 Debug.ActionLog(action.ToString() + " -> " + ai, this.ToString() , "n/a", "Add action");
9263 }
9264
9265 if (action_array.Find(action) != -1)
9266 {
9267 Debug.Log("Action " + action.Type() + " already added to " + this + ", skipping!");
9268 }
9269 else
9270 {
9271 action_array.Insert(action);
9272 }
9273 }
9274
9275 void RemoveAction(typename actionName)
9276 {
9277 PlayerBase player = PlayerBase.Cast(g_Game.GetPlayer());
9278 ActionBase action = player.GetActionManager().GetAction(actionName);
9279 typename ai = action.GetInputType();
9280 array<ActionBase_Basic> action_array = m_InputActionMap.Get(ai);
9281
9282 if (action_array)
9283 {
9284 action_array.RemoveItem(action);
9285 }
9286 }
9287
9288 // Allows override of default action command per item, defined in the SetActionAnimOverrides() of the item's class
9289 // Set -1 for params which should stay in default state
9290 void OverrideActionAnimation(typename action, int commandUID, int stanceMask = -1, int commandUIDProne = -1)
9291 {
9292 ActionOverrideData overrideData = new ActionOverrideData();
9293 overrideData.m_CommandUID = commandUID;
9294 overrideData.m_CommandUIDProne = commandUIDProne;
9295 overrideData.m_StanceMask = stanceMask;
9296
9297 TActionAnimOverrideMap actionMap = m_ItemActionOverrides.Get(action);
9298 if (!actionMap) // create new map of action > overidables map
9299 {
9300 actionMap = new TActionAnimOverrideMap();
9301 m_ItemActionOverrides.Insert(action, actionMap);
9302 }
9303
9304 actionMap.Insert(this.Type(), overrideData); // insert item -> overrides
9305
9306 }
9307
9308 void OnItemInHandsPlayerSwimStart(PlayerBase player);
9309
9310 ScriptedLightBase GetLight();
9311
9312 // Loads muzzle flash particle configuration from config and saves it to a map for faster access
9313 void LoadParticleConfigOnFire(int id)
9314 {
9315 if (!m_OnFireEffect)
9317
9320
9321 string config_to_search = "CfgVehicles";
9322 string muzzle_owner_config;
9323
9324 if (!m_OnFireEffect.Contains(id))
9325 {
9326 if (IsInherited(Weapon))
9327 config_to_search = "CfgWeapons";
9328
9329 muzzle_owner_config = config_to_search + " " + GetType() + " ";
9330
9331 string config_OnFire_class = muzzle_owner_config + "Particles " + "OnFire ";
9332
9333 int config_OnFire_subclass_count = g_Game.ConfigGetChildrenCount(config_OnFire_class);
9334
9335 if (config_OnFire_subclass_count > 0)
9336 {
9337 array<ref WeaponParticlesOnFire> WPOF_array = new array<ref WeaponParticlesOnFire>;
9338
9339 for (int i = 0; i < config_OnFire_subclass_count; i++)
9340 {
9341 string particle_class = "";
9342 g_Game.ConfigGetChildName(config_OnFire_class, i, particle_class);
9343 string config_OnFire_entry = config_OnFire_class + particle_class;
9344 WeaponParticlesOnFire WPOF = new WeaponParticlesOnFire(this, config_OnFire_entry);
9345 WPOF_array.Insert(WPOF);
9346 }
9347
9348
9349 m_OnFireEffect.Insert(id, WPOF_array);
9350 }
9351 }
9352
9353 if (!m_OnBulletCasingEjectEffect.Contains(id))
9354 {
9355 config_to_search = "CfgWeapons"; // Bullet Eject efect is supported on weapons only.
9356 muzzle_owner_config = config_to_search + " " + GetType() + " ";
9357
9358 string config_OnBulletCasingEject_class = muzzle_owner_config + "Particles " + "OnBulletCasingEject ";
9359
9360 int config_OnBulletCasingEject_count = g_Game.ConfigGetChildrenCount(config_OnBulletCasingEject_class);
9361
9362 if (config_OnBulletCasingEject_count > 0 && IsInherited(Weapon))
9363 {
9364 array<ref WeaponParticlesOnBulletCasingEject> WPOBE_array = new array<ref WeaponParticlesOnBulletCasingEject>;
9365
9366 for (i = 0; i < config_OnBulletCasingEject_count; i++)
9367 {
9368 string particle_class2 = "";
9369 g_Game.ConfigGetChildName(config_OnBulletCasingEject_class, i, particle_class2);
9370 string config_OnBulletCasingEject_entry = config_OnBulletCasingEject_class + particle_class2;
9371 WeaponParticlesOnBulletCasingEject WPOBE = new WeaponParticlesOnBulletCasingEject(this, config_OnBulletCasingEject_entry);
9372 WPOBE_array.Insert(WPOBE);
9373 }
9374
9375
9376 m_OnBulletCasingEjectEffect.Insert(id, WPOBE_array);
9377 }
9378 }
9379 }
9380
9381 // Loads muzzle flash particle configuration from config and saves it to a map for faster access
9383 {
9386
9387 if (!m_OnOverheatingEffect.Contains(id))
9388 {
9389 string config_to_search = "CfgVehicles";
9390
9391 if (IsInherited(Weapon))
9392 config_to_search = "CfgWeapons";
9393
9394 string muzzle_owner_config = config_to_search + " " + GetType() + " ";
9395 string config_OnOverheating_class = muzzle_owner_config + "Particles " + "OnOverheating ";
9396
9397 if (g_Game.ConfigIsExisting(config_OnOverheating_class))
9398 {
9399
9400 m_ShotsToStartOverheating = g_Game.ConfigGetFloat(config_OnOverheating_class + "shotsToStartOverheating");
9401
9403 {
9404 m_ShotsToStartOverheating = -1; // This prevents futher readings from config for future creations of this item
9405 string error = "Error reading config " + GetType() + ">Particles>OnOverheating - Parameter shotsToStartOverheating is configured wrong or is missing! Its value must be 1 or higher!";
9406 Error(error);
9407 return;
9408 }
9409
9410 m_OverheatingDecayInterval = g_Game.ConfigGetFloat(config_OnOverheating_class + "overheatingDecayInterval");
9411 m_MaxOverheatingValue = g_Game.ConfigGetFloat(config_OnOverheating_class + "maxOverheatingValue");
9412
9413
9414
9415 int config_OnOverheating_subclass_count = g_Game.ConfigGetChildrenCount(config_OnOverheating_class);
9416 array<ref WeaponParticlesOnOverheating> WPOOH_array = new array<ref WeaponParticlesOnOverheating>;
9417
9418 for (int i = 0; i < config_OnOverheating_subclass_count; i++)
9419 {
9420 string particle_class = "";
9421 g_Game.ConfigGetChildName(config_OnOverheating_class, i, particle_class);
9422 string config_OnOverheating_entry = config_OnOverheating_class + particle_class;
9423 int entry_type = g_Game.ConfigGetType(config_OnOverheating_entry);
9424
9425 if (entry_type == CT_CLASS)
9426 {
9427 WeaponParticlesOnOverheating WPOF = new WeaponParticlesOnOverheating(this, config_OnOverheating_entry);
9428 WPOOH_array.Insert(WPOF);
9429 }
9430 }
9431
9432
9433 m_OnOverheatingEffect.Insert(id, WPOOH_array);
9434 }
9435 }
9436 }
9437
9438 float GetOverheatingValue()
9439 {
9440 return m_OverheatingShots;
9441 }
9442
9443 void IncreaseOverheating(ItemBase weapon, string ammoType, ItemBase muzzle_owner, ItemBase suppressor, string config_to_search)
9444 {
9445 if (m_MaxOverheatingValue > 0)
9446 {
9448
9449 if (!m_CheckOverheating)
9451
9453 m_CheckOverheating.Run(m_OverheatingDecayInterval, this, "OnOverheatingDecay");
9454
9455 CheckOverheating(weapon, ammoType, muzzle_owner, suppressor, config_to_search);
9456 }
9457 }
9458
9459 void CheckOverheating(ItemBase weapon = null, string ammoType = "", ItemBase muzzle_owner = null, ItemBase suppressor = null, string config_to_search = "")
9460 {
9462 UpdateOverheating(weapon, ammoType, muzzle_owner, suppressor, config_to_search);
9463
9465 StartOverheating(weapon, ammoType, muzzle_owner, suppressor, config_to_search);
9466
9468 StopOverheating(weapon, ammoType, muzzle_owner, suppressor, config_to_search);
9469
9471 {
9473 }
9474 }
9475
9477 {
9479 }
9480
9481 void OnOverheatingDecay()
9482 {
9483 if (m_MaxOverheatingValue > 0)
9484 m_OverheatingShots -= 1 + m_OverheatingShots / m_MaxOverheatingValue; // The hotter a barrel is, the faster it needs to cool down.
9485 else
9487
9488 if (m_OverheatingShots <= 0)
9489 {
9492 }
9493 else
9494 {
9495 if (!m_CheckOverheating)
9497
9499 m_CheckOverheating.Run(m_OverheatingDecayInterval, this, "OnOverheatingDecay");
9500 }
9501
9502 CheckOverheating(this, "", this);
9503 }
9504
9505 void StartOverheating(ItemBase weapon = null, string ammoType = "", ItemBase muzzle_owner = null, ItemBase suppressor = null, string config_to_search = "")
9506 {
9508 ItemBase.PlayOverheatingParticles(this, ammoType, this, suppressor, "CfgWeapons");
9509 }
9510
9511 void UpdateOverheating(ItemBase weapon = null, string ammoType = "", ItemBase muzzle_owner = null, ItemBase suppressor = null, string config_to_search = "")
9512 {
9514 ItemBase.UpdateOverheatingParticles(this, ammoType, this, suppressor, "CfgWeapons");
9516 }
9517
9518 void StopOverheating(ItemBase weapon = null, string ammoType = "", ItemBase muzzle_owner = null, ItemBase suppressor = null, string config_to_search = "")
9519 {
9521 ItemBase.StopOverheatingParticles(weapon, ammoType, muzzle_owner, suppressor, config_to_search);
9522 }
9523
9524 void RegisterOverheatingParticle(Particle p, float min_heat_coef, float max_heat_coef, int particle_id, Object parent, vector local_pos, vector local_ori)
9525 {
9527 m_OverheatingParticles = new array<ref OverheatingParticle>;
9528
9529 OverheatingParticle OP = new OverheatingParticle();
9530 OP.RegisterParticle(p);
9531 OP.SetOverheatingLimitMin(min_heat_coef);
9532 OP.SetOverheatingLimitMax(max_heat_coef);
9533 OP.SetParticleParams(particle_id, parent, local_pos, local_ori);
9534
9535 m_OverheatingParticles.Insert(OP);
9536 }
9537
9538 float GetOverheatingCoef()
9539 {
9540 if (m_MaxOverheatingValue > 0)
9542
9543 return -1;
9544 }
9545
9547 {
9549 {
9550 float overheat_coef = GetOverheatingCoef();
9551 int count = m_OverheatingParticles.Count();
9552
9553 for (int i = count; i > 0; --i)
9554 {
9555 int id = i - 1;
9556 OverheatingParticle OP = m_OverheatingParticles.Get(id);
9557 Particle p = OP.GetParticle();
9558
9559 float overheat_min = OP.GetOverheatingLimitMin();
9560 float overheat_max = OP.GetOverheatingLimitMax();
9561
9562 if (overheat_coef < overheat_min && overheat_coef >= overheat_max)
9563 {
9564 if (p)
9565 {
9566 p.Stop();
9567 OP.RegisterParticle(null);
9568 }
9569 }
9570 }
9571 }
9572 }
9573
9575 {
9577 {
9578 for (int i = m_OverheatingParticles.Count(); i > 0; i--)
9579 {
9580 int id = i - 1;
9581 OverheatingParticle OP = m_OverheatingParticles.Get(id);
9582
9583 if (OP)
9584 {
9585 Particle p = OP.GetParticle();
9586
9587 if (p)
9588 {
9589 p.Stop();
9590 }
9591
9592 delete OP;
9593 }
9594 }
9595
9596 m_OverheatingParticles.Clear();
9598 }
9599 }
9600
9602 float GetInfectionChance(int system = 0, Param param = null)
9603 {
9604 return 0.0;
9605 }
9606
9607
9608 float GetDisinfectQuantity(int system = 0, Param param1 = null)
9609 {
9610 return 250;//default value
9611 }
9612
9613 float GetFilterDamageRatio()
9614 {
9615 return 0;
9616 }
9617
9619 bool HasMuzzle()
9620 {
9621 if (IsInherited(Weapon) || IsInherited(SuppressorBase))
9622 return true;
9623
9624 return false;
9625 }
9626
9628 int GetMuzzleID()
9629 {
9630 if (!m_WeaponTypeToID)
9631 m_WeaponTypeToID = new map<string, int>;
9632
9633 if (m_WeaponTypeToID.Contains(GetType()))
9634 {
9635 return m_WeaponTypeToID.Get(GetType());
9636 }
9637 else
9638 {
9639 // Register new weapon ID
9641 }
9642
9644 }
9645
9652 {
9653 return -1;
9654 }
9655
9656
9657
9658 // -------------------------------------------------------------------------
9659 void ~ItemBase()
9660 {
9661 if (g_Game && g_Game.GetPlayer() && (!g_Game.IsDedicatedServer()))
9662 {
9663 PlayerBase player = PlayerBase.Cast(g_Game.GetPlayer());
9664 int r_index = player.GetHumanInventory().FindUserReservedLocationIndex(this);
9665
9666 if (r_index >= 0)
9667 {
9668 InventoryLocation r_il = new InventoryLocation;
9669 player.GetHumanInventory().GetUserReservedLocation(r_index,r_il);
9670
9671 player.GetHumanInventory().ClearUserReservedLocationAtIndex(r_index);
9672 int r_type = r_il.GetType();
9673 if (r_type == InventoryLocationType.CARGO || r_type == InventoryLocationType.PROXYCARGO)
9674 {
9675 r_il.GetParent().GetOnReleaseLock().Invoke(this);
9676 }
9677 else if (r_type == InventoryLocationType.ATTACHMENT)
9678 {
9679 r_il.GetParent().GetOnAttachmentReleaseLock().Invoke(this, r_il.GetSlot());
9680 }
9681
9682 }
9683
9684 player.GetHumanInventory().ClearUserReservedLocation(this);
9685 }
9686
9687 if (m_LockingSound)
9688 SEffectManager.DestroyEffect(m_LockingSound);
9689 }
9690
9691
9692
9693 // -------------------------------------------------------------------------
9694 static int GetDebugActionsMask()
9695 {
9696 return ItemBase.m_DebugActionsMask;
9697 }
9698
9699 static bool HasDebugActionsMask(int mask)
9700 {
9701 return ItemBase.m_DebugActionsMask & mask;
9702 }
9703
9704 static void SetDebugActionsMask(int mask)
9705 {
9706 ItemBase.m_DebugActionsMask = mask;
9707 }
9708
9709 static void AddDebugActionsMask(int mask)
9710 {
9711 ItemBase.m_DebugActionsMask |= mask;
9712 }
9713
9714 static void RemoveDebugActionsMask(int mask)
9715 {
9716 ItemBase.m_DebugActionsMask &= ~mask;
9717 }
9718
9719 static void ToggleDebugActionsMask(int mask)
9720 {
9721 if (HasDebugActionsMask(mask))
9722 {
9724 }
9725 else
9726 {
9727 AddDebugActionsMask(mask);
9728 }
9729 }
9730
9731 // -------------------------------------------------------------------------
9732 void SetCEBasedQuantity()
9733 {
9734 if (GetEconomyProfile())
9735 {
9736 float q_max = GetEconomyProfile().GetQuantityMax();
9737 if (q_max > 0)
9738 {
9739 float q_min = GetEconomyProfile().GetQuantityMin();
9740 float quantity_randomized = Math.RandomFloatInclusive(q_min, q_max);
9741
9742 if (HasComponent(COMP_TYPE_ENERGY_MANAGER))//more direct access for speed
9743 {
9744 ComponentEnergyManager comp = GetCompEM();
9745 if (comp && (comp.GetEnergyMaxPristine() || comp.GetEnergyAtSpawn()))//checking for a potential for energy, we need to check both values, as both are optional, only when both are set to 0, we know the item can't have energy
9746 {
9747 comp.SetEnergy0To1(quantity_randomized);
9748 }
9749 }
9750 else if (HasQuantity())
9751 {
9752 SetQuantityNormalized(quantity_randomized, false);
9753 //PrintString("<==> Normalized quantity for item: "+ GetType()+", qmin:"+q_min.ToString()+"; qmax:"+q_max.ToString()+";quantity:" +quantity_randomized.ToString());
9754 }
9755
9756 }
9757 }
9758 }
9759
9761 void LockToParent()
9762 {
9763 EntityAI parent = GetHierarchyParent();
9764
9765 if (parent)
9766 {
9767 InventoryLocation inventory_location_to_lock = new InventoryLocation;
9768 GetInventory().GetCurrentInventoryLocation(inventory_location_to_lock);
9769 parent.GetInventory().SetSlotLock(inventory_location_to_lock.GetSlot(), true);
9770 }
9771 }
9772
9774 void UnlockFromParent()
9775 {
9776 EntityAI parent = GetHierarchyParent();
9777
9778 if (parent)
9779 {
9780 InventoryLocation inventory_location_to_unlock = new InventoryLocation;
9781 GetInventory().GetCurrentInventoryLocation(inventory_location_to_unlock);
9782 parent.GetInventory().SetSlotLock(inventory_location_to_unlock.GetSlot(), false);
9783 }
9784 }
9785
9786 override void CombineItemsClient(EntityAI entity2, bool use_stack_max = true)
9787 {
9788 /*
9789 ref Param1<EntityAI> item = new Param1<EntityAI>(entity2);
9790 RPCSingleParam(ERPCs.RPC_ITEM_COMBINE, item, g_Game.GetPlayer());
9791 */
9792 ItemBase item2 = ItemBase.Cast(entity2);
9793
9794 if (g_Game.IsClient())
9795 {
9796 if (ScriptInputUserData.CanStoreInputUserData())
9797 {
9798 ScriptInputUserData ctx = new ScriptInputUserData;
9800 ctx.Write(-1);
9801 ItemBase i1 = this; // @NOTE: workaround for correct serialization
9802 ctx.Write(i1);
9803 ctx.Write(item2);
9804 ctx.Write(use_stack_max);
9805 ctx.Write(-1);
9806 ctx.Send();
9807
9808 if (IsCombineAll(item2, use_stack_max))
9809 {
9810 g_Game.GetPlayer().GetInventory().AddInventoryReservationEx(item2,null,GameInventory.c_InventoryReservationTimeoutShortMS);
9811 }
9812 }
9813 }
9814 else if (!g_Game.IsMultiplayer())
9815 {
9816 CombineItems(item2, use_stack_max);
9817 }
9818 }
9819
9820 bool IsLiquidPresent()
9821 {
9822 return (GetLiquidType() != 0 && HasQuantity());
9823 }
9824
9825 bool IsLiquidContainer()
9826 {
9827 return m_LiquidContainerMask != 0;
9828 }
9829
9831 {
9832 return m_LiquidContainerMask;
9833 }
9834
9835 bool IsBloodContainer()
9836 {
9837 //m_LiquidContainerMask & GROUP_LIQUID_BLOOD ???
9838 return false;
9839 }
9840
9841 bool IsNVG()
9842 {
9843 return false;
9844 }
9845
9848 bool IsExplosive()
9849 {
9850 return false;
9851 }
9852
9854 {
9855 return "";
9856 }
9857
9859
9860 bool IsLightSource()
9861 {
9862 return false;
9863 }
9864
9866 {
9867 return true;
9868 }
9869
9870 //--- ACTION CONDITIONS
9871 //direction
9872 bool IsFacingPlayer(PlayerBase player, string selection)
9873 {
9874 return true;
9875 }
9876
9877 bool IsPlayerInside(PlayerBase player, string selection)
9878 {
9879 return true;
9880 }
9881
9882 override bool CanObstruct()
9883 {
9884 PlayerBase player = PlayerBase.Cast(g_Game.GetPlayer());
9885 return !player || !IsPlayerInside(player, "");
9886 }
9887
9888 override bool IsBeingPlaced()
9889 {
9890 return m_IsBeingPlaced;
9891 }
9892
9893 void SetIsBeingPlaced(bool is_being_placed)
9894 {
9895 m_IsBeingPlaced = is_being_placed;
9896 if (!is_being_placed)
9898 SetSynchDirty();
9899 }
9900
9901 //server-side
9902 void OnEndPlacement() {}
9903
9904 override bool IsHologram()
9905 {
9906 return m_IsHologram;
9907 }
9908
9909 bool CanBeDigged()
9910 {
9911 return m_CanBeDigged;
9912 }
9913
9915 {
9916 return 1;
9917 }
9918
9919 bool CanMakeGardenplot()
9920 {
9921 return false;
9922 }
9923
9924 void SetIsHologram(bool is_hologram)
9925 {
9926 m_IsHologram = is_hologram;
9927 SetSynchDirty();
9928 }
9929 /*
9930 protected float GetNutritionalEnergy()
9931 {
9932 Edible_Base edible = Edible_Base.Cast(this);
9933 return edible.GetFoodEnergy();
9934 }
9935
9936 protected float GetNutritionalWaterContent()
9937 {
9938 Edible_Base edible = Edible_Base.Cast(this);
9939 return edible.GetFoodWater();
9940 }
9941
9942 protected float GetNutritionalIndex()
9943 {
9944 Edible_Base edible = Edible_Base.Cast(this);
9945 return edible.GetFoodNutritionalIndex();
9946 }
9947
9948 protected float GetNutritionalFullnessIndex()
9949 {
9950 Edible_Base edible = Edible_Base.Cast(this);
9951 return edible.GetFoodTotalVolume();
9952 }
9953
9954 protected float GetNutritionalToxicity()
9955 {
9956 Edible_Base edible = Edible_Base.Cast(this);
9957 return edible.GetFoodToxicity();
9958
9959 }
9960 */
9961
9962
9963 // -------------------------------------------------------------------------
9964 override void OnMovedInsideCargo(EntityAI container)
9965 {
9966 super.OnMovedInsideCargo(container);
9967
9968 MiscGameplayFunctions.RemoveAllAttachedChildrenByTypename(this, {Bolt_Base});
9969 }
9970
9971 override void EEItemLocationChanged(notnull InventoryLocation oldLoc, notnull InventoryLocation newLoc)
9972 {
9973 super.EEItemLocationChanged(oldLoc, newLoc);
9974
9975 PlayerBase newPlayer = null;
9976 PlayerBase oldPlayer = null;
9977
9978 if (newLoc.GetParent())
9979 newPlayer = PlayerBase.Cast(newLoc.GetParent().GetHierarchyRootPlayer());
9980
9981 if (oldLoc.GetParent())
9982 oldPlayer = PlayerBase.Cast(oldLoc.GetParent().GetHierarchyRootPlayer());
9983
9984 if (oldPlayer && oldLoc.GetType() == InventoryLocationType.HANDS)
9985 {
9986 int rIndex = oldPlayer.GetHumanInventory().FindUserReservedLocationIndex(this);
9987
9988 if (rIndex >= 0)
9989 {
9990 InventoryLocation rIl = new InventoryLocation;
9991 oldPlayer.GetHumanInventory().GetUserReservedLocation(rIndex, rIl);
9992
9993 oldPlayer.GetHumanInventory().ClearUserReservedLocationAtIndex(rIndex);
9994 int rType = rIl.GetType();
9995 if (rType == InventoryLocationType.CARGO || rType == InventoryLocationType.PROXYCARGO)
9996 {
9997 rIl.GetParent().GetOnReleaseLock().Invoke(this);
9998 }
9999 else if (rType == InventoryLocationType.ATTACHMENT)
10000 {
10001 rIl.GetParent().GetOnAttachmentReleaseLock().Invoke(this, rIl.GetSlot());
10002 }
10003
10004 }
10005 }
10006
10007 if (newLoc.GetType() == InventoryLocationType.HANDS && oldLoc.GetType() != InventoryLocationType.TEMP)
10008 {
10009 if (newPlayer)
10010 newPlayer.ForceStandUpForHeavyItems(newLoc.GetItem());
10011
10012 if (newPlayer == oldPlayer)
10013 {
10014 if (oldLoc.GetParent() && newPlayer.GetHumanInventory().LocationGetEntity(oldLoc) == NULL)
10015 {
10016 if (oldLoc.GetType() == InventoryLocationType.CARGO)
10017 {
10018 if (oldLoc.GetParent().GetInventory().TestAddEntityInCargoExLoc(oldLoc, false, false, false, true, false, false))
10019 {
10020 newPlayer.GetHumanInventory().SetUserReservedLocation(this,oldLoc);
10021 }
10022 }
10023 else
10024 {
10025 newPlayer.GetHumanInventory().SetUserReservedLocation(this,oldLoc);
10026 }
10027 }
10028
10029 if (newPlayer.GetHumanInventory().FindUserReservedLocationIndex(this) >= 0)
10030 {
10031 int type = oldLoc.GetType();
10032 if (type == InventoryLocationType.CARGO || type == InventoryLocationType.PROXYCARGO)
10033 {
10034 oldLoc.GetParent().GetOnSetLock().Invoke(this);
10035 }
10036 else if (type == InventoryLocationType.ATTACHMENT)
10037 {
10038 oldLoc.GetParent().GetOnAttachmentSetLock().Invoke(this, oldLoc.GetSlot());
10039 }
10040 }
10041 if (!m_OldLocation)
10042 {
10043 m_OldLocation = new InventoryLocation;
10044 }
10045 m_OldLocation.Copy(oldLoc);
10046 }
10047 else
10048 {
10049 if (m_OldLocation)
10050 {
10051 m_OldLocation.Reset();
10052 }
10053 }
10054
10055 g_Game.GetAnalyticsClient().OnItemAttachedAtPlayer(this,"Hands");
10056 }
10057 else
10058 {
10059 if (newPlayer)
10060 {
10061 int resIndex = newPlayer.GetHumanInventory().FindCollidingUserReservedLocationIndex(this, newLoc);
10062 if (resIndex >= 0)
10063 {
10064 InventoryLocation il = new InventoryLocation;
10065 newPlayer.GetHumanInventory().GetUserReservedLocation(resIndex, il);
10066 ItemBase it = ItemBase.Cast(il.GetItem());
10067 newPlayer.GetHumanInventory().ClearUserReservedLocationAtIndex(resIndex);
10068 int rel_type = il.GetType();
10069 if (rel_type == InventoryLocationType.CARGO || rel_type == InventoryLocationType.PROXYCARGO)
10070 {
10071 il.GetParent().GetOnReleaseLock().Invoke(it);
10072 }
10073 else if (rel_type == InventoryLocationType.ATTACHMENT)
10074 {
10075 il.GetParent().GetOnAttachmentReleaseLock().Invoke(it, il.GetSlot());
10076 }
10077 //it.GetOnReleaseLock().Invoke(it);
10078 }
10079 }
10080 else if (oldPlayer && newLoc.GetType() == InventoryLocationType.GROUND && m_ThrowItemOnDrop)
10081 {
10082 //ThrowPhysically(oldPlayer, vector.Zero);
10083 m_ThrowItemOnDrop = false;
10084 }
10085
10086 if (m_OldLocation)
10087 {
10088 m_OldLocation.Reset();
10089 }
10090 }
10091
10092 if (oldLoc.GetType() == InventoryLocationType.TEMP)
10093 {
10094 PluginInventoryRepair.Cast(GetPlugin(PluginInventoryRepair)).Remove(oldLoc.GetItem());
10095 }
10096
10097 if (newLoc.GetType() == InventoryLocationType.TEMP)
10098 {
10099 PluginInventoryRepair.Cast(GetPlugin(PluginInventoryRepair)).Add(oldLoc.GetItem());
10100 }
10101 }
10102
10103 override void EOnContact(IEntity other, Contact extra)
10104 {
10106 {
10107 int liquidType = -1;
10108 float impactSpeed = ProcessImpactSoundEx(other, extra, m_ConfigWeight, m_ImpactSoundSurfaceHash, liquidType);
10109 if (impactSpeed > 0.0)
10110 {
10111 m_ImpactSpeed = impactSpeed;
10112 #ifndef SERVER
10113 PlayImpactSound(m_ConfigWeight, m_ImpactSpeed, m_ImpactSoundSurfaceHash);
10114 #else
10115 m_WantPlayImpactSound = true;
10116 SetSynchDirty();
10117 #endif
10118 m_CanPlayImpactSound = (liquidType == -1);// prevents further playing of the sound when the surface is a liquid type
10119 }
10120 }
10121
10122 #ifdef SERVER
10123 if (GetCompEM() && GetCompEM().IsPlugged())
10124 {
10125 if (GetCompEM().GetCordLength() < vector.Distance(GetPosition(), GetCompEM().GetEnergySource().GetPosition()))
10126 GetCompEM().UnplugThis();
10127 }
10128 #endif
10129 }
10130
10131 void RefreshPhysics();
10132
10133 override void OnCreatePhysics()
10134 {
10136 }
10137
10138 override void OnItemAttachmentSlotChanged(notnull InventoryLocation oldLoc, notnull InventoryLocation newLoc)
10139 {
10140
10141 }
10142 // -------------------------------------------------------------------------
10143 override void OnItemLocationChanged(EntityAI old_owner, EntityAI new_owner)
10144 {
10145 super.OnItemLocationChanged(old_owner, new_owner);
10146
10147 PlayerBase relatedPlayer = PlayerBase.Cast(old_owner);
10148 PlayerBase playerNew = PlayerBase.Cast(new_owner);
10149
10150 if (!relatedPlayer && playerNew)
10151 relatedPlayer = playerNew;
10152
10153 if (relatedPlayer && relatedPlayer.GetPerformedActionID() != -1)
10154 {
10155 ActionManagerBase actionMgr = relatedPlayer.GetActionManager();
10156 if (actionMgr)
10157 {
10158 ActionBase currentAction = actionMgr.GetRunningAction();
10159 if (currentAction)
10160 currentAction.OnItemLocationChanged(this);
10161 }
10162 }
10163
10164 Man ownerPlayerOld = null;
10165 Man ownerPlayerNew = null;
10166
10167 if (old_owner)
10168 {
10169 if (old_owner.IsMan())
10170 {
10171 ownerPlayerOld = Man.Cast(old_owner);
10172 }
10173 else
10174 {
10175 ownerPlayerOld = Man.Cast(old_owner.GetHierarchyRootPlayer());
10176 }
10177 }
10178 else
10179 {
10180 if (new_owner && IsElectricAppliance() && GetCompEM() && GetCompEM().IsPlugged())
10181 {
10182 ActionBase action = ActionManagerBase.GetAction(ActionRepositionPluggedItem);
10183
10184 if (!action || !playerNew || playerNew.GetPerformedActionID() != action.GetID())
10185 {
10186 GetCompEM().UnplugThis();
10187 }
10188 }
10189 }
10190
10191 if (new_owner)
10192 {
10193 if (new_owner.IsMan())
10194 {
10195 ownerPlayerNew = Man.Cast(new_owner);
10196 }
10197 else
10198 {
10199 ownerPlayerNew = Man.Cast(new_owner.GetHierarchyRootPlayer());
10200 }
10201 }
10202
10203 if (ownerPlayerOld != ownerPlayerNew)
10204 {
10205 if (ownerPlayerOld)
10206 {
10207 array<EntityAI> subItemsExit = new array<EntityAI>;
10208 GetInventory().EnumerateInventory(InventoryTraversalType.PREORDER,subItemsExit);
10209 for (int i = 0; i < subItemsExit.Count(); i++)
10210 {
10211 ItemBase itemExit = ItemBase.Cast(subItemsExit.Get(i));
10212 itemExit.OnInventoryExit(ownerPlayerOld);
10213 }
10214 }
10215
10216 if (ownerPlayerNew)
10217 {
10218 array<EntityAI> subItemsEnter = new array<EntityAI>;
10219 GetInventory().EnumerateInventory(InventoryTraversalType.PREORDER,subItemsEnter);
10220 for (int j = 0; j < subItemsEnter.Count(); j++)
10221 {
10222 ItemBase itemEnter = ItemBase.Cast(subItemsEnter.Get(j));
10223 itemEnter.OnInventoryEnter(ownerPlayerNew);
10224 }
10225 }
10226 }
10227 else if (ownerPlayerNew != null)
10228 {
10229 PlayerBase nplayer;
10230 if (PlayerBase.CastTo(nplayer, ownerPlayerNew))
10231 {
10232 array<EntityAI> subItemsUpdate = new array<EntityAI>;
10233 GetInventory().EnumerateInventory(InventoryTraversalType.PREORDER,subItemsUpdate);
10234 for (int k = 0; k < subItemsUpdate.Count(); k++)
10235 {
10236 ItemBase itemUpdate = ItemBase.Cast(subItemsUpdate.Get(k));
10237 itemUpdate.UpdateQuickbarShortcutVisibility(nplayer);
10238 }
10239 }
10240 }
10241
10242 if (old_owner)
10243 old_owner.OnChildItemRemoved(this);
10244 if (new_owner)
10245 new_owner.OnChildItemReceived(this);
10246 }
10247
10248 // -------------------------------------------------------------------------------
10249 override void EEDelete(EntityAI parent)
10250 {
10251 super.EEDelete(parent);
10252 PlayerBase player = PlayerBase.Cast(GetHierarchyRootPlayer());
10253 if (player)
10254 {
10255 OnInventoryExit(player);
10256
10257 if (player.IsAlive())
10258 {
10259 int r_index = player.GetHumanInventory().FindUserReservedLocationIndex(this);
10260 if (r_index >= 0)
10261 {
10262 InventoryLocation r_il = new InventoryLocation;
10263 player.GetHumanInventory().GetUserReservedLocation(r_index,r_il);
10264
10265 player.GetHumanInventory().ClearUserReservedLocationAtIndex(r_index);
10266 int r_type = r_il.GetType();
10267 if (r_type == InventoryLocationType.CARGO || r_type == InventoryLocationType.PROXYCARGO)
10268 {
10269 r_il.GetParent().GetOnReleaseLock().Invoke(this);
10270 }
10271 else if (r_type == InventoryLocationType.ATTACHMENT)
10272 {
10273 r_il.GetParent().GetOnAttachmentReleaseLock().Invoke(this, r_il.GetSlot());
10274 }
10275
10276 }
10277
10278 player.RemoveQuickBarEntityShortcut(this);
10279 }
10280 }
10281 }
10282 // -------------------------------------------------------------------------------
10283 override void EEKilled(Object killer)
10284 {
10285 super.EEKilled(killer);
10286
10288 if (killer && killer.IsFireplace() && CanExplodeInFire())
10289 {
10290 if (GetTemperature() >= GameConstants.ITEM_TEMPERATURE_TO_EXPLODE_MIN)
10291 {
10292 if (IsMagazine())
10293 {
10294 if (Magazine.Cast(this).GetAmmoCount() > 0)
10295 {
10296 ExplodeAmmo();
10297 }
10298 }
10299 else
10300 {
10301 Explode(DamageType.EXPLOSION);
10302 }
10303 }
10304 }
10305 }
10306
10307 override void OnWasAttached(EntityAI parent, int slot_id)
10308 {
10309 MiscGameplayFunctions.RemoveAllAttachedChildrenByTypename(this, {Bolt_Base});
10310
10311 super.OnWasAttached(parent, slot_id);
10312
10313 if (HasQuantity())
10314 UpdateNetSyncVariableFloat("m_VarQuantity", GetQuantityMin(), m_VarQuantityMax);
10315
10316 if (g_Game.IsServer() || !g_Game.IsMultiplayer()) // single player or server side multiplayer
10317 StartItemSoundServer(SoundConstants.ITEM_ATTACH, slot_id);
10318 }
10319
10320 override void OnWasDetached(EntityAI parent, int slot_id)
10321 {
10322 super.OnWasDetached(parent, slot_id);
10323
10324 if (HasQuantity())
10325 UpdateNetSyncVariableFloat("m_VarQuantity", GetQuantityMin(), m_VarQuantityMax);
10326
10327 if (g_Game.IsServer() || !g_Game.IsMultiplayer()) // single player or server side multiplayer
10328 StartItemSoundServer(SoundConstants.ITEM_DETACH, slot_id);
10329 }
10330
10331 override string ChangeIntoOnAttach(string slot)
10332 {
10333 int idx;
10334 TStringArray inventory_slots = new TStringArray;
10335 TStringArray attach_types = new TStringArray;
10336
10337 ConfigGetTextArray("ChangeInventorySlot",inventory_slots);
10338 if (inventory_slots.Count() < 1) //is string
10339 {
10340 inventory_slots.Insert(ConfigGetString("ChangeInventorySlot"));
10341 attach_types.Insert(ConfigGetString("ChangeIntoOnAttach"));
10342 }
10343 else //is array
10344 {
10345 ConfigGetTextArray("ChangeIntoOnAttach",attach_types);
10346 }
10347
10348 idx = inventory_slots.Find(slot);
10349 if (idx < 0)
10350 return "";
10351
10352 return attach_types.Get(idx);
10353 }
10354
10355 override string ChangeIntoOnDetach()
10356 {
10357 int idx = -1;
10358 string slot;
10359
10360 TStringArray inventory_slots = new TStringArray;
10361 TStringArray detach_types = new TStringArray;
10362
10363 this.ConfigGetTextArray("ChangeInventorySlot",inventory_slots);
10364 if (inventory_slots.Count() < 1) //is string
10365 {
10366 inventory_slots.Insert(this.ConfigGetString("ChangeInventorySlot"));
10367 detach_types.Insert(this.ConfigGetString("ChangeIntoOnDetach"));
10368 }
10369 else //is array
10370 {
10371 this.ConfigGetTextArray("ChangeIntoOnDetach",detach_types);
10372 if (detach_types.Count() < 1)
10373 detach_types.Insert(this.ConfigGetString("ChangeIntoOnDetach"));
10374 }
10375
10376 for (int i = 0; i < inventory_slots.Count(); i++)
10377 {
10378 slot = inventory_slots.Get(i);
10379 }
10380
10381 if (slot != "")
10382 {
10383 if (detach_types.Count() == 1)
10384 idx = 0;
10385 else
10386 idx = inventory_slots.Find(slot);
10387 }
10388 if (idx < 0)
10389 return "";
10390
10391 return detach_types.Get(idx);
10392 }
10393
10394 void ExplodeAmmo()
10395 {
10396 //timer
10397 ref Timer explode_timer = new Timer(CALL_CATEGORY_SYSTEM);
10398
10399 //min/max time
10400 float min_time = 1;
10401 float max_time = 3;
10402 float delay = Math.RandomFloat(min_time, max_time);
10403
10404 explode_timer.Run(delay, this, "DoAmmoExplosion");
10405 }
10406
10407 void DoAmmoExplosion()
10408 {
10409 Magazine magazine = Magazine.Cast(this);
10410 int pop_sounds_count = 6;
10411 string pop_sounds[ 6 ] = { "ammopops_1","ammopops_2","ammopops_3","ammopops_4","ammopops_5","ammopops_6" };
10412
10413 //play sound
10414 int sound_idx = Math.RandomInt(0, pop_sounds_count - 1);
10415 string sound_name = pop_sounds[ sound_idx ];
10416 g_Game.CreateSoundOnObject(this, sound_name, 20, false);
10417
10418 //remove ammo count
10419 magazine.ServerAddAmmoCount(-1);
10420
10421 //if condition then repeat -> ExplodeAmmo
10422 float min_temp_to_explode = 100; //min temperature for item to explode
10423
10424 if (magazine.GetAmmoCount() > 0 && GetTemperature() >= min_temp_to_explode) //TODO ? add check for parent -> fireplace
10425 {
10426 ExplodeAmmo();
10427 }
10428 }
10429
10430 // -------------------------------------------------------------------------------
10431 override void EEHitBy(TotalDamageResult damageResult, int damageType, EntityAI source, int component, string dmgZone, string ammo, vector modelPos, float speedCoef)
10432 {
10433 super.EEHitBy(damageResult, damageType, source, component, dmgZone, ammo, modelPos, speedCoef);
10434
10435 const int CHANCE_DAMAGE_CARGO = 4;
10436 const int CHANCE_DAMAGE_ATTACHMENT = 1;
10437 const int CHANCE_DAMAGE_NOTHING = 2;
10438
10439 if (IsClothing() || IsContainer() || IsItemTent())
10440 {
10441 float dmg = damageResult.GetDamage("","Health") * -0.5;
10442 int chances;
10443 int rnd;
10444
10445 if (GetInventory().GetCargo())
10446 {
10447 chances = CHANCE_DAMAGE_CARGO + CHANCE_DAMAGE_ATTACHMENT + CHANCE_DAMAGE_NOTHING;
10448 rnd = Math.RandomInt(0,chances);
10449
10450 if (rnd < CHANCE_DAMAGE_CARGO)
10451 {
10452 DamageItemInCargo(dmg);
10453 }
10454 else if (rnd < (chances - CHANCE_DAMAGE_NOTHING))
10455 {
10457 }
10458 }
10459 else
10460 {
10461 chances = CHANCE_DAMAGE_ATTACHMENT + CHANCE_DAMAGE_NOTHING;
10462 rnd = Math.RandomInt(0,chances);
10463
10464 if (rnd < CHANCE_DAMAGE_ATTACHMENT)
10465 {
10467 }
10468 }
10469 }
10470 }
10471
10472 bool DamageItemInCargo(float damage)
10473 {
10474 CargoBase cargo = GetInventory().GetCargo();
10475 if (cargo)
10476 {
10477 int item_count = cargo.GetItemCount();
10478 if (item_count > 0)
10479 {
10480 int random_pick = Math.RandomInt(0, item_count);
10481 ItemBase item = ItemBase.Cast(cargo.GetItem(random_pick));
10482 if (!item.IsExplosive())
10483 {
10484 item.AddHealth("","",damage);
10485 return true;
10486 }
10487 }
10488 }
10489 return false;
10490 }
10491
10492 bool DamageItemAttachments(float damage)
10493 {
10494 GameInventory inventory = GetInventory();
10495 int attachment_count = inventory.AttachmentCount();
10496 if (attachment_count > 0)
10497 {
10498 int random_pick = Math.RandomInt(0, attachment_count);
10499 ItemBase attachment = ItemBase.Cast(inventory.GetAttachmentFromIndex(random_pick));
10500 if (!attachment.IsExplosive())
10501 {
10502 attachment.AddHealth("","",damage);
10503 return true;
10504 }
10505 }
10506 return false;
10507 }
10508
10509 override bool IsSplitable()
10510 {
10511 return m_CanThisBeSplit;
10512 }
10513 //----------------
10514 override bool CanBeSplit()
10515 {
10516 if (IsSplitable() && (GetQuantity() > 1))
10517 return GetInventory().CanRemoveEntity();
10518
10519 return false;
10520 }
10521
10522 protected bool ShouldSplitQuantity(float quantity)
10523 {
10524 // don't call 'CanBeSplit' here, too strict and will introduce a freeze-crash when dismantling fence with a fireplace nearby
10525 if (!IsSplitable())
10526 return false;
10527
10528 // nothing to split?
10529 if (GetQuantity() <= 1)
10530 return false;
10531
10532 // check if we should re-use the item instead of creating a new copy?
10533 // implicit cast to int, if 'IsSplitable' returns true, these values are assumed ints
10534 int delta = GetQuantity() - quantity;
10535 if (delta == 0)
10536 return false;
10537
10538 // valid to split
10539 return true;
10540 }
10541
10542 override void SplitIntoStackMaxClient(EntityAI destination_entity, int slot_id )
10543 {
10544 if (g_Game.IsClient())
10545 {
10546 if (ScriptInputUserData.CanStoreInputUserData())
10547 {
10548 ScriptInputUserData ctx = new ScriptInputUserData;
10550 ctx.Write(1);
10551 ItemBase i1 = this; // @NOTE: workaround for correct serialization
10552 ctx.Write(i1);
10553 ctx.Write(destination_entity);
10554 ctx.Write(true);
10555 ctx.Write(slot_id);
10556 ctx.Send();
10557 }
10558 }
10559 else if (!g_Game.IsMultiplayer())
10560 {
10561 SplitIntoStackMax(destination_entity, slot_id, PlayerBase.Cast(g_Game.GetPlayer()));
10562 }
10563 }
10564
10565 void SplitIntoStackMax(EntityAI destination_entity, int slot_id, PlayerBase player)
10566 {
10567 float split_quantity_new;
10568 ItemBase new_item;
10569 float quantity = GetQuantity();
10570 float stack_max = GetTargetQuantityMax(slot_id);
10571 InventoryLocation loc = new InventoryLocation;
10572
10573 if (destination_entity && slot_id != -1 && InventorySlots.IsSlotIdValid(slot_id))
10574 {
10575 if (stack_max <= GetQuantity())
10576 split_quantity_new = stack_max;
10577 else
10578 split_quantity_new = GetQuantity();
10579
10580 if (ShouldSplitQuantity(split_quantity_new))
10581 {
10582 new_item = ItemBase.Cast(destination_entity.GetInventory().CreateAttachmentEx(this.GetType(), slot_id));
10583 if (new_item)
10584 {
10585 new_item.SetResultOfSplit(true);
10586 MiscGameplayFunctions.TransferItemProperties(this, new_item);
10587 AddQuantity(-split_quantity_new, false, true);
10588 new_item.SetQuantity(split_quantity_new, false, true);
10589 }
10590 }
10591 }
10592 else if (destination_entity && slot_id == -1)
10593 {
10594 if (quantity > stack_max)
10595 split_quantity_new = stack_max;
10596 else
10597 split_quantity_new = quantity;
10598
10599 if (ShouldSplitQuantity(split_quantity_new))
10600 {
10601 GameInventory destinationInventory = destination_entity.GetInventory();
10602 if (destinationInventory.FindFreeLocationFor(this, FindInventoryLocationType.ANY, loc))
10603 {
10604 Object o = destinationInventory.LocationCreateEntity(loc, GetType(), ECE_IN_INVENTORY, RF_DEFAULT);
10605 new_item = ItemBase.Cast(o);
10606 }
10607
10608 if (new_item)
10609 {
10610 new_item.SetResultOfSplit(true);
10611 MiscGameplayFunctions.TransferItemProperties(this, new_item);
10612 AddQuantity(-split_quantity_new, false, true);
10613 new_item.SetQuantity(split_quantity_new, false, true);
10614 }
10615 }
10616 }
10617 else
10618 {
10619 if (stack_max != 0)
10620 {
10621 if (stack_max < GetQuantity())
10622 {
10623 split_quantity_new = GetQuantity() - stack_max;
10624 }
10625
10626 if (split_quantity_new == 0)
10627 {
10628 if (!g_Game.IsMultiplayer())
10629 player.PhysicalPredictiveDropItem(this);
10630 else
10631 player.ServerDropEntity(this);
10632 return;
10633 }
10634
10635 if (ShouldSplitQuantity(split_quantity_new))
10636 {
10637 new_item = ItemBase.Cast(g_Game.CreateObjectEx(GetType(), player.GetWorldPosition(), ECE_PLACE_ON_SURFACE));
10638
10639 if (new_item)
10640 {
10641 new_item.SetResultOfSplit(true);
10642 MiscGameplayFunctions.TransferItemProperties(this, new_item);
10643 SetQuantity(split_quantity_new, false, true);
10644 new_item.SetQuantity(stack_max, false, true);
10645 new_item.PlaceOnSurface();
10646 }
10647 }
10648 }
10649 }
10650 }
10651
10652 override void SplitIntoStackMaxEx(EntityAI destination_entity, int slot_id)
10653 {
10654 float split_quantity_new;
10655 ItemBase new_item;
10656 float quantity = GetQuantity();
10657 float stack_max = GetTargetQuantityMax(slot_id);
10658 InventoryLocation loc = new InventoryLocation;
10659
10660 if (destination_entity && slot_id != -1 && InventorySlots.IsSlotIdValid(slot_id))
10661 {
10662 if (stack_max <= GetQuantity())
10663 split_quantity_new = stack_max;
10664 else
10665 split_quantity_new = GetQuantity();
10666
10667 if (ShouldSplitQuantity(split_quantity_new))
10668 {
10669 new_item = ItemBase.Cast(destination_entity.GetInventory().CreateAttachmentEx(this.GetType(), slot_id));
10670 if (new_item)
10671 {
10672 new_item.SetResultOfSplit(true);
10673 MiscGameplayFunctions.TransferItemProperties(this, new_item);
10674 AddQuantity(-split_quantity_new, false, true);
10675 new_item.SetQuantity(split_quantity_new, false, true);
10676 }
10677 }
10678 }
10679 else if (destination_entity && slot_id == -1)
10680 {
10681 if (quantity > stack_max)
10682 split_quantity_new = stack_max;
10683 else
10684 split_quantity_new = quantity;
10685
10686 if (ShouldSplitQuantity(split_quantity_new))
10687 {
10688 GameInventory destinationInventory = destination_entity.GetInventory();
10689 if (destinationInventory.FindFreeLocationFor(this, FindInventoryLocationType.ANY, loc))
10690 {
10691 Object o = destinationInventory.LocationCreateEntity(loc, GetType(), ECE_IN_INVENTORY, RF_DEFAULT);
10692 new_item = ItemBase.Cast(o);
10693 }
10694
10695 if (new_item)
10696 {
10697 new_item.SetResultOfSplit(true);
10698 MiscGameplayFunctions.TransferItemProperties(this, new_item);
10699 AddQuantity(-split_quantity_new, false, true);
10700 new_item.SetQuantity(split_quantity_new, false, true);
10701 }
10702 }
10703 }
10704 else
10705 {
10706 if (stack_max != 0)
10707 {
10708 if (stack_max < GetQuantity())
10709 {
10710 split_quantity_new = GetQuantity() - stack_max;
10711 }
10712
10713 if (ShouldSplitQuantity(split_quantity_new))
10714 {
10715 new_item = ItemBase.Cast(g_Game.CreateObjectEx(GetType(),GetWorldPosition(), ECE_PLACE_ON_SURFACE));
10716
10717 if (new_item)
10718 {
10719 new_item.SetResultOfSplit(true);
10720 MiscGameplayFunctions.TransferItemProperties(this, new_item);
10721 SetQuantity(split_quantity_new, false, true);
10722 new_item.SetQuantity(stack_max, false, true);
10723 new_item.PlaceOnSurface();
10724 }
10725 }
10726 }
10727 }
10728 }
10729
10730 void SplitIntoStackMaxToInventoryLocationClient(notnull InventoryLocation dst)
10731 {
10732 if (g_Game.IsClient())
10733 {
10734 if (ScriptInputUserData.CanStoreInputUserData())
10735 {
10736 ScriptInputUserData ctx = new ScriptInputUserData;
10738 ctx.Write(4);
10739 ItemBase thiz = this; // @NOTE: workaround for correct serialization
10740 ctx.Write(thiz);
10741 dst.WriteToContext(ctx);
10742 ctx.Send();
10743 }
10744 }
10745 else if (!g_Game.IsMultiplayer())
10746 {
10748 }
10749 }
10750
10751 void SplitIntoStackMaxCargoClient(EntityAI destination_entity, int idx, int row, int col)
10752 {
10753 if (g_Game.IsClient())
10754 {
10755 if (ScriptInputUserData.CanStoreInputUserData())
10756 {
10757 ScriptInputUserData ctx = new ScriptInputUserData;
10759 ctx.Write(2);
10760 ItemBase dummy = this; // @NOTE: workaround for correct serialization
10761 ctx.Write(dummy);
10762 ctx.Write(destination_entity);
10763 ctx.Write(true);
10764 ctx.Write(idx);
10765 ctx.Write(row);
10766 ctx.Write(col);
10767 ctx.Send();
10768 }
10769 }
10770 else if (!g_Game.IsMultiplayer())
10771 {
10772 SplitIntoStackMaxCargo(destination_entity, idx, row, col);
10773 }
10774 }
10775
10776 void SplitIntoStackMaxToInventoryLocation(notnull InventoryLocation dst)
10777 {
10779 }
10780
10781 ItemBase SplitIntoStackMaxToInventoryLocationEx(notnull InventoryLocation dst)
10782 {
10783 float quantity = GetQuantity();
10784 float split_quantity_new;
10785 ItemBase new_item;
10786 if (dst.IsValid())
10787 {
10788 int slot_id = dst.GetSlot();
10789 float stack_max = GetTargetQuantityMax(slot_id);
10790
10791 if (quantity > stack_max)
10792 split_quantity_new = stack_max;
10793 else
10794 split_quantity_new = quantity;
10795
10796 if (ShouldSplitQuantity(split_quantity_new))
10797 {
10798 new_item = ItemBase.Cast(GameInventory.LocationCreateEntity(dst, this.GetType(), ECE_IN_INVENTORY, RF_DEFAULT));
10799
10800 if (new_item)
10801 {
10802 new_item.SetResultOfSplit(true);
10803 MiscGameplayFunctions.TransferItemProperties(this,new_item);
10804 AddQuantity(-split_quantity_new, false, true);
10805 new_item.SetQuantity(split_quantity_new, false, true);
10806 }
10807
10808 return new_item;
10809 }
10810 }
10811
10812 return null;
10813 }
10814
10815 void SplitIntoStackMaxCargo(EntityAI destination_entity, int idx, int row, int col)
10816 {
10817 float quantity = GetQuantity();
10818 float split_quantity_new;
10819 ItemBase new_item;
10820 if (destination_entity)
10821 {
10822 float stackable = GetTargetQuantityMax();
10823 if (quantity > stackable)
10824 split_quantity_new = stackable;
10825 else
10826 split_quantity_new = quantity;
10827
10828 if (ShouldSplitQuantity(split_quantity_new))
10829 {
10830 new_item = ItemBase.Cast(destination_entity.GetInventory().CreateEntityInCargoEx(this.GetType(), idx, row, col, false));
10831 if (new_item)
10832 {
10833 new_item.SetResultOfSplit(true);
10834 MiscGameplayFunctions.TransferItemProperties(this,new_item);
10835 AddQuantity(-split_quantity_new, false, true);
10836 new_item.SetQuantity(split_quantity_new, false, true);
10837 }
10838 }
10839 }
10840 }
10841
10842 void SplitIntoStackMaxHandsClient(PlayerBase player)
10843 {
10844 if (g_Game.IsClient())
10845 {
10846 if (ScriptInputUserData.CanStoreInputUserData())
10847 {
10848 ScriptInputUserData ctx = new ScriptInputUserData;
10850 ctx.Write(3);
10851 ItemBase i1 = this; // @NOTE: workaround for correct serialization
10852 ctx.Write(i1);
10853 ItemBase destination_entity = this;
10854 ctx.Write(destination_entity);
10855 ctx.Write(true);
10856 ctx.Write(0);
10857 ctx.Send();
10858 }
10859 }
10860 else if (!g_Game.IsMultiplayer())
10861 {
10862 SplitIntoStackMaxHands(player);
10863 }
10864 }
10865
10866 void SplitIntoStackMaxHands(PlayerBase player)
10867 {
10868 float quantity = GetQuantity();
10869 float split_quantity_new;
10870 ref ItemBase new_item;
10871 if (player)
10872 {
10873 float stackable = GetTargetQuantityMax();
10874 if (quantity > stackable)
10875 split_quantity_new = stackable;
10876 else
10877 split_quantity_new = quantity;
10878
10879 if (ShouldSplitQuantity(split_quantity_new))
10880 {
10881 EntityAI in_hands = player.GetHumanInventory().CreateInHands(this.GetType());
10882 new_item = ItemBase.Cast(in_hands);
10883 if (new_item)
10884 {
10885 new_item.SetResultOfSplit(true);
10886 MiscGameplayFunctions.TransferItemProperties(this,new_item);
10887 AddQuantity(-split_quantity_new, false, true);
10888 new_item.SetQuantity(split_quantity_new, false, true);
10889 }
10890 }
10891 }
10892 }
10893
10894 void SplitItemToInventoryLocation(notnull InventoryLocation dst)
10895 {
10896 float quantity = GetQuantity();
10897 float split_quantity_new = Math.Floor(quantity * 0.5);
10898
10899 if (!ShouldSplitQuantity(split_quantity_new))
10900 return;
10901
10902 ItemBase new_item = ItemBase.Cast(GameInventory.LocationCreateEntity(dst, GetType(), ECE_IN_INVENTORY, RF_DEFAULT));
10903
10904 if (new_item)
10905 {
10906 if (new_item.GetQuantityMax() < split_quantity_new)
10907 {
10908 split_quantity_new = new_item.GetQuantityMax();
10909 }
10910
10911 new_item.SetResultOfSplit(true);
10912 MiscGameplayFunctions.TransferItemProperties(this, new_item);
10913
10914 if (dst.IsValid() && dst.GetType() == InventoryLocationType.ATTACHMENT && split_quantity_new > 1)
10915 {
10916 AddQuantity(-1, false, true);
10917 new_item.SetQuantity(1, false, true);
10918 }
10919 else
10920 {
10921 AddQuantity(-split_quantity_new, false, true);
10922 new_item.SetQuantity(split_quantity_new, false, true);
10923 }
10924 }
10925 }
10926
10927 void SplitItem(PlayerBase player)
10928 {
10929 float quantity = GetQuantity();
10930 float split_quantity_new = Math.Floor(quantity / 2);
10931
10932 if (!ShouldSplitQuantity(split_quantity_new))
10933 return;
10934
10935 InventoryLocation invloc = new InventoryLocation;
10936 bool found = player.GetInventory().FindFirstFreeLocationForNewEntity(GetType(), FindInventoryLocationType.ATTACHMENT, invloc);
10937
10938 ItemBase new_item;
10939 new_item = player.CreateCopyOfItemInInventoryOrGroundEx(this, true);
10940
10941 if (new_item)
10942 {
10943 if (new_item.GetQuantityMax() < split_quantity_new)
10944 {
10945 split_quantity_new = new_item.GetQuantityMax();
10946 }
10947 if (found && invloc.IsValid() && invloc.GetType() == InventoryLocationType.ATTACHMENT && split_quantity_new > 1)
10948 {
10949 AddQuantity(-1, false, true);
10950 new_item.SetQuantity(1, false, true);
10951 }
10952 else if (split_quantity_new > 1)
10953 {
10954 AddQuantity(-split_quantity_new, false, true);
10955 new_item.SetQuantity(split_quantity_new, false, true);
10956 }
10957 }
10958 }
10959
10961 void OnQuantityChanged(float delta)
10962 {
10963 SetWeightDirty();
10964 ItemBase parent = ItemBase.Cast(GetHierarchyParent());
10965
10966 if (parent)
10967 parent.OnAttachmentQuantityChangedEx(this, delta);
10968
10969 if (IsLiquidContainer())
10970 {
10971 if (GetQuantityNormalized() <= 0.0)
10972 {
10974 }
10975 else if (GetLiquidType() == LIQUID_NONE)
10976 {
10977 ErrorEx("Undefined liquid type quantity changed, please define liquid type first! Using init value.",ErrorExSeverity.INFO);
10979 }
10980 }
10981 }
10982
10985 {
10986 // insert code here
10987 }
10988
10990 void OnAttachmentQuantityChangedEx(ItemBase item , float delta)
10991 {
10993 }
10994
10995 override void EEHealthLevelChanged(int oldLevel, int newLevel, string zone)
10996 {
10997 super.EEHealthLevelChanged(oldLevel,newLevel,zone);
10998
10999 if (g_Game.IsServer())
11000 {
11001 if (newLevel == GameConstants.STATE_RUINED)
11002 {
11004 EntityAI parent = GetHierarchyParent();
11005 if (parent && parent.IsFireplace())
11006 {
11007 CargoBase cargo = GetInventory().GetCargo();
11008 if (cargo)
11009 {
11010 for (int i = 0; i < cargo.GetItemCount(); ++i)
11011 {
11012 parent.GetInventory().TakeEntityToInventory(InventoryMode.SERVER, FindInventoryLocationType.CARGO, cargo.GetItem(i));
11013 }
11014 }
11015 }
11016 }
11017
11018 if (IsResultOfSplit())
11019 {
11020 // reset the splitting result flag, return to normal item behavior
11021 SetResultOfSplit(false);
11022 return;
11023 }
11024
11025 if (m_Cleanness != 0 && oldLevel < newLevel && newLevel != 0)
11026 {
11027 SetCleanness(0);//unclean the item upon damage dealt
11028 }
11029 }
11030 }
11031
11032 // just the split? TODO: verify
11033 override void OnRightClick()
11034 {
11035 super.OnRightClick();
11036
11037 if (CanBeSplit() && !GetDayZGame().IsLeftCtrlDown() && !g_Game.GetPlayer().GetInventory().HasInventoryReservation(this,null))
11038 {
11039 if (g_Game.IsClient())
11040 {
11041 if (ScriptInputUserData.CanStoreInputUserData())
11042 {
11043 EntityAI root = GetHierarchyRoot();
11044 Man playerOwner = GetHierarchyRootPlayer();
11045 InventoryLocation dst = new InventoryLocation;
11046
11047 // If we have no hierarchy root player and the root is the same as this item the source item is in the vicinity so we want to create the new split item there also
11048 if (!playerOwner && root && root == this)
11049 {
11051 }
11052 else
11053 {
11054 // Check if we can place the new split item in the same parent where the source item is placed in or otherwise drop it in vicinity
11055 GetInventory().GetCurrentInventoryLocation(dst);
11056 if (!dst.GetParent() || dst.GetParent() && !dst.GetParent().GetInventory().FindFreeLocationFor(this, FindInventoryLocationType.CARGO, dst))
11057 {
11058 PlayerBase player = PlayerBase.Cast(g_Game.GetPlayer());
11059 if (!player.GetInventory().FindFreeLocationFor(this, FindInventoryLocationType.CARGO, dst) || !playerOwner)
11060 {
11062 }
11063 else
11064 {
11065 dst.SetCargo(dst.GetParent(), this, dst.GetIdx(), dst.GetRow(), dst.GetCol(), dst.GetFlip());
11066 /* hacky solution to check reservation of "this" item instead of null since the gamecode is checking null against null and returning reservation=true incorrectly
11067 this shouldnt cause issues within this scope*/
11068 if (g_Game.GetPlayer().GetInventory().HasInventoryReservation(this, dst))
11069 {
11071 }
11072 else
11073 {
11074 g_Game.GetPlayer().GetInventory().AddInventoryReservationEx(null, dst, GameInventory.c_InventoryReservationTimeoutShortMS);
11075 }
11076 }
11077 }
11078 }
11079
11080 ScriptInputUserData ctx = new ScriptInputUserData;
11082 ctx.Write(4);
11083 ItemBase thiz = this; // @NOTE: workaround for correct serialization
11084 ctx.Write(thiz);
11085 dst.WriteToContext(ctx);
11086 ctx.Write(true); // dummy
11087 ctx.Send();
11088 }
11089 }
11090 else if (!g_Game.IsMultiplayer())
11091 {
11092 SplitItem(PlayerBase.Cast(g_Game.GetPlayer()));
11093 }
11094 }
11095 }
11096
11097 protected void SetInventoryLocationToVicinityOrCurrent(EntityAI root, inout InventoryLocation dst)
11098 {
11099 if (root)
11100 {
11101 vector m4[4];
11102 root.GetTransform(m4);
11103 dst.SetGround(this, m4);
11104 }
11105 else
11106 {
11107 GetInventory().GetCurrentInventoryLocation(dst);
11108 }
11109 }
11110
11111 override bool CanBeCombined(EntityAI other_item, bool reservation_check = true, bool stack_max_limit = false)
11112 {
11113 //TODO: delete check zero quantity check after fix double posts hands fsm events
11114 if (!other_item || GetType() != other_item.GetType() || (IsFullQuantity() && other_item.GetQuantity() > 0) || other_item == this)
11115 return false;
11116
11117 if (GetHealthLevel() == GameConstants.STATE_RUINED || other_item.GetHealthLevel() == GameConstants.STATE_RUINED)
11118 return false;
11119
11120 //can_this_be_combined = ConfigGetBool("canBeSplit");
11122 return false;
11123
11124
11125 Magazine mag = Magazine.Cast(this);
11126 if (mag)
11127 {
11128 if (mag.GetAmmoCount() >= mag.GetAmmoMax())
11129 return false;
11130
11131 if (stack_max_limit)
11132 {
11133 Magazine other_mag = Magazine.Cast(other_item);
11134 if (other_item)
11135 {
11136 if (mag.GetAmmoCount() + other_mag.GetAmmoCount() > mag.GetAmmoMax())
11137 return false;
11138 }
11139
11140 }
11141 }
11142 else
11143 {
11144 //TODO: delete check zero quantity check after fix double posts hands fsm events
11145 if (GetQuantity() >= GetQuantityMax() && other_item.GetQuantity() > 0 )
11146 return false;
11147
11148 if (stack_max_limit && (GetQuantity() + other_item.GetQuantity() > GetQuantityMax()))
11149 return false;
11150 }
11151
11152 PlayerBase player = null;
11153 if (CastTo(player, GetHierarchyRootPlayer())) //false when attached to player's attachment slot
11154 {
11155 if (player.GetInventory().HasAttachment(this))
11156 return false;
11157
11158 if (player.IsItemsToDelete())
11159 return false;
11160 }
11161
11162 if (reservation_check && (GetInventory().HasInventoryReservation(this, null) || other_item.GetInventory().HasInventoryReservation(other_item, null)))
11163 return false;
11164
11165 int slotID;
11166 string slotName;
11167 if (GetInventory().GetCurrentAttachmentSlotInfo(slotID,slotName) && GetHierarchyParent().GetInventory().GetSlotLock(slotID))
11168 return false;
11169
11170 return true;
11171 }
11172
11173 bool IsCombineAll(ItemBase other_item, bool use_stack_max = false)
11174 {
11175 return ComputeQuantityUsed(other_item, use_stack_max) == other_item.GetQuantity();
11176 }
11177
11178 bool IsResultOfSplit()
11179 {
11180 return m_IsResultOfSplit;
11181 }
11182
11183 void SetResultOfSplit(bool value)
11184 {
11185 m_IsResultOfSplit = value;
11186 }
11187
11188 int ComputeQuantityUsed(ItemBase other_item, bool use_stack_max = true)
11189 {
11190 return ComputeQuantityUsedEx(other_item, use_stack_max);
11191 }
11192
11193 float ComputeQuantityUsedEx(ItemBase other_item, bool use_stack_max = true)
11194 {
11195 float other_item_quantity = other_item.GetQuantity();
11196 float this_free_space;
11197
11198 float stack_max = GetQuantityMax();
11199
11200 this_free_space = stack_max - GetQuantity();
11201
11202 if (other_item_quantity > this_free_space)
11203 {
11204 return this_free_space;
11205 }
11206 else
11207 {
11208 return other_item_quantity;
11209 }
11210 }
11211
11212 override void CombineItemsEx(EntityAI entity2, bool use_stack_max = true)
11213 {
11214 CombineItems(ItemBase.Cast(entity2),use_stack_max);
11215 }
11216
11217 void CombineItems(ItemBase other_item, bool use_stack_max = true)
11218 {
11219 if (!CanBeCombined(other_item, false))
11220 return;
11221
11222 if (!IsMagazine() && other_item)
11223 {
11224 float quantity_used = ComputeQuantityUsedEx(other_item,use_stack_max);
11225 if (quantity_used != 0)
11226 {
11227 float hp1 = GetHealth01("","");
11228 float hp2 = other_item.GetHealth01("","");
11229 float hpResult = ((hp1*GetQuantity()) + (hp2*quantity_used));
11230 hpResult = hpResult / (GetQuantity() + quantity_used);
11231
11232 hpResult *= GetMaxHealth();
11233 Math.Round(hpResult);
11234 SetHealth("", "Health", hpResult);
11235
11236 AddQuantity(quantity_used);
11237 other_item.AddQuantity(-quantity_used);
11238 }
11239 }
11240 OnCombine(other_item);
11241 }
11242
11243 void OnCombine(ItemBase other_item)
11244 {
11245 #ifdef SERVER
11246 if (!GetHierarchyRootPlayer() && GetHierarchyParent())
11247 GetHierarchyParent().IncreaseLifetimeUp();
11248 #endif
11249 };
11250
11251 void GetRecipesActions(Man player, out TSelectableActionInfoArray outputList)
11252 {
11253 PlayerBase p = PlayerBase.Cast(player);
11254
11255 array<int> recipesIds = p.m_Recipes;
11256 PluginRecipesManager moduleRecipesManager = PluginRecipesManager.Cast(GetPlugin(PluginRecipesManager));
11257 if (moduleRecipesManager)
11258 {
11259 EntityAI itemInHands = player.GetEntityInHands();
11260 moduleRecipesManager.GetValidRecipes(ItemBase.Cast(this), ItemBase.Cast(itemInHands), recipesIds, p);
11261 }
11262
11263 for (int i = 0;i < recipesIds.Count(); i++)
11264 {
11265 int key = recipesIds.Get(i);
11266 string recipeName = moduleRecipesManager.GetRecipeName(key);
11267 outputList.Insert(new TSelectableActionInfo(SAT_CRAFTING, key, recipeName));
11268 }
11269 }
11270
11271 // -------------------------------------------------------------------------
11272 override void GetDebugActions(out TSelectableActionInfoArrayEx outputList)
11273 {
11274 super.GetDebugActions(outputList);
11275
11276 //quantity
11277 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.ADD_QUANTITY, "Quantity +20%", FadeColors.LIGHT_GREY));
11278 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.REMOVE_QUANTITY, "Quantity -20%", FadeColors.LIGHT_GREY));
11279 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SET_QUANTITY_0, "Set Quantity 0", FadeColors.LIGHT_GREY));
11280 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SET_MAX_QUANTITY, "Set Quantity Max", FadeColors.LIGHT_GREY));
11281 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SEPARATOR, "___________________________", FadeColors.RED));
11282
11283 //health
11284 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.ADD_HEALTH, "Health +20%", FadeColors.LIGHT_GREY));
11285 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.REMOVE_HEALTH, "Health -20%", FadeColors.LIGHT_GREY));
11286 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.DESTROY_HEALTH, "Health 0", FadeColors.LIGHT_GREY));
11287 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SEPARATOR, "___________________________", FadeColors.RED));
11288 //temperature
11289 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.ADD_TEMPERATURE, "Temperature +20", FadeColors.LIGHT_GREY));
11290 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.REMOVE_TEMPERATURE, "Temperature -20", FadeColors.LIGHT_GREY));
11291 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.FLIP_FROZEN, "Toggle Frozen", FadeColors.LIGHT_GREY));
11292 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SEPARATOR, "___________________________", FadeColors.RED));
11293
11294 //wet
11295 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.ADD_WETNESS, "Wetness +20", FadeColors.LIGHT_GREY));
11296 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.REMOVE_WETNESS, "Wetness -20", FadeColors.LIGHT_GREY));
11297 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SEPARATOR, "___________________________", FadeColors.RED));
11298
11299 //liquidtype
11300 if (IsLiquidContainer())
11301 {
11302 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.LIQUIDTYPE_UP, "LiquidType Next", FadeColors.LIGHT_GREY));
11303 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.LIQUIDTYPE_DOWN, "LiquidType Previous", FadeColors.LIGHT_GREY));
11304 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SEPARATOR, "___________________________", FadeColors.RED));
11305 }
11306
11307 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.MAKE_SPECIAL, "Make Special", FadeColors.LIGHT_GREY));
11308 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SEPARATOR, "___________________________", FadeColors.RED));
11309
11310 // watch
11311 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.WATCH_ITEM, "Watch (CTRL-Z)", FadeColors.LIGHT_GREY));
11312 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.WATCH_PLAYER, "Watch Player", FadeColors.LIGHT_GREY));
11313 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SEPARATOR, "___________________________", FadeColors.RED));
11314
11315 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.DELETE, "Delete", FadeColors.RED));
11316
11317 InventoryLocation loc = new InventoryLocation();
11318 GetInventory().GetCurrentInventoryLocation(loc);
11319 if (!loc || loc.GetType() == InventoryLocationType.GROUND)
11320 {
11321 if (Gizmo_IsSupported())
11322 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.GIZMO_OBJECT, "Gizmo Object", FadeColors.LIGHT_GREY));
11323 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.GIZMO_PHYSICS, "Gizmo Physics (SP Only)", FadeColors.LIGHT_GREY)); // intentionally allowed for testing physics desync
11324 }
11325
11326 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SEPARATOR, "___________________________", FadeColors.RED));
11327 }
11328
11329 // -------------------------------------------------------------------------
11330 // -------------------------------------------------------------------------
11331 // -------------------------------------------------------------------------
11332 override bool OnAction(int action_id, Man player, ParamsReadContext ctx)
11333 {
11334 super.OnAction(action_id, player, ctx);
11335
11336 if (g_Game.IsClient() || !g_Game.IsMultiplayer())
11337 {
11338 switch (action_id)
11339 {
11340 case EActions.GIZMO_OBJECT:
11341 if (GetGizmoApi())
11342 GetGizmoApi().SelectObject(this);
11343 return true;
11344 case EActions.GIZMO_PHYSICS:
11345 if (GetGizmoApi())
11346 GetGizmoApi().SelectPhysics(GetPhysics());
11347 return true;
11348 }
11349 }
11350
11351 if (g_Game.IsServer())
11352 {
11353 switch (action_id)
11354 {
11355 case EActions.DELETE:
11356 Delete();
11357 return true;
11358 }
11359 }
11360
11361 if (action_id >= EActions.RECIPES_RANGE_START && action_id < EActions.RECIPES_RANGE_END)
11362 {
11363 PluginRecipesManager plugin_recipes_manager = PluginRecipesManager.Cast(GetPlugin(PluginRecipesManager));
11364 int idWithoutOffset = action_id - EActions.RECIPES_RANGE_START;
11365 PlayerBase p = PlayerBase.Cast(player);
11366 if (EActions.RECIPES_RANGE_START < 1000)
11367 {
11368 float anim_length = plugin_recipes_manager.GetRecipeLengthInSecs(idWithoutOffset);
11369 float specialty_weight = plugin_recipes_manager.GetRecipeSpecialty(idWithoutOffset);
11370 }
11371 }
11372 #ifndef SERVER
11373 else if (action_id == EActions.WATCH_PLAYER)
11374 {
11375 PluginDeveloper.SetDeveloperItemClientEx(player);
11376 }
11377 #endif
11378 if (g_Game.IsServer())
11379 {
11380 if (action_id >= EActions.DEBUG_ITEM_WATCH_BUTTON_RANGE_START && action_id < EActions.DEBUG_ITEM_WATCH_BUTTON_RANGE_END)
11381 {
11382 int id = action_id - EActions.DEBUG_ITEM_WATCH_BUTTON_RANGE_START;
11383 OnDebugButtonPressServer(id + 1);
11384 }
11385
11386 else if (action_id >= EActions.DEBUG_AGENTS_RANGE_INJECT_START && action_id < EActions.DEBUG_AGENTS_RANGE_INJECT_END)
11387 {
11388 int agent_id = action_id - EActions.DEBUG_AGENTS_RANGE_INJECT_START;
11389 InsertAgent(agent_id,100);
11390 }
11391
11392 else if (action_id >= EActions.DEBUG_AGENTS_RANGE_REMOVE_START && action_id < EActions.DEBUG_AGENTS_RANGE_REMOVE_END)
11393 {
11394 int agent_id2 = action_id - EActions.DEBUG_AGENTS_RANGE_REMOVE_START;
11395 RemoveAgent(agent_id2);
11396 }
11397
11398 else if (action_id == EActions.ADD_QUANTITY)
11399 {
11400 if (IsMagazine())
11401 {
11402 Magazine mag = Magazine.Cast(this);
11403 mag.ServerSetAmmoCount(mag.GetAmmoCount() + mag.GetAmmoMax() * 0.2);
11404 }
11405 else
11406 {
11407 AddQuantity(GetQuantityMax() * 0.2);
11408 }
11409
11410 if (m_EM)
11411 {
11412 m_EM.AddEnergy(m_EM.GetEnergyMax() * 0.2);
11413 }
11414 //PrintVariables();
11415 }
11416
11417 else if (action_id == EActions.REMOVE_QUANTITY) //Quantity -20%
11418 {
11419 if (IsMagazine())
11420 {
11421 Magazine mag2 = Magazine.Cast(this);
11422 mag2.ServerSetAmmoCount(mag2.GetAmmoCount() - mag2.GetAmmoMax() * 0.2);
11423 }
11424 else
11425 {
11426 AddQuantity(- GetQuantityMax() * 0.2);
11427 }
11428 if (m_EM)
11429 {
11430 m_EM.AddEnergy(- m_EM.GetEnergyMax() * 0.2);
11431 }
11432 //PrintVariables();
11433 }
11434
11435 else if (action_id == EActions.SET_QUANTITY_0) //SetMaxQuantity
11436 {
11437 SetQuantity(0);
11438
11439 if (m_EM)
11440 {
11441 m_EM.SetEnergy(0);
11442 }
11443 }
11444
11445 else if (action_id == EActions.SET_MAX_QUANTITY) //SetMaxQuantity
11446 {
11448
11449 if (m_EM)
11450 {
11451 m_EM.SetEnergy(m_EM.GetEnergyMax());
11452 }
11453 }
11454
11455 else if (action_id == EActions.ADD_HEALTH)
11456 {
11457 AddHealth("","",GetMaxHealth("","Health")/5);
11458 }
11459 else if (action_id == EActions.REMOVE_HEALTH)
11460 {
11461 AddHealth("","",-GetMaxHealth("","Health")/5);
11462 }
11463 else if (action_id == EActions.DESTROY_HEALTH)
11464 {
11465 SetHealth01("","",0);
11466 }
11467 else if (action_id == EActions.WATCH_ITEM)
11468 {
11470 mid.RegisterDebugItem(ItemBase.Cast(this), PlayerBase.Cast(player));
11471 #ifdef DEVELOPER
11472 SetDebugDeveloper_item(this);
11473 #endif
11474 }
11475
11476 else if (action_id == EActions.ADD_TEMPERATURE)
11477 {
11478 AddTemperature(20);
11479 //PrintVariables();
11480 }
11481
11482 else if (action_id == EActions.REMOVE_TEMPERATURE)
11483 {
11484 AddTemperature(-20);
11485 //PrintVariables();
11486 }
11487
11488 else if (action_id == EActions.FLIP_FROZEN)
11489 {
11490 SetFrozen(!GetIsFrozen());
11491 //PrintVariables();
11492 }
11493
11494 else if (action_id == EActions.ADD_WETNESS)
11495 {
11496 AddWet(GetWetMax()/5);
11497 //PrintVariables();
11498 }
11499
11500 else if (action_id == EActions.REMOVE_WETNESS)
11501 {
11502 AddWet(-GetWetMax()/5);
11503 //PrintVariables();
11504 }
11505
11506 else if (action_id == EActions.LIQUIDTYPE_UP)
11507 {
11508 int curr_type = GetLiquidType();
11509 SetLiquidType(curr_type * 2);
11510 //AddWet(1);
11511 //PrintVariables();
11512 }
11513
11514 else if (action_id == EActions.LIQUIDTYPE_DOWN)
11515 {
11516 int curr_type2 = GetLiquidType();
11517 SetLiquidType(curr_type2 / 2);
11518 }
11519
11520 else if (action_id == EActions.MAKE_SPECIAL)
11521 {
11522 auto debugParams = DebugSpawnParams.WithPlayer(player);
11523 OnDebugSpawnEx(debugParams);
11524 }
11525
11526 }
11527
11528
11529 return false;
11530 }
11531
11532 // -------------------------------------------------------------------------
11533
11534
11537 void OnActivatedByTripWire();
11538
11540 void OnActivatedByItem(notnull ItemBase item);
11541
11542 //----------------------------------------------------------------
11543 //returns true if item is able to explode when put in fire
11544 bool CanExplodeInFire()
11545 {
11546 return false;
11547 }
11548
11549 //----------------------------------------------------------------
11550 bool CanEat()
11551 {
11552 return true;
11553 }
11554
11555 //----------------------------------------------------------------
11556 override bool IsIgnoredByConstruction()
11557 {
11558 return true;
11559 }
11560
11561 //----------------------------------------------------------------
11562 //has FoodStages in config?
11563 bool HasFoodStage()
11564 {
11565 string config_path = string.Format("CfgVehicles %1 Food FoodStages", GetType());
11566 return g_Game.ConfigIsExisting(config_path);
11567 }
11568
11570 FoodStage GetFoodStage()
11571 {
11572 return null;
11573 }
11574
11575 bool CanBeCooked()
11576 {
11577 return false;
11578 }
11579
11580 bool CanBeCookedOnStick()
11581 {
11582 return false;
11583 }
11584
11586 void RefreshAudioVisualsOnClient( CookingMethodType cooking_method, bool is_done, bool is_empty, bool is_burned );
11588
11589 //----------------------------------------------------------------
11590 bool CanRepair(ItemBase item_repair_kit)
11591 {
11592 PluginRepairing module_repairing = PluginRepairing.Cast(GetPlugin(PluginRepairing));
11593 return module_repairing.CanRepair(this, item_repair_kit);
11594 }
11595
11596 //----------------------------------------------------------------
11597 bool Repair(PlayerBase player, ItemBase item_repair_kit, float specialty_weight)
11598 {
11599 PluginRepairing module_repairing = PluginRepairing.Cast(GetPlugin(PluginRepairing));
11600 return module_repairing.Repair(player, this, item_repair_kit, specialty_weight);
11601 }
11602
11603 //----------------------------------------------------------------
11604 int GetItemSize()
11605 {
11606 /*
11607 vector v_size = this.ConfigGetVector("itemSize");
11608 int v_size_x = v_size[0];
11609 int v_size_y = v_size[1];
11610 int size = v_size_x * v_size_y;
11611 return size;
11612 */
11613
11614 return 1;
11615 }
11616
11617 //----------------------------------------------------------------
11618 //Override for allowing seemingly unallowed moves when two clients send a conflicting message simultaneously
11619 bool CanBeMovedOverride()
11620 {
11621 return m_CanBeMovedOverride;
11622 }
11623
11624 //----------------------------------------------------------------
11625 //Override for allowing seemingly unallowed moves when two clients send a conflicting message simultaneously
11626 void SetCanBeMovedOverride(bool setting)
11627 {
11628 m_CanBeMovedOverride = setting;
11629 }
11630
11631 //----------------------------------------------------------------
11639 void MessageToOwnerStatus(string text)
11640 {
11641 PlayerBase player = PlayerBase.Cast(this.GetHierarchyRootPlayer());
11642
11643 if (player)
11644 {
11645 player.MessageStatus(text);
11646 }
11647 }
11648
11649 //----------------------------------------------------------------
11657 void MessageToOwnerAction(string text)
11658 {
11659 PlayerBase player = PlayerBase.Cast(this.GetHierarchyRootPlayer());
11660
11661 if (player)
11662 {
11663 player.MessageAction(text);
11664 }
11665 }
11666
11667 //----------------------------------------------------------------
11675 void MessageToOwnerFriendly(string text)
11676 {
11677 PlayerBase player = PlayerBase.Cast(this.GetHierarchyRootPlayer());
11678
11679 if (player)
11680 {
11681 player.MessageFriendly(text);
11682 }
11683 }
11684
11685 //----------------------------------------------------------------
11693 void MessageToOwnerImportant(string text)
11694 {
11695 PlayerBase player = PlayerBase.Cast(this.GetHierarchyRootPlayer());
11696
11697 if (player)
11698 {
11699 player.MessageImportant(text);
11700 }
11701 }
11702
11703 override bool IsItemBase()
11704 {
11705 return true;
11706 }
11707
11708 // Checks if item is of questioned kind
11709 override bool KindOf(string tag)
11710 {
11711 bool found = false;
11712 string item_name = this.GetType();
11713 ref TStringArray item_tag_array = new TStringArray;
11714 g_Game.ConfigGetTextArray("cfgVehicles " + item_name + " itemInfo", item_tag_array);
11715
11716 int array_size = item_tag_array.Count();
11717 for (int i = 0; i < array_size; i++)
11718 {
11719 if (item_tag_array.Get(i) == tag)
11720 {
11721 found = true;
11722 break;
11723 }
11724 }
11725 return found;
11726 }
11727
11728
11729 override void OnRPC(PlayerIdentity sender, int rpc_type,ParamsReadContext ctx)
11730 {
11731 //Debug.Log("OnRPC called");
11732 super.OnRPC(sender, rpc_type,ctx);
11733
11734 //Play soundset for attachment locking (ActionLockAttachment.c)
11735 switch (rpc_type)
11736 {
11737 #ifndef SERVER
11738 case ERPCs.RPC_SOUND_LOCK_ATTACH:
11739 Param2<bool, string> p = new Param2<bool, string>(false, "");
11740
11741 if (!ctx.Read(p))
11742 return;
11743
11744 bool play = p.param1;
11745 string soundSet = p.param2;
11746
11747 if (play)
11748 {
11749 if (m_LockingSound)
11750 {
11752 {
11753 m_LockingSound = SEffectManager.PlaySound(soundSet, GetPosition(), 0, 0, true);
11754 }
11755 }
11756 else
11757 {
11758 m_LockingSound = SEffectManager.PlaySound(soundSet, GetPosition(), 0, 0, true);
11759 }
11760 }
11761 else
11762 {
11763 SEffectManager.DestroyEffect(m_LockingSound);
11764 }
11765
11766 break;
11767 #endif
11768
11769 }
11770
11771 if (GetWrittenNoteData())
11772 {
11773 GetWrittenNoteData().OnRPC(sender, rpc_type,ctx);
11774 }
11775 }
11776
11777 //-----------------------------
11778 // VARIABLE MANIPULATION SYSTEM
11779 //-----------------------------
11780 int NameToID(string name)
11781 {
11782 PluginVariables plugin = PluginVariables.Cast(GetPlugin(PluginVariables));
11783 return plugin.GetID(name);
11784 }
11785
11786 string IDToName(int id)
11787 {
11788 PluginVariables plugin = PluginVariables.Cast(GetPlugin(PluginVariables));
11789 return plugin.GetName(id);
11790 }
11791
11793 void OnSyncVariables(ParamsReadContext ctx)//with ID optimization
11794 {
11795 //Debug.Log("OnSyncVariables called for item: "+ ToString(this.GetType()),"varSync");
11796 //read the flags
11797 int varFlags;
11798 if (!ctx.Read(varFlags))
11799 return;
11800
11801 if (varFlags & ItemVariableFlags.FLOAT)
11802 {
11803 ReadVarsFromCTX(ctx);
11804 }
11805 }
11806
11807 override void SerializeNumericalVars(array<float> floats_out)
11808 {
11809 //some variables handled on EntityAI level already!
11810 super.SerializeNumericalVars(floats_out);
11811
11812 // the order of serialization must be the same as the order of de-serialization
11813 //--------------------------------------------
11814 if (IsVariableSet(VARIABLE_QUANTITY))
11815 {
11816 floats_out.Insert(m_VarQuantity);
11817 }
11818 //--------------------------------------------
11819 if (IsVariableSet(VARIABLE_WET))
11820 {
11821 floats_out.Insert(m_VarWet);
11822 }
11823 //--------------------------------------------
11824 if (IsVariableSet(VARIABLE_LIQUIDTYPE))
11825 {
11826 floats_out.Insert(m_VarLiquidType);
11827 }
11828 //--------------------------------------------
11829 if (IsVariableSet(VARIABLE_COLOR))
11830 {
11831 floats_out.Insert(m_ColorComponentR);
11832 floats_out.Insert(m_ColorComponentG);
11833 floats_out.Insert(m_ColorComponentB);
11834 floats_out.Insert(m_ColorComponentA);
11835 }
11836 //--------------------------------------------
11837 if (IsVariableSet(VARIABLE_CLEANNESS))
11838 {
11839 floats_out.Insert(m_Cleanness);
11840 }
11841 }
11842
11843 override void DeSerializeNumericalVars(array<float> floats)
11844 {
11845 //some variables handled on EntityAI level already!
11846 super.DeSerializeNumericalVars(floats);
11847
11848 // the order of serialization must be the same as the order of de-serialization
11849 int index = 0;
11850 int mask = Math.Round(floats.Get(index));
11851
11852 index++;
11853 //--------------------------------------------
11854 if (mask & VARIABLE_QUANTITY)
11855 {
11856 if (m_IsStoreLoad)
11857 {
11858 SetStoreLoadedQuantity(floats.Get(index));
11859 }
11860 else
11861 {
11862 float quantity = floats.Get(index);
11863 SetQuantity(quantity, true, false, false, false);
11864 }
11865 index++;
11866 }
11867 //--------------------------------------------
11868 if (mask & VARIABLE_WET)
11869 {
11870 float wet = floats.Get(index);
11871 SetWet(wet);
11872 index++;
11873 }
11874 //--------------------------------------------
11875 if (mask & VARIABLE_LIQUIDTYPE)
11876 {
11877 int liquidtype = Math.Round(floats.Get(index));
11878 SetLiquidType(liquidtype);
11879 index++;
11880 }
11881 //--------------------------------------------
11882 if (mask & VARIABLE_COLOR)
11883 {
11884 m_ColorComponentR = Math.Round(floats.Get(index));
11885 index++;
11886 m_ColorComponentG = Math.Round(floats.Get(index));
11887 index++;
11888 m_ColorComponentB = Math.Round(floats.Get(index));
11889 index++;
11890 m_ColorComponentA = Math.Round(floats.Get(index));
11891 index++;
11892 }
11893 //--------------------------------------------
11894 if (mask & VARIABLE_CLEANNESS)
11895 {
11896 int cleanness = Math.Round(floats.Get(index));
11897 SetCleanness(cleanness);
11898 index++;
11899 }
11900 }
11901
11902 override void WriteVarsToCTX(ParamsWriteContext ctx)
11903 {
11904 super.WriteVarsToCTX(ctx);
11905
11906 //--------------------------------------------
11907 if (IsVariableSet(VARIABLE_QUANTITY))
11908 {
11909 ctx.Write(GetQuantity());
11910 }
11911 //--------------------------------------------
11912 if (IsVariableSet(VARIABLE_WET))
11913 {
11914 ctx.Write(GetWet());
11915 }
11916 //--------------------------------------------
11917 if (IsVariableSet(VARIABLE_LIQUIDTYPE))
11918 {
11919 ctx.Write(GetLiquidType());
11920 }
11921 //--------------------------------------------
11922 if (IsVariableSet(VARIABLE_COLOR))
11923 {
11924 int r,g,b,a;
11925 GetColor(r,g,b,a);
11926 ctx.Write(r);
11927 ctx.Write(g);
11928 ctx.Write(b);
11929 ctx.Write(a);
11930 }
11931 //--------------------------------------------
11932 if (IsVariableSet(VARIABLE_CLEANNESS))
11933 {
11934 ctx.Write(GetCleanness());
11935 }
11936 }
11937
11938 override bool ReadVarsFromCTX(ParamsReadContext ctx, int version = -1)//with ID optimization
11939 {
11940 if (!super.ReadVarsFromCTX(ctx,version))
11941 return false;
11942
11943 int intValue;
11944 float value;
11945
11946 if (version < 140)
11947 {
11948 if (!ctx.Read(intValue))
11949 return false;
11950
11951 m_VariablesMask = intValue;
11952 }
11953
11954 if (m_VariablesMask & VARIABLE_QUANTITY)
11955 {
11956 if (!ctx.Read(value))
11957 return false;
11958
11959 if (IsStoreLoad())
11960 {
11962 }
11963 else
11964 {
11965 SetQuantity(value, true, false, false, false);
11966 }
11967 }
11968 //--------------------------------------------
11969 if (version < 140)
11970 {
11971 if (m_VariablesMask & VARIABLE_TEMPERATURE)
11972 {
11973 if (!ctx.Read(value))
11974 return false;
11975 SetTemperatureDirect(value);
11976 }
11977 }
11978 //--------------------------------------------
11979 if (m_VariablesMask & VARIABLE_WET)
11980 {
11981 if (!ctx.Read(value))
11982 return false;
11983 SetWet(value);
11984 }
11985 //--------------------------------------------
11986 if (m_VariablesMask & VARIABLE_LIQUIDTYPE)
11987 {
11988 if (!ctx.Read(intValue))
11989 return false;
11990 SetLiquidType(intValue);
11991 }
11992 //--------------------------------------------
11993 if (m_VariablesMask & VARIABLE_COLOR)
11994 {
11995 int r,g,b,a;
11996 if (!ctx.Read(r))
11997 return false;
11998 if (!ctx.Read(g))
11999 return false;
12000 if (!ctx.Read(b))
12001 return false;
12002 if (!ctx.Read(a))
12003 return false;
12004
12005 SetColor(r,g,b,a);
12006 }
12007 //--------------------------------------------
12008 if (m_VariablesMask & VARIABLE_CLEANNESS)
12009 {
12010 if (!ctx.Read(intValue))
12011 return false;
12012 SetCleanness(intValue);
12013 }
12014 //--------------------------------------------
12015 if (version >= 138 && version < 140)
12016 {
12017 if (m_VariablesMask & VARIABLE_TEMPERATURE)
12018 {
12019 if (!ctx.Read(intValue))
12020 return false;
12021 SetFrozen(intValue);
12022 }
12023 }
12024
12025 return true;
12026 }
12027
12028 //----------------------------------------------------------------
12029 override bool OnStoreLoad(ParamsReadContext ctx, int version)
12030 {
12031 m_IsStoreLoad = true;
12033 {
12034 m_FixDamageSystemInit = true;
12035 }
12036
12037 if (!super.OnStoreLoad(ctx, version))
12038 {
12039 m_IsStoreLoad = false;
12040 return false;
12041 }
12042
12043 if (version >= 114)
12044 {
12045 bool hasQuickBarIndexSaved;
12046
12047 if (!ctx.Read(hasQuickBarIndexSaved))
12048 {
12049 m_IsStoreLoad = false;
12050 return false;
12051 }
12052
12053 if (hasQuickBarIndexSaved)
12054 {
12055 int itmQBIndex;
12056
12057 //Load quickbar item bind
12058 if (!ctx.Read(itmQBIndex))
12059 {
12060 m_IsStoreLoad = false;
12061 return false;
12062 }
12063
12064 PlayerBase parentPlayer = PlayerBase.Cast(GetHierarchyRootPlayer());
12065 if (itmQBIndex != -1 && parentPlayer)
12066 parentPlayer.SetLoadedQuickBarItemBind(this, itmQBIndex);
12067 }
12068 }
12069 else
12070 {
12071 // Backup of how it used to be
12072 PlayerBase player;
12073 int itemQBIndex;
12074 if (version == int.MAX)
12075 {
12076 if (!ctx.Read(itemQBIndex))
12077 {
12078 m_IsStoreLoad = false;
12079 return false;
12080 }
12081 }
12082 else if (Class.CastTo(player, GetHierarchyRootPlayer()))
12083 {
12084 //Load quickbar item bind
12085 if (!ctx.Read(itemQBIndex))
12086 {
12087 m_IsStoreLoad = false;
12088 return false;
12089 }
12090 if (itemQBIndex != -1 && player)
12091 player.SetLoadedQuickBarItemBind(this,itemQBIndex);
12092 }
12093 }
12094
12095 if (version < 140)
12096 {
12097 // variable management system
12098 if (!LoadVariables(ctx, version))
12099 {
12100 m_IsStoreLoad = false;
12101 return false;
12102 }
12103 }
12104
12105 //agent trasmission system
12106 if (!LoadAgents(ctx, version))
12107 {
12108 m_IsStoreLoad = false;
12109 return false;
12110 }
12111 if (version >= 132)
12112 {
12113 RemotelyActivatedItemBehaviour raib = GetRemotelyActivatedItemBehaviour();
12114 if (raib)
12115 {
12116 if (!raib.OnStoreLoad(ctx,version))
12117 {
12118 m_IsStoreLoad = false;
12119 return false;
12120 }
12121 }
12122 }
12123
12124 m_IsStoreLoad = false;
12125 return true;
12126 }
12127
12128 //----------------------------------------------------------------
12129
12130 override void OnStoreSave(ParamsWriteContext ctx)
12131 {
12132 super.OnStoreSave(ctx);
12133
12134 PlayerBase player;
12135 if (PlayerBase.CastTo(player,GetHierarchyRootPlayer()))
12136 {
12137 ctx.Write(true); // Keep track of if we should actually read this in or not
12138 //Save quickbar item bind
12139 int itemQBIndex = -1;
12140 itemQBIndex = player.FindQuickBarEntityIndex(this);
12141 ctx.Write(itemQBIndex);
12142 }
12143 else
12144 {
12145 ctx.Write(false); // Keep track of if we should actually read this in or not
12146 }
12147
12148 SaveAgents(ctx);//agent trasmission system
12149
12150 RemotelyActivatedItemBehaviour raib = GetRemotelyActivatedItemBehaviour();
12151 if (raib)
12152 {
12153 raib.OnStoreSave(ctx);
12154 }
12155 }
12156 //----------------------------------------------------------------
12157
12158 override void AfterStoreLoad()
12159 {
12160 super.AfterStoreLoad();
12161
12163 {
12165 }
12166
12167 if (GetStoreLoadedQuantity() != float.LOWEST)
12168 {
12170 SetStoreLoadedQuantity(float.LOWEST);//IMPORTANT to do this !! we use 'm_StoreLoadedQuantity' inside SetQuantity to distinguish between initial quantity setting and the consequent(normal gameplay) calls
12171 }
12172 }
12173
12174 override void EEOnAfterLoad()
12175 {
12176 super.EEOnAfterLoad();
12177
12179 {
12180 m_FixDamageSystemInit = false;
12181 }
12182
12185 }
12186
12187 bool CanBeDisinfected()
12188 {
12189 return false;
12190 }
12191
12192
12193 //----------------------------------------------------------------
12194 override void OnVariablesSynchronized()
12195 {
12196 if (m_Initialized)
12197 {
12198 #ifdef PLATFORM_CONSOLE
12199 //bruteforce it is
12200 if (IsSplitable())
12201 {
12202 UIScriptedMenu menu = g_Game.GetUIManager().FindMenu(MENU_INVENTORY);
12203 if (menu)
12204 {
12205 menu.Refresh();
12206 }
12207 }
12208 #endif
12209 }
12210
12212 {
12213 PlayImpactSound(m_ConfigWeight, m_ImpactSpeed, m_ImpactSoundSurfaceHash);
12214 m_WantPlayImpactSound = false;
12215 }
12216
12218 {
12219 SetWeightDirty();
12221 }
12222 if (m_VarWet != m_VarWetPrev)
12223 {
12226 }
12227
12228 if (m_SoundSyncPlay != 0)
12229 {
12232
12233 m_SoundSyncPlay = 0;
12234 m_SoundSyncSlotID = -1;
12235 }
12236 if (m_SoundSyncStop != 0)
12237 {
12239 m_ItemSoundHandler.StopItemSoundClient(m_SoundSyncStop);
12240 m_SoundSyncStop = 0;
12241 }
12242
12243 super.OnVariablesSynchronized();
12244 }
12245
12246 //------------------------- Quantity
12247 //----------------------------------------------------------------
12249 override bool SetQuantity(float value, bool destroy_config = true, bool destroy_forced = false, bool allow_client = false, bool clamp_to_stack_max = true)
12250 {
12251 if (!IsServerCheck(allow_client))
12252 return false;
12253
12254 if (!HasQuantity())
12255 return false;
12256
12257 float min = GetQuantityMin();
12258 float max = GetQuantityMax();
12259
12260 if (value <= (min + 0.001))
12261 value = min;
12262
12263 if (value == min)
12264 {
12265 if (destroy_config)
12266 {
12267 bool dstr = ConfigGetBool("varQuantityDestroyOnMin");
12268 if (dstr)
12269 {
12270 m_VarQuantity = Math.Clamp(value, min, max);
12271 this.Delete();
12272 return true;
12273 }
12274 }
12275 else if (destroy_forced)
12276 {
12277 m_VarQuantity = Math.Clamp(value, min, max);
12278 this.Delete();
12279 return true;
12280 }
12281 // we get here if destroy_config IS true AND dstr(config destroy param) IS false;
12282 RemoveAllAgents();//we remove all agents when we got to the min value, but the item is not getting deleted
12283 }
12284
12285 float delta = m_VarQuantity;
12286 m_VarQuantity = Math.Clamp(value, min, max);
12287
12288 if (g_Game.IsServer() || !g_Game.IsMultiplayer()) // single player or server side multiplayer
12289 {
12290 EntityAI parent = GetHierarchyRoot();
12291 InventoryLocation iLoc = new InventoryLocation();
12292 GetInventory().GetCurrentInventoryLocation(iLoc);
12293 if (iLoc && iLoc.IsValid() && delta != m_VarQuantity)
12294 {
12295 int iLocSlot = iLoc.GetSlot();
12296 if (delta < m_VarQuantity && iLoc.GetType() != InventoryLocationType.GROUND)
12297 {
12298 StartItemSoundServer(SoundConstants.ITEM_ATTACH, iLocSlot);
12299 }
12300 if (delta > m_VarQuantity && m_VarQuantity != 0 && !IsPrepareToDelete() && iLoc.GetType() == InventoryLocationType.ATTACHMENT)
12301 {
12302 StartItemSoundServer(SoundConstants.ITEM_DETACH, iLocSlot);
12303 }
12304 }
12305 }
12306
12307 if (GetStoreLoadedQuantity() == float.LOWEST)//any other value means we are setting quantity from storage
12308 {
12309 delta = m_VarQuantity - delta;
12310
12311 if (delta)
12312 OnQuantityChanged(delta);
12313 }
12314
12315 SetVariableMask(VARIABLE_QUANTITY);
12316
12317 return false;
12318 }
12319
12320 //----------------------------------------------------------------
12322 bool AddQuantity(float value, bool destroy_config = true, bool destroy_forced = false)
12323 {
12324 return SetQuantity(GetQuantity() + value, destroy_config, destroy_forced);
12325 }
12326 //----------------------------------------------------------------
12327 void SetQuantityMax()
12328 {
12329 float max = GetQuantityMax();
12330 SetQuantity(max);
12331 }
12332
12333 override void SetQuantityToMinimum()
12334 {
12335 float min = GetQuantityMin();
12336 SetQuantity(min);
12337 }
12338 //----------------------------------------------------------------
12340 override void SetQuantityNormalized(float value, bool destroy_config = true, bool destroy_forced = false)
12341 {
12342 float value_clamped = Math.Clamp(value, 0, 1);//just to make sure
12343 int result = Math.Round(Math.Lerp(GetQuantityMin(), GetQuantityMax(), value_clamped));
12344 SetQuantity(result, destroy_config, destroy_forced);
12345 }
12346
12347 //----------------------------------------------------------------
12349 override float GetQuantityNormalized()
12350 {
12351 return Math.InverseLerp(GetQuantityMin(), GetQuantityMax(),m_VarQuantity);
12352 }
12353
12355 {
12356 return GetQuantityNormalized();
12357 }
12358
12359 /*void SetAmmoNormalized(float value)
12360 {
12361 float value_clamped = Math.Clamp(value, 0, 1);
12362 Magazine this_mag = Magazine.Cast(this);
12363 int max_rounds = this_mag.GetAmmoMax();
12364 int result = value * max_rounds;//can the rounded if higher precision is required
12365 this_mag.SetAmmoCount(result);
12366 }*/
12367 //----------------------------------------------------------------
12368 override int GetQuantityMax()
12369 {
12370 int slot = -1;
12371 GameInventory inventory = GetInventory();
12372 if (inventory)
12373 {
12374 InventoryLocation il = new InventoryLocation;
12375 inventory.GetCurrentInventoryLocation(il);
12376 slot = il.GetSlot();
12377 }
12378
12379 return GetTargetQuantityMax(slot);
12380 }
12381
12382 override int GetTargetQuantityMax(int attSlotID = -1)
12383 {
12384 float quantity_max = 0;
12385
12386 if (IsSplitable()) //only stackable/splitable items can check for stack size
12387 {
12388 if (attSlotID != -1)
12389 quantity_max = InventorySlots.GetStackMaxForSlotId(attSlotID);
12390
12391 if (quantity_max <= 0)
12392 quantity_max = m_VarStackMax;
12393 }
12394
12395 if (quantity_max <= 0)
12396 quantity_max = m_VarQuantityMax;
12397
12398 return quantity_max;
12399 }
12400 //----------------------------------------------------------------
12401 override int GetQuantityMin()
12402 {
12403 return m_VarQuantityMin;
12404 }
12405 //----------------------------------------------------------------
12406 int GetQuantityInit()
12407 {
12408 return m_VarQuantityInit;
12409 }
12410
12411 //----------------------------------------------------------------
12412 override bool HasQuantity()
12413 {
12414 return !(GetQuantityMax() - GetQuantityMin() == 0);
12415 }
12416
12417 override float GetQuantity()
12418 {
12419 return m_VarQuantity;
12420 }
12421
12422 bool IsFullQuantity()
12423 {
12424 return GetQuantity() >= GetQuantityMax();
12425 }
12426
12427 //Calculates weight of single item without attachments and cargo
12428 override float GetSingleInventoryItemWeightEx()
12429 {
12430 //this needs to be first stored inside local variables, when returned directly during inside return call, the result is completely different due to enforce script bug
12431 float weightEx = GetWeightEx();//overall weight of the item
12432 float special = GetInventoryAndCargoWeight();//cargo and attachment weight
12433 return weightEx - special;
12434 }
12435
12436 // Obsolete, use GetSingleInventoryItemWeightEx() instead
12438 {
12440 }
12441
12442 override protected float GetWeightSpecialized(bool forceRecalc = false)
12443 {
12444 if (IsSplitable()) //quantity determines size of the stack
12445 {
12446 #ifdef DEVELOPER
12447 if (WeightDebug.m_VerbosityFlags & WeightDebugType.RECALC_FORCED)
12448 {
12449 WeightDebugData data1 = WeightDebug.GetWeightDebug(this);
12450 data1.SetCalcDetails("TIB1: " + GetConfigWeightModifiedDebugText() +" * " + GetQuantity()+"(quantity)");
12451 }
12452 #endif
12453
12454 return GetQuantity() * GetConfigWeightModified();
12455 }
12456 else if (HasEnergyManager())// items with energy manager
12457 {
12458 #ifdef DEVELOPER
12459 if (WeightDebug.m_VerbosityFlags & WeightDebugType.RECALC_FORCED)
12460 {
12461 WeightDebugData data2 = WeightDebug.GetWeightDebug(this);
12462 data2.SetCalcDetails("TIB2: "+super.GetWeightSpecialized(forceRecalc)+"(contents weight) + " + GetConfigWeightModifiedDebugText() +" + " + GetCompEM().GetEnergy()+"(energy) * " + ConfigGetFloat("weightPerQuantityUnit") +"(weightPerQuantityUnit)");
12463 }
12464 #endif
12465 return super.GetWeightSpecialized(forceRecalc) + (GetCompEM().GetEnergy() * ConfigGetFloat("weightPerQuantityUnit")) + GetConfigWeightModified();
12466 }
12467 else//everything else
12468 {
12469 #ifdef DEVELOPER
12470 if (WeightDebug.m_VerbosityFlags & WeightDebugType.RECALC_FORCED)
12471 {
12472 WeightDebugData data3 = WeightDebug.GetWeightDebug(this);
12473 data3.SetCalcDetails("TIB3: "+super.GetWeightSpecialized(forceRecalc)+"(contents weight) + " + GetConfigWeightModifiedDebugText() +" + " + GetQuantity()+"(quantity) * " + ConfigGetFloat("weightPerQuantityUnit") +"(weightPerQuantityUnit))");
12474 }
12475 #endif
12476 return super.GetWeightSpecialized(forceRecalc) + (GetQuantity() * ConfigGetFloat("weightPerQuantityUnit")) + GetConfigWeightModified();
12477 }
12478 }
12479
12481 int GetNumberOfItems()
12482 {
12483 int item_count = 0;
12484 ItemBase item;
12485
12486 GameInventory inventory = GetInventory();
12487 CargoBase cargo = inventory.GetCargo();
12488 if (cargo != NULL)
12489 {
12490 item_count = cargo.GetItemCount();
12491 }
12492
12493 int nAttachments = inventory.AttachmentCount();
12494 for (int i = 0; i < nAttachments; ++i)
12495 {
12496 Class.CastTo(item, inventory.GetAttachmentFromIndex(i));
12497 if (item)
12498 item_count += item.GetNumberOfItems();
12499 }
12500 return item_count;
12501 }
12502
12504 float GetUnitWeight(bool include_wetness = true)
12505 {
12506 float weight = 0;
12507 float wetness = 1;
12508 if (include_wetness)
12509 wetness += GetWet();
12510 if (IsSplitable()) //quantity determines size of the stack
12511 {
12512 weight = wetness * m_ConfigWeight;
12513 }
12514 else if (IsLiquidContainer()) //is a liquid container, default liquid weight is set to 1. May revisit later?
12515 {
12516 weight = 1;
12517 }
12518 return weight;
12519 }
12520
12521 //-----------------------------------------------------------------
12522
12523 override void ClearInventory()
12524 {
12525 GameInventory inventory = GetInventory();
12526 if ((g_Game.IsServer() || !g_Game.IsMultiplayer()) && inventory)
12527 {
12528 array<EntityAI> items = new array<EntityAI>;
12529 inventory.EnumerateInventory(InventoryTraversalType.INORDER, items);
12530 for (int i = 0; i < items.Count(); ++i)
12531 {
12532 ItemBase item = ItemBase.Cast(items.Get(i));
12533 if (item)
12534 {
12535 g_Game.ObjectDelete(item);
12536 }
12537 }
12538 }
12539 }
12540
12541 //------------------------- Energy
12542
12543 //----------------------------------------------------------------
12544 float GetEnergy()
12545 {
12546 float energy = 0;
12547 if (HasEnergyManager())
12548 {
12549 energy = GetCompEM().GetEnergy();
12550 }
12551 return energy;
12552 }
12553
12554
12555 override void OnEnergyConsumed()
12556 {
12557 super.OnEnergyConsumed();
12558
12560 }
12561
12562 override void OnEnergyAdded()
12563 {
12564 super.OnEnergyAdded();
12565
12567 }
12568
12569 // Converts energy (from Energy Manager) to quantity, if enabled.
12571 {
12572 if (g_Game.IsServer() && HasEnergyManager() && GetCompEM().HasConversionOfEnergyToQuantity())
12573 {
12574 if (HasQuantity())
12575 {
12576 float energy_0to1 = GetCompEM().GetEnergy0To1();
12577 SetQuantityNormalized(energy_0to1);
12578 }
12579 }
12580 }
12581
12582 //----------------------------------------------------------------
12583 float GetHeatIsolationInit()
12584 {
12585 return ConfigGetFloat("heatIsolation");
12586 }
12587
12588 float GetHeatIsolation()
12589 {
12590 return m_HeatIsolation;
12591 }
12592
12593 float GetDryingIncrement(string pIncrementName)
12594 {
12595 string paramPath = string.Format("CfgVehicles %1 EnvironmentWetnessIncrements Drying %2", GetType(), pIncrementName);
12596 if (g_Game.ConfigIsExisting(paramPath))
12597 return g_Game.ConfigGetFloat(paramPath);
12598
12599 return 0.0;
12600 }
12601
12602 float GetSoakingIncrement(string pIncrementName)
12603 {
12604 string paramPath = string.Format("CfgVehicles %1 EnvironmentWetnessIncrements Soaking %2", GetType(), pIncrementName);
12605 if (g_Game.ConfigIsExisting(paramPath))
12606 return g_Game.ConfigGetFloat(paramPath);
12607
12608 return 0.0;
12609 }
12610 //----------------------------------------------------------------
12611 override void SetWet(float value, bool allow_client = false)
12612 {
12613 if (!IsServerCheck(allow_client))
12614 return;
12615
12616 float min = GetWetMin();
12617 float max = GetWetMax();
12618
12619 float previousValue = m_VarWet;
12620
12621 m_VarWet = Math.Clamp(value, min, max);
12622
12623 if (previousValue != m_VarWet)
12624 {
12625 SetVariableMask(VARIABLE_WET);
12626 OnWetChanged(m_VarWet, previousValue);
12627 }
12628 }
12629 //----------------------------------------------------------------
12630 override void AddWet(float value)
12631 {
12632 SetWet(GetWet() + value);
12633 }
12634 //----------------------------------------------------------------
12635 override void SetWetMax()
12636 {
12638 }
12639 //----------------------------------------------------------------
12640 override float GetWet()
12641 {
12642 return m_VarWet;
12643 }
12644 //----------------------------------------------------------------
12645 override float GetWetMax()
12646 {
12647 return m_VarWetMax;
12648 }
12649 //----------------------------------------------------------------
12650 override float GetWetMin()
12651 {
12652 return m_VarWetMin;
12653 }
12654 //----------------------------------------------------------------
12655 override float GetWetInit()
12656 {
12657 return m_VarWetInit;
12658 }
12659 //----------------------------------------------------------------
12660 override void OnWetChanged(float newVal, float oldVal)
12661 {
12662 EWetnessLevel newLevel = GetWetLevelInternal(newVal);
12663 EWetnessLevel oldLevel = GetWetLevelInternal(oldVal);
12664 if (newLevel != oldLevel)
12665 {
12666 OnWetLevelChanged(newLevel,oldLevel);
12667 }
12668 }
12669
12670 override void OnWetLevelChanged(EWetnessLevel newLevel, EWetnessLevel oldLevel)
12671 {
12672 SetWeightDirty();
12673 }
12674
12675 override EWetnessLevel GetWetLevel()
12676 {
12677 return GetWetLevelInternal(m_VarWet);
12678 }
12679
12680 //----------------------------------------------------------------
12681
12682 override void SetStoreLoad(bool value)
12683 {
12684 m_IsStoreLoad = value;
12685 }
12686
12687 override bool IsStoreLoad()
12688 {
12689 return m_IsStoreLoad;
12690 }
12691
12692 override void SetStoreLoadedQuantity(float value)
12693 {
12694 m_StoreLoadedQuantity = value;
12695 }
12696
12697 override float GetStoreLoadedQuantity()
12698 {
12699 return m_StoreLoadedQuantity;
12700 }
12701
12702 //----------------------------------------------------------------
12703
12704 float GetItemModelLength()
12705 {
12706 if (ConfigIsExisting("itemModelLength"))
12707 {
12708 return ConfigGetFloat("itemModelLength");
12709 }
12710 return 0;
12711 }
12712
12713 float GetItemAttachOffset()
12714 {
12715 if (ConfigIsExisting("itemAttachOffset"))
12716 {
12717 return ConfigGetFloat("itemAttachOffset");
12718 }
12719 return 0;
12720 }
12721
12722 override void SetCleanness(int value, bool allow_client = false)
12723 {
12724 if (!IsServerCheck(allow_client))
12725 return;
12726
12727 int previousValue = m_Cleanness;
12728
12729 m_Cleanness = Math.Clamp(value, m_CleannessMin, m_CleannessMax);
12730
12731 if (previousValue != m_Cleanness)
12732 SetVariableMask(VARIABLE_CLEANNESS);
12733 }
12734
12735 override int GetCleanness()
12736 {
12737 return m_Cleanness;
12738 }
12739
12741 {
12742 return true;
12743 }
12744
12745 //----------------------------------------------------------------
12746 // ATTACHMENT LOCKING
12747 // Getters relevant to generic ActionLockAttachment
12748 int GetLockType()
12749 {
12750 return m_LockType;
12751 }
12752
12753 string GetLockSoundSet()
12754 {
12755 return m_LockSoundSet;
12756 }
12757
12758 //----------------------------------------------------------------
12759 //------------------------- Color
12760 // sets items color variable given color components
12761 override void SetColor(int r, int g, int b, int a)
12762 {
12767 SetVariableMask(VARIABLE_COLOR);
12768 }
12770 override void GetColor(out int r,out int g,out int b,out int a)
12771 {
12776 }
12777
12778 bool IsColorSet()
12779 {
12780 return IsVariableSet(VARIABLE_COLOR);
12781 }
12782
12784 string GetColorString()
12785 {
12786 int r,g,b,a;
12787 GetColor(r,g,b,a);
12788 r = r/255;
12789 g = g/255;
12790 b = b/255;
12791 a = a/255;
12792 return MiscGameplayFunctions.GetColorString(r, g, b, a);
12793 }
12794 //----------------------------------------------------------------
12795 //------------------------- LiquidType
12796
12797 override void SetLiquidType(int value, bool allow_client = false)
12798 {
12799 if (!IsServerCheck(allow_client))
12800 return;
12801
12802 int old = m_VarLiquidType;
12803 m_VarLiquidType = value;
12804 OnLiquidTypeChanged(old,value);
12805 SetVariableMask(VARIABLE_LIQUIDTYPE);
12806 }
12807
12808 int GetLiquidTypeInit()
12809 {
12810 return ConfigGetInt("varLiquidTypeInit");
12811 }
12812
12813 override int GetLiquidType()
12814 {
12815 return m_VarLiquidType;
12816 }
12817
12818 protected void OnLiquidTypeChanged(int oldType, int newType)
12819 {
12820 if (newType == LIQUID_NONE && GetIsFrozen())
12821 SetFrozen(false);
12822 }
12823
12825 void UpdateQuickbarShortcutVisibility(PlayerBase player)
12826 {
12827 player.SetEnableQuickBarEntityShortcut(this,!GetHierarchyParent() || GetHierarchyParent().GetInventory().AreChildrenAccessible());
12828 }
12829
12830 // -------------------------------------------------------------------------
12832 void OnInventoryEnter(Man player)
12833 {
12834 PlayerBase nplayer;
12835 if (PlayerBase.CastTo(nplayer, player))
12836 {
12837 m_CanPlayImpactSound = true;
12838 nplayer.SetEnableQuickBarEntityShortcut(this,!GetHierarchyParent() || GetHierarchyParent().GetInventory().AreChildrenAccessible());
12839 }
12840 }
12841
12842 // -------------------------------------------------------------------------
12844 void OnInventoryExit(Man player)
12845 {
12846 PlayerBase nplayer;
12847 if (PlayerBase.CastTo(nplayer,player))
12848 {
12849 nplayer.SetEnableQuickBarEntityShortcut(this, false);
12850 }
12851
12852 player.GetHumanInventory().ClearUserReservedLocationForContainer(this);
12853
12854 if (HasEnergyManager())
12855 {
12856 GetCompEM().UpdatePlugState(); // Unplug the el. device if it's necesarry.
12857 }
12858 }
12859
12860 // ADVANCED PLACEMENT EVENTS
12861 override void OnPlacementStarted(Man player)
12862 {
12863 super.OnPlacementStarted(player);
12864
12865 SetTakeable(false);
12866 }
12867
12868 override void OnPlacementComplete(Man player, vector position = "0 0 0", vector orientation = "0 0 0")
12869 {
12870 if (m_AdminLog)
12871 {
12872 m_AdminLog.OnPlacementComplete(player, this);
12873 }
12874
12875 super.OnPlacementComplete(player, position, orientation);
12876 }
12877
12878 //-----------------------------
12879 // AGENT SYSTEM
12880 //-----------------------------
12881 //--------------------------------------------------------------------------
12882 bool ContainsAgent(int agent_id)
12883 {
12884 if (agent_id & m_AttachedAgents)
12885 {
12886 return true;
12887 }
12888 else
12889 {
12890 return false;
12891 }
12892 }
12893
12894 //--------------------------------------------------------------------------
12895 override void RemoveAgent(int agent_id)
12896 {
12897 if (ContainsAgent(agent_id))
12898 {
12899 m_AttachedAgents = ~agent_id & m_AttachedAgents;
12900 }
12901 }
12902
12903 //--------------------------------------------------------------------------
12904 override void RemoveAllAgents()
12905 {
12906 m_AttachedAgents = 0;
12907 }
12908 //--------------------------------------------------------------------------
12909 override void RemoveAllAgentsExcept(int agent_to_keep)
12910 {
12911 m_AttachedAgents = m_AttachedAgents & agent_to_keep;
12912 }
12913 // -------------------------------------------------------------------------
12914 override void InsertAgent(int agent, float count = 1)
12915 {
12916 if (count < 1)
12917 return;
12918 //Debug.Log("Inserting Agent on item: " + agent.ToString() +" count: " + count.ToString());
12920 }
12921
12923 void TransferAgents(int agents)
12924 {
12926 }
12927
12928 // -------------------------------------------------------------------------
12929 override int GetAgents()
12930 {
12931 return m_AttachedAgents;
12932 }
12933 //----------------------------------------------------------------------
12934
12935 /*int GetContaminationType()
12936 {
12937 int contamination_type;
12938
12939 const int CONTAMINATED_MASK = eAgents.CHOLERA | eAgents.INFLUENZA | eAgents.SALMONELLA | eAgents.BRAIN;
12940 const int POISONED_MASK = eAgents.FOOD_POISON | eAgents.CHEMICAL_POISON;
12941 const int NERVE_GAS_MASK = eAgents.CHEMICAL_POISON;
12942 const int DIRTY_MASK = eAgents.WOUND_AGENT;
12943
12944 Edible_Base edible = Edible_Base.Cast(this);
12945 int agents = GetAgents();
12946 if (edible)
12947 {
12948 NutritionalProfile profile = Edible_Base.GetNutritionalProfile(edible);
12949 if (profile)
12950 {
12951 agents = agents | profile.GetAgents();//merge item's agents with nutritional agents
12952 }
12953 }
12954 if (agents & CONTAMINATED_MASK)
12955 {
12956 contamination_type = contamination_type | EContaminationTypes.ITEM_BADGE_CONTAMINATED;
12957 }
12958 if (agents & POISONED_MASK)
12959 {
12960 contamination_type = contamination_type | EContaminationTypes.ITEM_BADGE_POISONED;
12961 }
12962 if (agents & NERVE_GAS_MASK)
12963 {
12964 contamination_type = contamination_type | EContaminationTypes.ITEM_BADGE_NERVE_GAS;
12965 }
12966 if (agents & DIRTY_MASK)
12967 {
12968 contamination_type = contamination_type | EContaminationTypes.ITEM_BADGE_DIRTY;
12969 }
12970
12971 return agents;
12972 }*/
12973
12974 // -------------------------------------------------------------------------
12975 bool LoadAgents(ParamsReadContext ctx, int version)
12976 {
12977 if (!ctx.Read(m_AttachedAgents))
12978 return false;
12979 return true;
12980 }
12981 // -------------------------------------------------------------------------
12983 {
12984
12986 }
12987 // -------------------------------------------------------------------------
12988
12990 override void CheckForRoofLimited(float timeTresholdMS = 3000)
12991 {
12992 super.CheckForRoofLimited(timeTresholdMS);
12993
12994 float time = g_Game.GetTime();
12995 if ((time - m_PreviousRoofTestTime) >= timeTresholdMS)
12996 {
12997 m_PreviousRoofTestTime = time;
12998 SetRoofAbove(MiscGameplayFunctions.IsUnderRoof(this));
12999 }
13000 }
13001
13002 // returns item's protection level against enviromental hazard, for masks with filters, returns the filters protection for valid filter, otherwise 0
13003 float GetProtectionLevel(int type, bool consider_filter = false, int system = 0)
13004 {
13005 if (IsDamageDestroyed() || (HasQuantity() && GetQuantity() <= 0))
13006 {
13007 return 0;
13008 }
13009
13010 if (GetInventory().GetAttachmentSlotsCount() != 0)//is it an item with attachable filter ?
13011 {
13012 ItemBase filter = ItemBase.Cast(FindAttachmentBySlotName("GasMaskFilter"));
13013 if (filter)
13014 return filter.GetProtectionLevel(type, false, system);//it's a valid filter, return the protection
13015 else
13016 return 0;//otherwise return 0 when no filter attached
13017 }
13018
13019 string subclassPath, entryName;
13020
13021 switch (type)
13022 {
13023 case DEF_BIOLOGICAL:
13024 entryName = "biological";
13025 break;
13026 case DEF_CHEMICAL:
13027 entryName = "chemical";
13028 break;
13029 default:
13030 entryName = "biological";
13031 break;
13032 }
13033
13034 subclassPath = "CfgVehicles " + this.GetType() + " Protection ";
13035
13036 return g_Game.ConfigGetFloat(subclassPath + entryName);
13037 }
13038
13039
13040
13042 override void EEOnCECreate()
13043 {
13044 if (!IsMagazine())
13046
13048 }
13049
13050
13051 //-------------------------
13052 // OPEN/CLOSE USER ACTIONS
13053 //-------------------------
13055 void Open();
13056 void Close();
13057 bool IsOpen()
13058 {
13059 return true;
13060 }
13061
13062 override bool CanDisplayCargo()
13063 {
13064 return IsOpen();
13065 }
13066
13067
13068 // ------------------------------------------------------------
13069 // CONDITIONS
13070 // ------------------------------------------------------------
13071 override bool CanPutInCargo(EntityAI parent)
13072 {
13073 if (parent)
13074 {
13075 if (parent.IsInherited(DayZInfected))
13076 return true;
13077
13078 if (!parent.IsRuined())
13079 return true;
13080 }
13081
13082 return true;
13083 }
13084
13085 override bool CanPutAsAttachment(EntityAI parent)
13086 {
13087 if (!super.CanPutAsAttachment(parent))
13088 {
13089 return false;
13090 }
13091
13092 if (!IsRuined() && !parent.IsRuined())
13093 {
13094 return true;
13095 }
13096
13097 return false;
13098 }
13099
13100 override bool CanReceiveItemIntoCargo(EntityAI item)
13101 {
13102 //removed 15.06. coz of loading from storage -> after load items in cargo was lost -> waiting for proper solution
13103 //if (GetHealthLevel() == GameConstants.STATE_RUINED)
13104 // return false;
13105
13106 return super.CanReceiveItemIntoCargo(item);
13107 }
13108
13109 override bool CanReceiveAttachment(EntityAI attachment, int slotId)
13110 {
13111 //removed 15.06. coz of loading from storage -> after load items in cargo was lost -> waiting for proper solution
13112 //if (GetHealthLevel() == GameConstants.STATE_RUINED)
13113 // return false;
13114
13115 GameInventory attachmentInv = attachment.GetInventory();
13116 if (attachmentInv && attachmentInv.GetCargo() && attachmentInv.GetCargo().GetItemCount() > 0)
13117 {
13118 if (GetHierarchyParent() && !GetHierarchyParent().IsInherited(PlayerBase))
13119 return false;
13120 }
13121
13122 InventoryLocation loc = new InventoryLocation();
13123 attachment.GetInventory().GetCurrentInventoryLocation(loc);
13124 if (loc && loc.IsValid() && !GetInventory().AreChildrenAccessible())
13125 return false;
13126
13127 return super.CanReceiveAttachment(attachment, slotId);
13128 }
13129
13130 override bool CanReleaseAttachment(EntityAI attachment)
13131 {
13132 if (!super.CanReleaseAttachment(attachment))
13133 return false;
13134
13135 return GetInventory().AreChildrenAccessible();
13136 }
13137
13138 /*override bool CanLoadAttachment(EntityAI attachment)
13139 {
13140 //removed 15.06. coz of loading from storage -> after load items in cargo was lost -> waiting for proper solution
13141 //if (GetHealthLevel() == GameConstants.STATE_RUINED)
13142 // return false;
13143
13144 GameInventory attachmentInv = attachment.GetInventory();
13145 if (attachmentInv && attachmentInv.GetCargo() && attachmentInv.GetCargo().GetItemCount() > 0)
13146 {
13147 bool boo = (GetHierarchyParent() && !GetHierarchyParent().IsInherited(PlayerBase));
13148 ErrorEx("CanLoadAttachment | this: " + this + " | attachment: " + attachment + " | boo: " + boo,ErrorExSeverity.INFO);
13149
13150 if (GetHierarchyParent() && !GetHierarchyParent().IsInherited(PlayerBase))
13151 return false;
13152 }
13153
13154 return super.CanLoadAttachment(attachment);
13155 }*/
13156
13157 // Plays muzzle flash particle effects
13158 static void PlayFireParticles(ItemBase weapon, int muzzle_index, string ammoType, ItemBase muzzle_owner, ItemBase suppressor, string config_to_search)
13159 {
13160 int id = muzzle_owner.GetMuzzleID();
13161 array<ref WeaponParticlesOnFire> WPOF_array = m_OnFireEffect.Get(id);
13162
13163 if (WPOF_array)
13164 {
13165 for (int i = 0; i < WPOF_array.Count(); i++)
13166 {
13167 WeaponParticlesOnFire WPOF = WPOF_array.Get(i);
13168
13169 if (WPOF)
13170 {
13171 WPOF.OnActivate(weapon, muzzle_index, ammoType, muzzle_owner, suppressor, config_to_search);
13172 }
13173 }
13174 }
13175 }
13176
13177 // Plays bullet eject particle effects (usually just smoke, the bullet itself is a 3D model and is not part of this function)
13178 static void PlayBulletCasingEjectParticles(ItemBase weapon, string ammoType, ItemBase muzzle_owner, ItemBase suppressor, string config_to_search)
13179 {
13180 int id = muzzle_owner.GetMuzzleID();
13181 array<ref WeaponParticlesOnBulletCasingEject> WPOBE_array = m_OnBulletCasingEjectEffect.Get(id);
13182
13183 if (WPOBE_array)
13184 {
13185 for (int i = 0; i < WPOBE_array.Count(); i++)
13186 {
13187 WeaponParticlesOnBulletCasingEject WPOBE = WPOBE_array.Get(i);
13188
13189 if (WPOBE)
13190 {
13191 WPOBE.OnActivate(weapon, 0, ammoType, muzzle_owner, suppressor, config_to_search);
13192 }
13193 }
13194 }
13195 }
13196
13197 // Plays all weapon overheating particles
13198 static void PlayOverheatingParticles(ItemBase weapon, string ammoType, ItemBase muzzle_owner, ItemBase suppressor, string config_to_search)
13199 {
13200 int id = muzzle_owner.GetMuzzleID();
13201 array<ref WeaponParticlesOnOverheating> WPOOH_array = weapon.m_OnOverheatingEffect.Get(id);
13202
13203 if (WPOOH_array)
13204 {
13205 for (int i = 0; i < WPOOH_array.Count(); i++)
13206 {
13207 WeaponParticlesOnOverheating WPOOH = WPOOH_array.Get(i);
13208
13209 if (WPOOH)
13210 {
13211 WPOOH.OnActivate(weapon, 0, ammoType, muzzle_owner, suppressor, config_to_search);
13212 }
13213 }
13214 }
13215 }
13216
13217 // Updates all weapon overheating particles
13218 static void UpdateOverheatingParticles(ItemBase weapon, string ammoType, ItemBase muzzle_owner, ItemBase suppressor, string config_to_search)
13219 {
13220 int id = muzzle_owner.GetMuzzleID();
13221 array<ref WeaponParticlesOnOverheating> WPOOH_array = weapon.m_OnOverheatingEffect.Get(id);
13222
13223 if (WPOOH_array)
13224 {
13225 for (int i = 0; i < WPOOH_array.Count(); i++)
13226 {
13227 WeaponParticlesOnOverheating WPOOH = WPOOH_array.Get(i);
13228
13229 if (WPOOH)
13230 {
13231 WPOOH.OnUpdate(weapon, ammoType, muzzle_owner, suppressor, config_to_search);
13232 }
13233 }
13234 }
13235 }
13236
13237 // Stops overheating particles
13238 static void StopOverheatingParticles(ItemBase weapon, string ammoType, ItemBase muzzle_owner, ItemBase suppressor, string config_to_search)
13239 {
13240 int id = muzzle_owner.GetMuzzleID();
13241 array<ref WeaponParticlesOnOverheating> WPOOH_array = weapon.m_OnOverheatingEffect.Get(id);
13242
13243 if (WPOOH_array)
13244 {
13245 for (int i = 0; i < WPOOH_array.Count(); i++)
13246 {
13247 WeaponParticlesOnOverheating WPOOH = WPOOH_array.Get(i);
13248
13249 if (WPOOH)
13250 {
13251 WPOOH.OnDeactivate(weapon, ammoType, muzzle_owner, suppressor, config_to_search);
13252 }
13253 }
13254 }
13255 }
13256
13257 //----------------------------------------------------------------
13258 //Item Behaviour - unified approach
13259 override bool IsHeavyBehaviour()
13260 {
13261 if (m_ItemBehaviour == 0)
13262 {
13263 return true;
13264 }
13265
13266 return false;
13267 }
13268
13269 override bool IsOneHandedBehaviour()
13270 {
13271 if (m_ItemBehaviour == 1)
13272 {
13273 return true;
13274 }
13275
13276 return false;
13277 }
13278
13279 override bool IsTwoHandedBehaviour()
13280 {
13281 if (m_ItemBehaviour == 2)
13282 {
13283 return true;
13284 }
13285
13286 return false;
13287 }
13288
13289 bool IsDeployable()
13290 {
13291 return false;
13292 }
13293
13295 float GetDeployTime()
13296 {
13297 return UATimeSpent.DEFAULT_DEPLOY;
13298 }
13299
13300
13301 //----------------------------------------------------------------
13302 // Item Targeting (User Actions)
13303 override void SetTakeable(bool pState)
13304 {
13305 m_IsTakeable = pState;
13306 SetSynchDirty();
13307 }
13308
13309 override bool IsTakeable()
13310 {
13311 return m_IsTakeable;
13312 }
13313
13314 // For cases where we want to show object widget which cant be taken to hands
13316 {
13317 return false;
13318 }
13319
13321 protected void PreLoadSoundAttachmentType()
13322 {
13323 string att_type = "None";
13324
13325 if (ConfigIsExisting("soundAttType"))
13326 {
13327 att_type = ConfigGetString("soundAttType");
13328 }
13329
13330 m_SoundAttType = att_type;
13331 }
13332
13333 override string GetAttachmentSoundType()
13334 {
13335 return m_SoundAttType;
13336 }
13337
13338 //----------------------------------------------------------------
13339 //SOUNDS - ItemSoundHandler
13340 //----------------------------------------------------------------
13341
13342 string GetPlaceSoundset(); // played when deploy starts
13343 string GetLoopDeploySoundset(); // played when deploy starts and stopped when it finishes
13344 string GetDeploySoundset(); // played when deploy sucessfully finishes
13345 string GetLoopFoldSoundset(); // played when fold starts and stopped when it finishes
13346 string GetFoldSoundset(); // played when fold sucessfully finishes
13347
13349 {
13350 if (!m_ItemSoundHandler)
13352
13353 return m_ItemSoundHandler;
13354 }
13355
13356 // override to initialize sounds
13357 protected void InitItemSounds()
13358 {
13359 if (GetPlaceSoundset() == string.Empty && GetDeploySoundset() == string.Empty && GetLoopDeploySoundset() == string.Empty && !GetInventoryItemType().SetDetachSoundEvent() && !GetInventoryItemType().SetAttachSoundEvent())
13360 return;
13361
13363
13364 if (GetPlaceSoundset() != string.Empty)
13365 handler.AddSound(SoundConstants.ITEM_PLACE, GetPlaceSoundset());
13366
13367 if (GetDeploySoundset() != string.Empty)
13368 handler.AddSound(SoundConstants.ITEM_DEPLOY, GetDeploySoundset());
13369
13370 SoundParameters params = new SoundParameters();
13371 params.m_Loop = true;
13372 if (GetLoopDeploySoundset() != string.Empty)
13373 handler.AddSound(SoundConstants.ITEM_DEPLOY_LOOP, GetLoopDeploySoundset(), params);
13374 }
13375
13376 // Start sound using ItemSoundHandler
13377 void StartItemSoundServer(int id, int slotId)
13378 {
13379 if (g_Game.IsServer() || !g_Game.IsMultiplayer()) // single player or server side multiplayer
13380 {
13381 m_SoundSyncSlotID = slotId;
13382 m_SoundSyncPlay = id;
13383
13384 SetSynchDirty();
13385
13386 g_Game.GetCallQueue(CALL_CATEGORY_SYSTEM).Remove(ClearStartItemSoundServer); // in case one is queued already
13387 g_Game.GetCallQueue(CALL_CATEGORY_SYSTEM).CallLater(ClearStartItemSoundServer, 100);
13388 }
13389 }
13390
13391 void StartItemSoundServer(int id)
13392 {
13393 StartItemSoundServer(id, InventorySlots.INVALID);
13394 }
13395
13396 // Stop sound using ItemSoundHandler
13397 void StopItemSoundServer(int id)
13398 {
13399 if (!g_Game.IsServer())
13400 return;
13401
13402 m_SoundSyncStop = id;
13403 SetSynchDirty();
13404
13405 g_Game.GetCallQueue(CALL_CATEGORY_SYSTEM).Remove(ClearStopItemSoundServer); // in case one is queued already
13406 g_Game.GetCallQueue(CALL_CATEGORY_SYSTEM).CallLater(ClearStopItemSoundServer, 100);
13407 }
13408
13409 protected void ClearStartItemSoundServer()
13410 {
13411 m_SoundSyncPlay = 0;
13412 m_SoundSyncSlotID = InventorySlots.INVALID;
13413 }
13414
13415 protected void ClearStopItemSoundServer()
13416 {
13417 m_SoundSyncStop = 0;
13418 }
13419
13420 void OnApply(PlayerBase player);
13421
13423 {
13424 return 1.0;
13425 };
13426 //returns applicable selection
13427 array<string> GetHeadHidingSelection()
13428 {
13430 }
13431
13433 {
13435 }
13436
13437 WrittenNoteData GetWrittenNoteData() {};
13438
13440 {
13441 SetDynamicPhysicsLifeTime(0.01);
13442 m_ItemBeingDroppedPhys = false;
13443 }
13444
13446 {
13447 array<string> zone_names = new array<string>;
13448 GetDamageZones(zone_names);
13449 for (int i = 0; i < zone_names.Count(); i++)
13450 {
13451 SetHealthMax(zone_names.Get(i),"Health");
13452 }
13453 SetHealthMax("","Health");
13454 }
13455
13457 void SetZoneDamageCEInit()
13458 {
13459 float global_health = GetHealth01("","Health");
13460 array<string> zones = new array<string>;
13461 GetDamageZones(zones);
13462 //set damage of all zones to match global health level
13463 for (int i = 0; i < zones.Count(); i++)
13464 {
13465 SetHealth01(zones.Get(i),"Health",global_health);
13466 }
13467 }
13468
13470 bool IsCoverFaceForShave(string slot_name)
13471 {
13472 return IsExclusionFlagPresent(PlayerBase.GetFaceCoverageShaveValues());
13473 }
13474
13475 void ProcessItemWetness(float delta, bool hasParent, bool hasRootAsPlayer, ItemBase refParentIB)
13476 {
13477 if (!hasRootAsPlayer)
13478 {
13479 if (refParentIB)
13480 {
13481 // parent is wet
13482 if ((refParentIB.GetWet() >= GameConstants.STATE_SOAKING_WET) && (m_VarWet < m_VarWetMax))
13483 AddWet(delta * GameConstants.WETNESS_RATE_WETTING_INSIDE);
13484 // parent has liquid inside
13485 else if ((refParentIB.GetLiquidType() != 0) && (refParentIB.GetQuantity() > 0) && (m_VarWet < m_VarWetMax))
13486 AddWet(delta * GameConstants.WETNESS_RATE_WETTING_LIQUID);
13487 // drying
13488 else if (m_VarWet > m_VarWetMin)
13489 AddWet(-1 * delta * GetDryingIncrement("ground") * 2);
13490 }
13491 else
13492 {
13493 // drying on ground or inside non-itembase (car, ...)
13494 if (m_VarWet > m_VarWetMin)
13495 AddWet(-1 * delta * GetDryingIncrement("ground"));
13496 }
13497 }
13498 }
13499
13500 void ProcessItemTemperature(float delta, bool hasParent, bool hasRootAsPlayer, ItemBase refParentIB)
13501 {
13503 {
13504 float target = g_Game.GetMission().GetWorldData().GetBaseEnvTemperatureAtObject(this);
13505 if (GetTemperature() != target || !IsFreezeThawProgressFinished())
13506 {
13507 float heatPermCoef = 1.0;
13508 EntityAI ent = this;
13509 while (ent)
13510 {
13511 heatPermCoef *= ent.GetHeatPermeabilityCoef();
13512 ent = ent.GetHierarchyParent();
13513 }
13514
13515 SetTemperatureEx(new TemperatureDataInterpolated(target,ETemperatureAccessTypes.ACCESS_WORLD,delta,GameConstants.TEMP_COEF_WORLD,heatPermCoef));
13516 }
13517 }
13518 }
13519
13520 void HierarchyCheck(out bool hasParent, out bool hasRootAsPlayer, out ItemBase refParentIB)
13521 {
13522 // hierarchy check for an item to decide whether it has some parent and it is in some player inventory
13523 EntityAI parent = GetHierarchyParent();
13524 if (!parent)
13525 {
13526 hasParent = false;
13527 hasRootAsPlayer = false;
13528 }
13529 else
13530 {
13531 hasParent = true;
13532 hasRootAsPlayer = (GetHierarchyRootPlayer() != null);
13533 refParentIB = ItemBase.Cast(parent);
13534 }
13535 }
13536
13537 protected void ProcessDecay(float delta, bool hasRootAsPlayer)
13538 {
13539 // this is stub, implemented on Edible_Base
13540 }
13541
13542 bool CanDecay()
13543 {
13544 // return true used on selected food clases so they can decay
13545 return false;
13546 }
13547
13548 protected bool CanProcessDecay()
13549 {
13550 // this is stub, implemented on Edible_Base class
13551 // used to determine whether it is still necessary for the food to decay
13552 return false;
13553 }
13554
13555 protected bool CanHaveWetness()
13556 {
13557 // return true used on selected items that have a wetness effect
13558 return false;
13559 }
13560
13562 bool CanBeConsumed(ConsumeConditionData data = null)
13563 {
13564 return !GetIsFrozen() && IsOpen();
13565 }
13566
13567 override void ProcessVariables()
13568 {
13569 bool hasParent = false, hasRootAsPlayer = false;
13570 ItemBase refParentIB;
13571
13572 bool wwtu = g_Game.IsWorldWetTempUpdateEnabled();
13573 bool foodDecay = g_Game.IsFoodDecayEnabled();
13574
13575 if (wwtu || foodDecay)
13576 {
13577 bool processWetness = wwtu && CanHaveWetness();
13578 bool processTemperature = wwtu && CanHaveTemperature();
13579 bool processDecay = foodDecay && CanDecay() && CanProcessDecay();
13580
13581 if (processWetness || processTemperature || processDecay)
13582 {
13583 HierarchyCheck(hasParent, hasRootAsPlayer, refParentIB);
13584
13585 if (processWetness)
13586 ProcessItemWetness(m_ElapsedSinceLastUpdate, hasParent, hasRootAsPlayer, refParentIB);
13587
13588 if (processTemperature)
13589 ProcessItemTemperature(m_ElapsedSinceLastUpdate, hasParent, hasRootAsPlayer, refParentIB);
13590
13591 if (processDecay)
13592 ProcessDecay(m_ElapsedSinceLastUpdate, hasRootAsPlayer);
13593 }
13594 }
13595 }
13596
13599 {
13600 return m_TemperaturePerQuantityWeight * GameConstants.ITEM_TEMPERATURE_QUANTITY_WEIGHT_MULTIPLIER;
13601 }
13602
13603 override float GetTemperatureFreezeThreshold()
13604 {
13606 return Liquid.GetFreezeThreshold(GetLiquidType());
13607
13608 return super.GetTemperatureFreezeThreshold();
13609 }
13610
13611 override float GetTemperatureThawThreshold()
13612 {
13614 return Liquid.GetThawThreshold(GetLiquidType());
13615
13616 return super.GetTemperatureThawThreshold();
13617 }
13618
13619 override float GetItemOverheatThreshold()
13620 {
13622 return Liquid.GetBoilThreshold(GetLiquidType());
13623
13624 return super.GetItemOverheatThreshold();
13625 }
13626
13627 override float GetTemperatureFreezeTime()
13628 {
13629 if (HasQuantity())
13630 return Math.Lerp(GameConstants.TEMPERATURE_TIME_FREEZE_MIN,Math.Max(GameConstants.TEMPERATURE_TIME_FREEZE_MIN,super.GetTemperatureFreezeTime()),GetQuantityNormalized());
13631
13632 return super.GetTemperatureFreezeTime();
13633 }
13634
13635 override float GetTemperatureThawTime()
13636 {
13637 if (HasQuantity())
13638 return Math.Lerp(GameConstants.TEMPERATURE_TIME_THAW_MIN,Math.Max(GameConstants.TEMPERATURE_TIME_FREEZE_MIN,super.GetTemperatureThawTime()),GetQuantityNormalized());
13639
13640 return super.GetTemperatureThawTime();
13641 }
13642
13644 void AffectLiquidContainerOnFill(int liquid_type, float amount);
13646 void AffectLiquidContainerOnTransfer(int liquidType, float amount, float sourceLiquidTemperature);
13647
13648 bool IsCargoException4x3(EntityAI item)
13649 {
13650 return (item.IsKindOf("Cauldron") || item.IsKindOf("Pot") || item.IsKindOf("FryingPan") || item.IsKindOf("SmallProtectorCase") || (item.IsKindOf("PortableGasStove") && item.FindAttachmentBySlotName("CookingEquipment")));
13651 }
13652
13654 {
13655 MiscGameplayFunctions.TransferItemProperties(oldItem, this);
13656 }
13657
13659 void AddLightSourceItem(ItemBase lightsource)
13660 {
13661 m_LightSourceItem = lightsource;
13662 }
13663
13665 {
13666 m_LightSourceItem = null;
13667 }
13668
13670 {
13671 return m_LightSourceItem;
13672 }
13673
13675 array<int> GetValidFinishers()
13676 {
13677 return null;
13678 }
13679
13681 bool GetActionWidgetOverride(out typename name)
13682 {
13683 return false;
13684 }
13685
13686 bool PairWithDevice(notnull ItemBase otherDevice)
13687 {
13688 if (g_Game.IsServer())
13689 {
13690 ItemBase explosive = otherDevice;
13692 if (!trg)
13693 {
13694 trg = RemoteDetonatorTrigger.Cast(otherDevice);
13695 explosive = this;
13696 }
13697
13698 explosive.PairRemote(trg);
13699 trg.SetControlledDevice(explosive);
13700
13701 int persistentID = RemotelyActivatedItemBehaviour.GeneratePersistentID();
13702 trg.SetPersistentPairID(persistentID);
13703 explosive.SetPersistentPairID(persistentID);
13704
13705 return true;
13706 }
13707 return false;
13708 }
13709
13711 float GetBaitEffectivity()
13712 {
13713 float ret = 1.0;
13714 if (HasQuantity())
13715 ret *= GetQuantityNormalized();
13716 ret *= GetHealth01();
13717
13718 return ret;
13719 }
13720
13721 #ifdef DEVELOPER
13722 override void SetDebugItem()
13723 {
13724 super.SetDebugItem();
13725 _itemBase = this;
13726 }
13727
13728 override string GetDebugText()
13729 {
13730 string text = super.GetDebugText();
13731
13732 text += string.Format("Heat isolation(raw): %1\n", GetHeatIsolation());
13733 text += string.Format("Heat isolation(modified): %1\n", MiscGameplayFunctions.GetCurrentItemHeatIsolation(this));
13734
13735 return text;
13736 }
13737 #endif
13738
13739 bool CanBeUsedForSuicide()
13740 {
13741 return true;
13742 }
13743
13745 //DEPRECATED BELOW
13747 // Backwards compatibility
13748 void ProcessItemWetnessAndTemperature(float delta, bool hasParent, bool hasRootAsPlayer, ItemBase refParentIB)
13749 {
13750 ProcessItemWetness(delta, hasParent, hasRootAsPlayer, refParentIB);
13751 ProcessItemTemperature(delta, hasParent, hasRootAsPlayer, refParentIB);
13752 }
13753
13754 // replaced by ItemSoundHandler
13755 protected EffectSound m_SoundDeployFinish;
13756 protected EffectSound m_SoundPlace;
13757 protected EffectSound m_DeployLoopSoundEx;
13758 protected EffectSound m_SoundDeploy;
13759 bool m_IsPlaceSound;
13760 bool m_IsDeploySound;
13762
13763 string GetDeployFinishSoundset();
13764 void PlayDeploySound();
13765 void PlayDeployFinishSound();
13766 void PlayPlaceSound();
13767 void PlayDeployLoopSoundEx();
13768 void StopDeployLoopSoundEx();
13769 void SoundSynchRemoteReset();
13770 void SoundSynchRemote();
13771 bool UsesGlobalDeploy(){return false;}
13772 bool CanPlayDeployLoopSound(){return false;}
13774 bool IsPlaceSound(){return m_IsPlaceSound;}
13775 bool IsDeploySound(){return m_IsDeploySound;}
13776 void SetIsPlaceSound(bool is_place_sound);
13777 void SetIsDeploySound(bool is_deploy_sound);
13778
13779 [Obsolete("Use ItemSoundHandler instead")]
13781 void PlayAttachSound(string slot_type)
13782 {
13783 if (!g_Game.IsDedicatedServer())
13784 {
13785 if (ConfigIsExisting("attachSoundSet"))
13786 {
13787 string cfg_path = "";
13788 string soundset = "";
13789 string type_name = GetType();
13790
13791 TStringArray cfg_soundset_array = new TStringArray;
13792 TStringArray cfg_slot_array = new TStringArray;
13793 ConfigGetTextArray("attachSoundSet",cfg_soundset_array);
13794 ConfigGetTextArray("attachSoundSlot",cfg_slot_array);
13795
13796 if (cfg_soundset_array.Count() > 0 && cfg_soundset_array.Count() == cfg_slot_array.Count())
13797 {
13798 for (int i = 0; i < cfg_soundset_array.Count(); i++)
13799 {
13800 if (cfg_slot_array[i] == slot_type)
13801 {
13802 soundset = cfg_soundset_array[i];
13803 break;
13804 }
13805 }
13806 }
13807
13808 if (soundset != "")
13809 {
13810 EffectSound sound = SEffectManager.PlaySound(soundset, GetPosition());
13811 sound.SetAutodestroy(true);
13812 }
13813 }
13814 }
13815 }
13816
13817 void PlayDetachSound(string slot_type) {}
13818}
13819
13820EntityAI SpawnItemOnLocation(string object_name, notnull InventoryLocation loc, bool full_quantity)
13821{
13822 EntityAI entity = SpawnEntity(object_name, loc, ECE_IN_INVENTORY, RF_DEFAULT);
13823 if (entity)
13824 {
13825 bool is_item = entity.IsInherited(ItemBase);
13826 if (is_item && full_quantity)
13827 {
13828 ItemBase item = ItemBase.Cast(entity);
13829 item.SetQuantity(item.GetQuantityInit());
13830 }
13831 }
13832 else
13833 {
13834 ErrorEx("Cannot spawn entity: " + object_name,ErrorExSeverity.INFO);
13835 return NULL;
13836 }
13837 return entity;
13838}
13839
13840void SetupSpawnedItem(ItemBase item, float health, float quantity)
13841{
13842 if (item)
13843 {
13844 if (health > 0)
13845 item.SetHealth("", "", health);
13846
13847 if (item.CanHaveTemperature())
13848 {
13849 item.SetTemperatureDirect(GameConstants.ITEM_TEMPERATURE_NEUTRAL_ZONE_MIDDLE);
13850 if (item.CanFreeze())
13851 item.SetFrozen(false);
13852 }
13853
13854 if (item.HasEnergyManager())
13855 {
13856 if (quantity >= 0)
13857 {
13858 item.GetCompEM().SetEnergy0To1(quantity);
13859 }
13860 else
13861 {
13862 item.GetCompEM().SetEnergy(Math.AbsFloat(quantity));
13863 }
13864 }
13865 else if (item.IsMagazine())
13866 {
13867 Magazine mag = Magazine.Cast(item);
13868 if (quantity >= 0)
13869 {
13870 mag.ServerSetAmmoCount(mag.GetAmmoMax() * quantity);
13871 }
13872 else
13873 {
13874 mag.ServerSetAmmoCount(Math.AbsFloat(quantity));
13875 }
13876
13877 }
13878 else
13879 {
13880 if (quantity >= 0)
13881 {
13882 item.SetQuantityNormalized(quantity, false);
13883 }
13884 else
13885 {
13886 item.SetQuantity(Math.AbsFloat(quantity));
13887 }
13888
13889 }
13890 }
13891}
13892
13893#ifdef DEVELOPER
13894ItemBase _itemBase;//watched item goes here(LCTRL+RMB->Watch)
13895#endif
Param4< int, int, string, int > TSelectableActionInfoWithColor
Param3 TSelectableActionInfo
EWetnessLevel
Определения 3_Game/DayZ/Entities/EntityAI.c:2
bool SetAttachSoundEvent()
void InventoryItemType()
bool SetDetachSoundEvent()
InventoryMode
NOTE: PREDICTIVE is not to be used at all in multiplayer.
const int INPUT_UDT_ITEM_MANIPULATION
class LogManager EntityAI
eBleedingSourceType GetType()
ItemSuppressor SuppressorBase
void ActionDropItem()
Определения ActionDropItem.c:34
void ActionManagerBase(PlayerBase player)
Определения ActionManagerBase.c:63
map< typename, ref array< ActionBase_Basic > > TInputActionMap
Определения ActionManagerClient.c:1
void AddAction(typename actionName)
Определения AdvancedCommunication.c:220
void RemoveAction(typename actionName)
Определения AdvancedCommunication.c:252
TInputActionMap m_InputActionMap
Определения AdvancedCommunication.c:137
bool m_ActionsInitialize
Определения AdvancedCommunication.c:138
override void GetActions(typename action_input_type, out array< ActionBase_Basic > actions)
Определения AdvancedCommunication.c:202
void InitializeActions()
Определения AdvancedCommunication.c:190
string Debug()
Определения CachedEquipmentStorageBase.c:29
const int ECE_PLACE_ON_SURFACE
Определения CentralEconomy.c:37
proto native void SpawnEntity(string sClassName, vector vPos, float fRange, int iCount)
Spawn an entity through CE.
const int ECE_IN_INVENTORY
Определения CentralEconomy.c:36
const int RF_DEFAULT
Определения CentralEconomy.c:65
PlayerSpawnPresetDiscreteItemSetSlotData name
one set for cargo
PlayerSpawnPreset slotName
Open
Implementations only.
override void EEOnCECreate()
Определения ContaminatedArea_Dynamic.c:42
map
Определения ControlsXboxNew.c:4
CookingMethodType
Определения Cooking.c:2
DamageType
exposed from C++ (do not change)
Определения DamageSystem.c:11
DayZGame g_Game
Определения DayZGame.c:3942
DayZGame GetDayZGame()
Определения DayZGame.c:3944
EActions
Определения EActions.c:2
ERPCs
Определения ERPCs.c:2
PluginAdminLog m_AdminLog
Определения EmoteManager.c:159
const int MIN
Определения EnConvert.c:28
const int MAX
Определения EnConvert.c:27
float GetTemperature()
Определения Environment.c:500
override bool IsExplosive()
Определения ExplosivesBase.c:59
override bool IsPrepareToDelete()
Определения FireplaceBase.c:643
override bool CanHaveTemperature()
Определения FireplaceBase.c:561
class GP5GasMask extends MaskBase ItemBase
proto GizmoApi GetGizmoApi()
Empty
Определения Hand_States.c:14
FindInventoryLocationType
flags for searching locations in inventory
Определения InventoryLocation.c:18
InventoryLocationType
types of Inventory Location
Определения InventoryLocation.c:4
class BoxCollidingParams component
ComponentInfo for BoxCollidingResult.
bool DamageItemInCargo(float damage)
Определения ItemBase.c:6453
static bool HasDebugActionsMask(int mask)
Определения ItemBase.c:5680
bool HidesSelectionBySlot()
Определения ItemBase.c:9413
float m_VarWetMin
Определения ItemBase.c:4937
void SplitItem(PlayerBase player)
Определения ItemBase.c:6908
void CopyScriptPropertiesFrom(EntityAI oldItem)
Определения ItemBase.c:9634
override void InsertAgent(int agent, float count=1)
Определения ItemBase.c:8895
override float GetQuantityNormalized()
Gets quantity in normalized 0..1 form between the item's Min a Max values as defined by item's config...
Определения ItemBase.c:8330
static void SetDebugActionsMask(int mask)
Определения ItemBase.c:5685
void SetIsDeploySound(bool is_deploy_sound)
bool IsOpen()
Определения ItemBase.c:9038
void SplitItemToInventoryLocation(notnull InventoryLocation dst)
Определения ItemBase.c:6875
override bool IsHeavyBehaviour()
Определения ItemBase.c:9240
override void SetWetMax()
Определения ItemBase.c:8616
bool IsCoverFaceForShave(string slot_name)
DEPRECATED in use, but returns correct values nontheless. Check performed elsewhere.
Определения ItemBase.c:9451
void ClearStartItemSoundServer()
Определения ItemBase.c:9390
float m_VarWet
Определения ItemBase.c:4934
void ProcessItemTemperature(float delta, bool hasParent, bool hasRootAsPlayer, ItemBase refParentIB)
Определения ItemBase.c:9481
map< typename, ref ActionOverrideData > TActionAnimOverrideMap
Определения ItemBase.c:3
override void RemoveAllAgentsExcept(int agent_to_keep)
Определения ItemBase.c:8890
static ref map< int, ref array< ref WeaponParticlesOnBulletCasingEject > > m_OnBulletCasingEjectEffect
Определения ItemBase.c:4997
bool CanBeMovedOverride()
Определения ItemBase.c:7600
override void SetWet(float value, bool allow_client=false)
Определения ItemBase.c:8592
ref TIntArray m_SingleUseActions
Определения ItemBase.c:4983
void StartItemSoundServer(int id, int slotId)
Определения ItemBase.c:9358
override void ProcessVariables()
Определения ItemBase.c:9548
ref TStringArray m_HeadHidingSelections
Определения ItemBase.c:5011
float GetWeightSpecialized(bool forceRecalc=false)
Определения ItemBase.c:8423
bool LoadAgents(ParamsReadContext ctx, int version)
Определения ItemBase.c:8956
void UpdateQuickbarShortcutVisibility(PlayerBase player)
To be called on moving item within character's inventory; 'player' should never be null.
Определения ItemBase.c:8806
void OverrideActionAnimation(typename action, int commandUID, int stanceMask=-1, int commandUIDProne=-1)
Определения ItemBase.c:5271
ref array< ref OverheatingParticle > m_OverheatingParticles
Определения ItemBase.c:5009
override float GetTemperatureFreezeThreshold()
Определения ItemBase.c:9584
bool m_IsSoundSynchRemote
Определения ItemBase.c:9742
float m_OverheatingShots
Определения ItemBase.c:5004
void StopItemSoundServer(int id)
Определения ItemBase.c:9378
static void ToggleDebugActionsMask(int mask)
Определения ItemBase.c:5700
void IncreaseOverheating(ItemBase weapon, string ammoType, ItemBase muzzle_owner, ItemBase suppressor, string config_to_search)
Определения ItemBase.c:5424
override float GetTemperatureFreezeTime()
Определения ItemBase.c:9608
ref array< int > m_CompatibleLocks
Определения ItemBase.c:5021
bool CanBeCooked()
Определения ItemBase.c:7556
override void CombineItemsClient(EntityAI entity2, bool use_stack_max=true)
Определения ItemBase.c:5767
float m_TemperaturePerQuantityWeight
Определения ItemBase.c:5035
bool m_RecipesInitialized
Определения ItemBase.c:4919
void SplitIntoStackMax(EntityAI destination_entity, int slot_id, PlayerBase player)
Определения ItemBase.c:6546
override float GetTemperatureThawThreshold()
Определения ItemBase.c:9592
override void OnEnergyConsumed()
Определения ItemBase.c:8536
void RefreshAudioVisualsOnClient(CookingMethodType cooking_method, bool is_done, bool is_empty, bool is_burned)
cooking-related effect methods
Определения Bottle_Base.c:158
int GetNumberOfItems()
Returns the number of items in cargo, otherwise returns 0(non-cargo objects). Recursive.
Определения ItemBase.c:8462
override EWetnessLevel GetWetLevel()
Определения ItemBase.c:8656
float GetSingleInventoryItemWeight()
Определения ItemBase.c:8418
ref TIntArray m_InteractActions
Определения ItemBase.c:4985
void MessageToOwnerStatus(string text)
Send message to owner player in grey color.
Определения ItemBase.c:7620
float m_VarQuantity
Определения ItemBase.c:4925
bool CanPlayDeployLoopSound()
Определения ItemBase.c:9753
override float GetWetMax()
Определения ItemBase.c:8626
bool CanBeUsedForSuicide()
Определения ItemBase.c:9720
override void CombineItemsEx(EntityAI entity2, bool use_stack_max=true)
Определения ItemBase.c:7193
void OnItemInHandsPlayerSwimStart(PlayerBase player)
void SetIsHologram(bool is_hologram)
Определения ItemBase.c:5905
void OnSyncVariables(ParamsReadContext ctx)
DEPRECATED (most likely)
Определения ItemBase.c:7774
void DoAmmoExplosion()
Определения ItemBase.c:6388
static ref map< int, ref array< ref WeaponParticlesOnFire > > m_OnFireEffect
Определения ItemBase.c:4996
void SplitIntoStackMaxCargoClient(EntityAI destination_entity, int idx, int row, int col)
Определения ItemBase.c:6732
int GetItemSize()
Определения ItemBase.c:7585
bool m_CanBeMovedOverride
Определения ItemBase.c:4962
override string ChangeIntoOnAttach(string slot)
Определения ItemBase.c:6312
void UpdateOverheating(ItemBase weapon=null, string ammoType="", ItemBase muzzle_owner=null, ItemBase suppressor=null, string config_to_search="")
Определения ItemBase.c:5492
bool CanDecay()
Определения ItemBase.c:9523
ScriptedLightBase GetLight()
string GetPlaceSoundset()
bool AddQuantity(float value, bool destroy_config=true, bool destroy_forced=false)
add item quantity[related to varQuantity... config entry], destroy_config = true > if the quantity re...
Определения ItemBase.c:8303
void SetQuantityMax()
Определения ItemBase.c:8308
override float GetQuantity()
Определения ItemBase.c:8398
int m_ColorComponentR
Определения ItemBase.c:4974
int m_ShotsToStartOverheating
Определения ItemBase.c:5006
override void OnWetChanged(float newVal, float oldVal)
Определения ItemBase.c:8641
void StopOverheating(ItemBase weapon=null, string ammoType="", ItemBase muzzle_owner=null, ItemBase suppressor=null, string config_to_search="")
Определения ItemBase.c:5499
static void PlayFireParticles(ItemBase weapon, int muzzle_index, string ammoType, ItemBase muzzle_owner, ItemBase suppressor, string config_to_search)
Определения ItemBase.c:9139
void OnOverheatingDecay()
Определения ItemBase.c:5462
float GetDryingIncrement(string pIncrementName)
Определения ItemBase.c:8574
void SoundSynchRemoteReset()
int m_Cleanness
Определения ItemBase.c:4940
bool HasMuzzle()
Returns true if this item has a muzzle (weapons, suppressors)
Определения ItemBase.c:5600
bool UsesGlobalDeploy()
Определения ItemBase.c:9752
int m_ItemBehaviour
Определения ItemBase.c:4955
override bool CanReleaseAttachment(EntityAI attachment)
Определения ItemBase.c:9111
float m_HeatIsolation
Определения ItemBase.c:4950
float m_VarWetInit
Определения ItemBase.c:4936
override void OnMovedInsideCargo(EntityAI container)
Определения ItemBase.c:5945
void SetCEBasedQuantity()
Определения ItemBase.c:5713
bool m_CanPlayImpactSound
Определения ItemBase.c:4946
override string GetAttachmentSoundType()
Определения ItemBase.c:9314
float GetOverheatingCoef()
Определения ItemBase.c:5519
array< string > GetHeadHidingSelection()
Определения ItemBase.c:9408
void PlayAttachSound(string slot_type)
Plays sound on item attach. Be advised, the config structure may slightly change in 1....
Определения ItemBase.c:9762
override bool IsStoreLoad()
Определения ItemBase.c:8668
int ComputeQuantityUsed(ItemBase other_item, bool use_stack_max=true)
Определения ItemBase.c:7169
bool IsLightSource()
Определения ItemBase.c:5841
bool m_HasQuantityBar
Определения ItemBase.c:4968
void SetResultOfSplit(bool value)
Определения ItemBase.c:7164
void SplitIntoStackMaxCargo(EntityAI destination_entity, int idx, int row, int col)
Определения ItemBase.c:6796
void OnAttachmentQuantityChanged(ItemBase item)
Called on server side when some attachment's quantity is changed. Call super.OnAttachmentQuantityChan...
Определения ItemBase.c:6965
void UpdateAllOverheatingParticles()
Определения ItemBase.c:5527
float GetSoakingIncrement(string pIncrementName)
Определения ItemBase.c:8583
static void StopOverheatingParticles(ItemBase weapon, string ammoType, ItemBase muzzle_owner, ItemBase suppressor, string config_to_search)
Определения ItemBase.c:9219
override float GetStoreLoadedQuantity()
Определения ItemBase.c:8678
int m_LockType
Определения ItemBase.c:5022
const int ITEM_SOUNDS_MAX
Определения ItemBase.c:5027
bool m_CanBeDigged
Определения ItemBase.c:4969
float m_ItemAttachOffset
Определения ItemBase.c:4952
float GetItemModelLength()
Определения ItemBase.c:8685
bool m_ThrowItemOnDrop
Определения ItemBase.c:4960
override bool ReadVarsFromCTX(ParamsReadContext ctx, int version=-1)
Определения ItemBase.c:7919
override void CheckForRoofLimited(float timeTresholdMS=3000)
Roof check for entity, limited by time (anti-spam solution)
Определения ItemBase.c:8971
void Close()
float GetHeatIsolation()
Определения ItemBase.c:8569
void CombineItems(ItemBase other_item, bool use_stack_max=true)
Определения ItemBase.c:7198
void TransferModifiers(PlayerBase reciever)
appears to be deprecated, legacy code
float GetTemperaturePerQuantityWeight()
Used in heat comfort calculations only!
Определения ItemBase.c:9579
bool CanHaveWetness()
Определения ItemBase.c:9536
int m_CleannessMin
Определения ItemBase.c:4942
void TransferAgents(int agents)
transfer agents from another item
Определения ItemBase.c:8904
string IDToName(int id)
Определения ItemBase.c:7767
bool CanBeConsumed(ConsumeConditionData data=null)
Items cannot be consumed if frozen by default. Override for exceptions.
Определения ItemBase.c:9543
float GetHeatIsolationInit()
Определения ItemBase.c:8564
void PlayPlaceSound()
void SetCanBeMovedOverride(bool setting)
Определения ItemBase.c:7607
override bool HasQuantity()
Определения ItemBase.c:8393
float m_VarWetPrev
Определения ItemBase.c:4935
int m_SoundSyncStop
Определения ItemBase.c:5029
bool IsCargoException4x3(EntityAI item)
Определения ItemBase.c:9629
ref TIntArray m_ContinuousActions
Определения ItemBase.c:4984
int GetMuzzleID()
Returns global muzzle ID. If not found, then it gets automatically registered.
Определения ItemBase.c:5609
void LoadParticleConfigOnFire(int id)
Определения ItemBase.c:5294
int m_VarLiquidType
Определения ItemBase.c:4954
int m_QuickBarBonus
Определения ItemBase.c:4956
void PreLoadSoundAttachmentType()
Attachment Sound Type getting from config file.
Определения ItemBase.c:9302
override float GetWetInit()
Определения ItemBase.c:8636
int m_ImpactSoundSurfaceHash
Определения ItemBase.c:4948
int m_SoundSyncPlay
Определения ItemBase.c:5028
int m_MaxOverheatingValue
Определения ItemBase.c:5007
void SetupSpawnedItem(ItemBase item, float health, float quantity)
Определения ItemBase.c:4931
bool m_IsTakeable
Определения ItemBase.c:4959
bool ShouldSplitQuantity(float quantity)
Определения ItemBase.c:6503
static ref map< string, int > m_WeaponTypeToID
Определения ItemBase.c:4999
string GetLockSoundSet()
Определения ItemBase.c:8734
string GetColorString()
Returns item's PROCEDURAL color as formated string, i.e. "#(argb,8,8,3)color(0.15,...
Определения ItemBase.c:8765
array< int > GetValidFinishers()
returns an array of possible finishers
Определения ItemBase.c:9656
void OnAttachmentQuantityChangedEx(ItemBase item, float delta)
Called on server side when some attachment's quantity is changed. Call super.OnAttachmentQuantityChan...
Определения ItemBase.c:6971
class ItemBase extends InventoryItem SpawnItemOnLocation(string object_name, notnull InventoryLocation loc, bool full_quantity)
Определения ItemBase.c:4911
ItemSoundHandler GetItemSoundHandler()
Определения ItemBase.c:9329
override int GetQuantityMin()
Определения ItemBase.c:8382
void SplitIntoStackMaxToInventoryLocationClient(notnull InventoryLocation dst)
Определения ItemBase.c:6711
override int GetQuickBarBonus()
Определения ItemBase.c:5179
override void SetTakeable(bool pState)
Определения ItemBase.c:9284
float m_OverheatingDecayInterval
Определения ItemBase.c:5008
void SetIsPlaceSound(bool is_place_sound)
override void SplitIntoStackMaxClient(EntityAI destination_entity, int slot_id)
Определения ItemBase.c:6523
void HierarchyCheck(out bool hasParent, out bool hasRootAsPlayer, out ItemBase refParentIB)
Определения ItemBase.c:9501
bool CanProcessDecay()
Определения ItemBase.c:9529
void RemoveAudioVisualsOnClient()
Определения Bottle_Base.c:151
void SoundSynchRemote()
static void AddDebugActionsMask(int mask)
Определения ItemBase.c:5690
void PlayDeployLoopSoundEx()
void RemoveLightSourceItem()
Определения ItemBase.c:9645
bool CanRepair(ItemBase item_repair_kit)
Определения ItemBase.c:7571
bool can_this_be_combined
Определения ItemBase.c:4964
EffectSound m_SoundDeploy
Определения ItemBase.c:9739
int m_SoundSyncSlotID
Определения ItemBase.c:5030
int m_Count
Определения ItemBase.c:4930
float GetBaitEffectivity()
generic effectivity as a bait for animal catching
Определения ItemBase.c:9692
float GetDeployTime()
how long it takes to deploy this item in seconds
Определения ItemBase.c:9276
override bool IsSplitable()
Определения ItemBase.c:6490
bool DamageItemAttachments(float damage)
Определения ItemBase.c:6473
override void WriteVarsToCTX(ParamsWriteContext ctx)
Определения ItemBase.c:7883
void ConvertEnergyToQuantity()
Определения ItemBase.c:8551
override void RemoveAllAgents()
Определения ItemBase.c:8885
override void SetQuantityToMinimum()
Определения ItemBase.c:8314
bool m_WantPlayImpactSound
Определения ItemBase.c:4945
override float GetTemperatureThawTime()
Определения ItemBase.c:9616
ref map< int, ref array< ref WeaponParticlesOnOverheating > > m_OnOverheatingEffect
Определения ItemBase.c:4998
int m_ColorComponentG
Определения ItemBase.c:4975
float m_StoreLoadedQuantity
Определения ItemBase.c:4932
void MessageToOwnerAction(string text)
Send message to owner player in yellow color.
Определения ItemBase.c:7638
int m_ColorComponentA
Определения ItemBase.c:4977
int m_VarQuantityInit
Определения ItemBase.c:4927
float GetFilterDamageRatio()
Определения ItemBase.c:5594
override void SetLiquidType(int value, bool allow_client=false)
Определения ItemBase.c:8778
void OnQuantityChanged(float delta)
Called on server side when this item's quantity is changed. Call super.OnQuantityChanged(); first whe...
Определения ItemBase.c:6942
void OnApply(PlayerBase player)
override void SetQuantityNormalized(float value, bool destroy_config=true, bool destroy_forced=false)
Sets quantity in normalized 0..1 form between the item's Min a Max values as defined by item's config...
Определения ItemBase.c:8321
bool m_HideSelectionsBySlot
Определения ItemBase.c:5012
bool IsOverheatingEffectActive()
Определения ItemBase.c:5457
void SetIsBeingPlaced(bool is_being_placed)
Определения ItemBase.c:5874
int GetLiquidContainerMask()
Определения ItemBase.c:5811
void SetInventoryLocationToVicinityOrCurrent(EntityAI root, inout InventoryLocation dst)
Определения ItemBase.c:7078
ref Timer m_CheckOverheating
Определения ItemBase.c:5005
void RegisterOverheatingParticle(Particle p, float min_heat_coef, float max_heat_coef, int particle_id, Object parent, vector local_pos, vector local_ori)
Определения ItemBase.c:5505
float GetEnergy()
Определения ItemBase.c:8525
bool CanBeDigged()
Определения ItemBase.c:5890
bool GetActionWidgetOverride(out typename name)
If we need a different (handheld)item action widget displayed, the logic goes in here.
Определения ItemBase.c:9662
bool IsNVG()
Определения ItemBase.c:5822
float GetUnitWeight(bool include_wetness=true)
Obsolete, use GetWeightEx instead.
Определения ItemBase.c:8485
void SetZoneDamageCEInit()
Sets zone damages to match randomized global health set by CE (CE spawn only)
Определения ItemBase.c:9438
bool m_IsDeploySound
Определения ItemBase.c:9741
bool CanEat()
Определения ItemBase.c:7531
static void PlayOverheatingParticles(ItemBase weapon, string ammoType, ItemBase muzzle_owner, ItemBase suppressor, string config_to_search)
Определения ItemBase.c:9179
override bool IsOneHandedBehaviour()
Определения ItemBase.c:9250
void AddLightSourceItem(ItemBase lightsource)
Adds a light source child.
Определения ItemBase.c:9640
bool IsLiquidContainer()
Определения ItemBase.c:5806
FoodStage GetFoodStage()
overridden on Edible_Base; so we don't have to parse configs all the time
Определения ItemBase.c:7551
override float GetSingleInventoryItemWeightEx()
Определения ItemBase.c:8409
void SaveAgents(ParamsWriteContext ctx)
Определения ItemBase.c:8963
override int GetTargetQuantityMax(int attSlotID=-1)
Определения ItemBase.c:8363
int m_CleannessInit
Определения ItemBase.c:4941
float GetDisinfectQuantity(int system=0, Param param1=null)
Определения ItemBase.c:5589
override int GetAgents()
Определения ItemBase.c:8910
int m_VarQuantityMax
Определения ItemBase.c:4929
override bool IsHologram()
Определения ItemBase.c:5885
float GetItemAttachOffset()
Определения ItemBase.c:8694
bool IsPlaceSound()
Определения ItemBase.c:9755
static int GetDebugActionsMask()
Определения ItemBase.c:5675
override int GetLiquidType()
Определения ItemBase.c:8794
void ProcessDecay(float delta, bool hasRootAsPlayer)
Определения ItemBase.c:9518
override bool IsItemBase()
Определения ItemBase.c:7684
void PlayDeploySound()
override bool IsTwoHandedBehaviour()
Определения ItemBase.c:9260
void ExplodeAmmo()
Определения ItemBase.c:6375
bool IsCombineAll(ItemBase other_item, bool use_stack_max=false)
Определения ItemBase.c:7154
float GetProtectionLevel(int type, bool consider_filter=false, int system=0)
Определения ItemBase.c:8984
static void PlayBulletCasingEjectParticles(ItemBase weapon, string ammoType, ItemBase muzzle_owner, ItemBase suppressor, string config_to_search)
Определения ItemBase.c:9159
override void OnEnergyAdded()
Определения ItemBase.c:8543
void AffectLiquidContainerOnFill(int liquid_type, float amount)
from enviro source
void AffectLiquidContainerOnTransfer(int liquidType, float amount, float sourceLiquidTemperature)
from other liquid container source
string GetExplosiveTriggerSlotName()
Определения ItemBase.c:5834
EffectSound m_DeployLoopSoundEx
Определения ItemBase.c:9738
override void DeSerializeNumericalVars(array< float > floats)
Определения ItemBase.c:7824
void StopItemDynamicPhysics()
Определения ItemBase.c:9420
bool HasFoodStage()
Определения ItemBase.c:7544
override void SetStoreLoad(bool value)
Определения ItemBase.c:8663
float GetOverheatingValue()
Определения ItemBase.c:5419
bool ContainsAgent(int agent_id)
Определения ItemBase.c:8863
override void AddWet(float value)
Определения ItemBase.c:8611
bool IsLiquidPresent()
Определения ItemBase.c:5801
bool IsFullQuantity()
Определения ItemBase.c:8403
override void EOnContact(IEntity other, Contact extra)
Определения ItemBase.c:6084
void SplitIntoStackMaxHands(PlayerBase player)
Определения ItemBase.c:6847
void SplitIntoStackMaxHandsClient(PlayerBase player)
Определения ItemBase.c:6823
int m_CleannessMax
Определения ItemBase.c:4943
float m_VarStackMax
Определения ItemBase.c:4931
ref Timer m_PhysDropTimer
Определения ItemBase.c:5018
void MessageToOwnerFriendly(string text)
Send message to owner player in green color.
Определения ItemBase.c:7656
override void SetStoreLoadedQuantity(float value)
Определения ItemBase.c:8673
bool m_IsResultOfSplit string m_SoundAttType
distinguish if item has been created as new or it came from splitting (server only flag)
Определения ItemBase.c:4972
void CheckOverheating(ItemBase weapon=null, string ammoType="", ItemBase muzzle_owner=null, ItemBase suppressor=null, string config_to_search="")
Определения ItemBase.c:5440
void UnlockFromParent()
Unlocks this item from its attachment slot of its parent.
Определения ItemBase.c:5755
bool Repair(PlayerBase player, ItemBase item_repair_kit, float specialty_weight)
Определения ItemBase.c:7578
void OnLiquidTypeChanged(int oldType, int newType)
Определения ItemBase.c:8799
void StartOverheating(ItemBase weapon=null, string ammoType="", ItemBase muzzle_owner=null, ItemBase suppressor=null, string config_to_search="")
Определения ItemBase.c:5486
void PlayDeployFinishSound()
bool AllowFoodConsumption()
Определения ItemBase.c:8721
bool m_IsOverheatingEffectActive
Определения ItemBase.c:5003
int m_LiquidContainerMask
Определения ItemBase.c:4953
void ProcessItemWetness(float delta, bool hasParent, bool hasRootAsPlayer, ItemBase refParentIB)
Определения ItemBase.c:9456
override int GetCleanness()
Определения ItemBase.c:8716
bool PairWithDevice(notnull ItemBase otherDevice)
Определения ItemBase.c:9667
bool IsDeploySound()
Определения ItemBase.c:9756
static void RemoveDebugActionsMask(int mask)
Определения ItemBase.c:5695
static void UpdateOverheatingParticles(ItemBase weapon, string ammoType, ItemBase muzzle_owner, ItemBase suppressor, string config_to_search)
Определения ItemBase.c:9199
int m_VarQuantityMin
Определения ItemBase.c:4928
void PerformDamageSystemReinit()
Определения ItemBase.c:9426
override void ClearInventory()
Определения ItemBase.c:8504
static int m_LastRegisteredWeaponID
Определения ItemBase.c:5000
ItemBase GetLightSourceItem()
Определения ItemBase.c:9650
void MessageToOwnerImportant(string text)
Send message to owner player in red color.
Определения ItemBase.c:7674
override float GetItemOverheatThreshold()
Определения ItemBase.c:9600
void StopDeployLoopSoundEx()
bool m_CanThisBeSplit
Определения ItemBase.c:4965
override void SerializeNumericalVars(array< float > floats_out)
Определения ItemBase.c:7788
ItemBase SplitIntoStackMaxToInventoryLocationEx(notnull InventoryLocation dst)
Определения ItemBase.c:6762
float m_ItemModelLength
Определения ItemBase.c:4951
bool m_IsHologram
Определения ItemBase.c:4958
static int m_DebugActionsMask
Определения ItemBase.c:4918
void KillAllOverheatingParticles()
Определения ItemBase.c:5555
bool CanBeCookedOnStick()
Определения ItemBase.c:7561
override int GetQuantityMax()
Определения ItemBase.c:8349
void GetRecipesActions(Man player, out TSelectableActionInfoArray outputList)
Определения ItemBase.c:7232
void OnActivatedByTripWire()
bool IsColorSet()
Определения ItemBase.c:8759
override void RemoveAgent(int agent_id)
Определения ItemBase.c:8876
bool m_ItemBeingDroppedPhys
Определения ItemBase.c:4961
override bool CanPutAsAttachment(EntityAI parent)
Определения ItemBase.c:9066
void PlayDetachSound(string slot_type)
Определения ItemBase.c:9798
static ref map< typename, ref TInputActionMap > m_ItemTypeActionsMap
Определения ItemBase.c:4912
void ProcessItemWetnessAndTemperature(float delta, bool hasParent, bool hasRootAsPlayer, ItemBase refParentIB)
Определения ItemBase.c:9729
override bool IsBeingPlaced()
Определения ItemBase.c:5869
int GetQuantityInit()
Определения ItemBase.c:8387
float ComputeQuantityUsedEx(ItemBase other_item, bool use_stack_max=true)
Определения ItemBase.c:7174
bool IsResultOfSplit()
Определения ItemBase.c:7159
bool m_FixDamageSystemInit
Определения ItemBase.c:4963
float m_ImpactSpeed
Определения ItemBase.c:4947
bool m_IsStoreLoad
Определения ItemBase.c:4966
int GetLiquidTypeInit()
Определения ItemBase.c:8789
string GetDeployFinishSoundset()
ItemBase m_LightSourceItem
Определения ItemBase.c:4981
void LockToParent()
Locks this item in it's current attachment slot of its parent. This makes the "locked" icon visible i...
Определения ItemBase.c:5742
override void SplitIntoStackMaxEx(EntityAI destination_entity, int slot_id)
Определения ItemBase.c:6633
int m_AttachedAgents
Определения ItemBase.c:4989
string m_LockSoundSet
Определения ItemBase.c:5024
void LoadParticleConfigOnOverheating(int id)
Определения ItemBase.c:5363
float m_VarQuantityPrev
Определения ItemBase.c:4926
bool IsSoundSynchRemote()
Определения ItemBase.c:9754
bool m_CanShowQuantity
Определения ItemBase.c:4967
override void OnRightClick()
Определения ItemBase.c:7014
int m_ColorComponentB
Определения ItemBase.c:4976
static ref map< typename, ref TActionAnimOverrideMap > m_ItemActionOverrides
Определения ItemBase.c:4914
bool IsActionTargetVisible()
Определения ItemBase.c:9296
override void OnItemAttachmentSlotChanged(notnull InventoryLocation oldLoc, notnull InventoryLocation newLoc)
Определения ItemBase.c:6119
override void EEHitBy(TotalDamageResult damageResult, int damageType, EntityAI source, int component, string dmgZone, string ammo, vector modelPos, float speedCoef)
Определения ItemBase.c:6412
bool m_IsBeingPlaced
Определения ItemBase.c:4957
int NameToID(string name)
Определения ItemBase.c:7761
void ~ItemBase()
Определения ItemBase.c:5640
override void OnWetLevelChanged(EWetnessLevel newLevel, EWetnessLevel oldLevel)
Определения ItemBase.c:8651
void ClearStopItemSoundServer()
Определения ItemBase.c:9396
override string ChangeIntoOnDetach()
Определения ItemBase.c:6336
float m_VarWetMax
Определения ItemBase.c:4938
void SplitIntoStackMaxToInventoryLocation(notnull InventoryLocation dst)
Определения ItemBase.c:6757
int GetLockType()
Определения ItemBase.c:8729
EffectSound m_SoundDeployFinish
Определения ItemBase.c:9736
override float GetWet()
Определения ItemBase.c:8621
EffectSound m_SoundPlace
Определения ItemBase.c:9737
float GetQuantityNormalizedScripted()
Определения ItemBase.c:8335
override void SetCleanness(int value, bool allow_client=false)
Определения ItemBase.c:8703
bool m_IsPlaceSound
Определения ItemBase.c:9740
override float GetWetMin()
Определения ItemBase.c:8631
ref ItemSoundHandler m_ItemSoundHandler
Определения ItemBase.c:5032
override bool KindOf(string tag)
Определения ItemBase.c:7690
void ItemSoundHandler(ItemBase parent)
Определения ItemSoundHandler.c:31
string Type
Определения JsonDataContaminatedArea.c:11
EffectSound m_LockingSound
Определения Land_Underground_Entrance.c:336
string GetDebugText()
Определения ModifierBase.c:71
@ LOWEST
Определения PPEConstants.c:54
void PluginItemDiagnostic()
Определения PluginItemDiagnostic.c:74
PluginBase GetPlugin(typename plugin_type)
Определения PluginManager.c:325
override RemotelyActivatedItemBehaviour GetRemotelyActivatedItemBehaviour()
Определения RemoteDetonator.c:272
void RemoteDetonatorTrigger()
Определения RemoteDetonator.c:233
override void OnActivatedByItem(notnull ItemBase item)
Called when this item is activated by other.
Определения RemoteDetonator.c:305
int particle_id
Определения SmokeSimulation.c:28
ETemperatureAccessTypes
Определения TemperatureAccessConstants.c:2
override void Explode(int damageType, string ammoType="")
Определения Trap_LandMine.c:220
bool m_Initialized
Определения UiHintPanel.c:317
int GetID()
Определения ActionBase.c:1335
void OnItemLocationChanged(ItemBase item)
Определения ActionBase.c:974
GetInputType()
Определения ActionBase.c:221
int m_StanceMask
Определения ActionBase.c:25
int m_CommandUIDProne
Определения ActionBase.c:24
int m_CommandUID
Определения ActionBase.c:23
proto native int GetItemCount()
proto native EntityAI GetItem(int index)
float GetEnergyAtSpawn()
Определения ComponentEnergyManager.c:1325
void SetEnergy0To1(float energy01)
Energy manager: Sets stored energy for this device between 0 and MAX based on relative input value be...
Определения ComponentEnergyManager.c:550
float GetEnergyMaxPristine()
Energy manager: Returns the maximum amount of energy this device can store. It's damage is NOT taken ...
Определения ComponentEnergyManager.c:1320
override void SetAutodestroy(bool auto_destroy)
Sets whether Effect automatically cleans up when it stops.
Определения EffectSound.c:603
bool IsSoundPlaying()
Get whether EffectSound is currently playing.
Определения EffectSound.c:274
override bool IsMan()
Определения 3_Game/DayZ/Entities/Man.c:48
proto native EntityAI GetAttachmentFromIndex(int index)
proto native bool GetCurrentInventoryLocation(out notnull InventoryLocation loc)
returns information about current item location
proto native bool EnumerateInventory(InventoryTraversalType tt, out array< EntityAI > items)
enumerate inventory using traversal type and filling items array
proto native CargoBase GetCargo()
cargo
static proto native EntityAI LocationCreateEntity(notnull InventoryLocation inv_loc, string type, int iSetupFlags, int iRotation)
creates new item directly at location
proto native int AttachmentCount()
Returns count of attachments attached to this item.
proto native bool FindFreeLocationFor(notnull EntityAI item, FindInventoryLocationType flags, out notnull InventoryLocation loc)
FindFreeLocationFor.
proto void SelectObject(Object object)
proto void SelectPhysics(Physics physics)
Определения ItemBase.c:21
proto native bool IsValid()
verify current set inventory location
proto native EntityAI GetParent()
returns parent of current inventory location
proto native int GetSlot()
returns slot id if current type is Attachment
proto native int GetCol()
returns column of cargo if current type is Cargo / ProxyCargo
proto native int GetRow()
returns row of cargo if current type is Cargo / ProxyCargo
bool WriteToContext(ParamsWriteContext ctx)
Определения InventoryLocation.c:507
proto native int GetType()
returns type of InventoryLocation
proto native int GetIdx()
returns index of cargo if current type is Cargo / ProxyCargo
proto native void SetCargo(notnull EntityAI parent, EntityAI e, int idx, int row, int col, bool flip)
sets current inventory location type to Cargo with coordinates (idx, row, col)
proto native bool GetFlip()
returns flip status of cargo
proto native EntityAI GetItem()
returns item of current inventory location
InventoryLocation.
Определения InventoryLocation.c:30
override bool CanDisplayCargo()
Определения TentBase.c:91
override void OnInventoryEnter(Man player)
Определения BarbedWire.c:203
override string GetFoldSoundset()
Определения BaseBuildingBase.c:108
override bool CanPutAsAttachment(EntityAI parent)
Определения ItemBase.c:7
override bool CanReceiveItemIntoCargo(EntityAI item)
Определения TentBase.c:934
override bool OnStoreLoad(ParamsReadContext ctx, int version)
Определения GardenBase.c:199
override void OnWasDetached(EntityAI parent, int slot_id)
override void EEOnAfterLoad()
Определения GardenBase.c:242
override void EEDelete(EntityAI parent)
Определения BaseBuildingBase.c:68
override bool CanBeRepairedByCrafting()
Определения TentBase.c:86
override void OnPlacementStarted(Man player)
Определения BatteryCharger.c:376
override void OnItemLocationChanged(EntityAI old_owner, EntityAI new_owner)
Определения BarbedWire.c:357
override bool IsElectricAppliance()
Определения BatteryCharger.c:43
override bool IsItemTent()
Определения TentBase.c:81
override string GetLoopFoldSoundset()
Определения BaseBuildingBase.c:113
override bool CanMakeGardenplot()
Определения FieldShovel.c:3
override void GetDebugActions(out TSelectableActionInfoArrayEx outputList)
Определения PowerGenerator.c:397
override void EEItemLocationChanged(notnull InventoryLocation oldLoc, notnull InventoryLocation newLoc)
Определения HandcuffsLocked.c:12
override WrittenNoteData GetWrittenNoteData()
Определения Paper.c:30
override int GetDamageSystemVersionChange()
Определения BaseBuildingBase.c:1238
override bool SetQuantity(float value, bool destroy_config=true, bool destroy_forced=false, bool allow_client=false, bool clamp_to_stack_max=true)
Определения PileOfWoodenPlanks.c:88
override void InitItemVariables()
Определения Matchbox.c:3
override void SetActionAnimOverrides()
Определения PickAxe.c:28
override void OnCreatePhysics()
Определения BaseBuildingBase.c:489
override string GetDeploySoundset()
Определения BarbedWire.c:392
override float GetBandagingEffectivity()
Определения BandageDressing.c:49
override bool OnAction(int action_id, Man player, ParamsReadContext ctx)
Определения PowerGenerator.c:409
override void EEHealthLevelChanged(int oldLevel, int newLevel, string zone)
Определения BaseBuildingBase.c:496
override void OnStoreSave(ParamsWriteContext ctx)
Определения GardenBase.c:266
override void AfterStoreLoad()
Определения BarbedWire.c:155
override int GetOnDigWormsAmount()
Определения FieldShovel.c:27
override bool IsSelfAdjustingTemperature()
Определения PortableGasStove.c:287
override bool IsPlayerInside(PlayerBase player, string selection)
Определения BaseBuildingBase.c:1037
override void OnVariablesSynchronized()
Определения GardenBase.c:97
override void RefreshPhysics()
Определения BatteryCharger.c:359
override bool CanObstruct()
Определения BaseBuildingBase.c:84
override void OnWasAttached(EntityAI parent, int slot_id)
override bool CanReceiveAttachment(EntityAI attachment, int slotId)
Определения BaseBuildingBase.c:982
override bool CanPutInCargo(EntityAI parent)
Определения GardenBase.c:331
override string GetLoopDeploySoundset()
Определения BarbedWire.c:397
override void OnPlacementComplete(Man player, vector position="0 0 0", vector orientation="0 0 0")
Определения BarbedWire.c:372
override void OnInventoryExit(Man player)
Определения BatteryCharger.c:341
override bool IsTakeable()
Определения BaseBuildingBase.c:1008
override bool IsIgnoredByConstruction()
Определения BaseBuildingBase.c:1170
override void InitItemSounds()
Определения BaseBuildingBase.c:94
override void EEKilled(Object killer)
Определения HandcuffsLocked.c:70
override void OnCombine(ItemBase other_item)
Определения BandageDressing.c:71
override bool CanExplodeInFire()
Определения LargeGasCannister.c:3
override bool IsFacingPlayer(PlayerBase player, string selection)
Определения BaseBuildingBase.c:1032
override bool CanBeCombined(EntityAI other_item, bool reservation_check=true, bool stack_max_limit=false)
Определения Rag.c:61
override bool IsBloodContainer()
Определения BloodContainerBase.c:10
override bool CanBeSplit()
Определения Rag.c:34
override bool IsDeployable()
Определения BaseBuildingBase.c:365
override void OnRPC(PlayerIdentity sender, int rpc_type, ParamsReadContext ctx)
Определения ToolBase.c:24
override bool CanBeDisinfected()
Определения BandageDressing.c:54
override float GetInfectionChance(int system=0, Param param=null)
Определения BandageDressing.c:59
override void OnEndPlacement()
Определения KitBase.c:65
Определения ItemBase.c:14
Определения EnMath.c:7
float GetOverheatingLimitMax()
Определения WeaponParticles.c:417
void SetOverheatingLimitMax(float max)
Определения WeaponParticles.c:407
void SetParticleParams(int particle_id, Object parent, vector local_pos, vector local_ori)
Определения WeaponParticles.c:422
float GetOverheatingLimitMin()
Определения WeaponParticles.c:412
Particle GetParticle()
Определения WeaponParticles.c:397
void SetOverheatingLimitMin(float min)
Определения WeaponParticles.c:402
void RegisterParticle(Particle p)
Определения WeaponParticles.c:392
void Stop()
Legacy function for backwards compatibility with 1.14 and below.
Определения Particle.c:266
void SetControlledDevice(EntityAI pDevice)
Определения RemoteDetonator.c:140
bool OnStoreLoad(ParamsReadContext ctx, int version)
void OnStoreSave(ParamsWriteContext ctx)
proto native void Send()
proto bool Write(void value_out)
proto bool Read(void value_in)
bool m_Loop
Определения ItemSoundHandler.c:5
override void Stop()
Определения DayZPlayerImplement.c:40
proto native float GetDamage(string zoneName, string healthType)
override void Refresh()
Определения ChatInputMenu.c:70
void SetCalcDetails(string details)
Определения 3_Game/DayZ/tools/Debug.c:916
void OnRPC(PlayerIdentity sender, int rpc_type, ParamsReadContext ctx)
Определения WrittenNoteData.c:13
const float LOWEST
Определения EnConvert.c:113
Serializer ParamsReadContext
Определения gameplay.c:15
class LOD Object
InventoryTraversalType
tree traversal type, for more see http://en.wikipedia.org/wiki/Tree_traversal
Определения gameplay.c:6
Serializer ParamsWriteContext
Определения gameplay.c:16
const int DEF_BIOLOGICAL
Определения 3_Game/DayZ/constants.c:515
const int DEF_CHEMICAL
Определения 3_Game/DayZ/constants.c:516
const int COMP_TYPE_ENERGY_MANAGER
Определения Component.c:9
ErrorExSeverity
Определения EnDebug.c:62
void Error(string err)
Messagebox with error message.
Определения EnDebug.c:90
enum ShapeType ErrorEx
proto native void SetColor(int color)
array< string > TStringArray
Определения EnScript.c:712
array< int > TIntArray
Определения EnScript.c:714
void Obsolete(string msg="")
Определения EnScript.c:371
EntityEvent
Entity events for event-mask, or throwing event from code.
Определения EnEntity.c:45
static const float ITEM_TEMPERATURE_NEUTRAL_ZONE_MIDDLE
Определения 3_Game/DayZ/constants.c:811
const int VARIABLE_LIQUIDTYPE
Определения 3_Game/DayZ/constants.c:635
const int VARIABLE_CLEANNESS
Определения 3_Game/DayZ/constants.c:638
const int VARIABLE_COLOR
Определения 3_Game/DayZ/constants.c:637
const int VARIABLE_TEMPERATURE
Определения 3_Game/DayZ/constants.c:633
const int VARIABLE_QUANTITY
Определения 3_Game/DayZ/constants.c:631
const int VARIABLE_WET
Определения 3_Game/DayZ/constants.c:634
const int LIQUID_NONE
Определения 3_Game/DayZ/constants.c:532
static proto float AbsFloat(float f)
Returns absolute value.
const int MENU_INVENTORY
Определения 3_Game/DayZ/constants.c:180
proto native bool dBodyIsDynamic(notnull IEntity ent)
const int SAT_CRAFTING
Определения 3_Game/DayZ/constants.c:456
const int SAT_DEBUG_ACTION
Определения 3_Game/DayZ/constants.c:457
vector GetPosition()
Get the world position of the Effect.
Определения Effect.c:473
static proto string Format(string fmt, void param1=NULL, void param2=NULL, void param3=NULL, void param4=NULL, void param5=NULL, void param6=NULL, void param7=NULL, void param8=NULL, void param9=NULL)
Gets n-th character from string.
const int CALL_CATEGORY_GAMEPLAY
Определения 3_Game/DayZ/tools/tools.c:10
const int CALL_CATEGORY_SYSTEM
Определения 3_Game/DayZ/tools/tools.c:8
proto native int GetColor()

Используется в BakedBeansCan_Opened::CanProcessDecay(), PeachesCan_Opened::CanProcessDecay(), SardinesCan_Opened::CanProcessDecay(), SpaghettiCan_Opened::CanProcessDecay(), TunaCan_Opened::CanProcessDecay() и SetActions().