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

◆ WriteVarsToCTX()

override void SpawnItemOnLocation::WriteVarsToCTX ( ParamsWriteContext ctx)
protected

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

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

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