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

◆ OnWasAttached()

override void SpawnItemOnLocation::OnWasAttached ( EntityAI parent,
int slot_id )
private

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

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

Используется в Entity::EEItemLocationChanged().