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

◆ SerializeNumericalVars()

override void SpawnItemOnLocation::SerializeNumericalVars ( array< float > floats_out)
protected

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

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