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

◆ OnStoreSave()

override void SpawnItemOnLocation::OnStoreSave ( ParamsWriteContext ctx)
protected

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

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