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

◆ WriteVarsToCTX()

override void SpawnItemOnLocation::WriteVarsToCTX ( ParamsWriteContext ctx)
private

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

7667{
7668 override bool CanPutAsAttachment(EntityAI parent)
7669 {
7670 return true;
7671 }
7672};
7673
7674//const bool QUANTITY_DEBUG_REMOVE_ME = false;
7675
7676class ItemBase extends InventoryItem
7677{
7681
7683
7684 static int m_DebugActionsMask;
7686 // ============================================
7687 // Variable Manipulation System
7688 // ============================================
7689 // Quantity
7690
7691 float m_VarQuantity;
7692 float m_VarQuantityPrev;//for client to know quantity changed during synchronization
7694 int m_VarQuantityMin;
7695 int m_VarQuantityMax;
7696 int m_Count;
7697 float m_VarStackMax;
7698 float m_StoreLoadedQuantity = float.LOWEST;
7699 // Wet
7700 float m_VarWet;
7701 float m_VarWetPrev;//for client to know wetness changed during synchronization
7702 float m_VarWetInit;
7703 float m_VarWetMin;
7704 float m_VarWetMax;
7705 // Cleanness
7706 int m_Cleanness;
7707 int m_CleannessInit;
7708 int m_CleannessMin;
7709 int m_CleannessMax;
7710 // impact sounds
7712 bool m_CanPlayImpactSound = true;
7713 float m_ImpactSpeed;
7715 //
7716 float m_HeatIsolation;
7717 float m_ItemModelLength;
7718 float m_ItemAttachOffset; // Offset length for when the item is attached e.g. to weapon
7720 int m_VarLiquidType;
7721 int m_ItemBehaviour; // -1 = not specified; 0 = heavy item; 1= onehanded item; 2 = twohanded item
7722 int m_QuickBarBonus;
7723 bool m_IsBeingPlaced;
7724 bool m_IsHologram;
7725 bool m_IsTakeable;
7726 bool m_ThrowItemOnDrop;
7729 bool m_FixDamageSystemInit = false; //can be changed on storage version check
7730 bool can_this_be_combined; //Check if item can be combined
7731 bool m_CanThisBeSplit; //Check if item can be split
7732 bool m_IsStoreLoad = false;
7733 bool m_CanShowQuantity;
7734 bool m_HasQuantityBar;
7735 protected bool m_CanBeDigged;
7736 protected bool m_IsResultOfSplit
7737
7738 string m_SoundAttType;
7739 // items color variables
7744 //-------------------------------------------------------
7745
7746 // light source managing
7748
7752
7753 //==============================================
7754 // agent system
7755 private int m_AttachedAgents;
7756
7758 void TransferModifiers(PlayerBase reciever);
7759
7760
7761 // Weapons & suppressors particle effects
7766 static int m_LastRegisteredWeaponID = 0;
7767
7768 // Overheating effects
7770 float m_OverheatingShots;
7771 ref Timer m_CheckOverheating;
7772 int m_ShotsToStartOverheating = 0; // After these many shots, the overheating effect begins
7773 int m_MaxOverheatingValue = 0; // Limits the number of shots that will be tracked
7774 float m_OverheatingDecayInterval = 1; // Timer's interval for decrementing overheat effect's lifespan
7775 ref array <ref OverheatingParticle> m_OverheatingParticles;
7776
7778 protected bool m_HideSelectionsBySlot;
7779
7780 // Admin Log
7781 PluginAdminLog m_AdminLog;
7782
7783 // misc
7784 ref Timer m_PhysDropTimer;
7785
7786 // Attachment Locking variables
7787 ref array<int> m_CompatibleLocks;
7788 protected int m_LockType;
7789 protected ref EffectSound m_LockingSound;
7790 protected string m_LockSoundSet;
7791
7792 // ItemSoundHandler
7793 protected const int ITEM_SOUNDS_MAX = 63; // optimize network synch
7794 protected int m_SoundSyncPlay; // id for sound to play
7795 protected int m_SoundSyncStop; // id for sound to stop
7797
7798 //temperature
7799 private float m_TemperaturePerQuantityWeight;
7800
7801 // -------------------------------------------------------------------------
7802 void ItemBase()
7803 {
7804 SetEventMask(EntityEvent.INIT); // Enable EOnInit event
7808
7809 if (!GetGame().IsDedicatedServer())
7810 {
7811 if (HasMuzzle())
7812 {
7814
7816 {
7818 }
7819 }
7820
7822 m_ActionsInitialize = false;
7823 }
7824
7825 m_OldLocation = null;
7826
7827 if (GetGame().IsServer())
7828 {
7829 m_AdminLog = PluginAdminLog.Cast(GetPlugin(PluginAdminLog));
7830 }
7831
7832 if (ConfigIsExisting("headSelectionsToHide"))
7833 {
7835 ConfigGetTextArray("headSelectionsToHide",m_HeadHidingSelections);
7836 }
7837
7838 m_HideSelectionsBySlot = false;
7839 if (ConfigIsExisting("hideSelectionsByinventorySlot"))
7840 {
7841 m_HideSelectionsBySlot = ConfigGetBool("hideSelectionsByinventorySlot");
7842 }
7843
7844 m_QuickBarBonus = Math.Max(0, ConfigGetInt("quickBarBonus"));
7845
7846 m_IsResultOfSplit = false;
7847
7849 }
7850
7851 override void InitItemVariables()
7852 {
7853 super.InitItemVariables();
7854
7855 m_VarQuantityInit = ConfigGetInt("varQuantityInit");
7856 m_VarQuantity = m_VarQuantityInit;//should be by the CE, this is just a precaution
7857 m_VarQuantityMin = ConfigGetInt("varQuantityMin");
7858 m_VarQuantityMax = ConfigGetInt("varQuantityMax");
7859 m_VarStackMax = ConfigGetFloat("varStackMax");
7860 m_Count = ConfigGetInt("count");
7861
7862 m_CanShowQuantity = ConfigGetBool("quantityShow");
7863 m_HasQuantityBar = ConfigGetBool("quantityBar");
7864
7865 m_CleannessInit = ConfigGetInt("varCleannessInit");
7867 m_CleannessMin = ConfigGetInt("varCleannessMin");
7868 m_CleannessMax = ConfigGetInt("varCleannessMax");
7869
7870 m_WantPlayImpactSound = false;
7871 m_ImpactSpeed = 0.0;
7872
7873 m_VarWetInit = ConfigGetFloat("varWetInit");
7875 m_VarWetMin = ConfigGetFloat("varWetMin");
7876 m_VarWetMax = ConfigGetFloat("varWetMax");
7877
7878 m_LiquidContainerMask = ConfigGetInt("liquidContainerType");
7879 if (IsLiquidContainer() && GetQuantity() != 0)
7881 m_IsBeingPlaced = false;
7882 m_IsHologram = false;
7883 m_IsTakeable = true;
7884 m_CanBeMovedOverride = false;
7888 m_CanBeDigged = ConfigGetBool("canBeDigged");
7889
7890 m_CompatibleLocks = new array<int>();
7891 ConfigGetIntArray("compatibleLocks", m_CompatibleLocks);
7892 m_LockType = ConfigGetInt("lockType");
7893
7894 //Define if item can be split and set ability to be combined accordingly
7895 m_CanThisBeSplit = false;
7896 can_this_be_combined = false;
7897 if (ConfigIsExisting("canBeSplit"))
7898 {
7899 can_this_be_combined = ConfigGetBool("canBeSplit");
7901 }
7902
7903 m_ItemBehaviour = -1;
7904 if (ConfigIsExisting("itemBehaviour"))
7905 m_ItemBehaviour = ConfigGetInt("itemBehaviour");
7906
7907 //RegisterNetSyncVariableInt("m_VariablesMask");
7908 if (HasQuantity()) RegisterNetSyncVariableFloat("m_VarQuantity", GetQuantityMin(), m_VarQuantityMax);
7909 RegisterNetSyncVariableFloat("m_VarWet", GetWetMin(), GetWetMax(), 2);
7910 RegisterNetSyncVariableInt("m_VarLiquidType");
7911 RegisterNetSyncVariableInt("m_Cleanness",0,1);
7912
7913 RegisterNetSyncVariableBoolSignal("m_WantPlayImpactSound");
7914 RegisterNetSyncVariableFloat("m_ImpactSpeed");
7915 RegisterNetSyncVariableInt("m_ImpactSoundSurfaceHash");
7916
7917 RegisterNetSyncVariableInt("m_ColorComponentR", 0, 255);
7918 RegisterNetSyncVariableInt("m_ColorComponentG", 0, 255);
7919 RegisterNetSyncVariableInt("m_ColorComponentB", 0, 255);
7920 RegisterNetSyncVariableInt("m_ColorComponentA", 0, 255);
7921
7922 RegisterNetSyncVariableBool("m_IsBeingPlaced");
7923 RegisterNetSyncVariableBool("m_IsTakeable");
7924 RegisterNetSyncVariableBool("m_IsHologram");
7925
7926 InitItemSounds();
7928 {
7929 RegisterNetSyncVariableInt("m_SoundSyncPlay", 0, ITEM_SOUNDS_MAX);
7930 RegisterNetSyncVariableInt("m_SoundSyncStop", 0, ITEM_SOUNDS_MAX);
7931 }
7932
7933 m_LockSoundSet = ConfigGetString("lockSoundSet");
7934
7936 if (ConfigIsExisting("temperaturePerQuantityWeight"))
7937 m_TemperaturePerQuantityWeight = ConfigGetFloat("temperaturePerQuantityWeight");
7938
7939 }
7940
7941 override int GetQuickBarBonus()
7942 {
7943 return m_QuickBarBonus;
7944 }
7945
7946 void InitializeActions()
7947 {
7949 if (!m_InputActionMap)
7950 {
7952 m_InputActionMap = iam;
7953 SetActions();
7955 }
7956 }
7957
7958 override void GetActions(typename action_input_type, out array<ActionBase_Basic> actions)
7959 {
7961 {
7962 m_ActionsInitialize = true;
7964 }
7965
7966 actions = m_InputActionMap.Get(action_input_type);
7967 }
7968
7969 void SetActions()
7970 {
7971 AddAction(ActionTakeItem);
7972 AddAction(ActionTakeItemToHands);
7973 AddAction(ActionWorldCraft);
7975 AddAction(ActionAttachWithSwitch);
7976 }
7977
7978 void SetActionAnimOverrides(); // Override action animation for specific item
7979
7980 void AddAction(typename actionName)
7981 {
7982 ActionBase action = ActionManagerBase.GetAction(actionName);
7983
7984 if (!action)
7985 {
7986 Debug.LogError("Action " + actionName + " dosn't exist!");
7987 return;
7988 }
7989
7990 typename ai = action.GetInputType();
7991 if (!ai)
7992 {
7993 m_ActionsInitialize = false;
7994 return;
7995 }
7996
7997 array<ActionBase_Basic> action_array = m_InputActionMap.Get(ai);
7998 if (!action_array)
7999 {
8000 action_array = new array<ActionBase_Basic>;
8001 m_InputActionMap.Insert(ai, action_array);
8002 }
8003 if (LogManager.IsActionLogEnable())
8004 {
8005 Debug.ActionLog(action.ToString() + " -> " + ai, this.ToString() , "n/a", "Add action");
8006 }
8007
8008 if (action_array.Find(action) != -1)
8009 {
8010 Debug.Log("Action " + action.Type() + " already added to " + this + ", skipping!");
8011 }
8012 else
8013 {
8014 action_array.Insert(action);
8015 }
8016 }
8017
8018 void RemoveAction(typename actionName)
8019 {
8020 PlayerBase player = PlayerBase.Cast(GetGame().GetPlayer());
8021 ActionBase action = player.GetActionManager().GetAction(actionName);
8022 typename ai = action.GetInputType();
8023 array<ActionBase_Basic> action_array = m_InputActionMap.Get(ai);
8024
8025 if (action_array)
8026 {
8027 action_array.RemoveItem(action);
8028 }
8029 }
8030
8031 // Allows override of default action command per item, defined in the SetActionAnimOverrides() of the item's class
8032 // Set -1 for params which should stay in default state
8033 void OverrideActionAnimation(typename action, int commandUID, int stanceMask = -1, int commandUIDProne = -1)
8034 {
8035 ActionOverrideData overrideData = new ActionOverrideData();
8036 overrideData.m_CommandUID = commandUID;
8037 overrideData.m_CommandUIDProne = commandUIDProne;
8038 overrideData.m_StanceMask = stanceMask;
8039
8040 TActionAnimOverrideMap actionMap = m_ItemActionOverrides.Get(action);
8041 if (!actionMap) // create new map of action > overidables map
8042 {
8043 actionMap = new TActionAnimOverrideMap();
8044 m_ItemActionOverrides.Insert(action, actionMap);
8045 }
8046
8047 actionMap.Insert(this.Type(), overrideData); // insert item -> overrides
8048
8049 }
8050
8051 void OnItemInHandsPlayerSwimStart(PlayerBase player);
8052
8053 ScriptedLightBase GetLight();
8054
8055 // Loads muzzle flash particle configuration from config and saves it to a map for faster access
8056 void LoadParticleConfigOnFire(int id)
8057 {
8058 if (!m_OnFireEffect)
8060
8063
8064 string config_to_search = "CfgVehicles";
8065 string muzzle_owner_config;
8066
8067 if (!m_OnFireEffect.Contains(id))
8068 {
8069 if (IsInherited(Weapon))
8070 config_to_search = "CfgWeapons";
8071
8072 muzzle_owner_config = config_to_search + " " + GetType() + " ";
8073
8074 string config_OnFire_class = muzzle_owner_config + "Particles " + "OnFire ";
8075
8076 int config_OnFire_subclass_count = GetGame().ConfigGetChildrenCount(config_OnFire_class);
8077
8078 if (config_OnFire_subclass_count > 0)
8079 {
8080 array<ref WeaponParticlesOnFire> WPOF_array = new array<ref WeaponParticlesOnFire>;
8081
8082 for (int i = 0; i < config_OnFire_subclass_count; i++)
8083 {
8084 string particle_class = "";
8085 GetGame().ConfigGetChildName(config_OnFire_class, i, particle_class);
8086 string config_OnFire_entry = config_OnFire_class + particle_class;
8087 WeaponParticlesOnFire WPOF = new WeaponParticlesOnFire(this, config_OnFire_entry);
8088 WPOF_array.Insert(WPOF);
8089 }
8090
8091
8092 m_OnFireEffect.Insert(id, WPOF_array);
8093 }
8094 }
8095
8096 if (!m_OnBulletCasingEjectEffect.Contains(id))
8097 {
8098 config_to_search = "CfgWeapons"; // Bullet Eject efect is supported on weapons only.
8099 muzzle_owner_config = config_to_search + " " + GetType() + " ";
8100
8101 string config_OnBulletCasingEject_class = muzzle_owner_config + "Particles " + "OnBulletCasingEject ";
8102
8103 int config_OnBulletCasingEject_count = GetGame().ConfigGetChildrenCount(config_OnBulletCasingEject_class);
8104
8105 if (config_OnBulletCasingEject_count > 0 && IsInherited(Weapon))
8106 {
8107 array<ref WeaponParticlesOnBulletCasingEject> WPOBE_array = new array<ref WeaponParticlesOnBulletCasingEject>;
8108
8109 for (i = 0; i < config_OnBulletCasingEject_count; i++)
8110 {
8111 string particle_class2 = "";
8112 GetGame().ConfigGetChildName(config_OnBulletCasingEject_class, i, particle_class2);
8113 string config_OnBulletCasingEject_entry = config_OnBulletCasingEject_class + particle_class2;
8114 WeaponParticlesOnBulletCasingEject WPOBE = new WeaponParticlesOnBulletCasingEject(this, config_OnBulletCasingEject_entry);
8115 WPOBE_array.Insert(WPOBE);
8116 }
8117
8118
8119 m_OnBulletCasingEjectEffect.Insert(id, WPOBE_array);
8120 }
8121 }
8122 }
8123
8124 // Loads muzzle flash particle configuration from config and saves it to a map for faster access
8126 {
8129
8130 if (!m_OnOverheatingEffect.Contains(id))
8131 {
8132 string config_to_search = "CfgVehicles";
8133
8134 if (IsInherited(Weapon))
8135 config_to_search = "CfgWeapons";
8136
8137 string muzzle_owner_config = config_to_search + " " + GetType() + " ";
8138 string config_OnOverheating_class = muzzle_owner_config + "Particles " + "OnOverheating ";
8139
8140 if (GetGame().ConfigIsExisting(config_OnOverheating_class))
8141 {
8142
8143 m_ShotsToStartOverheating = GetGame().ConfigGetFloat(config_OnOverheating_class + "shotsToStartOverheating");
8144
8146 {
8147 m_ShotsToStartOverheating = -1; // This prevents futher readings from config for future creations of this item
8148 string error = "Error reading config " + GetType() + ">Particles>OnOverheating - Parameter shotsToStartOverheating is configured wrong or is missing! Its value must be 1 or higher!";
8149 Error(error);
8150 return;
8151 }
8152
8153 m_OverheatingDecayInterval = GetGame().ConfigGetFloat(config_OnOverheating_class + "overheatingDecayInterval");
8154 m_MaxOverheatingValue = GetGame().ConfigGetFloat(config_OnOverheating_class + "maxOverheatingValue");
8155
8156
8157
8158 int config_OnOverheating_subclass_count = GetGame().ConfigGetChildrenCount(config_OnOverheating_class);
8159 array<ref WeaponParticlesOnOverheating> WPOOH_array = new array<ref WeaponParticlesOnOverheating>;
8160
8161 for (int i = 0; i < config_OnOverheating_subclass_count; i++)
8162 {
8163 string particle_class = "";
8164 GetGame().ConfigGetChildName(config_OnOverheating_class, i, particle_class);
8165 string config_OnOverheating_entry = config_OnOverheating_class + particle_class;
8166 int entry_type = GetGame().ConfigGetType(config_OnOverheating_entry);
8167
8168 if (entry_type == CT_CLASS)
8169 {
8170 WeaponParticlesOnOverheating WPOF = new WeaponParticlesOnOverheating(this, config_OnOverheating_entry);
8171 WPOOH_array.Insert(WPOF);
8172 }
8173 }
8174
8175
8176 m_OnOverheatingEffect.Insert(id, WPOOH_array);
8177 }
8178 }
8179 }
8180
8181 float GetOverheatingValue()
8182 {
8183 return m_OverheatingShots;
8184 }
8185
8186 void IncreaseOverheating(ItemBase weapon, string ammoType, ItemBase muzzle_owner, ItemBase suppressor, string config_to_search)
8187 {
8188 if (m_MaxOverheatingValue > 0)
8189 {
8191
8192 if (!m_CheckOverheating)
8194
8196 m_CheckOverheating.Run(m_OverheatingDecayInterval, this, "OnOverheatingDecay");
8197
8198 CheckOverheating(weapon, ammoType, muzzle_owner, suppressor, config_to_search);
8199 }
8200 }
8201
8202 void CheckOverheating(ItemBase weapon = null, string ammoType = "", ItemBase muzzle_owner = null, ItemBase suppressor = null, string config_to_search = "")
8203 {
8205 UpdateOverheating(weapon, ammoType, muzzle_owner, suppressor, config_to_search);
8206
8208 StartOverheating(weapon, ammoType, muzzle_owner, suppressor, config_to_search);
8209
8211 StopOverheating(weapon, ammoType, muzzle_owner, suppressor, config_to_search);
8212
8214 {
8216 }
8217 }
8218
8220 {
8222 }
8223
8224 void OnOverheatingDecay()
8225 {
8226 if (m_MaxOverheatingValue > 0)
8227 m_OverheatingShots -= 1 + m_OverheatingShots / m_MaxOverheatingValue; // The hotter a barrel is, the faster it needs to cool down.
8228 else
8230
8231 if (m_OverheatingShots <= 0)
8232 {
8235 }
8236 else
8237 {
8238 if (!m_CheckOverheating)
8240
8242 m_CheckOverheating.Run(m_OverheatingDecayInterval, this, "OnOverheatingDecay");
8243 }
8244
8245 CheckOverheating(this, "", this);
8246 }
8247
8248 void StartOverheating(ItemBase weapon = null, string ammoType = "", ItemBase muzzle_owner = null, ItemBase suppressor = null, string config_to_search = "")
8249 {
8251 ItemBase.PlayOverheatingParticles(this, ammoType, this, suppressor, "CfgWeapons");
8252 }
8253
8254 void UpdateOverheating(ItemBase weapon = null, string ammoType = "", ItemBase muzzle_owner = null, ItemBase suppressor = null, string config_to_search = "")
8255 {
8257 ItemBase.UpdateOverheatingParticles(this, ammoType, this, suppressor, "CfgWeapons");
8259 }
8260
8261 void StopOverheating(ItemBase weapon = null, string ammoType = "", ItemBase muzzle_owner = null, ItemBase suppressor = null, string config_to_search = "")
8262 {
8264 ItemBase.StopOverheatingParticles(weapon, ammoType, muzzle_owner, suppressor, config_to_search);
8265 }
8266
8267 void RegisterOverheatingParticle(Particle p, float min_heat_coef, float max_heat_coef, int particle_id, Object parent, vector local_pos, vector local_ori)
8268 {
8270 m_OverheatingParticles = new array<ref OverheatingParticle>;
8271
8272 OverheatingParticle OP = new OverheatingParticle();
8273 OP.RegisterParticle(p);
8274 OP.SetOverheatingLimitMin(min_heat_coef);
8275 OP.SetOverheatingLimitMax(max_heat_coef);
8276 OP.SetParticleParams(particle_id, parent, local_pos, local_ori);
8277
8278 m_OverheatingParticles.Insert(OP);
8279 }
8280
8281 float GetOverheatingCoef()
8282 {
8283 if (m_MaxOverheatingValue > 0)
8285
8286 return -1;
8287 }
8288
8290 {
8292 {
8293 float overheat_coef = GetOverheatingCoef();
8294 int count = m_OverheatingParticles.Count();
8295
8296 for (int i = count; i > 0; --i)
8297 {
8298 int id = i - 1;
8299 OverheatingParticle OP = m_OverheatingParticles.Get(id);
8300 Particle p = OP.GetParticle();
8301
8302 float overheat_min = OP.GetOverheatingLimitMin();
8303 float overheat_max = OP.GetOverheatingLimitMax();
8304
8305 if (overheat_coef < overheat_min && overheat_coef >= overheat_max)
8306 {
8307 if (p)
8308 {
8309 p.Stop();
8310 OP.RegisterParticle(null);
8311 }
8312 }
8313 }
8314 }
8315 }
8316
8318 {
8320 {
8321 for (int i = m_OverheatingParticles.Count(); i > 0; i--)
8322 {
8323 int id = i - 1;
8324 OverheatingParticle OP = m_OverheatingParticles.Get(id);
8325
8326 if (OP)
8327 {
8328 Particle p = OP.GetParticle();
8329
8330 if (p)
8331 {
8332 p.Stop();
8333 }
8334
8335 delete OP;
8336 }
8337 }
8338
8339 m_OverheatingParticles.Clear();
8341 }
8342 }
8343
8345 float GetInfectionChance(int system = 0, Param param = null)
8346 {
8347 return 0.0;
8348 }
8349
8350
8351 float GetDisinfectQuantity(int system = 0, Param param1 = null)
8352 {
8353 return 250;//default value
8354 }
8355
8356 float GetFilterDamageRatio()
8357 {
8358 return 0;
8359 }
8360
8362 bool HasMuzzle()
8363 {
8364 if (IsInherited(Weapon) || IsInherited(SuppressorBase))
8365 return true;
8366
8367 return false;
8368 }
8369
8371 int GetMuzzleID()
8372 {
8373 if (!m_WeaponTypeToID)
8375
8376 if (m_WeaponTypeToID.Contains(GetType()))
8377 {
8378 return m_WeaponTypeToID.Get(GetType());
8379 }
8380 else
8381 {
8382 // Register new weapon ID
8384 }
8385
8387 }
8388
8395 {
8396 return -1;
8397 }
8398
8399
8400
8401 // -------------------------------------------------------------------------
8402 void ~ItemBase()
8403 {
8404 if (GetGame() && GetGame().GetPlayer() && (!GetGame().IsDedicatedServer()))
8405 {
8406 PlayerBase player = PlayerBase.Cast(GetGame().GetPlayer());
8407 int r_index = player.GetHumanInventory().FindUserReservedLocationIndex(this);
8408
8409 if (r_index >= 0)
8410 {
8411 InventoryLocation r_il = new InventoryLocation;
8412 player.GetHumanInventory().GetUserReservedLocation(r_index,r_il);
8413
8414 player.GetHumanInventory().ClearUserReservedLocationAtIndex(r_index);
8415 int r_type = r_il.GetType();
8416 if (r_type == InventoryLocationType.CARGO || r_type == InventoryLocationType.PROXYCARGO)
8417 {
8418 r_il.GetParent().GetOnReleaseLock().Invoke(this);
8419 }
8420 else if (r_type == InventoryLocationType.ATTACHMENT)
8421 {
8422 r_il.GetParent().GetOnAttachmentReleaseLock().Invoke(this, r_il.GetSlot());
8423 }
8424
8425 }
8426
8427 player.GetHumanInventory().ClearUserReservedLocation(this);
8428 }
8429
8430 if (m_LockingSound)
8431 SEffectManager.DestroyEffect(m_LockingSound);
8432 }
8433
8434
8435
8436 // -------------------------------------------------------------------------
8437 static int GetDebugActionsMask()
8438 {
8439 return ItemBase.m_DebugActionsMask;
8440 }
8441
8442 static bool HasDebugActionsMask(int mask)
8443 {
8444 return ItemBase.m_DebugActionsMask & mask;
8445 }
8446
8447 static void SetDebugActionsMask(int mask)
8448 {
8449 ItemBase.m_DebugActionsMask = mask;
8450 }
8451
8452 static void AddDebugActionsMask(int mask)
8453 {
8454 ItemBase.m_DebugActionsMask |= mask;
8455 }
8456
8457 static void RemoveDebugActionsMask(int mask)
8458 {
8459 ItemBase.m_DebugActionsMask &= ~mask;
8460 }
8461
8462 static void ToggleDebugActionsMask(int mask)
8463 {
8464 if (HasDebugActionsMask(mask))
8465 {
8467 }
8468 else
8469 {
8470 AddDebugActionsMask(mask);
8471 }
8472 }
8473
8474 // -------------------------------------------------------------------------
8475 void SetCEBasedQuantity()
8476 {
8477 if (GetEconomyProfile())
8478 {
8479 float q_max = GetEconomyProfile().GetQuantityMax();
8480 if (q_max > 0)
8481 {
8482 float q_min = GetEconomyProfile().GetQuantityMin();
8483 float quantity_randomized = Math.RandomFloatInclusive(q_min, q_max);
8484
8485 if (HasComponent(COMP_TYPE_ENERGY_MANAGER))//more direct access for speed
8486 {
8487 ComponentEnergyManager comp = GetCompEM();
8488 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
8489 {
8490 comp.SetEnergy0To1(quantity_randomized);
8491 }
8492 }
8493 else if (HasQuantity())
8494 {
8495 SetQuantityNormalized(quantity_randomized, false);
8496 //PrintString("<==> Normalized quantity for item: "+ GetType()+", qmin:"+q_min.ToString()+"; qmax:"+q_max.ToString()+";quantity:" +quantity_randomized.ToString());
8497 }
8498
8499 }
8500 }
8501 }
8502
8504 void LockToParent()
8505 {
8506 EntityAI parent = GetHierarchyParent();
8507
8508 if (parent)
8509 {
8510 InventoryLocation inventory_location_to_lock = new InventoryLocation;
8511 GetInventory().GetCurrentInventoryLocation(inventory_location_to_lock);
8512 parent.GetInventory().SetSlotLock(inventory_location_to_lock.GetSlot(), true);
8513 }
8514 }
8515
8517 void UnlockFromParent()
8518 {
8519 EntityAI parent = GetHierarchyParent();
8520
8521 if (parent)
8522 {
8523 InventoryLocation inventory_location_to_unlock = new InventoryLocation;
8524 GetInventory().GetCurrentInventoryLocation(inventory_location_to_unlock);
8525 parent.GetInventory().SetSlotLock(inventory_location_to_unlock.GetSlot(), false);
8526 }
8527 }
8528
8529 override void CombineItemsClient(EntityAI entity2, bool use_stack_max = true)
8530 {
8531 /*
8532 ref Param1<EntityAI> item = new Param1<EntityAI>(entity2);
8533 RPCSingleParam(ERPCs.RPC_ITEM_COMBINE, item, GetGame().GetPlayer());
8534 */
8535 ItemBase item2 = ItemBase.Cast(entity2);
8536
8537 if (GetGame().IsClient())
8538 {
8539 if (ScriptInputUserData.CanStoreInputUserData())
8540 {
8541 ScriptInputUserData ctx = new ScriptInputUserData;
8543 ctx.Write(-1);
8544 ItemBase i1 = this; // @NOTE: workaround for correct serialization
8545 ctx.Write(i1);
8546 ctx.Write(item2);
8547 ctx.Write(use_stack_max);
8548 ctx.Write(-1);
8549 ctx.Send();
8550
8551 if (IsCombineAll(item2, use_stack_max))
8552 {
8553 GetGame().GetPlayer().GetInventory().AddInventoryReservationEx(item2,null,GameInventory.c_InventoryReservationTimeoutShortMS);
8554 }
8555 }
8556 }
8557 else if (!GetGame().IsMultiplayer())
8558 {
8559 CombineItems(item2, use_stack_max);
8560 }
8561 }
8562
8563 bool IsLiquidPresent()
8564 {
8565 return (GetLiquidType() != 0 && HasQuantity());
8566 }
8567
8568 bool IsLiquidContainer()
8569 {
8570 return m_LiquidContainerMask != 0;
8571 }
8572
8574 {
8575 return m_LiquidContainerMask;
8576 }
8577
8578 bool IsBloodContainer()
8579 {
8580 //m_LiquidContainerMask & GROUP_LIQUID_BLOOD ???
8581 return false;
8582 }
8583
8584 bool IsNVG()
8585 {
8586 return false;
8587 }
8588
8591 bool IsExplosive()
8592 {
8593 return false;
8594 }
8595
8597 {
8598 return "";
8599 }
8600
8602
8603 bool IsLightSource()
8604 {
8605 return false;
8606 }
8607
8609 {
8610 return true;
8611 }
8612
8613 //--- ACTION CONDITIONS
8614 //direction
8615 bool IsFacingPlayer(PlayerBase player, string selection)
8616 {
8617 return true;
8618 }
8619
8620 bool IsPlayerInside(PlayerBase player, string selection)
8621 {
8622 return true;
8623 }
8624
8625 override bool CanObstruct()
8626 {
8627 PlayerBase player = PlayerBase.Cast(g_Game.GetPlayer());
8628 return !player || !IsPlayerInside(player, "");
8629 }
8630
8631 override bool IsBeingPlaced()
8632 {
8633 return m_IsBeingPlaced;
8634 }
8635
8636 void SetIsBeingPlaced(bool is_being_placed)
8637 {
8638 m_IsBeingPlaced = is_being_placed;
8639 if (!is_being_placed)
8641 SetSynchDirty();
8642 }
8643
8644 //server-side
8645 void OnEndPlacement() {}
8646
8647 override bool IsHologram()
8648 {
8649 return m_IsHologram;
8650 }
8651
8652 bool CanBeDigged()
8653 {
8654 return m_CanBeDigged;
8655 }
8656
8658 {
8659 return 1;
8660 }
8661
8662 bool CanMakeGardenplot()
8663 {
8664 return false;
8665 }
8666
8667 void SetIsHologram(bool is_hologram)
8668 {
8669 m_IsHologram = is_hologram;
8670 SetSynchDirty();
8671 }
8672 /*
8673 protected float GetNutritionalEnergy()
8674 {
8675 Edible_Base edible = Edible_Base.Cast(this);
8676 return edible.GetFoodEnergy();
8677 }
8678
8679 protected float GetNutritionalWaterContent()
8680 {
8681 Edible_Base edible = Edible_Base.Cast(this);
8682 return edible.GetFoodWater();
8683 }
8684
8685 protected float GetNutritionalIndex()
8686 {
8687 Edible_Base edible = Edible_Base.Cast(this);
8688 return edible.GetFoodNutritionalIndex();
8689 }
8690
8691 protected float GetNutritionalFullnessIndex()
8692 {
8693 Edible_Base edible = Edible_Base.Cast(this);
8694 return edible.GetFoodTotalVolume();
8695 }
8696
8697 protected float GetNutritionalToxicity()
8698 {
8699 Edible_Base edible = Edible_Base.Cast(this);
8700 return edible.GetFoodToxicity();
8701
8702 }
8703 */
8704
8705
8706 // -------------------------------------------------------------------------
8707 override void OnMovedInsideCargo(EntityAI container)
8708 {
8709 super.OnMovedInsideCargo(container);
8710
8711 MiscGameplayFunctions.RemoveAllAttachedChildrenByTypename(this, {Bolt_Base});
8712 }
8713
8714 override void EEItemLocationChanged(notnull InventoryLocation oldLoc, notnull InventoryLocation newLoc)
8715 {
8716 super.EEItemLocationChanged(oldLoc,newLoc);
8717
8718 PlayerBase new_player = null;
8719 PlayerBase old_player = null;
8720
8721 if (newLoc.GetParent())
8722 new_player = PlayerBase.Cast(newLoc.GetParent().GetHierarchyRootPlayer());
8723
8724 if (oldLoc.GetParent())
8725 old_player = PlayerBase.Cast(oldLoc.GetParent().GetHierarchyRootPlayer());
8726
8727 if (old_player && oldLoc.GetType() == InventoryLocationType.HANDS)
8728 {
8729 int r_index = old_player.GetHumanInventory().FindUserReservedLocationIndex(this);
8730
8731 if (r_index >= 0)
8732 {
8733 InventoryLocation r_il = new InventoryLocation;
8734 old_player.GetHumanInventory().GetUserReservedLocation(r_index,r_il);
8735
8736 old_player.GetHumanInventory().ClearUserReservedLocationAtIndex(r_index);
8737 int r_type = r_il.GetType();
8738 if (r_type == InventoryLocationType.CARGO || r_type == InventoryLocationType.PROXYCARGO)
8739 {
8740 r_il.GetParent().GetOnReleaseLock().Invoke(this);
8741 }
8742 else if (r_type == InventoryLocationType.ATTACHMENT)
8743 {
8744 r_il.GetParent().GetOnAttachmentReleaseLock().Invoke(this, r_il.GetSlot());
8745 }
8746
8747 }
8748 }
8749
8750 if (newLoc.GetType() == InventoryLocationType.HANDS)
8751 {
8752 if (new_player)
8753 new_player.ForceStandUpForHeavyItems(newLoc.GetItem());
8754
8755 if (new_player == old_player)
8756 {
8757
8758 if (oldLoc.GetParent() && new_player.GetHumanInventory().LocationGetEntity(oldLoc) == NULL)
8759 {
8760 if (oldLoc.GetType() == InventoryLocationType.CARGO)
8761 {
8762 if (oldLoc.GetParent().GetInventory().TestAddEntityInCargoExLoc(oldLoc, false, false, false, true, false, false))
8763 {
8764 new_player.GetHumanInventory().SetUserReservedLocation(this,oldLoc);
8765 }
8766 }
8767 else
8768 {
8769 new_player.GetHumanInventory().SetUserReservedLocation(this,oldLoc);
8770 }
8771 }
8772
8773 if (new_player.GetHumanInventory().FindUserReservedLocationIndex(this) >= 0)
8774 {
8775 int type = oldLoc.GetType();
8776 if (type == InventoryLocationType.CARGO || type == InventoryLocationType.PROXYCARGO)
8777 {
8778 oldLoc.GetParent().GetOnSetLock().Invoke(this);
8779 }
8780 else if (type == InventoryLocationType.ATTACHMENT)
8781 {
8782 oldLoc.GetParent().GetOnAttachmentSetLock().Invoke(this, oldLoc.GetSlot());
8783 }
8784 }
8785 if (!m_OldLocation)
8786 {
8787 m_OldLocation = new InventoryLocation;
8788 }
8789 m_OldLocation.Copy(oldLoc);
8790 }
8791 else
8792 {
8793 if (m_OldLocation)
8794 {
8795 m_OldLocation.Reset();
8796 }
8797 }
8798
8800 }
8801 else
8802 {
8803 if (new_player)
8804 {
8805 int res_index = new_player.GetHumanInventory().FindCollidingUserReservedLocationIndex(this, newLoc);
8806 if (res_index >= 0)
8807 {
8808 InventoryLocation il = new InventoryLocation;
8809 new_player.GetHumanInventory().GetUserReservedLocation(res_index,il);
8810 ItemBase it = ItemBase.Cast(il.GetItem());
8811 new_player.GetHumanInventory().ClearUserReservedLocationAtIndex(res_index);
8812 int rel_type = il.GetType();
8813 if (rel_type == InventoryLocationType.CARGO || rel_type == InventoryLocationType.PROXYCARGO)
8814 {
8815 il.GetParent().GetOnReleaseLock().Invoke(it);
8816 }
8817 else if (rel_type == InventoryLocationType.ATTACHMENT)
8818 {
8819 il.GetParent().GetOnAttachmentReleaseLock().Invoke(it, il.GetSlot());
8820 }
8821 //it.GetOnReleaseLock().Invoke(it);
8822 }
8823 }
8824 else if (old_player && newLoc.GetType() == InventoryLocationType.GROUND && m_ThrowItemOnDrop)
8825 {
8826 //ThrowPhysically(old_player, vector.Zero);
8827 m_ThrowItemOnDrop = false;
8828 }
8829
8830 if (m_OldLocation)
8831 {
8832 m_OldLocation.Reset();
8833 }
8834 }
8835 }
8836
8837 override void EOnContact(IEntity other, Contact extra)
8838 {
8840 {
8841 int liquidType = -1;
8842 float impactSpeed = ProcessImpactSoundEx(other, extra, m_ConfigWeight, m_ImpactSoundSurfaceHash, liquidType);
8843 if (impactSpeed > 0.0)
8844 {
8845 m_ImpactSpeed = impactSpeed;
8846 #ifndef SERVER
8847 PlayImpactSound(m_ConfigWeight, m_ImpactSpeed, m_ImpactSoundSurfaceHash);
8848 #else
8849 m_WantPlayImpactSound = true;
8850 SetSynchDirty();
8851 #endif
8852 m_CanPlayImpactSound = (liquidType == -1);// prevents further playing of the sound when the surface is a liquid type
8853 }
8854 }
8855
8856 #ifdef SERVER
8857 if (GetCompEM() && GetCompEM().IsPlugged())
8858 {
8859 if (GetCompEM().GetCordLength() < vector.Distance(GetPosition(), GetCompEM().GetEnergySource().GetPosition()))
8860 GetCompEM().UnplugThis();
8861 }
8862 #endif
8863 }
8864
8865 void RefreshPhysics();
8866
8867 override void OnCreatePhysics()
8868 {
8870 }
8871
8872 override void OnItemAttachmentSlotChanged(notnull InventoryLocation oldLoc, notnull InventoryLocation newLoc)
8873 {
8874
8875 }
8876 // -------------------------------------------------------------------------
8877 override void OnItemLocationChanged(EntityAI old_owner, EntityAI new_owner)
8878 {
8879 super.OnItemLocationChanged(old_owner, new_owner);
8880
8881 PlayerBase relatedPlayer = PlayerBase.Cast(old_owner);
8882 PlayerBase playerNew = PlayerBase.Cast(new_owner);
8883
8884 if (!relatedPlayer && playerNew)
8885 relatedPlayer = playerNew;
8886
8887 if (relatedPlayer && relatedPlayer.GetPerformedActionID() != -1)
8888 {
8889 ActionManagerBase actionMgr = relatedPlayer.GetActionManager();
8890 if (actionMgr)
8891 {
8892 ActionBase currentAction = actionMgr.GetRunningAction();
8893 if (currentAction)
8894 currentAction.OnItemLocationChanged(this);
8895 }
8896 }
8897
8898 Man ownerPlayerOld = null;
8899 Man ownerPlayerNew = null;
8900
8901 if (old_owner)
8902 {
8903 if (old_owner.IsMan())
8904 {
8905 ownerPlayerOld = Man.Cast(old_owner);
8906 }
8907 else
8908 {
8909 ownerPlayerOld = Man.Cast(old_owner.GetHierarchyRootPlayer());
8910 }
8911 }
8912 else
8913 {
8914 if (new_owner && IsElectricAppliance() && GetCompEM() && GetCompEM().IsPlugged())
8915 {
8916 ActionBase action = ActionManagerBase.GetAction(ActionRepositionPluggedItem);
8917
8918 if (!action || !playerNew || playerNew.GetPerformedActionID() != action.GetID())
8919 {
8920 GetCompEM().UnplugThis();
8921 }
8922 }
8923 }
8924
8925 if (new_owner)
8926 {
8927 if (new_owner.IsMan())
8928 {
8929 ownerPlayerNew = Man.Cast(new_owner);
8930 }
8931 else
8932 {
8933 ownerPlayerNew = Man.Cast(new_owner.GetHierarchyRootPlayer());
8934 }
8935 }
8936
8937 if (ownerPlayerOld != ownerPlayerNew)
8938 {
8939 if (ownerPlayerOld)
8940 {
8941 array<EntityAI> subItemsExit = new array<EntityAI>;
8942 GetInventory().EnumerateInventory(InventoryTraversalType.PREORDER,subItemsExit);
8943 for (int i = 0; i < subItemsExit.Count(); i++)
8944 {
8945 ItemBase itemExit = ItemBase.Cast(subItemsExit.Get(i));
8946 itemExit.OnInventoryExit(ownerPlayerOld);
8947 }
8948 }
8949
8950 if (ownerPlayerNew)
8951 {
8952 array<EntityAI> subItemsEnter = new array<EntityAI>;
8953 GetInventory().EnumerateInventory(InventoryTraversalType.PREORDER,subItemsEnter);
8954 for (int j = 0; j < subItemsEnter.Count(); j++)
8955 {
8956 ItemBase itemEnter = ItemBase.Cast(subItemsEnter.Get(j));
8957 itemEnter.OnInventoryEnter(ownerPlayerNew);
8958 }
8959 }
8960 }
8961 else if (ownerPlayerNew != null)
8962 {
8963 PlayerBase nplayer;
8964 if (PlayerBase.CastTo(nplayer, ownerPlayerNew))
8965 {
8966 array<EntityAI> subItemsUpdate = new array<EntityAI>;
8967 GetInventory().EnumerateInventory(InventoryTraversalType.PREORDER,subItemsUpdate);
8968 for (int k = 0; k < subItemsUpdate.Count(); k++)
8969 {
8970 ItemBase itemUpdate = ItemBase.Cast(subItemsUpdate.Get(k));
8971 itemUpdate.UpdateQuickbarShortcutVisibility(nplayer);
8972 }
8973 }
8974 }
8975
8976 if (old_owner)
8977 old_owner.OnChildItemRemoved(this);
8978 if (new_owner)
8979 new_owner.OnChildItemReceived(this);
8980 }
8981
8982 // -------------------------------------------------------------------------------
8983 override void EEDelete(EntityAI parent)
8984 {
8985 super.EEDelete(parent);
8986 PlayerBase player = PlayerBase.Cast(GetHierarchyRootPlayer());
8987 if (player)
8988 {
8989 OnInventoryExit(player);
8990
8991 if (player.IsAlive())
8992 {
8993 int r_index = player.GetHumanInventory().FindUserReservedLocationIndex(this);
8994 if (r_index >= 0)
8995 {
8996 InventoryLocation r_il = new InventoryLocation;
8997 player.GetHumanInventory().GetUserReservedLocation(r_index,r_il);
8998
8999 player.GetHumanInventory().ClearUserReservedLocationAtIndex(r_index);
9000 int r_type = r_il.GetType();
9001 if (r_type == InventoryLocationType.CARGO || r_type == InventoryLocationType.PROXYCARGO)
9002 {
9003 r_il.GetParent().GetOnReleaseLock().Invoke(this);
9004 }
9005 else if (r_type == InventoryLocationType.ATTACHMENT)
9006 {
9007 r_il.GetParent().GetOnAttachmentReleaseLock().Invoke(this, r_il.GetSlot());
9008 }
9009
9010 }
9011
9012 player.RemoveQuickBarEntityShortcut(this);
9013 }
9014 }
9015 }
9016 // -------------------------------------------------------------------------------
9017 override void EEKilled(Object killer)
9018 {
9019 super.EEKilled(killer);
9020
9022 if (killer && killer.IsFireplace() && CanExplodeInFire())
9023 {
9024 if (GetTemperature() >= GameConstants.ITEM_TEMPERATURE_TO_EXPLODE_MIN)
9025 {
9026 if (IsMagazine())
9027 {
9028 if (Magazine.Cast(this).GetAmmoCount() > 0)
9029 {
9030 ExplodeAmmo();
9031 }
9032 }
9033 else
9034 {
9035 Explode(DamageType.EXPLOSION);
9036 }
9037 }
9038 }
9039 }
9040
9041 override void OnWasAttached(EntityAI parent, int slot_id)
9042 {
9043 MiscGameplayFunctions.RemoveAllAttachedChildrenByTypename(this, {Bolt_Base});
9044
9045 super.OnWasAttached(parent, slot_id);
9046
9047 if (HasQuantity())
9048 UpdateNetSyncVariableFloat("m_VarQuantity", GetQuantityMin(), m_VarQuantityMax);
9049
9050 PlayAttachSound(InventorySlots.GetSlotName(slot_id));
9051 }
9052
9053 override void OnWasDetached(EntityAI parent, int slot_id)
9054 {
9055 super.OnWasDetached(parent, slot_id);
9056
9057 if (HasQuantity())
9058 UpdateNetSyncVariableFloat("m_VarQuantity", GetQuantityMin(), m_VarQuantityMax);
9059 }
9060
9061 override string ChangeIntoOnAttach(string slot)
9062 {
9063 int idx;
9064 TStringArray inventory_slots = new TStringArray;
9065 TStringArray attach_types = new TStringArray;
9066
9067 ConfigGetTextArray("ChangeInventorySlot",inventory_slots);
9068 if (inventory_slots.Count() < 1) //is string
9069 {
9070 inventory_slots.Insert(ConfigGetString("ChangeInventorySlot"));
9071 attach_types.Insert(ConfigGetString("ChangeIntoOnAttach"));
9072 }
9073 else //is array
9074 {
9075 ConfigGetTextArray("ChangeIntoOnAttach",attach_types);
9076 }
9077
9078 idx = inventory_slots.Find(slot);
9079 if (idx < 0)
9080 return "";
9081
9082 return attach_types.Get(idx);
9083 }
9084
9085 override string ChangeIntoOnDetach()
9086 {
9087 int idx = -1;
9088 string slot;
9089
9090 TStringArray inventory_slots = new TStringArray;
9091 TStringArray detach_types = new TStringArray;
9092
9093 this.ConfigGetTextArray("ChangeInventorySlot",inventory_slots);
9094 if (inventory_slots.Count() < 1) //is string
9095 {
9096 inventory_slots.Insert(this.ConfigGetString("ChangeInventorySlot"));
9097 detach_types.Insert(this.ConfigGetString("ChangeIntoOnDetach"));
9098 }
9099 else //is array
9100 {
9101 this.ConfigGetTextArray("ChangeIntoOnDetach",detach_types);
9102 if (detach_types.Count() < 1)
9103 detach_types.Insert(this.ConfigGetString("ChangeIntoOnDetach"));
9104 }
9105
9106 for (int i = 0; i < inventory_slots.Count(); i++)
9107 {
9108 slot = inventory_slots.Get(i);
9109 }
9110
9111 if (slot != "")
9112 {
9113 if (detach_types.Count() == 1)
9114 idx = 0;
9115 else
9116 idx = inventory_slots.Find(slot);
9117 }
9118 if (idx < 0)
9119 return "";
9120
9121 return detach_types.Get(idx);
9122 }
9123
9124 void ExplodeAmmo()
9125 {
9126 //timer
9127 ref Timer explode_timer = new Timer(CALL_CATEGORY_SYSTEM);
9128
9129 //min/max time
9130 float min_time = 1;
9131 float max_time = 3;
9132 float delay = Math.RandomFloat(min_time, max_time);
9133
9134 explode_timer.Run(delay, this, "DoAmmoExplosion");
9135 }
9136
9137 void DoAmmoExplosion()
9138 {
9139 Magazine magazine = Magazine.Cast(this);
9140 int pop_sounds_count = 6;
9141 string pop_sounds[ 6 ] = { "ammopops_1","ammopops_2","ammopops_3","ammopops_4","ammopops_5","ammopops_6" };
9142
9143 //play sound
9144 int sound_idx = Math.RandomInt(0, pop_sounds_count - 1);
9145 string sound_name = pop_sounds[ sound_idx ];
9146 GetGame().CreateSoundOnObject(this, sound_name, 20, false);
9147
9148 //remove ammo count
9149 magazine.ServerAddAmmoCount(-1);
9150
9151 //if condition then repeat -> ExplodeAmmo
9152 float min_temp_to_explode = 100; //min temperature for item to explode
9153
9154 if (magazine.GetAmmoCount() > 0 && GetTemperature() >= min_temp_to_explode) //TODO ? add check for parent -> fireplace
9155 {
9156 ExplodeAmmo();
9157 }
9158 }
9159
9160 // -------------------------------------------------------------------------------
9161 override void EEHitBy(TotalDamageResult damageResult, int damageType, EntityAI source, int component, string dmgZone, string ammo, vector modelPos, float speedCoef)
9162 {
9163 super.EEHitBy(damageResult, damageType, source, component, dmgZone, ammo, modelPos, speedCoef);
9164
9165 const int CHANCE_DAMAGE_CARGO = 4;
9166 const int CHANCE_DAMAGE_ATTACHMENT = 1;
9167 const int CHANCE_DAMAGE_NOTHING = 2;
9168
9169 if (IsClothing() || IsContainer() || IsItemTent())
9170 {
9171 float dmg = damageResult.GetDamage("","Health") * -0.5;
9172 int chances;
9173 int rnd;
9174
9175 if (GetInventory().GetCargo())
9176 {
9177 chances = CHANCE_DAMAGE_CARGO + CHANCE_DAMAGE_ATTACHMENT + CHANCE_DAMAGE_NOTHING;
9178 rnd = Math.RandomInt(0,chances);
9179
9180 if (rnd < CHANCE_DAMAGE_CARGO)
9181 {
9182 DamageItemInCargo(dmg);
9183 }
9184 else if (rnd < (chances - CHANCE_DAMAGE_NOTHING))
9185 {
9187 }
9188 }
9189 else
9190 {
9191 chances = CHANCE_DAMAGE_ATTACHMENT + CHANCE_DAMAGE_NOTHING;
9192 rnd = Math.RandomInt(0,chances);
9193
9194 if (rnd < CHANCE_DAMAGE_ATTACHMENT)
9195 {
9197 }
9198 }
9199 }
9200 }
9201
9202 bool DamageItemInCargo(float damage)
9203 {
9204 if (GetInventory().GetCargo())
9205 {
9206 int item_count = GetInventory().GetCargo().GetItemCount();
9207 if (item_count > 0)
9208 {
9209 int random_pick = Math.RandomInt(0, item_count);
9210 ItemBase item = ItemBase.Cast(GetInventory().GetCargo().GetItem(random_pick));
9211 if (!item.IsExplosive())
9212 {
9213 item.AddHealth("","",damage);
9214 return true;
9215 }
9216 }
9217 }
9218 return false;
9219 }
9220
9221 bool DamageItemAttachments(float damage)
9222 {
9223 int attachment_count = GetInventory().AttachmentCount();
9224 if (attachment_count > 0)
9225 {
9226 int random_pick = Math.RandomInt(0, attachment_count);
9227 ItemBase attachment = ItemBase.Cast(GetInventory().GetAttachmentFromIndex(random_pick));
9228 if (!attachment.IsExplosive())
9229 {
9230 attachment.AddHealth("","",damage);
9231 return true;
9232 }
9233 }
9234 return false;
9235 }
9236
9237 override bool IsSplitable()
9238 {
9239 return m_CanThisBeSplit;
9240 }
9241 //----------------
9242 override bool CanBeSplit()
9243 {
9244 if (IsSplitable() && (GetQuantity() > 1))
9245 return GetInventory().CanRemoveEntity();
9246
9247 return false;
9248 }
9249
9250 override void SplitIntoStackMaxClient(EntityAI destination_entity, int slot_id )
9251 {
9252 if (!CanBeSplit())
9253 return;
9254
9255 if (GetGame().IsClient())
9256 {
9257 if (ScriptInputUserData.CanStoreInputUserData())
9258 {
9259 ScriptInputUserData ctx = new ScriptInputUserData;
9261 ctx.Write(1);
9262 ItemBase i1 = this; // @NOTE: workaround for correct serialization
9263 ctx.Write(i1);
9264 ctx.Write(destination_entity);
9265 ctx.Write(true);
9266 ctx.Write(slot_id);
9267 ctx.Send();
9268 }
9269 }
9270 else if (!GetGame().IsMultiplayer())
9271 {
9272 SplitIntoStackMax(destination_entity, slot_id, PlayerBase.Cast(GetGame().GetPlayer()));
9273 }
9274 }
9275
9276 void SplitIntoStackMax(EntityAI destination_entity, int slot_id, PlayerBase player)
9277 {
9278 if (!CanBeSplit())
9279 return;
9280
9281 float split_quantity_new;
9282 ref ItemBase new_item;
9283 float quantity = GetQuantity();
9284 float stack_max = GetTargetQuantityMax(slot_id);
9285 InventoryLocation loc = new InventoryLocation;
9286
9287 if (destination_entity && slot_id != -1 && InventorySlots.IsSlotIdValid(slot_id))
9288 {
9289 if (stack_max <= GetQuantity())
9290 split_quantity_new = stack_max;
9291 else
9292 split_quantity_new = GetQuantity();
9293
9294 new_item = ItemBase.Cast(destination_entity.GetInventory().CreateAttachmentEx(this.GetType(), slot_id));
9295 if (new_item)
9296 {
9297 new_item.SetResultOfSplit(true);
9298 MiscGameplayFunctions.TransferItemProperties(this, new_item);
9299 AddQuantity(-split_quantity_new);
9300 new_item.SetQuantity(split_quantity_new);
9301 }
9302 }
9303 else if (destination_entity && slot_id == -1)
9304 {
9305 if (quantity > stack_max)
9306 split_quantity_new = stack_max;
9307 else
9308 split_quantity_new = quantity;
9309
9310 if (destination_entity.GetInventory().FindFreeLocationFor(this, FindInventoryLocationType.ANY, loc))
9311 {
9312 Object o = destination_entity.GetInventory().LocationCreateEntity(loc, GetType(), ECE_IN_INVENTORY, RF_DEFAULT);
9313 new_item = ItemBase.Cast(o);
9314 }
9315
9316 if (new_item)
9317 {
9318 new_item.SetResultOfSplit(true);
9319 MiscGameplayFunctions.TransferItemProperties(this, new_item);
9320 AddQuantity(-split_quantity_new);
9321 new_item.SetQuantity(split_quantity_new);
9322 }
9323 }
9324 else
9325 {
9326 if (stack_max != 0)
9327 {
9328 if (stack_max < GetQuantity())
9329 {
9330 split_quantity_new = GetQuantity() - stack_max;
9331 }
9332
9333 if (split_quantity_new == 0)
9334 {
9335 if (!GetGame().IsMultiplayer())
9336 player.PhysicalPredictiveDropItem(this);
9337 else
9338 player.ServerDropEntity(this);
9339 return;
9340 }
9341
9342 new_item = ItemBase.Cast(GetGame().CreateObjectEx(GetType(), player.GetWorldPosition(), ECE_PLACE_ON_SURFACE));
9343
9344 if (new_item)
9345 {
9346 new_item.SetResultOfSplit(true);
9347 MiscGameplayFunctions.TransferItemProperties(this, new_item);
9348 SetQuantity(split_quantity_new);
9349 new_item.SetQuantity(stack_max);
9350 new_item.PlaceOnSurface();
9351 }
9352 }
9353 }
9354 }
9355
9356 override void SplitIntoStackMaxEx(EntityAI destination_entity, int slot_id)
9357 {
9358 if (!CanBeSplit())
9359 return;
9360
9361 float split_quantity_new;
9362 ref ItemBase new_item;
9363 float quantity = GetQuantity();
9364 float stack_max = GetTargetQuantityMax(slot_id);
9365 InventoryLocation loc = new InventoryLocation;
9366
9367 if (destination_entity && slot_id != -1 && InventorySlots.IsSlotIdValid(slot_id))
9368 {
9369 if (stack_max <= GetQuantity())
9370 split_quantity_new = stack_max;
9371 else
9372 split_quantity_new = GetQuantity();
9373
9374 new_item = ItemBase.Cast(destination_entity.GetInventory().CreateAttachmentEx(this.GetType(), slot_id));
9375 if (new_item)
9376 {
9377 new_item.SetResultOfSplit(true);
9378 MiscGameplayFunctions.TransferItemProperties(this, new_item);
9379 AddQuantity(-split_quantity_new);
9380 new_item.SetQuantity(split_quantity_new);
9381 }
9382 }
9383 else if (destination_entity && slot_id == -1)
9384 {
9385 if (quantity > stack_max)
9386 split_quantity_new = stack_max;
9387 else
9388 split_quantity_new = quantity;
9389
9390 if (destination_entity.GetInventory().FindFreeLocationFor(this, FindInventoryLocationType.ANY, loc))
9391 {
9392 Object o = destination_entity.GetInventory().LocationCreateEntity(loc, GetType(), ECE_IN_INVENTORY, RF_DEFAULT);
9393 new_item = ItemBase.Cast(o);
9394 }
9395
9396 if (new_item)
9397 {
9398 new_item.SetResultOfSplit(true);
9399 MiscGameplayFunctions.TransferItemProperties(this, new_item);
9400 AddQuantity(-split_quantity_new);
9401 new_item.SetQuantity(split_quantity_new);
9402 }
9403 }
9404 else
9405 {
9406 if (stack_max != 0)
9407 {
9408 if (stack_max < GetQuantity())
9409 {
9410 split_quantity_new = GetQuantity() - stack_max;
9411 }
9412
9413 new_item = ItemBase.Cast(GetGame().CreateObjectEx(GetType(),GetWorldPosition(), ECE_PLACE_ON_SURFACE));
9414
9415 if (new_item)
9416 {
9417 new_item.SetResultOfSplit(true);
9418 MiscGameplayFunctions.TransferItemProperties(this, new_item);
9419 SetQuantity(split_quantity_new);
9420 new_item.SetQuantity(stack_max);
9421 new_item.PlaceOnSurface();
9422 }
9423 }
9424 }
9425 }
9426
9427 void SplitIntoStackMaxToInventoryLocationClient(notnull InventoryLocation dst)
9428 {
9429 if (!CanBeSplit())
9430 return;
9431
9432 if (GetGame().IsClient())
9433 {
9434 if (ScriptInputUserData.CanStoreInputUserData())
9435 {
9436 ScriptInputUserData ctx = new ScriptInputUserData;
9438 ctx.Write(4);
9439 ItemBase thiz = this; // @NOTE: workaround for correct serialization
9440 ctx.Write(thiz);
9441 dst.WriteToContext(ctx);
9442 ctx.Send();
9443 }
9444 }
9445 else if (!GetGame().IsMultiplayer())
9446 {
9448 }
9449 }
9450
9451 void SplitIntoStackMaxCargoClient(EntityAI destination_entity, int idx, int row, int col)
9452 {
9453 if (!CanBeSplit())
9454 return;
9455
9456 if (GetGame().IsClient())
9457 {
9458 if (ScriptInputUserData.CanStoreInputUserData())
9459 {
9460 ScriptInputUserData ctx = new ScriptInputUserData;
9462 ctx.Write(2);
9463 ItemBase dummy = this; // @NOTE: workaround for correct serialization
9464 ctx.Write(dummy);
9465 ctx.Write(destination_entity);
9466 ctx.Write(true);
9467 ctx.Write(idx);
9468 ctx.Write(row);
9469 ctx.Write(col);
9470 ctx.Send();
9471 }
9472 }
9473 else if (!GetGame().IsMultiplayer())
9474 {
9475 SplitIntoStackMaxCargo(destination_entity, idx, row, col);
9476 }
9477 }
9478
9479 void SplitIntoStackMaxToInventoryLocation(notnull InventoryLocation dst)
9480 {
9482 }
9483
9484 ItemBase SplitIntoStackMaxToInventoryLocationEx(notnull InventoryLocation dst)
9485 {
9486 if (!CanBeSplit())
9487 return this;
9488
9489 float quantity = GetQuantity();
9490 float split_quantity_new;
9491 ItemBase new_item;
9492 if (dst.IsValid())
9493 {
9494 int slot_id = dst.GetSlot();
9495 float stack_max = GetTargetQuantityMax(slot_id);
9496
9497 if (quantity > stack_max)
9498 split_quantity_new = stack_max;
9499 else
9500 split_quantity_new = quantity;
9501
9502 new_item = ItemBase.Cast(GameInventory.LocationCreateEntity(dst, this.GetType(), ECE_IN_INVENTORY, RF_DEFAULT));
9503
9504 if (new_item)
9505 {
9506 new_item.SetResultOfSplit(true);
9507 MiscGameplayFunctions.TransferItemProperties(this,new_item);
9508 AddQuantity(-split_quantity_new);
9509 new_item.SetQuantity(split_quantity_new);
9510 }
9511
9512 return new_item;
9513 }
9514
9515 return null;
9516 }
9517
9518 void SplitIntoStackMaxCargo(EntityAI destination_entity, int idx, int row, int col)
9519 {
9520 if (!CanBeSplit())
9521 return;
9522
9523 float quantity = GetQuantity();
9524 float split_quantity_new;
9525 ref ItemBase new_item;
9526 if (destination_entity)
9527 {
9528 float stackable = GetTargetQuantityMax();
9529 if (quantity > stackable)
9530 split_quantity_new = stackable;
9531 else
9532 split_quantity_new = quantity;
9533
9534 new_item = ItemBase.Cast(destination_entity.GetInventory().CreateEntityInCargoEx(this.GetType(), idx, row, col, false));
9535 if (new_item)
9536 {
9537 new_item.SetResultOfSplit(true);
9538 MiscGameplayFunctions.TransferItemProperties(this,new_item);
9539 AddQuantity(-split_quantity_new);
9540 new_item.SetQuantity(split_quantity_new);
9541 }
9542 }
9543 }
9544
9545 void SplitIntoStackMaxHandsClient(PlayerBase player)
9546 {
9547 if (!CanBeSplit())
9548 return;
9549
9550 if (GetGame().IsClient())
9551 {
9552 if (ScriptInputUserData.CanStoreInputUserData())
9553 {
9554 ScriptInputUserData ctx = new ScriptInputUserData;
9556 ctx.Write(3);
9557 ItemBase i1 = this; // @NOTE: workaround for correct serialization
9558 ctx.Write(i1);
9559 ItemBase destination_entity = this;
9560 ctx.Write(destination_entity);
9561 ctx.Write(true);
9562 ctx.Write(0);
9563 ctx.Send();
9564 }
9565 }
9566 else if (!GetGame().IsMultiplayer())
9567 {
9568 SplitIntoStackMaxHands(player);
9569 }
9570 }
9571
9572 void SplitIntoStackMaxHands(PlayerBase player)
9573 {
9574 if (!CanBeSplit())
9575 return;
9576
9577 float quantity = GetQuantity();
9578 float split_quantity_new;
9579 ref ItemBase new_item;
9580 if (player)
9581 {
9582 float stackable = GetTargetQuantityMax();
9583 if (quantity > stackable)
9584 split_quantity_new = stackable;
9585 else
9586 split_quantity_new = quantity;
9587
9588 EntityAI in_hands = player.GetHumanInventory().CreateInHands(this.GetType());
9589 new_item = ItemBase.Cast(in_hands);
9590 if (new_item)
9591 {
9592 new_item.SetResultOfSplit(true);
9593 MiscGameplayFunctions.TransferItemProperties(this,new_item);
9594 AddQuantity(-split_quantity_new);
9595 new_item.SetQuantity(split_quantity_new);
9596 }
9597 }
9598 }
9599
9600 void SplitItemToInventoryLocation(notnull InventoryLocation dst)
9601 {
9602 if (!CanBeSplit())
9603 return;
9604
9605 float quantity = GetQuantity();
9606 float split_quantity_new = Math.Floor(quantity * 0.5);
9607
9608 ItemBase new_item = ItemBase.Cast(GameInventory.LocationCreateEntity(dst, GetType(), ECE_IN_INVENTORY, RF_DEFAULT));
9609
9610 if (new_item)
9611 {
9612 if (new_item.GetQuantityMax() < split_quantity_new)
9613 {
9614 split_quantity_new = new_item.GetQuantityMax();
9615 }
9616
9617 new_item.SetResultOfSplit(true);
9618 MiscGameplayFunctions.TransferItemProperties(this, new_item);
9619
9620 if (dst.IsValid() && dst.GetType() == InventoryLocationType.ATTACHMENT && split_quantity_new > 1)
9621 {
9622 AddQuantity(-1);
9623 new_item.SetQuantity(1);
9624 }
9625 else
9626 {
9627 AddQuantity(-split_quantity_new);
9628 new_item.SetQuantity(split_quantity_new);
9629 }
9630 }
9631 }
9632
9633 void SplitItem(PlayerBase player)
9634 {
9635 if (!CanBeSplit())
9636 return;
9637
9638 float quantity = GetQuantity();
9639 float split_quantity_new = Math.Floor(quantity / 2);
9640
9641 InventoryLocation invloc = new InventoryLocation;
9642 bool found = player.GetInventory().FindFirstFreeLocationForNewEntity(GetType(), FindInventoryLocationType.ATTACHMENT, invloc);
9643
9644 ItemBase new_item;
9645 new_item = player.CreateCopyOfItemInInventoryOrGroundEx(this, true);
9646
9647 if (new_item)
9648 {
9649 if (new_item.GetQuantityMax() < split_quantity_new)
9650 {
9651 split_quantity_new = new_item.GetQuantityMax();
9652 }
9653 if (found && invloc.IsValid() && invloc.GetType() == InventoryLocationType.ATTACHMENT && split_quantity_new > 1)
9654 {
9655 AddQuantity(-1);
9656 new_item.SetQuantity(1);
9657 }
9658 else
9659 {
9660 AddQuantity(-split_quantity_new);
9661 new_item.SetQuantity(split_quantity_new);
9662 }
9663 }
9664 }
9665
9667 void OnQuantityChanged(float delta)
9668 {
9669 SetWeightDirty();
9670 ItemBase parent = ItemBase.Cast(GetHierarchyParent());
9671
9672 if (parent)
9673 parent.OnAttachmentQuantityChangedEx(this, delta);
9674
9675 if (IsLiquidContainer())
9676 {
9677 if (GetQuantityNormalized() <= 0.0)
9678 {
9680 }
9681 else if (GetLiquidType() == LIQUID_NONE)
9682 {
9683 ErrorEx("Undefined liquid type quantity changed, please define liquid type first! Using init value.",ErrorExSeverity.INFO);
9685 }
9686 }
9687
9688 }
9689
9692 {
9693 // insert code here
9694 }
9695
9697 void OnAttachmentQuantityChangedEx(ItemBase item , float delta)
9698 {
9700 }
9701
9702 override void EEHealthLevelChanged(int oldLevel, int newLevel, string zone)
9703 {
9704 super.EEHealthLevelChanged(oldLevel,newLevel,zone);
9705
9706 if (GetGame().IsServer())
9707 {
9708 if (newLevel == GameConstants.STATE_RUINED)
9709 {
9711 EntityAI parent = GetHierarchyParent();
9712 if (parent && parent.IsFireplace())
9713 {
9714 CargoBase cargo = GetInventory().GetCargo();
9715 if (cargo)
9716 {
9717 for (int i = 0; i < cargo.GetItemCount(); ++i)
9718 {
9719 parent.GetInventory().TakeEntityToInventory(InventoryMode.SERVER, FindInventoryLocationType.CARGO, cargo.GetItem(i));
9720 }
9721 }
9722 }
9723 }
9724
9725 if (IsResultOfSplit())
9726 {
9727 // reset the splitting result flag, return to normal item behavior
9728 SetResultOfSplit(false);
9729 return;
9730 }
9731
9732 if (m_Cleanness != 0 && oldLevel < newLevel && newLevel != 0)
9733 {
9734 SetCleanness(0);//unclean the item upon damage dealt
9735 }
9736 }
9737 }
9738
9739 // just the split? TODO: verify
9740 override void OnRightClick()
9741 {
9742 super.OnRightClick();
9743
9744 if (CanBeSplit() && !GetDayZGame().IsLeftCtrlDown() && !GetGame().GetPlayer().GetInventory().HasInventoryReservation(this,null))
9745 {
9746 if (GetGame().IsClient())
9747 {
9748 if (ScriptInputUserData.CanStoreInputUserData())
9749 {
9750 vector m4[4];
9751 PlayerBase player = PlayerBase.Cast(GetGame().GetPlayer());
9752
9753 EntityAI root = GetHierarchyRoot();
9754
9755 InventoryLocation dst = new InventoryLocation;
9756 if (!player.GetInventory().FindFirstFreeLocationForNewEntity(GetType(), FindInventoryLocationType.CARGO, dst))
9757 {
9758 if (root)
9759 {
9760 root.GetTransform(m4);
9761 dst.SetGround(this, m4);
9762 }
9763 else
9764 GetInventory().GetCurrentInventoryLocation(dst);
9765 }
9766 else
9767 {
9768 dst.SetCargo(dst.GetParent(), this, dst.GetIdx(), dst.GetRow(), dst.GetCol(), dst.GetFlip());
9769 /* hacky solution to check reservation of "this" item instead of null since the gamecode is checking null against null and returning reservation=true incorrectly
9770 this shouldnt cause issues within this scope*/
9771 if (GetGame().GetPlayer().GetInventory().HasInventoryReservation(this, dst))
9772 {
9773 if (root)
9774 {
9775 root.GetTransform(m4);
9776 dst.SetGround(this, m4);
9777 }
9778 else
9779 GetInventory().GetCurrentInventoryLocation(dst);
9780 }
9781 else
9782 {
9783 GetGame().GetPlayer().GetInventory().AddInventoryReservationEx(null, dst, GameInventory.c_InventoryReservationTimeoutShortMS);
9784 }
9785 }
9786
9787 ScriptInputUserData ctx = new ScriptInputUserData;
9789 ctx.Write(4);
9790 ItemBase thiz = this; // @NOTE: workaround for correct serialization
9791 ctx.Write(thiz);
9792 dst.WriteToContext(ctx);
9793 ctx.Write(true); // dummy
9794 ctx.Send();
9795 }
9796 }
9797 else if (!GetGame().IsMultiplayer())
9798 {
9799 SplitItem(PlayerBase.Cast(GetGame().GetPlayer()));
9800 }
9801 }
9802 }
9803
9804 override bool CanBeCombined(EntityAI other_item, bool reservation_check = true, bool stack_max_limit = false)
9805 {
9806 //TODO: delete check zero quantity check after fix double posts hands fsm events
9807 if (!other_item || GetType() != other_item.GetType() || (IsFullQuantity() && other_item.GetQuantity() > 0) || other_item == this)
9808 return false;
9809
9810 if (GetHealthLevel() == GameConstants.STATE_RUINED || other_item.GetHealthLevel() == GameConstants.STATE_RUINED)
9811 return false;
9812
9813 //can_this_be_combined = ConfigGetBool("canBeSplit");
9815 return false;
9816
9817
9818 Magazine mag = Magazine.Cast(this);
9819 if (mag)
9820 {
9821 if (mag.GetAmmoCount() >= mag.GetAmmoMax())
9822 return false;
9823
9824 if (stack_max_limit)
9825 {
9826 Magazine other_mag = Magazine.Cast(other_item);
9827 if (other_item)
9828 {
9829 if (mag.GetAmmoCount() + other_mag.GetAmmoCount() > mag.GetAmmoMax())
9830 return false;
9831 }
9832
9833 }
9834 }
9835 else
9836 {
9837 //TODO: delete check zero quantity check after fix double posts hands fsm events
9838 if (GetQuantity() >= GetQuantityMax() && other_item.GetQuantity() > 0 )
9839 return false;
9840
9841 if (stack_max_limit && (GetQuantity() + other_item.GetQuantity() > GetQuantityMax()))
9842 return false;
9843 }
9844
9845 PlayerBase player = null;
9846 if (CastTo(player, GetHierarchyRootPlayer())) //false when attached to player's attachment slot
9847 {
9848 if (player.GetInventory().HasAttachment(this))
9849 return false;
9850
9851 if (player.IsItemsToDelete())
9852 return false;
9853 }
9854
9855 if (reservation_check && (GetInventory().HasInventoryReservation(this, null) || other_item.GetInventory().HasInventoryReservation(other_item, null)))
9856 return false;
9857
9858 int slotID;
9859 string slotName;
9860 if (GetInventory().GetCurrentAttachmentSlotInfo(slotID,slotName) && GetHierarchyParent().GetInventory().GetSlotLock(slotID))
9861 return false;
9862
9863 return true;
9864 }
9865
9866 bool IsCombineAll(ItemBase other_item, bool use_stack_max = false)
9867 {
9868 return ComputeQuantityUsed(other_item, use_stack_max) == other_item.GetQuantity();
9869 }
9870
9871 bool IsResultOfSplit()
9872 {
9873 return m_IsResultOfSplit;
9874 }
9875
9876 void SetResultOfSplit(bool value)
9877 {
9878 m_IsResultOfSplit = value;
9879 }
9880
9881 int ComputeQuantityUsed(ItemBase other_item, bool use_stack_max = true)
9882 {
9883 return ComputeQuantityUsedEx(other_item, use_stack_max);
9884 }
9885
9886 float ComputeQuantityUsedEx(ItemBase other_item, bool use_stack_max = true)
9887 {
9888 float other_item_quantity = other_item.GetQuantity();
9889 float this_free_space;
9890
9891 float stack_max = GetQuantityMax();
9892
9893 this_free_space = stack_max - GetQuantity();
9894
9895 if (other_item_quantity > this_free_space)
9896 {
9897 return this_free_space;
9898 }
9899 else
9900 {
9901 return other_item_quantity;
9902 }
9903 }
9904
9905 override void CombineItemsEx(EntityAI entity2, bool use_stack_max = true)
9906 {
9907 CombineItems(ItemBase.Cast(entity2),use_stack_max);
9908 }
9909
9910 void CombineItems(ItemBase other_item, bool use_stack_max = true)
9911 {
9912 if (!CanBeCombined(other_item, false))
9913 return;
9914
9915 if (!IsMagazine() && other_item)
9916 {
9917 float quantity_used = ComputeQuantityUsedEx(other_item,use_stack_max);
9918 if (quantity_used != 0)
9919 {
9920 float hp1 = GetHealth01("","");
9921 float hp2 = other_item.GetHealth01("","");
9922 float hpResult = ((hp1*GetQuantity()) + (hp2*quantity_used));
9923 hpResult = hpResult / (GetQuantity() + quantity_used);
9924
9925 hpResult *= GetMaxHealth();
9926 Math.Round(hpResult);
9927 SetHealth("", "Health", hpResult);
9928
9929 AddQuantity(quantity_used);
9930 other_item.AddQuantity(-quantity_used);
9931 }
9932 }
9933 OnCombine(other_item);
9934 }
9935
9936 void OnCombine(ItemBase other_item)
9937 {
9938 #ifdef SERVER
9939 if (!GetHierarchyRootPlayer() && GetHierarchyParent())
9940 GetHierarchyParent().IncreaseLifetimeUp();
9941 #endif
9942 };
9943
9944 void GetRecipesActions(Man player, out TSelectableActionInfoArray outputList)
9945 {
9946 PlayerBase p = PlayerBase.Cast(player);
9947
9948 array<int> recipesIds = p.m_Recipes;
9949 PluginRecipesManager moduleRecipesManager = PluginRecipesManager.Cast(GetPlugin(PluginRecipesManager));
9950 if (moduleRecipesManager)
9951 {
9952 EntityAI itemInHands = player.GetHumanInventory().GetEntityInHands();
9953 moduleRecipesManager.GetValidRecipes(ItemBase.Cast(this), ItemBase.Cast(itemInHands), recipesIds, p);
9954 }
9955
9956 for (int i = 0;i < recipesIds.Count(); i++)
9957 {
9958 int key = recipesIds.Get(i);
9959 string recipeName = moduleRecipesManager.GetRecipeName(key);
9960 outputList.Insert(new TSelectableActionInfo(SAT_CRAFTING, key, recipeName));
9961 }
9962 }
9963
9964 // -------------------------------------------------------------------------
9965 override void GetDebugActions(out TSelectableActionInfoArrayEx outputList)
9966 {
9967 super.GetDebugActions(outputList);
9968
9969 //quantity
9970 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.ADD_QUANTITY, "Quantity +20%", FadeColors.LIGHT_GREY));
9971 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.REMOVE_QUANTITY, "Quantity -20%", FadeColors.LIGHT_GREY));
9972 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SET_QUANTITY_0, "Set Quantity 0", FadeColors.LIGHT_GREY));
9973 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SET_MAX_QUANTITY, "Set Quantity Max", FadeColors.LIGHT_GREY));
9974
9975 //health
9976 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.ADD_HEALTH, "Health +20%", FadeColors.LIGHT_GREY));
9977 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.REMOVE_HEALTH, "Health -20%", FadeColors.LIGHT_GREY));
9978 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.DESTROY_HEALTH, "Health 0", FadeColors.LIGHT_GREY));
9979 //temperature
9980 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.ADD_TEMPERATURE, "Temperature +20", FadeColors.LIGHT_GREY));
9981 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.REMOVE_TEMPERATURE, "Temperature -20", FadeColors.LIGHT_GREY));
9982 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.FLIP_FROZEN, "Toggle Frozen", FadeColors.LIGHT_GREY));
9983
9984 //wet
9985 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.ADD_WETNESS, "Wetness +20", FadeColors.LIGHT_GREY));
9986 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.REMOVE_WETNESS, "Wetness -20", FadeColors.LIGHT_GREY));
9987
9988 //liquidtype
9989 if (IsLiquidContainer())
9990 {
9991 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.LIQUIDTYPE_UP, "LiquidType Next", FadeColors.LIGHT_GREY));
9992 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.LIQUIDTYPE_DOWN, "LiquidType Previous", FadeColors.LIGHT_GREY));
9993 }
9994
9995 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.MAKE_SPECIAL, "Make Special", FadeColors.LIGHT_GREY));
9996 // watch
9997 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.WATCH_ITEM, "Watch (CTRL-Z)", FadeColors.LIGHT_GREY));
9998 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.WATCH_PLAYER, "Watch Player", FadeColors.LIGHT_GREY));
9999
10000 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SEPARATOR, "", FadeColors.RED));
10001 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.DELETE, "Delete", FadeColors.RED));
10002 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SEPARATOR, "", FadeColors.RED));
10003 }
10004
10005 // -------------------------------------------------------------------------
10006 // -------------------------------------------------------------------------
10007 // -------------------------------------------------------------------------
10008 override bool OnAction(int action_id, Man player, ParamsReadContext ctx)
10009 {
10010 super.OnAction(action_id, player, ctx);
10011 if (action_id >= EActions.RECIPES_RANGE_START && action_id < EActions.RECIPES_RANGE_END)
10012 {
10013 PluginRecipesManager plugin_recipes_manager = PluginRecipesManager.Cast(GetPlugin(PluginRecipesManager));
10014 int idWithoutOffset = action_id - EActions.RECIPES_RANGE_START;
10015 PlayerBase p = PlayerBase.Cast(player);
10016 if (EActions.RECIPES_RANGE_START < 1000)
10017 {
10018 float anim_length = plugin_recipes_manager.GetRecipeLengthInSecs(idWithoutOffset);
10019 float specialty_weight = plugin_recipes_manager.GetRecipeSpecialty(idWithoutOffset);
10020 }
10021 }
10022 #ifndef SERVER
10023 else if (action_id == EActions.WATCH_PLAYER)
10024 {
10025 PluginDeveloper.SetDeveloperItemClientEx(player);
10026 }
10027 #endif
10028 if (GetGame().IsServer())
10029 {
10030 if (action_id >= EActions.DEBUG_ITEM_WATCH_BUTTON_RANGE_START && action_id < EActions.DEBUG_ITEM_WATCH_BUTTON_RANGE_END)
10031 {
10032 int id = action_id - EActions.DEBUG_ITEM_WATCH_BUTTON_RANGE_START;
10033 OnDebugButtonPressServer(id + 1);
10034 }
10035
10036 else if (action_id >= EActions.DEBUG_AGENTS_RANGE_INJECT_START && action_id < EActions.DEBUG_AGENTS_RANGE_INJECT_END)
10037 {
10038 int agent_id = action_id - EActions.DEBUG_AGENTS_RANGE_INJECT_START;
10039 InsertAgent(agent_id,100);
10040 }
10041
10042 else if (action_id >= EActions.DEBUG_AGENTS_RANGE_REMOVE_START && action_id < EActions.DEBUG_AGENTS_RANGE_REMOVE_END)
10043 {
10044 int agent_id2 = action_id - EActions.DEBUG_AGENTS_RANGE_REMOVE_START;
10045 RemoveAgent(agent_id2);
10046 }
10047
10048 else if (action_id == EActions.ADD_QUANTITY)
10049 {
10050 if (IsMagazine())
10051 {
10052 Magazine mag = Magazine.Cast(this);
10053 mag.ServerSetAmmoCount(mag.GetAmmoCount() + mag.GetAmmoMax() * 0.2);
10054 }
10055 else
10056 {
10057 AddQuantity(GetQuantityMax() * 0.2);
10058 }
10059
10060 if (m_EM)
10061 {
10062 m_EM.AddEnergy(m_EM.GetEnergyMax() * 0.2);
10063 }
10064 //PrintVariables();
10065 }
10066
10067 else if (action_id == EActions.REMOVE_QUANTITY) //Quantity -20%
10068 {
10069 if (IsMagazine())
10070 {
10071 Magazine mag2 = Magazine.Cast(this);
10072 mag2.ServerSetAmmoCount(mag2.GetAmmoCount() - mag2.GetAmmoMax() * 0.2);
10073 }
10074 else
10075 {
10076 AddQuantity(- GetQuantityMax() * 0.2);
10077 }
10078 if (m_EM)
10079 {
10080 m_EM.AddEnergy(- m_EM.GetEnergyMax() * 0.2);
10081 }
10082 //PrintVariables();
10083 }
10084
10085 else if (action_id == EActions.SET_QUANTITY_0) //SetMaxQuantity
10086 {
10087 SetQuantity(0);
10088
10089 if (m_EM)
10090 {
10091 m_EM.SetEnergy(0);
10092 }
10093 }
10094
10095 else if (action_id == EActions.SET_MAX_QUANTITY) //SetMaxQuantity
10096 {
10098
10099 if (m_EM)
10100 {
10101 m_EM.SetEnergy(m_EM.GetEnergyMax());
10102 }
10103 }
10104
10105 else if (action_id == EActions.ADD_HEALTH)
10106 {
10107 AddHealth("","",GetMaxHealth("","Health")/5);
10108 }
10109 else if (action_id == EActions.REMOVE_HEALTH)
10110 {
10111 AddHealth("","",-GetMaxHealth("","Health")/5);
10112 }
10113 else if (action_id == EActions.DESTROY_HEALTH)
10114 {
10115 SetHealth01("","",0);
10116 }
10117 else if (action_id == EActions.WATCH_ITEM)
10118 {
10120 mid.RegisterDebugItem(ItemBase.Cast(this), PlayerBase.Cast(player));
10121 #ifdef DEVELOPER
10122 SetDebugDeveloper_item(this);
10123 #endif
10124 }
10125
10126 else if (action_id == EActions.ADD_TEMPERATURE)
10127 {
10128 AddTemperature(20);
10129 //PrintVariables();
10130 }
10131
10132 else if (action_id == EActions.REMOVE_TEMPERATURE)
10133 {
10134 AddTemperature(-20);
10135 //PrintVariables();
10136 }
10137
10138 else if (action_id == EActions.FLIP_FROZEN)
10139 {
10140 SetFrozen(!GetIsFrozen());
10141 //PrintVariables();
10142 }
10143
10144 else if (action_id == EActions.ADD_WETNESS)
10145 {
10146 AddWet(GetWetMax()/5);
10147 //PrintVariables();
10148 }
10149
10150 else if (action_id == EActions.REMOVE_WETNESS)
10151 {
10152 AddWet(-GetWetMax()/5);
10153 //PrintVariables();
10154 }
10155
10156 else if (action_id == EActions.LIQUIDTYPE_UP)
10157 {
10158 int curr_type = GetLiquidType();
10159 SetLiquidType(curr_type * 2);
10160 //AddWet(1);
10161 //PrintVariables();
10162 }
10163
10164 else if (action_id == EActions.LIQUIDTYPE_DOWN)
10165 {
10166 int curr_type2 = GetLiquidType();
10167 SetLiquidType(curr_type2 / 2);
10168 }
10169
10170 else if (action_id == EActions.MAKE_SPECIAL)
10171 {
10172 auto debugParams = DebugSpawnParams.WithPlayer(player);
10173 OnDebugSpawnEx(debugParams);
10174 }
10175
10176 else if (action_id == EActions.DELETE)
10177 {
10178 Delete();
10179 }
10180
10181 }
10182
10183
10184 return false;
10185 }
10186
10187 // -------------------------------------------------------------------------
10188
10189
10192 void OnActivatedByTripWire();
10193
10195 void OnActivatedByItem(notnull ItemBase item);
10196
10197 //----------------------------------------------------------------
10198 //returns true if item is able to explode when put in fire
10199 bool CanExplodeInFire()
10200 {
10201 return false;
10202 }
10203
10204 //----------------------------------------------------------------
10205 bool CanEat()
10206 {
10207 return true;
10208 }
10209
10210 //----------------------------------------------------------------
10211 override bool IsIgnoredByConstruction()
10212 {
10213 return true;
10214 }
10215
10216 //----------------------------------------------------------------
10217 //has FoodStages in config?
10218 bool HasFoodStage()
10219 {
10220 string config_path = string.Format("CfgVehicles %1 Food FoodStages", GetType());
10221 return GetGame().ConfigIsExisting(config_path);
10222 }
10223
10225 FoodStage GetFoodStage()
10226 {
10227 return null;
10228 }
10229
10230 bool CanBeCooked()
10231 {
10232 return false;
10233 }
10234
10235 bool CanBeCookedOnStick()
10236 {
10237 return false;
10238 }
10239
10241 void RefreshAudioVisualsOnClient( CookingMethodType cooking_method, bool is_done, bool is_empty, bool is_burned );
10243
10244 //----------------------------------------------------------------
10245 bool CanRepair(ItemBase item_repair_kit)
10246 {
10247 PluginRepairing module_repairing = PluginRepairing.Cast(GetPlugin(PluginRepairing));
10248 return module_repairing.CanRepair(this, item_repair_kit);
10249 }
10250
10251 //----------------------------------------------------------------
10252 bool Repair(PlayerBase player, ItemBase item_repair_kit, float specialty_weight)
10253 {
10254 PluginRepairing module_repairing = PluginRepairing.Cast(GetPlugin(PluginRepairing));
10255 return module_repairing.Repair(player, this, item_repair_kit, specialty_weight);
10256 }
10257
10258 //----------------------------------------------------------------
10259 int GetItemSize()
10260 {
10261 /*
10262 vector v_size = this.ConfigGetVector("itemSize");
10263 int v_size_x = v_size[0];
10264 int v_size_y = v_size[1];
10265 int size = v_size_x * v_size_y;
10266 return size;
10267 */
10268
10269 return 1;
10270 }
10271
10272 //----------------------------------------------------------------
10273 //Override for allowing seemingly unallowed moves when two clients send a conflicting message simultaneously
10274 bool CanBeMovedOverride()
10275 {
10276 return m_CanBeMovedOverride;
10277 }
10278
10279 //----------------------------------------------------------------
10280 //Override for allowing seemingly unallowed moves when two clients send a conflicting message simultaneously
10281 void SetCanBeMovedOverride(bool setting)
10282 {
10283 m_CanBeMovedOverride = setting;
10284 }
10285
10286 //----------------------------------------------------------------
10294 void MessageToOwnerStatus(string text)
10295 {
10296 PlayerBase player = PlayerBase.Cast(this.GetHierarchyRootPlayer());
10297
10298 if (player)
10299 {
10300 player.MessageStatus(text);
10301 }
10302 }
10303
10304 //----------------------------------------------------------------
10312 void MessageToOwnerAction(string text)
10313 {
10314 PlayerBase player = PlayerBase.Cast(this.GetHierarchyRootPlayer());
10315
10316 if (player)
10317 {
10318 player.MessageAction(text);
10319 }
10320 }
10321
10322 //----------------------------------------------------------------
10330 void MessageToOwnerFriendly(string text)
10331 {
10332 PlayerBase player = PlayerBase.Cast(this.GetHierarchyRootPlayer());
10333
10334 if (player)
10335 {
10336 player.MessageFriendly(text);
10337 }
10338 }
10339
10340 //----------------------------------------------------------------
10348 void MessageToOwnerImportant(string text)
10349 {
10350 PlayerBase player = PlayerBase.Cast(this.GetHierarchyRootPlayer());
10351
10352 if (player)
10353 {
10354 player.MessageImportant(text);
10355 }
10356 }
10357
10358 override bool IsItemBase()
10359 {
10360 return true;
10361 }
10362
10363 // Checks if item is of questioned kind
10364 override bool KindOf(string tag)
10365 {
10366 bool found = false;
10367 string item_name = this.GetType();
10368 ref TStringArray item_tag_array = new TStringArray;
10369 GetGame().ConfigGetTextArray("cfgVehicles " + item_name + " itemInfo", item_tag_array);
10370
10371 int array_size = item_tag_array.Count();
10372 for (int i = 0; i < array_size; i++)
10373 {
10374 if (item_tag_array.Get(i) == tag)
10375 {
10376 found = true;
10377 break;
10378 }
10379 }
10380 return found;
10381 }
10382
10383
10384 override void OnRPC(PlayerIdentity sender, int rpc_type,ParamsReadContext ctx)
10385 {
10386 //Debug.Log("OnRPC called");
10387 super.OnRPC(sender, rpc_type,ctx);
10388
10389 //Play soundset for attachment locking (ActionLockAttachment.c)
10390 switch (rpc_type)
10391 {
10392 #ifndef SERVER
10393 case ERPCs.RPC_SOUND_LOCK_ATTACH:
10394 Param2<bool, string> p = new Param2<bool, string>(false, "");
10395
10396 if (!ctx.Read(p))
10397 return;
10398
10399 bool play = p.param1;
10400 string soundSet = p.param2;
10401
10402 if (play)
10403 {
10404 if (m_LockingSound)
10405 {
10407 {
10408 m_LockingSound = SEffectManager.PlaySound(soundSet, GetPosition(), 0, 0, true);
10409 }
10410 }
10411 else
10412 {
10413 m_LockingSound = SEffectManager.PlaySound(soundSet, GetPosition(), 0, 0, true);
10414 }
10415 }
10416 else
10417 {
10418 SEffectManager.DestroyEffect(m_LockingSound);
10419 }
10420
10421 break;
10422 #endif
10423
10424 }
10425
10426 if (GetWrittenNoteData())
10427 {
10428 GetWrittenNoteData().OnRPC(sender, rpc_type,ctx);
10429 }
10430 }
10431
10432 //-----------------------------
10433 // VARIABLE MANIPULATION SYSTEM
10434 //-----------------------------
10435 int NameToID(string name)
10436 {
10437 PluginVariables plugin = PluginVariables.Cast(GetPlugin(PluginVariables));
10438 return plugin.GetID(name);
10439 }
10440
10441 string IDToName(int id)
10442 {
10443 PluginVariables plugin = PluginVariables.Cast(GetPlugin(PluginVariables));
10444 return plugin.GetName(id);
10445 }
10446
10448 void OnSyncVariables(ParamsReadContext ctx)//with ID optimization
10449 {
10450 //Debug.Log("OnSyncVariables called for item: "+ ToString(this.GetType()),"varSync");
10451 //read the flags
10452 int varFlags;
10453 if (!ctx.Read(varFlags))
10454 return;
10455
10456 if (varFlags & ItemVariableFlags.FLOAT)
10457 {
10458 ReadVarsFromCTX(ctx);
10459 }
10460 }
10461
10462 override void SerializeNumericalVars(array<float> floats_out)
10463 {
10464 //some variables handled on EntityAI level already!
10465 super.SerializeNumericalVars(floats_out);
10466
10467 // the order of serialization must be the same as the order of de-serialization
10468 //--------------------------------------------
10469 if (IsVariableSet(VARIABLE_QUANTITY))
10470 {
10471 floats_out.Insert(m_VarQuantity);
10472 }
10473 //--------------------------------------------
10474 if (IsVariableSet(VARIABLE_WET))
10475 {
10476 floats_out.Insert(m_VarWet);
10477 }
10478 //--------------------------------------------
10479 if (IsVariableSet(VARIABLE_LIQUIDTYPE))
10480 {
10481 floats_out.Insert(m_VarLiquidType);
10482 }
10483 //--------------------------------------------
10484 if (IsVariableSet(VARIABLE_COLOR))
10485 {
10486 floats_out.Insert(m_ColorComponentR);
10487 floats_out.Insert(m_ColorComponentG);
10488 floats_out.Insert(m_ColorComponentB);
10489 floats_out.Insert(m_ColorComponentA);
10490 }
10491 //--------------------------------------------
10492 if (IsVariableSet(VARIABLE_CLEANNESS))
10493 {
10494 floats_out.Insert(m_Cleanness);
10495 }
10496 }
10497
10498 override void DeSerializeNumericalVars(array<float> floats)
10499 {
10500 //some variables handled on EntityAI level already!
10501 super.DeSerializeNumericalVars(floats);
10502
10503 // the order of serialization must be the same as the order of de-serialization
10504 int index = 0;
10505 int mask = Math.Round(floats.Get(index));
10506
10507 index++;
10508 //--------------------------------------------
10509 if (mask & VARIABLE_QUANTITY)
10510 {
10511 if (m_IsStoreLoad)
10512 {
10513 SetStoreLoadedQuantity(floats.Get(index));
10514 }
10515 else
10516 {
10517 float quantity = floats.Get(index);
10518 SetQuantity(quantity, true, false, false, false);
10519 }
10520 index++;
10521 }
10522 //--------------------------------------------
10523 if (mask & VARIABLE_WET)
10524 {
10525 float wet = floats.Get(index);
10526 SetWet(wet);
10527 index++;
10528 }
10529 //--------------------------------------------
10530 if (mask & VARIABLE_LIQUIDTYPE)
10531 {
10532 int liquidtype = Math.Round(floats.Get(index));
10533 SetLiquidType(liquidtype);
10534 index++;
10535 }
10536 //--------------------------------------------
10537 if (mask & VARIABLE_COLOR)
10538 {
10539 m_ColorComponentR = Math.Round(floats.Get(index));
10540 index++;
10541 m_ColorComponentG = Math.Round(floats.Get(index));
10542 index++;
10543 m_ColorComponentB = Math.Round(floats.Get(index));
10544 index++;
10545 m_ColorComponentA = Math.Round(floats.Get(index));
10546 index++;
10547 }
10548 //--------------------------------------------
10549 if (mask & VARIABLE_CLEANNESS)
10550 {
10551 int cleanness = Math.Round(floats.Get(index));
10552 SetCleanness(cleanness);
10553 index++;
10554 }
10555 }
10556
10557 override void WriteVarsToCTX(ParamsWriteContext ctx)
10558 {
10559 super.WriteVarsToCTX(ctx);
10560
10561 //--------------------------------------------
10562 if (IsVariableSet(VARIABLE_QUANTITY))
10563 {
10564 ctx.Write(GetQuantity());
10565 }
10566 //--------------------------------------------
10567 if (IsVariableSet(VARIABLE_WET))
10568 {
10569 ctx.Write(GetWet());
10570 }
10571 //--------------------------------------------
10572 if (IsVariableSet(VARIABLE_LIQUIDTYPE))
10573 {
10574 ctx.Write(GetLiquidType());
10575 }
10576 //--------------------------------------------
10577 if (IsVariableSet(VARIABLE_COLOR))
10578 {
10579 int r,g,b,a;
10580 GetColor(r,g,b,a);
10581 ctx.Write(r);
10582 ctx.Write(g);
10583 ctx.Write(b);
10584 ctx.Write(a);
10585 }
10586 //--------------------------------------------
10587 if (IsVariableSet(VARIABLE_CLEANNESS))
10588 {
10589 ctx.Write(GetCleanness());
10590 }
10591 }
10592
10593 override bool ReadVarsFromCTX(ParamsReadContext ctx, int version = -1)//with ID optimization
10594 {
10595 if (!super.ReadVarsFromCTX(ctx,version))
10596 return false;
10597
10598 int intValue;
10599 float value;
10600
10601 if (version < 140)
10602 {
10603 if (!ctx.Read(intValue))
10604 return false;
10605
10606 m_VariablesMask = intValue;
10607 }
10608
10609 if (m_VariablesMask & VARIABLE_QUANTITY)
10610 {
10611 if (!ctx.Read(value))
10612 return false;
10613
10614 if (IsStoreLoad())
10615 {
10617 }
10618 else
10619 {
10620 SetQuantity(value, true, false, false, false);
10621 }
10622 }
10623 //--------------------------------------------
10624 if (version < 140)
10625 {
10626 if (m_VariablesMask & VARIABLE_TEMPERATURE)
10627 {
10628 if (!ctx.Read(value))
10629 return false;
10630 SetTemperatureDirect(value);
10631 }
10632 }
10633 //--------------------------------------------
10634 if (m_VariablesMask & VARIABLE_WET)
10635 {
10636 if (!ctx.Read(value))
10637 return false;
10638 SetWet(value);
10639 }
10640 //--------------------------------------------
10641 if (m_VariablesMask & VARIABLE_LIQUIDTYPE)
10642 {
10643 if (!ctx.Read(intValue))
10644 return false;
10645 SetLiquidType(intValue);
10646 }
10647 //--------------------------------------------
10648 if (m_VariablesMask & VARIABLE_COLOR)
10649 {
10650 int r,g,b,a;
10651 if (!ctx.Read(r))
10652 return false;
10653 if (!ctx.Read(g))
10654 return false;
10655 if (!ctx.Read(b))
10656 return false;
10657 if (!ctx.Read(a))
10658 return false;
10659
10660 SetColor(r,g,b,a);
10661 }
10662 //--------------------------------------------
10663 if (m_VariablesMask & VARIABLE_CLEANNESS)
10664 {
10665 if (!ctx.Read(intValue))
10666 return false;
10667 SetCleanness(intValue);
10668 }
10669 //--------------------------------------------
10670 if (version >= 138 && version < 140)
10671 {
10672 if (m_VariablesMask & VARIABLE_TEMPERATURE)
10673 {
10674 if (!ctx.Read(intValue))
10675 return false;
10676 SetFrozen(intValue);
10677 }
10678 }
10679
10680 return true;
10681 }
10682
10683 //----------------------------------------------------------------
10684 override bool OnStoreLoad(ParamsReadContext ctx, int version)
10685 {
10686 m_IsStoreLoad = true;
10688 {
10689 m_FixDamageSystemInit = true;
10690 }
10691
10692 if (!super.OnStoreLoad(ctx, version))
10693 {
10694 m_IsStoreLoad = false;
10695 return false;
10696 }
10697
10698 if (version >= 114)
10699 {
10700 bool hasQuickBarIndexSaved;
10701
10702 if (!ctx.Read(hasQuickBarIndexSaved))
10703 {
10704 m_IsStoreLoad = false;
10705 return false;
10706 }
10707
10708 if (hasQuickBarIndexSaved)
10709 {
10710 int itmQBIndex;
10711
10712 //Load quickbar item bind
10713 if (!ctx.Read(itmQBIndex))
10714 {
10715 m_IsStoreLoad = false;
10716 return false;
10717 }
10718
10719 PlayerBase parentPlayer = PlayerBase.Cast(GetHierarchyRootPlayer());
10720 if (itmQBIndex != -1 && parentPlayer)
10721 parentPlayer.SetLoadedQuickBarItemBind(this, itmQBIndex);
10722 }
10723 }
10724 else
10725 {
10726 // Backup of how it used to be
10727 PlayerBase player;
10728 int itemQBIndex;
10729 if (version == int.MAX)
10730 {
10731 if (!ctx.Read(itemQBIndex))
10732 {
10733 m_IsStoreLoad = false;
10734 return false;
10735 }
10736 }
10737 else if (Class.CastTo(player, GetHierarchyRootPlayer()))
10738 {
10739 //Load quickbar item bind
10740 if (!ctx.Read(itemQBIndex))
10741 {
10742 m_IsStoreLoad = false;
10743 return false;
10744 }
10745 if (itemQBIndex != -1 && player)
10746 player.SetLoadedQuickBarItemBind(this,itemQBIndex);
10747 }
10748 }
10749
10750 if (version < 140)
10751 {
10752 // variable management system
10753 if (!LoadVariables(ctx, version))
10754 {
10755 m_IsStoreLoad = false;
10756 return false;
10757 }
10758 }
10759
10760 //agent trasmission system
10761 if (!LoadAgents(ctx, version))
10762 {
10763 m_IsStoreLoad = false;
10764 return false;
10765 }
10766 if (version >= 132)
10767 {
10768 RemotelyActivatedItemBehaviour raib = GetRemotelyActivatedItemBehaviour();
10769 if (raib)
10770 {
10771 if (!raib.OnStoreLoad(ctx,version))
10772 {
10773 m_IsStoreLoad = false;
10774 return false;
10775 }
10776 }
10777 }
10778
10779 m_IsStoreLoad = false;
10780 return true;
10781 }
10782
10783 //----------------------------------------------------------------
10784
10785 override void OnStoreSave(ParamsWriteContext ctx)
10786 {
10787 super.OnStoreSave(ctx);
10788
10789 PlayerBase player;
10790 if (PlayerBase.CastTo(player,GetHierarchyRootPlayer()))
10791 {
10792 ctx.Write(true); // Keep track of if we should actually read this in or not
10793 //Save quickbar item bind
10794 int itemQBIndex = -1;
10795 itemQBIndex = player.FindQuickBarEntityIndex(this);
10796 ctx.Write(itemQBIndex);
10797 }
10798 else
10799 {
10800 ctx.Write(false); // Keep track of if we should actually read this in or not
10801 }
10802
10803 SaveAgents(ctx);//agent trasmission system
10804
10805 RemotelyActivatedItemBehaviour raib = GetRemotelyActivatedItemBehaviour();
10806 if (raib)
10807 {
10808 raib.OnStoreSave(ctx);
10809 }
10810 }
10811 //----------------------------------------------------------------
10812
10813 override void AfterStoreLoad()
10814 {
10815 super.AfterStoreLoad();
10816
10818 {
10820 }
10821
10822 if (GetStoreLoadedQuantity() != float.LOWEST)
10823 {
10825 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
10826 }
10827 }
10828
10829 override void EEOnAfterLoad()
10830 {
10831 super.EEOnAfterLoad();
10832
10834 {
10835 m_FixDamageSystemInit = false;
10836 }
10837
10840 }
10841
10842 bool CanBeDisinfected()
10843 {
10844 return false;
10845 }
10846
10847
10848 //----------------------------------------------------------------
10849 override void OnVariablesSynchronized()
10850 {
10851 if (m_Initialized)
10852 {
10853 #ifdef PLATFORM_CONSOLE
10854 //bruteforce it is
10855 if (IsSplitable())
10856 {
10857 UIScriptedMenu menu = GetGame().GetUIManager().FindMenu(MENU_INVENTORY);
10858 if (menu)
10859 {
10860 menu.Refresh();
10861 }
10862 }
10863 #endif
10864 }
10865
10867 {
10868 PlayImpactSound(m_ConfigWeight, m_ImpactSpeed, m_ImpactSoundSurfaceHash);
10869 m_WantPlayImpactSound = false;
10870 }
10871
10873 {
10874 SetWeightDirty();
10876 }
10877 if (m_VarWet != m_VarWetPrev)
10878 {
10881 }
10882
10883 if (m_SoundSyncPlay != 0)
10884 {
10885 m_ItemSoundHandler.PlayItemSoundClient(m_SoundSyncPlay);
10886 m_SoundSyncPlay = 0;
10887 }
10888 if (m_SoundSyncStop != 0)
10889 {
10890 m_ItemSoundHandler.StopItemSoundClient(m_SoundSyncStop);
10891 m_SoundSyncStop = 0;
10892 }
10893
10894 super.OnVariablesSynchronized();
10895 }
10896
10897 //------------------------- Quantity
10898 //----------------------------------------------------------------
10900 override bool SetQuantity(float value, bool destroy_config = true, bool destroy_forced = false, bool allow_client = false, bool clamp_to_stack_max = true)
10901 {
10902 if (!IsServerCheck(allow_client))
10903 return false;
10904
10905 if (!HasQuantity())
10906 return false;
10907
10908 float min = GetQuantityMin();
10909 float max = GetQuantityMax();
10910
10911 if (value <= (min + 0.001))
10912 value = min;
10913
10914 if (value == min)
10915 {
10916 if (destroy_config)
10917 {
10918 bool dstr = ConfigGetBool("varQuantityDestroyOnMin");
10919 if (dstr)
10920 {
10921 m_VarQuantity = Math.Clamp(value, min, max);
10922 this.Delete();
10923 return true;
10924 }
10925 }
10926 else if (destroy_forced)
10927 {
10928 m_VarQuantity = Math.Clamp(value, min, max);
10929 this.Delete();
10930 return true;
10931 }
10932 // we get here if destroy_config IS true AND dstr(config destroy param) IS false;
10933 RemoveAllAgents();//we remove all agents when we got to the min value, but the item is not getting deleted
10934 }
10935
10936 float delta = m_VarQuantity;
10937 m_VarQuantity = Math.Clamp(value, min, max);
10938
10939 if (GetStoreLoadedQuantity() == float.LOWEST)//any other value means we are setting quantity from storage
10940 {
10941 delta = m_VarQuantity - delta;
10942
10943 if (delta)
10944 OnQuantityChanged(delta);
10945 }
10946
10947 SetVariableMask(VARIABLE_QUANTITY);
10948
10949 return false;
10950 }
10951
10952 //----------------------------------------------------------------
10954 bool AddQuantity(float value, bool destroy_config = true, bool destroy_forced = false)
10955 {
10956 return SetQuantity(GetQuantity() + value, destroy_config, destroy_forced);
10957 }
10958 //----------------------------------------------------------------
10959 void SetQuantityMax()
10960 {
10961 float max = GetQuantityMax();
10962 SetQuantity(max);
10963 }
10964
10965 override void SetQuantityToMinimum()
10966 {
10967 float min = GetQuantityMin();
10968 SetQuantity(min);
10969 }
10970 //----------------------------------------------------------------
10972 void SetQuantityNormalized(float value, bool destroy_config = true, bool destroy_forced = false)
10973 {
10974 float value_clamped = Math.Clamp(value, 0, 1);//just to make sure
10975 int result = Math.Round(Math.Lerp(GetQuantityMin(), GetQuantityMax(), value_clamped));
10976 SetQuantity(result, destroy_config, destroy_forced);
10977 }
10978
10979 //----------------------------------------------------------------
10981 override float GetQuantityNormalized()
10982 {
10983 return Math.InverseLerp(GetQuantityMin(), GetQuantityMax(),m_VarQuantity);
10984 }
10985
10987 {
10988 return GetQuantityNormalized();
10989 }
10990
10991 /*void SetAmmoNormalized(float value)
10992 {
10993 float value_clamped = Math.Clamp(value, 0, 1);
10994 Magazine this_mag = Magazine.Cast(this);
10995 int max_rounds = this_mag.GetAmmoMax();
10996 int result = value * max_rounds;//can the rounded if higher precision is required
10997 this_mag.SetAmmoCount(result);
10998 }*/
10999 //----------------------------------------------------------------
11000 override int GetQuantityMax()
11001 {
11002 int slot = -1;
11003 if (GetInventory())
11004 {
11005 InventoryLocation il = new InventoryLocation;
11006 GetInventory().GetCurrentInventoryLocation(il);
11007 slot = il.GetSlot();
11008 }
11009
11010 return GetTargetQuantityMax(slot);
11011 }
11012
11013 override int GetTargetQuantityMax(int attSlotID = -1)
11014 {
11015 float quantity_max = 0;
11016
11017 if (IsSplitable()) //only stackable/splitable items can check for stack size
11018 {
11019 if (attSlotID != -1)
11020 quantity_max = InventorySlots.GetStackMaxForSlotId(attSlotID);
11021
11022 if (quantity_max <= 0)
11023 quantity_max = m_VarStackMax;
11024 }
11025
11026 if (quantity_max <= 0)
11027 quantity_max = m_VarQuantityMax;
11028
11029 return quantity_max;
11030 }
11031 //----------------------------------------------------------------
11032 override int GetQuantityMin()
11033 {
11034 return m_VarQuantityMin;
11035 }
11036 //----------------------------------------------------------------
11037 int GetQuantityInit()
11038 {
11039 return m_VarQuantityInit;
11040 }
11041
11042 //----------------------------------------------------------------
11043 override bool HasQuantity()
11044 {
11045 return !(GetQuantityMax() - GetQuantityMin() == 0);
11046 }
11047
11048 override float GetQuantity()
11049 {
11050 return m_VarQuantity;
11051 }
11052
11053 bool IsFullQuantity()
11054 {
11055 return GetQuantity() >= GetQuantityMax();
11056 }
11057
11058 //Calculates weight of single item without attachments and cargo
11059 override float GetSingleInventoryItemWeightEx()
11060 {
11061 //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
11062 float weightEx = GetWeightEx();//overall weight of the item
11063 float special = GetInventoryAndCargoWeight();//cargo and attachment weight
11064 return weightEx - special;
11065 }
11066
11067 // Obsolete, use GetSingleInventoryItemWeightEx() instead
11069 {
11071 }
11072
11073 override protected float GetWeightSpecialized(bool forceRecalc = false)
11074 {
11075 if (IsSplitable()) //quantity determines size of the stack
11076 {
11077 #ifdef DEVELOPER
11078 if (WeightDebug.m_VerbosityFlags & WeightDebugType.RECALC_FORCED)
11079 {
11080 WeightDebugData data1 = WeightDebug.GetWeightDebug(this);
11081 data1.SetCalcDetails("TIB1: " + GetConfigWeightModifiedDebugText() +" * " + GetQuantity()+"(quantity)");
11082 }
11083 #endif
11084
11085 return GetQuantity() * GetConfigWeightModified();
11086 }
11087 else if (HasEnergyManager())// items with energy manager
11088 {
11089 #ifdef DEVELOPER
11090 if (WeightDebug.m_VerbosityFlags & WeightDebugType.RECALC_FORCED)
11091 {
11092 WeightDebugData data2 = WeightDebug.GetWeightDebug(this);
11093 data2.SetCalcDetails("TIB2: "+super.GetWeightSpecialized(forceRecalc)+"(contents weight) + " + GetConfigWeightModifiedDebugText() +" + " + GetCompEM().GetEnergy()+"(energy) * " + ConfigGetFloat("weightPerQuantityUnit") +"(weightPerQuantityUnit)");
11094 }
11095 #endif
11096 return super.GetWeightSpecialized(forceRecalc) + (GetCompEM().GetEnergy() * ConfigGetFloat("weightPerQuantityUnit")) + GetConfigWeightModified());
11097 }
11098 else//everything else
11099 {
11100 #ifdef DEVELOPER
11101 if (WeightDebug.m_VerbosityFlags & WeightDebugType.RECALC_FORCED)
11102 {
11103 WeightDebugData data3 = WeightDebug.GetWeightDebug(this);
11104 data3.SetCalcDetails("TIB3: "+super.GetWeightSpecialized(forceRecalc)+"(contents weight) + " + GetConfigWeightModifiedDebugText() +" + " + GetQuantity()+"(quantity) * " + ConfigGetFloat("weightPerQuantityUnit") +"(weightPerQuantityUnit))");
11105 }
11106 #endif
11107 return super.GetWeightSpecialized(forceRecalc) + (GetQuantity() * ConfigGetFloat("weightPerQuantityUnit")) + GetConfigWeightModified());
11108 }
11109 }
11110
11112 int GetNumberOfItems()
11113 {
11114 int item_count = 0;
11115 ItemBase item;
11116
11117 if (GetInventory().GetCargo() != NULL)
11118 {
11119 item_count = GetInventory().GetCargo().GetItemCount();
11120 }
11121
11122 for (int i = 0; i < GetInventory().AttachmentCount(); i++)
11123 {
11124 Class.CastTo(item,GetInventory().GetAttachmentFromIndex(i));
11125 if (item)
11126 item_count += item.GetNumberOfItems();
11127 }
11128 return item_count;
11129 }
11130
11132 float GetUnitWeight(bool include_wetness = true)
11133 {
11134 float weight = 0;
11135 float wetness = 1;
11136 if (include_wetness)
11137 wetness += GetWet();
11138 if (IsSplitable()) //quantity determines size of the stack
11139 {
11140 weight = wetness * m_ConfigWeight;
11141 }
11142 else if (IsLiquidContainer()) //is a liquid container, default liquid weight is set to 1. May revisit later?
11143 {
11144 weight = 1;
11145 }
11146 return weight;
11147 }
11148
11149 //-----------------------------------------------------------------
11150
11151 override void ClearInventory()
11152 {
11153 if ((GetGame().IsServer() || !GetGame().IsMultiplayer()) && GetInventory())
11154 {
11155 GameInventory inv = GetInventory();
11156 array<EntityAI> items = new array<EntityAI>;
11157 inv.EnumerateInventory(InventoryTraversalType.INORDER, items);
11158 for (int i = 0; i < items.Count(); i++)
11159 {
11160 ItemBase item = ItemBase.Cast(items.Get(i));
11161 if (item)
11162 {
11163 GetGame().ObjectDelete(item);
11164 }
11165 }
11166 }
11167 }
11168
11169 //------------------------- Energy
11170
11171 //----------------------------------------------------------------
11172 float GetEnergy()
11173 {
11174 float energy = 0;
11175 if (HasEnergyManager())
11176 {
11177 energy = GetCompEM().GetEnergy();
11178 }
11179 return energy;
11180 }
11181
11182
11183 override void OnEnergyConsumed()
11184 {
11185 super.OnEnergyConsumed();
11186
11188 }
11189
11190 override void OnEnergyAdded()
11191 {
11192 super.OnEnergyAdded();
11193
11195 }
11196
11197 // Converts energy (from Energy Manager) to quantity, if enabled.
11199 {
11200 if (GetGame().IsServer() && HasEnergyManager() && GetCompEM().HasConversionOfEnergyToQuantity())
11201 {
11202 if (HasQuantity())
11203 {
11204 float energy_0to1 = GetCompEM().GetEnergy0To1();
11205 SetQuantityNormalized(energy_0to1);
11206 }
11207 }
11208 }
11209
11210 //----------------------------------------------------------------
11211 float GetHeatIsolationInit()
11212 {
11213 return ConfigGetFloat("heatIsolation");
11214 }
11215
11216 float GetHeatIsolation()
11217 {
11218 return m_HeatIsolation;
11219 }
11220
11221 float GetDryingIncrement(string pIncrementName)
11222 {
11223 string paramPath = string.Format("CfgVehicles %1 EnvironmentWetnessIncrements Drying %2", GetType(), pIncrementName);
11224 if (GetGame().ConfigIsExisting(paramPath))
11225 return GetGame().ConfigGetFloat(paramPath);
11226
11227 return 0.0;
11228 }
11229
11230 float GetSoakingIncrement(string pIncrementName)
11231 {
11232 string paramPath = string.Format("CfgVehicles %1 EnvironmentWetnessIncrements Soaking %2", GetType(), pIncrementName);
11233 if (GetGame().ConfigIsExisting(paramPath))
11234 return GetGame().ConfigGetFloat(paramPath);
11235
11236 return 0.0;
11237 }
11238 //----------------------------------------------------------------
11239 override void SetWet(float value, bool allow_client = false)
11240 {
11241 if (!IsServerCheck(allow_client))
11242 return;
11243
11244 float min = GetWetMin();
11245 float max = GetWetMax();
11246
11247 float previousValue = m_VarWet;
11248
11249 m_VarWet = Math.Clamp(value, min, max);
11250
11251 if (previousValue != m_VarWet)
11252 {
11253 SetVariableMask(VARIABLE_WET);
11254 OnWetChanged(m_VarWet, previousValue);
11255 }
11256 }
11257 //----------------------------------------------------------------
11258 override void AddWet(float value)
11259 {
11260 SetWet(GetWet() + value);
11261 }
11262 //----------------------------------------------------------------
11263 override void SetWetMax()
11264 {
11266 }
11267 //----------------------------------------------------------------
11268 override float GetWet()
11269 {
11270 return m_VarWet;
11271 }
11272 //----------------------------------------------------------------
11273 override float GetWetMax()
11274 {
11275 return m_VarWetMax;
11276 }
11277 //----------------------------------------------------------------
11278 override float GetWetMin()
11279 {
11280 return m_VarWetMin;
11281 }
11282 //----------------------------------------------------------------
11283 override float GetWetInit()
11284 {
11285 return m_VarWetInit;
11286 }
11287 //----------------------------------------------------------------
11288 override void OnWetChanged(float newVal, float oldVal)
11289 {
11290 EWetnessLevel newLevel = GetWetLevelInternal(newVal);
11291 EWetnessLevel oldLevel = GetWetLevelInternal(oldVal);
11292 if (newLevel != oldLevel)
11293 {
11294 OnWetLevelChanged(newLevel,oldLevel);
11295 }
11296 }
11297
11298 override void OnWetLevelChanged(EWetnessLevel newLevel, EWetnessLevel oldLevel)
11299 {
11300 SetWeightDirty();
11301 }
11302
11303 override EWetnessLevel GetWetLevel()
11304 {
11305 return GetWetLevelInternal(m_VarWet);
11306 }
11307
11308 //----------------------------------------------------------------
11309
11310 override void SetStoreLoad(bool value)
11311 {
11312 m_IsStoreLoad = value;
11313 }
11314
11315 override bool IsStoreLoad()
11316 {
11317 return m_IsStoreLoad;
11318 }
11319
11320 override void SetStoreLoadedQuantity(float value)
11321 {
11322 m_StoreLoadedQuantity = value;
11323 }
11324
11325 override float GetStoreLoadedQuantity()
11326 {
11327 return m_StoreLoadedQuantity;
11328 }
11329
11330 //----------------------------------------------------------------
11331
11332 float GetItemModelLength()
11333 {
11334 if (ConfigIsExisting("itemModelLength"))
11335 {
11336 return ConfigGetFloat("itemModelLength");
11337 }
11338 return 0;
11339 }
11340
11341 float GetItemAttachOffset()
11342 {
11343 if (ConfigIsExisting("itemAttachOffset"))
11344 {
11345 return ConfigGetFloat("itemAttachOffset");
11346 }
11347 return 0;
11348 }
11349
11350 override void SetCleanness(int value, bool allow_client = false)
11351 {
11352 if (!IsServerCheck(allow_client))
11353 return;
11354
11355 int previousValue = m_Cleanness;
11356
11357 m_Cleanness = Math.Clamp(value, m_CleannessMin, m_CleannessMax);
11358
11359 if (previousValue != m_Cleanness)
11360 SetVariableMask(VARIABLE_CLEANNESS);
11361 }
11362
11363 override int GetCleanness()
11364 {
11365 return m_Cleanness;
11366 }
11367
11369 {
11370 return true;
11371 }
11372
11373 //----------------------------------------------------------------
11374 // ATTACHMENT LOCKING
11375 // Getters relevant to generic ActionLockAttachment
11376 int GetLockType()
11377 {
11378 return m_LockType;
11379 }
11380
11381 string GetLockSoundSet()
11382 {
11383 return m_LockSoundSet;
11384 }
11385
11386 //----------------------------------------------------------------
11387 //------------------------- Color
11388 // sets items color variable given color components
11389 override void SetColor(int r, int g, int b, int a)
11390 {
11395 SetVariableMask(VARIABLE_COLOR);
11396 }
11398 override void GetColor(out int r,out int g,out int b,out int a)
11399 {
11404 }
11405
11406 bool IsColorSet()
11407 {
11408 return IsVariableSet(VARIABLE_COLOR);
11409 }
11410
11412 string GetColorString()
11413 {
11414 int r,g,b,a;
11415 GetColor(r,g,b,a);
11416 r = r/255;
11417 g = g/255;
11418 b = b/255;
11419 a = a/255;
11420 return MiscGameplayFunctions.GetColorString(r, g, b, a);
11421 }
11422 //----------------------------------------------------------------
11423 //------------------------- LiquidType
11424
11425 override void SetLiquidType(int value, bool allow_client = false)
11426 {
11427 if (!IsServerCheck(allow_client))
11428 return;
11429
11430 int old = m_VarLiquidType;
11431 m_VarLiquidType = value;
11432 OnLiquidTypeChanged(old,value);
11433 SetVariableMask(VARIABLE_LIQUIDTYPE);
11434 }
11435
11436 int GetLiquidTypeInit()
11437 {
11438 return ConfigGetInt("varLiquidTypeInit");
11439 }
11440
11441 override int GetLiquidType()
11442 {
11443 return m_VarLiquidType;
11444 }
11445
11446 protected void OnLiquidTypeChanged(int oldType, int newType)
11447 {
11448 if (newType == LIQUID_NONE && GetIsFrozen())
11449 SetFrozen(false);
11450 }
11451
11453 void UpdateQuickbarShortcutVisibility(PlayerBase player)
11454 {
11455 player.SetEnableQuickBarEntityShortcut(this,!GetHierarchyParent() || GetHierarchyParent().GetInventory().AreChildrenAccessible());
11456 }
11457
11458 // -------------------------------------------------------------------------
11460 void OnInventoryEnter(Man player)
11461 {
11462 PlayerBase nplayer;
11463 if (PlayerBase.CastTo(nplayer, player))
11464 {
11465 m_CanPlayImpactSound = true;
11466 //nplayer.OnItemInventoryEnter(this);
11467 nplayer.SetEnableQuickBarEntityShortcut(this,!GetHierarchyParent() || GetHierarchyParent().GetInventory().AreChildrenAccessible());
11468 }
11469 }
11470
11471 // -------------------------------------------------------------------------
11473 void OnInventoryExit(Man player)
11474 {
11475 PlayerBase nplayer;
11476 if (PlayerBase.CastTo(nplayer,player))
11477 {
11478 //nplayer.OnItemInventoryExit(this);
11479 nplayer.SetEnableQuickBarEntityShortcut(this,false);
11480
11481 }
11482
11483 //if (!GetGame().IsDedicatedServer())
11484 player.GetHumanInventory().ClearUserReservedLocationForContainer(this);
11485
11486
11487 if (HasEnergyManager())
11488 {
11489 GetCompEM().UpdatePlugState(); // Unplug the el. device if it's necesarry.
11490 }
11491 }
11492
11493 // ADVANCED PLACEMENT EVENTS
11494 override void OnPlacementStarted(Man player)
11495 {
11496 super.OnPlacementStarted(player);
11497
11498 SetTakeable(false);
11499 }
11500
11501 override void OnPlacementComplete(Man player, vector position = "0 0 0", vector orientation = "0 0 0")
11502 {
11503 if (m_AdminLog)
11504 {
11505 m_AdminLog.OnPlacementComplete(player, this);
11506 }
11507
11508 super.OnPlacementComplete(player, position, orientation);
11509 }
11510
11511 //-----------------------------
11512 // AGENT SYSTEM
11513 //-----------------------------
11514 //--------------------------------------------------------------------------
11515 bool ContainsAgent(int agent_id)
11516 {
11517 if (agent_id & m_AttachedAgents)
11518 {
11519 return true;
11520 }
11521 else
11522 {
11523 return false;
11524 }
11525 }
11526
11527 //--------------------------------------------------------------------------
11528 override void RemoveAgent(int agent_id)
11529 {
11530 if (ContainsAgent(agent_id))
11531 {
11532 m_AttachedAgents = ~agent_id & m_AttachedAgents;
11533 }
11534 }
11535
11536 //--------------------------------------------------------------------------
11537 override void RemoveAllAgents()
11538 {
11539 m_AttachedAgents = 0;
11540 }
11541 //--------------------------------------------------------------------------
11542 override void RemoveAllAgentsExcept(int agent_to_keep)
11543 {
11544 m_AttachedAgents = m_AttachedAgents & agent_to_keep;
11545 }
11546 // -------------------------------------------------------------------------
11547 override void InsertAgent(int agent, float count = 1)
11548 {
11549 if (count < 1)
11550 return;
11551 //Debug.Log("Inserting Agent on item: " + agent.ToString() +" count: " + count.ToString());
11553 }
11554
11556 void TransferAgents(int agents)
11557 {
11559 }
11560
11561 // -------------------------------------------------------------------------
11562 override int GetAgents()
11563 {
11564 return m_AttachedAgents;
11565 }
11566 //----------------------------------------------------------------------
11567
11568 /*int GetContaminationType()
11569 {
11570 int contamination_type;
11571
11572 const int CONTAMINATED_MASK = eAgents.CHOLERA | eAgents.INFLUENZA | eAgents.SALMONELLA | eAgents.BRAIN;
11573 const int POISONED_MASK = eAgents.FOOD_POISON | eAgents.CHEMICAL_POISON;
11574 const int NERVE_GAS_MASK = eAgents.CHEMICAL_POISON;
11575 const int DIRTY_MASK = eAgents.WOUND_AGENT;
11576
11577 Edible_Base edible = Edible_Base.Cast(this);
11578 int agents = GetAgents();
11579 if (edible)
11580 {
11581 NutritionalProfile profile = Edible_Base.GetNutritionalProfile(edible);
11582 if (profile)
11583 {
11584 agents = agents | profile.GetAgents();//merge item's agents with nutritional agents
11585 }
11586 }
11587 if (agents & CONTAMINATED_MASK)
11588 {
11589 contamination_type = contamination_type | EContaminationTypes.ITEM_BADGE_CONTAMINATED;
11590 }
11591 if (agents & POISONED_MASK)
11592 {
11593 contamination_type = contamination_type | EContaminationTypes.ITEM_BADGE_POISONED;
11594 }
11595 if (agents & NERVE_GAS_MASK)
11596 {
11597 contamination_type = contamination_type | EContaminationTypes.ITEM_BADGE_NERVE_GAS;
11598 }
11599 if (agents & DIRTY_MASK)
11600 {
11601 contamination_type = contamination_type | EContaminationTypes.ITEM_BADGE_DIRTY;
11602 }
11603
11604 return agents;
11605 }*/
11606
11607 // -------------------------------------------------------------------------
11608 bool LoadAgents(ParamsReadContext ctx, int version)
11609 {
11610 if (!ctx.Read(m_AttachedAgents))
11611 return false;
11612 return true;
11613 }
11614 // -------------------------------------------------------------------------
11616 {
11617
11619 }
11620 // -------------------------------------------------------------------------
11621
11623 override void CheckForRoofLimited(float timeTresholdMS = 3000)
11624 {
11625 super.CheckForRoofLimited(timeTresholdMS);
11626
11627 float time = GetGame().GetTime();
11628 if ((time - m_PreviousRoofTestTime) >= timeTresholdMS)
11629 {
11630 m_PreviousRoofTestTime = time;
11631 SetRoofAbove(MiscGameplayFunctions.IsUnderRoof(this));
11632 }
11633 }
11634
11635 // returns item's protection level against enviromental hazard, for masks with filters, returns the filters protection for valid filter, otherwise 0
11636 float GetProtectionLevel(int type, bool consider_filter = false, int system = 0)
11637 {
11638 if (IsDamageDestroyed() || (HasQuantity() && GetQuantity() <= 0))
11639 {
11640 return 0;
11641 }
11642
11643 if (GetInventory().GetAttachmentSlotsCount() != 0)//is it an item with attachable filter ?
11644 {
11645 ItemBase filter = ItemBase.Cast(FindAttachmentBySlotName("GasMaskFilter"));
11646 if (filter)
11647 return filter.GetProtectionLevel(type, false, system);//it's a valid filter, return the protection
11648 else
11649 return 0;//otherwise return 0 when no filter attached
11650 }
11651
11652 string subclassPath, entryName;
11653
11654 switch (type)
11655 {
11656 case DEF_BIOLOGICAL:
11657 entryName = "biological";
11658 break;
11659 case DEF_CHEMICAL:
11660 entryName = "chemical";
11661 break;
11662 default:
11663 entryName = "biological";
11664 break;
11665 }
11666
11667 subclassPath = "CfgVehicles " + this.GetType() + " Protection ";
11668
11669 return GetGame().ConfigGetFloat(subclassPath + entryName);
11670 }
11671
11672
11673
11675 override void EEOnCECreate()
11676 {
11677 if (!IsMagazine())
11679
11681 }
11682
11683
11684 //-------------------------
11685 // OPEN/CLOSE USER ACTIONS
11686 //-------------------------
11688 void Open();
11689 void Close();
11690 bool IsOpen()
11691 {
11692 return true;
11693 }
11694
11695 override bool CanDisplayCargo()
11696 {
11697 return IsOpen();
11698 }
11699
11700
11701 // ------------------------------------------------------------
11702 // CONDITIONS
11703 // ------------------------------------------------------------
11704 override bool CanPutInCargo(EntityAI parent)
11705 {
11706 if (parent)
11707 {
11708 if (parent.IsInherited(DayZInfected))
11709 return true;
11710
11711 if (!parent.IsRuined())
11712 return true;
11713 }
11714
11715 return true;
11716 }
11717
11718 override bool CanPutAsAttachment(EntityAI parent)
11719 {
11720 if (!super.CanPutAsAttachment(parent))
11721 {
11722 return false;
11723 }
11724
11725 if (!IsRuined() && !parent.IsRuined())
11726 {
11727 return true;
11728 }
11729
11730 return false;
11731 }
11732
11733 override bool CanReceiveItemIntoCargo(EntityAI item)
11734 {
11735 //removed 15.06. coz of loading from storage -> after load items in cargo was lost -> waiting for proper solution
11736 //if (GetHealthLevel() == GameConstants.STATE_RUINED)
11737 // return false;
11738
11739 return super.CanReceiveItemIntoCargo(item);
11740 }
11741
11742 override bool CanReceiveAttachment(EntityAI attachment, int slotId)
11743 {
11744 //removed 15.06. coz of loading from storage -> after load items in cargo was lost -> waiting for proper solution
11745 //if (GetHealthLevel() == GameConstants.STATE_RUINED)
11746 // return false;
11747
11748 GameInventory attachmentInv = attachment.GetInventory();
11749 if (attachmentInv && attachmentInv.GetCargo() && attachmentInv.GetCargo().GetItemCount() > 0)
11750 {
11751 if (GetHierarchyParent() && !GetHierarchyParent().IsInherited(PlayerBase))
11752 return false;
11753 }
11754
11755 InventoryLocation loc = new InventoryLocation();
11756 attachment.GetInventory().GetCurrentInventoryLocation(loc);
11757 if (loc && loc.IsValid() && !GetInventory().AreChildrenAccessible())
11758 return false;
11759
11760 return super.CanReceiveAttachment(attachment, slotId);
11761 }
11762
11763 override bool CanReleaseAttachment(EntityAI attachment)
11764 {
11765 if (!super.CanReleaseAttachment(attachment))
11766 return false;
11767
11768 return GetInventory().AreChildrenAccessible();
11769 }
11770
11771 /*override bool CanLoadAttachment(EntityAI attachment)
11772 {
11773 //removed 15.06. coz of loading from storage -> after load items in cargo was lost -> waiting for proper solution
11774 //if (GetHealthLevel() == GameConstants.STATE_RUINED)
11775 // return false;
11776
11777 GameInventory attachmentInv = attachment.GetInventory();
11778 if (attachmentInv && attachmentInv.GetCargo() && attachmentInv.GetCargo().GetItemCount() > 0)
11779 {
11780 bool boo = (GetHierarchyParent() && !GetHierarchyParent().IsInherited(PlayerBase));
11781 ErrorEx("CanLoadAttachment | this: " + this + " | attachment: " + attachment + " | boo: " + boo,ErrorExSeverity.INFO);
11782
11783 if (GetHierarchyParent() && !GetHierarchyParent().IsInherited(PlayerBase))
11784 return false;
11785 }
11786
11787 return super.CanLoadAttachment(attachment);
11788 }*/
11789
11790 // Plays muzzle flash particle effects
11791 static void PlayFireParticles(ItemBase weapon, int muzzle_index, string ammoType, ItemBase muzzle_owner, ItemBase suppressor, string config_to_search)
11792 {
11793 int id = muzzle_owner.GetMuzzleID();
11794 array<ref WeaponParticlesOnFire> WPOF_array = m_OnFireEffect.Get(id);
11795
11796 if (WPOF_array)
11797 {
11798 for (int i = 0; i < WPOF_array.Count(); i++)
11799 {
11800 WeaponParticlesOnFire WPOF = WPOF_array.Get(i);
11801
11802 if (WPOF)
11803 {
11804 WPOF.OnActivate(weapon, muzzle_index, ammoType, muzzle_owner, suppressor, config_to_search);
11805 }
11806 }
11807 }
11808 }
11809
11810 // Plays bullet eject particle effects (usually just smoke, the bullet itself is a 3D model and is not part of this function)
11811 static void PlayBulletCasingEjectParticles(ItemBase weapon, string ammoType, ItemBase muzzle_owner, ItemBase suppressor, string config_to_search)
11812 {
11813 int id = muzzle_owner.GetMuzzleID();
11814 array<ref WeaponParticlesOnBulletCasingEject> WPOBE_array = m_OnBulletCasingEjectEffect.Get(id);
11815
11816 if (WPOBE_array)
11817 {
11818 for (int i = 0; i < WPOBE_array.Count(); i++)
11819 {
11820 WeaponParticlesOnBulletCasingEject WPOBE = WPOBE_array.Get(i);
11821
11822 if (WPOBE)
11823 {
11824 WPOBE.OnActivate(weapon, 0, ammoType, muzzle_owner, suppressor, config_to_search);
11825 }
11826 }
11827 }
11828 }
11829
11830 // Plays all weapon overheating particles
11831 static void PlayOverheatingParticles(ItemBase weapon, string ammoType, ItemBase muzzle_owner, ItemBase suppressor, string config_to_search)
11832 {
11833 int id = muzzle_owner.GetMuzzleID();
11834 array<ref WeaponParticlesOnOverheating> WPOOH_array = weapon.m_OnOverheatingEffect.Get(id);
11835
11836 if (WPOOH_array)
11837 {
11838 for (int i = 0; i < WPOOH_array.Count(); i++)
11839 {
11840 WeaponParticlesOnOverheating WPOOH = WPOOH_array.Get(i);
11841
11842 if (WPOOH)
11843 {
11844 WPOOH.OnActivate(weapon, 0, ammoType, muzzle_owner, suppressor, config_to_search);
11845 }
11846 }
11847 }
11848 }
11849
11850 // Updates all weapon overheating particles
11851 static void UpdateOverheatingParticles(ItemBase weapon, string ammoType, ItemBase muzzle_owner, ItemBase suppressor, string config_to_search)
11852 {
11853 int id = muzzle_owner.GetMuzzleID();
11854 array<ref WeaponParticlesOnOverheating> WPOOH_array = weapon.m_OnOverheatingEffect.Get(id);
11855
11856 if (WPOOH_array)
11857 {
11858 for (int i = 0; i < WPOOH_array.Count(); i++)
11859 {
11860 WeaponParticlesOnOverheating WPOOH = WPOOH_array.Get(i);
11861
11862 if (WPOOH)
11863 {
11864 WPOOH.OnUpdate(weapon, ammoType, muzzle_owner, suppressor, config_to_search);
11865 }
11866 }
11867 }
11868 }
11869
11870 // Stops overheating particles
11871 static void StopOverheatingParticles(ItemBase weapon, string ammoType, ItemBase muzzle_owner, ItemBase suppressor, string config_to_search)
11872 {
11873 int id = muzzle_owner.GetMuzzleID();
11874 array<ref WeaponParticlesOnOverheating> WPOOH_array = weapon.m_OnOverheatingEffect.Get(id);
11875
11876 if (WPOOH_array)
11877 {
11878 for (int i = 0; i < WPOOH_array.Count(); i++)
11879 {
11880 WeaponParticlesOnOverheating WPOOH = WPOOH_array.Get(i);
11881
11882 if (WPOOH)
11883 {
11884 WPOOH.OnDeactivate(weapon, ammoType, muzzle_owner, suppressor, config_to_search);
11885 }
11886 }
11887 }
11888 }
11889
11890 //----------------------------------------------------------------
11891 //Item Behaviour - unified approach
11892 override bool IsHeavyBehaviour()
11893 {
11894 if (m_ItemBehaviour == 0)
11895 {
11896 return true;
11897 }
11898
11899 return false;
11900 }
11901
11902 override bool IsOneHandedBehaviour()
11903 {
11904 if (m_ItemBehaviour == 1)
11905 {
11906 return true;
11907 }
11908
11909 return false;
11910 }
11911
11912 override bool IsTwoHandedBehaviour()
11913 {
11914 if (m_ItemBehaviour == 2)
11915 {
11916 return true;
11917 }
11918
11919 return false;
11920 }
11921
11922 bool IsDeployable()
11923 {
11924 return false;
11925 }
11926
11928 float GetDeployTime()
11929 {
11930 return UATimeSpent.DEFAULT_DEPLOY;
11931 }
11932
11933
11934 //----------------------------------------------------------------
11935 // Item Targeting (User Actions)
11936 override void SetTakeable(bool pState)
11937 {
11938 m_IsTakeable = pState;
11939 SetSynchDirty();
11940 }
11941
11942 override bool IsTakeable()
11943 {
11944 return m_IsTakeable;
11945 }
11946
11947 // For cases where we want to show object widget which cant be taken to hands
11949 {
11950 return false;
11951 }
11952
11954 protected void PreLoadSoundAttachmentType()
11955 {
11956 string att_type = "None";
11957
11958 if (ConfigIsExisting("soundAttType"))
11959 {
11960 att_type = ConfigGetString("soundAttType");
11961 }
11962
11963 m_SoundAttType = att_type;
11964 }
11965
11966 override string GetAttachmentSoundType()
11967 {
11968 return m_SoundAttType;
11969 }
11970
11971 //----------------------------------------------------------------
11972 //SOUNDS - ItemSoundHandler
11973 //----------------------------------------------------------------
11974
11975 string GetPlaceSoundset(); // played when deploy starts
11976 string GetLoopDeploySoundset(); // played when deploy starts and stopped when it finishes
11977 string GetDeploySoundset(); // played when deploy sucessfully finishes
11978
11980 {
11981 if (!m_ItemSoundHandler)
11983
11984 return m_ItemSoundHandler;
11985 }
11986
11987 // override to initialize sounds
11988 protected void InitItemSounds()
11989 {
11990 if (GetPlaceSoundset() == string.Empty && GetDeploySoundset() == string.Empty && GetLoopDeploySoundset() == string.Empty)
11991 return;
11992
11994
11995 if (GetPlaceSoundset() != string.Empty)
11996 handler.AddSound(SoundConstants.ITEM_PLACE, GetPlaceSoundset());
11997
11998 if (GetDeploySoundset() != string.Empty)
11999 handler.AddSound(SoundConstants.ITEM_DEPLOY, GetDeploySoundset());
12000
12001 SoundParameters params = new SoundParameters();
12002 params.m_Loop = true;
12003 if (GetLoopDeploySoundset() != string.Empty)
12004 handler.AddSound(SoundConstants.ITEM_DEPLOY_LOOP, GetLoopDeploySoundset(), params);
12005 }
12006
12007 // Start sound using ItemSoundHandler
12008 void StartItemSoundServer(int id)
12009 {
12010 if (!GetGame().IsServer())
12011 return;
12012
12013 m_SoundSyncPlay = id;
12014 SetSynchDirty();
12015
12016 GetGame().GetCallQueue(CALL_CATEGORY_SYSTEM).Remove(ClearStartItemSoundServer); // in case one is queued already
12018 }
12019
12020 // Stop sound using ItemSoundHandler
12021 void StopItemSoundServer(int id)
12022 {
12023 if (!GetGame().IsServer())
12024 return;
12025
12026 m_SoundSyncStop = id;
12027 SetSynchDirty();
12028
12029 GetGame().GetCallQueue(CALL_CATEGORY_SYSTEM).Remove(ClearStopItemSoundServer); // in case one is queued already
12031 }
12032
12033 protected void ClearStartItemSoundServer()
12034 {
12035 m_SoundSyncPlay = 0;
12036 }
12037
12038 protected void ClearStopItemSoundServer()
12039 {
12040 m_SoundSyncStop = 0;
12041 }
12042
12044 void PlayAttachSound(string slot_type)
12045 {
12046 if (!GetGame().IsDedicatedServer())
12047 {
12048 if (ConfigIsExisting("attachSoundSet"))
12049 {
12050 string cfg_path = "";
12051 string soundset = "";
12052 string type_name = GetType();
12053
12054 TStringArray cfg_soundset_array = new TStringArray;
12055 TStringArray cfg_slot_array = new TStringArray;
12056 ConfigGetTextArray("attachSoundSet",cfg_soundset_array);
12057 ConfigGetTextArray("attachSoundSlot",cfg_slot_array);
12058
12059 if (cfg_soundset_array.Count() > 0 && cfg_soundset_array.Count() == cfg_slot_array.Count())
12060 {
12061 for (int i = 0; i < cfg_soundset_array.Count(); i++)
12062 {
12063 if (cfg_slot_array[i] == slot_type)
12064 {
12065 soundset = cfg_soundset_array[i];
12066 break;
12067 }
12068 }
12069 }
12070
12071 if (soundset != "")
12072 {
12073 EffectSound sound = SEffectManager.PlaySound(soundset, GetPosition());
12074 sound.SetAutodestroy(true);
12075 }
12076 }
12077 }
12078 }
12079
12080 void PlayDetachSound(string slot_type)
12081 {
12082 //TODO - evaluate if needed and devise universal config structure if so
12083 }
12084
12085 void OnApply(PlayerBase player);
12086
12088 {
12089 return 1.0;
12090 };
12091 //returns applicable selection
12092 array<string> GetHeadHidingSelection()
12093 {
12095 }
12096
12098 {
12100 }
12101
12102 WrittenNoteData GetWrittenNoteData() {};
12103
12105 {
12106 SetDynamicPhysicsLifeTime(0.01);
12107 m_ItemBeingDroppedPhys = false;
12108 }
12109
12111 {
12112 array<string> zone_names = new array<string>;
12113 GetDamageZones(zone_names);
12114 for (int i = 0; i < zone_names.Count(); i++)
12115 {
12116 SetHealthMax(zone_names.Get(i),"Health");
12117 }
12118 SetHealthMax("","Health");
12119 }
12120
12122 void SetZoneDamageCEInit()
12123 {
12124 float global_health = GetHealth01("","Health");
12125 array<string> zones = new array<string>;
12126 GetDamageZones(zones);
12127 //set damage of all zones to match global health level
12128 for (int i = 0; i < zones.Count(); i++)
12129 {
12130 SetHealth01(zones.Get(i),"Health",global_health);
12131 }
12132 }
12133
12135 bool IsCoverFaceForShave(string slot_name)
12136 {
12137 return IsExclusionFlagPresent(PlayerBase.GetFaceCoverageShaveValues());
12138 }
12139
12140 void ProcessItemWetness(float delta, bool hasParent, bool hasRootAsPlayer, ItemBase refParentIB)
12141 {
12142 if (!hasRootAsPlayer)
12143 {
12144 if (refParentIB)
12145 {
12146 // parent is wet
12147 if ((refParentIB.GetWet() >= GameConstants.STATE_SOAKING_WET) && (m_VarWet < m_VarWetMax))
12148 AddWet(delta * GameConstants.WETNESS_RATE_WETTING_INSIDE);
12149 // parent has liquid inside
12150 else if ((refParentIB.GetLiquidType() != 0) && (refParentIB.GetQuantity() > 0) && (m_VarWet < m_VarWetMax))
12151 AddWet(delta * GameConstants.WETNESS_RATE_WETTING_LIQUID);
12152 // drying
12153 else if (m_VarWet > m_VarWetMin)
12154 AddWet(-1 * delta * GetDryingIncrement("ground") * 2);
12155 }
12156 else
12157 {
12158 // drying on ground or inside non-itembase (car, ...)
12159 if (m_VarWet > m_VarWetMin)
12160 AddWet(-1 * delta * GetDryingIncrement("ground"));
12161 }
12162 }
12163 }
12164
12165 void ProcessItemTemperature(float delta, bool hasParent, bool hasRootAsPlayer, ItemBase refParentIB)
12166 {
12168 {
12169 float target = g_Game.GetMission().GetWorldData().GetBaseEnvTemperatureAtObject(this);
12170 if (GetTemperature() != target || !IsFreezeThawProgressFinished())
12171 {
12172 float heatPermCoef = 1.0;
12173 EntityAI ent = this;
12174 while (ent)
12175 {
12176 heatPermCoef *= ent.GetHeatPermeabilityCoef();
12177 ent = ent.GetHierarchyParent();
12178 }
12179
12180 SetTemperatureEx(new TemperatureDataInterpolated(target,ETemperatureAccessTypes.ACCESS_WORLD,delta,GameConstants.TEMP_COEF_WORLD,heatPermCoef));
12181 }
12182 }
12183 }
12184
12185 void HierarchyCheck(out bool hasParent, out bool hasRootAsPlayer, out ItemBase refParentIB)
12186 {
12187 // hierarchy check for an item to decide whether it has some parent and it is in some player inventory
12188 EntityAI parent = GetHierarchyParent();
12189 if (!parent)
12190 {
12191 hasParent = false;
12192 hasRootAsPlayer = false;
12193 }
12194 else
12195 {
12196 hasParent = true;
12197 hasRootAsPlayer = (GetHierarchyRootPlayer() != null);
12198 refParentIB = ItemBase.Cast(parent);
12199 }
12200 }
12201
12202 protected void ProcessDecay(float delta, bool hasRootAsPlayer)
12203 {
12204 // this is stub, implemented on Edible_Base
12205 }
12206
12207 bool CanDecay()
12208 {
12209 // return true used on selected food clases so they can decay
12210 return false;
12211 }
12212
12213 protected bool CanProcessDecay()
12214 {
12215 // this is stub, implemented on Edible_Base class
12216 // used to determine whether it is still necessary for the food to decay
12217 return false;
12218 }
12219
12220 protected bool CanHaveWetness()
12221 {
12222 // return true used on selected items that have a wetness effect
12223 return false;
12224 }
12225
12227 bool CanBeConsumed(ConsumeConditionData data = null)
12228 {
12229 return !GetIsFrozen() && IsOpen();
12230 }
12231
12232 override void ProcessVariables()
12233 {
12234 bool hasParent = false, hasRootAsPlayer = false;
12235 ItemBase refParentIB;
12236
12237 bool wwtu = g_Game.IsWorldWetTempUpdateEnabled();
12238 bool foodDecay = g_Game.IsFoodDecayEnabled();
12239
12240 if (wwtu || foodDecay)
12241 {
12242 bool processWetness = wwtu && CanHaveWetness();
12243 bool processTemperature = wwtu && CanHaveTemperature();
12244 bool processDecay = foodDecay && CanDecay() && CanProcessDecay();
12245
12246 if (processWetness || processTemperature || processDecay)
12247 {
12248 HierarchyCheck(hasParent, hasRootAsPlayer, refParentIB);
12249
12250 if (processWetness)
12251 ProcessItemWetness(m_ElapsedSinceLastUpdate, hasParent, hasRootAsPlayer, refParentIB);
12252
12253 if (processTemperature)
12254 ProcessItemTemperature(m_ElapsedSinceLastUpdate, hasParent, hasRootAsPlayer, refParentIB);
12255
12256 if (processDecay)
12257 ProcessDecay(m_ElapsedSinceLastUpdate, hasRootAsPlayer);
12258 }
12259 }
12260 }
12261
12264 {
12265 return m_TemperaturePerQuantityWeight * GameConstants.ITEM_TEMPERATURE_QUANTITY_WEIGHT_MULTIPLIER;
12266 }
12267
12268 override float GetTemperatureFreezeThreshold()
12269 {
12271 return Liquid.GetFreezeThreshold(GetLiquidType());
12272
12273 return super.GetTemperatureFreezeThreshold();
12274 }
12275
12276 override float GetTemperatureThawThreshold()
12277 {
12279 return Liquid.GetThawThreshold(GetLiquidType());
12280
12281 return super.GetTemperatureThawThreshold();
12282 }
12283
12284 override float GetItemOverheatThreshold()
12285 {
12287 return Liquid.GetBoilThreshold(GetLiquidType());
12288
12289 return super.GetItemOverheatThreshold();
12290 }
12291
12292 override float GetTemperatureFreezeTime()
12293 {
12294 if (HasQuantity())
12295 return Math.Lerp(GameConstants.TEMPERATURE_TIME_FREEZE_MIN,Math.Max(GameConstants.TEMPERATURE_TIME_FREEZE_MIN,super.GetTemperatureFreezeTime()),GetQuantityNormalized());
12296
12297 return super.GetTemperatureFreezeTime();
12298 }
12299
12300 override float GetTemperatureThawTime()
12301 {
12302 if (HasQuantity())
12303 return Math.Lerp(GameConstants.TEMPERATURE_TIME_THAW_MIN,Math.Max(GameConstants.TEMPERATURE_TIME_FREEZE_MIN,super.GetTemperatureThawTime()),GetQuantityNormalized());
12304
12305 return super.GetTemperatureThawTime();
12306 }
12307
12309 void AffectLiquidContainerOnFill(int liquid_type, float amount);
12311 void AffectLiquidContainerOnTransfer(int liquidType, float amount, float sourceLiquidTemperature);
12312
12313 bool IsCargoException4x3(EntityAI item)
12314 {
12315 return (item.IsKindOf("Cauldron") || item.IsKindOf("Pot") || item.IsKindOf("FryingPan") || item.IsKindOf("SmallProtectorCase") || (item.IsKindOf("PortableGasStove") && item.FindAttachmentBySlotName("CookingEquipment")));
12316 }
12317
12319 {
12320 MiscGameplayFunctions.TransferItemProperties(oldItem, this);
12321 }
12322
12324 void AddLightSourceItem(ItemBase lightsource)
12325 {
12326 m_LightSourceItem = lightsource;
12327 }
12328
12330 {
12331 m_LightSourceItem = null;
12332 }
12333
12335 {
12336 return m_LightSourceItem;
12337 }
12338
12340 array<int> GetValidFinishers()
12341 {
12342 return null;
12343 }
12344
12346 bool GetActionWidgetOverride(out typename name)
12347 {
12348 return false;
12349 }
12350
12351 bool PairWithDevice(notnull ItemBase otherDevice)
12352 {
12353 if (GetGame().IsServer())
12354 {
12355 ItemBase explosive = otherDevice;
12357 if (!trg)
12358 {
12359 trg = RemoteDetonatorTrigger.Cast(otherDevice);
12360 explosive = this;
12361 }
12362
12363 explosive.PairRemote(trg);
12364 trg.SetControlledDevice(explosive);
12365
12366 int persistentID = RemotelyActivatedItemBehaviour.GeneratePersistentID();
12367 trg.SetPersistentPairID(persistentID);
12368 explosive.SetPersistentPairID(persistentID);
12369
12370 return true;
12371 }
12372 return false;
12373 }
12374
12376 float GetBaitEffectivity()
12377 {
12378 float ret = 1.0;
12379 if (HasQuantity())
12380 ret *= GetQuantityNormalized();
12381 ret *= GetHealth01();
12382
12383 return ret;
12384 }
12385
12386 #ifdef DEVELOPER
12387 override void SetDebugItem()
12388 {
12389 super.SetDebugItem();
12390 _itemBase = this;
12391 }
12392
12393 override string GetDebugText()
12394 {
12395 string text = super.GetDebugText();
12396
12397 text += string.Format("Heat isolation(raw): %1\n", GetHeatIsolation());
12398 text += string.Format("Heat isolation(modified): %1\n", MiscGameplayFunctions.GetCurrentItemHeatIsolation(this));
12399
12400 return text;
12401 }
12402 #endif
12403
12404 bool CanBeUsedForSuicide()
12405 {
12406 return true;
12407 }
12408
12410 //DEPRECATED BELOW
12412 // Backwards compatibility
12413 void ProcessItemWetnessAndTemperature(float delta, bool hasParent, bool hasRootAsPlayer, ItemBase refParentIB)
12414 {
12415 ProcessItemWetness(delta, hasParent, hasRootAsPlayer, refParentIB);
12416 ProcessItemTemperature(delta, hasParent, hasRootAsPlayer, refParentIB);
12417 }
12418
12419 // replaced by ItemSoundHandler
12420 protected EffectSound m_SoundDeployFinish;
12421 protected EffectSound m_SoundPlace;
12422 protected EffectSound m_DeployLoopSoundEx;
12423 protected EffectSound m_SoundDeploy;
12424 bool m_IsPlaceSound;
12425 bool m_IsDeploySound;
12427
12428 string GetDeployFinishSoundset();
12429 void PlayDeploySound();
12430 void PlayDeployFinishSound();
12431 void PlayPlaceSound();
12432 void PlayDeployLoopSoundEx();
12433 void StopDeployLoopSoundEx();
12434 void SoundSynchRemoteReset();
12435 void SoundSynchRemote();
12436 bool UsesGlobalDeploy(){return false;}
12437 bool CanPlayDeployLoopSound(){return false;}
12439 bool IsPlaceSound(){return m_IsPlaceSound;}
12440 bool IsDeploySound(){return m_IsDeploySound;}
12441 void SetIsPlaceSound(bool is_place_sound);
12442 void SetIsDeploySound(bool is_deploy_sound);
12443}
12444
12445EntityAI SpawnItemOnLocation(string object_name, notnull InventoryLocation loc, bool full_quantity)
12446{
12447 EntityAI entity = SpawnEntity(object_name, loc, ECE_IN_INVENTORY, RF_DEFAULT);
12448 if (entity)
12449 {
12450 bool is_item = entity.IsInherited(ItemBase);
12451 if (is_item && full_quantity)
12452 {
12453 ItemBase item = ItemBase.Cast(entity);
12454 item.SetQuantity(item.GetQuantityInit());
12455 }
12456 }
12457 else
12458 {
12459 ErrorEx("Cannot spawn entity: " + object_name,ErrorExSeverity.INFO);
12460 return NULL;
12461 }
12462 return entity;
12463}
12464
12465void SetupSpawnedItem(ItemBase item, float health, float quantity)
12466{
12467 if (item)
12468 {
12469 if (health > 0)
12470 item.SetHealth("", "", health);
12471
12472 if (item.CanHaveTemperature())
12473 {
12474 item.SetTemperatureDirect(GameConstants.ITEM_TEMPERATURE_NEUTRAL_ZONE_MIDDLE);
12475 if (item.CanFreeze())
12476 item.SetFrozen(false);
12477 }
12478
12479 if (item.HasEnergyManager())
12480 {
12481 if (quantity >= 0)
12482 {
12483 item.GetCompEM().SetEnergy0To1(quantity);
12484 }
12485 else
12486 {
12487 item.GetCompEM().SetEnergy(Math.AbsFloat(quantity));
12488 }
12489 }
12490 else if (item.IsMagazine())
12491 {
12492 Magazine mag = Magazine.Cast(item);
12493 if (quantity >= 0)
12494 {
12495 mag.ServerSetAmmoCount(mag.GetAmmoMax() * quantity);
12496 }
12497 else
12498 {
12499 mag.ServerSetAmmoCount(Math.AbsFloat(quantity));
12500 }
12501
12502 }
12503 else
12504 {
12505 if (quantity >= 0)
12506 {
12507 item.SetQuantityNormalized(quantity, false);
12508 }
12509 else
12510 {
12511 item.SetQuantity(Math.AbsFloat(quantity));
12512 }
12513
12514 }
12515 }
12516}
12517
12518#ifdef DEVELOPER
12519ItemBase _itemBase;//watched item goes here(LCTRL+RMB->Watch)
12520#endif
Param4< int, int, string, int > TSelectableActionInfoWithColor
Определения EntityAI.c:97
Param3 TSelectableActionInfo
EWetnessLevel
Определения EntityAI.c:2
InventoryMode
NOTE: PREDICTIVE is not to be used at all in multiplayer.
Определения Inventory.c:22
const int INPUT_UDT_ITEM_MANIPULATION
Определения _constants.c:8
class LogManager EntityAI
eBleedingSourceType GetType()
Определения BleedingSource.c:63
ItemSuppressor SuppressorBase
Определения InventoryItem.c:7
void ActionDropItem()
Определения ActionDropItem.c:14
void ActionManagerBase(PlayerBase player)
Определения ActionManagerBase.c:63
map< typename, ref array< ActionBase_Basic > > TInputActionMap
Определения ActionManagerClient.c:1
void AddAction(typename actionName)
Определения AdvancedCommunication.c:220
void RemoveAction(typename actionName)
Определения AdvancedCommunication.c:252
TInputActionMap m_InputActionMap
Определения AdvancedCommunication.c:137
bool m_ActionsInitialize
Определения AdvancedCommunication.c:138
override void GetActions(typename action_input_type, out array< ActionBase_Basic > actions)
Определения AdvancedCommunication.c:202
void InitializeActions()
Определения AdvancedCommunication.c:190
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
map
Определения ControlsXboxNew.c:4
CookingMethodType
Определения Cooking.c:2
DamageType
exposed from C++ (do not change)
Определения DamageSystem.c:11
DayZGame g_Game
Определения DayZGame.c:3868
DayZGame GetDayZGame()
Определения DayZGame.c:3870
EActions
Определения EActions.c:2
ERPCs
Определения ERPCs.c:2
PluginAdminLog m_AdminLog
Определения EmoteManager.c:142
const int MAX
Определения EnConvert.c:27
override bool IsExplosive()
Определения ExplosivesBase.c:59
override bool CanHaveTemperature()
Определения FireplaceBase.c:557
class GP5GasMask extends MaskBase ItemBase
Empty
Определения Hand_States.c:14
FindInventoryLocationType
flags for searching locations in inventory
Определения InventoryLocation.c:17
InventoryLocationType
types of Inventory Location
Определения InventoryLocation.c:4
class BoxCollidingParams component
ComponentInfo for BoxCollidingResult.
bool DamageItemInCargo(float damage)
Определения ItemBase.c:6308
static bool HasDebugActionsMask(int mask)
Определения ItemBase.c:5548
bool HidesSelectionBySlot()
Определения ItemBase.c:9203
float m_VarWetMin
Определения ItemBase.c:4809
void SplitItem(PlayerBase player)
Определения ItemBase.c:6739
void CopyScriptPropertiesFrom(EntityAI oldItem)
Определения ItemBase.c:9424
override void InsertAgent(int agent, float count=1)
Определения ItemBase.c:8653
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:8087
static void SetDebugActionsMask(int mask)
Определения ItemBase.c:5553
void SetIsDeploySound(bool is_deploy_sound)
bool IsOpen()
Определения ItemBase.c:8796
void SplitItemToInventoryLocation(notnull InventoryLocation dst)
Определения ItemBase.c:6706
override bool IsHeavyBehaviour()
Определения ItemBase.c:8998
override void SetWetMax()
Определения ItemBase.c:8369
bool IsCoverFaceForShave(string slot_name)
DEPRECATED in use, but returns correct values nontheless. Check performed elsewhere.
Определения ItemBase.c:9241
void ClearStartItemSoundServer()
Определения ItemBase.c:9139
float m_VarWet
Определения ItemBase.c:4806
void ProcessItemTemperature(float delta, bool hasParent, bool hasRootAsPlayer, ItemBase refParentIB)
Определения ItemBase.c:9271
map< typename, ref ActionOverrideData > TActionAnimOverrideMap
Определения ItemBase.c:2
override void RemoveAllAgentsExcept(int agent_to_keep)
Определения ItemBase.c:8648
static ref map< int, ref array< ref WeaponParticlesOnBulletCasingEject > > m_OnBulletCasingEjectEffect
Определения ItemBase.c:4869
bool CanBeMovedOverride()
Определения ItemBase.c:7380
override void SetWet(float value, bool allow_client=false)
Определения ItemBase.c:8345
ref TIntArray m_SingleUseActions
Определения ItemBase.c:4855
override void ProcessVariables()
Определения ItemBase.c:9338
ref TStringArray m_HeadHidingSelections
Определения ItemBase.c:4883
float GetWeightSpecialized(bool forceRecalc=false)
Определения ItemBase.c:8179
bool LoadAgents(ParamsReadContext ctx, int version)
Определения ItemBase.c:8714
void UpdateQuickbarShortcutVisibility(PlayerBase player)
To be called on moving item within character's inventory; 'player' should never be null.
Определения ItemBase.c:8559
void OverrideActionAnimation(typename action, int commandUID, int stanceMask=-1, int commandUIDProne=-1)
Определения ItemBase.c:5139
ref array< ref OverheatingParticle > m_OverheatingParticles
Определения ItemBase.c:4881
override float GetTemperatureFreezeThreshold()
Определения ItemBase.c:9374
bool m_IsSoundSynchRemote
Определения ItemBase.c:9532
float m_OverheatingShots
Определения ItemBase.c:4876
void StopItemSoundServer(int id)
Определения ItemBase.c:9127
static void ToggleDebugActionsMask(int mask)
Определения ItemBase.c:5568
void IncreaseOverheating(ItemBase weapon, string ammoType, ItemBase muzzle_owner, ItemBase suppressor, string config_to_search)
Определения ItemBase.c:5292
override float GetTemperatureFreezeTime()
Определения ItemBase.c:9398
ref array< int > m_CompatibleLocks
Определения ItemBase.c:4893
bool CanBeCooked()
Определения ItemBase.c:7336
override void CombineItemsClient(EntityAI entity2, bool use_stack_max=true)
Определения ItemBase.c:5635
float m_TemperaturePerQuantityWeight
Определения ItemBase.c:4905
bool m_RecipesInitialized
Определения ItemBase.c:4791
void SplitIntoStackMax(EntityAI destination_entity, int slot_id, PlayerBase player)
Определения ItemBase.c:6382
override float GetTemperatureThawThreshold()
Определения ItemBase.c:9382
override void OnEnergyConsumed()
Определения ItemBase.c:8289
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:8078
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:8218
override EWetnessLevel GetWetLevel()
Определения ItemBase.c:8409
float GetSingleInventoryItemWeight()
Определения ItemBase.c:8174
ref TIntArray m_InteractActions
Определения ItemBase.c:4857
void MessageToOwnerStatus(string text)
Send message to owner player in grey color.
Определения ItemBase.c:7400
float m_VarQuantity
Определения ItemBase.c:4797
bool CanPlayDeployLoopSound()
Определения ItemBase.c:9543
override float GetWetMax()
Определения ItemBase.c:8379
bool CanBeUsedForSuicide()
Определения ItemBase.c:9510
override void CombineItemsEx(EntityAI entity2, bool use_stack_max=true)
Определения ItemBase.c:7011
void OnItemInHandsPlayerSwimStart(PlayerBase player)
void SetIsHologram(bool is_hologram)
Определения ItemBase.c:5773
void OnSyncVariables(ParamsReadContext ctx)
DEPRECATED (most likely)
Определения ItemBase.c:7554
void StartItemSoundServer(int id)
Определения ItemBase.c:9114
void DoAmmoExplosion()
Определения ItemBase.c:6243
static ref map< int, ref array< ref WeaponParticlesOnFire > > m_OnFireEffect
Определения ItemBase.c:4868
void SplitIntoStackMaxCargoClient(EntityAI destination_entity, int idx, int row, int col)
Определения ItemBase.c:6557
int GetItemSize()
Определения ItemBase.c:7365
bool m_CanBeMovedOverride
Определения ItemBase.c:4834
override string ChangeIntoOnAttach(string slot)
Определения ItemBase.c:6167
void UpdateOverheating(ItemBase weapon=null, string ammoType="", ItemBase muzzle_owner=null, ItemBase suppressor=null, string config_to_search="")
Определения ItemBase.c:5360
bool CanDecay()
Определения ItemBase.c:9313
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:8060
void SetQuantityMax()
Определения ItemBase.c:8065
override float GetQuantity()
Определения ItemBase.c:8154
int m_ColorComponentR
Определения ItemBase.c:4846
int m_ShotsToStartOverheating
Определения ItemBase.c:4878
override void OnWetChanged(float newVal, float oldVal)
Определения ItemBase.c:8394
void StopOverheating(ItemBase weapon=null, string ammoType="", ItemBase muzzle_owner=null, ItemBase suppressor=null, string config_to_search="")
Определения ItemBase.c:5367
static void PlayFireParticles(ItemBase weapon, int muzzle_index, string ammoType, ItemBase muzzle_owner, ItemBase suppressor, string config_to_search)
Определения ItemBase.c:8897
void OnOverheatingDecay()
Определения ItemBase.c:5330
float GetDryingIncrement(string pIncrementName)
Определения ItemBase.c:8327
void SoundSynchRemoteReset()
int m_Cleanness
Определения ItemBase.c:4812
bool HasMuzzle()
Returns true if this item has a muzzle (weapons, suppressors)
Определения ItemBase.c:5468
bool UsesGlobalDeploy()
Определения ItemBase.c:9542
int m_ItemBehaviour
Определения ItemBase.c:4827
override bool CanReleaseAttachment(EntityAI attachment)
Определения ItemBase.c:8869
float m_HeatIsolation
Определения ItemBase.c:4822
float m_VarWetInit
Определения ItemBase.c:4808
override void OnMovedInsideCargo(EntityAI container)
Определения ItemBase.c:5813
void SetCEBasedQuantity()
Определения ItemBase.c:5581
bool m_CanPlayImpactSound
Определения ItemBase.c:4818
override string GetAttachmentSoundType()
Определения ItemBase.c:9072
float GetOverheatingCoef()
Определения ItemBase.c:5387
array< string > GetHeadHidingSelection()
Определения ItemBase.c:9198
void PlayAttachSound(string slot_type)
Plays sound on item attach. Be advised, the config structure may slightly change in 1....
Определения ItemBase.c:9150
override bool IsStoreLoad()
Определения ItemBase.c:8421
int ComputeQuantityUsed(ItemBase other_item, bool use_stack_max=true)
Определения ItemBase.c:6987
bool IsLightSource()
Определения ItemBase.c:5709
bool m_HasQuantityBar
Определения ItemBase.c:4840
void SetResultOfSplit(bool value)
Определения ItemBase.c:6982
void SplitIntoStackMaxCargo(EntityAI destination_entity, int idx, int row, int col)
Определения ItemBase.c:6624
void OnAttachmentQuantityChanged(ItemBase item)
Called on server side when some attachment's quantity is changed. Call super.OnAttachmentQuantityChan...
Определения ItemBase.c:6797
void UpdateAllOverheatingParticles()
Определения ItemBase.c:5395
float GetSoakingIncrement(string pIncrementName)
Определения ItemBase.c:8336
static void StopOverheatingParticles(ItemBase weapon, string ammoType, ItemBase muzzle_owner, ItemBase suppressor, string config_to_search)
Определения ItemBase.c:8977
override float GetStoreLoadedQuantity()
Определения ItemBase.c:8431
int m_LockType
Определения ItemBase.c:4894
const int ITEM_SOUNDS_MAX
Определения ItemBase.c:4899
bool m_CanBeDigged
Определения ItemBase.c:4841
float m_ItemAttachOffset
Определения ItemBase.c:4824
float GetItemModelLength()
Определения ItemBase.c:8438
bool m_ThrowItemOnDrop
Определения ItemBase.c:4832
override bool ReadVarsFromCTX(ParamsReadContext ctx, int version=-1)
Определения ItemBase.c:7699
override void CheckForRoofLimited(float timeTresholdMS=3000)
Roof check for entity, limited by time (anti-spam solution)
Определения ItemBase.c:8729
void Close()
float GetHeatIsolation()
Определения ItemBase.c:8322
void CombineItems(ItemBase other_item, bool use_stack_max=true)
Определения ItemBase.c:7016
void TransferModifiers(PlayerBase reciever)
appears to be deprecated, legacy code
float GetTemperaturePerQuantityWeight()
Used in heat comfort calculations only!
Определения ItemBase.c:9369
bool CanHaveWetness()
Определения ItemBase.c:9326
int m_CleannessMin
Определения ItemBase.c:4814
void TransferAgents(int agents)
transfer agents from another item
Определения ItemBase.c:8662
string IDToName(int id)
Определения ItemBase.c:7547
bool CanBeConsumed(ConsumeConditionData data=null)
Items cannot be consumed if frozen by default. Override for exceptions.
Определения ItemBase.c:9333
float GetHeatIsolationInit()
Определения ItemBase.c:8317
void PlayPlaceSound()
void SetCanBeMovedOverride(bool setting)
Определения ItemBase.c:7387
override bool HasQuantity()
Определения ItemBase.c:8149
float m_VarWetPrev
Определения ItemBase.c:4807
int m_SoundSyncStop
Определения ItemBase.c:4901
bool IsCargoException4x3(EntityAI item)
Определения ItemBase.c:9419
ref TIntArray m_ContinuousActions
Определения ItemBase.c:4856
int GetMuzzleID()
Returns global muzzle ID. If not found, then it gets automatically registered.
Определения ItemBase.c:5477
void LoadParticleConfigOnFire(int id)
Определения ItemBase.c:5162
int m_VarLiquidType
Определения ItemBase.c:4826
int m_QuickBarBonus
Определения ItemBase.c:4828
void PreLoadSoundAttachmentType()
Attachment Sound Type getting from config file.
Определения ItemBase.c:9060
override float GetWetInit()
Определения ItemBase.c:8389
int m_ImpactSoundSurfaceHash
Определения ItemBase.c:4820
int m_SoundSyncPlay
Определения ItemBase.c:4900
int m_MaxOverheatingValue
Определения ItemBase.c:4879
void SetupSpawnedItem(ItemBase item, float health, float quantity)
Определения ItemBase.c:4803
bool m_IsTakeable
Определения ItemBase.c:4831
static ref map< string, int > m_WeaponTypeToID
Определения ItemBase.c:4871
string GetLockSoundSet()
Определения ItemBase.c:8487
string GetColorString()
Returns item's PROCEDURAL color as formated string, i.e. "#(argb,8,8,3)color(0.15,...
Определения ItemBase.c:8518
array< int > GetValidFinishers()
returns an array of possible finishers
Определения ItemBase.c:9446
void OnAttachmentQuantityChangedEx(ItemBase item, float delta)
Called on server side when some attachment's quantity is changed. Call super.OnAttachmentQuantityChan...
Определения ItemBase.c:6803
class ItemBase extends InventoryItem SpawnItemOnLocation(string object_name, notnull InventoryLocation loc, bool full_quantity)
Определения ItemBase.c:4783
ItemSoundHandler GetItemSoundHandler()
Определения ItemBase.c:9085
override int GetQuantityMin()
Определения ItemBase.c:8138
void SplitIntoStackMaxToInventoryLocationClient(notnull InventoryLocation dst)
Определения ItemBase.c:6533
override int GetQuickBarBonus()
Определения ItemBase.c:5047
override void SetTakeable(bool pState)
Определения ItemBase.c:9042
float m_OverheatingDecayInterval
Определения ItemBase.c:4880
void SetIsPlaceSound(bool is_place_sound)
override void SplitIntoStackMaxClient(EntityAI destination_entity, int slot_id)
Определения ItemBase.c:6356
void HierarchyCheck(out bool hasParent, out bool hasRootAsPlayer, out ItemBase refParentIB)
Определения ItemBase.c:9291
bool CanProcessDecay()
Определения ItemBase.c:9319
void RemoveAudioVisualsOnClient()
Определения Bottle_Base.c:151
void SoundSynchRemote()
static void AddDebugActionsMask(int mask)
Определения ItemBase.c:5558
void PlayDeployLoopSoundEx()
void RemoveLightSourceItem()
Определения ItemBase.c:9435
bool CanRepair(ItemBase item_repair_kit)
Определения ItemBase.c:7351
bool can_this_be_combined
Определения ItemBase.c:4836
EffectSound m_SoundDeploy
Определения ItemBase.c:9529
int m_Count
Определения ItemBase.c:4802
float GetBaitEffectivity()
generic effectivity as a bait for animal catching
Определения ItemBase.c:9482
float GetDeployTime()
how long it takes to deploy this item in seconds
Определения ItemBase.c:9034
override bool IsSplitable()
Определения ItemBase.c:6343
bool DamageItemAttachments(float damage)
Определения ItemBase.c:6327
override void WriteVarsToCTX(ParamsWriteContext ctx)
Определения ItemBase.c:7663
void ConvertEnergyToQuantity()
Определения ItemBase.c:8304
override void RemoveAllAgents()
Определения ItemBase.c:8643
override void SetQuantityToMinimum()
Определения ItemBase.c:8071
bool m_WantPlayImpactSound
Определения ItemBase.c:4817
override float GetTemperatureThawTime()
Определения ItemBase.c:9406
ref map< int, ref array< ref WeaponParticlesOnOverheating > > m_OnOverheatingEffect
Определения ItemBase.c:4870
int m_ColorComponentG
Определения ItemBase.c:4847
float m_StoreLoadedQuantity
Определения ItemBase.c:4804
void MessageToOwnerAction(string text)
Send message to owner player in yellow color.
Определения ItemBase.c:7418
int m_ColorComponentA
Определения ItemBase.c:4849
int m_VarQuantityInit
Определения ItemBase.c:4799
float GetFilterDamageRatio()
Определения ItemBase.c:5462
override void SetLiquidType(int value, bool allow_client=false)
Определения ItemBase.c:8531
void OnQuantityChanged(float delta)
Called on server side when this item's quantity is changed. Call super.OnQuantityChanged(); first whe...
Определения ItemBase.c:6773
void OnApply(PlayerBase player)
bool m_HideSelectionsBySlot
Определения ItemBase.c:4884
bool IsOverheatingEffectActive()
Определения ItemBase.c:5325
void SetIsBeingPlaced(bool is_being_placed)
Определения ItemBase.c:5742
int GetLiquidContainerMask()
Определения ItemBase.c:5679
ref Timer m_CheckOverheating
Определения ItemBase.c:4877
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:5373
float GetEnergy()
Определения ItemBase.c:8278
bool CanBeDigged()
Определения ItemBase.c:5758
bool GetActionWidgetOverride(out typename name)
If we need a different (handheld)item action widget displayed, the logic goes in here.
Определения ItemBase.c:9452
bool IsNVG()
Определения ItemBase.c:5690
float GetUnitWeight(bool include_wetness=true)
Obsolete, use GetWeightEx instead.
Определения ItemBase.c:8238
void SetZoneDamageCEInit()
Sets zone damages to match randomized global health set by CE (CE spawn only)
Определения ItemBase.c:9228
bool m_IsDeploySound
Определения ItemBase.c:9531
bool CanEat()
Определения ItemBase.c:7311
static void PlayOverheatingParticles(ItemBase weapon, string ammoType, ItemBase muzzle_owner, ItemBase suppressor, string config_to_search)
Определения ItemBase.c:8937
override bool IsOneHandedBehaviour()
Определения ItemBase.c:9008
void AddLightSourceItem(ItemBase lightsource)
Adds a light source child.
Определения ItemBase.c:9430
bool IsLiquidContainer()
Определения ItemBase.c:5674
FoodStage GetFoodStage()
overridden on Edible_Base; so we don't have to parse configs all the time
Определения ItemBase.c:7331
override float GetSingleInventoryItemWeightEx()
Определения ItemBase.c:8165
void SaveAgents(ParamsWriteContext ctx)
Определения ItemBase.c:8721
override int GetTargetQuantityMax(int attSlotID=-1)
Определения ItemBase.c:8119
int m_CleannessInit
Определения ItemBase.c:4813
float GetDisinfectQuantity(int system=0, Param param1=null)
Определения ItemBase.c:5457
override int GetAgents()
Определения ItemBase.c:8668
int m_VarQuantityMax
Определения ItemBase.c:4801
override bool IsHologram()
Определения ItemBase.c:5753
float GetItemAttachOffset()
Определения ItemBase.c:8447
bool IsPlaceSound()
Определения ItemBase.c:9545
static int GetDebugActionsMask()
Определения ItemBase.c:5543
override int GetLiquidType()
Определения ItemBase.c:8547
void ProcessDecay(float delta, bool hasRootAsPlayer)
Определения ItemBase.c:9308
override bool IsItemBase()
Определения ItemBase.c:7464
void PlayDeploySound()
override bool IsTwoHandedBehaviour()
Определения ItemBase.c:9018
void ExplodeAmmo()
Определения ItemBase.c:6230
bool IsCombineAll(ItemBase other_item, bool use_stack_max=false)
Определения ItemBase.c:6972
float GetProtectionLevel(int type, bool consider_filter=false, int system=0)
Определения ItemBase.c:8742
static void PlayBulletCasingEjectParticles(ItemBase weapon, string ammoType, ItemBase muzzle_owner, ItemBase suppressor, string config_to_search)
Определения ItemBase.c:8917
override void OnEnergyAdded()
Определения ItemBase.c:8296
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:5702
EffectSound m_DeployLoopSoundEx
Определения ItemBase.c:9528
override void DeSerializeNumericalVars(array< float > floats)
Определения ItemBase.c:7604
void StopItemDynamicPhysics()
Определения ItemBase.c:9210
bool HasFoodStage()
Определения ItemBase.c:7324
override void SetStoreLoad(bool value)
Определения ItemBase.c:8416
float GetOverheatingValue()
Определения ItemBase.c:5287
bool ContainsAgent(int agent_id)
Определения ItemBase.c:8621
override void AddWet(float value)
Определения ItemBase.c:8364
bool IsLiquidPresent()
Определения ItemBase.c:5669
bool IsFullQuantity()
Определения ItemBase.c:8159
override void EOnContact(IEntity other, Contact extra)
Определения ItemBase.c:5943
void SplitIntoStackMaxHands(PlayerBase player)
Определения ItemBase.c:6678
void SplitIntoStackMaxHandsClient(PlayerBase player)
Определения ItemBase.c:6651
int m_CleannessMax
Определения ItemBase.c:4815
float m_VarStackMax
Определения ItemBase.c:4803
ref Timer m_PhysDropTimer
Определения ItemBase.c:4890
void MessageToOwnerFriendly(string text)
Send message to owner player in green color.
Определения ItemBase.c:7436
override void SetStoreLoadedQuantity(float value)
Определения ItemBase.c:8426
bool m_IsResultOfSplit string m_SoundAttType
distinguish if item has been created as new or it came from splitting (server only flag)
Определения ItemBase.c:4844
void CheckOverheating(ItemBase weapon=null, string ammoType="", ItemBase muzzle_owner=null, ItemBase suppressor=null, string config_to_search="")
Определения ItemBase.c:5308
void UnlockFromParent()
Unlocks this item from its attachment slot of its parent.
Определения ItemBase.c:5623
bool Repair(PlayerBase player, ItemBase item_repair_kit, float specialty_weight)
Определения ItemBase.c:7358
void OnLiquidTypeChanged(int oldType, int newType)
Определения ItemBase.c:8552
void StartOverheating(ItemBase weapon=null, string ammoType="", ItemBase muzzle_owner=null, ItemBase suppressor=null, string config_to_search="")
Определения ItemBase.c:5354
void PlayDeployFinishSound()
bool AllowFoodConsumption()
Определения ItemBase.c:8474
bool m_IsOverheatingEffectActive
Определения ItemBase.c:4875
int m_LiquidContainerMask
Определения ItemBase.c:4825
void ProcessItemWetness(float delta, bool hasParent, bool hasRootAsPlayer, ItemBase refParentIB)
Определения ItemBase.c:9246
override int GetCleanness()
Определения ItemBase.c:8469
bool PairWithDevice(notnull ItemBase otherDevice)
Определения ItemBase.c:9457
bool IsDeploySound()
Определения ItemBase.c:9546
static void RemoveDebugActionsMask(int mask)
Определения ItemBase.c:5563
static void UpdateOverheatingParticles(ItemBase weapon, string ammoType, ItemBase muzzle_owner, ItemBase suppressor, string config_to_search)
Определения ItemBase.c:8957
int m_VarQuantityMin
Определения ItemBase.c:4800
void PerformDamageSystemReinit()
Определения ItemBase.c:9216
override void ClearInventory()
Определения ItemBase.c:8257
static int m_LastRegisteredWeaponID
Определения ItemBase.c:4872
ItemBase GetLightSourceItem()
Определения ItemBase.c:9440
void MessageToOwnerImportant(string text)
Send message to owner player in red color.
Определения ItemBase.c:7454
override float GetItemOverheatThreshold()
Определения ItemBase.c:9390
void StopDeployLoopSoundEx()
bool m_CanThisBeSplit
Определения ItemBase.c:4837
override void SerializeNumericalVars(array< float > floats_out)
Определения ItemBase.c:7568
void Open()
Implementations only.
Определения CannedFood.c:100
ItemBase SplitIntoStackMaxToInventoryLocationEx(notnull InventoryLocation dst)
Определения ItemBase.c:6590
float m_ItemModelLength
Определения ItemBase.c:4823
bool m_IsHologram
Определения ItemBase.c:4830
static int m_DebugActionsMask
Определения ItemBase.c:4790
void KillAllOverheatingParticles()
Определения ItemBase.c:5423
bool CanBeCookedOnStick()
Определения ItemBase.c:7341
override int GetQuantityMax()
Определения ItemBase.c:8106
void GetRecipesActions(Man player, out TSelectableActionInfoArray outputList)
Определения ItemBase.c:7050
void OnActivatedByTripWire()
bool IsColorSet()
Определения ItemBase.c:8512
override void RemoveAgent(int agent_id)
Определения ItemBase.c:8634
bool m_ItemBeingDroppedPhys
Определения ItemBase.c:4833
override bool CanPutAsAttachment(EntityAI parent)
Определения ItemBase.c:8824
void PlayDetachSound(string slot_type)
Определения ItemBase.c:9186
static ref map< typename, ref TInputActionMap > m_ItemTypeActionsMap
Определения ItemBase.c:4784
void ProcessItemWetnessAndTemperature(float delta, bool hasParent, bool hasRootAsPlayer, ItemBase refParentIB)
Определения ItemBase.c:9519
override bool IsBeingPlaced()
Определения ItemBase.c:5737
int GetQuantityInit()
Определения ItemBase.c:8143
float ComputeQuantityUsedEx(ItemBase other_item, bool use_stack_max=true)
Определения ItemBase.c:6992
bool IsResultOfSplit()
Определения ItemBase.c:6977
bool m_FixDamageSystemInit
Определения ItemBase.c:4835
float m_ImpactSpeed
Определения ItemBase.c:4819
bool m_IsStoreLoad
Определения ItemBase.c:4838
int GetLiquidTypeInit()
Определения ItemBase.c:8542
string GetDeployFinishSoundset()
ItemBase m_LightSourceItem
Определения ItemBase.c:4853
void LockToParent()
Locks this item in it's current attachment slot of its parent. This makes the "locked" icon visible i...
Определения ItemBase.c:5610
override void SplitIntoStackMaxEx(EntityAI destination_entity, int slot_id)
Определения ItemBase.c:6462
int m_AttachedAgents
Определения ItemBase.c:4861
string m_LockSoundSet
Определения ItemBase.c:4896
void LoadParticleConfigOnOverheating(int id)
Определения ItemBase.c:5231
float m_VarQuantityPrev
Определения ItemBase.c:4798
bool IsSoundSynchRemote()
Определения ItemBase.c:9544
bool m_CanShowQuantity
Определения ItemBase.c:4839
override void EEOnCECreate()
Called when entity is being created as new by CE/ Debug.
Определения ItemBase.c:8781
override void OnRightClick()
Определения ItemBase.c:6846
int m_ColorComponentB
Определения ItemBase.c:4848
static ref map< typename, ref TActionAnimOverrideMap > m_ItemActionOverrides
Определения ItemBase.c:4786
bool IsActionTargetVisible()
Определения ItemBase.c:9054
override void OnItemAttachmentSlotChanged(notnull InventoryLocation oldLoc, notnull InventoryLocation newLoc)
Определения ItemBase.c:5978
override void EEHitBy(TotalDamageResult damageResult, int damageType, EntityAI source, int component, string dmgZone, string ammo, vector modelPos, float speedCoef)
Определения ItemBase.c:6267
bool m_IsBeingPlaced
Определения ItemBase.c:4829
int NameToID(string name)
Определения ItemBase.c:7541
void ~ItemBase()
Определения ItemBase.c:5508
override void OnWetLevelChanged(EWetnessLevel newLevel, EWetnessLevel oldLevel)
Определения ItemBase.c:8404
void ClearStopItemSoundServer()
Определения ItemBase.c:9144
override string ChangeIntoOnDetach()
Определения ItemBase.c:6191
float m_VarWetMax
Определения ItemBase.c:4810
void SplitIntoStackMaxToInventoryLocation(notnull InventoryLocation dst)
Определения ItemBase.c:6585
int GetLockType()
Определения ItemBase.c:8482
EffectSound m_SoundDeployFinish
Определения ItemBase.c:9526
override float GetWet()
Определения ItemBase.c:8374
EffectSound m_SoundPlace
Определения ItemBase.c:9527
float GetQuantityNormalizedScripted()
Определения ItemBase.c:8092
override void SetCleanness(int value, bool allow_client=false)
Определения ItemBase.c:8456
bool m_IsPlaceSound
Определения ItemBase.c:9530
override float GetWetMin()
Определения ItemBase.c:8384
ref ItemSoundHandler m_ItemSoundHandler
Определения ItemBase.c:4902
override bool KindOf(string tag)
Определения ItemBase.c:7470
void ItemSoundHandler(ItemBase parent)
Определения ItemSoundHandler.c:31
string Type
Определения JsonDataContaminatedArea.c:11
EffectSound m_LockingSound
Определения Land_Underground_Entrance.c:321
string GetDebugText()
Определения ModifierBase.c:71
PlayerBase GetPlayer()
Определения ModifierBase.c:51
@ LOWEST
Определения PPEConstants.c:54
void PluginItemDiagnostic()
Определения PluginItemDiagnostic.c:74
PluginBase GetPlugin(typename plugin_type)
Определения PluginManager.c:316
EntityAI GetItem()
Определения RadialQuickbarMenu.c:37
override RemotelyActivatedItemBehaviour GetRemotelyActivatedItemBehaviour()
Определения RemoteDetonator.c:272
void RemoteDetonatorTrigger()
Определения RemoteDetonator.c:233
override void OnActivatedByItem(notnull ItemBase item)
Called when this item is activated by other.
Определения RemoteDetonator.c:305
int particle_id
Определения SmokeSimulation.c:28
ETemperatureAccessTypes
Определения TemperatureAccessConstants.c:2
override void Explode(int damageType, string ammoType="")
Определения Trap_LandMine.c:220
bool m_Initialized
Определения UiHintPanel.c:317
void Debug()
Определения UniversalTemperatureSource.c:349
int GetID()
Определения ActionBase.c:1321
void OnItemLocationChanged(ItemBase item)
Определения ActionBase.c:962
GetInputType()
Определения ActionBase.c:215
int m_StanceMask
Определения ActionBase.c:25
int m_CommandUIDProne
Определения ActionBase.c:24
int m_CommandUID
Определения ActionBase.c:23
void OnItemAttachedAtPlayer(EntityAI item, string slot_name)
Определения AnalyticsManagerClient.c:77
proto native UIManager GetUIManager()
proto bool ConfigGetChildName(string path, int index, out string name)
Get name of subclass in config class on path.
proto native float ConfigGetFloat(string path)
Get float value from config on path.
override ScriptCallQueue GetCallQueue(int call_category)
Определения DayZGame.c:1187
proto native bool ConfigIsExisting(string path)
proto native void ConfigGetTextArray(string path, out TStringArray values)
Get array of strings from config on path.
proto native DayZPlayer GetPlayer()
proto int GetTime()
returns mission time in milliseconds
proto native int ConfigGetType(string path)
Returns type of config value.
AnalyticsManagerClient GetAnalyticsClient()
Определения Game.c:1513
proto native int ConfigGetChildrenCount(string path)
Get count of subclasses in config class on path.
proto native SoundOnVehicle CreateSoundOnObject(Object source, string sound_name, float distance, bool looped, bool create_local=false)
proto native void ObjectDelete(Object obj)
proto native int GetItemCount()
proto native EntityAI GetItem(int index)
float GetEnergyAtSpawn()
Определения ComponentEnergyManager.c:1280
void SetEnergy0To1(float energy01)
Energy manager: Sets stored energy for this device between 0 and MAX based on relative input value be...
Определения ComponentEnergyManager.c:541
float GetEnergyMaxPristine()
Energy manager: Returns the maximum amount of energy this device can store. It's damage is NOT taken ...
Определения ComponentEnergyManager.c:1275
override void SetAutodestroy(bool auto_destroy)
Sets whether Effect automatically cleans up when it stops.
Определения EffectSound.c:603
bool IsSoundPlaying()
Get whether EffectSound is currently playing.
Определения EffectSound.c:274
override bool IsMan()
Определения Man.c:44
Определения Building.c:6
Определения constants.c:659
proto native bool EnumerateInventory(InventoryTraversalType tt, out array< EntityAI > items)
enumerate inventory using traversal type and filling items array
proto native CargoBase GetCargo()
cargo
Определения ItemBase.c:15
proto native bool IsValid()
verify current set inventory location
proto native EntityAI GetParent()
returns parent of current inventory location
proto native int GetSlot()
returns slot id if current type is Attachment
proto native int GetCol()
returns column of cargo if current type is Cargo / ProxyCargo
proto native int GetRow()
returns row of cargo if current type is Cargo / ProxyCargo
proto native void SetGround(EntityAI e, vector mat[4])
sets current inventory location type to Ground with transformation mat
bool WriteToContext(ParamsWriteContext ctx)
Определения InventoryLocation.c:469
proto native int GetType()
returns type of InventoryLocation
proto native int GetIdx()
returns index of cargo if current type is Cargo / ProxyCargo
proto native void SetCargo(notnull EntityAI parent, EntityAI e, int idx, int row, int col, bool flip)
sets current inventory location type to Cargo with coordinates (idx, row, col)
proto native bool GetFlip()
returns flip status of cargo
proto native EntityAI GetItem()
returns item of current inventory location
InventoryLocation.
Определения InventoryLocation.c:29
override bool CanDisplayCargo()
Определения UndergroundStash.c:24
override void OnInventoryEnter(Man player)
Определения BarbedWire.c:203
override bool CanPutAsAttachment(EntityAI parent)
Определения ItemBase.c:6
override bool CanReceiveItemIntoCargo(EntityAI item)
Определения TentBase.c:913
override bool OnStoreLoad(ParamsReadContext ctx, int version)
Определения GardenBase.c:149
override void OnWasDetached(EntityAI parent, int slot_id)
Определения InventoryItem.c:920
override void EEOnAfterLoad()
Определения GardenBase.c:187
override void EEDelete(EntityAI parent)
Определения BaseBuildingBase.c:68
override bool CanBeRepairedByCrafting()
Определения TentBase.c:86
override void OnPlacementStarted(Man player)
Определения BatteryCharger.c:376
override void OnItemLocationChanged(EntityAI old_owner, EntityAI new_owner)
Определения BarbedWire.c:357
override bool IsElectricAppliance()
Определения BatteryCharger.c:43
override bool IsItemTent()
Определения TentBase.c:81
override void SetActions()
Определения InventoryItem.c:732
override bool CanMakeGardenplot()
Определения FieldShovel.c:3
override void GetDebugActions(out TSelectableActionInfoArrayEx outputList)
Определения PowerGenerator.c:412
override void EEItemLocationChanged(notnull InventoryLocation oldLoc, notnull InventoryLocation newLoc)
Определения HandcuffsLocked.c:12
override WrittenNoteData GetWrittenNoteData()
Определения Paper.c:30
override int GetDamageSystemVersionChange()
Определения BaseBuildingBase.c:1218
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:465
override string GetDeploySoundset()
Определения BarbedWire.c:392
override float GetBandagingEffectivity()
Определения BandageDressing.c:49
override bool OnAction(int action_id, Man player, ParamsReadContext ctx)
Определения PowerGenerator.c:424
override void EEHealthLevelChanged(int oldLevel, int newLevel, string zone)
Определения BaseBuildingBase.c:472
override void OnStoreSave(ParamsWriteContext ctx)
Определения GardenBase.c:206
override void AfterStoreLoad()
Определения GardenBase.c:182
override int GetOnDigWormsAmount()
Определения FieldShovel.c:27
override bool IsSelfAdjustingTemperature()
Определения PortableGasStove.c:287
override bool IsPlayerInside(PlayerBase player, string selection)
Определения BaseBuildingBase.c:1017
override void OnVariablesSynchronized()
Определения GardenBase.c:68
override void RefreshPhysics()
Определения BatteryCharger.c:359
override bool CanObstruct()
Определения BaseBuildingBase.c:84
override void OnWasAttached(EntityAI parent, int slot_id)
Определения InventoryItem.c:912
override bool CanReceiveAttachment(EntityAI attachment, int slotId)
Определения BaseBuildingBase.c:962
override bool CanPutInCargo(EntityAI parent)
Определения GardenBase.c:269
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:988
override bool IsIgnoredByConstruction()
Определения BaseBuildingBase.c:1150
override void InitItemSounds()
Определения TentBase.c:810
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:1012
override bool CanBeCombined(EntityAI other_item, bool reservation_check=true, bool stack_max_limit=false)
Определения Rag.c:61
override bool IsBloodContainer()
Определения BloodContainerBase.c:10
override bool IsClothing()
Определения InventoryItem.c:840
override bool CanBeSplit()
Определения Rag.c:34
override bool IsDeployable()
Определения BaseBuildingBase.c:341
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
Определения InventoryItem.c:731
Определения EnMath.c:7
float GetOverheatingLimitMax()
Определения WeaponParticles.c:417
void SetOverheatingLimitMax(float max)
Определения WeaponParticles.c:407
void SetParticleParams(int particle_id, Object parent, vector local_pos, vector local_ori)
Определения WeaponParticles.c:422
float GetOverheatingLimitMin()
Определения WeaponParticles.c:412
Particle GetParticle()
Определения WeaponParticles.c:397
void SetOverheatingLimitMin(float min)
Определения WeaponParticles.c:402
void RegisterParticle(Particle p)
Определения WeaponParticles.c:392
void Stop()
Legacy function for backwards compatibility with 1.14 and below.
Определения Particle.c:266
void SetControlledDevice(EntityAI pDevice)
Определения RemoteDetonator.c:140
bool OnStoreLoad(ParamsReadContext ctx, int version)
void OnStoreSave(ParamsWriteContext ctx)
proto void Remove(func fn)
remove specific call from queue
proto void CallLater(func fn, int delay=0, bool repeat=false, void param1=NULL, void param2=NULL, void param3=NULL, void param4=NULL, void param5=NULL, void param6=NULL, void param7=NULL, void param8=NULL, void param9=NULL)
adds call into the queue with given parameters and arguments (arguments are held in memory until the ...
proto native void Send()
proto bool Write(void value_out)
proto bool Read(void value_in)
bool m_Loop
Определения ItemSoundHandler.c:5
override void Stop()
Определения DayZPlayerImplement.c:64
proto native float GetDamage(string zoneName, string healthType)
UIScriptedMenu FindMenu(int id)
Returns menu with specific ID if it is open (see MenuID)
Определения UIManager.c:160
override void Refresh()
Определения ChatInputMenu.c:70
void SetCalcDetails(string details)
Определения Debug.c:816
void OnRPC(PlayerIdentity sender, int rpc_type, ParamsReadContext ctx)
Определения WrittenNoteData.c:13
const float LOWEST
Определения EnConvert.c:100
Serializer ParamsReadContext
Определения gameplay.c:15
class LOD Object
InventoryTraversalType
tree traversal type, for more see http://en.wikipedia.org/wiki/Tree_traversal
Определения gameplay.c:6
proto native CGame GetGame()
Serializer ParamsWriteContext
Определения gameplay.c:16
const int DEF_BIOLOGICAL
Определения constants.c:510
const int DEF_CHEMICAL
Определения constants.c:511
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:685
array< int > TIntArray
Определения EnScript.c:687
EntityEvent
Entity events for event-mask, or throwing event from code.
Определения EnEntity.c:45
static const float ITEM_TEMPERATURE_NEUTRAL_ZONE_MIDDLE
Определения constants.c:806
const int VARIABLE_LIQUIDTYPE
Определения constants.c:630
const int VARIABLE_CLEANNESS
Определения constants.c:633
const int VARIABLE_COLOR
Определения constants.c:632
const int VARIABLE_TEMPERATURE
Определения constants.c:628
const int VARIABLE_QUANTITY
Определения constants.c:626
const int VARIABLE_WET
Определения constants.c:629
const int LIQUID_NONE
Определения constants.c:527
static proto float AbsFloat(float f)
Returns absolute value.
const int MENU_INVENTORY
Определения constants.c:180
proto native bool dBodyIsDynamic(notnull IEntity ent)
const int SAT_CRAFTING
Определения constants.c:451
const int SAT_DEBUG_ACTION
Определения constants.c:452
class JsonUndergroundAreaTriggerData GetPosition
Определения UndergroundAreaLoader.c:9
static proto string Format(string fmt, void param1=NULL, void param2=NULL, void param3=NULL, void param4=NULL, void param5=NULL, void param6=NULL, void param7=NULL, void param8=NULL, void param9=NULL)
Gets n-th character from string.
const int CALL_CATEGORY_GAMEPLAY
Определения tools.c:10
const int CALL_CATEGORY_SYSTEM
Определения tools.c:8
proto native int GetColor()

Используется в Entity::SaveVariables().