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

◆ HasDebugActionsMask()

static bool SpawnItemOnLocation::HasDebugActionsMask ( int mask)
staticprivate

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

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

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