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

◆ SetQuantity()

override bool SpawnItemOnLocation::SetQuantity ( float value,
bool destroy_config = true,
bool destroy_forced = false,
bool allow_client = false,
bool clamp_to_stack_max = true )
protected

Set item quantity[related to varQuantity... config entry], destroy_config = true > if the quantity reaches varQuantityMin or lower and the item config contains the varQuantityDestroyOnMin = true entry, the item gets destroyed. destroy_forced = true means item gets destroyed when quantity reaches varQuantityMin or lower regardless of config setting, returns true if the item gets deleted.

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

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

Используется в CalcAndSetQuantity(), Capture(), MaskBase::EEHealthLevelChanged() и Release().