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

◆ IsPlayerInside()

bool SpawnItemOnLocation::IsPlayerInside ( PlayerBase player,
string selection )
private

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

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