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

◆ GetUnitWeight()

float SpawnItemOnLocation::GetUnitWeight ( bool include_wetness = true)
protected

Obsolete, use GetWeightEx instead.

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

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