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

◆ EOnContact()

override void SpawnItemOnLocation::EOnContact ( IEntity other,
Contact extra )
private

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

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