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

◆ AfterStoreLoad()

override void SpawnItemOnLocation::AfterStoreLoad ( )
protected

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

8144{
8145 override bool CanPutAsAttachment(EntityAI parent)
8146 {
8147 return true;
8148 }
8149};
8150
8152{
8153
8154};
8155
8156//const bool QUANTITY_DEBUG_REMOVE_ME = false;
8157
8158class ItemBase extends InventoryItem
8159{
8163
8165
8166 static int m_DebugActionsMask;
8168 // ============================================
8169 // Variable Manipulation System
8170 // ============================================
8171 // Quantity
8172
8173 float m_VarQuantity;
8174 float m_VarQuantityPrev;//for client to know quantity changed during synchronization
8176 int m_VarQuantityMin;
8177 int m_VarQuantityMax;
8178 int m_Count;
8179 float m_VarStackMax;
8180 float m_StoreLoadedQuantity = float.LOWEST;
8181 // Wet
8182 float m_VarWet;
8183 float m_VarWetPrev;//for client to know wetness changed during synchronization
8184 float m_VarWetInit;
8185 float m_VarWetMin;
8186 float m_VarWetMax;
8187 // Cleanness
8188 int m_Cleanness;
8189 int m_CleannessInit;
8190 int m_CleannessMin;
8191 int m_CleannessMax;
8192 // impact sounds
8194 bool m_CanPlayImpactSound = true;
8195 float m_ImpactSpeed;
8197 //
8198 float m_HeatIsolation;
8199 float m_ItemModelLength;
8200 float m_ItemAttachOffset; // Offset length for when the item is attached e.g. to weapon
8202 int m_VarLiquidType;
8203 int m_ItemBehaviour; // -1 = not specified; 0 = heavy item; 1= onehanded item; 2 = twohanded item
8204 int m_QuickBarBonus;
8205 bool m_IsBeingPlaced;
8206 bool m_IsHologram;
8207 bool m_IsTakeable;
8208 bool m_ThrowItemOnDrop;
8211 bool m_FixDamageSystemInit = false; //can be changed on storage version check
8212 bool can_this_be_combined; //Check if item can be combined
8213 bool m_CanThisBeSplit; //Check if item can be split
8214 bool m_IsStoreLoad = false;
8215 bool m_CanShowQuantity;
8216 bool m_HasQuantityBar;
8217 protected bool m_CanBeDigged;
8218 protected bool m_IsResultOfSplit
8219
8220 string m_SoundAttType;
8221 // items color variables
8226 //-------------------------------------------------------
8227
8228 // light source managing
8230
8234
8235 //==============================================
8236 // agent system
8237 private int m_AttachedAgents;
8238
8240 void TransferModifiers(PlayerBase reciever);
8241
8242
8243 // Weapons & suppressors particle effects
8247 ref static map<string, int> m_WeaponTypeToID;
8248 static int m_LastRegisteredWeaponID = 0;
8249
8250 // Overheating effects
8252 float m_OverheatingShots;
8253 ref Timer m_CheckOverheating;
8254 int m_ShotsToStartOverheating = 0; // After these many shots, the overheating effect begins
8255 int m_MaxOverheatingValue = 0; // Limits the number of shots that will be tracked
8256 float m_OverheatingDecayInterval = 1; // Timer's interval for decrementing overheat effect's lifespan
8257 ref array <ref OverheatingParticle> m_OverheatingParticles;
8258
8260 protected bool m_HideSelectionsBySlot;
8261
8262 // Admin Log
8263 PluginAdminLog m_AdminLog;
8264
8265 // misc
8266 ref Timer m_PhysDropTimer;
8267
8268 // Attachment Locking variables
8269 ref array<int> m_CompatibleLocks;
8270 protected int m_LockType;
8271 protected ref EffectSound m_LockingSound;
8272 protected string m_LockSoundSet;
8273
8274 // ItemSoundHandler variables
8275 protected const int ITEM_SOUNDS_MAX = 63; // optimize network synch
8276 protected int m_SoundSyncPlay; // id for sound to play
8277 protected int m_SoundSyncStop; // id for sound to stop
8278 protected int m_SoundSyncSlotID = InventorySlots.INVALID; // slot id for attach/detach sound based on slot
8279
8281
8282 //temperature
8283 private float m_TemperaturePerQuantityWeight;
8284
8285 // -------------------------------------------------------------------------
8286 void ItemBase()
8287 {
8288 SetEventMask(EntityEvent.INIT); // Enable EOnInit event
8292
8293 if (!g_Game.IsDedicatedServer())
8294 {
8295 if (HasMuzzle())
8296 {
8298
8300 {
8302 }
8303 }
8304
8306 m_ActionsInitialize = false;
8307 }
8308
8309 m_OldLocation = null;
8310
8311 if (g_Game.IsServer())
8312 {
8313 m_AdminLog = PluginAdminLog.Cast(GetPlugin(PluginAdminLog));
8314 }
8315
8316 if (ConfigIsExisting("headSelectionsToHide"))
8317 {
8319 ConfigGetTextArray("headSelectionsToHide",m_HeadHidingSelections);
8320 }
8321
8322 m_HideSelectionsBySlot = false;
8323 if (ConfigIsExisting("hideSelectionsByinventorySlot"))
8324 {
8325 m_HideSelectionsBySlot = ConfigGetBool("hideSelectionsByinventorySlot");
8326 }
8327
8328 m_QuickBarBonus = Math.Max(0, ConfigGetInt("quickBarBonus"));
8329
8330 m_IsResultOfSplit = false;
8331
8333 }
8334
8335 override void InitItemVariables()
8336 {
8337 super.InitItemVariables();
8338
8339 m_VarQuantityInit = ConfigGetInt("varQuantityInit");
8340 m_VarQuantity = m_VarQuantityInit;//should be by the CE, this is just a precaution
8341 m_VarQuantityMin = ConfigGetInt("varQuantityMin");
8342 m_VarQuantityMax = ConfigGetInt("varQuantityMax");
8343 m_VarStackMax = ConfigGetFloat("varStackMax");
8344 m_Count = ConfigGetInt("count");
8345
8346 m_CanShowQuantity = ConfigGetBool("quantityShow");
8347 m_HasQuantityBar = ConfigGetBool("quantityBar");
8348
8349 m_CleannessInit = ConfigGetInt("varCleannessInit");
8351 m_CleannessMin = ConfigGetInt("varCleannessMin");
8352 m_CleannessMax = ConfigGetInt("varCleannessMax");
8353
8354 m_WantPlayImpactSound = false;
8355 m_ImpactSpeed = 0.0;
8356
8357 m_VarWetInit = ConfigGetFloat("varWetInit");
8359 m_VarWetMin = ConfigGetFloat("varWetMin");
8360 m_VarWetMax = ConfigGetFloat("varWetMax");
8361
8362 m_LiquidContainerMask = ConfigGetInt("liquidContainerType");
8363 if (IsLiquidContainer() && GetQuantity() != 0)
8365 m_IsBeingPlaced = false;
8366 m_IsHologram = false;
8367 m_IsTakeable = true;
8368 m_CanBeMovedOverride = false;
8372 m_CanBeDigged = ConfigGetBool("canBeDigged");
8373
8374 m_CompatibleLocks = new array<int>();
8375 ConfigGetIntArray("compatibleLocks", m_CompatibleLocks);
8376 m_LockType = ConfigGetInt("lockType");
8377
8378 //Define if item can be split and set ability to be combined accordingly
8379 m_CanThisBeSplit = false;
8380 can_this_be_combined = false;
8381 if (ConfigIsExisting("canBeSplit"))
8382 {
8383 can_this_be_combined = ConfigGetBool("canBeSplit");
8385 }
8386
8387 m_ItemBehaviour = -1;
8388 if (ConfigIsExisting("itemBehaviour"))
8389 m_ItemBehaviour = ConfigGetInt("itemBehaviour");
8390
8391 //RegisterNetSyncVariableInt("m_VariablesMask");
8392 if (HasQuantity()) RegisterNetSyncVariableFloat("m_VarQuantity", GetQuantityMin(), m_VarQuantityMax);
8393 RegisterNetSyncVariableFloat("m_VarWet", GetWetMin(), GetWetMax(), 2);
8394 RegisterNetSyncVariableInt("m_VarLiquidType");
8395 RegisterNetSyncVariableInt("m_Cleanness",0,1);
8396
8397 RegisterNetSyncVariableBoolSignal("m_WantPlayImpactSound");
8398 RegisterNetSyncVariableFloat("m_ImpactSpeed");
8399 RegisterNetSyncVariableInt("m_ImpactSoundSurfaceHash");
8400
8401 RegisterNetSyncVariableInt("m_ColorComponentR", 0, 255);
8402 RegisterNetSyncVariableInt("m_ColorComponentG", 0, 255);
8403 RegisterNetSyncVariableInt("m_ColorComponentB", 0, 255);
8404 RegisterNetSyncVariableInt("m_ColorComponentA", 0, 255);
8405
8406 RegisterNetSyncVariableBool("m_IsBeingPlaced");
8407 RegisterNetSyncVariableBool("m_IsTakeable");
8408 RegisterNetSyncVariableBool("m_IsHologram");
8409
8412 {
8413 RegisterNetSyncVariableInt("m_SoundSyncPlay", 0, ITEM_SOUNDS_MAX);
8414 RegisterNetSyncVariableInt("m_SoundSyncStop", 0, ITEM_SOUNDS_MAX);
8415 RegisterNetSyncVariableInt("m_SoundSyncSlotID", int.MIN, int.MAX);
8416 }
8417
8418 m_LockSoundSet = ConfigGetString("lockSoundSet");
8419
8421 if (ConfigIsExisting("temperaturePerQuantityWeight"))
8422 m_TemperaturePerQuantityWeight = ConfigGetFloat("temperaturePerQuantityWeight");
8423
8424 m_SoundSyncSlotID = -1;
8425 }
8426
8427 override int GetQuickBarBonus()
8428 {
8429 return m_QuickBarBonus;
8430 }
8431
8432 void InitializeActions()
8433 {
8435 if (!m_InputActionMap)
8436 {
8438 m_InputActionMap = iam;
8439 SetActions();
8441 }
8442 }
8443
8444 override void GetActions(typename action_input_type, out array<ActionBase_Basic> actions)
8445 {
8447 {
8448 m_ActionsInitialize = true;
8450 }
8451
8452 actions = m_InputActionMap.Get(action_input_type);
8453 }
8454
8455 void SetActions()
8456 {
8457 AddAction(ActionTakeItem);
8458 AddAction(ActionTakeItemToHands);
8459 AddAction(ActionWorldCraft);
8461 AddAction(ActionAttachWithSwitch);
8462 }
8463
8464 void SetActionAnimOverrides(); // Override action animation for specific item
8465
8466 void AddAction(typename actionName)
8467 {
8468 ActionBase action = ActionManagerBase.GetAction(actionName);
8469
8470 if (!action)
8471 {
8472 Debug.LogError("Action " + actionName + " dosn't exist!");
8473 return;
8474 }
8475
8476 typename ai = action.GetInputType();
8477 if (!ai)
8478 {
8479 m_ActionsInitialize = false;
8480 return;
8481 }
8482
8483 array<ActionBase_Basic> action_array = m_InputActionMap.Get(ai);
8484 if (!action_array)
8485 {
8486 action_array = new array<ActionBase_Basic>;
8487 m_InputActionMap.Insert(ai, action_array);
8488 }
8489 if (LogManager.IsActionLogEnable())
8490 {
8491 Debug.ActionLog(action.ToString() + " -> " + ai, this.ToString() , "n/a", "Add action");
8492 }
8493
8494 if (action_array.Find(action) != -1)
8495 {
8496 Debug.Log("Action " + action.Type() + " already added to " + this + ", skipping!");
8497 }
8498 else
8499 {
8500 action_array.Insert(action);
8501 }
8502 }
8503
8504 void RemoveAction(typename actionName)
8505 {
8506 PlayerBase player = PlayerBase.Cast(g_Game.GetPlayer());
8507 ActionBase action = player.GetActionManager().GetAction(actionName);
8508 typename ai = action.GetInputType();
8509 array<ActionBase_Basic> action_array = m_InputActionMap.Get(ai);
8510
8511 if (action_array)
8512 {
8513 action_array.RemoveItem(action);
8514 }
8515 }
8516
8517 // Allows override of default action command per item, defined in the SetActionAnimOverrides() of the item's class
8518 // Set -1 for params which should stay in default state
8519 void OverrideActionAnimation(typename action, int commandUID, int stanceMask = -1, int commandUIDProne = -1)
8520 {
8521 ActionOverrideData overrideData = new ActionOverrideData();
8522 overrideData.m_CommandUID = commandUID;
8523 overrideData.m_CommandUIDProne = commandUIDProne;
8524 overrideData.m_StanceMask = stanceMask;
8525
8526 TActionAnimOverrideMap actionMap = m_ItemActionOverrides.Get(action);
8527 if (!actionMap) // create new map of action > overidables map
8528 {
8529 actionMap = new TActionAnimOverrideMap();
8530 m_ItemActionOverrides.Insert(action, actionMap);
8531 }
8532
8533 actionMap.Insert(this.Type(), overrideData); // insert item -> overrides
8534
8535 }
8536
8537 void OnItemInHandsPlayerSwimStart(PlayerBase player);
8538
8539 ScriptedLightBase GetLight();
8540
8541 // Loads muzzle flash particle configuration from config and saves it to a map for faster access
8542 void LoadParticleConfigOnFire(int id)
8543 {
8544 if (!m_OnFireEffect)
8546
8549
8550 string config_to_search = "CfgVehicles";
8551 string muzzle_owner_config;
8552
8553 if (!m_OnFireEffect.Contains(id))
8554 {
8555 if (IsInherited(Weapon))
8556 config_to_search = "CfgWeapons";
8557
8558 muzzle_owner_config = config_to_search + " " + GetType() + " ";
8559
8560 string config_OnFire_class = muzzle_owner_config + "Particles " + "OnFire ";
8561
8562 int config_OnFire_subclass_count = g_Game.ConfigGetChildrenCount(config_OnFire_class);
8563
8564 if (config_OnFire_subclass_count > 0)
8565 {
8566 array<ref WeaponParticlesOnFire> WPOF_array = new array<ref WeaponParticlesOnFire>;
8567
8568 for (int i = 0; i < config_OnFire_subclass_count; i++)
8569 {
8570 string particle_class = "";
8571 g_Game.ConfigGetChildName(config_OnFire_class, i, particle_class);
8572 string config_OnFire_entry = config_OnFire_class + particle_class;
8573 WeaponParticlesOnFire WPOF = new WeaponParticlesOnFire(this, config_OnFire_entry);
8574 WPOF_array.Insert(WPOF);
8575 }
8576
8577
8578 m_OnFireEffect.Insert(id, WPOF_array);
8579 }
8580 }
8581
8582 if (!m_OnBulletCasingEjectEffect.Contains(id))
8583 {
8584 config_to_search = "CfgWeapons"; // Bullet Eject efect is supported on weapons only.
8585 muzzle_owner_config = config_to_search + " " + GetType() + " ";
8586
8587 string config_OnBulletCasingEject_class = muzzle_owner_config + "Particles " + "OnBulletCasingEject ";
8588
8589 int config_OnBulletCasingEject_count = g_Game.ConfigGetChildrenCount(config_OnBulletCasingEject_class);
8590
8591 if (config_OnBulletCasingEject_count > 0 && IsInherited(Weapon))
8592 {
8593 array<ref WeaponParticlesOnBulletCasingEject> WPOBE_array = new array<ref WeaponParticlesOnBulletCasingEject>;
8594
8595 for (i = 0; i < config_OnBulletCasingEject_count; i++)
8596 {
8597 string particle_class2 = "";
8598 g_Game.ConfigGetChildName(config_OnBulletCasingEject_class, i, particle_class2);
8599 string config_OnBulletCasingEject_entry = config_OnBulletCasingEject_class + particle_class2;
8600 WeaponParticlesOnBulletCasingEject WPOBE = new WeaponParticlesOnBulletCasingEject(this, config_OnBulletCasingEject_entry);
8601 WPOBE_array.Insert(WPOBE);
8602 }
8603
8604
8605 m_OnBulletCasingEjectEffect.Insert(id, WPOBE_array);
8606 }
8607 }
8608 }
8609
8610 // Loads muzzle flash particle configuration from config and saves it to a map for faster access
8612 {
8615
8616 if (!m_OnOverheatingEffect.Contains(id))
8617 {
8618 string config_to_search = "CfgVehicles";
8619
8620 if (IsInherited(Weapon))
8621 config_to_search = "CfgWeapons";
8622
8623 string muzzle_owner_config = config_to_search + " " + GetType() + " ";
8624 string config_OnOverheating_class = muzzle_owner_config + "Particles " + "OnOverheating ";
8625
8626 if (g_Game.ConfigIsExisting(config_OnOverheating_class))
8627 {
8628
8629 m_ShotsToStartOverheating = g_Game.ConfigGetFloat(config_OnOverheating_class + "shotsToStartOverheating");
8630
8632 {
8633 m_ShotsToStartOverheating = -1; // This prevents futher readings from config for future creations of this item
8634 string error = "Error reading config " + GetType() + ">Particles>OnOverheating - Parameter shotsToStartOverheating is configured wrong or is missing! Its value must be 1 or higher!";
8635 Error(error);
8636 return;
8637 }
8638
8639 m_OverheatingDecayInterval = g_Game.ConfigGetFloat(config_OnOverheating_class + "overheatingDecayInterval");
8640 m_MaxOverheatingValue = g_Game.ConfigGetFloat(config_OnOverheating_class + "maxOverheatingValue");
8641
8642
8643
8644 int config_OnOverheating_subclass_count = g_Game.ConfigGetChildrenCount(config_OnOverheating_class);
8645 array<ref WeaponParticlesOnOverheating> WPOOH_array = new array<ref WeaponParticlesOnOverheating>;
8646
8647 for (int i = 0; i < config_OnOverheating_subclass_count; i++)
8648 {
8649 string particle_class = "";
8650 g_Game.ConfigGetChildName(config_OnOverheating_class, i, particle_class);
8651 string config_OnOverheating_entry = config_OnOverheating_class + particle_class;
8652 int entry_type = g_Game.ConfigGetType(config_OnOverheating_entry);
8653
8654 if (entry_type == CT_CLASS)
8655 {
8656 WeaponParticlesOnOverheating WPOF = new WeaponParticlesOnOverheating(this, config_OnOverheating_entry);
8657 WPOOH_array.Insert(WPOF);
8658 }
8659 }
8660
8661
8662 m_OnOverheatingEffect.Insert(id, WPOOH_array);
8663 }
8664 }
8665 }
8666
8667 float GetOverheatingValue()
8668 {
8669 return m_OverheatingShots;
8670 }
8671
8672 void IncreaseOverheating(ItemBase weapon, string ammoType, ItemBase muzzle_owner, ItemBase suppressor, string config_to_search)
8673 {
8674 if (m_MaxOverheatingValue > 0)
8675 {
8677
8678 if (!m_CheckOverheating)
8680
8682 m_CheckOverheating.Run(m_OverheatingDecayInterval, this, "OnOverheatingDecay");
8683
8684 CheckOverheating(weapon, ammoType, muzzle_owner, suppressor, config_to_search);
8685 }
8686 }
8687
8688 void CheckOverheating(ItemBase weapon = null, string ammoType = "", ItemBase muzzle_owner = null, ItemBase suppressor = null, string config_to_search = "")
8689 {
8691 UpdateOverheating(weapon, ammoType, muzzle_owner, suppressor, config_to_search);
8692
8694 StartOverheating(weapon, ammoType, muzzle_owner, suppressor, config_to_search);
8695
8697 StopOverheating(weapon, ammoType, muzzle_owner, suppressor, config_to_search);
8698
8700 {
8702 }
8703 }
8704
8706 {
8708 }
8709
8710 void OnOverheatingDecay()
8711 {
8712 if (m_MaxOverheatingValue > 0)
8713 m_OverheatingShots -= 1 + m_OverheatingShots / m_MaxOverheatingValue; // The hotter a barrel is, the faster it needs to cool down.
8714 else
8716
8717 if (m_OverheatingShots <= 0)
8718 {
8721 }
8722 else
8723 {
8724 if (!m_CheckOverheating)
8726
8728 m_CheckOverheating.Run(m_OverheatingDecayInterval, this, "OnOverheatingDecay");
8729 }
8730
8731 CheckOverheating(this, "", this);
8732 }
8733
8734 void StartOverheating(ItemBase weapon = null, string ammoType = "", ItemBase muzzle_owner = null, ItemBase suppressor = null, string config_to_search = "")
8735 {
8737 ItemBase.PlayOverheatingParticles(this, ammoType, this, suppressor, "CfgWeapons");
8738 }
8739
8740 void UpdateOverheating(ItemBase weapon = null, string ammoType = "", ItemBase muzzle_owner = null, ItemBase suppressor = null, string config_to_search = "")
8741 {
8743 ItemBase.UpdateOverheatingParticles(this, ammoType, this, suppressor, "CfgWeapons");
8745 }
8746
8747 void StopOverheating(ItemBase weapon = null, string ammoType = "", ItemBase muzzle_owner = null, ItemBase suppressor = null, string config_to_search = "")
8748 {
8750 ItemBase.StopOverheatingParticles(weapon, ammoType, muzzle_owner, suppressor, config_to_search);
8751 }
8752
8753 void RegisterOverheatingParticle(Particle p, float min_heat_coef, float max_heat_coef, int particle_id, Object parent, vector local_pos, vector local_ori)
8754 {
8756 m_OverheatingParticles = new array<ref OverheatingParticle>;
8757
8758 OverheatingParticle OP = new OverheatingParticle();
8759 OP.RegisterParticle(p);
8760 OP.SetOverheatingLimitMin(min_heat_coef);
8761 OP.SetOverheatingLimitMax(max_heat_coef);
8762 OP.SetParticleParams(particle_id, parent, local_pos, local_ori);
8763
8764 m_OverheatingParticles.Insert(OP);
8765 }
8766
8767 float GetOverheatingCoef()
8768 {
8769 if (m_MaxOverheatingValue > 0)
8771
8772 return -1;
8773 }
8774
8776 {
8778 {
8779 float overheat_coef = GetOverheatingCoef();
8780 int count = m_OverheatingParticles.Count();
8781
8782 for (int i = count; i > 0; --i)
8783 {
8784 int id = i - 1;
8785 OverheatingParticle OP = m_OverheatingParticles.Get(id);
8786 Particle p = OP.GetParticle();
8787
8788 float overheat_min = OP.GetOverheatingLimitMin();
8789 float overheat_max = OP.GetOverheatingLimitMax();
8790
8791 if (overheat_coef < overheat_min && overheat_coef >= overheat_max)
8792 {
8793 if (p)
8794 {
8795 p.Stop();
8796 OP.RegisterParticle(null);
8797 }
8798 }
8799 }
8800 }
8801 }
8802
8804 {
8806 {
8807 for (int i = m_OverheatingParticles.Count(); i > 0; i--)
8808 {
8809 int id = i - 1;
8810 OverheatingParticle OP = m_OverheatingParticles.Get(id);
8811
8812 if (OP)
8813 {
8814 Particle p = OP.GetParticle();
8815
8816 if (p)
8817 {
8818 p.Stop();
8819 }
8820
8821 delete OP;
8822 }
8823 }
8824
8825 m_OverheatingParticles.Clear();
8827 }
8828 }
8829
8831 float GetInfectionChance(int system = 0, Param param = null)
8832 {
8833 return 0.0;
8834 }
8835
8836
8837 float GetDisinfectQuantity(int system = 0, Param param1 = null)
8838 {
8839 return 250;//default value
8840 }
8841
8842 float GetFilterDamageRatio()
8843 {
8844 return 0;
8845 }
8846
8848 bool HasMuzzle()
8849 {
8850 if (IsInherited(Weapon) || IsInherited(SuppressorBase))
8851 return true;
8852
8853 return false;
8854 }
8855
8857 int GetMuzzleID()
8858 {
8859 if (!m_WeaponTypeToID)
8860 m_WeaponTypeToID = new map<string, int>;
8861
8862 if (m_WeaponTypeToID.Contains(GetType()))
8863 {
8864 return m_WeaponTypeToID.Get(GetType());
8865 }
8866 else
8867 {
8868 // Register new weapon ID
8870 }
8871
8873 }
8874
8881 {
8882 return -1;
8883 }
8884
8885
8886
8887 // -------------------------------------------------------------------------
8888 void ~ItemBase()
8889 {
8890 if (g_Game && g_Game.GetPlayer() && (!g_Game.IsDedicatedServer()))
8891 {
8892 PlayerBase player = PlayerBase.Cast(g_Game.GetPlayer());
8893 int r_index = player.GetHumanInventory().FindUserReservedLocationIndex(this);
8894
8895 if (r_index >= 0)
8896 {
8897 InventoryLocation r_il = new InventoryLocation;
8898 player.GetHumanInventory().GetUserReservedLocation(r_index,r_il);
8899
8900 player.GetHumanInventory().ClearUserReservedLocationAtIndex(r_index);
8901 int r_type = r_il.GetType();
8902 if (r_type == InventoryLocationType.CARGO || r_type == InventoryLocationType.PROXYCARGO)
8903 {
8904 r_il.GetParent().GetOnReleaseLock().Invoke(this);
8905 }
8906 else if (r_type == InventoryLocationType.ATTACHMENT)
8907 {
8908 r_il.GetParent().GetOnAttachmentReleaseLock().Invoke(this, r_il.GetSlot());
8909 }
8910
8911 }
8912
8913 player.GetHumanInventory().ClearUserReservedLocation(this);
8914 }
8915
8916 if (m_LockingSound)
8917 SEffectManager.DestroyEffect(m_LockingSound);
8918 }
8919
8920
8921
8922 // -------------------------------------------------------------------------
8923 static int GetDebugActionsMask()
8924 {
8925 return ItemBase.m_DebugActionsMask;
8926 }
8927
8928 static bool HasDebugActionsMask(int mask)
8929 {
8930 return ItemBase.m_DebugActionsMask & mask;
8931 }
8932
8933 static void SetDebugActionsMask(int mask)
8934 {
8935 ItemBase.m_DebugActionsMask = mask;
8936 }
8937
8938 static void AddDebugActionsMask(int mask)
8939 {
8940 ItemBase.m_DebugActionsMask |= mask;
8941 }
8942
8943 static void RemoveDebugActionsMask(int mask)
8944 {
8945 ItemBase.m_DebugActionsMask &= ~mask;
8946 }
8947
8948 static void ToggleDebugActionsMask(int mask)
8949 {
8950 if (HasDebugActionsMask(mask))
8951 {
8953 }
8954 else
8955 {
8956 AddDebugActionsMask(mask);
8957 }
8958 }
8959
8960 // -------------------------------------------------------------------------
8961 void SetCEBasedQuantity()
8962 {
8963 if (GetEconomyProfile())
8964 {
8965 float q_max = GetEconomyProfile().GetQuantityMax();
8966 if (q_max > 0)
8967 {
8968 float q_min = GetEconomyProfile().GetQuantityMin();
8969 float quantity_randomized = Math.RandomFloatInclusive(q_min, q_max);
8970
8971 if (HasComponent(COMP_TYPE_ENERGY_MANAGER))//more direct access for speed
8972 {
8973 ComponentEnergyManager comp = GetCompEM();
8974 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
8975 {
8976 comp.SetEnergy0To1(quantity_randomized);
8977 }
8978 }
8979 else if (HasQuantity())
8980 {
8981 SetQuantityNormalized(quantity_randomized, false);
8982 //PrintString("<==> Normalized quantity for item: "+ GetType()+", qmin:"+q_min.ToString()+"; qmax:"+q_max.ToString()+";quantity:" +quantity_randomized.ToString());
8983 }
8984
8985 }
8986 }
8987 }
8988
8990 void LockToParent()
8991 {
8992 EntityAI parent = GetHierarchyParent();
8993
8994 if (parent)
8995 {
8996 InventoryLocation inventory_location_to_lock = new InventoryLocation;
8997 GetInventory().GetCurrentInventoryLocation(inventory_location_to_lock);
8998 parent.GetInventory().SetSlotLock(inventory_location_to_lock.GetSlot(), true);
8999 }
9000 }
9001
9003 void UnlockFromParent()
9004 {
9005 EntityAI parent = GetHierarchyParent();
9006
9007 if (parent)
9008 {
9009 InventoryLocation inventory_location_to_unlock = new InventoryLocation;
9010 GetInventory().GetCurrentInventoryLocation(inventory_location_to_unlock);
9011 parent.GetInventory().SetSlotLock(inventory_location_to_unlock.GetSlot(), false);
9012 }
9013 }
9014
9015 override void CombineItemsClient(EntityAI entity2, bool use_stack_max = true)
9016 {
9017 /*
9018 ref Param1<EntityAI> item = new Param1<EntityAI>(entity2);
9019 RPCSingleParam(ERPCs.RPC_ITEM_COMBINE, item, g_Game.GetPlayer());
9020 */
9021 ItemBase item2 = ItemBase.Cast(entity2);
9022
9023 if (g_Game.IsClient())
9024 {
9025 if (ScriptInputUserData.CanStoreInputUserData())
9026 {
9027 ScriptInputUserData ctx = new ScriptInputUserData;
9029 ctx.Write(-1);
9030 ItemBase i1 = this; // @NOTE: workaround for correct serialization
9031 ctx.Write(i1);
9032 ctx.Write(item2);
9033 ctx.Write(use_stack_max);
9034 ctx.Write(-1);
9035 ctx.Send();
9036
9037 if (IsCombineAll(item2, use_stack_max))
9038 {
9039 g_Game.GetPlayer().GetInventory().AddInventoryReservationEx(item2,null,GameInventory.c_InventoryReservationTimeoutShortMS);
9040 }
9041 }
9042 }
9043 else if (!g_Game.IsMultiplayer())
9044 {
9045 CombineItems(item2, use_stack_max);
9046 }
9047 }
9048
9049 bool IsLiquidPresent()
9050 {
9051 return (GetLiquidType() != 0 && HasQuantity());
9052 }
9053
9054 bool IsLiquidContainer()
9055 {
9056 return m_LiquidContainerMask != 0;
9057 }
9058
9060 {
9061 return m_LiquidContainerMask;
9062 }
9063
9064 bool IsBloodContainer()
9065 {
9066 //m_LiquidContainerMask & GROUP_LIQUID_BLOOD ???
9067 return false;
9068 }
9069
9070 bool IsNVG()
9071 {
9072 return false;
9073 }
9074
9077 bool IsExplosive()
9078 {
9079 return false;
9080 }
9081
9083 {
9084 return "";
9085 }
9086
9088
9089 bool IsLightSource()
9090 {
9091 return false;
9092 }
9093
9095 {
9096 return true;
9097 }
9098
9099 //--- ACTION CONDITIONS
9100 //direction
9101 bool IsFacingPlayer(PlayerBase player, string selection)
9102 {
9103 return true;
9104 }
9105
9106 bool IsPlayerInside(PlayerBase player, string selection)
9107 {
9108 return true;
9109 }
9110
9111 override bool CanObstruct()
9112 {
9113 PlayerBase player = PlayerBase.Cast(g_Game.GetPlayer());
9114 return !player || !IsPlayerInside(player, "");
9115 }
9116
9117 override bool IsBeingPlaced()
9118 {
9119 return m_IsBeingPlaced;
9120 }
9121
9122 void SetIsBeingPlaced(bool is_being_placed)
9123 {
9124 m_IsBeingPlaced = is_being_placed;
9125 if (!is_being_placed)
9127 SetSynchDirty();
9128 }
9129
9130 //server-side
9131 void OnEndPlacement() {}
9132
9133 override bool IsHologram()
9134 {
9135 return m_IsHologram;
9136 }
9137
9138 bool CanBeDigged()
9139 {
9140 return m_CanBeDigged;
9141 }
9142
9144 {
9145 return 1;
9146 }
9147
9148 bool CanMakeGardenplot()
9149 {
9150 return false;
9151 }
9152
9153 void SetIsHologram(bool is_hologram)
9154 {
9155 m_IsHologram = is_hologram;
9156 SetSynchDirty();
9157 }
9158 /*
9159 protected float GetNutritionalEnergy()
9160 {
9161 Edible_Base edible = Edible_Base.Cast(this);
9162 return edible.GetFoodEnergy();
9163 }
9164
9165 protected float GetNutritionalWaterContent()
9166 {
9167 Edible_Base edible = Edible_Base.Cast(this);
9168 return edible.GetFoodWater();
9169 }
9170
9171 protected float GetNutritionalIndex()
9172 {
9173 Edible_Base edible = Edible_Base.Cast(this);
9174 return edible.GetFoodNutritionalIndex();
9175 }
9176
9177 protected float GetNutritionalFullnessIndex()
9178 {
9179 Edible_Base edible = Edible_Base.Cast(this);
9180 return edible.GetFoodTotalVolume();
9181 }
9182
9183 protected float GetNutritionalToxicity()
9184 {
9185 Edible_Base edible = Edible_Base.Cast(this);
9186 return edible.GetFoodToxicity();
9187
9188 }
9189 */
9190
9191
9192 // -------------------------------------------------------------------------
9193 override void OnMovedInsideCargo(EntityAI container)
9194 {
9195 super.OnMovedInsideCargo(container);
9196
9197 MiscGameplayFunctions.RemoveAllAttachedChildrenByTypename(this, {Bolt_Base});
9198 }
9199
9200 override void EEItemLocationChanged(notnull InventoryLocation oldLoc, notnull InventoryLocation newLoc)
9201 {
9202 super.EEItemLocationChanged(oldLoc, newLoc);
9203
9204 PlayerBase newPlayer = null;
9205 PlayerBase oldPlayer = null;
9206
9207 if (newLoc.GetParent())
9208 newPlayer = PlayerBase.Cast(newLoc.GetParent().GetHierarchyRootPlayer());
9209
9210 if (oldLoc.GetParent())
9211 oldPlayer = PlayerBase.Cast(oldLoc.GetParent().GetHierarchyRootPlayer());
9212
9213 if (oldPlayer && oldLoc.GetType() == InventoryLocationType.HANDS)
9214 {
9215 int rIndex = oldPlayer.GetHumanInventory().FindUserReservedLocationIndex(this);
9216
9217 if (rIndex >= 0)
9218 {
9219 InventoryLocation rIl = new InventoryLocation;
9220 oldPlayer.GetHumanInventory().GetUserReservedLocation(rIndex, rIl);
9221
9222 oldPlayer.GetHumanInventory().ClearUserReservedLocationAtIndex(rIndex);
9223 int rType = rIl.GetType();
9224 if (rType == InventoryLocationType.CARGO || rType == InventoryLocationType.PROXYCARGO)
9225 {
9226 rIl.GetParent().GetOnReleaseLock().Invoke(this);
9227 }
9228 else if (rType == InventoryLocationType.ATTACHMENT)
9229 {
9230 rIl.GetParent().GetOnAttachmentReleaseLock().Invoke(this, rIl.GetSlot());
9231 }
9232
9233 }
9234 }
9235
9236 if (newLoc.GetType() == InventoryLocationType.HANDS && oldLoc.GetType() != InventoryLocationType.TEMP)
9237 {
9238 if (newPlayer)
9239 newPlayer.ForceStandUpForHeavyItems(newLoc.GetItem());
9240
9241 if (newPlayer == oldPlayer)
9242 {
9243 if (oldLoc.GetParent() && newPlayer.GetHumanInventory().LocationGetEntity(oldLoc) == NULL)
9244 {
9245 if (oldLoc.GetType() == InventoryLocationType.CARGO)
9246 {
9247 if (oldLoc.GetParent().GetInventory().TestAddEntityInCargoExLoc(oldLoc, false, false, false, true, false, false))
9248 {
9249 newPlayer.GetHumanInventory().SetUserReservedLocation(this,oldLoc);
9250 }
9251 }
9252 else
9253 {
9254 newPlayer.GetHumanInventory().SetUserReservedLocation(this,oldLoc);
9255 }
9256 }
9257
9258 if (newPlayer.GetHumanInventory().FindUserReservedLocationIndex(this) >= 0)
9259 {
9260 int type = oldLoc.GetType();
9261 if (type == InventoryLocationType.CARGO || type == InventoryLocationType.PROXYCARGO)
9262 {
9263 oldLoc.GetParent().GetOnSetLock().Invoke(this);
9264 }
9265 else if (type == InventoryLocationType.ATTACHMENT)
9266 {
9267 oldLoc.GetParent().GetOnAttachmentSetLock().Invoke(this, oldLoc.GetSlot());
9268 }
9269 }
9270 if (!m_OldLocation)
9271 {
9272 m_OldLocation = new InventoryLocation;
9273 }
9274 m_OldLocation.Copy(oldLoc);
9275 }
9276 else
9277 {
9278 if (m_OldLocation)
9279 {
9280 m_OldLocation.Reset();
9281 }
9282 }
9283
9284 g_Game.GetAnalyticsClient().OnItemAttachedAtPlayer(this,"Hands");
9285 }
9286 else
9287 {
9288 if (newPlayer)
9289 {
9290 int resIndex = newPlayer.GetHumanInventory().FindCollidingUserReservedLocationIndex(this, newLoc);
9291 if (resIndex >= 0)
9292 {
9293 InventoryLocation il = new InventoryLocation;
9294 newPlayer.GetHumanInventory().GetUserReservedLocation(resIndex, il);
9295 ItemBase it = ItemBase.Cast(il.GetItem());
9296 newPlayer.GetHumanInventory().ClearUserReservedLocationAtIndex(resIndex);
9297 int rel_type = il.GetType();
9298 if (rel_type == InventoryLocationType.CARGO || rel_type == InventoryLocationType.PROXYCARGO)
9299 {
9300 il.GetParent().GetOnReleaseLock().Invoke(it);
9301 }
9302 else if (rel_type == InventoryLocationType.ATTACHMENT)
9303 {
9304 il.GetParent().GetOnAttachmentReleaseLock().Invoke(it, il.GetSlot());
9305 }
9306 //it.GetOnReleaseLock().Invoke(it);
9307 }
9308 }
9309 else if (oldPlayer && newLoc.GetType() == InventoryLocationType.GROUND && m_ThrowItemOnDrop)
9310 {
9311 //ThrowPhysically(oldPlayer, vector.Zero);
9312 m_ThrowItemOnDrop = false;
9313 }
9314
9315 if (m_OldLocation)
9316 {
9317 m_OldLocation.Reset();
9318 }
9319 }
9320
9321 if (oldLoc.GetType() == InventoryLocationType.TEMP)
9322 {
9323 PluginInventoryRepair.Cast(GetPlugin(PluginInventoryRepair)).Remove(oldLoc.GetItem());
9324 }
9325
9326 if (newLoc.GetType() == InventoryLocationType.TEMP)
9327 {
9328 PluginInventoryRepair.Cast(GetPlugin(PluginInventoryRepair)).Add(oldLoc.GetItem());
9329 }
9330 }
9331
9332 override void EOnContact(IEntity other, Contact extra)
9333 {
9335 {
9336 int liquidType = -1;
9337 float impactSpeed = ProcessImpactSoundEx(other, extra, m_ConfigWeight, m_ImpactSoundSurfaceHash, liquidType);
9338 if (impactSpeed > 0.0)
9339 {
9340 m_ImpactSpeed = impactSpeed;
9341 #ifndef SERVER
9342 PlayImpactSound(m_ConfigWeight, m_ImpactSpeed, m_ImpactSoundSurfaceHash);
9343 #else
9344 m_WantPlayImpactSound = true;
9345 SetSynchDirty();
9346 #endif
9347 m_CanPlayImpactSound = (liquidType == -1);// prevents further playing of the sound when the surface is a liquid type
9348 }
9349 }
9350
9351 #ifdef SERVER
9352 if (GetCompEM() && GetCompEM().IsPlugged())
9353 {
9354 if (GetCompEM().GetCordLength() < vector.Distance(GetPosition(), GetCompEM().GetEnergySource().GetPosition()))
9355 GetCompEM().UnplugThis();
9356 }
9357 #endif
9358 }
9359
9360 void RefreshPhysics();
9361
9362 override void OnCreatePhysics()
9363 {
9365 }
9366
9367 override void OnItemAttachmentSlotChanged(notnull InventoryLocation oldLoc, notnull InventoryLocation newLoc)
9368 {
9369
9370 }
9371 // -------------------------------------------------------------------------
9372 override void OnItemLocationChanged(EntityAI old_owner, EntityAI new_owner)
9373 {
9374 super.OnItemLocationChanged(old_owner, new_owner);
9375
9376 PlayerBase relatedPlayer = PlayerBase.Cast(old_owner);
9377 PlayerBase playerNew = PlayerBase.Cast(new_owner);
9378
9379 if (!relatedPlayer && playerNew)
9380 relatedPlayer = playerNew;
9381
9382 if (relatedPlayer && relatedPlayer.GetPerformedActionID() != -1)
9383 {
9384 ActionManagerBase actionMgr = relatedPlayer.GetActionManager();
9385 if (actionMgr)
9386 {
9387 ActionBase currentAction = actionMgr.GetRunningAction();
9388 if (currentAction)
9389 currentAction.OnItemLocationChanged(this);
9390 }
9391 }
9392
9393 Man ownerPlayerOld = null;
9394 Man ownerPlayerNew = null;
9395
9396 if (old_owner)
9397 {
9398 if (old_owner.IsMan())
9399 {
9400 ownerPlayerOld = Man.Cast(old_owner);
9401 }
9402 else
9403 {
9404 ownerPlayerOld = Man.Cast(old_owner.GetHierarchyRootPlayer());
9405 }
9406 }
9407 else
9408 {
9409 if (new_owner && IsElectricAppliance() && GetCompEM() && GetCompEM().IsPlugged())
9410 {
9411 ActionBase action = ActionManagerBase.GetAction(ActionRepositionPluggedItem);
9412
9413 if (!action || !playerNew || playerNew.GetPerformedActionID() != action.GetID())
9414 {
9415 GetCompEM().UnplugThis();
9416 }
9417 }
9418 }
9419
9420 if (new_owner)
9421 {
9422 if (new_owner.IsMan())
9423 {
9424 ownerPlayerNew = Man.Cast(new_owner);
9425 }
9426 else
9427 {
9428 ownerPlayerNew = Man.Cast(new_owner.GetHierarchyRootPlayer());
9429 }
9430 }
9431
9432 if (ownerPlayerOld != ownerPlayerNew)
9433 {
9434 if (ownerPlayerOld)
9435 {
9436 array<EntityAI> subItemsExit = new array<EntityAI>;
9437 GetInventory().EnumerateInventory(InventoryTraversalType.PREORDER,subItemsExit);
9438 for (int i = 0; i < subItemsExit.Count(); i++)
9439 {
9440 ItemBase itemExit = ItemBase.Cast(subItemsExit.Get(i));
9441 itemExit.OnInventoryExit(ownerPlayerOld);
9442 }
9443 }
9444
9445 if (ownerPlayerNew)
9446 {
9447 array<EntityAI> subItemsEnter = new array<EntityAI>;
9448 GetInventory().EnumerateInventory(InventoryTraversalType.PREORDER,subItemsEnter);
9449 for (int j = 0; j < subItemsEnter.Count(); j++)
9450 {
9451 ItemBase itemEnter = ItemBase.Cast(subItemsEnter.Get(j));
9452 itemEnter.OnInventoryEnter(ownerPlayerNew);
9453 }
9454 }
9455 }
9456 else if (ownerPlayerNew != null)
9457 {
9458 PlayerBase nplayer;
9459 if (PlayerBase.CastTo(nplayer, ownerPlayerNew))
9460 {
9461 array<EntityAI> subItemsUpdate = new array<EntityAI>;
9462 GetInventory().EnumerateInventory(InventoryTraversalType.PREORDER,subItemsUpdate);
9463 for (int k = 0; k < subItemsUpdate.Count(); k++)
9464 {
9465 ItemBase itemUpdate = ItemBase.Cast(subItemsUpdate.Get(k));
9466 itemUpdate.UpdateQuickbarShortcutVisibility(nplayer);
9467 }
9468 }
9469 }
9470
9471 if (old_owner)
9472 old_owner.OnChildItemRemoved(this);
9473 if (new_owner)
9474 new_owner.OnChildItemReceived(this);
9475 }
9476
9477 // -------------------------------------------------------------------------------
9478 override void EEDelete(EntityAI parent)
9479 {
9480 super.EEDelete(parent);
9481 PlayerBase player = PlayerBase.Cast(GetHierarchyRootPlayer());
9482 if (player)
9483 {
9484 OnInventoryExit(player);
9485
9486 if (player.IsAlive())
9487 {
9488 int r_index = player.GetHumanInventory().FindUserReservedLocationIndex(this);
9489 if (r_index >= 0)
9490 {
9491 InventoryLocation r_il = new InventoryLocation;
9492 player.GetHumanInventory().GetUserReservedLocation(r_index,r_il);
9493
9494 player.GetHumanInventory().ClearUserReservedLocationAtIndex(r_index);
9495 int r_type = r_il.GetType();
9496 if (r_type == InventoryLocationType.CARGO || r_type == InventoryLocationType.PROXYCARGO)
9497 {
9498 r_il.GetParent().GetOnReleaseLock().Invoke(this);
9499 }
9500 else if (r_type == InventoryLocationType.ATTACHMENT)
9501 {
9502 r_il.GetParent().GetOnAttachmentReleaseLock().Invoke(this, r_il.GetSlot());
9503 }
9504
9505 }
9506
9507 player.RemoveQuickBarEntityShortcut(this);
9508 }
9509 }
9510 }
9511 // -------------------------------------------------------------------------------
9512 override void EEKilled(Object killer)
9513 {
9514 super.EEKilled(killer);
9515
9517 if (killer && killer.IsFireplace() && CanExplodeInFire())
9518 {
9519 if (GetTemperature() >= GameConstants.ITEM_TEMPERATURE_TO_EXPLODE_MIN)
9520 {
9521 if (IsMagazine())
9522 {
9523 if (Magazine.Cast(this).GetAmmoCount() > 0)
9524 {
9525 ExplodeAmmo();
9526 }
9527 }
9528 else
9529 {
9530 Explode(DamageType.EXPLOSION);
9531 }
9532 }
9533 }
9534 }
9535
9536 override void OnWasAttached(EntityAI parent, int slot_id)
9537 {
9538 MiscGameplayFunctions.RemoveAllAttachedChildrenByTypename(this, {Bolt_Base});
9539
9540 super.OnWasAttached(parent, slot_id);
9541
9542 if (HasQuantity())
9543 UpdateNetSyncVariableFloat("m_VarQuantity", GetQuantityMin(), m_VarQuantityMax);
9544
9545 if (g_Game.IsServer() || !g_Game.IsMultiplayer()) // single player or server side multiplayer
9546 StartItemSoundServer(SoundConstants.ITEM_ATTACH, slot_id);
9547 }
9548
9549 override void OnWasDetached(EntityAI parent, int slot_id)
9550 {
9551 super.OnWasDetached(parent, slot_id);
9552
9553 if (HasQuantity())
9554 UpdateNetSyncVariableFloat("m_VarQuantity", GetQuantityMin(), m_VarQuantityMax);
9555
9556 if (g_Game.IsServer() || !g_Game.IsMultiplayer()) // single player or server side multiplayer
9557 StartItemSoundServer(SoundConstants.ITEM_DETACH, slot_id);
9558 }
9559
9560 override string ChangeIntoOnAttach(string slot)
9561 {
9562 int idx;
9563 TStringArray inventory_slots = new TStringArray;
9564 TStringArray attach_types = new TStringArray;
9565
9566 ConfigGetTextArray("ChangeInventorySlot",inventory_slots);
9567 if (inventory_slots.Count() < 1) //is string
9568 {
9569 inventory_slots.Insert(ConfigGetString("ChangeInventorySlot"));
9570 attach_types.Insert(ConfigGetString("ChangeIntoOnAttach"));
9571 }
9572 else //is array
9573 {
9574 ConfigGetTextArray("ChangeIntoOnAttach",attach_types);
9575 }
9576
9577 idx = inventory_slots.Find(slot);
9578 if (idx < 0)
9579 return "";
9580
9581 return attach_types.Get(idx);
9582 }
9583
9584 override string ChangeIntoOnDetach()
9585 {
9586 int idx = -1;
9587 string slot;
9588
9589 TStringArray inventory_slots = new TStringArray;
9590 TStringArray detach_types = new TStringArray;
9591
9592 this.ConfigGetTextArray("ChangeInventorySlot",inventory_slots);
9593 if (inventory_slots.Count() < 1) //is string
9594 {
9595 inventory_slots.Insert(this.ConfigGetString("ChangeInventorySlot"));
9596 detach_types.Insert(this.ConfigGetString("ChangeIntoOnDetach"));
9597 }
9598 else //is array
9599 {
9600 this.ConfigGetTextArray("ChangeIntoOnDetach",detach_types);
9601 if (detach_types.Count() < 1)
9602 detach_types.Insert(this.ConfigGetString("ChangeIntoOnDetach"));
9603 }
9604
9605 for (int i = 0; i < inventory_slots.Count(); i++)
9606 {
9607 slot = inventory_slots.Get(i);
9608 }
9609
9610 if (slot != "")
9611 {
9612 if (detach_types.Count() == 1)
9613 idx = 0;
9614 else
9615 idx = inventory_slots.Find(slot);
9616 }
9617 if (idx < 0)
9618 return "";
9619
9620 return detach_types.Get(idx);
9621 }
9622
9623 void ExplodeAmmo()
9624 {
9625 //timer
9626 ref Timer explode_timer = new Timer(CALL_CATEGORY_SYSTEM);
9627
9628 //min/max time
9629 float min_time = 1;
9630 float max_time = 3;
9631 float delay = Math.RandomFloat(min_time, max_time);
9632
9633 explode_timer.Run(delay, this, "DoAmmoExplosion");
9634 }
9635
9636 void DoAmmoExplosion()
9637 {
9638 Magazine magazine = Magazine.Cast(this);
9639 int pop_sounds_count = 6;
9640 string pop_sounds[ 6 ] = { "ammopops_1","ammopops_2","ammopops_3","ammopops_4","ammopops_5","ammopops_6" };
9641
9642 //play sound
9643 int sound_idx = Math.RandomInt(0, pop_sounds_count - 1);
9644 string sound_name = pop_sounds[ sound_idx ];
9645 g_Game.CreateSoundOnObject(this, sound_name, 20, false);
9646
9647 //remove ammo count
9648 magazine.ServerAddAmmoCount(-1);
9649
9650 //if condition then repeat -> ExplodeAmmo
9651 float min_temp_to_explode = 100; //min temperature for item to explode
9652
9653 if (magazine.GetAmmoCount() > 0 && GetTemperature() >= min_temp_to_explode) //TODO ? add check for parent -> fireplace
9654 {
9655 ExplodeAmmo();
9656 }
9657 }
9658
9659 // -------------------------------------------------------------------------------
9660 override void EEHitBy(TotalDamageResult damageResult, int damageType, EntityAI source, int component, string dmgZone, string ammo, vector modelPos, float speedCoef)
9661 {
9662 super.EEHitBy(damageResult, damageType, source, component, dmgZone, ammo, modelPos, speedCoef);
9663
9664 const int CHANCE_DAMAGE_CARGO = 4;
9665 const int CHANCE_DAMAGE_ATTACHMENT = 1;
9666 const int CHANCE_DAMAGE_NOTHING = 2;
9667
9668 if (IsClothing() || IsContainer() || IsItemTent())
9669 {
9670 float dmg = damageResult.GetDamage("","Health") * -0.5;
9671 int chances;
9672 int rnd;
9673
9674 if (GetInventory().GetCargo())
9675 {
9676 chances = CHANCE_DAMAGE_CARGO + CHANCE_DAMAGE_ATTACHMENT + CHANCE_DAMAGE_NOTHING;
9677 rnd = Math.RandomInt(0,chances);
9678
9679 if (rnd < CHANCE_DAMAGE_CARGO)
9680 {
9681 DamageItemInCargo(dmg);
9682 }
9683 else if (rnd < (chances - CHANCE_DAMAGE_NOTHING))
9684 {
9686 }
9687 }
9688 else
9689 {
9690 chances = CHANCE_DAMAGE_ATTACHMENT + CHANCE_DAMAGE_NOTHING;
9691 rnd = Math.RandomInt(0,chances);
9692
9693 if (rnd < CHANCE_DAMAGE_ATTACHMENT)
9694 {
9696 }
9697 }
9698 }
9699 }
9700
9701 bool DamageItemInCargo(float damage)
9702 {
9703 CargoBase cargo = GetInventory().GetCargo();
9704 if (cargo)
9705 {
9706 int item_count = cargo.GetItemCount();
9707 if (item_count > 0)
9708 {
9709 int random_pick = Math.RandomInt(0, item_count);
9710 ItemBase item = ItemBase.Cast(cargo.GetItem(random_pick));
9711 if (!item.IsExplosive())
9712 {
9713 item.AddHealth("","",damage);
9714 return true;
9715 }
9716 }
9717 }
9718 return false;
9719 }
9720
9721 bool DamageItemAttachments(float damage)
9722 {
9723 GameInventory inventory = GetInventory();
9724 int attachment_count = inventory.AttachmentCount();
9725 if (attachment_count > 0)
9726 {
9727 int random_pick = Math.RandomInt(0, attachment_count);
9728 ItemBase attachment = ItemBase.Cast(inventory.GetAttachmentFromIndex(random_pick));
9729 if (!attachment.IsExplosive())
9730 {
9731 attachment.AddHealth("","",damage);
9732 return true;
9733 }
9734 }
9735 return false;
9736 }
9737
9738 override bool IsSplitable()
9739 {
9740 return m_CanThisBeSplit;
9741 }
9742 //----------------
9743 override bool CanBeSplit()
9744 {
9745 if (IsSplitable() && (GetQuantity() > 1))
9746 return GetInventory().CanRemoveEntity();
9747
9748 return false;
9749 }
9750
9751 protected bool ShouldSplitQuantity(float quantity)
9752 {
9753 // don't call 'CanBeSplit' here, too strict and will introduce a freeze-crash when dismantling fence with a fireplace nearby
9754 if (!IsSplitable())
9755 return false;
9756
9757 // nothing to split?
9758 if (GetQuantity() <= 1)
9759 return false;
9760
9761 // check if we should re-use the item instead of creating a new copy?
9762 // implicit cast to int, if 'IsSplitable' returns true, these values are assumed ints
9763 int delta = GetQuantity() - quantity;
9764 if (delta == 0)
9765 return false;
9766
9767 // valid to split
9768 return true;
9769 }
9770
9771 override void SplitIntoStackMaxClient(EntityAI destination_entity, int slot_id )
9772 {
9773 if (g_Game.IsClient())
9774 {
9775 if (ScriptInputUserData.CanStoreInputUserData())
9776 {
9777 ScriptInputUserData ctx = new ScriptInputUserData;
9779 ctx.Write(1);
9780 ItemBase i1 = this; // @NOTE: workaround for correct serialization
9781 ctx.Write(i1);
9782 ctx.Write(destination_entity);
9783 ctx.Write(true);
9784 ctx.Write(slot_id);
9785 ctx.Send();
9786 }
9787 }
9788 else if (!g_Game.IsMultiplayer())
9789 {
9790 SplitIntoStackMax(destination_entity, slot_id, PlayerBase.Cast(g_Game.GetPlayer()));
9791 }
9792 }
9793
9794 void SplitIntoStackMax(EntityAI destination_entity, int slot_id, PlayerBase player)
9795 {
9796 float split_quantity_new;
9797 ItemBase new_item;
9798 float quantity = GetQuantity();
9799 float stack_max = GetTargetQuantityMax(slot_id);
9800 InventoryLocation loc = new InventoryLocation;
9801
9802 if (destination_entity && slot_id != -1 && InventorySlots.IsSlotIdValid(slot_id))
9803 {
9804 if (stack_max <= GetQuantity())
9805 split_quantity_new = stack_max;
9806 else
9807 split_quantity_new = GetQuantity();
9808
9809 if (ShouldSplitQuantity(split_quantity_new))
9810 {
9811 new_item = ItemBase.Cast(destination_entity.GetInventory().CreateAttachmentEx(this.GetType(), slot_id));
9812 if (new_item)
9813 {
9814 new_item.SetResultOfSplit(true);
9815 MiscGameplayFunctions.TransferItemProperties(this, new_item);
9816 AddQuantity(-split_quantity_new, false, true);
9817 new_item.SetQuantity(split_quantity_new, false, true);
9818 }
9819 }
9820 }
9821 else if (destination_entity && slot_id == -1)
9822 {
9823 if (quantity > stack_max)
9824 split_quantity_new = stack_max;
9825 else
9826 split_quantity_new = quantity;
9827
9828 if (ShouldSplitQuantity(split_quantity_new))
9829 {
9830 GameInventory destinationInventory = destination_entity.GetInventory();
9831 if (destinationInventory.FindFreeLocationFor(this, FindInventoryLocationType.ANY, loc))
9832 {
9833 Object o = destinationInventory.LocationCreateEntity(loc, GetType(), ECE_IN_INVENTORY, RF_DEFAULT);
9834 new_item = ItemBase.Cast(o);
9835 }
9836
9837 if (new_item)
9838 {
9839 new_item.SetResultOfSplit(true);
9840 MiscGameplayFunctions.TransferItemProperties(this, new_item);
9841 AddQuantity(-split_quantity_new, false, true);
9842 new_item.SetQuantity(split_quantity_new, false, true);
9843 }
9844 }
9845 }
9846 else
9847 {
9848 if (stack_max != 0)
9849 {
9850 if (stack_max < GetQuantity())
9851 {
9852 split_quantity_new = GetQuantity() - stack_max;
9853 }
9854
9855 if (split_quantity_new == 0)
9856 {
9857 if (!g_Game.IsMultiplayer())
9858 player.PhysicalPredictiveDropItem(this);
9859 else
9860 player.ServerDropEntity(this);
9861 return;
9862 }
9863
9864 if (ShouldSplitQuantity(split_quantity_new))
9865 {
9866 new_item = ItemBase.Cast(g_Game.CreateObjectEx(GetType(), player.GetWorldPosition(), ECE_PLACE_ON_SURFACE));
9867
9868 if (new_item)
9869 {
9870 new_item.SetResultOfSplit(true);
9871 MiscGameplayFunctions.TransferItemProperties(this, new_item);
9872 SetQuantity(split_quantity_new, false, true);
9873 new_item.SetQuantity(stack_max, false, true);
9874 new_item.PlaceOnSurface();
9875 }
9876 }
9877 }
9878 }
9879 }
9880
9881 override void SplitIntoStackMaxEx(EntityAI destination_entity, int slot_id)
9882 {
9883 float split_quantity_new;
9884 ItemBase new_item;
9885 float quantity = GetQuantity();
9886 float stack_max = GetTargetQuantityMax(slot_id);
9887 InventoryLocation loc = new InventoryLocation;
9888
9889 if (destination_entity && slot_id != -1 && InventorySlots.IsSlotIdValid(slot_id))
9890 {
9891 if (stack_max <= GetQuantity())
9892 split_quantity_new = stack_max;
9893 else
9894 split_quantity_new = GetQuantity();
9895
9896 if (ShouldSplitQuantity(split_quantity_new))
9897 {
9898 new_item = ItemBase.Cast(destination_entity.GetInventory().CreateAttachmentEx(this.GetType(), slot_id));
9899 if (new_item)
9900 {
9901 new_item.SetResultOfSplit(true);
9902 MiscGameplayFunctions.TransferItemProperties(this, new_item);
9903 AddQuantity(-split_quantity_new, false, true);
9904 new_item.SetQuantity(split_quantity_new, false, true);
9905 }
9906 }
9907 }
9908 else if (destination_entity && slot_id == -1)
9909 {
9910 if (quantity > stack_max)
9911 split_quantity_new = stack_max;
9912 else
9913 split_quantity_new = quantity;
9914
9915 if (ShouldSplitQuantity(split_quantity_new))
9916 {
9917 GameInventory destinationInventory = destination_entity.GetInventory();
9918 if (destinationInventory.FindFreeLocationFor(this, FindInventoryLocationType.ANY, loc))
9919 {
9920 Object o = destinationInventory.LocationCreateEntity(loc, GetType(), ECE_IN_INVENTORY, RF_DEFAULT);
9921 new_item = ItemBase.Cast(o);
9922 }
9923
9924 if (new_item)
9925 {
9926 new_item.SetResultOfSplit(true);
9927 MiscGameplayFunctions.TransferItemProperties(this, new_item);
9928 AddQuantity(-split_quantity_new, false, true);
9929 new_item.SetQuantity(split_quantity_new, false, true);
9930 }
9931 }
9932 }
9933 else
9934 {
9935 if (stack_max != 0)
9936 {
9937 if (stack_max < GetQuantity())
9938 {
9939 split_quantity_new = GetQuantity() - stack_max;
9940 }
9941
9942 if (ShouldSplitQuantity(split_quantity_new))
9943 {
9944 new_item = ItemBase.Cast(g_Game.CreateObjectEx(GetType(),GetWorldPosition(), ECE_PLACE_ON_SURFACE));
9945
9946 if (new_item)
9947 {
9948 new_item.SetResultOfSplit(true);
9949 MiscGameplayFunctions.TransferItemProperties(this, new_item);
9950 SetQuantity(split_quantity_new, false, true);
9951 new_item.SetQuantity(stack_max, false, true);
9952 new_item.PlaceOnSurface();
9953 }
9954 }
9955 }
9956 }
9957 }
9958
9959 void SplitIntoStackMaxToInventoryLocationClient(notnull InventoryLocation dst)
9960 {
9961 if (g_Game.IsClient())
9962 {
9963 if (ScriptInputUserData.CanStoreInputUserData())
9964 {
9965 ScriptInputUserData ctx = new ScriptInputUserData;
9967 ctx.Write(4);
9968 ItemBase thiz = this; // @NOTE: workaround for correct serialization
9969 ctx.Write(thiz);
9970 dst.WriteToContext(ctx);
9971 ctx.Send();
9972 }
9973 }
9974 else if (!g_Game.IsMultiplayer())
9975 {
9977 }
9978 }
9979
9980 void SplitIntoStackMaxCargoClient(EntityAI destination_entity, int idx, int row, int col)
9981 {
9982 if (g_Game.IsClient())
9983 {
9984 if (ScriptInputUserData.CanStoreInputUserData())
9985 {
9986 ScriptInputUserData ctx = new ScriptInputUserData;
9988 ctx.Write(2);
9989 ItemBase dummy = this; // @NOTE: workaround for correct serialization
9990 ctx.Write(dummy);
9991 ctx.Write(destination_entity);
9992 ctx.Write(true);
9993 ctx.Write(idx);
9994 ctx.Write(row);
9995 ctx.Write(col);
9996 ctx.Send();
9997 }
9998 }
9999 else if (!g_Game.IsMultiplayer())
10000 {
10001 SplitIntoStackMaxCargo(destination_entity, idx, row, col);
10002 }
10003 }
10004
10005 void SplitIntoStackMaxToInventoryLocation(notnull InventoryLocation dst)
10006 {
10008 }
10009
10010 ItemBase SplitIntoStackMaxToInventoryLocationEx(notnull InventoryLocation dst)
10011 {
10012 float quantity = GetQuantity();
10013 float split_quantity_new;
10014 ItemBase new_item;
10015 if (dst.IsValid())
10016 {
10017 int slot_id = dst.GetSlot();
10018 float stack_max = GetTargetQuantityMax(slot_id);
10019
10020 if (quantity > stack_max)
10021 split_quantity_new = stack_max;
10022 else
10023 split_quantity_new = quantity;
10024
10025 if (ShouldSplitQuantity(split_quantity_new))
10026 {
10027 new_item = ItemBase.Cast(GameInventory.LocationCreateEntity(dst, this.GetType(), ECE_IN_INVENTORY, RF_DEFAULT));
10028
10029 if (new_item)
10030 {
10031 new_item.SetResultOfSplit(true);
10032 MiscGameplayFunctions.TransferItemProperties(this,new_item);
10033 AddQuantity(-split_quantity_new, false, true);
10034 new_item.SetQuantity(split_quantity_new, false, true);
10035 }
10036
10037 return new_item;
10038 }
10039 }
10040
10041 return null;
10042 }
10043
10044 void SplitIntoStackMaxCargo(EntityAI destination_entity, int idx, int row, int col)
10045 {
10046 float quantity = GetQuantity();
10047 float split_quantity_new;
10048 ItemBase new_item;
10049 if (destination_entity)
10050 {
10051 float stackable = GetTargetQuantityMax();
10052 if (quantity > stackable)
10053 split_quantity_new = stackable;
10054 else
10055 split_quantity_new = quantity;
10056
10057 if (ShouldSplitQuantity(split_quantity_new))
10058 {
10059 new_item = ItemBase.Cast(destination_entity.GetInventory().CreateEntityInCargoEx(this.GetType(), idx, row, col, false));
10060 if (new_item)
10061 {
10062 new_item.SetResultOfSplit(true);
10063 MiscGameplayFunctions.TransferItemProperties(this,new_item);
10064 AddQuantity(-split_quantity_new, false, true);
10065 new_item.SetQuantity(split_quantity_new, false, true);
10066 }
10067 }
10068 }
10069 }
10070
10071 void SplitIntoStackMaxHandsClient(PlayerBase player)
10072 {
10073 if (g_Game.IsClient())
10074 {
10075 if (ScriptInputUserData.CanStoreInputUserData())
10076 {
10077 ScriptInputUserData ctx = new ScriptInputUserData;
10079 ctx.Write(3);
10080 ItemBase i1 = this; // @NOTE: workaround for correct serialization
10081 ctx.Write(i1);
10082 ItemBase destination_entity = this;
10083 ctx.Write(destination_entity);
10084 ctx.Write(true);
10085 ctx.Write(0);
10086 ctx.Send();
10087 }
10088 }
10089 else if (!g_Game.IsMultiplayer())
10090 {
10091 SplitIntoStackMaxHands(player);
10092 }
10093 }
10094
10095 void SplitIntoStackMaxHands(PlayerBase player)
10096 {
10097 float quantity = GetQuantity();
10098 float split_quantity_new;
10099 ref ItemBase new_item;
10100 if (player)
10101 {
10102 float stackable = GetTargetQuantityMax();
10103 if (quantity > stackable)
10104 split_quantity_new = stackable;
10105 else
10106 split_quantity_new = quantity;
10107
10108 if (ShouldSplitQuantity(split_quantity_new))
10109 {
10110 EntityAI in_hands = player.GetHumanInventory().CreateInHands(this.GetType());
10111 new_item = ItemBase.Cast(in_hands);
10112 if (new_item)
10113 {
10114 new_item.SetResultOfSplit(true);
10115 MiscGameplayFunctions.TransferItemProperties(this,new_item);
10116 AddQuantity(-split_quantity_new, false, true);
10117 new_item.SetQuantity(split_quantity_new, false, true);
10118 }
10119 }
10120 }
10121 }
10122
10123 void SplitItemToInventoryLocation(notnull InventoryLocation dst)
10124 {
10125 float quantity = GetQuantity();
10126 float split_quantity_new = Math.Floor(quantity * 0.5);
10127
10128 if (!ShouldSplitQuantity(split_quantity_new))
10129 return;
10130
10131 ItemBase new_item = ItemBase.Cast(GameInventory.LocationCreateEntity(dst, GetType(), ECE_IN_INVENTORY, RF_DEFAULT));
10132
10133 if (new_item)
10134 {
10135 if (new_item.GetQuantityMax() < split_quantity_new)
10136 {
10137 split_quantity_new = new_item.GetQuantityMax();
10138 }
10139
10140 new_item.SetResultOfSplit(true);
10141 MiscGameplayFunctions.TransferItemProperties(this, new_item);
10142
10143 if (dst.IsValid() && dst.GetType() == InventoryLocationType.ATTACHMENT && split_quantity_new > 1)
10144 {
10145 AddQuantity(-1, false, true);
10146 new_item.SetQuantity(1, false, true);
10147 }
10148 else
10149 {
10150 AddQuantity(-split_quantity_new, false, true);
10151 new_item.SetQuantity(split_quantity_new, false, true);
10152 }
10153 }
10154 }
10155
10156 void SplitItem(PlayerBase player)
10157 {
10158 float quantity = GetQuantity();
10159 float split_quantity_new = Math.Floor(quantity / 2);
10160
10161 if (!ShouldSplitQuantity(split_quantity_new))
10162 return;
10163
10164 InventoryLocation invloc = new InventoryLocation;
10165 bool found = player.GetInventory().FindFirstFreeLocationForNewEntity(GetType(), FindInventoryLocationType.ATTACHMENT, invloc);
10166
10167 ItemBase new_item;
10168 new_item = player.CreateCopyOfItemInInventoryOrGroundEx(this, true);
10169
10170 if (new_item)
10171 {
10172 if (new_item.GetQuantityMax() < split_quantity_new)
10173 {
10174 split_quantity_new = new_item.GetQuantityMax();
10175 }
10176 if (found && invloc.IsValid() && invloc.GetType() == InventoryLocationType.ATTACHMENT && split_quantity_new > 1)
10177 {
10178 AddQuantity(-1, false, true);
10179 new_item.SetQuantity(1, false, true);
10180 }
10181 else if (split_quantity_new > 1)
10182 {
10183 AddQuantity(-split_quantity_new, false, true);
10184 new_item.SetQuantity(split_quantity_new, false, true);
10185 }
10186 }
10187 }
10188
10190 void OnQuantityChanged(float delta)
10191 {
10192 SetWeightDirty();
10193 ItemBase parent = ItemBase.Cast(GetHierarchyParent());
10194
10195 if (parent)
10196 parent.OnAttachmentQuantityChangedEx(this, delta);
10197
10198 if (IsLiquidContainer())
10199 {
10200 if (GetQuantityNormalized() <= 0.0)
10201 {
10203 }
10204 else if (GetLiquidType() == LIQUID_NONE)
10205 {
10206 ErrorEx("Undefined liquid type quantity changed, please define liquid type first! Using init value.",ErrorExSeverity.INFO);
10208 }
10209 }
10210 }
10211
10214 {
10215 // insert code here
10216 }
10217
10219 void OnAttachmentQuantityChangedEx(ItemBase item , float delta)
10220 {
10222 }
10223
10224 override void EEHealthLevelChanged(int oldLevel, int newLevel, string zone)
10225 {
10226 super.EEHealthLevelChanged(oldLevel,newLevel,zone);
10227
10228 if (g_Game.IsServer())
10229 {
10230 if (newLevel == GameConstants.STATE_RUINED)
10231 {
10233 EntityAI parent = GetHierarchyParent();
10234 if (parent && parent.IsFireplace())
10235 {
10236 CargoBase cargo = GetInventory().GetCargo();
10237 if (cargo)
10238 {
10239 for (int i = 0; i < cargo.GetItemCount(); ++i)
10240 {
10241 parent.GetInventory().TakeEntityToInventory(InventoryMode.SERVER, FindInventoryLocationType.CARGO, cargo.GetItem(i));
10242 }
10243 }
10244 }
10245 }
10246
10247 if (IsResultOfSplit())
10248 {
10249 // reset the splitting result flag, return to normal item behavior
10250 SetResultOfSplit(false);
10251 return;
10252 }
10253
10254 if (m_Cleanness != 0 && oldLevel < newLevel && newLevel != 0)
10255 {
10256 SetCleanness(0);//unclean the item upon damage dealt
10257 }
10258 }
10259 }
10260
10261 // just the split? TODO: verify
10262 override void OnRightClick()
10263 {
10264 super.OnRightClick();
10265
10266 if (CanBeSplit() && !GetDayZGame().IsLeftCtrlDown() && !g_Game.GetPlayer().GetInventory().HasInventoryReservation(this,null))
10267 {
10268 if (g_Game.IsClient())
10269 {
10270 if (ScriptInputUserData.CanStoreInputUserData())
10271 {
10272 EntityAI root = GetHierarchyRoot();
10273 Man playerOwner = GetHierarchyRootPlayer();
10274 InventoryLocation dst = new InventoryLocation;
10275
10276 // 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
10277 if (!playerOwner && root && root == this)
10278 {
10280 }
10281 else
10282 {
10283 // 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
10284 GetInventory().GetCurrentInventoryLocation(dst);
10285 if (!dst.GetParent() || dst.GetParent() && !dst.GetParent().GetInventory().FindFreeLocationFor(this, FindInventoryLocationType.CARGO, dst))
10286 {
10287 PlayerBase player = PlayerBase.Cast(g_Game.GetPlayer());
10288 if (!player.GetInventory().FindFreeLocationFor(this, FindInventoryLocationType.CARGO, dst) || !playerOwner)
10289 {
10291 }
10292 else
10293 {
10294 dst.SetCargo(dst.GetParent(), this, dst.GetIdx(), dst.GetRow(), dst.GetCol(), dst.GetFlip());
10295 /* hacky solution to check reservation of "this" item instead of null since the gamecode is checking null against null and returning reservation=true incorrectly
10296 this shouldnt cause issues within this scope*/
10297 if (g_Game.GetPlayer().GetInventory().HasInventoryReservation(this, dst))
10298 {
10300 }
10301 else
10302 {
10303 g_Game.GetPlayer().GetInventory().AddInventoryReservationEx(null, dst, GameInventory.c_InventoryReservationTimeoutShortMS);
10304 }
10305 }
10306 }
10307 }
10308
10309 ScriptInputUserData ctx = new ScriptInputUserData;
10311 ctx.Write(4);
10312 ItemBase thiz = this; // @NOTE: workaround for correct serialization
10313 ctx.Write(thiz);
10314 dst.WriteToContext(ctx);
10315 ctx.Write(true); // dummy
10316 ctx.Send();
10317 }
10318 }
10319 else if (!g_Game.IsMultiplayer())
10320 {
10321 SplitItem(PlayerBase.Cast(g_Game.GetPlayer()));
10322 }
10323 }
10324 }
10325
10326 protected void SetInventoryLocationToVicinityOrCurrent(EntityAI root, inout InventoryLocation dst)
10327 {
10328 if (root)
10329 {
10330 vector m4[4];
10331 root.GetTransform(m4);
10332 dst.SetGround(this, m4);
10333 }
10334 else
10335 {
10336 GetInventory().GetCurrentInventoryLocation(dst);
10337 }
10338 }
10339
10340 override bool CanBeCombined(EntityAI other_item, bool reservation_check = true, bool stack_max_limit = false)
10341 {
10342 //TODO: delete check zero quantity check after fix double posts hands fsm events
10343 if (!other_item || GetType() != other_item.GetType() || (IsFullQuantity() && other_item.GetQuantity() > 0) || other_item == this)
10344 return false;
10345
10346 if (GetHealthLevel() == GameConstants.STATE_RUINED || other_item.GetHealthLevel() == GameConstants.STATE_RUINED)
10347 return false;
10348
10349 //can_this_be_combined = ConfigGetBool("canBeSplit");
10351 return false;
10352
10353
10354 Magazine mag = Magazine.Cast(this);
10355 if (mag)
10356 {
10357 if (mag.GetAmmoCount() >= mag.GetAmmoMax())
10358 return false;
10359
10360 if (stack_max_limit)
10361 {
10362 Magazine other_mag = Magazine.Cast(other_item);
10363 if (other_item)
10364 {
10365 if (mag.GetAmmoCount() + other_mag.GetAmmoCount() > mag.GetAmmoMax())
10366 return false;
10367 }
10368
10369 }
10370 }
10371 else
10372 {
10373 //TODO: delete check zero quantity check after fix double posts hands fsm events
10374 if (GetQuantity() >= GetQuantityMax() && other_item.GetQuantity() > 0 )
10375 return false;
10376
10377 if (stack_max_limit && (GetQuantity() + other_item.GetQuantity() > GetQuantityMax()))
10378 return false;
10379 }
10380
10381 PlayerBase player = null;
10382 if (CastTo(player, GetHierarchyRootPlayer())) //false when attached to player's attachment slot
10383 {
10384 if (player.GetInventory().HasAttachment(this))
10385 return false;
10386
10387 if (player.IsItemsToDelete())
10388 return false;
10389 }
10390
10391 if (reservation_check && (GetInventory().HasInventoryReservation(this, null) || other_item.GetInventory().HasInventoryReservation(other_item, null)))
10392 return false;
10393
10394 int slotID;
10395 string slotName;
10396 if (GetInventory().GetCurrentAttachmentSlotInfo(slotID,slotName) && GetHierarchyParent().GetInventory().GetSlotLock(slotID))
10397 return false;
10398
10399 return true;
10400 }
10401
10402 bool IsCombineAll(ItemBase other_item, bool use_stack_max = false)
10403 {
10404 return ComputeQuantityUsed(other_item, use_stack_max) == other_item.GetQuantity();
10405 }
10406
10407 bool IsResultOfSplit()
10408 {
10409 return m_IsResultOfSplit;
10410 }
10411
10412 void SetResultOfSplit(bool value)
10413 {
10414 m_IsResultOfSplit = value;
10415 }
10416
10417 int ComputeQuantityUsed(ItemBase other_item, bool use_stack_max = true)
10418 {
10419 return ComputeQuantityUsedEx(other_item, use_stack_max);
10420 }
10421
10422 float ComputeQuantityUsedEx(ItemBase other_item, bool use_stack_max = true)
10423 {
10424 float other_item_quantity = other_item.GetQuantity();
10425 float this_free_space;
10426
10427 float stack_max = GetQuantityMax();
10428
10429 this_free_space = stack_max - GetQuantity();
10430
10431 if (other_item_quantity > this_free_space)
10432 {
10433 return this_free_space;
10434 }
10435 else
10436 {
10437 return other_item_quantity;
10438 }
10439 }
10440
10441 override void CombineItemsEx(EntityAI entity2, bool use_stack_max = true)
10442 {
10443 CombineItems(ItemBase.Cast(entity2),use_stack_max);
10444 }
10445
10446 void CombineItems(ItemBase other_item, bool use_stack_max = true)
10447 {
10448 if (!CanBeCombined(other_item, false))
10449 return;
10450
10451 if (!IsMagazine() && other_item)
10452 {
10453 float quantity_used = ComputeQuantityUsedEx(other_item,use_stack_max);
10454 if (quantity_used != 0)
10455 {
10456 float hp1 = GetHealth01("","");
10457 float hp2 = other_item.GetHealth01("","");
10458 float hpResult = ((hp1*GetQuantity()) + (hp2*quantity_used));
10459 hpResult = hpResult / (GetQuantity() + quantity_used);
10460
10461 hpResult *= GetMaxHealth();
10462 Math.Round(hpResult);
10463 SetHealth("", "Health", hpResult);
10464
10465 AddQuantity(quantity_used);
10466 other_item.AddQuantity(-quantity_used);
10467 }
10468 }
10469 OnCombine(other_item);
10470 }
10471
10472 void OnCombine(ItemBase other_item)
10473 {
10474 #ifdef SERVER
10475 if (!GetHierarchyRootPlayer() && GetHierarchyParent())
10476 GetHierarchyParent().IncreaseLifetimeUp();
10477 #endif
10478 };
10479
10480 void GetRecipesActions(Man player, out TSelectableActionInfoArray outputList)
10481 {
10482 PlayerBase p = PlayerBase.Cast(player);
10483
10484 array<int> recipesIds = p.m_Recipes;
10485 PluginRecipesManager moduleRecipesManager = PluginRecipesManager.Cast(GetPlugin(PluginRecipesManager));
10486 if (moduleRecipesManager)
10487 {
10488 EntityAI itemInHands = player.GetEntityInHands();
10489 moduleRecipesManager.GetValidRecipes(ItemBase.Cast(this), ItemBase.Cast(itemInHands), recipesIds, p);
10490 }
10491
10492 for (int i = 0;i < recipesIds.Count(); i++)
10493 {
10494 int key = recipesIds.Get(i);
10495 string recipeName = moduleRecipesManager.GetRecipeName(key);
10496 outputList.Insert(new TSelectableActionInfo(SAT_CRAFTING, key, recipeName));
10497 }
10498 }
10499
10500 // -------------------------------------------------------------------------
10501 override void GetDebugActions(out TSelectableActionInfoArrayEx outputList)
10502 {
10503 super.GetDebugActions(outputList);
10504
10505 //quantity
10506 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.ADD_QUANTITY, "Quantity +20%", FadeColors.LIGHT_GREY));
10507 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.REMOVE_QUANTITY, "Quantity -20%", FadeColors.LIGHT_GREY));
10508 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SET_QUANTITY_0, "Set Quantity 0", FadeColors.LIGHT_GREY));
10509 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SET_MAX_QUANTITY, "Set Quantity Max", FadeColors.LIGHT_GREY));
10510 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SEPARATOR, "___________________________", FadeColors.RED));
10511
10512 //health
10513 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.ADD_HEALTH, "Health +20%", FadeColors.LIGHT_GREY));
10514 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.REMOVE_HEALTH, "Health -20%", FadeColors.LIGHT_GREY));
10515 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.DESTROY_HEALTH, "Health 0", FadeColors.LIGHT_GREY));
10516 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SEPARATOR, "___________________________", FadeColors.RED));
10517 //temperature
10518 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.ADD_TEMPERATURE, "Temperature +20", FadeColors.LIGHT_GREY));
10519 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.REMOVE_TEMPERATURE, "Temperature -20", FadeColors.LIGHT_GREY));
10520 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.FLIP_FROZEN, "Toggle Frozen", FadeColors.LIGHT_GREY));
10521 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SEPARATOR, "___________________________", FadeColors.RED));
10522
10523 //wet
10524 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.ADD_WETNESS, "Wetness +20", FadeColors.LIGHT_GREY));
10525 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.REMOVE_WETNESS, "Wetness -20", FadeColors.LIGHT_GREY));
10526 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SEPARATOR, "___________________________", FadeColors.RED));
10527
10528 //liquidtype
10529 if (IsLiquidContainer())
10530 {
10531 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.LIQUIDTYPE_UP, "LiquidType Next", FadeColors.LIGHT_GREY));
10532 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.LIQUIDTYPE_DOWN, "LiquidType Previous", FadeColors.LIGHT_GREY));
10533 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SEPARATOR, "___________________________", FadeColors.RED));
10534 }
10535
10536 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.MAKE_SPECIAL, "Make Special", FadeColors.LIGHT_GREY));
10537 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SEPARATOR, "___________________________", FadeColors.RED));
10538
10539 // watch
10540 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.WATCH_ITEM, "Watch (CTRL-Z)", FadeColors.LIGHT_GREY));
10541 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.WATCH_PLAYER, "Watch Player", FadeColors.LIGHT_GREY));
10542 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SEPARATOR, "___________________________", FadeColors.RED));
10543
10544 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.DELETE, "Delete", FadeColors.RED));
10545
10546 InventoryLocation loc = new InventoryLocation();
10547 GetInventory().GetCurrentInventoryLocation(loc);
10548 if (!loc || loc.GetType() == InventoryLocationType.GROUND)
10549 {
10550 if (Gizmo_IsSupported())
10551 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.GIZMO_OBJECT, "Gizmo Object", FadeColors.LIGHT_GREY));
10552 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.GIZMO_PHYSICS, "Gizmo Physics (SP Only)", FadeColors.LIGHT_GREY)); // intentionally allowed for testing physics desync
10553 }
10554
10555 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SEPARATOR, "___________________________", FadeColors.RED));
10556 }
10557
10558 // -------------------------------------------------------------------------
10559 // -------------------------------------------------------------------------
10560 // -------------------------------------------------------------------------
10561 override bool OnAction(int action_id, Man player, ParamsReadContext ctx)
10562 {
10563 super.OnAction(action_id, player, ctx);
10564
10565 if (g_Game.IsClient() || !g_Game.IsMultiplayer())
10566 {
10567 switch (action_id)
10568 {
10569 case EActions.GIZMO_OBJECT:
10570 if (GetGizmoApi())
10571 GetGizmoApi().SelectObject(this);
10572 return true;
10573 case EActions.GIZMO_PHYSICS:
10574 if (GetGizmoApi())
10575 GetGizmoApi().SelectPhysics(GetPhysics());
10576 return true;
10577 }
10578 }
10579
10580 if (g_Game.IsServer())
10581 {
10582 switch (action_id)
10583 {
10584 case EActions.DELETE:
10585 Delete();
10586 return true;
10587 }
10588 }
10589
10590 if (action_id >= EActions.RECIPES_RANGE_START && action_id < EActions.RECIPES_RANGE_END)
10591 {
10592 PluginRecipesManager plugin_recipes_manager = PluginRecipesManager.Cast(GetPlugin(PluginRecipesManager));
10593 int idWithoutOffset = action_id - EActions.RECIPES_RANGE_START;
10594 PlayerBase p = PlayerBase.Cast(player);
10595 if (EActions.RECIPES_RANGE_START < 1000)
10596 {
10597 float anim_length = plugin_recipes_manager.GetRecipeLengthInSecs(idWithoutOffset);
10598 float specialty_weight = plugin_recipes_manager.GetRecipeSpecialty(idWithoutOffset);
10599 }
10600 }
10601 #ifndef SERVER
10602 else if (action_id == EActions.WATCH_PLAYER)
10603 {
10604 PluginDeveloper.SetDeveloperItemClientEx(player);
10605 }
10606 #endif
10607 if (g_Game.IsServer())
10608 {
10609 if (action_id >= EActions.DEBUG_ITEM_WATCH_BUTTON_RANGE_START && action_id < EActions.DEBUG_ITEM_WATCH_BUTTON_RANGE_END)
10610 {
10611 int id = action_id - EActions.DEBUG_ITEM_WATCH_BUTTON_RANGE_START;
10612 OnDebugButtonPressServer(id + 1);
10613 }
10614
10615 else if (action_id >= EActions.DEBUG_AGENTS_RANGE_INJECT_START && action_id < EActions.DEBUG_AGENTS_RANGE_INJECT_END)
10616 {
10617 int agent_id = action_id - EActions.DEBUG_AGENTS_RANGE_INJECT_START;
10618 InsertAgent(agent_id,100);
10619 }
10620
10621 else if (action_id >= EActions.DEBUG_AGENTS_RANGE_REMOVE_START && action_id < EActions.DEBUG_AGENTS_RANGE_REMOVE_END)
10622 {
10623 int agent_id2 = action_id - EActions.DEBUG_AGENTS_RANGE_REMOVE_START;
10624 RemoveAgent(agent_id2);
10625 }
10626
10627 else if (action_id == EActions.ADD_QUANTITY)
10628 {
10629 if (IsMagazine())
10630 {
10631 Magazine mag = Magazine.Cast(this);
10632 mag.ServerSetAmmoCount(mag.GetAmmoCount() + mag.GetAmmoMax() * 0.2);
10633 }
10634 else
10635 {
10636 AddQuantity(GetQuantityMax() * 0.2);
10637 }
10638
10639 if (m_EM)
10640 {
10641 m_EM.AddEnergy(m_EM.GetEnergyMax() * 0.2);
10642 }
10643 //PrintVariables();
10644 }
10645
10646 else if (action_id == EActions.REMOVE_QUANTITY) //Quantity -20%
10647 {
10648 if (IsMagazine())
10649 {
10650 Magazine mag2 = Magazine.Cast(this);
10651 mag2.ServerSetAmmoCount(mag2.GetAmmoCount() - mag2.GetAmmoMax() * 0.2);
10652 }
10653 else
10654 {
10655 AddQuantity(- GetQuantityMax() * 0.2);
10656 }
10657 if (m_EM)
10658 {
10659 m_EM.AddEnergy(- m_EM.GetEnergyMax() * 0.2);
10660 }
10661 //PrintVariables();
10662 }
10663
10664 else if (action_id == EActions.SET_QUANTITY_0) //SetMaxQuantity
10665 {
10666 SetQuantity(0);
10667
10668 if (m_EM)
10669 {
10670 m_EM.SetEnergy(0);
10671 }
10672 }
10673
10674 else if (action_id == EActions.SET_MAX_QUANTITY) //SetMaxQuantity
10675 {
10677
10678 if (m_EM)
10679 {
10680 m_EM.SetEnergy(m_EM.GetEnergyMax());
10681 }
10682 }
10683
10684 else if (action_id == EActions.ADD_HEALTH)
10685 {
10686 AddHealth("","",GetMaxHealth("","Health")/5);
10687 }
10688 else if (action_id == EActions.REMOVE_HEALTH)
10689 {
10690 AddHealth("","",-GetMaxHealth("","Health")/5);
10691 }
10692 else if (action_id == EActions.DESTROY_HEALTH)
10693 {
10694 SetHealth01("","",0);
10695 }
10696 else if (action_id == EActions.WATCH_ITEM)
10697 {
10699 mid.RegisterDebugItem(ItemBase.Cast(this), PlayerBase.Cast(player));
10700 #ifdef DEVELOPER
10701 SetDebugDeveloper_item(this);
10702 #endif
10703 }
10704
10705 else if (action_id == EActions.ADD_TEMPERATURE)
10706 {
10707 AddTemperature(20);
10708 //PrintVariables();
10709 }
10710
10711 else if (action_id == EActions.REMOVE_TEMPERATURE)
10712 {
10713 AddTemperature(-20);
10714 //PrintVariables();
10715 }
10716
10717 else if (action_id == EActions.FLIP_FROZEN)
10718 {
10719 SetFrozen(!GetIsFrozen());
10720 //PrintVariables();
10721 }
10722
10723 else if (action_id == EActions.ADD_WETNESS)
10724 {
10725 AddWet(GetWetMax()/5);
10726 //PrintVariables();
10727 }
10728
10729 else if (action_id == EActions.REMOVE_WETNESS)
10730 {
10731 AddWet(-GetWetMax()/5);
10732 //PrintVariables();
10733 }
10734
10735 else if (action_id == EActions.LIQUIDTYPE_UP)
10736 {
10737 int curr_type = GetLiquidType();
10738 SetLiquidType(curr_type * 2);
10739 //AddWet(1);
10740 //PrintVariables();
10741 }
10742
10743 else if (action_id == EActions.LIQUIDTYPE_DOWN)
10744 {
10745 int curr_type2 = GetLiquidType();
10746 SetLiquidType(curr_type2 / 2);
10747 }
10748
10749 else if (action_id == EActions.MAKE_SPECIAL)
10750 {
10751 auto debugParams = DebugSpawnParams.WithPlayer(player);
10752 OnDebugSpawnEx(debugParams);
10753 }
10754
10755 }
10756
10757
10758 return false;
10759 }
10760
10761 // -------------------------------------------------------------------------
10762
10763
10766 void OnActivatedByTripWire();
10767
10769 void OnActivatedByItem(notnull ItemBase item);
10770
10771 //----------------------------------------------------------------
10772 //returns true if item is able to explode when put in fire
10773 bool CanExplodeInFire()
10774 {
10775 return false;
10776 }
10777
10778 //----------------------------------------------------------------
10779 bool CanEat()
10780 {
10781 return true;
10782 }
10783
10784 //----------------------------------------------------------------
10785 override bool IsIgnoredByConstruction()
10786 {
10787 return true;
10788 }
10789
10790 //----------------------------------------------------------------
10791 //has FoodStages in config?
10792 bool HasFoodStage()
10793 {
10794 string config_path = string.Format("CfgVehicles %1 Food FoodStages", GetType());
10795 return g_Game.ConfigIsExisting(config_path);
10796 }
10797
10799 FoodStage GetFoodStage()
10800 {
10801 return null;
10802 }
10803
10804 bool CanBeCooked()
10805 {
10806 return false;
10807 }
10808
10809 bool CanBeCookedOnStick()
10810 {
10811 return false;
10812 }
10813
10815 void RefreshAudioVisualsOnClient( CookingMethodType cooking_method, bool is_done, bool is_empty, bool is_burned );
10817
10818 //----------------------------------------------------------------
10819 bool CanRepair(ItemBase item_repair_kit)
10820 {
10821 PluginRepairing module_repairing = PluginRepairing.Cast(GetPlugin(PluginRepairing));
10822 return module_repairing.CanRepair(this, item_repair_kit);
10823 }
10824
10825 //----------------------------------------------------------------
10826 bool Repair(PlayerBase player, ItemBase item_repair_kit, float specialty_weight)
10827 {
10828 PluginRepairing module_repairing = PluginRepairing.Cast(GetPlugin(PluginRepairing));
10829 return module_repairing.Repair(player, this, item_repair_kit, specialty_weight);
10830 }
10831
10832 //----------------------------------------------------------------
10833 int GetItemSize()
10834 {
10835 /*
10836 vector v_size = this.ConfigGetVector("itemSize");
10837 int v_size_x = v_size[0];
10838 int v_size_y = v_size[1];
10839 int size = v_size_x * v_size_y;
10840 return size;
10841 */
10842
10843 return 1;
10844 }
10845
10846 //----------------------------------------------------------------
10847 //Override for allowing seemingly unallowed moves when two clients send a conflicting message simultaneously
10848 bool CanBeMovedOverride()
10849 {
10850 return m_CanBeMovedOverride;
10851 }
10852
10853 //----------------------------------------------------------------
10854 //Override for allowing seemingly unallowed moves when two clients send a conflicting message simultaneously
10855 void SetCanBeMovedOverride(bool setting)
10856 {
10857 m_CanBeMovedOverride = setting;
10858 }
10859
10860 //----------------------------------------------------------------
10868 void MessageToOwnerStatus(string text)
10869 {
10870 PlayerBase player = PlayerBase.Cast(this.GetHierarchyRootPlayer());
10871
10872 if (player)
10873 {
10874 player.MessageStatus(text);
10875 }
10876 }
10877
10878 //----------------------------------------------------------------
10886 void MessageToOwnerAction(string text)
10887 {
10888 PlayerBase player = PlayerBase.Cast(this.GetHierarchyRootPlayer());
10889
10890 if (player)
10891 {
10892 player.MessageAction(text);
10893 }
10894 }
10895
10896 //----------------------------------------------------------------
10904 void MessageToOwnerFriendly(string text)
10905 {
10906 PlayerBase player = PlayerBase.Cast(this.GetHierarchyRootPlayer());
10907
10908 if (player)
10909 {
10910 player.MessageFriendly(text);
10911 }
10912 }
10913
10914 //----------------------------------------------------------------
10922 void MessageToOwnerImportant(string text)
10923 {
10924 PlayerBase player = PlayerBase.Cast(this.GetHierarchyRootPlayer());
10925
10926 if (player)
10927 {
10928 player.MessageImportant(text);
10929 }
10930 }
10931
10932 override bool IsItemBase()
10933 {
10934 return true;
10935 }
10936
10937 // Checks if item is of questioned kind
10938 override bool KindOf(string tag)
10939 {
10940 bool found = false;
10941 string item_name = this.GetType();
10942 ref TStringArray item_tag_array = new TStringArray;
10943 g_Game.ConfigGetTextArray("cfgVehicles " + item_name + " itemInfo", item_tag_array);
10944
10945 int array_size = item_tag_array.Count();
10946 for (int i = 0; i < array_size; i++)
10947 {
10948 if (item_tag_array.Get(i) == tag)
10949 {
10950 found = true;
10951 break;
10952 }
10953 }
10954 return found;
10955 }
10956
10957
10958 override void OnRPC(PlayerIdentity sender, int rpc_type,ParamsReadContext ctx)
10959 {
10960 //Debug.Log("OnRPC called");
10961 super.OnRPC(sender, rpc_type,ctx);
10962
10963 //Play soundset for attachment locking (ActionLockAttachment.c)
10964 switch (rpc_type)
10965 {
10966 #ifndef SERVER
10967 case ERPCs.RPC_SOUND_LOCK_ATTACH:
10968 Param2<bool, string> p = new Param2<bool, string>(false, "");
10969
10970 if (!ctx.Read(p))
10971 return;
10972
10973 bool play = p.param1;
10974 string soundSet = p.param2;
10975
10976 if (play)
10977 {
10978 if (m_LockingSound)
10979 {
10981 {
10982 m_LockingSound = SEffectManager.PlaySound(soundSet, GetPosition(), 0, 0, true);
10983 }
10984 }
10985 else
10986 {
10987 m_LockingSound = SEffectManager.PlaySound(soundSet, GetPosition(), 0, 0, true);
10988 }
10989 }
10990 else
10991 {
10992 SEffectManager.DestroyEffect(m_LockingSound);
10993 }
10994
10995 break;
10996 #endif
10997
10998 }
10999
11000 if (GetWrittenNoteData())
11001 {
11002 GetWrittenNoteData().OnRPC(sender, rpc_type,ctx);
11003 }
11004 }
11005
11006 //-----------------------------
11007 // VARIABLE MANIPULATION SYSTEM
11008 //-----------------------------
11009 int NameToID(string name)
11010 {
11011 PluginVariables plugin = PluginVariables.Cast(GetPlugin(PluginVariables));
11012 return plugin.GetID(name);
11013 }
11014
11015 string IDToName(int id)
11016 {
11017 PluginVariables plugin = PluginVariables.Cast(GetPlugin(PluginVariables));
11018 return plugin.GetName(id);
11019 }
11020
11022 void OnSyncVariables(ParamsReadContext ctx)//with ID optimization
11023 {
11024 //Debug.Log("OnSyncVariables called for item: "+ ToString(this.GetType()),"varSync");
11025 //read the flags
11026 int varFlags;
11027 if (!ctx.Read(varFlags))
11028 return;
11029
11030 if (varFlags & ItemVariableFlags.FLOAT)
11031 {
11032 ReadVarsFromCTX(ctx);
11033 }
11034 }
11035
11036 override void SerializeNumericalVars(array<float> floats_out)
11037 {
11038 //some variables handled on EntityAI level already!
11039 super.SerializeNumericalVars(floats_out);
11040
11041 // the order of serialization must be the same as the order of de-serialization
11042 //--------------------------------------------
11043 if (IsVariableSet(VARIABLE_QUANTITY))
11044 {
11045 floats_out.Insert(m_VarQuantity);
11046 }
11047 //--------------------------------------------
11048 if (IsVariableSet(VARIABLE_WET))
11049 {
11050 floats_out.Insert(m_VarWet);
11051 }
11052 //--------------------------------------------
11053 if (IsVariableSet(VARIABLE_LIQUIDTYPE))
11054 {
11055 floats_out.Insert(m_VarLiquidType);
11056 }
11057 //--------------------------------------------
11058 if (IsVariableSet(VARIABLE_COLOR))
11059 {
11060 floats_out.Insert(m_ColorComponentR);
11061 floats_out.Insert(m_ColorComponentG);
11062 floats_out.Insert(m_ColorComponentB);
11063 floats_out.Insert(m_ColorComponentA);
11064 }
11065 //--------------------------------------------
11066 if (IsVariableSet(VARIABLE_CLEANNESS))
11067 {
11068 floats_out.Insert(m_Cleanness);
11069 }
11070 }
11071
11072 override void DeSerializeNumericalVars(array<float> floats)
11073 {
11074 //some variables handled on EntityAI level already!
11075 super.DeSerializeNumericalVars(floats);
11076
11077 // the order of serialization must be the same as the order of de-serialization
11078 int index = 0;
11079 int mask = Math.Round(floats.Get(index));
11080
11081 index++;
11082 //--------------------------------------------
11083 if (mask & VARIABLE_QUANTITY)
11084 {
11085 if (m_IsStoreLoad)
11086 {
11087 SetStoreLoadedQuantity(floats.Get(index));
11088 }
11089 else
11090 {
11091 float quantity = floats.Get(index);
11092 SetQuantity(quantity, true, false, false, false);
11093 }
11094 index++;
11095 }
11096 //--------------------------------------------
11097 if (mask & VARIABLE_WET)
11098 {
11099 float wet = floats.Get(index);
11100 SetWet(wet);
11101 index++;
11102 }
11103 //--------------------------------------------
11104 if (mask & VARIABLE_LIQUIDTYPE)
11105 {
11106 int liquidtype = Math.Round(floats.Get(index));
11107 SetLiquidType(liquidtype);
11108 index++;
11109 }
11110 //--------------------------------------------
11111 if (mask & VARIABLE_COLOR)
11112 {
11113 m_ColorComponentR = Math.Round(floats.Get(index));
11114 index++;
11115 m_ColorComponentG = Math.Round(floats.Get(index));
11116 index++;
11117 m_ColorComponentB = Math.Round(floats.Get(index));
11118 index++;
11119 m_ColorComponentA = Math.Round(floats.Get(index));
11120 index++;
11121 }
11122 //--------------------------------------------
11123 if (mask & VARIABLE_CLEANNESS)
11124 {
11125 int cleanness = Math.Round(floats.Get(index));
11126 SetCleanness(cleanness);
11127 index++;
11128 }
11129 }
11130
11131 override void WriteVarsToCTX(ParamsWriteContext ctx)
11132 {
11133 super.WriteVarsToCTX(ctx);
11134
11135 //--------------------------------------------
11136 if (IsVariableSet(VARIABLE_QUANTITY))
11137 {
11138 ctx.Write(GetQuantity());
11139 }
11140 //--------------------------------------------
11141 if (IsVariableSet(VARIABLE_WET))
11142 {
11143 ctx.Write(GetWet());
11144 }
11145 //--------------------------------------------
11146 if (IsVariableSet(VARIABLE_LIQUIDTYPE))
11147 {
11148 ctx.Write(GetLiquidType());
11149 }
11150 //--------------------------------------------
11151 if (IsVariableSet(VARIABLE_COLOR))
11152 {
11153 int r,g,b,a;
11154 GetColor(r,g,b,a);
11155 ctx.Write(r);
11156 ctx.Write(g);
11157 ctx.Write(b);
11158 ctx.Write(a);
11159 }
11160 //--------------------------------------------
11161 if (IsVariableSet(VARIABLE_CLEANNESS))
11162 {
11163 ctx.Write(GetCleanness());
11164 }
11165 }
11166
11167 override bool ReadVarsFromCTX(ParamsReadContext ctx, int version = -1)//with ID optimization
11168 {
11169 if (!super.ReadVarsFromCTX(ctx,version))
11170 return false;
11171
11172 int intValue;
11173 float value;
11174
11175 if (version < 140)
11176 {
11177 if (!ctx.Read(intValue))
11178 return false;
11179
11180 m_VariablesMask = intValue;
11181 }
11182
11183 if (m_VariablesMask & VARIABLE_QUANTITY)
11184 {
11185 if (!ctx.Read(value))
11186 return false;
11187
11188 if (IsStoreLoad())
11189 {
11191 }
11192 else
11193 {
11194 SetQuantity(value, true, false, false, false);
11195 }
11196 }
11197 //--------------------------------------------
11198 if (version < 140)
11199 {
11200 if (m_VariablesMask & VARIABLE_TEMPERATURE)
11201 {
11202 if (!ctx.Read(value))
11203 return false;
11204 SetTemperatureDirect(value);
11205 }
11206 }
11207 //--------------------------------------------
11208 if (m_VariablesMask & VARIABLE_WET)
11209 {
11210 if (!ctx.Read(value))
11211 return false;
11212 SetWet(value);
11213 }
11214 //--------------------------------------------
11215 if (m_VariablesMask & VARIABLE_LIQUIDTYPE)
11216 {
11217 if (!ctx.Read(intValue))
11218 return false;
11219 SetLiquidType(intValue);
11220 }
11221 //--------------------------------------------
11222 if (m_VariablesMask & VARIABLE_COLOR)
11223 {
11224 int r,g,b,a;
11225 if (!ctx.Read(r))
11226 return false;
11227 if (!ctx.Read(g))
11228 return false;
11229 if (!ctx.Read(b))
11230 return false;
11231 if (!ctx.Read(a))
11232 return false;
11233
11234 SetColor(r,g,b,a);
11235 }
11236 //--------------------------------------------
11237 if (m_VariablesMask & VARIABLE_CLEANNESS)
11238 {
11239 if (!ctx.Read(intValue))
11240 return false;
11241 SetCleanness(intValue);
11242 }
11243 //--------------------------------------------
11244 if (version >= 138 && version < 140)
11245 {
11246 if (m_VariablesMask & VARIABLE_TEMPERATURE)
11247 {
11248 if (!ctx.Read(intValue))
11249 return false;
11250 SetFrozen(intValue);
11251 }
11252 }
11253
11254 return true;
11255 }
11256
11257 //----------------------------------------------------------------
11258 override bool OnStoreLoad(ParamsReadContext ctx, int version)
11259 {
11260 m_IsStoreLoad = true;
11262 {
11263 m_FixDamageSystemInit = true;
11264 }
11265
11266 if (!super.OnStoreLoad(ctx, version))
11267 {
11268 m_IsStoreLoad = false;
11269 return false;
11270 }
11271
11272 if (version >= 114)
11273 {
11274 bool hasQuickBarIndexSaved;
11275
11276 if (!ctx.Read(hasQuickBarIndexSaved))
11277 {
11278 m_IsStoreLoad = false;
11279 return false;
11280 }
11281
11282 if (hasQuickBarIndexSaved)
11283 {
11284 int itmQBIndex;
11285
11286 //Load quickbar item bind
11287 if (!ctx.Read(itmQBIndex))
11288 {
11289 m_IsStoreLoad = false;
11290 return false;
11291 }
11292
11293 PlayerBase parentPlayer = PlayerBase.Cast(GetHierarchyRootPlayer());
11294 if (itmQBIndex != -1 && parentPlayer)
11295 parentPlayer.SetLoadedQuickBarItemBind(this, itmQBIndex);
11296 }
11297 }
11298 else
11299 {
11300 // Backup of how it used to be
11301 PlayerBase player;
11302 int itemQBIndex;
11303 if (version == int.MAX)
11304 {
11305 if (!ctx.Read(itemQBIndex))
11306 {
11307 m_IsStoreLoad = false;
11308 return false;
11309 }
11310 }
11311 else if (Class.CastTo(player, GetHierarchyRootPlayer()))
11312 {
11313 //Load quickbar item bind
11314 if (!ctx.Read(itemQBIndex))
11315 {
11316 m_IsStoreLoad = false;
11317 return false;
11318 }
11319 if (itemQBIndex != -1 && player)
11320 player.SetLoadedQuickBarItemBind(this,itemQBIndex);
11321 }
11322 }
11323
11324 if (version < 140)
11325 {
11326 // variable management system
11327 if (!LoadVariables(ctx, version))
11328 {
11329 m_IsStoreLoad = false;
11330 return false;
11331 }
11332 }
11333
11334 //agent trasmission system
11335 if (!LoadAgents(ctx, version))
11336 {
11337 m_IsStoreLoad = false;
11338 return false;
11339 }
11340 if (version >= 132)
11341 {
11342 RemotelyActivatedItemBehaviour raib = GetRemotelyActivatedItemBehaviour();
11343 if (raib)
11344 {
11345 if (!raib.OnStoreLoad(ctx,version))
11346 {
11347 m_IsStoreLoad = false;
11348 return false;
11349 }
11350 }
11351 }
11352
11353 m_IsStoreLoad = false;
11354 return true;
11355 }
11356
11357 //----------------------------------------------------------------
11358
11359 override void OnStoreSave(ParamsWriteContext ctx)
11360 {
11361 super.OnStoreSave(ctx);
11362
11363 PlayerBase player;
11364 if (PlayerBase.CastTo(player,GetHierarchyRootPlayer()))
11365 {
11366 ctx.Write(true); // Keep track of if we should actually read this in or not
11367 //Save quickbar item bind
11368 int itemQBIndex = -1;
11369 itemQBIndex = player.FindQuickBarEntityIndex(this);
11370 ctx.Write(itemQBIndex);
11371 }
11372 else
11373 {
11374 ctx.Write(false); // Keep track of if we should actually read this in or not
11375 }
11376
11377 SaveAgents(ctx);//agent trasmission system
11378
11379 RemotelyActivatedItemBehaviour raib = GetRemotelyActivatedItemBehaviour();
11380 if (raib)
11381 {
11382 raib.OnStoreSave(ctx);
11383 }
11384 }
11385 //----------------------------------------------------------------
11386
11387 override void AfterStoreLoad()
11388 {
11389 super.AfterStoreLoad();
11390
11392 {
11394 }
11395
11396 if (GetStoreLoadedQuantity() != float.LOWEST)
11397 {
11399 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
11400 }
11401 }
11402
11403 override void EEOnAfterLoad()
11404 {
11405 super.EEOnAfterLoad();
11406
11408 {
11409 m_FixDamageSystemInit = false;
11410 }
11411
11414 }
11415
11416 bool CanBeDisinfected()
11417 {
11418 return false;
11419 }
11420
11421
11422 //----------------------------------------------------------------
11423 override void OnVariablesSynchronized()
11424 {
11425 if (m_Initialized)
11426 {
11427 #ifdef PLATFORM_CONSOLE
11428 //bruteforce it is
11429 if (IsSplitable())
11430 {
11431 UIScriptedMenu menu = g_Game.GetUIManager().FindMenu(MENU_INVENTORY);
11432 if (menu)
11433 {
11434 menu.Refresh();
11435 }
11436 }
11437 #endif
11438 }
11439
11441 {
11442 PlayImpactSound(m_ConfigWeight, m_ImpactSpeed, m_ImpactSoundSurfaceHash);
11443 m_WantPlayImpactSound = false;
11444 }
11445
11447 {
11448 SetWeightDirty();
11450 }
11451 if (m_VarWet != m_VarWetPrev)
11452 {
11455 }
11456
11457 if (m_SoundSyncPlay != 0)
11458 {
11461
11462 m_SoundSyncPlay = 0;
11463 m_SoundSyncSlotID = -1;
11464 }
11465 if (m_SoundSyncStop != 0)
11466 {
11468 m_ItemSoundHandler.StopItemSoundClient(m_SoundSyncStop);
11469 m_SoundSyncStop = 0;
11470 }
11471
11472 super.OnVariablesSynchronized();
11473 }
11474
11475 //------------------------- Quantity
11476 //----------------------------------------------------------------
11478 override bool SetQuantity(float value, bool destroy_config = true, bool destroy_forced = false, bool allow_client = false, bool clamp_to_stack_max = true)
11479 {
11480 if (!IsServerCheck(allow_client))
11481 return false;
11482
11483 if (!HasQuantity())
11484 return false;
11485
11486 float min = GetQuantityMin();
11487 float max = GetQuantityMax();
11488
11489 if (value <= (min + 0.001))
11490 value = min;
11491
11492 if (value == min)
11493 {
11494 if (destroy_config)
11495 {
11496 bool dstr = ConfigGetBool("varQuantityDestroyOnMin");
11497 if (dstr)
11498 {
11499 m_VarQuantity = Math.Clamp(value, min, max);
11500 this.Delete();
11501 return true;
11502 }
11503 }
11504 else if (destroy_forced)
11505 {
11506 m_VarQuantity = Math.Clamp(value, min, max);
11507 this.Delete();
11508 return true;
11509 }
11510 // we get here if destroy_config IS true AND dstr(config destroy param) IS false;
11511 RemoveAllAgents();//we remove all agents when we got to the min value, but the item is not getting deleted
11512 }
11513
11514 float delta = m_VarQuantity;
11515 m_VarQuantity = Math.Clamp(value, min, max);
11516
11517 if (g_Game.IsServer() || !g_Game.IsMultiplayer()) // single player or server side multiplayer
11518 {
11519 EntityAI parent = GetHierarchyRoot();
11520 InventoryLocation iLoc = new InventoryLocation();
11521 GetInventory().GetCurrentInventoryLocation(iLoc);
11522 if (iLoc && iLoc.IsValid() && delta != m_VarQuantity)
11523 {
11524 int iLocSlot = iLoc.GetSlot();
11525 if (delta < m_VarQuantity && iLoc.GetType() != InventoryLocationType.GROUND)
11526 {
11527 StartItemSoundServer(SoundConstants.ITEM_ATTACH, iLocSlot);
11528 }
11529 if (delta > m_VarQuantity && m_VarQuantity != 0 && !IsPrepareToDelete() && iLoc.GetType() == InventoryLocationType.ATTACHMENT)
11530 {
11531 StartItemSoundServer(SoundConstants.ITEM_DETACH, iLocSlot);
11532 }
11533 }
11534 }
11535
11536 if (GetStoreLoadedQuantity() == float.LOWEST)//any other value means we are setting quantity from storage
11537 {
11538 delta = m_VarQuantity - delta;
11539
11540 if (delta)
11541 OnQuantityChanged(delta);
11542 }
11543
11544 SetVariableMask(VARIABLE_QUANTITY);
11545
11546 return false;
11547 }
11548
11549 //----------------------------------------------------------------
11551 bool AddQuantity(float value, bool destroy_config = true, bool destroy_forced = false)
11552 {
11553 return SetQuantity(GetQuantity() + value, destroy_config, destroy_forced);
11554 }
11555 //----------------------------------------------------------------
11556 void SetQuantityMax()
11557 {
11558 float max = GetQuantityMax();
11559 SetQuantity(max);
11560 }
11561
11562 override void SetQuantityToMinimum()
11563 {
11564 float min = GetQuantityMin();
11565 SetQuantity(min);
11566 }
11567 //----------------------------------------------------------------
11569 override void SetQuantityNormalized(float value, bool destroy_config = true, bool destroy_forced = false)
11570 {
11571 float value_clamped = Math.Clamp(value, 0, 1);//just to make sure
11572 int result = Math.Round(Math.Lerp(GetQuantityMin(), GetQuantityMax(), value_clamped));
11573 SetQuantity(result, destroy_config, destroy_forced);
11574 }
11575
11576 //----------------------------------------------------------------
11578 override float GetQuantityNormalized()
11579 {
11580 return Math.InverseLerp(GetQuantityMin(), GetQuantityMax(),m_VarQuantity);
11581 }
11582
11584 {
11585 return GetQuantityNormalized();
11586 }
11587
11588 /*void SetAmmoNormalized(float value)
11589 {
11590 float value_clamped = Math.Clamp(value, 0, 1);
11591 Magazine this_mag = Magazine.Cast(this);
11592 int max_rounds = this_mag.GetAmmoMax();
11593 int result = value * max_rounds;//can the rounded if higher precision is required
11594 this_mag.SetAmmoCount(result);
11595 }*/
11596 //----------------------------------------------------------------
11597 override int GetQuantityMax()
11598 {
11599 int slot = -1;
11600 GameInventory inventory = GetInventory();
11601 if (inventory)
11602 {
11603 InventoryLocation il = new InventoryLocation;
11604 inventory.GetCurrentInventoryLocation(il);
11605 slot = il.GetSlot();
11606 }
11607
11608 return GetTargetQuantityMax(slot);
11609 }
11610
11611 override int GetTargetQuantityMax(int attSlotID = -1)
11612 {
11613 float quantity_max = 0;
11614
11615 if (IsSplitable()) //only stackable/splitable items can check for stack size
11616 {
11617 if (attSlotID != -1)
11618 quantity_max = InventorySlots.GetStackMaxForSlotId(attSlotID);
11619
11620 if (quantity_max <= 0)
11621 quantity_max = m_VarStackMax;
11622 }
11623
11624 if (quantity_max <= 0)
11625 quantity_max = m_VarQuantityMax;
11626
11627 return quantity_max;
11628 }
11629 //----------------------------------------------------------------
11630 override int GetQuantityMin()
11631 {
11632 return m_VarQuantityMin;
11633 }
11634 //----------------------------------------------------------------
11635 int GetQuantityInit()
11636 {
11637 return m_VarQuantityInit;
11638 }
11639
11640 //----------------------------------------------------------------
11641 override bool HasQuantity()
11642 {
11643 return !(GetQuantityMax() - GetQuantityMin() == 0);
11644 }
11645
11646 override float GetQuantity()
11647 {
11648 return m_VarQuantity;
11649 }
11650
11651 bool IsFullQuantity()
11652 {
11653 return GetQuantity() >= GetQuantityMax();
11654 }
11655
11656 //Calculates weight of single item without attachments and cargo
11657 override float GetSingleInventoryItemWeightEx()
11658 {
11659 //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
11660 float weightEx = GetWeightEx();//overall weight of the item
11661 float special = GetInventoryAndCargoWeight();//cargo and attachment weight
11662 return weightEx - special;
11663 }
11664
11665 // Obsolete, use GetSingleInventoryItemWeightEx() instead
11667 {
11669 }
11670
11671 override protected float GetWeightSpecialized(bool forceRecalc = false)
11672 {
11673 if (IsSplitable()) //quantity determines size of the stack
11674 {
11675 #ifdef DEVELOPER
11676 if (WeightDebug.m_VerbosityFlags & WeightDebugType.RECALC_FORCED)
11677 {
11678 WeightDebugData data1 = WeightDebug.GetWeightDebug(this);
11679 data1.SetCalcDetails("TIB1: " + GetConfigWeightModifiedDebugText() +" * " + GetQuantity()+"(quantity)");
11680 }
11681 #endif
11682
11683 return GetQuantity() * GetConfigWeightModified();
11684 }
11685 else if (HasEnergyManager())// items with energy manager
11686 {
11687 #ifdef DEVELOPER
11688 if (WeightDebug.m_VerbosityFlags & WeightDebugType.RECALC_FORCED)
11689 {
11690 WeightDebugData data2 = WeightDebug.GetWeightDebug(this);
11691 data2.SetCalcDetails("TIB2: "+super.GetWeightSpecialized(forceRecalc)+"(contents weight) + " + GetConfigWeightModifiedDebugText() +" + " + GetCompEM().GetEnergy()+"(energy) * " + ConfigGetFloat("weightPerQuantityUnit") +"(weightPerQuantityUnit)");
11692 }
11693 #endif
11694 return super.GetWeightSpecialized(forceRecalc) + (GetCompEM().GetEnergy() * ConfigGetFloat("weightPerQuantityUnit")) + GetConfigWeightModified();
11695 }
11696 else//everything else
11697 {
11698 #ifdef DEVELOPER
11699 if (WeightDebug.m_VerbosityFlags & WeightDebugType.RECALC_FORCED)
11700 {
11701 WeightDebugData data3 = WeightDebug.GetWeightDebug(this);
11702 data3.SetCalcDetails("TIB3: "+super.GetWeightSpecialized(forceRecalc)+"(contents weight) + " + GetConfigWeightModifiedDebugText() +" + " + GetQuantity()+"(quantity) * " + ConfigGetFloat("weightPerQuantityUnit") +"(weightPerQuantityUnit))");
11703 }
11704 #endif
11705 return super.GetWeightSpecialized(forceRecalc) + (GetQuantity() * ConfigGetFloat("weightPerQuantityUnit")) + GetConfigWeightModified();
11706 }
11707 }
11708
11710 int GetNumberOfItems()
11711 {
11712 int item_count = 0;
11713 ItemBase item;
11714
11715 GameInventory inventory = GetInventory();
11716 CargoBase cargo = inventory.GetCargo();
11717 if (cargo != NULL)
11718 {
11719 item_count = cargo.GetItemCount();
11720 }
11721
11722 int nAttachments = inventory.AttachmentCount();
11723 for (int i = 0; i < nAttachments; ++i)
11724 {
11725 Class.CastTo(item, inventory.GetAttachmentFromIndex(i));
11726 if (item)
11727 item_count += item.GetNumberOfItems();
11728 }
11729 return item_count;
11730 }
11731
11733 float GetUnitWeight(bool include_wetness = true)
11734 {
11735 float weight = 0;
11736 float wetness = 1;
11737 if (include_wetness)
11738 wetness += GetWet();
11739 if (IsSplitable()) //quantity determines size of the stack
11740 {
11741 weight = wetness * m_ConfigWeight;
11742 }
11743 else if (IsLiquidContainer()) //is a liquid container, default liquid weight is set to 1. May revisit later?
11744 {
11745 weight = 1;
11746 }
11747 return weight;
11748 }
11749
11750 //-----------------------------------------------------------------
11751
11752 override void ClearInventory()
11753 {
11754 GameInventory inventory = GetInventory();
11755 if ((g_Game.IsServer() || !g_Game.IsMultiplayer()) && inventory)
11756 {
11757 array<EntityAI> items = new array<EntityAI>;
11758 inventory.EnumerateInventory(InventoryTraversalType.INORDER, items);
11759 for (int i = 0; i < items.Count(); ++i)
11760 {
11761 ItemBase item = ItemBase.Cast(items.Get(i));
11762 if (item)
11763 {
11764 g_Game.ObjectDelete(item);
11765 }
11766 }
11767 }
11768 }
11769
11770 //------------------------- Energy
11771
11772 //----------------------------------------------------------------
11773 float GetEnergy()
11774 {
11775 float energy = 0;
11776 if (HasEnergyManager())
11777 {
11778 energy = GetCompEM().GetEnergy();
11779 }
11780 return energy;
11781 }
11782
11783
11784 override void OnEnergyConsumed()
11785 {
11786 super.OnEnergyConsumed();
11787
11789 }
11790
11791 override void OnEnergyAdded()
11792 {
11793 super.OnEnergyAdded();
11794
11796 }
11797
11798 // Converts energy (from Energy Manager) to quantity, if enabled.
11800 {
11801 if (g_Game.IsServer() && HasEnergyManager() && GetCompEM().HasConversionOfEnergyToQuantity())
11802 {
11803 if (HasQuantity())
11804 {
11805 float energy_0to1 = GetCompEM().GetEnergy0To1();
11806 SetQuantityNormalized(energy_0to1);
11807 }
11808 }
11809 }
11810
11811 //----------------------------------------------------------------
11812 float GetHeatIsolationInit()
11813 {
11814 return ConfigGetFloat("heatIsolation");
11815 }
11816
11817 float GetHeatIsolation()
11818 {
11819 return m_HeatIsolation;
11820 }
11821
11822 float GetDryingIncrement(string pIncrementName)
11823 {
11824 string paramPath = string.Format("CfgVehicles %1 EnvironmentWetnessIncrements Drying %2", GetType(), pIncrementName);
11825 if (g_Game.ConfigIsExisting(paramPath))
11826 return g_Game.ConfigGetFloat(paramPath);
11827
11828 return 0.0;
11829 }
11830
11831 float GetSoakingIncrement(string pIncrementName)
11832 {
11833 string paramPath = string.Format("CfgVehicles %1 EnvironmentWetnessIncrements Soaking %2", GetType(), pIncrementName);
11834 if (g_Game.ConfigIsExisting(paramPath))
11835 return g_Game.ConfigGetFloat(paramPath);
11836
11837 return 0.0;
11838 }
11839 //----------------------------------------------------------------
11840 override void SetWet(float value, bool allow_client = false)
11841 {
11842 if (!IsServerCheck(allow_client))
11843 return;
11844
11845 float min = GetWetMin();
11846 float max = GetWetMax();
11847
11848 float previousValue = m_VarWet;
11849
11850 m_VarWet = Math.Clamp(value, min, max);
11851
11852 if (previousValue != m_VarWet)
11853 {
11854 SetVariableMask(VARIABLE_WET);
11855 OnWetChanged(m_VarWet, previousValue);
11856 }
11857 }
11858 //----------------------------------------------------------------
11859 override void AddWet(float value)
11860 {
11861 SetWet(GetWet() + value);
11862 }
11863 //----------------------------------------------------------------
11864 override void SetWetMax()
11865 {
11867 }
11868 //----------------------------------------------------------------
11869 override float GetWet()
11870 {
11871 return m_VarWet;
11872 }
11873 //----------------------------------------------------------------
11874 override float GetWetMax()
11875 {
11876 return m_VarWetMax;
11877 }
11878 //----------------------------------------------------------------
11879 override float GetWetMin()
11880 {
11881 return m_VarWetMin;
11882 }
11883 //----------------------------------------------------------------
11884 override float GetWetInit()
11885 {
11886 return m_VarWetInit;
11887 }
11888 //----------------------------------------------------------------
11889 override void OnWetChanged(float newVal, float oldVal)
11890 {
11891 EWetnessLevel newLevel = GetWetLevelInternal(newVal);
11892 EWetnessLevel oldLevel = GetWetLevelInternal(oldVal);
11893 if (newLevel != oldLevel)
11894 {
11895 OnWetLevelChanged(newLevel,oldLevel);
11896 }
11897 }
11898
11899 override void OnWetLevelChanged(EWetnessLevel newLevel, EWetnessLevel oldLevel)
11900 {
11901 SetWeightDirty();
11902 }
11903
11904 override EWetnessLevel GetWetLevel()
11905 {
11906 return GetWetLevelInternal(m_VarWet);
11907 }
11908
11909 //----------------------------------------------------------------
11910
11911 override void SetStoreLoad(bool value)
11912 {
11913 m_IsStoreLoad = value;
11914 }
11915
11916 override bool IsStoreLoad()
11917 {
11918 return m_IsStoreLoad;
11919 }
11920
11921 override void SetStoreLoadedQuantity(float value)
11922 {
11923 m_StoreLoadedQuantity = value;
11924 }
11925
11926 override float GetStoreLoadedQuantity()
11927 {
11928 return m_StoreLoadedQuantity;
11929 }
11930
11931 //----------------------------------------------------------------
11932
11933 float GetItemModelLength()
11934 {
11935 if (ConfigIsExisting("itemModelLength"))
11936 {
11937 return ConfigGetFloat("itemModelLength");
11938 }
11939 return 0;
11940 }
11941
11942 float GetItemAttachOffset()
11943 {
11944 if (ConfigIsExisting("itemAttachOffset"))
11945 {
11946 return ConfigGetFloat("itemAttachOffset");
11947 }
11948 return 0;
11949 }
11950
11951 override void SetCleanness(int value, bool allow_client = false)
11952 {
11953 if (!IsServerCheck(allow_client))
11954 return;
11955
11956 int previousValue = m_Cleanness;
11957
11958 m_Cleanness = Math.Clamp(value, m_CleannessMin, m_CleannessMax);
11959
11960 if (previousValue != m_Cleanness)
11961 SetVariableMask(VARIABLE_CLEANNESS);
11962 }
11963
11964 override int GetCleanness()
11965 {
11966 return m_Cleanness;
11967 }
11968
11970 {
11971 return true;
11972 }
11973
11974 //----------------------------------------------------------------
11975 // ATTACHMENT LOCKING
11976 // Getters relevant to generic ActionLockAttachment
11977 int GetLockType()
11978 {
11979 return m_LockType;
11980 }
11981
11982 string GetLockSoundSet()
11983 {
11984 return m_LockSoundSet;
11985 }
11986
11987 //----------------------------------------------------------------
11988 //------------------------- Color
11989 // sets items color variable given color components
11990 override void SetColor(int r, int g, int b, int a)
11991 {
11996 SetVariableMask(VARIABLE_COLOR);
11997 }
11999 override void GetColor(out int r,out int g,out int b,out int a)
12000 {
12005 }
12006
12007 bool IsColorSet()
12008 {
12009 return IsVariableSet(VARIABLE_COLOR);
12010 }
12011
12013 string GetColorString()
12014 {
12015 int r,g,b,a;
12016 GetColor(r,g,b,a);
12017 r = r/255;
12018 g = g/255;
12019 b = b/255;
12020 a = a/255;
12021 return MiscGameplayFunctions.GetColorString(r, g, b, a);
12022 }
12023 //----------------------------------------------------------------
12024 //------------------------- LiquidType
12025
12026 override void SetLiquidType(int value, bool allow_client = false)
12027 {
12028 if (!IsServerCheck(allow_client))
12029 return;
12030
12031 int old = m_VarLiquidType;
12032 m_VarLiquidType = value;
12033 OnLiquidTypeChanged(old,value);
12034 SetVariableMask(VARIABLE_LIQUIDTYPE);
12035 }
12036
12037 int GetLiquidTypeInit()
12038 {
12039 return ConfigGetInt("varLiquidTypeInit");
12040 }
12041
12042 override int GetLiquidType()
12043 {
12044 return m_VarLiquidType;
12045 }
12046
12047 protected void OnLiquidTypeChanged(int oldType, int newType)
12048 {
12049 if (newType == LIQUID_NONE && GetIsFrozen())
12050 SetFrozen(false);
12051 }
12052
12054 void UpdateQuickbarShortcutVisibility(PlayerBase player)
12055 {
12056 player.SetEnableQuickBarEntityShortcut(this,!GetHierarchyParent() || GetHierarchyParent().GetInventory().AreChildrenAccessible());
12057 }
12058
12059 // -------------------------------------------------------------------------
12061 void OnInventoryEnter(Man player)
12062 {
12063 PlayerBase nplayer;
12064 if (PlayerBase.CastTo(nplayer, player))
12065 {
12066 m_CanPlayImpactSound = true;
12067 nplayer.SetEnableQuickBarEntityShortcut(this,!GetHierarchyParent() || GetHierarchyParent().GetInventory().AreChildrenAccessible());
12068 }
12069 }
12070
12071 // -------------------------------------------------------------------------
12073 void OnInventoryExit(Man player)
12074 {
12075 PlayerBase nplayer;
12076 if (PlayerBase.CastTo(nplayer,player))
12077 {
12078 nplayer.SetEnableQuickBarEntityShortcut(this, false);
12079 }
12080
12081 player.GetHumanInventory().ClearUserReservedLocationForContainer(this);
12082
12083 if (HasEnergyManager())
12084 {
12085 GetCompEM().UpdatePlugState(); // Unplug the el. device if it's necesarry.
12086 }
12087 }
12088
12089 // ADVANCED PLACEMENT EVENTS
12090 override void OnPlacementStarted(Man player)
12091 {
12092 super.OnPlacementStarted(player);
12093
12094 SetTakeable(false);
12095 }
12096
12097 override void OnPlacementComplete(Man player, vector position = "0 0 0", vector orientation = "0 0 0")
12098 {
12099 if (m_AdminLog)
12100 {
12101 m_AdminLog.OnPlacementComplete(player, this);
12102 }
12103
12104 super.OnPlacementComplete(player, position, orientation);
12105 }
12106
12107 //-----------------------------
12108 // AGENT SYSTEM
12109 //-----------------------------
12110 //--------------------------------------------------------------------------
12111 bool ContainsAgent(int agent_id)
12112 {
12113 if (agent_id & m_AttachedAgents)
12114 {
12115 return true;
12116 }
12117 else
12118 {
12119 return false;
12120 }
12121 }
12122
12123 //--------------------------------------------------------------------------
12124 override void RemoveAgent(int agent_id)
12125 {
12126 if (ContainsAgent(agent_id))
12127 {
12128 m_AttachedAgents = ~agent_id & m_AttachedAgents;
12129 }
12130 }
12131
12132 //--------------------------------------------------------------------------
12133 override void RemoveAllAgents()
12134 {
12135 m_AttachedAgents = 0;
12136 }
12137 //--------------------------------------------------------------------------
12138 override void RemoveAllAgentsExcept(int agent_to_keep)
12139 {
12140 m_AttachedAgents = m_AttachedAgents & agent_to_keep;
12141 }
12142 // -------------------------------------------------------------------------
12143 override void InsertAgent(int agent, float count = 1)
12144 {
12145 if (count < 1)
12146 return;
12147 //Debug.Log("Inserting Agent on item: " + agent.ToString() +" count: " + count.ToString());
12149 }
12150
12152 void TransferAgents(int agents)
12153 {
12155 }
12156
12157 // -------------------------------------------------------------------------
12158 override int GetAgents()
12159 {
12160 return m_AttachedAgents;
12161 }
12162 //----------------------------------------------------------------------
12163
12164 /*int GetContaminationType()
12165 {
12166 int contamination_type;
12167
12168 const int CONTAMINATED_MASK = eAgents.CHOLERA | eAgents.INFLUENZA | eAgents.SALMONELLA | eAgents.BRAIN;
12169 const int POISONED_MASK = eAgents.FOOD_POISON | eAgents.CHEMICAL_POISON;
12170 const int NERVE_GAS_MASK = eAgents.CHEMICAL_POISON;
12171 const int DIRTY_MASK = eAgents.WOUND_AGENT;
12172
12173 Edible_Base edible = Edible_Base.Cast(this);
12174 int agents = GetAgents();
12175 if (edible)
12176 {
12177 NutritionalProfile profile = Edible_Base.GetNutritionalProfile(edible);
12178 if (profile)
12179 {
12180 agents = agents | profile.GetAgents();//merge item's agents with nutritional agents
12181 }
12182 }
12183 if (agents & CONTAMINATED_MASK)
12184 {
12185 contamination_type = contamination_type | EContaminationTypes.ITEM_BADGE_CONTAMINATED;
12186 }
12187 if (agents & POISONED_MASK)
12188 {
12189 contamination_type = contamination_type | EContaminationTypes.ITEM_BADGE_POISONED;
12190 }
12191 if (agents & NERVE_GAS_MASK)
12192 {
12193 contamination_type = contamination_type | EContaminationTypes.ITEM_BADGE_NERVE_GAS;
12194 }
12195 if (agents & DIRTY_MASK)
12196 {
12197 contamination_type = contamination_type | EContaminationTypes.ITEM_BADGE_DIRTY;
12198 }
12199
12200 return agents;
12201 }*/
12202
12203 // -------------------------------------------------------------------------
12204 bool LoadAgents(ParamsReadContext ctx, int version)
12205 {
12206 if (!ctx.Read(m_AttachedAgents))
12207 return false;
12208 return true;
12209 }
12210 // -------------------------------------------------------------------------
12212 {
12213
12215 }
12216 // -------------------------------------------------------------------------
12217
12219 override void CheckForRoofLimited(float timeTresholdMS = 3000)
12220 {
12221 super.CheckForRoofLimited(timeTresholdMS);
12222
12223 float time = g_Game.GetTime();
12224 if ((time - m_PreviousRoofTestTime) >= timeTresholdMS)
12225 {
12226 m_PreviousRoofTestTime = time;
12227 SetRoofAbove(MiscGameplayFunctions.IsUnderRoof(this));
12228 }
12229 }
12230
12231 // returns item's protection level against enviromental hazard, for masks with filters, returns the filters protection for valid filter, otherwise 0
12232 float GetProtectionLevel(int type, bool consider_filter = false, int system = 0)
12233 {
12234 if (IsDamageDestroyed() || (HasQuantity() && GetQuantity() <= 0))
12235 {
12236 return 0;
12237 }
12238
12239 if (GetInventory().GetAttachmentSlotsCount() != 0)//is it an item with attachable filter ?
12240 {
12241 ItemBase filter = ItemBase.Cast(FindAttachmentBySlotName("GasMaskFilter"));
12242 if (filter)
12243 return filter.GetProtectionLevel(type, false, system);//it's a valid filter, return the protection
12244 else
12245 return 0;//otherwise return 0 when no filter attached
12246 }
12247
12248 string subclassPath, entryName;
12249
12250 switch (type)
12251 {
12252 case DEF_BIOLOGICAL:
12253 entryName = "biological";
12254 break;
12255 case DEF_CHEMICAL:
12256 entryName = "chemical";
12257 break;
12258 default:
12259 entryName = "biological";
12260 break;
12261 }
12262
12263 subclassPath = "CfgVehicles " + this.GetType() + " Protection ";
12264
12265 return g_Game.ConfigGetFloat(subclassPath + entryName);
12266 }
12267
12268
12269
12271 override void EEOnCECreate()
12272 {
12273 if (!IsMagazine())
12275
12277 }
12278
12279
12280 //-------------------------
12281 // OPEN/CLOSE USER ACTIONS
12282 //-------------------------
12284 void Open();
12285 void Close();
12286 bool IsOpen()
12287 {
12288 return true;
12289 }
12290
12291 override bool CanDisplayCargo()
12292 {
12293 return IsOpen();
12294 }
12295
12296
12297 // ------------------------------------------------------------
12298 // CONDITIONS
12299 // ------------------------------------------------------------
12300 override bool CanPutInCargo(EntityAI parent)
12301 {
12302 if (parent)
12303 {
12304 if (parent.IsInherited(DayZInfected))
12305 return true;
12306
12307 if (!parent.IsRuined())
12308 return true;
12309 }
12310
12311 return true;
12312 }
12313
12314 override bool CanPutAsAttachment(EntityAI parent)
12315 {
12316 if (!super.CanPutAsAttachment(parent))
12317 {
12318 return false;
12319 }
12320
12321 if (!IsRuined() && !parent.IsRuined())
12322 {
12323 return true;
12324 }
12325
12326 return false;
12327 }
12328
12329 override bool CanReceiveItemIntoCargo(EntityAI item)
12330 {
12331 //removed 15.06. coz of loading from storage -> after load items in cargo was lost -> waiting for proper solution
12332 //if (GetHealthLevel() == GameConstants.STATE_RUINED)
12333 // return false;
12334
12335 return super.CanReceiveItemIntoCargo(item);
12336 }
12337
12338 override bool CanReceiveAttachment(EntityAI attachment, int slotId)
12339 {
12340 //removed 15.06. coz of loading from storage -> after load items in cargo was lost -> waiting for proper solution
12341 //if (GetHealthLevel() == GameConstants.STATE_RUINED)
12342 // return false;
12343
12344 GameInventory attachmentInv = attachment.GetInventory();
12345 if (attachmentInv && attachmentInv.GetCargo() && attachmentInv.GetCargo().GetItemCount() > 0)
12346 {
12347 if (GetHierarchyParent() && !GetHierarchyParent().IsInherited(PlayerBase))
12348 return false;
12349 }
12350
12351 InventoryLocation loc = new InventoryLocation();
12352 attachment.GetInventory().GetCurrentInventoryLocation(loc);
12353 if (loc && loc.IsValid() && !GetInventory().AreChildrenAccessible())
12354 return false;
12355
12356 return super.CanReceiveAttachment(attachment, slotId);
12357 }
12358
12359 override bool CanReleaseAttachment(EntityAI attachment)
12360 {
12361 if (!super.CanReleaseAttachment(attachment))
12362 return false;
12363
12364 return GetInventory().AreChildrenAccessible();
12365 }
12366
12367 /*override bool CanLoadAttachment(EntityAI attachment)
12368 {
12369 //removed 15.06. coz of loading from storage -> after load items in cargo was lost -> waiting for proper solution
12370 //if (GetHealthLevel() == GameConstants.STATE_RUINED)
12371 // return false;
12372
12373 GameInventory attachmentInv = attachment.GetInventory();
12374 if (attachmentInv && attachmentInv.GetCargo() && attachmentInv.GetCargo().GetItemCount() > 0)
12375 {
12376 bool boo = (GetHierarchyParent() && !GetHierarchyParent().IsInherited(PlayerBase));
12377 ErrorEx("CanLoadAttachment | this: " + this + " | attachment: " + attachment + " | boo: " + boo,ErrorExSeverity.INFO);
12378
12379 if (GetHierarchyParent() && !GetHierarchyParent().IsInherited(PlayerBase))
12380 return false;
12381 }
12382
12383 return super.CanLoadAttachment(attachment);
12384 }*/
12385
12386 // Plays muzzle flash particle effects
12387 static void PlayFireParticles(ItemBase weapon, int muzzle_index, string ammoType, ItemBase muzzle_owner, ItemBase suppressor, string config_to_search)
12388 {
12389 int id = muzzle_owner.GetMuzzleID();
12390 array<ref WeaponParticlesOnFire> WPOF_array = m_OnFireEffect.Get(id);
12391
12392 if (WPOF_array)
12393 {
12394 for (int i = 0; i < WPOF_array.Count(); i++)
12395 {
12396 WeaponParticlesOnFire WPOF = WPOF_array.Get(i);
12397
12398 if (WPOF)
12399 {
12400 WPOF.OnActivate(weapon, muzzle_index, ammoType, muzzle_owner, suppressor, config_to_search);
12401 }
12402 }
12403 }
12404 }
12405
12406 // Plays bullet eject particle effects (usually just smoke, the bullet itself is a 3D model and is not part of this function)
12407 static void PlayBulletCasingEjectParticles(ItemBase weapon, string ammoType, ItemBase muzzle_owner, ItemBase suppressor, string config_to_search)
12408 {
12409 int id = muzzle_owner.GetMuzzleID();
12410 array<ref WeaponParticlesOnBulletCasingEject> WPOBE_array = m_OnBulletCasingEjectEffect.Get(id);
12411
12412 if (WPOBE_array)
12413 {
12414 for (int i = 0; i < WPOBE_array.Count(); i++)
12415 {
12416 WeaponParticlesOnBulletCasingEject WPOBE = WPOBE_array.Get(i);
12417
12418 if (WPOBE)
12419 {
12420 WPOBE.OnActivate(weapon, 0, ammoType, muzzle_owner, suppressor, config_to_search);
12421 }
12422 }
12423 }
12424 }
12425
12426 // Plays all weapon overheating particles
12427 static void PlayOverheatingParticles(ItemBase weapon, string ammoType, ItemBase muzzle_owner, ItemBase suppressor, string config_to_search)
12428 {
12429 int id = muzzle_owner.GetMuzzleID();
12430 array<ref WeaponParticlesOnOverheating> WPOOH_array = weapon.m_OnOverheatingEffect.Get(id);
12431
12432 if (WPOOH_array)
12433 {
12434 for (int i = 0; i < WPOOH_array.Count(); i++)
12435 {
12436 WeaponParticlesOnOverheating WPOOH = WPOOH_array.Get(i);
12437
12438 if (WPOOH)
12439 {
12440 WPOOH.OnActivate(weapon, 0, ammoType, muzzle_owner, suppressor, config_to_search);
12441 }
12442 }
12443 }
12444 }
12445
12446 // Updates all weapon overheating particles
12447 static void UpdateOverheatingParticles(ItemBase weapon, string ammoType, ItemBase muzzle_owner, ItemBase suppressor, string config_to_search)
12448 {
12449 int id = muzzle_owner.GetMuzzleID();
12450 array<ref WeaponParticlesOnOverheating> WPOOH_array = weapon.m_OnOverheatingEffect.Get(id);
12451
12452 if (WPOOH_array)
12453 {
12454 for (int i = 0; i < WPOOH_array.Count(); i++)
12455 {
12456 WeaponParticlesOnOverheating WPOOH = WPOOH_array.Get(i);
12457
12458 if (WPOOH)
12459 {
12460 WPOOH.OnUpdate(weapon, ammoType, muzzle_owner, suppressor, config_to_search);
12461 }
12462 }
12463 }
12464 }
12465
12466 // Stops overheating particles
12467 static void StopOverheatingParticles(ItemBase weapon, string ammoType, ItemBase muzzle_owner, ItemBase suppressor, string config_to_search)
12468 {
12469 int id = muzzle_owner.GetMuzzleID();
12470 array<ref WeaponParticlesOnOverheating> WPOOH_array = weapon.m_OnOverheatingEffect.Get(id);
12471
12472 if (WPOOH_array)
12473 {
12474 for (int i = 0; i < WPOOH_array.Count(); i++)
12475 {
12476 WeaponParticlesOnOverheating WPOOH = WPOOH_array.Get(i);
12477
12478 if (WPOOH)
12479 {
12480 WPOOH.OnDeactivate(weapon, ammoType, muzzle_owner, suppressor, config_to_search);
12481 }
12482 }
12483 }
12484 }
12485
12486 //----------------------------------------------------------------
12487 //Item Behaviour - unified approach
12488 override bool IsHeavyBehaviour()
12489 {
12490 if (m_ItemBehaviour == 0)
12491 {
12492 return true;
12493 }
12494
12495 return false;
12496 }
12497
12498 override bool IsOneHandedBehaviour()
12499 {
12500 if (m_ItemBehaviour == 1)
12501 {
12502 return true;
12503 }
12504
12505 return false;
12506 }
12507
12508 override bool IsTwoHandedBehaviour()
12509 {
12510 if (m_ItemBehaviour == 2)
12511 {
12512 return true;
12513 }
12514
12515 return false;
12516 }
12517
12518 bool IsDeployable()
12519 {
12520 return false;
12521 }
12522
12524 float GetDeployTime()
12525 {
12526 return UATimeSpent.DEFAULT_DEPLOY;
12527 }
12528
12529
12530 //----------------------------------------------------------------
12531 // Item Targeting (User Actions)
12532 override void SetTakeable(bool pState)
12533 {
12534 m_IsTakeable = pState;
12535 SetSynchDirty();
12536 }
12537
12538 override bool IsTakeable()
12539 {
12540 return m_IsTakeable;
12541 }
12542
12543 // For cases where we want to show object widget which cant be taken to hands
12545 {
12546 return false;
12547 }
12548
12550 protected void PreLoadSoundAttachmentType()
12551 {
12552 string att_type = "None";
12553
12554 if (ConfigIsExisting("soundAttType"))
12555 {
12556 att_type = ConfigGetString("soundAttType");
12557 }
12558
12559 m_SoundAttType = att_type;
12560 }
12561
12562 override string GetAttachmentSoundType()
12563 {
12564 return m_SoundAttType;
12565 }
12566
12567 //----------------------------------------------------------------
12568 //SOUNDS - ItemSoundHandler
12569 //----------------------------------------------------------------
12570
12571 string GetPlaceSoundset(); // played when deploy starts
12572 string GetLoopDeploySoundset(); // played when deploy starts and stopped when it finishes
12573 string GetDeploySoundset(); // played when deploy sucessfully finishes
12574 string GetLoopFoldSoundset(); // played when fold starts and stopped when it finishes
12575 string GetFoldSoundset(); // played when fold sucessfully finishes
12576
12578 {
12579 if (!m_ItemSoundHandler)
12581
12582 return m_ItemSoundHandler;
12583 }
12584
12585 // override to initialize sounds
12586 protected void InitItemSounds()
12587 {
12588 if (GetPlaceSoundset() == string.Empty && GetDeploySoundset() == string.Empty && GetLoopDeploySoundset() == string.Empty && !GetInventoryItemType().SetDetachSoundEvent() && !GetInventoryItemType().SetAttachSoundEvent())
12589 return;
12590
12592
12593 if (GetPlaceSoundset() != string.Empty)
12594 handler.AddSound(SoundConstants.ITEM_PLACE, GetPlaceSoundset());
12595
12596 if (GetDeploySoundset() != string.Empty)
12597 handler.AddSound(SoundConstants.ITEM_DEPLOY, GetDeploySoundset());
12598
12599 SoundParameters params = new SoundParameters();
12600 params.m_Loop = true;
12601 if (GetLoopDeploySoundset() != string.Empty)
12602 handler.AddSound(SoundConstants.ITEM_DEPLOY_LOOP, GetLoopDeploySoundset(), params);
12603 }
12604
12605 // Start sound using ItemSoundHandler
12606 void StartItemSoundServer(int id, int slotId)
12607 {
12608 if (g_Game.IsServer() || !g_Game.IsMultiplayer()) // single player or server side multiplayer
12609 {
12610 m_SoundSyncSlotID = slotId;
12611 m_SoundSyncPlay = id;
12612
12613 SetSynchDirty();
12614
12615 g_Game.GetCallQueue(CALL_CATEGORY_SYSTEM).Remove(ClearStartItemSoundServer); // in case one is queued already
12616 g_Game.GetCallQueue(CALL_CATEGORY_SYSTEM).CallLater(ClearStartItemSoundServer, 100);
12617 }
12618 }
12619
12620 void StartItemSoundServer(int id)
12621 {
12622 StartItemSoundServer(id, InventorySlots.INVALID);
12623 }
12624
12625 // Stop sound using ItemSoundHandler
12626 void StopItemSoundServer(int id)
12627 {
12628 if (!g_Game.IsServer())
12629 return;
12630
12631 m_SoundSyncStop = id;
12632 SetSynchDirty();
12633
12634 g_Game.GetCallQueue(CALL_CATEGORY_SYSTEM).Remove(ClearStopItemSoundServer); // in case one is queued already
12635 g_Game.GetCallQueue(CALL_CATEGORY_SYSTEM).CallLater(ClearStopItemSoundServer, 100);
12636 }
12637
12638 protected void ClearStartItemSoundServer()
12639 {
12640 m_SoundSyncPlay = 0;
12641 m_SoundSyncSlotID = InventorySlots.INVALID;
12642 }
12643
12644 protected void ClearStopItemSoundServer()
12645 {
12646 m_SoundSyncStop = 0;
12647 }
12648
12649 void OnApply(PlayerBase player);
12650
12652 {
12653 return 1.0;
12654 };
12655 //returns applicable selection
12656 array<string> GetHeadHidingSelection()
12657 {
12659 }
12660
12662 {
12664 }
12665
12666 WrittenNoteData GetWrittenNoteData() {};
12667
12669 {
12670 SetDynamicPhysicsLifeTime(0.01);
12671 m_ItemBeingDroppedPhys = false;
12672 }
12673
12675 {
12676 array<string> zone_names = new array<string>;
12677 GetDamageZones(zone_names);
12678 for (int i = 0; i < zone_names.Count(); i++)
12679 {
12680 SetHealthMax(zone_names.Get(i),"Health");
12681 }
12682 SetHealthMax("","Health");
12683 }
12684
12686 void SetZoneDamageCEInit()
12687 {
12688 float global_health = GetHealth01("","Health");
12689 array<string> zones = new array<string>;
12690 GetDamageZones(zones);
12691 //set damage of all zones to match global health level
12692 for (int i = 0; i < zones.Count(); i++)
12693 {
12694 SetHealth01(zones.Get(i),"Health",global_health);
12695 }
12696 }
12697
12699 bool IsCoverFaceForShave(string slot_name)
12700 {
12701 return IsExclusionFlagPresent(PlayerBase.GetFaceCoverageShaveValues());
12702 }
12703
12704 void ProcessItemWetness(float delta, bool hasParent, bool hasRootAsPlayer, ItemBase refParentIB)
12705 {
12706 if (!hasRootAsPlayer)
12707 {
12708 if (refParentIB)
12709 {
12710 // parent is wet
12711 if ((refParentIB.GetWet() >= GameConstants.STATE_SOAKING_WET) && (m_VarWet < m_VarWetMax))
12712 AddWet(delta * GameConstants.WETNESS_RATE_WETTING_INSIDE);
12713 // parent has liquid inside
12714 else if ((refParentIB.GetLiquidType() != 0) && (refParentIB.GetQuantity() > 0) && (m_VarWet < m_VarWetMax))
12715 AddWet(delta * GameConstants.WETNESS_RATE_WETTING_LIQUID);
12716 // drying
12717 else if (m_VarWet > m_VarWetMin)
12718 AddWet(-1 * delta * GetDryingIncrement("ground") * 2);
12719 }
12720 else
12721 {
12722 // drying on ground or inside non-itembase (car, ...)
12723 if (m_VarWet > m_VarWetMin)
12724 AddWet(-1 * delta * GetDryingIncrement("ground"));
12725 }
12726 }
12727 }
12728
12729 void ProcessItemTemperature(float delta, bool hasParent, bool hasRootAsPlayer, ItemBase refParentIB)
12730 {
12732 {
12733 float target = g_Game.GetMission().GetWorldData().GetBaseEnvTemperatureAtObject(this);
12734 if (GetTemperature() != target || !IsFreezeThawProgressFinished())
12735 {
12736 float heatPermCoef = 1.0;
12737 EntityAI ent = this;
12738 while (ent)
12739 {
12740 heatPermCoef *= ent.GetHeatPermeabilityCoef();
12741 ent = ent.GetHierarchyParent();
12742 }
12743
12744 SetTemperatureEx(new TemperatureDataInterpolated(target,ETemperatureAccessTypes.ACCESS_WORLD,delta,GameConstants.TEMP_COEF_WORLD,heatPermCoef));
12745 }
12746 }
12747 }
12748
12749 void HierarchyCheck(out bool hasParent, out bool hasRootAsPlayer, out ItemBase refParentIB)
12750 {
12751 // hierarchy check for an item to decide whether it has some parent and it is in some player inventory
12752 EntityAI parent = GetHierarchyParent();
12753 if (!parent)
12754 {
12755 hasParent = false;
12756 hasRootAsPlayer = false;
12757 }
12758 else
12759 {
12760 hasParent = true;
12761 hasRootAsPlayer = (GetHierarchyRootPlayer() != null);
12762 refParentIB = ItemBase.Cast(parent);
12763 }
12764 }
12765
12766 protected void ProcessDecay(float delta, bool hasRootAsPlayer)
12767 {
12768 // this is stub, implemented on Edible_Base
12769 }
12770
12771 bool CanDecay()
12772 {
12773 // return true used on selected food clases so they can decay
12774 return false;
12775 }
12776
12777 protected bool CanProcessDecay()
12778 {
12779 // this is stub, implemented on Edible_Base class
12780 // used to determine whether it is still necessary for the food to decay
12781 return false;
12782 }
12783
12784 protected bool CanHaveWetness()
12785 {
12786 // return true used on selected items that have a wetness effect
12787 return false;
12788 }
12789
12791 bool CanBeConsumed(ConsumeConditionData data = null)
12792 {
12793 return !GetIsFrozen() && IsOpen();
12794 }
12795
12796 override void ProcessVariables()
12797 {
12798 bool hasParent = false, hasRootAsPlayer = false;
12799 ItemBase refParentIB;
12800
12801 bool wwtu = g_Game.IsWorldWetTempUpdateEnabled();
12802 bool foodDecay = g_Game.IsFoodDecayEnabled();
12803
12804 if (wwtu || foodDecay)
12805 {
12806 bool processWetness = wwtu && CanHaveWetness();
12807 bool processTemperature = wwtu && CanHaveTemperature();
12808 bool processDecay = foodDecay && CanDecay() && CanProcessDecay();
12809
12810 if (processWetness || processTemperature || processDecay)
12811 {
12812 HierarchyCheck(hasParent, hasRootAsPlayer, refParentIB);
12813
12814 if (processWetness)
12815 ProcessItemWetness(m_ElapsedSinceLastUpdate, hasParent, hasRootAsPlayer, refParentIB);
12816
12817 if (processTemperature)
12818 ProcessItemTemperature(m_ElapsedSinceLastUpdate, hasParent, hasRootAsPlayer, refParentIB);
12819
12820 if (processDecay)
12821 ProcessDecay(m_ElapsedSinceLastUpdate, hasRootAsPlayer);
12822 }
12823 }
12824 }
12825
12828 {
12829 return m_TemperaturePerQuantityWeight * GameConstants.ITEM_TEMPERATURE_QUANTITY_WEIGHT_MULTIPLIER;
12830 }
12831
12832 override float GetTemperatureFreezeThreshold()
12833 {
12835 return Liquid.GetFreezeThreshold(GetLiquidType());
12836
12837 return super.GetTemperatureFreezeThreshold();
12838 }
12839
12840 override float GetTemperatureThawThreshold()
12841 {
12843 return Liquid.GetThawThreshold(GetLiquidType());
12844
12845 return super.GetTemperatureThawThreshold();
12846 }
12847
12848 override float GetItemOverheatThreshold()
12849 {
12851 return Liquid.GetBoilThreshold(GetLiquidType());
12852
12853 return super.GetItemOverheatThreshold();
12854 }
12855
12856 override float GetTemperatureFreezeTime()
12857 {
12858 if (HasQuantity())
12859 return Math.Lerp(GameConstants.TEMPERATURE_TIME_FREEZE_MIN,Math.Max(GameConstants.TEMPERATURE_TIME_FREEZE_MIN,super.GetTemperatureFreezeTime()),GetQuantityNormalized());
12860
12861 return super.GetTemperatureFreezeTime();
12862 }
12863
12864 override float GetTemperatureThawTime()
12865 {
12866 if (HasQuantity())
12867 return Math.Lerp(GameConstants.TEMPERATURE_TIME_THAW_MIN,Math.Max(GameConstants.TEMPERATURE_TIME_FREEZE_MIN,super.GetTemperatureThawTime()),GetQuantityNormalized());
12868
12869 return super.GetTemperatureThawTime();
12870 }
12871
12873 void AffectLiquidContainerOnFill(int liquid_type, float amount);
12875 void AffectLiquidContainerOnTransfer(int liquidType, float amount, float sourceLiquidTemperature);
12876
12877 bool IsCargoException4x3(EntityAI item)
12878 {
12879 return (item.IsKindOf("Cauldron") || item.IsKindOf("Pot") || item.IsKindOf("FryingPan") || item.IsKindOf("SmallProtectorCase") || (item.IsKindOf("PortableGasStove") && item.FindAttachmentBySlotName("CookingEquipment")));
12880 }
12881
12883 {
12884 MiscGameplayFunctions.TransferItemProperties(oldItem, this);
12885 }
12886
12888 void AddLightSourceItem(ItemBase lightsource)
12889 {
12890 m_LightSourceItem = lightsource;
12891 }
12892
12894 {
12895 m_LightSourceItem = null;
12896 }
12897
12899 {
12900 return m_LightSourceItem;
12901 }
12902
12904 array<int> GetValidFinishers()
12905 {
12906 return null;
12907 }
12908
12910 bool GetActionWidgetOverride(out typename name)
12911 {
12912 return false;
12913 }
12914
12915 bool PairWithDevice(notnull ItemBase otherDevice)
12916 {
12917 if (g_Game.IsServer())
12918 {
12919 ItemBase explosive = otherDevice;
12921 if (!trg)
12922 {
12923 trg = RemoteDetonatorTrigger.Cast(otherDevice);
12924 explosive = this;
12925 }
12926
12927 explosive.PairRemote(trg);
12928 trg.SetControlledDevice(explosive);
12929
12930 int persistentID = RemotelyActivatedItemBehaviour.GeneratePersistentID();
12931 trg.SetPersistentPairID(persistentID);
12932 explosive.SetPersistentPairID(persistentID);
12933
12934 return true;
12935 }
12936 return false;
12937 }
12938
12940 float GetBaitEffectivity()
12941 {
12942 float ret = 1.0;
12943 if (HasQuantity())
12944 ret *= GetQuantityNormalized();
12945 ret *= GetHealth01();
12946
12947 return ret;
12948 }
12949
12950 #ifdef DEVELOPER
12951 override void SetDebugItem()
12952 {
12953 super.SetDebugItem();
12954 _itemBase = this;
12955 }
12956
12957 override string GetDebugText()
12958 {
12959 string text = super.GetDebugText();
12960
12961 text += string.Format("Heat isolation(raw): %1\n", GetHeatIsolation());
12962 text += string.Format("Heat isolation(modified): %1\n", MiscGameplayFunctions.GetCurrentItemHeatIsolation(this));
12963
12964 return text;
12965 }
12966 #endif
12967
12968 bool CanBeUsedForSuicide()
12969 {
12970 return true;
12971 }
12972
12974 //DEPRECATED BELOW
12976 // Backwards compatibility
12977 void ProcessItemWetnessAndTemperature(float delta, bool hasParent, bool hasRootAsPlayer, ItemBase refParentIB)
12978 {
12979 ProcessItemWetness(delta, hasParent, hasRootAsPlayer, refParentIB);
12980 ProcessItemTemperature(delta, hasParent, hasRootAsPlayer, refParentIB);
12981 }
12982
12983 // replaced by ItemSoundHandler
12984 protected EffectSound m_SoundDeployFinish;
12985 protected EffectSound m_SoundPlace;
12986 protected EffectSound m_DeployLoopSoundEx;
12987 protected EffectSound m_SoundDeploy;
12988 bool m_IsPlaceSound;
12989 bool m_IsDeploySound;
12991
12992 string GetDeployFinishSoundset();
12993 void PlayDeploySound();
12994 void PlayDeployFinishSound();
12995 void PlayPlaceSound();
12996 void PlayDeployLoopSoundEx();
12997 void StopDeployLoopSoundEx();
12998 void SoundSynchRemoteReset();
12999 void SoundSynchRemote();
13000 bool UsesGlobalDeploy(){return false;}
13001 bool CanPlayDeployLoopSound(){return false;}
13003 bool IsPlaceSound(){return m_IsPlaceSound;}
13004 bool IsDeploySound(){return m_IsDeploySound;}
13005 void SetIsPlaceSound(bool is_place_sound);
13006 void SetIsDeploySound(bool is_deploy_sound);
13007
13008 [Obsolete("Use ItemSoundHandler instead")]
13010 void PlayAttachSound(string slot_type)
13011 {
13012 if (!g_Game.IsDedicatedServer())
13013 {
13014 if (ConfigIsExisting("attachSoundSet"))
13015 {
13016 string cfg_path = "";
13017 string soundset = "";
13018 string type_name = GetType();
13019
13020 TStringArray cfg_soundset_array = new TStringArray;
13021 TStringArray cfg_slot_array = new TStringArray;
13022 ConfigGetTextArray("attachSoundSet",cfg_soundset_array);
13023 ConfigGetTextArray("attachSoundSlot",cfg_slot_array);
13024
13025 if (cfg_soundset_array.Count() > 0 && cfg_soundset_array.Count() == cfg_slot_array.Count())
13026 {
13027 for (int i = 0; i < cfg_soundset_array.Count(); i++)
13028 {
13029 if (cfg_slot_array[i] == slot_type)
13030 {
13031 soundset = cfg_soundset_array[i];
13032 break;
13033 }
13034 }
13035 }
13036
13037 if (soundset != "")
13038 {
13039 EffectSound sound = SEffectManager.PlaySound(soundset, GetPosition());
13040 sound.SetAutodestroy(true);
13041 }
13042 }
13043 }
13044 }
13045
13046 void PlayDetachSound(string slot_type) {}
13047}
13048
13049EntityAI SpawnItemOnLocation(string object_name, notnull InventoryLocation loc, bool full_quantity)
13050{
13051 EntityAI entity = SpawnEntity(object_name, loc, ECE_IN_INVENTORY, RF_DEFAULT);
13052 if (entity)
13053 {
13054 bool is_item = entity.IsInherited(ItemBase);
13055 if (is_item && full_quantity)
13056 {
13057 ItemBase item = ItemBase.Cast(entity);
13058 item.SetQuantity(item.GetQuantityInit());
13059 }
13060 }
13061 else
13062 {
13063 ErrorEx("Cannot spawn entity: " + object_name,ErrorExSeverity.INFO);
13064 return NULL;
13065 }
13066 return entity;
13067}
13068
13069void SetupSpawnedItem(ItemBase item, float health, float quantity)
13070{
13071 if (item)
13072 {
13073 if (health > 0)
13074 item.SetHealth("", "", health);
13075
13076 if (item.CanHaveTemperature())
13077 {
13078 item.SetTemperatureDirect(GameConstants.ITEM_TEMPERATURE_NEUTRAL_ZONE_MIDDLE);
13079 if (item.CanFreeze())
13080 item.SetFrozen(false);
13081 }
13082
13083 if (item.HasEnergyManager())
13084 {
13085 if (quantity >= 0)
13086 {
13087 item.GetCompEM().SetEnergy0To1(quantity);
13088 }
13089 else
13090 {
13091 item.GetCompEM().SetEnergy(Math.AbsFloat(quantity));
13092 }
13093 }
13094 else if (item.IsMagazine())
13095 {
13096 Magazine mag = Magazine.Cast(item);
13097 if (quantity >= 0)
13098 {
13099 mag.ServerSetAmmoCount(mag.GetAmmoMax() * quantity);
13100 }
13101 else
13102 {
13103 mag.ServerSetAmmoCount(Math.AbsFloat(quantity));
13104 }
13105
13106 }
13107 else
13108 {
13109 if (quantity >= 0)
13110 {
13111 item.SetQuantityNormalized(quantity, false);
13112 }
13113 else
13114 {
13115 item.SetQuantity(Math.AbsFloat(quantity));
13116 }
13117
13118 }
13119 }
13120}
13121
13122#ifdef DEVELOPER
13123ItemBase _itemBase;//watched item goes here(LCTRL+RMB->Watch)
13124#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()