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

◆ CheckOverheating()

void SpawnItemOnLocation::CheckOverheating ( ItemBase weapon = null,
string ammoType = "",
ItemBase muzzle_owner = null,
ItemBase suppressor = null,
string config_to_search = "" )
private

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

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

Используется в InventoryItem::IncreaseOverheating() и InventoryItem::OnOverheatingDecay().