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

◆ NameToID()

int SpawnItemOnLocation::NameToID ( string name)
protected

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

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