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

◆ EEOnAfterLoad()

override void SpawnItemOnLocation::EEOnAfterLoad ( )
protected

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

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