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

◆ CanBeDigged()

bool SpawnItemOnLocation::CanBeDigged ( )
private

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

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