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

◆ RegisterOverheatingParticle()

void SpawnItemOnLocation::RegisterOverheatingParticle ( Particle p,
float min_heat_coef,
float max_heat_coef,
int particle_id,
Object parent,
vector local_pos,
vector local_ori )
private

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

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