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

◆ GetExplosiveTriggerSlotName()

string SpawnItemOnLocation::GetExplosiveTriggerSlotName ( )
private

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

5778{
5779 override bool CanPutAsAttachment(EntityAI parent)
5780 {
5781 return true;
5782 }
5783};
5784
5785//const bool QUANTITY_DEBUG_REMOVE_ME = false;
5786
5787class ItemBase extends InventoryItem
5788{
5792
5794
5795 static int m_DebugActionsMask;
5797 // ============================================
5798 // Variable Manipulation System
5799 // ============================================
5800 // Quantity
5801
5802 float m_VarQuantity;
5803 float m_VarQuantityPrev;//for client to know quantity changed during synchronization
5805 int m_VarQuantityMin;
5806 int m_VarQuantityMax;
5807 int m_Count;
5808 float m_VarStackMax;
5809 float m_StoreLoadedQuantity = float.LOWEST;
5810 // Wet
5811 float m_VarWet;
5812 float m_VarWetPrev;//for client to know wetness changed during synchronization
5813 float m_VarWetInit;
5814 float m_VarWetMin;
5815 float m_VarWetMax;
5816 // Cleanness
5817 int m_Cleanness;
5818 int m_CleannessInit;
5819 int m_CleannessMin;
5820 int m_CleannessMax;
5821 // impact sounds
5823 bool m_CanPlayImpactSound = true;
5824 float m_ImpactSpeed;
5826 //
5827 float m_HeatIsolation;
5828 float m_ItemModelLength;
5829 float m_ItemAttachOffset; // Offset length for when the item is attached e.g. to weapon
5831 int m_VarLiquidType;
5832 int m_ItemBehaviour; // -1 = not specified; 0 = heavy item; 1= onehanded item; 2 = twohanded item
5833 int m_QuickBarBonus;
5834 bool m_IsBeingPlaced;
5835 bool m_IsHologram;
5836 bool m_IsTakeable;
5837 bool m_ThrowItemOnDrop;
5840 bool m_FixDamageSystemInit = false; //can be changed on storage version check
5841 bool can_this_be_combined; //Check if item can be combined
5842 bool m_CanThisBeSplit; //Check if item can be split
5843 bool m_IsStoreLoad = false;
5844 bool m_CanShowQuantity;
5845 bool m_HasQuantityBar;
5846 protected bool m_CanBeDigged;
5847 protected bool m_IsResultOfSplit
5848
5849 string m_SoundAttType;
5850 // items color variables
5855 //-------------------------------------------------------
5856
5857 // light source managing
5859
5863
5864 //==============================================
5865 // agent system
5866 private int m_AttachedAgents;
5867
5869 void TransferModifiers(PlayerBase reciever);
5870
5871
5872 // Weapons & suppressors particle effects
5877 static int m_LastRegisteredWeaponID = 0;
5878
5879 // Overheating effects
5881 float m_OverheatingShots;
5882 ref Timer m_CheckOverheating;
5883 int m_ShotsToStartOverheating = 0; // After these many shots, the overheating effect begins
5884 int m_MaxOverheatingValue = 0; // Limits the number of shots that will be tracked
5885 float m_OverheatingDecayInterval = 1; // Timer's interval for decrementing overheat effect's lifespan
5886 ref array <ref OverheatingParticle> m_OverheatingParticles;
5887
5889 protected bool m_HideSelectionsBySlot;
5890
5891 // Admin Log
5892 PluginAdminLog m_AdminLog;
5893
5894 // misc
5895 ref Timer m_PhysDropTimer;
5896
5897 // Attachment Locking variables
5898 ref array<int> m_CompatibleLocks;
5899 protected int m_LockType;
5900 protected ref EffectSound m_LockingSound;
5901 protected string m_LockSoundSet;
5902
5903 // ItemSoundHandler
5904 protected const int ITEM_SOUNDS_MAX = 63; // optimize network synch
5905 protected int m_SoundSyncPlay; // id for sound to play
5906 protected int m_SoundSyncStop; // id for sound to stop
5908
5909 //temperature
5910 private float m_TemperaturePerQuantityWeight;
5911
5912 // -------------------------------------------------------------------------
5913 void ItemBase()
5914 {
5915 SetEventMask(EntityEvent.INIT); // Enable EOnInit event
5919
5920 if (!GetGame().IsDedicatedServer())
5921 {
5922 if (HasMuzzle())
5923 {
5925
5927 {
5929 }
5930 }
5931
5933 m_ActionsInitialize = false;
5934 }
5935
5936 m_OldLocation = null;
5937
5938 if (GetGame().IsServer())
5939 {
5940 m_AdminLog = PluginAdminLog.Cast(GetPlugin(PluginAdminLog));
5941 }
5942
5943 if (ConfigIsExisting("headSelectionsToHide"))
5944 {
5946 ConfigGetTextArray("headSelectionsToHide",m_HeadHidingSelections);
5947 }
5948
5949 m_HideSelectionsBySlot = false;
5950 if (ConfigIsExisting("hideSelectionsByinventorySlot"))
5951 {
5952 m_HideSelectionsBySlot = ConfigGetBool("hideSelectionsByinventorySlot");
5953 }
5954
5955 m_QuickBarBonus = Math.Max(0, ConfigGetInt("quickBarBonus"));
5956
5957 m_IsResultOfSplit = false;
5958
5960 }
5961
5962 override void InitItemVariables()
5963 {
5964 super.InitItemVariables();
5965
5966 m_VarQuantityInit = ConfigGetInt("varQuantityInit");
5967 m_VarQuantity = m_VarQuantityInit;//should be by the CE, this is just a precaution
5968 m_VarQuantityMin = ConfigGetInt("varQuantityMin");
5969 m_VarQuantityMax = ConfigGetInt("varQuantityMax");
5970 m_VarStackMax = ConfigGetFloat("varStackMax");
5971 m_Count = ConfigGetInt("count");
5972
5973 m_CanShowQuantity = ConfigGetBool("quantityShow");
5974 m_HasQuantityBar = ConfigGetBool("quantityBar");
5975
5976 m_CleannessInit = ConfigGetInt("varCleannessInit");
5978 m_CleannessMin = ConfigGetInt("varCleannessMin");
5979 m_CleannessMax = ConfigGetInt("varCleannessMax");
5980
5981 m_WantPlayImpactSound = false;
5982 m_ImpactSpeed = 0.0;
5983
5984 m_VarWetInit = ConfigGetFloat("varWetInit");
5986 m_VarWetMin = ConfigGetFloat("varWetMin");
5987 m_VarWetMax = ConfigGetFloat("varWetMax");
5988
5989 m_LiquidContainerMask = ConfigGetInt("liquidContainerType");
5990 if (IsLiquidContainer() && GetQuantity() != 0)
5992 m_IsBeingPlaced = false;
5993 m_IsHologram = false;
5994 m_IsTakeable = true;
5995 m_CanBeMovedOverride = false;
5999 m_CanBeDigged = ConfigGetBool("canBeDigged");
6000
6001 m_CompatibleLocks = new array<int>();
6002 ConfigGetIntArray("compatibleLocks", m_CompatibleLocks);
6003 m_LockType = ConfigGetInt("lockType");
6004
6005 //Define if item can be split and set ability to be combined accordingly
6006 m_CanThisBeSplit = false;
6007 can_this_be_combined = false;
6008 if (ConfigIsExisting("canBeSplit"))
6009 {
6010 can_this_be_combined = ConfigGetBool("canBeSplit");
6012 }
6013
6014 m_ItemBehaviour = -1;
6015 if (ConfigIsExisting("itemBehaviour"))
6016 m_ItemBehaviour = ConfigGetInt("itemBehaviour");
6017
6018 //RegisterNetSyncVariableInt("m_VariablesMask");
6019 if (HasQuantity()) RegisterNetSyncVariableFloat("m_VarQuantity", GetQuantityMin(), m_VarQuantityMax);
6020 RegisterNetSyncVariableFloat("m_VarWet", GetWetMin(), GetWetMax(), 2);
6021 RegisterNetSyncVariableInt("m_VarLiquidType");
6022 RegisterNetSyncVariableInt("m_Cleanness",0,1);
6023
6024 RegisterNetSyncVariableBoolSignal("m_WantPlayImpactSound");
6025 RegisterNetSyncVariableFloat("m_ImpactSpeed");
6026 RegisterNetSyncVariableInt("m_ImpactSoundSurfaceHash");
6027
6028 RegisterNetSyncVariableInt("m_ColorComponentR", 0, 255);
6029 RegisterNetSyncVariableInt("m_ColorComponentG", 0, 255);
6030 RegisterNetSyncVariableInt("m_ColorComponentB", 0, 255);
6031 RegisterNetSyncVariableInt("m_ColorComponentA", 0, 255);
6032
6033 RegisterNetSyncVariableBool("m_IsBeingPlaced");
6034 RegisterNetSyncVariableBool("m_IsTakeable");
6035 RegisterNetSyncVariableBool("m_IsHologram");
6036
6037 InitItemSounds();
6039 {
6040 RegisterNetSyncVariableInt("m_SoundSyncPlay", 0, ITEM_SOUNDS_MAX);
6041 RegisterNetSyncVariableInt("m_SoundSyncStop", 0, ITEM_SOUNDS_MAX);
6042 }
6043
6044 m_LockSoundSet = ConfigGetString("lockSoundSet");
6045
6047 if (ConfigIsExisting("temperaturePerQuantityWeight"))
6048 m_TemperaturePerQuantityWeight = ConfigGetFloat("temperaturePerQuantityWeight");
6049
6050 }
6051
6052 override int GetQuickBarBonus()
6053 {
6054 return m_QuickBarBonus;
6055 }
6056
6057 void InitializeActions()
6058 {
6060 if (!m_InputActionMap)
6061 {
6063 m_InputActionMap = iam;
6064 SetActions();
6066 }
6067 }
6068
6069 override void GetActions(typename action_input_type, out array<ActionBase_Basic> actions)
6070 {
6072 {
6073 m_ActionsInitialize = true;
6075 }
6076
6077 actions = m_InputActionMap.Get(action_input_type);
6078 }
6079
6080 void SetActions()
6081 {
6082 AddAction(ActionTakeItem);
6083 AddAction(ActionTakeItemToHands);
6084 AddAction(ActionWorldCraft);
6086 AddAction(ActionAttachWithSwitch);
6087 }
6088
6089 void SetActionAnimOverrides(); // Override action animation for specific item
6090
6091 void AddAction(typename actionName)
6092 {
6093 ActionBase action = ActionManagerBase.GetAction(actionName);
6094
6095 if (!action)
6096 {
6097 Debug.LogError("Action " + actionName + " dosn't exist!");
6098 return;
6099 }
6100
6101 typename ai = action.GetInputType();
6102 if (!ai)
6103 {
6104 m_ActionsInitialize = false;
6105 return;
6106 }
6107
6108 array<ActionBase_Basic> action_array = m_InputActionMap.Get(ai);
6109 if (!action_array)
6110 {
6111 action_array = new array<ActionBase_Basic>;
6112 m_InputActionMap.Insert(ai, action_array);
6113 }
6114 if (LogManager.IsActionLogEnable())
6115 {
6116 Debug.ActionLog(action.ToString() + " -> " + ai, this.ToString() , "n/a", "Add action");
6117 }
6118
6119 if (action_array.Find(action) != -1)
6120 {
6121 Debug.Log("Action " + action.Type() + " already added to " + this + ", skipping!");
6122 }
6123 else
6124 {
6125 action_array.Insert(action);
6126 }
6127 }
6128
6129 void RemoveAction(typename actionName)
6130 {
6131 PlayerBase player = PlayerBase.Cast(GetGame().GetPlayer());
6132 ActionBase action = player.GetActionManager().GetAction(actionName);
6133 typename ai = action.GetInputType();
6134 array<ActionBase_Basic> action_array = m_InputActionMap.Get(ai);
6135
6136 if (action_array)
6137 {
6138 action_array.RemoveItem(action);
6139 }
6140 }
6141
6142 // Allows override of default action command per item, defined in the SetActionAnimOverrides() of the item's class
6143 // Set -1 for params which should stay in default state
6144 void OverrideActionAnimation(typename action, int commandUID, int stanceMask = -1, int commandUIDProne = -1)
6145 {
6146 ActionOverrideData overrideData = new ActionOverrideData();
6147 overrideData.m_CommandUID = commandUID;
6148 overrideData.m_CommandUIDProne = commandUIDProne;
6149 overrideData.m_StanceMask = stanceMask;
6150
6151 TActionAnimOverrideMap actionMap = m_ItemActionOverrides.Get(action);
6152 if (!actionMap) // create new map of action > overidables map
6153 {
6154 actionMap = new TActionAnimOverrideMap();
6155 m_ItemActionOverrides.Insert(action, actionMap);
6156 }
6157
6158 actionMap.Insert(this.Type(), overrideData); // insert item -> overrides
6159
6160 }
6161
6162 void OnItemInHandsPlayerSwimStart(PlayerBase player);
6163
6164 ScriptedLightBase GetLight();
6165
6166 // Loads muzzle flash particle configuration from config and saves it to a map for faster access
6167 void LoadParticleConfigOnFire(int id)
6168 {
6169 if (!m_OnFireEffect)
6171
6174
6175 string config_to_search = "CfgVehicles";
6176 string muzzle_owner_config;
6177
6178 if (!m_OnFireEffect.Contains(id))
6179 {
6180 if (IsInherited(Weapon))
6181 config_to_search = "CfgWeapons";
6182
6183 muzzle_owner_config = config_to_search + " " + GetType() + " ";
6184
6185 string config_OnFire_class = muzzle_owner_config + "Particles " + "OnFire ";
6186
6187 int config_OnFire_subclass_count = GetGame().ConfigGetChildrenCount(config_OnFire_class);
6188
6189 if (config_OnFire_subclass_count > 0)
6190 {
6191 array<ref WeaponParticlesOnFire> WPOF_array = new array<ref WeaponParticlesOnFire>;
6192
6193 for (int i = 0; i < config_OnFire_subclass_count; i++)
6194 {
6195 string particle_class = "";
6196 GetGame().ConfigGetChildName(config_OnFire_class, i, particle_class);
6197 string config_OnFire_entry = config_OnFire_class + particle_class;
6198 WeaponParticlesOnFire WPOF = new WeaponParticlesOnFire(this, config_OnFire_entry);
6199 WPOF_array.Insert(WPOF);
6200 }
6201
6202
6203 m_OnFireEffect.Insert(id, WPOF_array);
6204 }
6205 }
6206
6207 if (!m_OnBulletCasingEjectEffect.Contains(id))
6208 {
6209 config_to_search = "CfgWeapons"; // Bullet Eject efect is supported on weapons only.
6210 muzzle_owner_config = config_to_search + " " + GetType() + " ";
6211
6212 string config_OnBulletCasingEject_class = muzzle_owner_config + "Particles " + "OnBulletCasingEject ";
6213
6214 int config_OnBulletCasingEject_count = GetGame().ConfigGetChildrenCount(config_OnBulletCasingEject_class);
6215
6216 if (config_OnBulletCasingEject_count > 0 && IsInherited(Weapon))
6217 {
6218 array<ref WeaponParticlesOnBulletCasingEject> WPOBE_array = new array<ref WeaponParticlesOnBulletCasingEject>;
6219
6220 for (i = 0; i < config_OnBulletCasingEject_count; i++)
6221 {
6222 string particle_class2 = "";
6223 GetGame().ConfigGetChildName(config_OnBulletCasingEject_class, i, particle_class2);
6224 string config_OnBulletCasingEject_entry = config_OnBulletCasingEject_class + particle_class2;
6225 WeaponParticlesOnBulletCasingEject WPOBE = new WeaponParticlesOnBulletCasingEject(this, config_OnBulletCasingEject_entry);
6226 WPOBE_array.Insert(WPOBE);
6227 }
6228
6229
6230 m_OnBulletCasingEjectEffect.Insert(id, WPOBE_array);
6231 }
6232 }
6233 }
6234
6235 // Loads muzzle flash particle configuration from config and saves it to a map for faster access
6237 {
6240
6241 if (!m_OnOverheatingEffect.Contains(id))
6242 {
6243 string config_to_search = "CfgVehicles";
6244
6245 if (IsInherited(Weapon))
6246 config_to_search = "CfgWeapons";
6247
6248 string muzzle_owner_config = config_to_search + " " + GetType() + " ";
6249 string config_OnOverheating_class = muzzle_owner_config + "Particles " + "OnOverheating ";
6250
6251 if (GetGame().ConfigIsExisting(config_OnOverheating_class))
6252 {
6253
6254 m_ShotsToStartOverheating = GetGame().ConfigGetFloat(config_OnOverheating_class + "shotsToStartOverheating");
6255
6257 {
6258 m_ShotsToStartOverheating = -1; // This prevents futher readings from config for future creations of this item
6259 string error = "Error reading config " + GetType() + ">Particles>OnOverheating - Parameter shotsToStartOverheating is configured wrong or is missing! Its value must be 1 or higher!";
6260 Error(error);
6261 return;
6262 }
6263
6264 m_OverheatingDecayInterval = GetGame().ConfigGetFloat(config_OnOverheating_class + "overheatingDecayInterval");
6265 m_MaxOverheatingValue = GetGame().ConfigGetFloat(config_OnOverheating_class + "maxOverheatingValue");
6266
6267
6268
6269 int config_OnOverheating_subclass_count = GetGame().ConfigGetChildrenCount(config_OnOverheating_class);
6270 array<ref WeaponParticlesOnOverheating> WPOOH_array = new array<ref WeaponParticlesOnOverheating>;
6271
6272 for (int i = 0; i < config_OnOverheating_subclass_count; i++)
6273 {
6274 string particle_class = "";
6275 GetGame().ConfigGetChildName(config_OnOverheating_class, i, particle_class);
6276 string config_OnOverheating_entry = config_OnOverheating_class + particle_class;
6277 int entry_type = GetGame().ConfigGetType(config_OnOverheating_entry);
6278
6279 if (entry_type == CT_CLASS)
6280 {
6281 WeaponParticlesOnOverheating WPOF = new WeaponParticlesOnOverheating(this, config_OnOverheating_entry);
6282 WPOOH_array.Insert(WPOF);
6283 }
6284 }
6285
6286
6287 m_OnOverheatingEffect.Insert(id, WPOOH_array);
6288 }
6289 }
6290 }
6291
6292 float GetOverheatingValue()
6293 {
6294 return m_OverheatingShots;
6295 }
6296
6297 void IncreaseOverheating(ItemBase weapon, string ammoType, ItemBase muzzle_owner, ItemBase suppressor, string config_to_search)
6298 {
6299 if (m_MaxOverheatingValue > 0)
6300 {
6302
6303 if (!m_CheckOverheating)
6305
6307 m_CheckOverheating.Run(m_OverheatingDecayInterval, this, "OnOverheatingDecay");
6308
6309 CheckOverheating(weapon, ammoType, muzzle_owner, suppressor, config_to_search);
6310 }
6311 }
6312
6313 void CheckOverheating(ItemBase weapon = null, string ammoType = "", ItemBase muzzle_owner = null, ItemBase suppressor = null, string config_to_search = "")
6314 {
6316 UpdateOverheating(weapon, ammoType, muzzle_owner, suppressor, config_to_search);
6317
6319 StartOverheating(weapon, ammoType, muzzle_owner, suppressor, config_to_search);
6320
6322 StopOverheating(weapon, ammoType, muzzle_owner, suppressor, config_to_search);
6323
6325 {
6327 }
6328 }
6329
6331 {
6333 }
6334
6335 void OnOverheatingDecay()
6336 {
6337 if (m_MaxOverheatingValue > 0)
6338 m_OverheatingShots -= 1 + m_OverheatingShots / m_MaxOverheatingValue; // The hotter a barrel is, the faster it needs to cool down.
6339 else
6341
6342 if (m_OverheatingShots <= 0)
6343 {
6346 }
6347 else
6348 {
6349 if (!m_CheckOverheating)
6351
6353 m_CheckOverheating.Run(m_OverheatingDecayInterval, this, "OnOverheatingDecay");
6354 }
6355
6356 CheckOverheating(this, "", this);
6357 }
6358
6359 void StartOverheating(ItemBase weapon = null, string ammoType = "", ItemBase muzzle_owner = null, ItemBase suppressor = null, string config_to_search = "")
6360 {
6362 ItemBase.PlayOverheatingParticles(this, ammoType, this, suppressor, "CfgWeapons");
6363 }
6364
6365 void UpdateOverheating(ItemBase weapon = null, string ammoType = "", ItemBase muzzle_owner = null, ItemBase suppressor = null, string config_to_search = "")
6366 {
6368 ItemBase.UpdateOverheatingParticles(this, ammoType, this, suppressor, "CfgWeapons");
6370 }
6371
6372 void StopOverheating(ItemBase weapon = null, string ammoType = "", ItemBase muzzle_owner = null, ItemBase suppressor = null, string config_to_search = "")
6373 {
6375 ItemBase.StopOverheatingParticles(weapon, ammoType, muzzle_owner, suppressor, config_to_search);
6376 }
6377
6378 void RegisterOverheatingParticle(Particle p, float min_heat_coef, float max_heat_coef, int particle_id, Object parent, vector local_pos, vector local_ori)
6379 {
6381 m_OverheatingParticles = new array<ref OverheatingParticle>;
6382
6383 OverheatingParticle OP = new OverheatingParticle();
6384 OP.RegisterParticle(p);
6385 OP.SetOverheatingLimitMin(min_heat_coef);
6386 OP.SetOverheatingLimitMax(max_heat_coef);
6387 OP.SetParticleParams(particle_id, parent, local_pos, local_ori);
6388
6389 m_OverheatingParticles.Insert(OP);
6390 }
6391
6392 float GetOverheatingCoef()
6393 {
6394 if (m_MaxOverheatingValue > 0)
6396
6397 return -1;
6398 }
6399
6401 {
6403 {
6404 float overheat_coef = GetOverheatingCoef();
6405 int count = m_OverheatingParticles.Count();
6406
6407 for (int i = count; i > 0; --i)
6408 {
6409 int id = i - 1;
6410 OverheatingParticle OP = m_OverheatingParticles.Get(id);
6411 Particle p = OP.GetParticle();
6412
6413 float overheat_min = OP.GetOverheatingLimitMin();
6414 float overheat_max = OP.GetOverheatingLimitMax();
6415
6416 if (overheat_coef < overheat_min && overheat_coef >= overheat_max)
6417 {
6418 if (p)
6419 {
6420 p.Stop();
6421 OP.RegisterParticle(null);
6422 }
6423 }
6424 }
6425 }
6426 }
6427
6429 {
6431 {
6432 for (int i = m_OverheatingParticles.Count(); i > 0; i--)
6433 {
6434 int id = i - 1;
6435 OverheatingParticle OP = m_OverheatingParticles.Get(id);
6436
6437 if (OP)
6438 {
6439 Particle p = OP.GetParticle();
6440
6441 if (p)
6442 {
6443 p.Stop();
6444 }
6445
6446 delete OP;
6447 }
6448 }
6449
6450 m_OverheatingParticles.Clear();
6452 }
6453 }
6454
6456 float GetInfectionChance(int system = 0, Param param = null)
6457 {
6458 return 0.0;
6459 }
6460
6461
6462 float GetDisinfectQuantity(int system = 0, Param param1 = null)
6463 {
6464 return 250;//default value
6465 }
6466
6467 float GetFilterDamageRatio()
6468 {
6469 return 0;
6470 }
6471
6473 bool HasMuzzle()
6474 {
6475 if (IsInherited(Weapon) || IsInherited(SuppressorBase))
6476 return true;
6477
6478 return false;
6479 }
6480
6482 int GetMuzzleID()
6483 {
6484 if (!m_WeaponTypeToID)
6486
6487 if (m_WeaponTypeToID.Contains(GetType()))
6488 {
6489 return m_WeaponTypeToID.Get(GetType());
6490 }
6491 else
6492 {
6493 // Register new weapon ID
6495 }
6496
6498 }
6499
6506 {
6507 return -1;
6508 }
6509
6510
6511
6512 // -------------------------------------------------------------------------
6513 void ~ItemBase()
6514 {
6515 if (GetGame() && GetGame().GetPlayer() && (!GetGame().IsDedicatedServer()))
6516 {
6517 PlayerBase player = PlayerBase.Cast(GetGame().GetPlayer());
6518 int r_index = player.GetHumanInventory().FindUserReservedLocationIndex(this);
6519
6520 if (r_index >= 0)
6521 {
6522 InventoryLocation r_il = new InventoryLocation;
6523 player.GetHumanInventory().GetUserReservedLocation(r_index,r_il);
6524
6525 player.GetHumanInventory().ClearUserReservedLocationAtIndex(r_index);
6526 int r_type = r_il.GetType();
6527 if (r_type == InventoryLocationType.CARGO || r_type == InventoryLocationType.PROXYCARGO)
6528 {
6529 r_il.GetParent().GetOnReleaseLock().Invoke(this);
6530 }
6531 else if (r_type == InventoryLocationType.ATTACHMENT)
6532 {
6533 r_il.GetParent().GetOnAttachmentReleaseLock().Invoke(this, r_il.GetSlot());
6534 }
6535
6536 }
6537
6538 player.GetHumanInventory().ClearUserReservedLocation(this);
6539 }
6540
6541 if (m_LockingSound)
6542 SEffectManager.DestroyEffect(m_LockingSound);
6543 }
6544
6545
6546
6547 // -------------------------------------------------------------------------
6548 static int GetDebugActionsMask()
6549 {
6550 return ItemBase.m_DebugActionsMask;
6551 }
6552
6553 static bool HasDebugActionsMask(int mask)
6554 {
6555 return ItemBase.m_DebugActionsMask & mask;
6556 }
6557
6558 static void SetDebugActionsMask(int mask)
6559 {
6560 ItemBase.m_DebugActionsMask = mask;
6561 }
6562
6563 static void AddDebugActionsMask(int mask)
6564 {
6565 ItemBase.m_DebugActionsMask |= mask;
6566 }
6567
6568 static void RemoveDebugActionsMask(int mask)
6569 {
6570 ItemBase.m_DebugActionsMask &= ~mask;
6571 }
6572
6573 static void ToggleDebugActionsMask(int mask)
6574 {
6575 if (HasDebugActionsMask(mask))
6576 {
6578 }
6579 else
6580 {
6581 AddDebugActionsMask(mask);
6582 }
6583 }
6584
6585 // -------------------------------------------------------------------------
6586 void SetCEBasedQuantity()
6587 {
6588 if (GetEconomyProfile())
6589 {
6590 float q_max = GetEconomyProfile().GetQuantityMax();
6591 if (q_max > 0)
6592 {
6593 float q_min = GetEconomyProfile().GetQuantityMin();
6594 float quantity_randomized = Math.RandomFloatInclusive(q_min, q_max);
6595
6596 if (HasComponent(COMP_TYPE_ENERGY_MANAGER))//more direct access for speed
6597 {
6598 ComponentEnergyManager comp = GetCompEM();
6599 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
6600 {
6601 comp.SetEnergy0To1(quantity_randomized);
6602 }
6603 }
6604 else if (HasQuantity())
6605 {
6606 SetQuantityNormalized(quantity_randomized, false);
6607 //PrintString("<==> Normalized quantity for item: "+ GetType()+", qmin:"+q_min.ToString()+"; qmax:"+q_max.ToString()+";quantity:" +quantity_randomized.ToString());
6608 }
6609
6610 }
6611 }
6612 }
6613
6615 void LockToParent()
6616 {
6617 EntityAI parent = GetHierarchyParent();
6618
6619 if (parent)
6620 {
6621 InventoryLocation inventory_location_to_lock = new InventoryLocation;
6622 GetInventory().GetCurrentInventoryLocation(inventory_location_to_lock);
6623 parent.GetInventory().SetSlotLock(inventory_location_to_lock.GetSlot(), true);
6624 }
6625 }
6626
6628 void UnlockFromParent()
6629 {
6630 EntityAI parent = GetHierarchyParent();
6631
6632 if (parent)
6633 {
6634 InventoryLocation inventory_location_to_unlock = new InventoryLocation;
6635 GetInventory().GetCurrentInventoryLocation(inventory_location_to_unlock);
6636 parent.GetInventory().SetSlotLock(inventory_location_to_unlock.GetSlot(), false);
6637 }
6638 }
6639
6640 override void CombineItemsClient(EntityAI entity2, bool use_stack_max = true)
6641 {
6642 /*
6643 ref Param1<EntityAI> item = new Param1<EntityAI>(entity2);
6644 RPCSingleParam(ERPCs.RPC_ITEM_COMBINE, item, GetGame().GetPlayer());
6645 */
6646 ItemBase item2 = ItemBase.Cast(entity2);
6647
6648 if (GetGame().IsClient())
6649 {
6650 if (ScriptInputUserData.CanStoreInputUserData())
6651 {
6652 ScriptInputUserData ctx = new ScriptInputUserData;
6654 ctx.Write(-1);
6655 ItemBase i1 = this; // @NOTE: workaround for correct serialization
6656 ctx.Write(i1);
6657 ctx.Write(item2);
6658 ctx.Write(use_stack_max);
6659 ctx.Write(-1);
6660 ctx.Send();
6661
6662 if (IsCombineAll(item2, use_stack_max))
6663 {
6664 GetGame().GetPlayer().GetInventory().AddInventoryReservationEx(item2,null,GameInventory.c_InventoryReservationTimeoutShortMS);
6665 }
6666 }
6667 }
6668 else if (!GetGame().IsMultiplayer())
6669 {
6670 CombineItems(item2, use_stack_max);
6671 }
6672 }
6673
6674 bool IsLiquidPresent()
6675 {
6676 return (GetLiquidType() != 0 && HasQuantity());
6677 }
6678
6679 bool IsLiquidContainer()
6680 {
6681 return m_LiquidContainerMask != 0;
6682 }
6683
6685 {
6686 return m_LiquidContainerMask;
6687 }
6688
6689 bool IsBloodContainer()
6690 {
6691 //m_LiquidContainerMask & GROUP_LIQUID_BLOOD ???
6692 return false;
6693 }
6694
6695 bool IsNVG()
6696 {
6697 return false;
6698 }
6699
6702 bool IsExplosive()
6703 {
6704 return false;
6705 }
6706
6708 {
6709 return "";
6710 }
6711
6713
6714 bool IsLightSource()
6715 {
6716 return false;
6717 }
6718
6720 {
6721 return true;
6722 }
6723
6724 //--- ACTION CONDITIONS
6725 //direction
6726 bool IsFacingPlayer(PlayerBase player, string selection)
6727 {
6728 return true;
6729 }
6730
6731 bool IsPlayerInside(PlayerBase player, string selection)
6732 {
6733 return true;
6734 }
6735
6736 override bool CanObstruct()
6737 {
6738 PlayerBase player = PlayerBase.Cast(g_Game.GetPlayer());
6739 return !player || !IsPlayerInside(player, "");
6740 }
6741
6742 override bool IsBeingPlaced()
6743 {
6744 return m_IsBeingPlaced;
6745 }
6746
6747 void SetIsBeingPlaced(bool is_being_placed)
6748 {
6749 m_IsBeingPlaced = is_being_placed;
6750 if (!is_being_placed)
6752 SetSynchDirty();
6753 }
6754
6755 //server-side
6756 void OnEndPlacement() {}
6757
6758 override bool IsHologram()
6759 {
6760 return m_IsHologram;
6761 }
6762
6763 bool CanBeDigged()
6764 {
6765 return m_CanBeDigged;
6766 }
6767
6769 {
6770 return 1;
6771 }
6772
6773 bool CanMakeGardenplot()
6774 {
6775 return false;
6776 }
6777
6778 void SetIsHologram(bool is_hologram)
6779 {
6780 m_IsHologram = is_hologram;
6781 SetSynchDirty();
6782 }
6783 /*
6784 protected float GetNutritionalEnergy()
6785 {
6786 Edible_Base edible = Edible_Base.Cast(this);
6787 return edible.GetFoodEnergy();
6788 }
6789
6790 protected float GetNutritionalWaterContent()
6791 {
6792 Edible_Base edible = Edible_Base.Cast(this);
6793 return edible.GetFoodWater();
6794 }
6795
6796 protected float GetNutritionalIndex()
6797 {
6798 Edible_Base edible = Edible_Base.Cast(this);
6799 return edible.GetFoodNutritionalIndex();
6800 }
6801
6802 protected float GetNutritionalFullnessIndex()
6803 {
6804 Edible_Base edible = Edible_Base.Cast(this);
6805 return edible.GetFoodTotalVolume();
6806 }
6807
6808 protected float GetNutritionalToxicity()
6809 {
6810 Edible_Base edible = Edible_Base.Cast(this);
6811 return edible.GetFoodToxicity();
6812
6813 }
6814 */
6815
6816
6817 // -------------------------------------------------------------------------
6818 override void OnMovedInsideCargo(EntityAI container)
6819 {
6820 super.OnMovedInsideCargo(container);
6821
6822 MiscGameplayFunctions.RemoveAllAttachedChildrenByTypename(this, {Bolt_Base});
6823 }
6824
6825 override void EEItemLocationChanged(notnull InventoryLocation oldLoc, notnull InventoryLocation newLoc)
6826 {
6827 super.EEItemLocationChanged(oldLoc,newLoc);
6828
6829 PlayerBase new_player = null;
6830 PlayerBase old_player = null;
6831
6832 if (newLoc.GetParent())
6833 new_player = PlayerBase.Cast(newLoc.GetParent().GetHierarchyRootPlayer());
6834
6835 if (oldLoc.GetParent())
6836 old_player = PlayerBase.Cast(oldLoc.GetParent().GetHierarchyRootPlayer());
6837
6838 if (old_player && oldLoc.GetType() == InventoryLocationType.HANDS)
6839 {
6840 int r_index = old_player.GetHumanInventory().FindUserReservedLocationIndex(this);
6841
6842 if (r_index >= 0)
6843 {
6844 InventoryLocation r_il = new InventoryLocation;
6845 old_player.GetHumanInventory().GetUserReservedLocation(r_index,r_il);
6846
6847 old_player.GetHumanInventory().ClearUserReservedLocationAtIndex(r_index);
6848 int r_type = r_il.GetType();
6849 if (r_type == InventoryLocationType.CARGO || r_type == InventoryLocationType.PROXYCARGO)
6850 {
6851 r_il.GetParent().GetOnReleaseLock().Invoke(this);
6852 }
6853 else if (r_type == InventoryLocationType.ATTACHMENT)
6854 {
6855 r_il.GetParent().GetOnAttachmentReleaseLock().Invoke(this, r_il.GetSlot());
6856 }
6857
6858 }
6859 }
6860
6861 if (newLoc.GetType() == InventoryLocationType.HANDS)
6862 {
6863 if (new_player)
6864 new_player.ForceStandUpForHeavyItems(newLoc.GetItem());
6865
6866 if (new_player == old_player)
6867 {
6868
6869 if (oldLoc.GetParent() && new_player.GetHumanInventory().LocationGetEntity(oldLoc) == NULL)
6870 {
6871 if (oldLoc.GetType() == InventoryLocationType.CARGO)
6872 {
6873 if (oldLoc.GetParent().GetInventory().TestAddEntityInCargoExLoc(oldLoc, false, false, false, true, false, false))
6874 {
6875 new_player.GetHumanInventory().SetUserReservedLocation(this,oldLoc);
6876 }
6877 }
6878 else
6879 {
6880 new_player.GetHumanInventory().SetUserReservedLocation(this,oldLoc);
6881 }
6882 }
6883
6884 if (new_player.GetHumanInventory().FindUserReservedLocationIndex(this) >= 0)
6885 {
6886 int type = oldLoc.GetType();
6887 if (type == InventoryLocationType.CARGO || type == InventoryLocationType.PROXYCARGO)
6888 {
6889 oldLoc.GetParent().GetOnSetLock().Invoke(this);
6890 }
6891 else if (type == InventoryLocationType.ATTACHMENT)
6892 {
6893 oldLoc.GetParent().GetOnAttachmentSetLock().Invoke(this, oldLoc.GetSlot());
6894 }
6895 }
6896 if (!m_OldLocation)
6897 {
6898 m_OldLocation = new InventoryLocation;
6899 }
6900 m_OldLocation.Copy(oldLoc);
6901 }
6902 else
6903 {
6904 if (m_OldLocation)
6905 {
6906 m_OldLocation.Reset();
6907 }
6908 }
6909
6911 }
6912 else
6913 {
6914 if (new_player)
6915 {
6916 int res_index = new_player.GetHumanInventory().FindCollidingUserReservedLocationIndex(this, newLoc);
6917 if (res_index >= 0)
6918 {
6919 InventoryLocation il = new InventoryLocation;
6920 new_player.GetHumanInventory().GetUserReservedLocation(res_index,il);
6921 ItemBase it = ItemBase.Cast(il.GetItem());
6922 new_player.GetHumanInventory().ClearUserReservedLocationAtIndex(res_index);
6923 int rel_type = il.GetType();
6924 if (rel_type == InventoryLocationType.CARGO || rel_type == InventoryLocationType.PROXYCARGO)
6925 {
6926 il.GetParent().GetOnReleaseLock().Invoke(it);
6927 }
6928 else if (rel_type == InventoryLocationType.ATTACHMENT)
6929 {
6930 il.GetParent().GetOnAttachmentReleaseLock().Invoke(it, il.GetSlot());
6931 }
6932 //it.GetOnReleaseLock().Invoke(it);
6933 }
6934 }
6935 else if (old_player && newLoc.GetType() == InventoryLocationType.GROUND && m_ThrowItemOnDrop)
6936 {
6937 //ThrowPhysically(old_player, vector.Zero);
6938 m_ThrowItemOnDrop = false;
6939 }
6940
6941 if (m_OldLocation)
6942 {
6943 m_OldLocation.Reset();
6944 }
6945 }
6946 }
6947
6948 override void EOnContact(IEntity other, Contact extra)
6949 {
6951 {
6952 int liquidType = -1;
6953 float impactSpeed = ProcessImpactSoundEx(other, extra, m_ConfigWeight, m_ImpactSoundSurfaceHash, liquidType);
6954 if (impactSpeed > 0.0)
6955 {
6956 m_ImpactSpeed = impactSpeed;
6957 #ifndef SERVER
6958 PlayImpactSound(m_ConfigWeight, m_ImpactSpeed, m_ImpactSoundSurfaceHash);
6959 #else
6960 m_WantPlayImpactSound = true;
6961 SetSynchDirty();
6962 #endif
6963 m_CanPlayImpactSound = (liquidType == -1);// prevents further playing of the sound when the surface is a liquid type
6964 }
6965 }
6966
6967 #ifdef SERVER
6968 if (GetCompEM() && GetCompEM().IsPlugged())
6969 {
6970 if (GetCompEM().GetCordLength() < vector.Distance(GetPosition(), GetCompEM().GetEnergySource().GetPosition()))
6971 GetCompEM().UnplugThis();
6972 }
6973 #endif
6974 }
6975
6976 void RefreshPhysics();
6977
6978 override void OnCreatePhysics()
6979 {
6981 }
6982
6983 override void OnItemAttachmentSlotChanged(notnull InventoryLocation oldLoc, notnull InventoryLocation newLoc)
6984 {
6985
6986 }
6987 // -------------------------------------------------------------------------
6988 override void OnItemLocationChanged(EntityAI old_owner, EntityAI new_owner)
6989 {
6990 super.OnItemLocationChanged(old_owner, new_owner);
6991
6992 PlayerBase relatedPlayer = PlayerBase.Cast(old_owner);
6993 PlayerBase playerNew = PlayerBase.Cast(new_owner);
6994
6995 if (!relatedPlayer && playerNew)
6996 relatedPlayer = playerNew;
6997
6998 if (relatedPlayer && relatedPlayer.GetPerformedActionID() != -1)
6999 {
7000 ActionManagerBase actionMgr = relatedPlayer.GetActionManager();
7001 if (actionMgr)
7002 {
7003 ActionBase currentAction = actionMgr.GetRunningAction();
7004 if (currentAction)
7005 currentAction.OnItemLocationChanged(this);
7006 }
7007 }
7008
7009 Man ownerPlayerOld = null;
7010 Man ownerPlayerNew = null;
7011
7012 if (old_owner)
7013 {
7014 if (old_owner.IsMan())
7015 {
7016 ownerPlayerOld = Man.Cast(old_owner);
7017 }
7018 else
7019 {
7020 ownerPlayerOld = Man.Cast(old_owner.GetHierarchyRootPlayer());
7021 }
7022 }
7023 else
7024 {
7025 if (new_owner && IsElectricAppliance() && GetCompEM() && GetCompEM().IsPlugged())
7026 {
7027 ActionBase action = ActionManagerBase.GetAction(ActionRepositionPluggedItem);
7028
7029 if (!action || !playerNew || playerNew.GetPerformedActionID() != action.GetID())
7030 {
7031 GetCompEM().UnplugThis();
7032 }
7033 }
7034 }
7035
7036 if (new_owner)
7037 {
7038 if (new_owner.IsMan())
7039 {
7040 ownerPlayerNew = Man.Cast(new_owner);
7041 }
7042 else
7043 {
7044 ownerPlayerNew = Man.Cast(new_owner.GetHierarchyRootPlayer());
7045 }
7046 }
7047
7048 if (ownerPlayerOld != ownerPlayerNew)
7049 {
7050 if (ownerPlayerOld)
7051 {
7052 array<EntityAI> subItemsExit = new array<EntityAI>;
7053 GetInventory().EnumerateInventory(InventoryTraversalType.PREORDER,subItemsExit);
7054 for (int i = 0; i < subItemsExit.Count(); i++)
7055 {
7056 ItemBase itemExit = ItemBase.Cast(subItemsExit.Get(i));
7057 itemExit.OnInventoryExit(ownerPlayerOld);
7058 }
7059 }
7060
7061 if (ownerPlayerNew)
7062 {
7063 array<EntityAI> subItemsEnter = new array<EntityAI>;
7064 GetInventory().EnumerateInventory(InventoryTraversalType.PREORDER,subItemsEnter);
7065 for (int j = 0; j < subItemsEnter.Count(); j++)
7066 {
7067 ItemBase itemEnter = ItemBase.Cast(subItemsEnter.Get(j));
7068 itemEnter.OnInventoryEnter(ownerPlayerNew);
7069 }
7070 }
7071 }
7072 else if (ownerPlayerNew != null)
7073 {
7074 PlayerBase nplayer;
7075 if (PlayerBase.CastTo(nplayer, ownerPlayerNew))
7076 {
7077 array<EntityAI> subItemsUpdate = new array<EntityAI>;
7078 GetInventory().EnumerateInventory(InventoryTraversalType.PREORDER,subItemsUpdate);
7079 for (int k = 0; k < subItemsUpdate.Count(); k++)
7080 {
7081 ItemBase itemUpdate = ItemBase.Cast(subItemsUpdate.Get(k));
7082 itemUpdate.UpdateQuickbarShortcutVisibility(nplayer);
7083 }
7084 }
7085 }
7086
7087 if (old_owner)
7088 old_owner.OnChildItemRemoved(this);
7089 if (new_owner)
7090 new_owner.OnChildItemReceived(this);
7091 }
7092
7093 // -------------------------------------------------------------------------------
7094 override void EEDelete(EntityAI parent)
7095 {
7096 super.EEDelete(parent);
7097 PlayerBase player = PlayerBase.Cast(GetHierarchyRootPlayer());
7098 if (player)
7099 {
7100 OnInventoryExit(player);
7101
7102 if (player.IsAlive())
7103 {
7104 int r_index = player.GetHumanInventory().FindUserReservedLocationIndex(this);
7105 if (r_index >= 0)
7106 {
7107 InventoryLocation r_il = new InventoryLocation;
7108 player.GetHumanInventory().GetUserReservedLocation(r_index,r_il);
7109
7110 player.GetHumanInventory().ClearUserReservedLocationAtIndex(r_index);
7111 int r_type = r_il.GetType();
7112 if (r_type == InventoryLocationType.CARGO || r_type == InventoryLocationType.PROXYCARGO)
7113 {
7114 r_il.GetParent().GetOnReleaseLock().Invoke(this);
7115 }
7116 else if (r_type == InventoryLocationType.ATTACHMENT)
7117 {
7118 r_il.GetParent().GetOnAttachmentReleaseLock().Invoke(this, r_il.GetSlot());
7119 }
7120
7121 }
7122
7123 player.RemoveQuickBarEntityShortcut(this);
7124 }
7125 }
7126 }
7127 // -------------------------------------------------------------------------------
7128 override void EEKilled(Object killer)
7129 {
7130 super.EEKilled(killer);
7131
7133 if (killer && killer.IsFireplace() && CanExplodeInFire())
7134 {
7135 if (GetTemperature() >= GameConstants.ITEM_TEMPERATURE_TO_EXPLODE_MIN)
7136 {
7137 if (IsMagazine())
7138 {
7139 if (Magazine.Cast(this).GetAmmoCount() > 0)
7140 {
7141 ExplodeAmmo();
7142 }
7143 }
7144 else
7145 {
7146 Explode(DamageType.EXPLOSION);
7147 }
7148 }
7149 }
7150 }
7151
7152 override void OnWasAttached(EntityAI parent, int slot_id)
7153 {
7154 MiscGameplayFunctions.RemoveAllAttachedChildrenByTypename(this, {Bolt_Base});
7155
7156 super.OnWasAttached(parent, slot_id);
7157
7158 if (HasQuantity())
7159 UpdateNetSyncVariableFloat("m_VarQuantity", GetQuantityMin(), m_VarQuantityMax);
7160
7161 PlayAttachSound(InventorySlots.GetSlotName(slot_id));
7162 }
7163
7164 override void OnWasDetached(EntityAI parent, int slot_id)
7165 {
7166 super.OnWasDetached(parent, slot_id);
7167
7168 if (HasQuantity())
7169 UpdateNetSyncVariableFloat("m_VarQuantity", GetQuantityMin(), m_VarQuantityMax);
7170 }
7171
7172 override string ChangeIntoOnAttach(string slot)
7173 {
7174 int idx;
7175 TStringArray inventory_slots = new TStringArray;
7176 TStringArray attach_types = new TStringArray;
7177
7178 ConfigGetTextArray("ChangeInventorySlot",inventory_slots);
7179 if (inventory_slots.Count() < 1) //is string
7180 {
7181 inventory_slots.Insert(ConfigGetString("ChangeInventorySlot"));
7182 attach_types.Insert(ConfigGetString("ChangeIntoOnAttach"));
7183 }
7184 else //is array
7185 {
7186 ConfigGetTextArray("ChangeIntoOnAttach",attach_types);
7187 }
7188
7189 idx = inventory_slots.Find(slot);
7190 if (idx < 0)
7191 return "";
7192
7193 return attach_types.Get(idx);
7194 }
7195
7196 override string ChangeIntoOnDetach()
7197 {
7198 int idx = -1;
7199 string slot;
7200
7201 TStringArray inventory_slots = new TStringArray;
7202 TStringArray detach_types = new TStringArray;
7203
7204 this.ConfigGetTextArray("ChangeInventorySlot",inventory_slots);
7205 if (inventory_slots.Count() < 1) //is string
7206 {
7207 inventory_slots.Insert(this.ConfigGetString("ChangeInventorySlot"));
7208 detach_types.Insert(this.ConfigGetString("ChangeIntoOnDetach"));
7209 }
7210 else //is array
7211 {
7212 this.ConfigGetTextArray("ChangeIntoOnDetach",detach_types);
7213 if (detach_types.Count() < 1)
7214 detach_types.Insert(this.ConfigGetString("ChangeIntoOnDetach"));
7215 }
7216
7217 for (int i = 0; i < inventory_slots.Count(); i++)
7218 {
7219 slot = inventory_slots.Get(i);
7220 }
7221
7222 if (slot != "")
7223 {
7224 if (detach_types.Count() == 1)
7225 idx = 0;
7226 else
7227 idx = inventory_slots.Find(slot);
7228 }
7229 if (idx < 0)
7230 return "";
7231
7232 return detach_types.Get(idx);
7233 }
7234
7235 void ExplodeAmmo()
7236 {
7237 //timer
7238 ref Timer explode_timer = new Timer(CALL_CATEGORY_SYSTEM);
7239
7240 //min/max time
7241 float min_time = 1;
7242 float max_time = 3;
7243 float delay = Math.RandomFloat(min_time, max_time);
7244
7245 explode_timer.Run(delay, this, "DoAmmoExplosion");
7246 }
7247
7248 void DoAmmoExplosion()
7249 {
7250 Magazine magazine = Magazine.Cast(this);
7251 int pop_sounds_count = 6;
7252 string pop_sounds[ 6 ] = { "ammopops_1","ammopops_2","ammopops_3","ammopops_4","ammopops_5","ammopops_6" };
7253
7254 //play sound
7255 int sound_idx = Math.RandomInt(0, pop_sounds_count - 1);
7256 string sound_name = pop_sounds[ sound_idx ];
7257 GetGame().CreateSoundOnObject(this, sound_name, 20, false);
7258
7259 //remove ammo count
7260 magazine.ServerAddAmmoCount(-1);
7261
7262 //if condition then repeat -> ExplodeAmmo
7263 float min_temp_to_explode = 100; //min temperature for item to explode
7264
7265 if (magazine.GetAmmoCount() > 0 && GetTemperature() >= min_temp_to_explode) //TODO ? add check for parent -> fireplace
7266 {
7267 ExplodeAmmo();
7268 }
7269 }
7270
7271 // -------------------------------------------------------------------------------
7272 override void EEHitBy(TotalDamageResult damageResult, int damageType, EntityAI source, int component, string dmgZone, string ammo, vector modelPos, float speedCoef)
7273 {
7274 super.EEHitBy(damageResult, damageType, source, component, dmgZone, ammo, modelPos, speedCoef);
7275
7276 const int CHANCE_DAMAGE_CARGO = 4;
7277 const int CHANCE_DAMAGE_ATTACHMENT = 1;
7278 const int CHANCE_DAMAGE_NOTHING = 2;
7279
7280 if (IsClothing() || IsContainer() || IsItemTent())
7281 {
7282 float dmg = damageResult.GetDamage("","Health") * -0.5;
7283 int chances;
7284 int rnd;
7285
7286 if (GetInventory().GetCargo())
7287 {
7288 chances = CHANCE_DAMAGE_CARGO + CHANCE_DAMAGE_ATTACHMENT + CHANCE_DAMAGE_NOTHING;
7289 rnd = Math.RandomInt(0,chances);
7290
7291 if (rnd < CHANCE_DAMAGE_CARGO)
7292 {
7293 DamageItemInCargo(dmg);
7294 }
7295 else if (rnd < (chances - CHANCE_DAMAGE_NOTHING))
7296 {
7298 }
7299 }
7300 else
7301 {
7302 chances = CHANCE_DAMAGE_ATTACHMENT + CHANCE_DAMAGE_NOTHING;
7303 rnd = Math.RandomInt(0,chances);
7304
7305 if (rnd < CHANCE_DAMAGE_ATTACHMENT)
7306 {
7308 }
7309 }
7310 }
7311 }
7312
7313 bool DamageItemInCargo(float damage)
7314 {
7315 if (GetInventory().GetCargo())
7316 {
7317 int item_count = GetInventory().GetCargo().GetItemCount();
7318 if (item_count > 0)
7319 {
7320 int random_pick = Math.RandomInt(0, item_count);
7321 ItemBase item = ItemBase.Cast(GetInventory().GetCargo().GetItem(random_pick));
7322 if (!item.IsExplosive())
7323 {
7324 item.AddHealth("","",damage);
7325 return true;
7326 }
7327 }
7328 }
7329 return false;
7330 }
7331
7332 bool DamageItemAttachments(float damage)
7333 {
7334 int attachment_count = GetInventory().AttachmentCount();
7335 if (attachment_count > 0)
7336 {
7337 int random_pick = Math.RandomInt(0, attachment_count);
7338 ItemBase attachment = ItemBase.Cast(GetInventory().GetAttachmentFromIndex(random_pick));
7339 if (!attachment.IsExplosive())
7340 {
7341 attachment.AddHealth("","",damage);
7342 return true;
7343 }
7344 }
7345 return false;
7346 }
7347
7348 override bool IsSplitable()
7349 {
7350 return m_CanThisBeSplit;
7351 }
7352 //----------------
7353 override bool CanBeSplit()
7354 {
7355 if (IsSplitable() && (GetQuantity() > 1))
7356 return GetInventory().CanRemoveEntity();
7357
7358 return false;
7359 }
7360
7361 protected bool ShouldSplitQuantity(float quantity)
7362 {
7363 // don't call 'CanBeSplit' here, too strict and will introduce a freeze-crash when dismantling fence with a fireplace nearby
7364 if (!IsSplitable())
7365 return false;
7366
7367 // nothing to split?
7368 if (GetQuantity() <= 1)
7369 return false;
7370
7371 // check if we should re-use the item instead of creating a new copy?
7372 // implicit cast to int, if 'IsSplitable' returns true, these values are assumed ints
7373 int delta = GetQuantity() - quantity;
7374 if (delta == 0)
7375 return false;
7376
7377 // valid to split
7378 return true;
7379 }
7380
7381 override void SplitIntoStackMaxClient(EntityAI destination_entity, int slot_id )
7382 {
7383 if (GetGame().IsClient())
7384 {
7385 if (ScriptInputUserData.CanStoreInputUserData())
7386 {
7387 ScriptInputUserData ctx = new ScriptInputUserData;
7389 ctx.Write(1);
7390 ItemBase i1 = this; // @NOTE: workaround for correct serialization
7391 ctx.Write(i1);
7392 ctx.Write(destination_entity);
7393 ctx.Write(true);
7394 ctx.Write(slot_id);
7395 ctx.Send();
7396 }
7397 }
7398 else if (!GetGame().IsMultiplayer())
7399 {
7400 SplitIntoStackMax(destination_entity, slot_id, PlayerBase.Cast(GetGame().GetPlayer()));
7401 }
7402 }
7403
7404 void SplitIntoStackMax(EntityAI destination_entity, int slot_id, PlayerBase player)
7405 {
7406 float split_quantity_new;
7407 ItemBase new_item;
7408 float quantity = GetQuantity();
7409 float stack_max = GetTargetQuantityMax(slot_id);
7410 InventoryLocation loc = new InventoryLocation;
7411
7412 if (destination_entity && slot_id != -1 && InventorySlots.IsSlotIdValid(slot_id))
7413 {
7414 if (stack_max <= GetQuantity())
7415 split_quantity_new = stack_max;
7416 else
7417 split_quantity_new = GetQuantity();
7418
7419 if (ShouldSplitQuantity(split_quantity_new))
7420 {
7421 new_item = ItemBase.Cast(destination_entity.GetInventory().CreateAttachmentEx(this.GetType(), slot_id));
7422 if (new_item)
7423 {
7424 new_item.SetResultOfSplit(true);
7425 MiscGameplayFunctions.TransferItemProperties(this, new_item);
7426 AddQuantity(-split_quantity_new, false, true);
7427 new_item.SetQuantity(split_quantity_new, false, true);
7428 }
7429 }
7430 }
7431 else if (destination_entity && slot_id == -1)
7432 {
7433 if (quantity > stack_max)
7434 split_quantity_new = stack_max;
7435 else
7436 split_quantity_new = quantity;
7437
7438 if (ShouldSplitQuantity(split_quantity_new))
7439 {
7440 if (destination_entity.GetInventory().FindFreeLocationFor(this, FindInventoryLocationType.ANY, loc))
7441 {
7442 Object o = destination_entity.GetInventory().LocationCreateEntity(loc, GetType(), ECE_IN_INVENTORY, RF_DEFAULT);
7443 new_item = ItemBase.Cast(o);
7444 }
7445
7446 if (new_item)
7447 {
7448 new_item.SetResultOfSplit(true);
7449 MiscGameplayFunctions.TransferItemProperties(this, new_item);
7450 AddQuantity(-split_quantity_new, false, true);
7451 new_item.SetQuantity(split_quantity_new, false, true);
7452 }
7453 }
7454 }
7455 else
7456 {
7457 if (stack_max != 0)
7458 {
7459 if (stack_max < GetQuantity())
7460 {
7461 split_quantity_new = GetQuantity() - stack_max;
7462 }
7463
7464 if (split_quantity_new == 0)
7465 {
7466 if (!GetGame().IsMultiplayer())
7467 player.PhysicalPredictiveDropItem(this);
7468 else
7469 player.ServerDropEntity(this);
7470 return;
7471 }
7472
7473 if (ShouldSplitQuantity(split_quantity_new))
7474 {
7475 new_item = ItemBase.Cast(GetGame().CreateObjectEx(GetType(), player.GetWorldPosition(), ECE_PLACE_ON_SURFACE));
7476
7477 if (new_item)
7478 {
7479 new_item.SetResultOfSplit(true);
7480 MiscGameplayFunctions.TransferItemProperties(this, new_item);
7481 SetQuantity(split_quantity_new, false, true);
7482 new_item.SetQuantity(stack_max, false, true);
7483 new_item.PlaceOnSurface();
7484 }
7485 }
7486 }
7487 }
7488 }
7489
7490 override void SplitIntoStackMaxEx(EntityAI destination_entity, int slot_id)
7491 {
7492 float split_quantity_new;
7493 ItemBase new_item;
7494 float quantity = GetQuantity();
7495 float stack_max = GetTargetQuantityMax(slot_id);
7496 InventoryLocation loc = new InventoryLocation;
7497
7498 if (destination_entity && slot_id != -1 && InventorySlots.IsSlotIdValid(slot_id))
7499 {
7500 if (stack_max <= GetQuantity())
7501 split_quantity_new = stack_max;
7502 else
7503 split_quantity_new = GetQuantity();
7504
7505 if (ShouldSplitQuantity(split_quantity_new))
7506 {
7507 new_item = ItemBase.Cast(destination_entity.GetInventory().CreateAttachmentEx(this.GetType(), slot_id));
7508 if (new_item)
7509 {
7510 new_item.SetResultOfSplit(true);
7511 MiscGameplayFunctions.TransferItemProperties(this, new_item);
7512 AddQuantity(-split_quantity_new, false, true);
7513 new_item.SetQuantity(split_quantity_new, false, true);
7514 }
7515 }
7516 }
7517 else if (destination_entity && slot_id == -1)
7518 {
7519 if (quantity > stack_max)
7520 split_quantity_new = stack_max;
7521 else
7522 split_quantity_new = quantity;
7523
7524 if (ShouldSplitQuantity(split_quantity_new))
7525 {
7526 if (destination_entity.GetInventory().FindFreeLocationFor(this, FindInventoryLocationType.ANY, loc))
7527 {
7528 Object o = destination_entity.GetInventory().LocationCreateEntity(loc, GetType(), ECE_IN_INVENTORY, RF_DEFAULT);
7529 new_item = ItemBase.Cast(o);
7530 }
7531
7532 if (new_item)
7533 {
7534 new_item.SetResultOfSplit(true);
7535 MiscGameplayFunctions.TransferItemProperties(this, new_item);
7536 AddQuantity(-split_quantity_new, false, true);
7537 new_item.SetQuantity(split_quantity_new, false, true);
7538 }
7539 }
7540 }
7541 else
7542 {
7543 if (stack_max != 0)
7544 {
7545 if (stack_max < GetQuantity())
7546 {
7547 split_quantity_new = GetQuantity() - stack_max;
7548 }
7549
7550 if (ShouldSplitQuantity(split_quantity_new))
7551 {
7552 new_item = ItemBase.Cast(GetGame().CreateObjectEx(GetType(),GetWorldPosition(), ECE_PLACE_ON_SURFACE));
7553
7554 if (new_item)
7555 {
7556 new_item.SetResultOfSplit(true);
7557 MiscGameplayFunctions.TransferItemProperties(this, new_item);
7558 SetQuantity(split_quantity_new, false, true);
7559 new_item.SetQuantity(stack_max, false, true);
7560 new_item.PlaceOnSurface();
7561 }
7562 }
7563 }
7564 }
7565 }
7566
7567 void SplitIntoStackMaxToInventoryLocationClient(notnull InventoryLocation dst)
7568 {
7569 if (GetGame().IsClient())
7570 {
7571 if (ScriptInputUserData.CanStoreInputUserData())
7572 {
7573 ScriptInputUserData ctx = new ScriptInputUserData;
7575 ctx.Write(4);
7576 ItemBase thiz = this; // @NOTE: workaround for correct serialization
7577 ctx.Write(thiz);
7578 dst.WriteToContext(ctx);
7579 ctx.Send();
7580 }
7581 }
7582 else if (!GetGame().IsMultiplayer())
7583 {
7585 }
7586 }
7587
7588 void SplitIntoStackMaxCargoClient(EntityAI destination_entity, int idx, int row, int col)
7589 {
7590 if (GetGame().IsClient())
7591 {
7592 if (ScriptInputUserData.CanStoreInputUserData())
7593 {
7594 ScriptInputUserData ctx = new ScriptInputUserData;
7596 ctx.Write(2);
7597 ItemBase dummy = this; // @NOTE: workaround for correct serialization
7598 ctx.Write(dummy);
7599 ctx.Write(destination_entity);
7600 ctx.Write(true);
7601 ctx.Write(idx);
7602 ctx.Write(row);
7603 ctx.Write(col);
7604 ctx.Send();
7605 }
7606 }
7607 else if (!GetGame().IsMultiplayer())
7608 {
7609 SplitIntoStackMaxCargo(destination_entity, idx, row, col);
7610 }
7611 }
7612
7613 void SplitIntoStackMaxToInventoryLocation(notnull InventoryLocation dst)
7614 {
7616 }
7617
7618 ItemBase SplitIntoStackMaxToInventoryLocationEx(notnull InventoryLocation dst)
7619 {
7620 float quantity = GetQuantity();
7621 float split_quantity_new;
7622 ItemBase new_item;
7623 if (dst.IsValid())
7624 {
7625 int slot_id = dst.GetSlot();
7626 float stack_max = GetTargetQuantityMax(slot_id);
7627
7628 if (quantity > stack_max)
7629 split_quantity_new = stack_max;
7630 else
7631 split_quantity_new = quantity;
7632
7633 if (ShouldSplitQuantity(split_quantity_new))
7634 {
7635 new_item = ItemBase.Cast(GameInventory.LocationCreateEntity(dst, this.GetType(), ECE_IN_INVENTORY, RF_DEFAULT));
7636
7637 if (new_item)
7638 {
7639 new_item.SetResultOfSplit(true);
7640 MiscGameplayFunctions.TransferItemProperties(this,new_item);
7641 AddQuantity(-split_quantity_new, false, true);
7642 new_item.SetQuantity(split_quantity_new, false, true);
7643 }
7644
7645 return new_item;
7646 }
7647 }
7648
7649 return null;
7650 }
7651
7652 void SplitIntoStackMaxCargo(EntityAI destination_entity, int idx, int row, int col)
7653 {
7654 float quantity = GetQuantity();
7655 float split_quantity_new;
7656 ItemBase new_item;
7657 if (destination_entity)
7658 {
7659 float stackable = GetTargetQuantityMax();
7660 if (quantity > stackable)
7661 split_quantity_new = stackable;
7662 else
7663 split_quantity_new = quantity;
7664
7665 if (ShouldSplitQuantity(split_quantity_new))
7666 {
7667 new_item = ItemBase.Cast(destination_entity.GetInventory().CreateEntityInCargoEx(this.GetType(), idx, row, col, false));
7668 if (new_item)
7669 {
7670 new_item.SetResultOfSplit(true);
7671 MiscGameplayFunctions.TransferItemProperties(this,new_item);
7672 AddQuantity(-split_quantity_new, false, true);
7673 new_item.SetQuantity(split_quantity_new, false, true);
7674 }
7675 }
7676 }
7677 }
7678
7679 void SplitIntoStackMaxHandsClient(PlayerBase player)
7680 {
7681 if (GetGame().IsClient())
7682 {
7683 if (ScriptInputUserData.CanStoreInputUserData())
7684 {
7685 ScriptInputUserData ctx = new ScriptInputUserData;
7687 ctx.Write(3);
7688 ItemBase i1 = this; // @NOTE: workaround for correct serialization
7689 ctx.Write(i1);
7690 ItemBase destination_entity = this;
7691 ctx.Write(destination_entity);
7692 ctx.Write(true);
7693 ctx.Write(0);
7694 ctx.Send();
7695 }
7696 }
7697 else if (!GetGame().IsMultiplayer())
7698 {
7699 SplitIntoStackMaxHands(player);
7700 }
7701 }
7702
7703 void SplitIntoStackMaxHands(PlayerBase player)
7704 {
7705 float quantity = GetQuantity();
7706 float split_quantity_new;
7707 ref ItemBase new_item;
7708 if (player)
7709 {
7710 float stackable = GetTargetQuantityMax();
7711 if (quantity > stackable)
7712 split_quantity_new = stackable;
7713 else
7714 split_quantity_new = quantity;
7715
7716 if (ShouldSplitQuantity(split_quantity_new))
7717 {
7718 EntityAI in_hands = player.GetHumanInventory().CreateInHands(this.GetType());
7719 new_item = ItemBase.Cast(in_hands);
7720 if (new_item)
7721 {
7722 new_item.SetResultOfSplit(true);
7723 MiscGameplayFunctions.TransferItemProperties(this,new_item);
7724 AddQuantity(-split_quantity_new, false, true);
7725 new_item.SetQuantity(split_quantity_new, false, true);
7726 }
7727 }
7728 }
7729 }
7730
7731 void SplitItemToInventoryLocation(notnull InventoryLocation dst)
7732 {
7733 float quantity = GetQuantity();
7734 float split_quantity_new = Math.Floor(quantity * 0.5);
7735
7736 if (!ShouldSplitQuantity(split_quantity_new))
7737 return;
7738
7739 ItemBase new_item = ItemBase.Cast(GameInventory.LocationCreateEntity(dst, GetType(), ECE_IN_INVENTORY, RF_DEFAULT));
7740
7741 if (new_item)
7742 {
7743 if (new_item.GetQuantityMax() < split_quantity_new)
7744 {
7745 split_quantity_new = new_item.GetQuantityMax();
7746 }
7747
7748 new_item.SetResultOfSplit(true);
7749 MiscGameplayFunctions.TransferItemProperties(this, new_item);
7750
7751 if (dst.IsValid() && dst.GetType() == InventoryLocationType.ATTACHMENT && split_quantity_new > 1)
7752 {
7753 AddQuantity(-1, false, true);
7754 new_item.SetQuantity(1, false, true);
7755 }
7756 else
7757 {
7758 AddQuantity(-split_quantity_new, false, true);
7759 new_item.SetQuantity(split_quantity_new, false, true);
7760 }
7761 }
7762 }
7763
7764 void SplitItem(PlayerBase player)
7765 {
7766 float quantity = GetQuantity();
7767 float split_quantity_new = Math.Floor(quantity / 2);
7768
7769 if (!ShouldSplitQuantity(split_quantity_new))
7770 return;
7771
7772 InventoryLocation invloc = new InventoryLocation;
7773 bool found = player.GetInventory().FindFirstFreeLocationForNewEntity(GetType(), FindInventoryLocationType.ATTACHMENT, invloc);
7774
7775 ItemBase new_item;
7776 new_item = player.CreateCopyOfItemInInventoryOrGroundEx(this, true);
7777
7778 if (new_item)
7779 {
7780 if (new_item.GetQuantityMax() < split_quantity_new)
7781 {
7782 split_quantity_new = new_item.GetQuantityMax();
7783 }
7784 if (found && invloc.IsValid() && invloc.GetType() == InventoryLocationType.ATTACHMENT && split_quantity_new > 1)
7785 {
7786 AddQuantity(-1, false, true);
7787 new_item.SetQuantity(1, false, true);
7788 }
7789 else if (split_quantity_new > 1)
7790 {
7791 AddQuantity(-split_quantity_new, false, true);
7792 new_item.SetQuantity(split_quantity_new, false, true);
7793 }
7794 }
7795 }
7796
7798 void OnQuantityChanged(float delta)
7799 {
7800 SetWeightDirty();
7801 ItemBase parent = ItemBase.Cast(GetHierarchyParent());
7802
7803 if (parent)
7804 parent.OnAttachmentQuantityChangedEx(this, delta);
7805
7806 if (IsLiquidContainer())
7807 {
7808 if (GetQuantityNormalized() <= 0.0)
7809 {
7811 }
7812 else if (GetLiquidType() == LIQUID_NONE)
7813 {
7814 ErrorEx("Undefined liquid type quantity changed, please define liquid type first! Using init value.",ErrorExSeverity.INFO);
7816 }
7817 }
7818
7819 }
7820
7823 {
7824 // insert code here
7825 }
7826
7828 void OnAttachmentQuantityChangedEx(ItemBase item , float delta)
7829 {
7831 }
7832
7833 override void EEHealthLevelChanged(int oldLevel, int newLevel, string zone)
7834 {
7835 super.EEHealthLevelChanged(oldLevel,newLevel,zone);
7836
7837 if (GetGame().IsServer())
7838 {
7839 if (newLevel == GameConstants.STATE_RUINED)
7840 {
7842 EntityAI parent = GetHierarchyParent();
7843 if (parent && parent.IsFireplace())
7844 {
7845 CargoBase cargo = GetInventory().GetCargo();
7846 if (cargo)
7847 {
7848 for (int i = 0; i < cargo.GetItemCount(); ++i)
7849 {
7850 parent.GetInventory().TakeEntityToInventory(InventoryMode.SERVER, FindInventoryLocationType.CARGO, cargo.GetItem(i));
7851 }
7852 }
7853 }
7854 }
7855
7856 if (IsResultOfSplit())
7857 {
7858 // reset the splitting result flag, return to normal item behavior
7859 SetResultOfSplit(false);
7860 return;
7861 }
7862
7863 if (m_Cleanness != 0 && oldLevel < newLevel && newLevel != 0)
7864 {
7865 SetCleanness(0);//unclean the item upon damage dealt
7866 }
7867 }
7868 }
7869
7870 // just the split? TODO: verify
7871 override void OnRightClick()
7872 {
7873 super.OnRightClick();
7874
7875 if (CanBeSplit() && !GetDayZGame().IsLeftCtrlDown() && !GetGame().GetPlayer().GetInventory().HasInventoryReservation(this,null))
7876 {
7877 if (GetGame().IsClient())
7878 {
7879 if (ScriptInputUserData.CanStoreInputUserData())
7880 {
7881 EntityAI root = GetHierarchyRoot();
7882 Man playerOwner = GetHierarchyRootPlayer();
7883 InventoryLocation dst = new InventoryLocation;
7884
7885 // 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
7886 if (!playerOwner && root && root == this)
7887 {
7889 }
7890 else
7891 {
7892 // 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
7893 GetInventory().GetCurrentInventoryLocation(dst);
7894 if (!dst.GetParent() || dst.GetParent() && !dst.GetParent().GetInventory().FindFreeLocationFor(this, FindInventoryLocationType.CARGO, dst))
7895 {
7896 PlayerBase player = PlayerBase.Cast(GetGame().GetPlayer());
7897 if (!player.GetInventory().FindFreeLocationFor(this, FindInventoryLocationType.CARGO, dst) || !playerOwner)
7898 {
7900 }
7901 else
7902 {
7903 dst.SetCargo(dst.GetParent(), this, dst.GetIdx(), dst.GetRow(), dst.GetCol(), dst.GetFlip());
7904 /* hacky solution to check reservation of "this" item instead of null since the gamecode is checking null against null and returning reservation=true incorrectly
7905 this shouldnt cause issues within this scope*/
7906 if (GetGame().GetPlayer().GetInventory().HasInventoryReservation(this, dst))
7907 {
7909 }
7910 else
7911 {
7912 GetGame().GetPlayer().GetInventory().AddInventoryReservationEx(null, dst, GameInventory.c_InventoryReservationTimeoutShortMS);
7913 }
7914 }
7915 }
7916 }
7917
7918 ScriptInputUserData ctx = new ScriptInputUserData;
7920 ctx.Write(4);
7921 ItemBase thiz = this; // @NOTE: workaround for correct serialization
7922 ctx.Write(thiz);
7923 dst.WriteToContext(ctx);
7924 ctx.Write(true); // dummy
7925 ctx.Send();
7926 }
7927 }
7928 else if (!GetGame().IsMultiplayer())
7929 {
7930 SplitItem(PlayerBase.Cast(GetGame().GetPlayer()));
7931 }
7932 }
7933 }
7934
7935 protected void SetInventoryLocationToVicinityOrCurrent(EntityAI root, inout InventoryLocation dst)
7936 {
7937 if (root)
7938 {
7939 vector m4[4];
7940 root.GetTransform(m4);
7941 dst.SetGround(this, m4);
7942 }
7943 else
7944 {
7945 GetInventory().GetCurrentInventoryLocation(dst);
7946 }
7947 }
7948
7949 override bool CanBeCombined(EntityAI other_item, bool reservation_check = true, bool stack_max_limit = false)
7950 {
7951 //TODO: delete check zero quantity check after fix double posts hands fsm events
7952 if (!other_item || GetType() != other_item.GetType() || (IsFullQuantity() && other_item.GetQuantity() > 0) || other_item == this)
7953 return false;
7954
7955 if (GetHealthLevel() == GameConstants.STATE_RUINED || other_item.GetHealthLevel() == GameConstants.STATE_RUINED)
7956 return false;
7957
7958 //can_this_be_combined = ConfigGetBool("canBeSplit");
7960 return false;
7961
7962
7963 Magazine mag = Magazine.Cast(this);
7964 if (mag)
7965 {
7966 if (mag.GetAmmoCount() >= mag.GetAmmoMax())
7967 return false;
7968
7969 if (stack_max_limit)
7970 {
7971 Magazine other_mag = Magazine.Cast(other_item);
7972 if (other_item)
7973 {
7974 if (mag.GetAmmoCount() + other_mag.GetAmmoCount() > mag.GetAmmoMax())
7975 return false;
7976 }
7977
7978 }
7979 }
7980 else
7981 {
7982 //TODO: delete check zero quantity check after fix double posts hands fsm events
7983 if (GetQuantity() >= GetQuantityMax() && other_item.GetQuantity() > 0 )
7984 return false;
7985
7986 if (stack_max_limit && (GetQuantity() + other_item.GetQuantity() > GetQuantityMax()))
7987 return false;
7988 }
7989
7990 PlayerBase player = null;
7991 if (CastTo(player, GetHierarchyRootPlayer())) //false when attached to player's attachment slot
7992 {
7993 if (player.GetInventory().HasAttachment(this))
7994 return false;
7995
7996 if (player.IsItemsToDelete())
7997 return false;
7998 }
7999
8000 if (reservation_check && (GetInventory().HasInventoryReservation(this, null) || other_item.GetInventory().HasInventoryReservation(other_item, null)))
8001 return false;
8002
8003 int slotID;
8004 string slotName;
8005 if (GetInventory().GetCurrentAttachmentSlotInfo(slotID,slotName) && GetHierarchyParent().GetInventory().GetSlotLock(slotID))
8006 return false;
8007
8008 return true;
8009 }
8010
8011 bool IsCombineAll(ItemBase other_item, bool use_stack_max = false)
8012 {
8013 return ComputeQuantityUsed(other_item, use_stack_max) == other_item.GetQuantity();
8014 }
8015
8016 bool IsResultOfSplit()
8017 {
8018 return m_IsResultOfSplit;
8019 }
8020
8021 void SetResultOfSplit(bool value)
8022 {
8023 m_IsResultOfSplit = value;
8024 }
8025
8026 int ComputeQuantityUsed(ItemBase other_item, bool use_stack_max = true)
8027 {
8028 return ComputeQuantityUsedEx(other_item, use_stack_max);
8029 }
8030
8031 float ComputeQuantityUsedEx(ItemBase other_item, bool use_stack_max = true)
8032 {
8033 float other_item_quantity = other_item.GetQuantity();
8034 float this_free_space;
8035
8036 float stack_max = GetQuantityMax();
8037
8038 this_free_space = stack_max - GetQuantity();
8039
8040 if (other_item_quantity > this_free_space)
8041 {
8042 return this_free_space;
8043 }
8044 else
8045 {
8046 return other_item_quantity;
8047 }
8048 }
8049
8050 override void CombineItemsEx(EntityAI entity2, bool use_stack_max = true)
8051 {
8052 CombineItems(ItemBase.Cast(entity2),use_stack_max);
8053 }
8054
8055 void CombineItems(ItemBase other_item, bool use_stack_max = true)
8056 {
8057 if (!CanBeCombined(other_item, false))
8058 return;
8059
8060 if (!IsMagazine() && other_item)
8061 {
8062 float quantity_used = ComputeQuantityUsedEx(other_item,use_stack_max);
8063 if (quantity_used != 0)
8064 {
8065 float hp1 = GetHealth01("","");
8066 float hp2 = other_item.GetHealth01("","");
8067 float hpResult = ((hp1*GetQuantity()) + (hp2*quantity_used));
8068 hpResult = hpResult / (GetQuantity() + quantity_used);
8069
8070 hpResult *= GetMaxHealth();
8071 Math.Round(hpResult);
8072 SetHealth("", "Health", hpResult);
8073
8074 AddQuantity(quantity_used);
8075 other_item.AddQuantity(-quantity_used);
8076 }
8077 }
8078 OnCombine(other_item);
8079 }
8080
8081 void OnCombine(ItemBase other_item)
8082 {
8083 #ifdef SERVER
8084 if (!GetHierarchyRootPlayer() && GetHierarchyParent())
8085 GetHierarchyParent().IncreaseLifetimeUp();
8086 #endif
8087 };
8088
8089 void GetRecipesActions(Man player, out TSelectableActionInfoArray outputList)
8090 {
8091 PlayerBase p = PlayerBase.Cast(player);
8092
8093 array<int> recipesIds = p.m_Recipes;
8094 PluginRecipesManager moduleRecipesManager = PluginRecipesManager.Cast(GetPlugin(PluginRecipesManager));
8095 if (moduleRecipesManager)
8096 {
8097 EntityAI itemInHands = player.GetHumanInventory().GetEntityInHands();
8098 moduleRecipesManager.GetValidRecipes(ItemBase.Cast(this), ItemBase.Cast(itemInHands), recipesIds, p);
8099 }
8100
8101 for (int i = 0;i < recipesIds.Count(); i++)
8102 {
8103 int key = recipesIds.Get(i);
8104 string recipeName = moduleRecipesManager.GetRecipeName(key);
8105 outputList.Insert(new TSelectableActionInfo(SAT_CRAFTING, key, recipeName));
8106 }
8107 }
8108
8109 // -------------------------------------------------------------------------
8110 override void GetDebugActions(out TSelectableActionInfoArrayEx outputList)
8111 {
8112 super.GetDebugActions(outputList);
8113
8114 //quantity
8115 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.ADD_QUANTITY, "Quantity +20%", FadeColors.LIGHT_GREY));
8116 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.REMOVE_QUANTITY, "Quantity -20%", FadeColors.LIGHT_GREY));
8117 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SET_QUANTITY_0, "Set Quantity 0", FadeColors.LIGHT_GREY));
8118 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SET_MAX_QUANTITY, "Set Quantity Max", FadeColors.LIGHT_GREY));
8119 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SEPARATOR, "___________________________", FadeColors.RED));
8120
8121 //health
8122 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.ADD_HEALTH, "Health +20%", FadeColors.LIGHT_GREY));
8123 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.REMOVE_HEALTH, "Health -20%", FadeColors.LIGHT_GREY));
8124 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.DESTROY_HEALTH, "Health 0", FadeColors.LIGHT_GREY));
8125 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SEPARATOR, "___________________________", FadeColors.RED));
8126 //temperature
8127 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.ADD_TEMPERATURE, "Temperature +20", FadeColors.LIGHT_GREY));
8128 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.REMOVE_TEMPERATURE, "Temperature -20", FadeColors.LIGHT_GREY));
8129 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.FLIP_FROZEN, "Toggle Frozen", FadeColors.LIGHT_GREY));
8130 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SEPARATOR, "___________________________", FadeColors.RED));
8131
8132 //wet
8133 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.ADD_WETNESS, "Wetness +20", FadeColors.LIGHT_GREY));
8134 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.REMOVE_WETNESS, "Wetness -20", FadeColors.LIGHT_GREY));
8135 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SEPARATOR, "___________________________", FadeColors.RED));
8136
8137 //liquidtype
8138 if (IsLiquidContainer())
8139 {
8140 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.LIQUIDTYPE_UP, "LiquidType Next", FadeColors.LIGHT_GREY));
8141 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.LIQUIDTYPE_DOWN, "LiquidType Previous", FadeColors.LIGHT_GREY));
8142 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SEPARATOR, "___________________________", FadeColors.RED));
8143 }
8144
8145 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.MAKE_SPECIAL, "Make Special", FadeColors.LIGHT_GREY));
8146 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SEPARATOR, "___________________________", FadeColors.RED));
8147
8148 // watch
8149 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.WATCH_ITEM, "Watch (CTRL-Z)", FadeColors.LIGHT_GREY));
8150 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.WATCH_PLAYER, "Watch Player", FadeColors.LIGHT_GREY));
8151 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SEPARATOR, "___________________________", FadeColors.RED));
8152
8153 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.DELETE, "Delete", FadeColors.RED));
8154
8155 InventoryLocation loc = new InventoryLocation();
8156 GetInventory().GetCurrentInventoryLocation(loc);
8157 if (!loc || loc.GetType() == InventoryLocationType.GROUND)
8158 {
8159 if (Gizmo_IsSupported())
8160 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.GIZMO_OBJECT, "Gizmo Object", FadeColors.LIGHT_GREY));
8161 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.GIZMO_PHYSICS, "Gizmo Physics (SP Only)", FadeColors.LIGHT_GREY)); // intentionally allowed for testing physics desync
8162 }
8163
8164 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SEPARATOR, "___________________________", FadeColors.RED));
8165 }
8166
8167 // -------------------------------------------------------------------------
8168 // -------------------------------------------------------------------------
8169 // -------------------------------------------------------------------------
8170 override bool OnAction(int action_id, Man player, ParamsReadContext ctx)
8171 {
8172 super.OnAction(action_id, player, ctx);
8173
8174 if (GetGame().IsClient() || !GetGame().IsMultiplayer())
8175 {
8176 switch (action_id)
8177 {
8178 case EActions.GIZMO_OBJECT:
8179 GetGame().GizmoSelectObject(this);
8180 return true;
8181 case EActions.GIZMO_PHYSICS:
8182 GetGame().GizmoSelectPhysics(GetPhysics());
8183 return true;
8184 }
8185 }
8186
8187 if (GetGame().IsServer())
8188 {
8189 switch (action_id)
8190 {
8191 case EActions.DELETE:
8192 Delete();
8193 return true;
8194 }
8195 }
8196
8197 if (action_id >= EActions.RECIPES_RANGE_START && action_id < EActions.RECIPES_RANGE_END)
8198 {
8199 PluginRecipesManager plugin_recipes_manager = PluginRecipesManager.Cast(GetPlugin(PluginRecipesManager));
8200 int idWithoutOffset = action_id - EActions.RECIPES_RANGE_START;
8201 PlayerBase p = PlayerBase.Cast(player);
8202 if (EActions.RECIPES_RANGE_START < 1000)
8203 {
8204 float anim_length = plugin_recipes_manager.GetRecipeLengthInSecs(idWithoutOffset);
8205 float specialty_weight = plugin_recipes_manager.GetRecipeSpecialty(idWithoutOffset);
8206 }
8207 }
8208 #ifndef SERVER
8209 else if (action_id == EActions.WATCH_PLAYER)
8210 {
8211 PluginDeveloper.SetDeveloperItemClientEx(player);
8212 }
8213 #endif
8214 if (GetGame().IsServer())
8215 {
8216 if (action_id >= EActions.DEBUG_ITEM_WATCH_BUTTON_RANGE_START && action_id < EActions.DEBUG_ITEM_WATCH_BUTTON_RANGE_END)
8217 {
8218 int id = action_id - EActions.DEBUG_ITEM_WATCH_BUTTON_RANGE_START;
8219 OnDebugButtonPressServer(id + 1);
8220 }
8221
8222 else if (action_id >= EActions.DEBUG_AGENTS_RANGE_INJECT_START && action_id < EActions.DEBUG_AGENTS_RANGE_INJECT_END)
8223 {
8224 int agent_id = action_id - EActions.DEBUG_AGENTS_RANGE_INJECT_START;
8225 InsertAgent(agent_id,100);
8226 }
8227
8228 else if (action_id >= EActions.DEBUG_AGENTS_RANGE_REMOVE_START && action_id < EActions.DEBUG_AGENTS_RANGE_REMOVE_END)
8229 {
8230 int agent_id2 = action_id - EActions.DEBUG_AGENTS_RANGE_REMOVE_START;
8231 RemoveAgent(agent_id2);
8232 }
8233
8234 else if (action_id == EActions.ADD_QUANTITY)
8235 {
8236 if (IsMagazine())
8237 {
8238 Magazine mag = Magazine.Cast(this);
8239 mag.ServerSetAmmoCount(mag.GetAmmoCount() + mag.GetAmmoMax() * 0.2);
8240 }
8241 else
8242 {
8243 AddQuantity(GetQuantityMax() * 0.2);
8244 }
8245
8246 if (m_EM)
8247 {
8248 m_EM.AddEnergy(m_EM.GetEnergyMax() * 0.2);
8249 }
8250 //PrintVariables();
8251 }
8252
8253 else if (action_id == EActions.REMOVE_QUANTITY) //Quantity -20%
8254 {
8255 if (IsMagazine())
8256 {
8257 Magazine mag2 = Magazine.Cast(this);
8258 mag2.ServerSetAmmoCount(mag2.GetAmmoCount() - mag2.GetAmmoMax() * 0.2);
8259 }
8260 else
8261 {
8262 AddQuantity(- GetQuantityMax() * 0.2);
8263 }
8264 if (m_EM)
8265 {
8266 m_EM.AddEnergy(- m_EM.GetEnergyMax() * 0.2);
8267 }
8268 //PrintVariables();
8269 }
8270
8271 else if (action_id == EActions.SET_QUANTITY_0) //SetMaxQuantity
8272 {
8273 SetQuantity(0);
8274
8275 if (m_EM)
8276 {
8277 m_EM.SetEnergy(0);
8278 }
8279 }
8280
8281 else if (action_id == EActions.SET_MAX_QUANTITY) //SetMaxQuantity
8282 {
8284
8285 if (m_EM)
8286 {
8287 m_EM.SetEnergy(m_EM.GetEnergyMax());
8288 }
8289 }
8290
8291 else if (action_id == EActions.ADD_HEALTH)
8292 {
8293 AddHealth("","",GetMaxHealth("","Health")/5);
8294 }
8295 else if (action_id == EActions.REMOVE_HEALTH)
8296 {
8297 AddHealth("","",-GetMaxHealth("","Health")/5);
8298 }
8299 else if (action_id == EActions.DESTROY_HEALTH)
8300 {
8301 SetHealth01("","",0);
8302 }
8303 else if (action_id == EActions.WATCH_ITEM)
8304 {
8306 mid.RegisterDebugItem(ItemBase.Cast(this), PlayerBase.Cast(player));
8307 #ifdef DEVELOPER
8308 SetDebugDeveloper_item(this);
8309 #endif
8310 }
8311
8312 else if (action_id == EActions.ADD_TEMPERATURE)
8313 {
8314 AddTemperature(20);
8315 //PrintVariables();
8316 }
8317
8318 else if (action_id == EActions.REMOVE_TEMPERATURE)
8319 {
8320 AddTemperature(-20);
8321 //PrintVariables();
8322 }
8323
8324 else if (action_id == EActions.FLIP_FROZEN)
8325 {
8326 SetFrozen(!GetIsFrozen());
8327 //PrintVariables();
8328 }
8329
8330 else if (action_id == EActions.ADD_WETNESS)
8331 {
8332 AddWet(GetWetMax()/5);
8333 //PrintVariables();
8334 }
8335
8336 else if (action_id == EActions.REMOVE_WETNESS)
8337 {
8338 AddWet(-GetWetMax()/5);
8339 //PrintVariables();
8340 }
8341
8342 else if (action_id == EActions.LIQUIDTYPE_UP)
8343 {
8344 int curr_type = GetLiquidType();
8345 SetLiquidType(curr_type * 2);
8346 //AddWet(1);
8347 //PrintVariables();
8348 }
8349
8350 else if (action_id == EActions.LIQUIDTYPE_DOWN)
8351 {
8352 int curr_type2 = GetLiquidType();
8353 SetLiquidType(curr_type2 / 2);
8354 }
8355
8356 else if (action_id == EActions.MAKE_SPECIAL)
8357 {
8358 auto debugParams = DebugSpawnParams.WithPlayer(player);
8359 OnDebugSpawnEx(debugParams);
8360 }
8361
8362 }
8363
8364
8365 return false;
8366 }
8367
8368 // -------------------------------------------------------------------------
8369
8370
8373 void OnActivatedByTripWire();
8374
8376 void OnActivatedByItem(notnull ItemBase item);
8377
8378 //----------------------------------------------------------------
8379 //returns true if item is able to explode when put in fire
8380 bool CanExplodeInFire()
8381 {
8382 return false;
8383 }
8384
8385 //----------------------------------------------------------------
8386 bool CanEat()
8387 {
8388 return true;
8389 }
8390
8391 //----------------------------------------------------------------
8392 override bool IsIgnoredByConstruction()
8393 {
8394 return true;
8395 }
8396
8397 //----------------------------------------------------------------
8398 //has FoodStages in config?
8399 bool HasFoodStage()
8400 {
8401 string config_path = string.Format("CfgVehicles %1 Food FoodStages", GetType());
8402 return GetGame().ConfigIsExisting(config_path);
8403 }
8404
8406 FoodStage GetFoodStage()
8407 {
8408 return null;
8409 }
8410
8411 bool CanBeCooked()
8412 {
8413 return false;
8414 }
8415
8416 bool CanBeCookedOnStick()
8417 {
8418 return false;
8419 }
8420
8422 void RefreshAudioVisualsOnClient( CookingMethodType cooking_method, bool is_done, bool is_empty, bool is_burned );
8424
8425 //----------------------------------------------------------------
8426 bool CanRepair(ItemBase item_repair_kit)
8427 {
8428 PluginRepairing module_repairing = PluginRepairing.Cast(GetPlugin(PluginRepairing));
8429 return module_repairing.CanRepair(this, item_repair_kit);
8430 }
8431
8432 //----------------------------------------------------------------
8433 bool Repair(PlayerBase player, ItemBase item_repair_kit, float specialty_weight)
8434 {
8435 PluginRepairing module_repairing = PluginRepairing.Cast(GetPlugin(PluginRepairing));
8436 return module_repairing.Repair(player, this, item_repair_kit, specialty_weight);
8437 }
8438
8439 //----------------------------------------------------------------
8440 int GetItemSize()
8441 {
8442 /*
8443 vector v_size = this.ConfigGetVector("itemSize");
8444 int v_size_x = v_size[0];
8445 int v_size_y = v_size[1];
8446 int size = v_size_x * v_size_y;
8447 return size;
8448 */
8449
8450 return 1;
8451 }
8452
8453 //----------------------------------------------------------------
8454 //Override for allowing seemingly unallowed moves when two clients send a conflicting message simultaneously
8455 bool CanBeMovedOverride()
8456 {
8457 return m_CanBeMovedOverride;
8458 }
8459
8460 //----------------------------------------------------------------
8461 //Override for allowing seemingly unallowed moves when two clients send a conflicting message simultaneously
8462 void SetCanBeMovedOverride(bool setting)
8463 {
8464 m_CanBeMovedOverride = setting;
8465 }
8466
8467 //----------------------------------------------------------------
8475 void MessageToOwnerStatus(string text)
8476 {
8477 PlayerBase player = PlayerBase.Cast(this.GetHierarchyRootPlayer());
8478
8479 if (player)
8480 {
8481 player.MessageStatus(text);
8482 }
8483 }
8484
8485 //----------------------------------------------------------------
8493 void MessageToOwnerAction(string text)
8494 {
8495 PlayerBase player = PlayerBase.Cast(this.GetHierarchyRootPlayer());
8496
8497 if (player)
8498 {
8499 player.MessageAction(text);
8500 }
8501 }
8502
8503 //----------------------------------------------------------------
8511 void MessageToOwnerFriendly(string text)
8512 {
8513 PlayerBase player = PlayerBase.Cast(this.GetHierarchyRootPlayer());
8514
8515 if (player)
8516 {
8517 player.MessageFriendly(text);
8518 }
8519 }
8520
8521 //----------------------------------------------------------------
8529 void MessageToOwnerImportant(string text)
8530 {
8531 PlayerBase player = PlayerBase.Cast(this.GetHierarchyRootPlayer());
8532
8533 if (player)
8534 {
8535 player.MessageImportant(text);
8536 }
8537 }
8538
8539 override bool IsItemBase()
8540 {
8541 return true;
8542 }
8543
8544 // Checks if item is of questioned kind
8545 override bool KindOf(string tag)
8546 {
8547 bool found = false;
8548 string item_name = this.GetType();
8549 ref TStringArray item_tag_array = new TStringArray;
8550 GetGame().ConfigGetTextArray("cfgVehicles " + item_name + " itemInfo", item_tag_array);
8551
8552 int array_size = item_tag_array.Count();
8553 for (int i = 0; i < array_size; i++)
8554 {
8555 if (item_tag_array.Get(i) == tag)
8556 {
8557 found = true;
8558 break;
8559 }
8560 }
8561 return found;
8562 }
8563
8564
8565 override void OnRPC(PlayerIdentity sender, int rpc_type,ParamsReadContext ctx)
8566 {
8567 //Debug.Log("OnRPC called");
8568 super.OnRPC(sender, rpc_type,ctx);
8569
8570 //Play soundset for attachment locking (ActionLockAttachment.c)
8571 switch (rpc_type)
8572 {
8573 #ifndef SERVER
8574 case ERPCs.RPC_SOUND_LOCK_ATTACH:
8575 Param2<bool, string> p = new Param2<bool, string>(false, "");
8576
8577 if (!ctx.Read(p))
8578 return;
8579
8580 bool play = p.param1;
8581 string soundSet = p.param2;
8582
8583 if (play)
8584 {
8585 if (m_LockingSound)
8586 {
8588 {
8589 m_LockingSound = SEffectManager.PlaySound(soundSet, GetPosition(), 0, 0, true);
8590 }
8591 }
8592 else
8593 {
8594 m_LockingSound = SEffectManager.PlaySound(soundSet, GetPosition(), 0, 0, true);
8595 }
8596 }
8597 else
8598 {
8599 SEffectManager.DestroyEffect(m_LockingSound);
8600 }
8601
8602 break;
8603 #endif
8604
8605 }
8606
8607 if (GetWrittenNoteData())
8608 {
8609 GetWrittenNoteData().OnRPC(sender, rpc_type,ctx);
8610 }
8611 }
8612
8613 //-----------------------------
8614 // VARIABLE MANIPULATION SYSTEM
8615 //-----------------------------
8616 int NameToID(string name)
8617 {
8618 PluginVariables plugin = PluginVariables.Cast(GetPlugin(PluginVariables));
8619 return plugin.GetID(name);
8620 }
8621
8622 string IDToName(int id)
8623 {
8624 PluginVariables plugin = PluginVariables.Cast(GetPlugin(PluginVariables));
8625 return plugin.GetName(id);
8626 }
8627
8629 void OnSyncVariables(ParamsReadContext ctx)//with ID optimization
8630 {
8631 //Debug.Log("OnSyncVariables called for item: "+ ToString(this.GetType()),"varSync");
8632 //read the flags
8633 int varFlags;
8634 if (!ctx.Read(varFlags))
8635 return;
8636
8637 if (varFlags & ItemVariableFlags.FLOAT)
8638 {
8639 ReadVarsFromCTX(ctx);
8640 }
8641 }
8642
8643 override void SerializeNumericalVars(array<float> floats_out)
8644 {
8645 //some variables handled on EntityAI level already!
8646 super.SerializeNumericalVars(floats_out);
8647
8648 // the order of serialization must be the same as the order of de-serialization
8649 //--------------------------------------------
8650 if (IsVariableSet(VARIABLE_QUANTITY))
8651 {
8652 floats_out.Insert(m_VarQuantity);
8653 }
8654 //--------------------------------------------
8655 if (IsVariableSet(VARIABLE_WET))
8656 {
8657 floats_out.Insert(m_VarWet);
8658 }
8659 //--------------------------------------------
8660 if (IsVariableSet(VARIABLE_LIQUIDTYPE))
8661 {
8662 floats_out.Insert(m_VarLiquidType);
8663 }
8664 //--------------------------------------------
8665 if (IsVariableSet(VARIABLE_COLOR))
8666 {
8667 floats_out.Insert(m_ColorComponentR);
8668 floats_out.Insert(m_ColorComponentG);
8669 floats_out.Insert(m_ColorComponentB);
8670 floats_out.Insert(m_ColorComponentA);
8671 }
8672 //--------------------------------------------
8673 if (IsVariableSet(VARIABLE_CLEANNESS))
8674 {
8675 floats_out.Insert(m_Cleanness);
8676 }
8677 }
8678
8679 override void DeSerializeNumericalVars(array<float> floats)
8680 {
8681 //some variables handled on EntityAI level already!
8682 super.DeSerializeNumericalVars(floats);
8683
8684 // the order of serialization must be the same as the order of de-serialization
8685 int index = 0;
8686 int mask = Math.Round(floats.Get(index));
8687
8688 index++;
8689 //--------------------------------------------
8690 if (mask & VARIABLE_QUANTITY)
8691 {
8692 if (m_IsStoreLoad)
8693 {
8694 SetStoreLoadedQuantity(floats.Get(index));
8695 }
8696 else
8697 {
8698 float quantity = floats.Get(index);
8699 SetQuantity(quantity, true, false, false, false);
8700 }
8701 index++;
8702 }
8703 //--------------------------------------------
8704 if (mask & VARIABLE_WET)
8705 {
8706 float wet = floats.Get(index);
8707 SetWet(wet);
8708 index++;
8709 }
8710 //--------------------------------------------
8711 if (mask & VARIABLE_LIQUIDTYPE)
8712 {
8713 int liquidtype = Math.Round(floats.Get(index));
8714 SetLiquidType(liquidtype);
8715 index++;
8716 }
8717 //--------------------------------------------
8718 if (mask & VARIABLE_COLOR)
8719 {
8720 m_ColorComponentR = Math.Round(floats.Get(index));
8721 index++;
8722 m_ColorComponentG = Math.Round(floats.Get(index));
8723 index++;
8724 m_ColorComponentB = Math.Round(floats.Get(index));
8725 index++;
8726 m_ColorComponentA = Math.Round(floats.Get(index));
8727 index++;
8728 }
8729 //--------------------------------------------
8730 if (mask & VARIABLE_CLEANNESS)
8731 {
8732 int cleanness = Math.Round(floats.Get(index));
8733 SetCleanness(cleanness);
8734 index++;
8735 }
8736 }
8737
8738 override void WriteVarsToCTX(ParamsWriteContext ctx)
8739 {
8740 super.WriteVarsToCTX(ctx);
8741
8742 //--------------------------------------------
8743 if (IsVariableSet(VARIABLE_QUANTITY))
8744 {
8745 ctx.Write(GetQuantity());
8746 }
8747 //--------------------------------------------
8748 if (IsVariableSet(VARIABLE_WET))
8749 {
8750 ctx.Write(GetWet());
8751 }
8752 //--------------------------------------------
8753 if (IsVariableSet(VARIABLE_LIQUIDTYPE))
8754 {
8755 ctx.Write(GetLiquidType());
8756 }
8757 //--------------------------------------------
8758 if (IsVariableSet(VARIABLE_COLOR))
8759 {
8760 int r,g,b,a;
8761 GetColor(r,g,b,a);
8762 ctx.Write(r);
8763 ctx.Write(g);
8764 ctx.Write(b);
8765 ctx.Write(a);
8766 }
8767 //--------------------------------------------
8768 if (IsVariableSet(VARIABLE_CLEANNESS))
8769 {
8770 ctx.Write(GetCleanness());
8771 }
8772 }
8773
8774 override bool ReadVarsFromCTX(ParamsReadContext ctx, int version = -1)//with ID optimization
8775 {
8776 if (!super.ReadVarsFromCTX(ctx,version))
8777 return false;
8778
8779 int intValue;
8780 float value;
8781
8782 if (version < 140)
8783 {
8784 if (!ctx.Read(intValue))
8785 return false;
8786
8787 m_VariablesMask = intValue;
8788 }
8789
8790 if (m_VariablesMask & VARIABLE_QUANTITY)
8791 {
8792 if (!ctx.Read(value))
8793 return false;
8794
8795 if (IsStoreLoad())
8796 {
8798 }
8799 else
8800 {
8801 SetQuantity(value, true, false, false, false);
8802 }
8803 }
8804 //--------------------------------------------
8805 if (version < 140)
8806 {
8807 if (m_VariablesMask & VARIABLE_TEMPERATURE)
8808 {
8809 if (!ctx.Read(value))
8810 return false;
8811 SetTemperatureDirect(value);
8812 }
8813 }
8814 //--------------------------------------------
8815 if (m_VariablesMask & VARIABLE_WET)
8816 {
8817 if (!ctx.Read(value))
8818 return false;
8819 SetWet(value);
8820 }
8821 //--------------------------------------------
8822 if (m_VariablesMask & VARIABLE_LIQUIDTYPE)
8823 {
8824 if (!ctx.Read(intValue))
8825 return false;
8826 SetLiquidType(intValue);
8827 }
8828 //--------------------------------------------
8829 if (m_VariablesMask & VARIABLE_COLOR)
8830 {
8831 int r,g,b,a;
8832 if (!ctx.Read(r))
8833 return false;
8834 if (!ctx.Read(g))
8835 return false;
8836 if (!ctx.Read(b))
8837 return false;
8838 if (!ctx.Read(a))
8839 return false;
8840
8841 SetColor(r,g,b,a);
8842 }
8843 //--------------------------------------------
8844 if (m_VariablesMask & VARIABLE_CLEANNESS)
8845 {
8846 if (!ctx.Read(intValue))
8847 return false;
8848 SetCleanness(intValue);
8849 }
8850 //--------------------------------------------
8851 if (version >= 138 && version < 140)
8852 {
8853 if (m_VariablesMask & VARIABLE_TEMPERATURE)
8854 {
8855 if (!ctx.Read(intValue))
8856 return false;
8857 SetFrozen(intValue);
8858 }
8859 }
8860
8861 return true;
8862 }
8863
8864 //----------------------------------------------------------------
8865 override bool OnStoreLoad(ParamsReadContext ctx, int version)
8866 {
8867 m_IsStoreLoad = true;
8869 {
8870 m_FixDamageSystemInit = true;
8871 }
8872
8873 if (!super.OnStoreLoad(ctx, version))
8874 {
8875 m_IsStoreLoad = false;
8876 return false;
8877 }
8878
8879 if (version >= 114)
8880 {
8881 bool hasQuickBarIndexSaved;
8882
8883 if (!ctx.Read(hasQuickBarIndexSaved))
8884 {
8885 m_IsStoreLoad = false;
8886 return false;
8887 }
8888
8889 if (hasQuickBarIndexSaved)
8890 {
8891 int itmQBIndex;
8892
8893 //Load quickbar item bind
8894 if (!ctx.Read(itmQBIndex))
8895 {
8896 m_IsStoreLoad = false;
8897 return false;
8898 }
8899
8900 PlayerBase parentPlayer = PlayerBase.Cast(GetHierarchyRootPlayer());
8901 if (itmQBIndex != -1 && parentPlayer)
8902 parentPlayer.SetLoadedQuickBarItemBind(this, itmQBIndex);
8903 }
8904 }
8905 else
8906 {
8907 // Backup of how it used to be
8908 PlayerBase player;
8909 int itemQBIndex;
8910 if (version == int.MAX)
8911 {
8912 if (!ctx.Read(itemQBIndex))
8913 {
8914 m_IsStoreLoad = false;
8915 return false;
8916 }
8917 }
8918 else if (Class.CastTo(player, GetHierarchyRootPlayer()))
8919 {
8920 //Load quickbar item bind
8921 if (!ctx.Read(itemQBIndex))
8922 {
8923 m_IsStoreLoad = false;
8924 return false;
8925 }
8926 if (itemQBIndex != -1 && player)
8927 player.SetLoadedQuickBarItemBind(this,itemQBIndex);
8928 }
8929 }
8930
8931 if (version < 140)
8932 {
8933 // variable management system
8934 if (!LoadVariables(ctx, version))
8935 {
8936 m_IsStoreLoad = false;
8937 return false;
8938 }
8939 }
8940
8941 //agent trasmission system
8942 if (!LoadAgents(ctx, version))
8943 {
8944 m_IsStoreLoad = false;
8945 return false;
8946 }
8947 if (version >= 132)
8948 {
8949 RemotelyActivatedItemBehaviour raib = GetRemotelyActivatedItemBehaviour();
8950 if (raib)
8951 {
8952 if (!raib.OnStoreLoad(ctx,version))
8953 {
8954 m_IsStoreLoad = false;
8955 return false;
8956 }
8957 }
8958 }
8959
8960 m_IsStoreLoad = false;
8961 return true;
8962 }
8963
8964 //----------------------------------------------------------------
8965
8966 override void OnStoreSave(ParamsWriteContext ctx)
8967 {
8968 super.OnStoreSave(ctx);
8969
8970 PlayerBase player;
8971 if (PlayerBase.CastTo(player,GetHierarchyRootPlayer()))
8972 {
8973 ctx.Write(true); // Keep track of if we should actually read this in or not
8974 //Save quickbar item bind
8975 int itemQBIndex = -1;
8976 itemQBIndex = player.FindQuickBarEntityIndex(this);
8977 ctx.Write(itemQBIndex);
8978 }
8979 else
8980 {
8981 ctx.Write(false); // Keep track of if we should actually read this in or not
8982 }
8983
8984 SaveAgents(ctx);//agent trasmission system
8985
8986 RemotelyActivatedItemBehaviour raib = GetRemotelyActivatedItemBehaviour();
8987 if (raib)
8988 {
8989 raib.OnStoreSave(ctx);
8990 }
8991 }
8992 //----------------------------------------------------------------
8993
8994 override void AfterStoreLoad()
8995 {
8996 super.AfterStoreLoad();
8997
8999 {
9001 }
9002
9003 if (GetStoreLoadedQuantity() != float.LOWEST)
9004 {
9006 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
9007 }
9008 }
9009
9010 override void EEOnAfterLoad()
9011 {
9012 super.EEOnAfterLoad();
9013
9015 {
9016 m_FixDamageSystemInit = false;
9017 }
9018
9021 }
9022
9023 bool CanBeDisinfected()
9024 {
9025 return false;
9026 }
9027
9028
9029 //----------------------------------------------------------------
9030 override void OnVariablesSynchronized()
9031 {
9032 if (m_Initialized)
9033 {
9034 #ifdef PLATFORM_CONSOLE
9035 //bruteforce it is
9036 if (IsSplitable())
9037 {
9038 UIScriptedMenu menu = GetGame().GetUIManager().FindMenu(MENU_INVENTORY);
9039 if (menu)
9040 {
9041 menu.Refresh();
9042 }
9043 }
9044 #endif
9045 }
9046
9048 {
9049 PlayImpactSound(m_ConfigWeight, m_ImpactSpeed, m_ImpactSoundSurfaceHash);
9050 m_WantPlayImpactSound = false;
9051 }
9052
9054 {
9055 SetWeightDirty();
9057 }
9058 if (m_VarWet != m_VarWetPrev)
9059 {
9062 }
9063
9064 if (m_SoundSyncPlay != 0)
9065 {
9066 m_ItemSoundHandler.PlayItemSoundClient(m_SoundSyncPlay);
9067 m_SoundSyncPlay = 0;
9068 }
9069 if (m_SoundSyncStop != 0)
9070 {
9071 m_ItemSoundHandler.StopItemSoundClient(m_SoundSyncStop);
9072 m_SoundSyncStop = 0;
9073 }
9074
9075 super.OnVariablesSynchronized();
9076 }
9077
9078 //------------------------- Quantity
9079 //----------------------------------------------------------------
9081 override bool SetQuantity(float value, bool destroy_config = true, bool destroy_forced = false, bool allow_client = false, bool clamp_to_stack_max = true)
9082 {
9083 if (!IsServerCheck(allow_client))
9084 return false;
9085
9086 if (!HasQuantity())
9087 return false;
9088
9089 float min = GetQuantityMin();
9090 float max = GetQuantityMax();
9091
9092 if (value <= (min + 0.001))
9093 value = min;
9094
9095 if (value == min)
9096 {
9097 if (destroy_config)
9098 {
9099 bool dstr = ConfigGetBool("varQuantityDestroyOnMin");
9100 if (dstr)
9101 {
9102 m_VarQuantity = Math.Clamp(value, min, max);
9103 this.Delete();
9104 return true;
9105 }
9106 }
9107 else if (destroy_forced)
9108 {
9109 m_VarQuantity = Math.Clamp(value, min, max);
9110 this.Delete();
9111 return true;
9112 }
9113 // we get here if destroy_config IS true AND dstr(config destroy param) IS false;
9114 RemoveAllAgents();//we remove all agents when we got to the min value, but the item is not getting deleted
9115 }
9116
9117 float delta = m_VarQuantity;
9118 m_VarQuantity = Math.Clamp(value, min, max);
9119
9120 if (GetStoreLoadedQuantity() == float.LOWEST)//any other value means we are setting quantity from storage
9121 {
9122 delta = m_VarQuantity - delta;
9123
9124 if (delta)
9125 OnQuantityChanged(delta);
9126 }
9127
9128 SetVariableMask(VARIABLE_QUANTITY);
9129
9130 return false;
9131 }
9132
9133 //----------------------------------------------------------------
9135 bool AddQuantity(float value, bool destroy_config = true, bool destroy_forced = false)
9136 {
9137 return SetQuantity(GetQuantity() + value, destroy_config, destroy_forced);
9138 }
9139 //----------------------------------------------------------------
9140 void SetQuantityMax()
9141 {
9142 float max = GetQuantityMax();
9143 SetQuantity(max);
9144 }
9145
9146 override void SetQuantityToMinimum()
9147 {
9148 float min = GetQuantityMin();
9149 SetQuantity(min);
9150 }
9151 //----------------------------------------------------------------
9153 override void SetQuantityNormalized(float value, bool destroy_config = true, bool destroy_forced = false)
9154 {
9155 float value_clamped = Math.Clamp(value, 0, 1);//just to make sure
9156 int result = Math.Round(Math.Lerp(GetQuantityMin(), GetQuantityMax(), value_clamped));
9157 SetQuantity(result, destroy_config, destroy_forced);
9158 }
9159
9160 //----------------------------------------------------------------
9162 override float GetQuantityNormalized()
9163 {
9164 return Math.InverseLerp(GetQuantityMin(), GetQuantityMax(),m_VarQuantity);
9165 }
9166
9168 {
9169 return GetQuantityNormalized();
9170 }
9171
9172 /*void SetAmmoNormalized(float value)
9173 {
9174 float value_clamped = Math.Clamp(value, 0, 1);
9175 Magazine this_mag = Magazine.Cast(this);
9176 int max_rounds = this_mag.GetAmmoMax();
9177 int result = value * max_rounds;//can the rounded if higher precision is required
9178 this_mag.SetAmmoCount(result);
9179 }*/
9180 //----------------------------------------------------------------
9181 override int GetQuantityMax()
9182 {
9183 int slot = -1;
9184 if (GetInventory())
9185 {
9186 InventoryLocation il = new InventoryLocation;
9187 GetInventory().GetCurrentInventoryLocation(il);
9188 slot = il.GetSlot();
9189 }
9190
9191 return GetTargetQuantityMax(slot);
9192 }
9193
9194 override int GetTargetQuantityMax(int attSlotID = -1)
9195 {
9196 float quantity_max = 0;
9197
9198 if (IsSplitable()) //only stackable/splitable items can check for stack size
9199 {
9200 if (attSlotID != -1)
9201 quantity_max = InventorySlots.GetStackMaxForSlotId(attSlotID);
9202
9203 if (quantity_max <= 0)
9204 quantity_max = m_VarStackMax;
9205 }
9206
9207 if (quantity_max <= 0)
9208 quantity_max = m_VarQuantityMax;
9209
9210 return quantity_max;
9211 }
9212 //----------------------------------------------------------------
9213 override int GetQuantityMin()
9214 {
9215 return m_VarQuantityMin;
9216 }
9217 //----------------------------------------------------------------
9218 int GetQuantityInit()
9219 {
9220 return m_VarQuantityInit;
9221 }
9222
9223 //----------------------------------------------------------------
9224 override bool HasQuantity()
9225 {
9226 return !(GetQuantityMax() - GetQuantityMin() == 0);
9227 }
9228
9229 override float GetQuantity()
9230 {
9231 return m_VarQuantity;
9232 }
9233
9234 bool IsFullQuantity()
9235 {
9236 return GetQuantity() >= GetQuantityMax();
9237 }
9238
9239 //Calculates weight of single item without attachments and cargo
9240 override float GetSingleInventoryItemWeightEx()
9241 {
9242 //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
9243 float weightEx = GetWeightEx();//overall weight of the item
9244 float special = GetInventoryAndCargoWeight();//cargo and attachment weight
9245 return weightEx - special;
9246 }
9247
9248 // Obsolete, use GetSingleInventoryItemWeightEx() instead
9250 {
9252 }
9253
9254 override protected float GetWeightSpecialized(bool forceRecalc = false)
9255 {
9256 if (IsSplitable()) //quantity determines size of the stack
9257 {
9258 #ifdef DEVELOPER
9259 if (WeightDebug.m_VerbosityFlags & WeightDebugType.RECALC_FORCED)
9260 {
9261 WeightDebugData data1 = WeightDebug.GetWeightDebug(this);
9262 data1.SetCalcDetails("TIB1: " + GetConfigWeightModifiedDebugText() +" * " + GetQuantity()+"(quantity)");
9263 }
9264 #endif
9265
9266 return GetQuantity() * GetConfigWeightModified();
9267 }
9268 else if (HasEnergyManager())// items with energy manager
9269 {
9270 #ifdef DEVELOPER
9271 if (WeightDebug.m_VerbosityFlags & WeightDebugType.RECALC_FORCED)
9272 {
9273 WeightDebugData data2 = WeightDebug.GetWeightDebug(this);
9274 data2.SetCalcDetails("TIB2: "+super.GetWeightSpecialized(forceRecalc)+"(contents weight) + " + GetConfigWeightModifiedDebugText() +" + " + GetCompEM().GetEnergy()+"(energy) * " + ConfigGetFloat("weightPerQuantityUnit") +"(weightPerQuantityUnit)");
9275 }
9276 #endif
9277 return super.GetWeightSpecialized(forceRecalc) + (GetCompEM().GetEnergy() * ConfigGetFloat("weightPerQuantityUnit")) + GetConfigWeightModified();
9278 }
9279 else//everything else
9280 {
9281 #ifdef DEVELOPER
9282 if (WeightDebug.m_VerbosityFlags & WeightDebugType.RECALC_FORCED)
9283 {
9284 WeightDebugData data3 = WeightDebug.GetWeightDebug(this);
9285 data3.SetCalcDetails("TIB3: "+super.GetWeightSpecialized(forceRecalc)+"(contents weight) + " + GetConfigWeightModifiedDebugText() +" + " + GetQuantity()+"(quantity) * " + ConfigGetFloat("weightPerQuantityUnit") +"(weightPerQuantityUnit))");
9286 }
9287 #endif
9288 return super.GetWeightSpecialized(forceRecalc) + (GetQuantity() * ConfigGetFloat("weightPerQuantityUnit")) + GetConfigWeightModified();
9289 }
9290 }
9291
9293 int GetNumberOfItems()
9294 {
9295 int item_count = 0;
9296 ItemBase item;
9297
9298 if (GetInventory().GetCargo() != NULL)
9299 {
9300 item_count = GetInventory().GetCargo().GetItemCount();
9301 }
9302
9303 for (int i = 0; i < GetInventory().AttachmentCount(); i++)
9304 {
9305 Class.CastTo(item,GetInventory().GetAttachmentFromIndex(i));
9306 if (item)
9307 item_count += item.GetNumberOfItems();
9308 }
9309 return item_count;
9310 }
9311
9313 float GetUnitWeight(bool include_wetness = true)
9314 {
9315 float weight = 0;
9316 float wetness = 1;
9317 if (include_wetness)
9318 wetness += GetWet();
9319 if (IsSplitable()) //quantity determines size of the stack
9320 {
9321 weight = wetness * m_ConfigWeight;
9322 }
9323 else if (IsLiquidContainer()) //is a liquid container, default liquid weight is set to 1. May revisit later?
9324 {
9325 weight = 1;
9326 }
9327 return weight;
9328 }
9329
9330 //-----------------------------------------------------------------
9331
9332 override void ClearInventory()
9333 {
9334 if ((GetGame().IsServer() || !GetGame().IsMultiplayer()) && GetInventory())
9335 {
9336 GameInventory inv = GetInventory();
9337 array<EntityAI> items = new array<EntityAI>;
9338 inv.EnumerateInventory(InventoryTraversalType.INORDER, items);
9339 for (int i = 0; i < items.Count(); i++)
9340 {
9341 ItemBase item = ItemBase.Cast(items.Get(i));
9342 if (item)
9343 {
9344 GetGame().ObjectDelete(item);
9345 }
9346 }
9347 }
9348 }
9349
9350 //------------------------- Energy
9351
9352 //----------------------------------------------------------------
9353 float GetEnergy()
9354 {
9355 float energy = 0;
9356 if (HasEnergyManager())
9357 {
9358 energy = GetCompEM().GetEnergy();
9359 }
9360 return energy;
9361 }
9362
9363
9364 override void OnEnergyConsumed()
9365 {
9366 super.OnEnergyConsumed();
9367
9369 }
9370
9371 override void OnEnergyAdded()
9372 {
9373 super.OnEnergyAdded();
9374
9376 }
9377
9378 // Converts energy (from Energy Manager) to quantity, if enabled.
9380 {
9381 if (GetGame().IsServer() && HasEnergyManager() && GetCompEM().HasConversionOfEnergyToQuantity())
9382 {
9383 if (HasQuantity())
9384 {
9385 float energy_0to1 = GetCompEM().GetEnergy0To1();
9386 SetQuantityNormalized(energy_0to1);
9387 }
9388 }
9389 }
9390
9391 //----------------------------------------------------------------
9392 float GetHeatIsolationInit()
9393 {
9394 return ConfigGetFloat("heatIsolation");
9395 }
9396
9397 float GetHeatIsolation()
9398 {
9399 return m_HeatIsolation;
9400 }
9401
9402 float GetDryingIncrement(string pIncrementName)
9403 {
9404 string paramPath = string.Format("CfgVehicles %1 EnvironmentWetnessIncrements Drying %2", GetType(), pIncrementName);
9405 if (GetGame().ConfigIsExisting(paramPath))
9406 return GetGame().ConfigGetFloat(paramPath);
9407
9408 return 0.0;
9409 }
9410
9411 float GetSoakingIncrement(string pIncrementName)
9412 {
9413 string paramPath = string.Format("CfgVehicles %1 EnvironmentWetnessIncrements Soaking %2", GetType(), pIncrementName);
9414 if (GetGame().ConfigIsExisting(paramPath))
9415 return GetGame().ConfigGetFloat(paramPath);
9416
9417 return 0.0;
9418 }
9419 //----------------------------------------------------------------
9420 override void SetWet(float value, bool allow_client = false)
9421 {
9422 if (!IsServerCheck(allow_client))
9423 return;
9424
9425 float min = GetWetMin();
9426 float max = GetWetMax();
9427
9428 float previousValue = m_VarWet;
9429
9430 m_VarWet = Math.Clamp(value, min, max);
9431
9432 if (previousValue != m_VarWet)
9433 {
9434 SetVariableMask(VARIABLE_WET);
9435 OnWetChanged(m_VarWet, previousValue);
9436 }
9437 }
9438 //----------------------------------------------------------------
9439 override void AddWet(float value)
9440 {
9441 SetWet(GetWet() + value);
9442 }
9443 //----------------------------------------------------------------
9444 override void SetWetMax()
9445 {
9447 }
9448 //----------------------------------------------------------------
9449 override float GetWet()
9450 {
9451 return m_VarWet;
9452 }
9453 //----------------------------------------------------------------
9454 override float GetWetMax()
9455 {
9456 return m_VarWetMax;
9457 }
9458 //----------------------------------------------------------------
9459 override float GetWetMin()
9460 {
9461 return m_VarWetMin;
9462 }
9463 //----------------------------------------------------------------
9464 override float GetWetInit()
9465 {
9466 return m_VarWetInit;
9467 }
9468 //----------------------------------------------------------------
9469 override void OnWetChanged(float newVal, float oldVal)
9470 {
9471 EWetnessLevel newLevel = GetWetLevelInternal(newVal);
9472 EWetnessLevel oldLevel = GetWetLevelInternal(oldVal);
9473 if (newLevel != oldLevel)
9474 {
9475 OnWetLevelChanged(newLevel,oldLevel);
9476 }
9477 }
9478
9479 override void OnWetLevelChanged(EWetnessLevel newLevel, EWetnessLevel oldLevel)
9480 {
9481 SetWeightDirty();
9482 }
9483
9484 override EWetnessLevel GetWetLevel()
9485 {
9486 return GetWetLevelInternal(m_VarWet);
9487 }
9488
9489 //----------------------------------------------------------------
9490
9491 override void SetStoreLoad(bool value)
9492 {
9493 m_IsStoreLoad = value;
9494 }
9495
9496 override bool IsStoreLoad()
9497 {
9498 return m_IsStoreLoad;
9499 }
9500
9501 override void SetStoreLoadedQuantity(float value)
9502 {
9503 m_StoreLoadedQuantity = value;
9504 }
9505
9506 override float GetStoreLoadedQuantity()
9507 {
9508 return m_StoreLoadedQuantity;
9509 }
9510
9511 //----------------------------------------------------------------
9512
9513 float GetItemModelLength()
9514 {
9515 if (ConfigIsExisting("itemModelLength"))
9516 {
9517 return ConfigGetFloat("itemModelLength");
9518 }
9519 return 0;
9520 }
9521
9522 float GetItemAttachOffset()
9523 {
9524 if (ConfigIsExisting("itemAttachOffset"))
9525 {
9526 return ConfigGetFloat("itemAttachOffset");
9527 }
9528 return 0;
9529 }
9530
9531 override void SetCleanness(int value, bool allow_client = false)
9532 {
9533 if (!IsServerCheck(allow_client))
9534 return;
9535
9536 int previousValue = m_Cleanness;
9537
9538 m_Cleanness = Math.Clamp(value, m_CleannessMin, m_CleannessMax);
9539
9540 if (previousValue != m_Cleanness)
9541 SetVariableMask(VARIABLE_CLEANNESS);
9542 }
9543
9544 override int GetCleanness()
9545 {
9546 return m_Cleanness;
9547 }
9548
9550 {
9551 return true;
9552 }
9553
9554 //----------------------------------------------------------------
9555 // ATTACHMENT LOCKING
9556 // Getters relevant to generic ActionLockAttachment
9557 int GetLockType()
9558 {
9559 return m_LockType;
9560 }
9561
9562 string GetLockSoundSet()
9563 {
9564 return m_LockSoundSet;
9565 }
9566
9567 //----------------------------------------------------------------
9568 //------------------------- Color
9569 // sets items color variable given color components
9570 override void SetColor(int r, int g, int b, int a)
9571 {
9576 SetVariableMask(VARIABLE_COLOR);
9577 }
9579 override void GetColor(out int r,out int g,out int b,out int a)
9580 {
9585 }
9586
9587 bool IsColorSet()
9588 {
9589 return IsVariableSet(VARIABLE_COLOR);
9590 }
9591
9593 string GetColorString()
9594 {
9595 int r,g,b,a;
9596 GetColor(r,g,b,a);
9597 r = r/255;
9598 g = g/255;
9599 b = b/255;
9600 a = a/255;
9601 return MiscGameplayFunctions.GetColorString(r, g, b, a);
9602 }
9603 //----------------------------------------------------------------
9604 //------------------------- LiquidType
9605
9606 override void SetLiquidType(int value, bool allow_client = false)
9607 {
9608 if (!IsServerCheck(allow_client))
9609 return;
9610
9611 int old = m_VarLiquidType;
9612 m_VarLiquidType = value;
9613 OnLiquidTypeChanged(old,value);
9614 SetVariableMask(VARIABLE_LIQUIDTYPE);
9615 }
9616
9617 int GetLiquidTypeInit()
9618 {
9619 return ConfigGetInt("varLiquidTypeInit");
9620 }
9621
9622 override int GetLiquidType()
9623 {
9624 return m_VarLiquidType;
9625 }
9626
9627 protected void OnLiquidTypeChanged(int oldType, int newType)
9628 {
9629 if (newType == LIQUID_NONE && GetIsFrozen())
9630 SetFrozen(false);
9631 }
9632
9634 void UpdateQuickbarShortcutVisibility(PlayerBase player)
9635 {
9636 player.SetEnableQuickBarEntityShortcut(this,!GetHierarchyParent() || GetHierarchyParent().GetInventory().AreChildrenAccessible());
9637 }
9638
9639 // -------------------------------------------------------------------------
9641 void OnInventoryEnter(Man player)
9642 {
9643 PlayerBase nplayer;
9644 if (PlayerBase.CastTo(nplayer, player))
9645 {
9646 m_CanPlayImpactSound = true;
9647 //nplayer.OnItemInventoryEnter(this);
9648 nplayer.SetEnableQuickBarEntityShortcut(this,!GetHierarchyParent() || GetHierarchyParent().GetInventory().AreChildrenAccessible());
9649 }
9650 }
9651
9652 // -------------------------------------------------------------------------
9654 void OnInventoryExit(Man player)
9655 {
9656 PlayerBase nplayer;
9657 if (PlayerBase.CastTo(nplayer,player))
9658 {
9659 //nplayer.OnItemInventoryExit(this);
9660 nplayer.SetEnableQuickBarEntityShortcut(this,false);
9661
9662 }
9663
9664 //if (!GetGame().IsDedicatedServer())
9665 player.GetHumanInventory().ClearUserReservedLocationForContainer(this);
9666
9667
9668 if (HasEnergyManager())
9669 {
9670 GetCompEM().UpdatePlugState(); // Unplug the el. device if it's necesarry.
9671 }
9672 }
9673
9674 // ADVANCED PLACEMENT EVENTS
9675 override void OnPlacementStarted(Man player)
9676 {
9677 super.OnPlacementStarted(player);
9678
9679 SetTakeable(false);
9680 }
9681
9682 override void OnPlacementComplete(Man player, vector position = "0 0 0", vector orientation = "0 0 0")
9683 {
9684 if (m_AdminLog)
9685 {
9686 m_AdminLog.OnPlacementComplete(player, this);
9687 }
9688
9689 super.OnPlacementComplete(player, position, orientation);
9690 }
9691
9692 //-----------------------------
9693 // AGENT SYSTEM
9694 //-----------------------------
9695 //--------------------------------------------------------------------------
9696 bool ContainsAgent(int agent_id)
9697 {
9698 if (agent_id & m_AttachedAgents)
9699 {
9700 return true;
9701 }
9702 else
9703 {
9704 return false;
9705 }
9706 }
9707
9708 //--------------------------------------------------------------------------
9709 override void RemoveAgent(int agent_id)
9710 {
9711 if (ContainsAgent(agent_id))
9712 {
9713 m_AttachedAgents = ~agent_id & m_AttachedAgents;
9714 }
9715 }
9716
9717 //--------------------------------------------------------------------------
9718 override void RemoveAllAgents()
9719 {
9720 m_AttachedAgents = 0;
9721 }
9722 //--------------------------------------------------------------------------
9723 override void RemoveAllAgentsExcept(int agent_to_keep)
9724 {
9725 m_AttachedAgents = m_AttachedAgents & agent_to_keep;
9726 }
9727 // -------------------------------------------------------------------------
9728 override void InsertAgent(int agent, float count = 1)
9729 {
9730 if (count < 1)
9731 return;
9732 //Debug.Log("Inserting Agent on item: " + agent.ToString() +" count: " + count.ToString());
9734 }
9735
9737 void TransferAgents(int agents)
9738 {
9740 }
9741
9742 // -------------------------------------------------------------------------
9743 override int GetAgents()
9744 {
9745 return m_AttachedAgents;
9746 }
9747 //----------------------------------------------------------------------
9748
9749 /*int GetContaminationType()
9750 {
9751 int contamination_type;
9752
9753 const int CONTAMINATED_MASK = eAgents.CHOLERA | eAgents.INFLUENZA | eAgents.SALMONELLA | eAgents.BRAIN;
9754 const int POISONED_MASK = eAgents.FOOD_POISON | eAgents.CHEMICAL_POISON;
9755 const int NERVE_GAS_MASK = eAgents.CHEMICAL_POISON;
9756 const int DIRTY_MASK = eAgents.WOUND_AGENT;
9757
9758 Edible_Base edible = Edible_Base.Cast(this);
9759 int agents = GetAgents();
9760 if (edible)
9761 {
9762 NutritionalProfile profile = Edible_Base.GetNutritionalProfile(edible);
9763 if (profile)
9764 {
9765 agents = agents | profile.GetAgents();//merge item's agents with nutritional agents
9766 }
9767 }
9768 if (agents & CONTAMINATED_MASK)
9769 {
9770 contamination_type = contamination_type | EContaminationTypes.ITEM_BADGE_CONTAMINATED;
9771 }
9772 if (agents & POISONED_MASK)
9773 {
9774 contamination_type = contamination_type | EContaminationTypes.ITEM_BADGE_POISONED;
9775 }
9776 if (agents & NERVE_GAS_MASK)
9777 {
9778 contamination_type = contamination_type | EContaminationTypes.ITEM_BADGE_NERVE_GAS;
9779 }
9780 if (agents & DIRTY_MASK)
9781 {
9782 contamination_type = contamination_type | EContaminationTypes.ITEM_BADGE_DIRTY;
9783 }
9784
9785 return agents;
9786 }*/
9787
9788 // -------------------------------------------------------------------------
9789 bool LoadAgents(ParamsReadContext ctx, int version)
9790 {
9791 if (!ctx.Read(m_AttachedAgents))
9792 return false;
9793 return true;
9794 }
9795 // -------------------------------------------------------------------------
9797 {
9798
9800 }
9801 // -------------------------------------------------------------------------
9802
9804 override void CheckForRoofLimited(float timeTresholdMS = 3000)
9805 {
9806 super.CheckForRoofLimited(timeTresholdMS);
9807
9808 float time = GetGame().GetTime();
9809 if ((time - m_PreviousRoofTestTime) >= timeTresholdMS)
9810 {
9811 m_PreviousRoofTestTime = time;
9812 SetRoofAbove(MiscGameplayFunctions.IsUnderRoof(this));
9813 }
9814 }
9815
9816 // returns item's protection level against enviromental hazard, for masks with filters, returns the filters protection for valid filter, otherwise 0
9817 float GetProtectionLevel(int type, bool consider_filter = false, int system = 0)
9818 {
9819 if (IsDamageDestroyed() || (HasQuantity() && GetQuantity() <= 0))
9820 {
9821 return 0;
9822 }
9823
9824 if (GetInventory().GetAttachmentSlotsCount() != 0)//is it an item with attachable filter ?
9825 {
9826 ItemBase filter = ItemBase.Cast(FindAttachmentBySlotName("GasMaskFilter"));
9827 if (filter)
9828 return filter.GetProtectionLevel(type, false, system);//it's a valid filter, return the protection
9829 else
9830 return 0;//otherwise return 0 when no filter attached
9831 }
9832
9833 string subclassPath, entryName;
9834
9835 switch (type)
9836 {
9837 case DEF_BIOLOGICAL:
9838 entryName = "biological";
9839 break;
9840 case DEF_CHEMICAL:
9841 entryName = "chemical";
9842 break;
9843 default:
9844 entryName = "biological";
9845 break;
9846 }
9847
9848 subclassPath = "CfgVehicles " + this.GetType() + " Protection ";
9849
9850 return GetGame().ConfigGetFloat(subclassPath + entryName);
9851 }
9852
9853
9854
9856 override void EEOnCECreate()
9857 {
9858 if (!IsMagazine())
9860
9862 }
9863
9864
9865 //-------------------------
9866 // OPEN/CLOSE USER ACTIONS
9867 //-------------------------
9869 void Open();
9870 void Close();
9871 bool IsOpen()
9872 {
9873 return true;
9874 }
9875
9876 override bool CanDisplayCargo()
9877 {
9878 return IsOpen();
9879 }
9880
9881
9882 // ------------------------------------------------------------
9883 // CONDITIONS
9884 // ------------------------------------------------------------
9885 override bool CanPutInCargo(EntityAI parent)
9886 {
9887 if (parent)
9888 {
9889 if (parent.IsInherited(DayZInfected))
9890 return true;
9891
9892 if (!parent.IsRuined())
9893 return true;
9894 }
9895
9896 return true;
9897 }
9898
9899 override bool CanPutAsAttachment(EntityAI parent)
9900 {
9901 if (!super.CanPutAsAttachment(parent))
9902 {
9903 return false;
9904 }
9905
9906 if (!IsRuined() && !parent.IsRuined())
9907 {
9908 return true;
9909 }
9910
9911 return false;
9912 }
9913
9914 override bool CanReceiveItemIntoCargo(EntityAI item)
9915 {
9916 //removed 15.06. coz of loading from storage -> after load items in cargo was lost -> waiting for proper solution
9917 //if (GetHealthLevel() == GameConstants.STATE_RUINED)
9918 // return false;
9919
9920 return super.CanReceiveItemIntoCargo(item);
9921 }
9922
9923 override bool CanReceiveAttachment(EntityAI attachment, int slotId)
9924 {
9925 //removed 15.06. coz of loading from storage -> after load items in cargo was lost -> waiting for proper solution
9926 //if (GetHealthLevel() == GameConstants.STATE_RUINED)
9927 // return false;
9928
9929 GameInventory attachmentInv = attachment.GetInventory();
9930 if (attachmentInv && attachmentInv.GetCargo() && attachmentInv.GetCargo().GetItemCount() > 0)
9931 {
9932 if (GetHierarchyParent() && !GetHierarchyParent().IsInherited(PlayerBase))
9933 return false;
9934 }
9935
9936 InventoryLocation loc = new InventoryLocation();
9937 attachment.GetInventory().GetCurrentInventoryLocation(loc);
9938 if (loc && loc.IsValid() && !GetInventory().AreChildrenAccessible())
9939 return false;
9940
9941 return super.CanReceiveAttachment(attachment, slotId);
9942 }
9943
9944 override bool CanReleaseAttachment(EntityAI attachment)
9945 {
9946 if (!super.CanReleaseAttachment(attachment))
9947 return false;
9948
9949 return GetInventory().AreChildrenAccessible();
9950 }
9951
9952 /*override bool CanLoadAttachment(EntityAI attachment)
9953 {
9954 //removed 15.06. coz of loading from storage -> after load items in cargo was lost -> waiting for proper solution
9955 //if (GetHealthLevel() == GameConstants.STATE_RUINED)
9956 // return false;
9957
9958 GameInventory attachmentInv = attachment.GetInventory();
9959 if (attachmentInv && attachmentInv.GetCargo() && attachmentInv.GetCargo().GetItemCount() > 0)
9960 {
9961 bool boo = (GetHierarchyParent() && !GetHierarchyParent().IsInherited(PlayerBase));
9962 ErrorEx("CanLoadAttachment | this: " + this + " | attachment: " + attachment + " | boo: " + boo,ErrorExSeverity.INFO);
9963
9964 if (GetHierarchyParent() && !GetHierarchyParent().IsInherited(PlayerBase))
9965 return false;
9966 }
9967
9968 return super.CanLoadAttachment(attachment);
9969 }*/
9970
9971 // Plays muzzle flash particle effects
9972 static void PlayFireParticles(ItemBase weapon, int muzzle_index, string ammoType, ItemBase muzzle_owner, ItemBase suppressor, string config_to_search)
9973 {
9974 int id = muzzle_owner.GetMuzzleID();
9975 array<ref WeaponParticlesOnFire> WPOF_array = m_OnFireEffect.Get(id);
9976
9977 if (WPOF_array)
9978 {
9979 for (int i = 0; i < WPOF_array.Count(); i++)
9980 {
9981 WeaponParticlesOnFire WPOF = WPOF_array.Get(i);
9982
9983 if (WPOF)
9984 {
9985 WPOF.OnActivate(weapon, muzzle_index, ammoType, muzzle_owner, suppressor, config_to_search);
9986 }
9987 }
9988 }
9989 }
9990
9991 // Plays bullet eject particle effects (usually just smoke, the bullet itself is a 3D model and is not part of this function)
9992 static void PlayBulletCasingEjectParticles(ItemBase weapon, string ammoType, ItemBase muzzle_owner, ItemBase suppressor, string config_to_search)
9993 {
9994 int id = muzzle_owner.GetMuzzleID();
9995 array<ref WeaponParticlesOnBulletCasingEject> WPOBE_array = m_OnBulletCasingEjectEffect.Get(id);
9996
9997 if (WPOBE_array)
9998 {
9999 for (int i = 0; i < WPOBE_array.Count(); i++)
10000 {
10001 WeaponParticlesOnBulletCasingEject WPOBE = WPOBE_array.Get(i);
10002
10003 if (WPOBE)
10004 {
10005 WPOBE.OnActivate(weapon, 0, ammoType, muzzle_owner, suppressor, config_to_search);
10006 }
10007 }
10008 }
10009 }
10010
10011 // Plays all weapon overheating particles
10012 static void PlayOverheatingParticles(ItemBase weapon, string ammoType, ItemBase muzzle_owner, ItemBase suppressor, string config_to_search)
10013 {
10014 int id = muzzle_owner.GetMuzzleID();
10015 array<ref WeaponParticlesOnOverheating> WPOOH_array = weapon.m_OnOverheatingEffect.Get(id);
10016
10017 if (WPOOH_array)
10018 {
10019 for (int i = 0; i < WPOOH_array.Count(); i++)
10020 {
10021 WeaponParticlesOnOverheating WPOOH = WPOOH_array.Get(i);
10022
10023 if (WPOOH)
10024 {
10025 WPOOH.OnActivate(weapon, 0, ammoType, muzzle_owner, suppressor, config_to_search);
10026 }
10027 }
10028 }
10029 }
10030
10031 // Updates all weapon overheating particles
10032 static void UpdateOverheatingParticles(ItemBase weapon, string ammoType, ItemBase muzzle_owner, ItemBase suppressor, string config_to_search)
10033 {
10034 int id = muzzle_owner.GetMuzzleID();
10035 array<ref WeaponParticlesOnOverheating> WPOOH_array = weapon.m_OnOverheatingEffect.Get(id);
10036
10037 if (WPOOH_array)
10038 {
10039 for (int i = 0; i < WPOOH_array.Count(); i++)
10040 {
10041 WeaponParticlesOnOverheating WPOOH = WPOOH_array.Get(i);
10042
10043 if (WPOOH)
10044 {
10045 WPOOH.OnUpdate(weapon, ammoType, muzzle_owner, suppressor, config_to_search);
10046 }
10047 }
10048 }
10049 }
10050
10051 // Stops overheating particles
10052 static void StopOverheatingParticles(ItemBase weapon, string ammoType, ItemBase muzzle_owner, ItemBase suppressor, string config_to_search)
10053 {
10054 int id = muzzle_owner.GetMuzzleID();
10055 array<ref WeaponParticlesOnOverheating> WPOOH_array = weapon.m_OnOverheatingEffect.Get(id);
10056
10057 if (WPOOH_array)
10058 {
10059 for (int i = 0; i < WPOOH_array.Count(); i++)
10060 {
10061 WeaponParticlesOnOverheating WPOOH = WPOOH_array.Get(i);
10062
10063 if (WPOOH)
10064 {
10065 WPOOH.OnDeactivate(weapon, ammoType, muzzle_owner, suppressor, config_to_search);
10066 }
10067 }
10068 }
10069 }
10070
10071 //----------------------------------------------------------------
10072 //Item Behaviour - unified approach
10073 override bool IsHeavyBehaviour()
10074 {
10075 if (m_ItemBehaviour == 0)
10076 {
10077 return true;
10078 }
10079
10080 return false;
10081 }
10082
10083 override bool IsOneHandedBehaviour()
10084 {
10085 if (m_ItemBehaviour == 1)
10086 {
10087 return true;
10088 }
10089
10090 return false;
10091 }
10092
10093 override bool IsTwoHandedBehaviour()
10094 {
10095 if (m_ItemBehaviour == 2)
10096 {
10097 return true;
10098 }
10099
10100 return false;
10101 }
10102
10103 bool IsDeployable()
10104 {
10105 return false;
10106 }
10107
10109 float GetDeployTime()
10110 {
10111 return UATimeSpent.DEFAULT_DEPLOY;
10112 }
10113
10114
10115 //----------------------------------------------------------------
10116 // Item Targeting (User Actions)
10117 override void SetTakeable(bool pState)
10118 {
10119 m_IsTakeable = pState;
10120 SetSynchDirty();
10121 }
10122
10123 override bool IsTakeable()
10124 {
10125 return m_IsTakeable;
10126 }
10127
10128 // For cases where we want to show object widget which cant be taken to hands
10130 {
10131 return false;
10132 }
10133
10135 protected void PreLoadSoundAttachmentType()
10136 {
10137 string att_type = "None";
10138
10139 if (ConfigIsExisting("soundAttType"))
10140 {
10141 att_type = ConfigGetString("soundAttType");
10142 }
10143
10144 m_SoundAttType = att_type;
10145 }
10146
10147 override string GetAttachmentSoundType()
10148 {
10149 return m_SoundAttType;
10150 }
10151
10152 //----------------------------------------------------------------
10153 //SOUNDS - ItemSoundHandler
10154 //----------------------------------------------------------------
10155
10156 string GetPlaceSoundset(); // played when deploy starts
10157 string GetLoopDeploySoundset(); // played when deploy starts and stopped when it finishes
10158 string GetDeploySoundset(); // played when deploy sucessfully finishes
10159 string GetLoopFoldSoundset(); // played when fold starts and stopped when it finishes
10160 string GetFoldSoundset(); // played when fold sucessfully finishes
10161
10163 {
10164 if (!m_ItemSoundHandler)
10166
10167 return m_ItemSoundHandler;
10168 }
10169
10170 // override to initialize sounds
10171 protected void InitItemSounds()
10172 {
10173 if (GetPlaceSoundset() == string.Empty && GetDeploySoundset() == string.Empty && GetLoopDeploySoundset() == string.Empty)
10174 return;
10175
10177
10178 if (GetPlaceSoundset() != string.Empty)
10179 handler.AddSound(SoundConstants.ITEM_PLACE, GetPlaceSoundset());
10180
10181 if (GetDeploySoundset() != string.Empty)
10182 handler.AddSound(SoundConstants.ITEM_DEPLOY, GetDeploySoundset());
10183
10184 SoundParameters params = new SoundParameters();
10185 params.m_Loop = true;
10186 if (GetLoopDeploySoundset() != string.Empty)
10187 handler.AddSound(SoundConstants.ITEM_DEPLOY_LOOP, GetLoopDeploySoundset(), params);
10188 }
10189
10190 // Start sound using ItemSoundHandler
10191 void StartItemSoundServer(int id)
10192 {
10193 if (!GetGame().IsServer())
10194 return;
10195
10196 m_SoundSyncPlay = id;
10197 SetSynchDirty();
10198
10199 GetGame().GetCallQueue(CALL_CATEGORY_SYSTEM).Remove(ClearStartItemSoundServer); // in case one is queued already
10201 }
10202
10203 // Stop sound using ItemSoundHandler
10204 void StopItemSoundServer(int id)
10205 {
10206 if (!GetGame().IsServer())
10207 return;
10208
10209 m_SoundSyncStop = id;
10210 SetSynchDirty();
10211
10212 GetGame().GetCallQueue(CALL_CATEGORY_SYSTEM).Remove(ClearStopItemSoundServer); // in case one is queued already
10214 }
10215
10216 protected void ClearStartItemSoundServer()
10217 {
10218 m_SoundSyncPlay = 0;
10219 }
10220
10221 protected void ClearStopItemSoundServer()
10222 {
10223 m_SoundSyncStop = 0;
10224 }
10225
10227 void PlayAttachSound(string slot_type)
10228 {
10229 if (!GetGame().IsDedicatedServer())
10230 {
10231 if (ConfigIsExisting("attachSoundSet"))
10232 {
10233 string cfg_path = "";
10234 string soundset = "";
10235 string type_name = GetType();
10236
10237 TStringArray cfg_soundset_array = new TStringArray;
10238 TStringArray cfg_slot_array = new TStringArray;
10239 ConfigGetTextArray("attachSoundSet",cfg_soundset_array);
10240 ConfigGetTextArray("attachSoundSlot",cfg_slot_array);
10241
10242 if (cfg_soundset_array.Count() > 0 && cfg_soundset_array.Count() == cfg_slot_array.Count())
10243 {
10244 for (int i = 0; i < cfg_soundset_array.Count(); i++)
10245 {
10246 if (cfg_slot_array[i] == slot_type)
10247 {
10248 soundset = cfg_soundset_array[i];
10249 break;
10250 }
10251 }
10252 }
10253
10254 if (soundset != "")
10255 {
10256 EffectSound sound = SEffectManager.PlaySound(soundset, GetPosition());
10257 sound.SetAutodestroy(true);
10258 }
10259 }
10260 }
10261 }
10262
10263 void PlayDetachSound(string slot_type)
10264 {
10265 //TODO - evaluate if needed and devise universal config structure if so
10266 }
10267
10268 void OnApply(PlayerBase player);
10269
10271 {
10272 return 1.0;
10273 };
10274 //returns applicable selection
10275 array<string> GetHeadHidingSelection()
10276 {
10278 }
10279
10281 {
10283 }
10284
10285 WrittenNoteData GetWrittenNoteData() {};
10286
10288 {
10289 SetDynamicPhysicsLifeTime(0.01);
10290 m_ItemBeingDroppedPhys = false;
10291 }
10292
10294 {
10295 array<string> zone_names = new array<string>;
10296 GetDamageZones(zone_names);
10297 for (int i = 0; i < zone_names.Count(); i++)
10298 {
10299 SetHealthMax(zone_names.Get(i),"Health");
10300 }
10301 SetHealthMax("","Health");
10302 }
10303
10305 void SetZoneDamageCEInit()
10306 {
10307 float global_health = GetHealth01("","Health");
10308 array<string> zones = new array<string>;
10309 GetDamageZones(zones);
10310 //set damage of all zones to match global health level
10311 for (int i = 0; i < zones.Count(); i++)
10312 {
10313 SetHealth01(zones.Get(i),"Health",global_health);
10314 }
10315 }
10316
10318 bool IsCoverFaceForShave(string slot_name)
10319 {
10320 return IsExclusionFlagPresent(PlayerBase.GetFaceCoverageShaveValues());
10321 }
10322
10323 void ProcessItemWetness(float delta, bool hasParent, bool hasRootAsPlayer, ItemBase refParentIB)
10324 {
10325 if (!hasRootAsPlayer)
10326 {
10327 if (refParentIB)
10328 {
10329 // parent is wet
10330 if ((refParentIB.GetWet() >= GameConstants.STATE_SOAKING_WET) && (m_VarWet < m_VarWetMax))
10331 AddWet(delta * GameConstants.WETNESS_RATE_WETTING_INSIDE);
10332 // parent has liquid inside
10333 else if ((refParentIB.GetLiquidType() != 0) && (refParentIB.GetQuantity() > 0) && (m_VarWet < m_VarWetMax))
10334 AddWet(delta * GameConstants.WETNESS_RATE_WETTING_LIQUID);
10335 // drying
10336 else if (m_VarWet > m_VarWetMin)
10337 AddWet(-1 * delta * GetDryingIncrement("ground") * 2);
10338 }
10339 else
10340 {
10341 // drying on ground or inside non-itembase (car, ...)
10342 if (m_VarWet > m_VarWetMin)
10343 AddWet(-1 * delta * GetDryingIncrement("ground"));
10344 }
10345 }
10346 }
10347
10348 void ProcessItemTemperature(float delta, bool hasParent, bool hasRootAsPlayer, ItemBase refParentIB)
10349 {
10351 {
10352 float target = g_Game.GetMission().GetWorldData().GetBaseEnvTemperatureAtObject(this);
10353 if (GetTemperature() != target || !IsFreezeThawProgressFinished())
10354 {
10355 float heatPermCoef = 1.0;
10356 EntityAI ent = this;
10357 while (ent)
10358 {
10359 heatPermCoef *= ent.GetHeatPermeabilityCoef();
10360 ent = ent.GetHierarchyParent();
10361 }
10362
10363 SetTemperatureEx(new TemperatureDataInterpolated(target,ETemperatureAccessTypes.ACCESS_WORLD,delta,GameConstants.TEMP_COEF_WORLD,heatPermCoef));
10364 }
10365 }
10366 }
10367
10368 void HierarchyCheck(out bool hasParent, out bool hasRootAsPlayer, out ItemBase refParentIB)
10369 {
10370 // hierarchy check for an item to decide whether it has some parent and it is in some player inventory
10371 EntityAI parent = GetHierarchyParent();
10372 if (!parent)
10373 {
10374 hasParent = false;
10375 hasRootAsPlayer = false;
10376 }
10377 else
10378 {
10379 hasParent = true;
10380 hasRootAsPlayer = (GetHierarchyRootPlayer() != null);
10381 refParentIB = ItemBase.Cast(parent);
10382 }
10383 }
10384
10385 protected void ProcessDecay(float delta, bool hasRootAsPlayer)
10386 {
10387 // this is stub, implemented on Edible_Base
10388 }
10389
10390 bool CanDecay()
10391 {
10392 // return true used on selected food clases so they can decay
10393 return false;
10394 }
10395
10396 protected bool CanProcessDecay()
10397 {
10398 // this is stub, implemented on Edible_Base class
10399 // used to determine whether it is still necessary for the food to decay
10400 return false;
10401 }
10402
10403 protected bool CanHaveWetness()
10404 {
10405 // return true used on selected items that have a wetness effect
10406 return false;
10407 }
10408
10410 bool CanBeConsumed(ConsumeConditionData data = null)
10411 {
10412 return !GetIsFrozen() && IsOpen();
10413 }
10414
10415 override void ProcessVariables()
10416 {
10417 bool hasParent = false, hasRootAsPlayer = false;
10418 ItemBase refParentIB;
10419
10420 bool wwtu = g_Game.IsWorldWetTempUpdateEnabled();
10421 bool foodDecay = g_Game.IsFoodDecayEnabled();
10422
10423 if (wwtu || foodDecay)
10424 {
10425 bool processWetness = wwtu && CanHaveWetness();
10426 bool processTemperature = wwtu && CanHaveTemperature();
10427 bool processDecay = foodDecay && CanDecay() && CanProcessDecay();
10428
10429 if (processWetness || processTemperature || processDecay)
10430 {
10431 HierarchyCheck(hasParent, hasRootAsPlayer, refParentIB);
10432
10433 if (processWetness)
10434 ProcessItemWetness(m_ElapsedSinceLastUpdate, hasParent, hasRootAsPlayer, refParentIB);
10435
10436 if (processTemperature)
10437 ProcessItemTemperature(m_ElapsedSinceLastUpdate, hasParent, hasRootAsPlayer, refParentIB);
10438
10439 if (processDecay)
10440 ProcessDecay(m_ElapsedSinceLastUpdate, hasRootAsPlayer);
10441 }
10442 }
10443 }
10444
10447 {
10448 return m_TemperaturePerQuantityWeight * GameConstants.ITEM_TEMPERATURE_QUANTITY_WEIGHT_MULTIPLIER;
10449 }
10450
10451 override float GetTemperatureFreezeThreshold()
10452 {
10454 return Liquid.GetFreezeThreshold(GetLiquidType());
10455
10456 return super.GetTemperatureFreezeThreshold();
10457 }
10458
10459 override float GetTemperatureThawThreshold()
10460 {
10462 return Liquid.GetThawThreshold(GetLiquidType());
10463
10464 return super.GetTemperatureThawThreshold();
10465 }
10466
10467 override float GetItemOverheatThreshold()
10468 {
10470 return Liquid.GetBoilThreshold(GetLiquidType());
10471
10472 return super.GetItemOverheatThreshold();
10473 }
10474
10475 override float GetTemperatureFreezeTime()
10476 {
10477 if (HasQuantity())
10478 return Math.Lerp(GameConstants.TEMPERATURE_TIME_FREEZE_MIN,Math.Max(GameConstants.TEMPERATURE_TIME_FREEZE_MIN,super.GetTemperatureFreezeTime()),GetQuantityNormalized());
10479
10480 return super.GetTemperatureFreezeTime();
10481 }
10482
10483 override float GetTemperatureThawTime()
10484 {
10485 if (HasQuantity())
10486 return Math.Lerp(GameConstants.TEMPERATURE_TIME_THAW_MIN,Math.Max(GameConstants.TEMPERATURE_TIME_FREEZE_MIN,super.GetTemperatureThawTime()),GetQuantityNormalized());
10487
10488 return super.GetTemperatureThawTime();
10489 }
10490
10492 void AffectLiquidContainerOnFill(int liquid_type, float amount);
10494 void AffectLiquidContainerOnTransfer(int liquidType, float amount, float sourceLiquidTemperature);
10495
10496 bool IsCargoException4x3(EntityAI item)
10497 {
10498 return (item.IsKindOf("Cauldron") || item.IsKindOf("Pot") || item.IsKindOf("FryingPan") || item.IsKindOf("SmallProtectorCase") || (item.IsKindOf("PortableGasStove") && item.FindAttachmentBySlotName("CookingEquipment")));
10499 }
10500
10502 {
10503 MiscGameplayFunctions.TransferItemProperties(oldItem, this);
10504 }
10505
10507 void AddLightSourceItem(ItemBase lightsource)
10508 {
10509 m_LightSourceItem = lightsource;
10510 }
10511
10513 {
10514 m_LightSourceItem = null;
10515 }
10516
10518 {
10519 return m_LightSourceItem;
10520 }
10521
10523 array<int> GetValidFinishers()
10524 {
10525 return null;
10526 }
10527
10529 bool GetActionWidgetOverride(out typename name)
10530 {
10531 return false;
10532 }
10533
10534 bool PairWithDevice(notnull ItemBase otherDevice)
10535 {
10536 if (GetGame().IsServer())
10537 {
10538 ItemBase explosive = otherDevice;
10540 if (!trg)
10541 {
10542 trg = RemoteDetonatorTrigger.Cast(otherDevice);
10543 explosive = this;
10544 }
10545
10546 explosive.PairRemote(trg);
10547 trg.SetControlledDevice(explosive);
10548
10549 int persistentID = RemotelyActivatedItemBehaviour.GeneratePersistentID();
10550 trg.SetPersistentPairID(persistentID);
10551 explosive.SetPersistentPairID(persistentID);
10552
10553 return true;
10554 }
10555 return false;
10556 }
10557
10559 float GetBaitEffectivity()
10560 {
10561 float ret = 1.0;
10562 if (HasQuantity())
10563 ret *= GetQuantityNormalized();
10564 ret *= GetHealth01();
10565
10566 return ret;
10567 }
10568
10569 #ifdef DEVELOPER
10570 override void SetDebugItem()
10571 {
10572 super.SetDebugItem();
10573 _itemBase = this;
10574 }
10575
10576 override string GetDebugText()
10577 {
10578 string text = super.GetDebugText();
10579
10580 text += string.Format("Heat isolation(raw): %1\n", GetHeatIsolation());
10581 text += string.Format("Heat isolation(modified): %1\n", MiscGameplayFunctions.GetCurrentItemHeatIsolation(this));
10582
10583 return text;
10584 }
10585 #endif
10586
10587 bool CanBeUsedForSuicide()
10588 {
10589 return true;
10590 }
10591
10593 //DEPRECATED BELOW
10595 // Backwards compatibility
10596 void ProcessItemWetnessAndTemperature(float delta, bool hasParent, bool hasRootAsPlayer, ItemBase refParentIB)
10597 {
10598 ProcessItemWetness(delta, hasParent, hasRootAsPlayer, refParentIB);
10599 ProcessItemTemperature(delta, hasParent, hasRootAsPlayer, refParentIB);
10600 }
10601
10602 // replaced by ItemSoundHandler
10603 protected EffectSound m_SoundDeployFinish;
10604 protected EffectSound m_SoundPlace;
10605 protected EffectSound m_DeployLoopSoundEx;
10606 protected EffectSound m_SoundDeploy;
10607 bool m_IsPlaceSound;
10608 bool m_IsDeploySound;
10610
10611 string GetDeployFinishSoundset();
10612 void PlayDeploySound();
10613 void PlayDeployFinishSound();
10614 void PlayPlaceSound();
10615 void PlayDeployLoopSoundEx();
10616 void StopDeployLoopSoundEx();
10617 void SoundSynchRemoteReset();
10618 void SoundSynchRemote();
10619 bool UsesGlobalDeploy(){return false;}
10620 bool CanPlayDeployLoopSound(){return false;}
10622 bool IsPlaceSound(){return m_IsPlaceSound;}
10623 bool IsDeploySound(){return m_IsDeploySound;}
10624 void SetIsPlaceSound(bool is_place_sound);
10625 void SetIsDeploySound(bool is_deploy_sound);
10626}
10627
10628EntityAI SpawnItemOnLocation(string object_name, notnull InventoryLocation loc, bool full_quantity)
10629{
10630 EntityAI entity = SpawnEntity(object_name, loc, ECE_IN_INVENTORY, RF_DEFAULT);
10631 if (entity)
10632 {
10633 bool is_item = entity.IsInherited(ItemBase);
10634 if (is_item && full_quantity)
10635 {
10636 ItemBase item = ItemBase.Cast(entity);
10637 item.SetQuantity(item.GetQuantityInit());
10638 }
10639 }
10640 else
10641 {
10642 ErrorEx("Cannot spawn entity: " + object_name,ErrorExSeverity.INFO);
10643 return NULL;
10644 }
10645 return entity;
10646}
10647
10648void SetupSpawnedItem(ItemBase item, float health, float quantity)
10649{
10650 if (item)
10651 {
10652 if (health > 0)
10653 item.SetHealth("", "", health);
10654
10655 if (item.CanHaveTemperature())
10656 {
10657 item.SetTemperatureDirect(GameConstants.ITEM_TEMPERATURE_NEUTRAL_ZONE_MIDDLE);
10658 if (item.CanFreeze())
10659 item.SetFrozen(false);
10660 }
10661
10662 if (item.HasEnergyManager())
10663 {
10664 if (quantity >= 0)
10665 {
10666 item.GetCompEM().SetEnergy0To1(quantity);
10667 }
10668 else
10669 {
10670 item.GetCompEM().SetEnergy(Math.AbsFloat(quantity));
10671 }
10672 }
10673 else if (item.IsMagazine())
10674 {
10675 Magazine mag = Magazine.Cast(item);
10676 if (quantity >= 0)
10677 {
10678 mag.ServerSetAmmoCount(mag.GetAmmoMax() * quantity);
10679 }
10680 else
10681 {
10682 mag.ServerSetAmmoCount(Math.AbsFloat(quantity));
10683 }
10684
10685 }
10686 else
10687 {
10688 if (quantity >= 0)
10689 {
10690 item.SetQuantityNormalized(quantity, false);
10691 }
10692 else
10693 {
10694 item.SetQuantity(Math.AbsFloat(quantity));
10695 }
10696
10697 }
10698 }
10699}
10700
10701#ifdef DEVELOPER
10702ItemBase _itemBase;//watched item goes here(LCTRL+RMB->Watch)
10703#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()