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

◆ CanBeUsedForSuicide()

bool SpawnItemOnLocation::CanBeUsedForSuicide ( )
protected

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

9658{
9659 override bool CanPutAsAttachment(EntityAI parent)
9660 {
9661 return true;
9662 }
9663};
9664
9665//const bool QUANTITY_DEBUG_REMOVE_ME = false;
9666
9667class ItemBase extends InventoryItem
9668{
9672
9674
9675 static int m_DebugActionsMask;
9677 // ============================================
9678 // Variable Manipulation System
9679 // ============================================
9680 // Quantity
9681
9682 float m_VarQuantity;
9683 float m_VarQuantityPrev;//for client to know quantity changed during synchronization
9685 int m_VarQuantityMin;
9686 int m_VarQuantityMax;
9687 int m_Count;
9688 float m_VarStackMax;
9689 float m_StoreLoadedQuantity = float.LOWEST;
9690 // Wet
9691 float m_VarWet;
9692 float m_VarWetPrev;//for client to know wetness changed during synchronization
9693 float m_VarWetInit;
9694 float m_VarWetMin;
9695 float m_VarWetMax;
9696 // Cleanness
9697 int m_Cleanness;
9698 int m_CleannessInit;
9699 int m_CleannessMin;
9700 int m_CleannessMax;
9701 // impact sounds
9703 bool m_CanPlayImpactSound = true;
9704 float m_ImpactSpeed;
9706 //
9707 float m_HeatIsolation;
9708 float m_ItemModelLength;
9709 float m_ItemAttachOffset; // Offset length for when the item is attached e.g. to weapon
9711 int m_VarLiquidType;
9712 int m_ItemBehaviour; // -1 = not specified; 0 = heavy item; 1= onehanded item; 2 = twohanded item
9713 int m_QuickBarBonus;
9714 bool m_IsBeingPlaced;
9715 bool m_IsHologram;
9716 bool m_IsTakeable;
9717 bool m_ThrowItemOnDrop;
9720 bool m_FixDamageSystemInit = false; //can be changed on storage version check
9721 bool can_this_be_combined; //Check if item can be combined
9722 bool m_CanThisBeSplit; //Check if item can be split
9723 bool m_IsStoreLoad = false;
9724 bool m_CanShowQuantity;
9725 bool m_HasQuantityBar;
9726 protected bool m_CanBeDigged;
9727 protected bool m_IsResultOfSplit
9728
9729 string m_SoundAttType;
9730 // items color variables
9735 //-------------------------------------------------------
9736
9737 // light source managing
9739
9743
9744 //==============================================
9745 // agent system
9746 private int m_AttachedAgents;
9747
9749 void TransferModifiers(PlayerBase reciever);
9750
9751
9752 // Weapons & suppressors particle effects
9757 static int m_LastRegisteredWeaponID = 0;
9758
9759 // Overheating effects
9761 float m_OverheatingShots;
9762 ref Timer m_CheckOverheating;
9763 int m_ShotsToStartOverheating = 0; // After these many shots, the overheating effect begins
9764 int m_MaxOverheatingValue = 0; // Limits the number of shots that will be tracked
9765 float m_OverheatingDecayInterval = 1; // Timer's interval for decrementing overheat effect's lifespan
9766 ref array <ref OverheatingParticle> m_OverheatingParticles;
9767
9769 protected bool m_HideSelectionsBySlot;
9770
9771 // Admin Log
9772 PluginAdminLog m_AdminLog;
9773
9774 // misc
9775 ref Timer m_PhysDropTimer;
9776
9777 // Attachment Locking variables
9778 ref array<int> m_CompatibleLocks;
9779 protected int m_LockType;
9780 protected ref EffectSound m_LockingSound;
9781 protected string m_LockSoundSet;
9782
9783 // ItemSoundHandler
9784 protected const int ITEM_SOUNDS_MAX = 63; // optimize network synch
9785 protected int m_SoundSyncPlay; // id for sound to play
9786 protected int m_SoundSyncStop; // id for sound to stop
9788
9789 //temperature
9790 private float m_TemperaturePerQuantityWeight;
9791
9792 // -------------------------------------------------------------------------
9793 void ItemBase()
9794 {
9795 SetEventMask(EntityEvent.INIT); // Enable EOnInit event
9799
9800 if (!GetGame().IsDedicatedServer())
9801 {
9802 if (HasMuzzle())
9803 {
9805
9807 {
9809 }
9810 }
9811
9813 m_ActionsInitialize = false;
9814 }
9815
9816 m_OldLocation = null;
9817
9818 if (GetGame().IsServer())
9819 {
9820 m_AdminLog = PluginAdminLog.Cast(GetPlugin(PluginAdminLog));
9821 }
9822
9823 if (ConfigIsExisting("headSelectionsToHide"))
9824 {
9826 ConfigGetTextArray("headSelectionsToHide",m_HeadHidingSelections);
9827 }
9828
9829 m_HideSelectionsBySlot = false;
9830 if (ConfigIsExisting("hideSelectionsByinventorySlot"))
9831 {
9832 m_HideSelectionsBySlot = ConfigGetBool("hideSelectionsByinventorySlot");
9833 }
9834
9835 m_QuickBarBonus = Math.Max(0, ConfigGetInt("quickBarBonus"));
9836
9837 m_IsResultOfSplit = false;
9838
9840 }
9841
9842 override void InitItemVariables()
9843 {
9844 super.InitItemVariables();
9845
9846 m_VarQuantityInit = ConfigGetInt("varQuantityInit");
9847 m_VarQuantity = m_VarQuantityInit;//should be by the CE, this is just a precaution
9848 m_VarQuantityMin = ConfigGetInt("varQuantityMin");
9849 m_VarQuantityMax = ConfigGetInt("varQuantityMax");
9850 m_VarStackMax = ConfigGetFloat("varStackMax");
9851 m_Count = ConfigGetInt("count");
9852
9853 m_CanShowQuantity = ConfigGetBool("quantityShow");
9854 m_HasQuantityBar = ConfigGetBool("quantityBar");
9855
9856 m_CleannessInit = ConfigGetInt("varCleannessInit");
9858 m_CleannessMin = ConfigGetInt("varCleannessMin");
9859 m_CleannessMax = ConfigGetInt("varCleannessMax");
9860
9861 m_WantPlayImpactSound = false;
9862 m_ImpactSpeed = 0.0;
9863
9864 m_VarWetInit = ConfigGetFloat("varWetInit");
9866 m_VarWetMin = ConfigGetFloat("varWetMin");
9867 m_VarWetMax = ConfigGetFloat("varWetMax");
9868
9869 m_LiquidContainerMask = ConfigGetInt("liquidContainerType");
9870 if (IsLiquidContainer() && GetQuantity() != 0)
9872 m_IsBeingPlaced = false;
9873 m_IsHologram = false;
9874 m_IsTakeable = true;
9875 m_CanBeMovedOverride = false;
9879 m_CanBeDigged = ConfigGetBool("canBeDigged");
9880
9881 m_CompatibleLocks = new array<int>();
9882 ConfigGetIntArray("compatibleLocks", m_CompatibleLocks);
9883 m_LockType = ConfigGetInt("lockType");
9884
9885 //Define if item can be split and set ability to be combined accordingly
9886 m_CanThisBeSplit = false;
9887 can_this_be_combined = false;
9888 if (ConfigIsExisting("canBeSplit"))
9889 {
9890 can_this_be_combined = ConfigGetBool("canBeSplit");
9892 }
9893
9894 m_ItemBehaviour = -1;
9895 if (ConfigIsExisting("itemBehaviour"))
9896 m_ItemBehaviour = ConfigGetInt("itemBehaviour");
9897
9898 //RegisterNetSyncVariableInt("m_VariablesMask");
9899 if (HasQuantity()) RegisterNetSyncVariableFloat("m_VarQuantity", GetQuantityMin(), m_VarQuantityMax);
9900 RegisterNetSyncVariableFloat("m_VarWet", GetWetMin(), GetWetMax(), 2);
9901 RegisterNetSyncVariableInt("m_VarLiquidType");
9902 RegisterNetSyncVariableInt("m_Cleanness",0,1);
9903
9904 RegisterNetSyncVariableBoolSignal("m_WantPlayImpactSound");
9905 RegisterNetSyncVariableFloat("m_ImpactSpeed");
9906 RegisterNetSyncVariableInt("m_ImpactSoundSurfaceHash");
9907
9908 RegisterNetSyncVariableInt("m_ColorComponentR", 0, 255);
9909 RegisterNetSyncVariableInt("m_ColorComponentG", 0, 255);
9910 RegisterNetSyncVariableInt("m_ColorComponentB", 0, 255);
9911 RegisterNetSyncVariableInt("m_ColorComponentA", 0, 255);
9912
9913 RegisterNetSyncVariableBool("m_IsBeingPlaced");
9914 RegisterNetSyncVariableBool("m_IsTakeable");
9915 RegisterNetSyncVariableBool("m_IsHologram");
9916
9917 InitItemSounds();
9919 {
9920 RegisterNetSyncVariableInt("m_SoundSyncPlay", 0, ITEM_SOUNDS_MAX);
9921 RegisterNetSyncVariableInt("m_SoundSyncStop", 0, ITEM_SOUNDS_MAX);
9922 }
9923
9924 m_LockSoundSet = ConfigGetString("lockSoundSet");
9925
9927 if (ConfigIsExisting("temperaturePerQuantityWeight"))
9928 m_TemperaturePerQuantityWeight = ConfigGetFloat("temperaturePerQuantityWeight");
9929
9930 }
9931
9932 override int GetQuickBarBonus()
9933 {
9934 return m_QuickBarBonus;
9935 }
9936
9937 void InitializeActions()
9938 {
9940 if (!m_InputActionMap)
9941 {
9943 m_InputActionMap = iam;
9944 SetActions();
9946 }
9947 }
9948
9949 override void GetActions(typename action_input_type, out array<ActionBase_Basic> actions)
9950 {
9952 {
9953 m_ActionsInitialize = true;
9955 }
9956
9957 actions = m_InputActionMap.Get(action_input_type);
9958 }
9959
9960 void SetActions()
9961 {
9962 AddAction(ActionTakeItem);
9963 AddAction(ActionTakeItemToHands);
9964 AddAction(ActionWorldCraft);
9966 AddAction(ActionAttachWithSwitch);
9967 }
9968
9969 void SetActionAnimOverrides(); // Override action animation for specific item
9970
9971 void AddAction(typename actionName)
9972 {
9973 ActionBase action = ActionManagerBase.GetAction(actionName);
9974
9975 if (!action)
9976 {
9977 Debug.LogError("Action " + actionName + " dosn't exist!");
9978 return;
9979 }
9980
9981 typename ai = action.GetInputType();
9982 if (!ai)
9983 {
9984 m_ActionsInitialize = false;
9985 return;
9986 }
9987
9988 array<ActionBase_Basic> action_array = m_InputActionMap.Get(ai);
9989 if (!action_array)
9990 {
9991 action_array = new array<ActionBase_Basic>;
9992 m_InputActionMap.Insert(ai, action_array);
9993 }
9994 if (LogManager.IsActionLogEnable())
9995 {
9996 Debug.ActionLog(action.ToString() + " -> " + ai, this.ToString() , "n/a", "Add action");
9997 }
9998
9999 if (action_array.Find(action) != -1)
10000 {
10001 Debug.Log("Action " + action.Type() + " already added to " + this + ", skipping!");
10002 }
10003 else
10004 {
10005 action_array.Insert(action);
10006 }
10007 }
10008
10009 void RemoveAction(typename actionName)
10010 {
10011 PlayerBase player = PlayerBase.Cast(GetGame().GetPlayer());
10012 ActionBase action = player.GetActionManager().GetAction(actionName);
10013 typename ai = action.GetInputType();
10014 array<ActionBase_Basic> action_array = m_InputActionMap.Get(ai);
10015
10016 if (action_array)
10017 {
10018 action_array.RemoveItem(action);
10019 }
10020 }
10021
10022 // Allows override of default action command per item, defined in the SetActionAnimOverrides() of the item's class
10023 // Set -1 for params which should stay in default state
10024 void OverrideActionAnimation(typename action, int commandUID, int stanceMask = -1, int commandUIDProne = -1)
10025 {
10026 ActionOverrideData overrideData = new ActionOverrideData();
10027 overrideData.m_CommandUID = commandUID;
10028 overrideData.m_CommandUIDProne = commandUIDProne;
10029 overrideData.m_StanceMask = stanceMask;
10030
10031 TActionAnimOverrideMap actionMap = m_ItemActionOverrides.Get(action);
10032 if (!actionMap) // create new map of action > overidables map
10033 {
10034 actionMap = new TActionAnimOverrideMap();
10035 m_ItemActionOverrides.Insert(action, actionMap);
10036 }
10037
10038 actionMap.Insert(this.Type(), overrideData); // insert item -> overrides
10039
10040 }
10041
10042 void OnItemInHandsPlayerSwimStart(PlayerBase player);
10043
10044 ScriptedLightBase GetLight();
10045
10046 // Loads muzzle flash particle configuration from config and saves it to a map for faster access
10047 void LoadParticleConfigOnFire(int id)
10048 {
10049 if (!m_OnFireEffect)
10051
10054
10055 string config_to_search = "CfgVehicles";
10056 string muzzle_owner_config;
10057
10058 if (!m_OnFireEffect.Contains(id))
10059 {
10060 if (IsInherited(Weapon))
10061 config_to_search = "CfgWeapons";
10062
10063 muzzle_owner_config = config_to_search + " " + GetType() + " ";
10064
10065 string config_OnFire_class = muzzle_owner_config + "Particles " + "OnFire ";
10066
10067 int config_OnFire_subclass_count = GetGame().ConfigGetChildrenCount(config_OnFire_class);
10068
10069 if (config_OnFire_subclass_count > 0)
10070 {
10071 array<ref WeaponParticlesOnFire> WPOF_array = new array<ref WeaponParticlesOnFire>;
10072
10073 for (int i = 0; i < config_OnFire_subclass_count; i++)
10074 {
10075 string particle_class = "";
10076 GetGame().ConfigGetChildName(config_OnFire_class, i, particle_class);
10077 string config_OnFire_entry = config_OnFire_class + particle_class;
10078 WeaponParticlesOnFire WPOF = new WeaponParticlesOnFire(this, config_OnFire_entry);
10079 WPOF_array.Insert(WPOF);
10080 }
10081
10082
10083 m_OnFireEffect.Insert(id, WPOF_array);
10084 }
10085 }
10086
10087 if (!m_OnBulletCasingEjectEffect.Contains(id))
10088 {
10089 config_to_search = "CfgWeapons"; // Bullet Eject efect is supported on weapons only.
10090 muzzle_owner_config = config_to_search + " " + GetType() + " ";
10091
10092 string config_OnBulletCasingEject_class = muzzle_owner_config + "Particles " + "OnBulletCasingEject ";
10093
10094 int config_OnBulletCasingEject_count = GetGame().ConfigGetChildrenCount(config_OnBulletCasingEject_class);
10095
10096 if (config_OnBulletCasingEject_count > 0 && IsInherited(Weapon))
10097 {
10098 array<ref WeaponParticlesOnBulletCasingEject> WPOBE_array = new array<ref WeaponParticlesOnBulletCasingEject>;
10099
10100 for (i = 0; i < config_OnBulletCasingEject_count; i++)
10101 {
10102 string particle_class2 = "";
10103 GetGame().ConfigGetChildName(config_OnBulletCasingEject_class, i, particle_class2);
10104 string config_OnBulletCasingEject_entry = config_OnBulletCasingEject_class + particle_class2;
10105 WeaponParticlesOnBulletCasingEject WPOBE = new WeaponParticlesOnBulletCasingEject(this, config_OnBulletCasingEject_entry);
10106 WPOBE_array.Insert(WPOBE);
10107 }
10108
10109
10110 m_OnBulletCasingEjectEffect.Insert(id, WPOBE_array);
10111 }
10112 }
10113 }
10114
10115 // Loads muzzle flash particle configuration from config and saves it to a map for faster access
10117 {
10120
10121 if (!m_OnOverheatingEffect.Contains(id))
10122 {
10123 string config_to_search = "CfgVehicles";
10124
10125 if (IsInherited(Weapon))
10126 config_to_search = "CfgWeapons";
10127
10128 string muzzle_owner_config = config_to_search + " " + GetType() + " ";
10129 string config_OnOverheating_class = muzzle_owner_config + "Particles " + "OnOverheating ";
10130
10131 if (GetGame().ConfigIsExisting(config_OnOverheating_class))
10132 {
10133
10134 m_ShotsToStartOverheating = GetGame().ConfigGetFloat(config_OnOverheating_class + "shotsToStartOverheating");
10135
10137 {
10138 m_ShotsToStartOverheating = -1; // This prevents futher readings from config for future creations of this item
10139 string error = "Error reading config " + GetType() + ">Particles>OnOverheating - Parameter shotsToStartOverheating is configured wrong or is missing! Its value must be 1 or higher!";
10140 Error(error);
10141 return;
10142 }
10143
10144 m_OverheatingDecayInterval = GetGame().ConfigGetFloat(config_OnOverheating_class + "overheatingDecayInterval");
10145 m_MaxOverheatingValue = GetGame().ConfigGetFloat(config_OnOverheating_class + "maxOverheatingValue");
10146
10147
10148
10149 int config_OnOverheating_subclass_count = GetGame().ConfigGetChildrenCount(config_OnOverheating_class);
10150 array<ref WeaponParticlesOnOverheating> WPOOH_array = new array<ref WeaponParticlesOnOverheating>;
10151
10152 for (int i = 0; i < config_OnOverheating_subclass_count; i++)
10153 {
10154 string particle_class = "";
10155 GetGame().ConfigGetChildName(config_OnOverheating_class, i, particle_class);
10156 string config_OnOverheating_entry = config_OnOverheating_class + particle_class;
10157 int entry_type = GetGame().ConfigGetType(config_OnOverheating_entry);
10158
10159 if (entry_type == CT_CLASS)
10160 {
10161 WeaponParticlesOnOverheating WPOF = new WeaponParticlesOnOverheating(this, config_OnOverheating_entry);
10162 WPOOH_array.Insert(WPOF);
10163 }
10164 }
10165
10166
10167 m_OnOverheatingEffect.Insert(id, WPOOH_array);
10168 }
10169 }
10170 }
10171
10172 float GetOverheatingValue()
10173 {
10174 return m_OverheatingShots;
10175 }
10176
10177 void IncreaseOverheating(ItemBase weapon, string ammoType, ItemBase muzzle_owner, ItemBase suppressor, string config_to_search)
10178 {
10179 if (m_MaxOverheatingValue > 0)
10180 {
10182
10183 if (!m_CheckOverheating)
10185
10187 m_CheckOverheating.Run(m_OverheatingDecayInterval, this, "OnOverheatingDecay");
10188
10189 CheckOverheating(weapon, ammoType, muzzle_owner, suppressor, config_to_search);
10190 }
10191 }
10192
10193 void CheckOverheating(ItemBase weapon = null, string ammoType = "", ItemBase muzzle_owner = null, ItemBase suppressor = null, string config_to_search = "")
10194 {
10196 UpdateOverheating(weapon, ammoType, muzzle_owner, suppressor, config_to_search);
10197
10199 StartOverheating(weapon, ammoType, muzzle_owner, suppressor, config_to_search);
10200
10202 StopOverheating(weapon, ammoType, muzzle_owner, suppressor, config_to_search);
10203
10205 {
10207 }
10208 }
10209
10211 {
10213 }
10214
10215 void OnOverheatingDecay()
10216 {
10217 if (m_MaxOverheatingValue > 0)
10218 m_OverheatingShots -= 1 + m_OverheatingShots / m_MaxOverheatingValue; // The hotter a barrel is, the faster it needs to cool down.
10219 else
10221
10222 if (m_OverheatingShots <= 0)
10223 {
10226 }
10227 else
10228 {
10229 if (!m_CheckOverheating)
10231
10233 m_CheckOverheating.Run(m_OverheatingDecayInterval, this, "OnOverheatingDecay");
10234 }
10235
10236 CheckOverheating(this, "", this);
10237 }
10238
10239 void StartOverheating(ItemBase weapon = null, string ammoType = "", ItemBase muzzle_owner = null, ItemBase suppressor = null, string config_to_search = "")
10240 {
10242 ItemBase.PlayOverheatingParticles(this, ammoType, this, suppressor, "CfgWeapons");
10243 }
10244
10245 void UpdateOverheating(ItemBase weapon = null, string ammoType = "", ItemBase muzzle_owner = null, ItemBase suppressor = null, string config_to_search = "")
10246 {
10248 ItemBase.UpdateOverheatingParticles(this, ammoType, this, suppressor, "CfgWeapons");
10250 }
10251
10252 void StopOverheating(ItemBase weapon = null, string ammoType = "", ItemBase muzzle_owner = null, ItemBase suppressor = null, string config_to_search = "")
10253 {
10255 ItemBase.StopOverheatingParticles(weapon, ammoType, muzzle_owner, suppressor, config_to_search);
10256 }
10257
10258 void RegisterOverheatingParticle(Particle p, float min_heat_coef, float max_heat_coef, int particle_id, Object parent, vector local_pos, vector local_ori)
10259 {
10261 m_OverheatingParticles = new array<ref OverheatingParticle>;
10262
10263 OverheatingParticle OP = new OverheatingParticle();
10264 OP.RegisterParticle(p);
10265 OP.SetOverheatingLimitMin(min_heat_coef);
10266 OP.SetOverheatingLimitMax(max_heat_coef);
10267 OP.SetParticleParams(particle_id, parent, local_pos, local_ori);
10268
10269 m_OverheatingParticles.Insert(OP);
10270 }
10271
10272 float GetOverheatingCoef()
10273 {
10274 if (m_MaxOverheatingValue > 0)
10276
10277 return -1;
10278 }
10279
10281 {
10283 {
10284 float overheat_coef = GetOverheatingCoef();
10285 int count = m_OverheatingParticles.Count();
10286
10287 for (int i = count; i > 0; --i)
10288 {
10289 int id = i - 1;
10290 OverheatingParticle OP = m_OverheatingParticles.Get(id);
10291 Particle p = OP.GetParticle();
10292
10293 float overheat_min = OP.GetOverheatingLimitMin();
10294 float overheat_max = OP.GetOverheatingLimitMax();
10295
10296 if (overheat_coef < overheat_min && overheat_coef >= overheat_max)
10297 {
10298 if (p)
10299 {
10300 p.Stop();
10301 OP.RegisterParticle(null);
10302 }
10303 }
10304 }
10305 }
10306 }
10307
10309 {
10311 {
10312 for (int i = m_OverheatingParticles.Count(); i > 0; i--)
10313 {
10314 int id = i - 1;
10315 OverheatingParticle OP = m_OverheatingParticles.Get(id);
10316
10317 if (OP)
10318 {
10319 Particle p = OP.GetParticle();
10320
10321 if (p)
10322 {
10323 p.Stop();
10324 }
10325
10326 delete OP;
10327 }
10328 }
10329
10330 m_OverheatingParticles.Clear();
10332 }
10333 }
10334
10336 float GetInfectionChance(int system = 0, Param param = null)
10337 {
10338 return 0.0;
10339 }
10340
10341
10342 float GetDisinfectQuantity(int system = 0, Param param1 = null)
10343 {
10344 return 250;//default value
10345 }
10346
10347 float GetFilterDamageRatio()
10348 {
10349 return 0;
10350 }
10351
10353 bool HasMuzzle()
10354 {
10355 if (IsInherited(Weapon) || IsInherited(SuppressorBase))
10356 return true;
10357
10358 return false;
10359 }
10360
10362 int GetMuzzleID()
10363 {
10364 if (!m_WeaponTypeToID)
10366
10367 if (m_WeaponTypeToID.Contains(GetType()))
10368 {
10369 return m_WeaponTypeToID.Get(GetType());
10370 }
10371 else
10372 {
10373 // Register new weapon ID
10375 }
10376
10378 }
10379
10386 {
10387 return -1;
10388 }
10389
10390
10391
10392 // -------------------------------------------------------------------------
10393 void ~ItemBase()
10394 {
10395 if (GetGame() && GetGame().GetPlayer() && (!GetGame().IsDedicatedServer()))
10396 {
10397 PlayerBase player = PlayerBase.Cast(GetGame().GetPlayer());
10398 int r_index = player.GetHumanInventory().FindUserReservedLocationIndex(this);
10399
10400 if (r_index >= 0)
10401 {
10402 InventoryLocation r_il = new InventoryLocation;
10403 player.GetHumanInventory().GetUserReservedLocation(r_index,r_il);
10404
10405 player.GetHumanInventory().ClearUserReservedLocationAtIndex(r_index);
10406 int r_type = r_il.GetType();
10407 if (r_type == InventoryLocationType.CARGO || r_type == InventoryLocationType.PROXYCARGO)
10408 {
10409 r_il.GetParent().GetOnReleaseLock().Invoke(this);
10410 }
10411 else if (r_type == InventoryLocationType.ATTACHMENT)
10412 {
10413 r_il.GetParent().GetOnAttachmentReleaseLock().Invoke(this, r_il.GetSlot());
10414 }
10415
10416 }
10417
10418 player.GetHumanInventory().ClearUserReservedLocation(this);
10419 }
10420
10421 if (m_LockingSound)
10422 SEffectManager.DestroyEffect(m_LockingSound);
10423 }
10424
10425
10426
10427 // -------------------------------------------------------------------------
10428 static int GetDebugActionsMask()
10429 {
10430 return ItemBase.m_DebugActionsMask;
10431 }
10432
10433 static bool HasDebugActionsMask(int mask)
10434 {
10435 return ItemBase.m_DebugActionsMask & mask;
10436 }
10437
10438 static void SetDebugActionsMask(int mask)
10439 {
10440 ItemBase.m_DebugActionsMask = mask;
10441 }
10442
10443 static void AddDebugActionsMask(int mask)
10444 {
10445 ItemBase.m_DebugActionsMask |= mask;
10446 }
10447
10448 static void RemoveDebugActionsMask(int mask)
10449 {
10450 ItemBase.m_DebugActionsMask &= ~mask;
10451 }
10452
10453 static void ToggleDebugActionsMask(int mask)
10454 {
10455 if (HasDebugActionsMask(mask))
10456 {
10458 }
10459 else
10460 {
10461 AddDebugActionsMask(mask);
10462 }
10463 }
10464
10465 // -------------------------------------------------------------------------
10466 void SetCEBasedQuantity()
10467 {
10468 if (GetEconomyProfile())
10469 {
10470 float q_max = GetEconomyProfile().GetQuantityMax();
10471 if (q_max > 0)
10472 {
10473 float q_min = GetEconomyProfile().GetQuantityMin();
10474 float quantity_randomized = Math.RandomFloatInclusive(q_min, q_max);
10475
10476 if (HasComponent(COMP_TYPE_ENERGY_MANAGER))//more direct access for speed
10477 {
10478 ComponentEnergyManager comp = GetCompEM();
10479 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
10480 {
10481 comp.SetEnergy0To1(quantity_randomized);
10482 }
10483 }
10484 else if (HasQuantity())
10485 {
10486 SetQuantityNormalized(quantity_randomized, false);
10487 //PrintString("<==> Normalized quantity for item: "+ GetType()+", qmin:"+q_min.ToString()+"; qmax:"+q_max.ToString()+";quantity:" +quantity_randomized.ToString());
10488 }
10489
10490 }
10491 }
10492 }
10493
10495 void LockToParent()
10496 {
10497 EntityAI parent = GetHierarchyParent();
10498
10499 if (parent)
10500 {
10501 InventoryLocation inventory_location_to_lock = new InventoryLocation;
10502 GetInventory().GetCurrentInventoryLocation(inventory_location_to_lock);
10503 parent.GetInventory().SetSlotLock(inventory_location_to_lock.GetSlot(), true);
10504 }
10505 }
10506
10508 void UnlockFromParent()
10509 {
10510 EntityAI parent = GetHierarchyParent();
10511
10512 if (parent)
10513 {
10514 InventoryLocation inventory_location_to_unlock = new InventoryLocation;
10515 GetInventory().GetCurrentInventoryLocation(inventory_location_to_unlock);
10516 parent.GetInventory().SetSlotLock(inventory_location_to_unlock.GetSlot(), false);
10517 }
10518 }
10519
10520 override void CombineItemsClient(EntityAI entity2, bool use_stack_max = true)
10521 {
10522 /*
10523 ref Param1<EntityAI> item = new Param1<EntityAI>(entity2);
10524 RPCSingleParam(ERPCs.RPC_ITEM_COMBINE, item, GetGame().GetPlayer());
10525 */
10526 ItemBase item2 = ItemBase.Cast(entity2);
10527
10528 if (GetGame().IsClient())
10529 {
10530 if (ScriptInputUserData.CanStoreInputUserData())
10531 {
10532 ScriptInputUserData ctx = new ScriptInputUserData;
10534 ctx.Write(-1);
10535 ItemBase i1 = this; // @NOTE: workaround for correct serialization
10536 ctx.Write(i1);
10537 ctx.Write(item2);
10538 ctx.Write(use_stack_max);
10539 ctx.Write(-1);
10540 ctx.Send();
10541
10542 if (IsCombineAll(item2, use_stack_max))
10543 {
10544 GetGame().GetPlayer().GetInventory().AddInventoryReservationEx(item2,null,GameInventory.c_InventoryReservationTimeoutShortMS);
10545 }
10546 }
10547 }
10548 else if (!GetGame().IsMultiplayer())
10549 {
10550 CombineItems(item2, use_stack_max);
10551 }
10552 }
10553
10554 bool IsLiquidPresent()
10555 {
10556 return (GetLiquidType() != 0 && HasQuantity());
10557 }
10558
10559 bool IsLiquidContainer()
10560 {
10561 return m_LiquidContainerMask != 0;
10562 }
10563
10565 {
10566 return m_LiquidContainerMask;
10567 }
10568
10569 bool IsBloodContainer()
10570 {
10571 //m_LiquidContainerMask & GROUP_LIQUID_BLOOD ???
10572 return false;
10573 }
10574
10575 bool IsNVG()
10576 {
10577 return false;
10578 }
10579
10582 bool IsExplosive()
10583 {
10584 return false;
10585 }
10586
10588 {
10589 return "";
10590 }
10591
10593
10594 bool IsLightSource()
10595 {
10596 return false;
10597 }
10598
10600 {
10601 return true;
10602 }
10603
10604 //--- ACTION CONDITIONS
10605 //direction
10606 bool IsFacingPlayer(PlayerBase player, string selection)
10607 {
10608 return true;
10609 }
10610
10611 bool IsPlayerInside(PlayerBase player, string selection)
10612 {
10613 return true;
10614 }
10615
10616 override bool CanObstruct()
10617 {
10618 PlayerBase player = PlayerBase.Cast(g_Game.GetPlayer());
10619 return !player || !IsPlayerInside(player, "");
10620 }
10621
10622 override bool IsBeingPlaced()
10623 {
10624 return m_IsBeingPlaced;
10625 }
10626
10627 void SetIsBeingPlaced(bool is_being_placed)
10628 {
10629 m_IsBeingPlaced = is_being_placed;
10630 if (!is_being_placed)
10632 SetSynchDirty();
10633 }
10634
10635 //server-side
10636 void OnEndPlacement() {}
10637
10638 override bool IsHologram()
10639 {
10640 return m_IsHologram;
10641 }
10642
10643 bool CanBeDigged()
10644 {
10645 return m_CanBeDigged;
10646 }
10647
10649 {
10650 return 1;
10651 }
10652
10653 bool CanMakeGardenplot()
10654 {
10655 return false;
10656 }
10657
10658 void SetIsHologram(bool is_hologram)
10659 {
10660 m_IsHologram = is_hologram;
10661 SetSynchDirty();
10662 }
10663 /*
10664 protected float GetNutritionalEnergy()
10665 {
10666 Edible_Base edible = Edible_Base.Cast(this);
10667 return edible.GetFoodEnergy();
10668 }
10669
10670 protected float GetNutritionalWaterContent()
10671 {
10672 Edible_Base edible = Edible_Base.Cast(this);
10673 return edible.GetFoodWater();
10674 }
10675
10676 protected float GetNutritionalIndex()
10677 {
10678 Edible_Base edible = Edible_Base.Cast(this);
10679 return edible.GetFoodNutritionalIndex();
10680 }
10681
10682 protected float GetNutritionalFullnessIndex()
10683 {
10684 Edible_Base edible = Edible_Base.Cast(this);
10685 return edible.GetFoodTotalVolume();
10686 }
10687
10688 protected float GetNutritionalToxicity()
10689 {
10690 Edible_Base edible = Edible_Base.Cast(this);
10691 return edible.GetFoodToxicity();
10692
10693 }
10694 */
10695
10696
10697 // -------------------------------------------------------------------------
10698 override void OnMovedInsideCargo(EntityAI container)
10699 {
10700 super.OnMovedInsideCargo(container);
10701
10702 MiscGameplayFunctions.RemoveAllAttachedChildrenByTypename(this, {Bolt_Base});
10703 }
10704
10705 override void EEItemLocationChanged(notnull InventoryLocation oldLoc, notnull InventoryLocation newLoc)
10706 {
10707 super.EEItemLocationChanged(oldLoc,newLoc);
10708
10709 PlayerBase new_player = null;
10710 PlayerBase old_player = null;
10711
10712 if (newLoc.GetParent())
10713 new_player = PlayerBase.Cast(newLoc.GetParent().GetHierarchyRootPlayer());
10714
10715 if (oldLoc.GetParent())
10716 old_player = PlayerBase.Cast(oldLoc.GetParent().GetHierarchyRootPlayer());
10717
10718 if (old_player && oldLoc.GetType() == InventoryLocationType.HANDS)
10719 {
10720 int r_index = old_player.GetHumanInventory().FindUserReservedLocationIndex(this);
10721
10722 if (r_index >= 0)
10723 {
10724 InventoryLocation r_il = new InventoryLocation;
10725 old_player.GetHumanInventory().GetUserReservedLocation(r_index,r_il);
10726
10727 old_player.GetHumanInventory().ClearUserReservedLocationAtIndex(r_index);
10728 int r_type = r_il.GetType();
10729 if (r_type == InventoryLocationType.CARGO || r_type == InventoryLocationType.PROXYCARGO)
10730 {
10731 r_il.GetParent().GetOnReleaseLock().Invoke(this);
10732 }
10733 else if (r_type == InventoryLocationType.ATTACHMENT)
10734 {
10735 r_il.GetParent().GetOnAttachmentReleaseLock().Invoke(this, r_il.GetSlot());
10736 }
10737
10738 }
10739 }
10740
10741 if (newLoc.GetType() == InventoryLocationType.HANDS)
10742 {
10743 if (new_player)
10744 new_player.ForceStandUpForHeavyItems(newLoc.GetItem());
10745
10746 if (new_player == old_player)
10747 {
10748
10749 if (oldLoc.GetParent() && new_player.GetHumanInventory().LocationGetEntity(oldLoc) == NULL)
10750 {
10751 if (oldLoc.GetType() == InventoryLocationType.CARGO)
10752 {
10753 if (oldLoc.GetParent().GetInventory().TestAddEntityInCargoExLoc(oldLoc, false, false, false, true, false, false))
10754 {
10755 new_player.GetHumanInventory().SetUserReservedLocation(this,oldLoc);
10756 }
10757 }
10758 else
10759 {
10760 new_player.GetHumanInventory().SetUserReservedLocation(this,oldLoc);
10761 }
10762 }
10763
10764 if (new_player.GetHumanInventory().FindUserReservedLocationIndex(this) >= 0)
10765 {
10766 int type = oldLoc.GetType();
10767 if (type == InventoryLocationType.CARGO || type == InventoryLocationType.PROXYCARGO)
10768 {
10769 oldLoc.GetParent().GetOnSetLock().Invoke(this);
10770 }
10771 else if (type == InventoryLocationType.ATTACHMENT)
10772 {
10773 oldLoc.GetParent().GetOnAttachmentSetLock().Invoke(this, oldLoc.GetSlot());
10774 }
10775 }
10776 if (!m_OldLocation)
10777 {
10778 m_OldLocation = new InventoryLocation;
10779 }
10780 m_OldLocation.Copy(oldLoc);
10781 }
10782 else
10783 {
10784 if (m_OldLocation)
10785 {
10786 m_OldLocation.Reset();
10787 }
10788 }
10789
10791 }
10792 else
10793 {
10794 if (new_player)
10795 {
10796 int res_index = new_player.GetHumanInventory().FindCollidingUserReservedLocationIndex(this, newLoc);
10797 if (res_index >= 0)
10798 {
10799 InventoryLocation il = new InventoryLocation;
10800 new_player.GetHumanInventory().GetUserReservedLocation(res_index,il);
10801 ItemBase it = ItemBase.Cast(il.GetItem());
10802 new_player.GetHumanInventory().ClearUserReservedLocationAtIndex(res_index);
10803 int rel_type = il.GetType();
10804 if (rel_type == InventoryLocationType.CARGO || rel_type == InventoryLocationType.PROXYCARGO)
10805 {
10806 il.GetParent().GetOnReleaseLock().Invoke(it);
10807 }
10808 else if (rel_type == InventoryLocationType.ATTACHMENT)
10809 {
10810 il.GetParent().GetOnAttachmentReleaseLock().Invoke(it, il.GetSlot());
10811 }
10812 //it.GetOnReleaseLock().Invoke(it);
10813 }
10814 }
10815 else if (old_player && newLoc.GetType() == InventoryLocationType.GROUND && m_ThrowItemOnDrop)
10816 {
10817 //ThrowPhysically(old_player, vector.Zero);
10818 m_ThrowItemOnDrop = false;
10819 }
10820
10821 if (m_OldLocation)
10822 {
10823 m_OldLocation.Reset();
10824 }
10825 }
10826 }
10827
10828 override void EOnContact(IEntity other, Contact extra)
10829 {
10831 {
10832 int liquidType = -1;
10833 float impactSpeed = ProcessImpactSoundEx(other, extra, m_ConfigWeight, m_ImpactSoundSurfaceHash, liquidType);
10834 if (impactSpeed > 0.0)
10835 {
10836 m_ImpactSpeed = impactSpeed;
10837 #ifndef SERVER
10838 PlayImpactSound(m_ConfigWeight, m_ImpactSpeed, m_ImpactSoundSurfaceHash);
10839 #else
10840 m_WantPlayImpactSound = true;
10841 SetSynchDirty();
10842 #endif
10843 m_CanPlayImpactSound = (liquidType == -1);// prevents further playing of the sound when the surface is a liquid type
10844 }
10845 }
10846
10847 #ifdef SERVER
10848 if (GetCompEM() && GetCompEM().IsPlugged())
10849 {
10850 if (GetCompEM().GetCordLength() < vector.Distance(GetPosition(), GetCompEM().GetEnergySource().GetPosition()))
10851 GetCompEM().UnplugThis();
10852 }
10853 #endif
10854 }
10855
10856 void RefreshPhysics();
10857
10858 override void OnCreatePhysics()
10859 {
10861 }
10862
10863 override void OnItemAttachmentSlotChanged(notnull InventoryLocation oldLoc, notnull InventoryLocation newLoc)
10864 {
10865
10866 }
10867 // -------------------------------------------------------------------------
10868 override void OnItemLocationChanged(EntityAI old_owner, EntityAI new_owner)
10869 {
10870 super.OnItemLocationChanged(old_owner, new_owner);
10871
10872 PlayerBase relatedPlayer = PlayerBase.Cast(old_owner);
10873 PlayerBase playerNew = PlayerBase.Cast(new_owner);
10874
10875 if (!relatedPlayer && playerNew)
10876 relatedPlayer = playerNew;
10877
10878 if (relatedPlayer && relatedPlayer.GetPerformedActionID() != -1)
10879 {
10880 ActionManagerBase actionMgr = relatedPlayer.GetActionManager();
10881 if (actionMgr)
10882 {
10883 ActionBase currentAction = actionMgr.GetRunningAction();
10884 if (currentAction)
10885 currentAction.OnItemLocationChanged(this);
10886 }
10887 }
10888
10889 Man ownerPlayerOld = null;
10890 Man ownerPlayerNew = null;
10891
10892 if (old_owner)
10893 {
10894 if (old_owner.IsMan())
10895 {
10896 ownerPlayerOld = Man.Cast(old_owner);
10897 }
10898 else
10899 {
10900 ownerPlayerOld = Man.Cast(old_owner.GetHierarchyRootPlayer());
10901 }
10902 }
10903 else
10904 {
10905 if (new_owner && IsElectricAppliance() && GetCompEM() && GetCompEM().IsPlugged())
10906 {
10907 ActionBase action = ActionManagerBase.GetAction(ActionRepositionPluggedItem);
10908
10909 if (!action || !playerNew || playerNew.GetPerformedActionID() != action.GetID())
10910 {
10911 GetCompEM().UnplugThis();
10912 }
10913 }
10914 }
10915
10916 if (new_owner)
10917 {
10918 if (new_owner.IsMan())
10919 {
10920 ownerPlayerNew = Man.Cast(new_owner);
10921 }
10922 else
10923 {
10924 ownerPlayerNew = Man.Cast(new_owner.GetHierarchyRootPlayer());
10925 }
10926 }
10927
10928 if (ownerPlayerOld != ownerPlayerNew)
10929 {
10930 if (ownerPlayerOld)
10931 {
10932 array<EntityAI> subItemsExit = new array<EntityAI>;
10933 GetInventory().EnumerateInventory(InventoryTraversalType.PREORDER,subItemsExit);
10934 for (int i = 0; i < subItemsExit.Count(); i++)
10935 {
10936 ItemBase itemExit = ItemBase.Cast(subItemsExit.Get(i));
10937 itemExit.OnInventoryExit(ownerPlayerOld);
10938 }
10939 }
10940
10941 if (ownerPlayerNew)
10942 {
10943 array<EntityAI> subItemsEnter = new array<EntityAI>;
10944 GetInventory().EnumerateInventory(InventoryTraversalType.PREORDER,subItemsEnter);
10945 for (int j = 0; j < subItemsEnter.Count(); j++)
10946 {
10947 ItemBase itemEnter = ItemBase.Cast(subItemsEnter.Get(j));
10948 itemEnter.OnInventoryEnter(ownerPlayerNew);
10949 }
10950 }
10951 }
10952 else if (ownerPlayerNew != null)
10953 {
10954 PlayerBase nplayer;
10955 if (PlayerBase.CastTo(nplayer, ownerPlayerNew))
10956 {
10957 array<EntityAI> subItemsUpdate = new array<EntityAI>;
10958 GetInventory().EnumerateInventory(InventoryTraversalType.PREORDER,subItemsUpdate);
10959 for (int k = 0; k < subItemsUpdate.Count(); k++)
10960 {
10961 ItemBase itemUpdate = ItemBase.Cast(subItemsUpdate.Get(k));
10962 itemUpdate.UpdateQuickbarShortcutVisibility(nplayer);
10963 }
10964 }
10965 }
10966
10967 if (old_owner)
10968 old_owner.OnChildItemRemoved(this);
10969 if (new_owner)
10970 new_owner.OnChildItemReceived(this);
10971 }
10972
10973 // -------------------------------------------------------------------------------
10974 override void EEDelete(EntityAI parent)
10975 {
10976 super.EEDelete(parent);
10977 PlayerBase player = PlayerBase.Cast(GetHierarchyRootPlayer());
10978 if (player)
10979 {
10980 OnInventoryExit(player);
10981
10982 if (player.IsAlive())
10983 {
10984 int r_index = player.GetHumanInventory().FindUserReservedLocationIndex(this);
10985 if (r_index >= 0)
10986 {
10987 InventoryLocation r_il = new InventoryLocation;
10988 player.GetHumanInventory().GetUserReservedLocation(r_index,r_il);
10989
10990 player.GetHumanInventory().ClearUserReservedLocationAtIndex(r_index);
10991 int r_type = r_il.GetType();
10992 if (r_type == InventoryLocationType.CARGO || r_type == InventoryLocationType.PROXYCARGO)
10993 {
10994 r_il.GetParent().GetOnReleaseLock().Invoke(this);
10995 }
10996 else if (r_type == InventoryLocationType.ATTACHMENT)
10997 {
10998 r_il.GetParent().GetOnAttachmentReleaseLock().Invoke(this, r_il.GetSlot());
10999 }
11000
11001 }
11002
11003 player.RemoveQuickBarEntityShortcut(this);
11004 }
11005 }
11006 }
11007 // -------------------------------------------------------------------------------
11008 override void EEKilled(Object killer)
11009 {
11010 super.EEKilled(killer);
11011
11013 if (killer && killer.IsFireplace() && CanExplodeInFire())
11014 {
11015 if (GetTemperature() >= GameConstants.ITEM_TEMPERATURE_TO_EXPLODE_MIN)
11016 {
11017 if (IsMagazine())
11018 {
11019 if (Magazine.Cast(this).GetAmmoCount() > 0)
11020 {
11021 ExplodeAmmo();
11022 }
11023 }
11024 else
11025 {
11026 Explode(DamageType.EXPLOSION);
11027 }
11028 }
11029 }
11030 }
11031
11032 override void OnWasAttached(EntityAI parent, int slot_id)
11033 {
11034 MiscGameplayFunctions.RemoveAllAttachedChildrenByTypename(this, {Bolt_Base});
11035
11036 super.OnWasAttached(parent, slot_id);
11037
11038 if (HasQuantity())
11039 UpdateNetSyncVariableFloat("m_VarQuantity", GetQuantityMin(), m_VarQuantityMax);
11040
11041 PlayAttachSound(InventorySlots.GetSlotName(slot_id));
11042 }
11043
11044 override void OnWasDetached(EntityAI parent, int slot_id)
11045 {
11046 super.OnWasDetached(parent, slot_id);
11047
11048 if (HasQuantity())
11049 UpdateNetSyncVariableFloat("m_VarQuantity", GetQuantityMin(), m_VarQuantityMax);
11050 }
11051
11052 override string ChangeIntoOnAttach(string slot)
11053 {
11054 int idx;
11055 TStringArray inventory_slots = new TStringArray;
11056 TStringArray attach_types = new TStringArray;
11057
11058 ConfigGetTextArray("ChangeInventorySlot",inventory_slots);
11059 if (inventory_slots.Count() < 1) //is string
11060 {
11061 inventory_slots.Insert(ConfigGetString("ChangeInventorySlot"));
11062 attach_types.Insert(ConfigGetString("ChangeIntoOnAttach"));
11063 }
11064 else //is array
11065 {
11066 ConfigGetTextArray("ChangeIntoOnAttach",attach_types);
11067 }
11068
11069 idx = inventory_slots.Find(slot);
11070 if (idx < 0)
11071 return "";
11072
11073 return attach_types.Get(idx);
11074 }
11075
11076 override string ChangeIntoOnDetach()
11077 {
11078 int idx = -1;
11079 string slot;
11080
11081 TStringArray inventory_slots = new TStringArray;
11082 TStringArray detach_types = new TStringArray;
11083
11084 this.ConfigGetTextArray("ChangeInventorySlot",inventory_slots);
11085 if (inventory_slots.Count() < 1) //is string
11086 {
11087 inventory_slots.Insert(this.ConfigGetString("ChangeInventorySlot"));
11088 detach_types.Insert(this.ConfigGetString("ChangeIntoOnDetach"));
11089 }
11090 else //is array
11091 {
11092 this.ConfigGetTextArray("ChangeIntoOnDetach",detach_types);
11093 if (detach_types.Count() < 1)
11094 detach_types.Insert(this.ConfigGetString("ChangeIntoOnDetach"));
11095 }
11096
11097 for (int i = 0; i < inventory_slots.Count(); i++)
11098 {
11099 slot = inventory_slots.Get(i);
11100 }
11101
11102 if (slot != "")
11103 {
11104 if (detach_types.Count() == 1)
11105 idx = 0;
11106 else
11107 idx = inventory_slots.Find(slot);
11108 }
11109 if (idx < 0)
11110 return "";
11111
11112 return detach_types.Get(idx);
11113 }
11114
11115 void ExplodeAmmo()
11116 {
11117 //timer
11118 ref Timer explode_timer = new Timer(CALL_CATEGORY_SYSTEM);
11119
11120 //min/max time
11121 float min_time = 1;
11122 float max_time = 3;
11123 float delay = Math.RandomFloat(min_time, max_time);
11124
11125 explode_timer.Run(delay, this, "DoAmmoExplosion");
11126 }
11127
11128 void DoAmmoExplosion()
11129 {
11130 Magazine magazine = Magazine.Cast(this);
11131 int pop_sounds_count = 6;
11132 string pop_sounds[ 6 ] = { "ammopops_1","ammopops_2","ammopops_3","ammopops_4","ammopops_5","ammopops_6" };
11133
11134 //play sound
11135 int sound_idx = Math.RandomInt(0, pop_sounds_count - 1);
11136 string sound_name = pop_sounds[ sound_idx ];
11137 GetGame().CreateSoundOnObject(this, sound_name, 20, false);
11138
11139 //remove ammo count
11140 magazine.ServerAddAmmoCount(-1);
11141
11142 //if condition then repeat -> ExplodeAmmo
11143 float min_temp_to_explode = 100; //min temperature for item to explode
11144
11145 if (magazine.GetAmmoCount() > 0 && GetTemperature() >= min_temp_to_explode) //TODO ? add check for parent -> fireplace
11146 {
11147 ExplodeAmmo();
11148 }
11149 }
11150
11151 // -------------------------------------------------------------------------------
11152 override void EEHitBy(TotalDamageResult damageResult, int damageType, EntityAI source, int component, string dmgZone, string ammo, vector modelPos, float speedCoef)
11153 {
11154 super.EEHitBy(damageResult, damageType, source, component, dmgZone, ammo, modelPos, speedCoef);
11155
11156 const int CHANCE_DAMAGE_CARGO = 4;
11157 const int CHANCE_DAMAGE_ATTACHMENT = 1;
11158 const int CHANCE_DAMAGE_NOTHING = 2;
11159
11160 if (IsClothing() || IsContainer() || IsItemTent())
11161 {
11162 float dmg = damageResult.GetDamage("","Health") * -0.5;
11163 int chances;
11164 int rnd;
11165
11166 if (GetInventory().GetCargo())
11167 {
11168 chances = CHANCE_DAMAGE_CARGO + CHANCE_DAMAGE_ATTACHMENT + CHANCE_DAMAGE_NOTHING;
11169 rnd = Math.RandomInt(0,chances);
11170
11171 if (rnd < CHANCE_DAMAGE_CARGO)
11172 {
11173 DamageItemInCargo(dmg);
11174 }
11175 else if (rnd < (chances - CHANCE_DAMAGE_NOTHING))
11176 {
11178 }
11179 }
11180 else
11181 {
11182 chances = CHANCE_DAMAGE_ATTACHMENT + CHANCE_DAMAGE_NOTHING;
11183 rnd = Math.RandomInt(0,chances);
11184
11185 if (rnd < CHANCE_DAMAGE_ATTACHMENT)
11186 {
11188 }
11189 }
11190 }
11191 }
11192
11193 bool DamageItemInCargo(float damage)
11194 {
11195 if (GetInventory().GetCargo())
11196 {
11197 int item_count = GetInventory().GetCargo().GetItemCount();
11198 if (item_count > 0)
11199 {
11200 int random_pick = Math.RandomInt(0, item_count);
11201 ItemBase item = ItemBase.Cast(GetInventory().GetCargo().GetItem(random_pick));
11202 if (!item.IsExplosive())
11203 {
11204 item.AddHealth("","",damage);
11205 return true;
11206 }
11207 }
11208 }
11209 return false;
11210 }
11211
11212 bool DamageItemAttachments(float damage)
11213 {
11214 int attachment_count = GetInventory().AttachmentCount();
11215 if (attachment_count > 0)
11216 {
11217 int random_pick = Math.RandomInt(0, attachment_count);
11218 ItemBase attachment = ItemBase.Cast(GetInventory().GetAttachmentFromIndex(random_pick));
11219 if (!attachment.IsExplosive())
11220 {
11221 attachment.AddHealth("","",damage);
11222 return true;
11223 }
11224 }
11225 return false;
11226 }
11227
11228 override bool IsSplitable()
11229 {
11230 return m_CanThisBeSplit;
11231 }
11232 //----------------
11233 override bool CanBeSplit()
11234 {
11235 if (IsSplitable() && (GetQuantity() > 1))
11236 return GetInventory().CanRemoveEntity();
11237
11238 return false;
11239 }
11240
11241 protected bool ShouldSplitQuantity(float quantity)
11242 {
11243 // don't call 'CanBeSplit' here, too strict and will introduce a freeze-crash when dismantling fence with a fireplace nearby
11244 if (!IsSplitable())
11245 return false;
11246
11247 // nothing to split?
11248 if (GetQuantity() <= 1)
11249 return false;
11250
11251 // check if we should re-use the item instead of creating a new copy?
11252 // implicit cast to int, if 'IsSplitable' returns true, these values are assumed ints
11253 int delta = GetQuantity() - quantity;
11254 if (delta == 0)
11255 return false;
11256
11257 // valid to split
11258 return true;
11259 }
11260
11261 override void SplitIntoStackMaxClient(EntityAI destination_entity, int slot_id )
11262 {
11263 if (GetGame().IsClient())
11264 {
11265 if (ScriptInputUserData.CanStoreInputUserData())
11266 {
11267 ScriptInputUserData ctx = new ScriptInputUserData;
11269 ctx.Write(1);
11270 ItemBase i1 = this; // @NOTE: workaround for correct serialization
11271 ctx.Write(i1);
11272 ctx.Write(destination_entity);
11273 ctx.Write(true);
11274 ctx.Write(slot_id);
11275 ctx.Send();
11276 }
11277 }
11278 else if (!GetGame().IsMultiplayer())
11279 {
11280 SplitIntoStackMax(destination_entity, slot_id, PlayerBase.Cast(GetGame().GetPlayer()));
11281 }
11282 }
11283
11284 void SplitIntoStackMax(EntityAI destination_entity, int slot_id, PlayerBase player)
11285 {
11286 float split_quantity_new;
11287 ItemBase new_item;
11288 float quantity = GetQuantity();
11289 float stack_max = GetTargetQuantityMax(slot_id);
11290 InventoryLocation loc = new InventoryLocation;
11291
11292 if (destination_entity && slot_id != -1 && InventorySlots.IsSlotIdValid(slot_id))
11293 {
11294 if (stack_max <= GetQuantity())
11295 split_quantity_new = stack_max;
11296 else
11297 split_quantity_new = GetQuantity();
11298
11299 if (ShouldSplitQuantity(split_quantity_new))
11300 {
11301 new_item = ItemBase.Cast(destination_entity.GetInventory().CreateAttachmentEx(this.GetType(), slot_id));
11302 if (new_item)
11303 {
11304 new_item.SetResultOfSplit(true);
11305 MiscGameplayFunctions.TransferItemProperties(this, new_item);
11306 AddQuantity(-split_quantity_new, false, true);
11307 new_item.SetQuantity(split_quantity_new, false, true);
11308 }
11309 }
11310 }
11311 else if (destination_entity && slot_id == -1)
11312 {
11313 if (quantity > stack_max)
11314 split_quantity_new = stack_max;
11315 else
11316 split_quantity_new = quantity;
11317
11318 if (ShouldSplitQuantity(split_quantity_new))
11319 {
11320 if (destination_entity.GetInventory().FindFreeLocationFor(this, FindInventoryLocationType.ANY, loc))
11321 {
11322 Object o = destination_entity.GetInventory().LocationCreateEntity(loc, GetType(), ECE_IN_INVENTORY, RF_DEFAULT);
11323 new_item = ItemBase.Cast(o);
11324 }
11325
11326 if (new_item)
11327 {
11328 new_item.SetResultOfSplit(true);
11329 MiscGameplayFunctions.TransferItemProperties(this, new_item);
11330 AddQuantity(-split_quantity_new, false, true);
11331 new_item.SetQuantity(split_quantity_new, false, true);
11332 }
11333 }
11334 }
11335 else
11336 {
11337 if (stack_max != 0)
11338 {
11339 if (stack_max < GetQuantity())
11340 {
11341 split_quantity_new = GetQuantity() - stack_max;
11342 }
11343
11344 if (split_quantity_new == 0)
11345 {
11346 if (!GetGame().IsMultiplayer())
11347 player.PhysicalPredictiveDropItem(this);
11348 else
11349 player.ServerDropEntity(this);
11350 return;
11351 }
11352
11353 if (ShouldSplitQuantity(split_quantity_new))
11354 {
11355 new_item = ItemBase.Cast(GetGame().CreateObjectEx(GetType(), player.GetWorldPosition(), ECE_PLACE_ON_SURFACE));
11356
11357 if (new_item)
11358 {
11359 new_item.SetResultOfSplit(true);
11360 MiscGameplayFunctions.TransferItemProperties(this, new_item);
11361 SetQuantity(split_quantity_new, false, true);
11362 new_item.SetQuantity(stack_max, false, true);
11363 new_item.PlaceOnSurface();
11364 }
11365 }
11366 }
11367 }
11368 }
11369
11370 override void SplitIntoStackMaxEx(EntityAI destination_entity, int slot_id)
11371 {
11372 float split_quantity_new;
11373 ItemBase new_item;
11374 float quantity = GetQuantity();
11375 float stack_max = GetTargetQuantityMax(slot_id);
11376 InventoryLocation loc = new InventoryLocation;
11377
11378 if (destination_entity && slot_id != -1 && InventorySlots.IsSlotIdValid(slot_id))
11379 {
11380 if (stack_max <= GetQuantity())
11381 split_quantity_new = stack_max;
11382 else
11383 split_quantity_new = GetQuantity();
11384
11385 if (ShouldSplitQuantity(split_quantity_new))
11386 {
11387 new_item = ItemBase.Cast(destination_entity.GetInventory().CreateAttachmentEx(this.GetType(), slot_id));
11388 if (new_item)
11389 {
11390 new_item.SetResultOfSplit(true);
11391 MiscGameplayFunctions.TransferItemProperties(this, new_item);
11392 AddQuantity(-split_quantity_new, false, true);
11393 new_item.SetQuantity(split_quantity_new, false, true);
11394 }
11395 }
11396 }
11397 else if (destination_entity && slot_id == -1)
11398 {
11399 if (quantity > stack_max)
11400 split_quantity_new = stack_max;
11401 else
11402 split_quantity_new = quantity;
11403
11404 if (ShouldSplitQuantity(split_quantity_new))
11405 {
11406 if (destination_entity.GetInventory().FindFreeLocationFor(this, FindInventoryLocationType.ANY, loc))
11407 {
11408 Object o = destination_entity.GetInventory().LocationCreateEntity(loc, GetType(), ECE_IN_INVENTORY, RF_DEFAULT);
11409 new_item = ItemBase.Cast(o);
11410 }
11411
11412 if (new_item)
11413 {
11414 new_item.SetResultOfSplit(true);
11415 MiscGameplayFunctions.TransferItemProperties(this, new_item);
11416 AddQuantity(-split_quantity_new, false, true);
11417 new_item.SetQuantity(split_quantity_new, false, true);
11418 }
11419 }
11420 }
11421 else
11422 {
11423 if (stack_max != 0)
11424 {
11425 if (stack_max < GetQuantity())
11426 {
11427 split_quantity_new = GetQuantity() - stack_max;
11428 }
11429
11430 if (ShouldSplitQuantity(split_quantity_new))
11431 {
11432 new_item = ItemBase.Cast(GetGame().CreateObjectEx(GetType(),GetWorldPosition(), ECE_PLACE_ON_SURFACE));
11433
11434 if (new_item)
11435 {
11436 new_item.SetResultOfSplit(true);
11437 MiscGameplayFunctions.TransferItemProperties(this, new_item);
11438 SetQuantity(split_quantity_new, false, true);
11439 new_item.SetQuantity(stack_max, false, true);
11440 new_item.PlaceOnSurface();
11441 }
11442 }
11443 }
11444 }
11445 }
11446
11447 void SplitIntoStackMaxToInventoryLocationClient(notnull InventoryLocation dst)
11448 {
11449 if (GetGame().IsClient())
11450 {
11451 if (ScriptInputUserData.CanStoreInputUserData())
11452 {
11453 ScriptInputUserData ctx = new ScriptInputUserData;
11455 ctx.Write(4);
11456 ItemBase thiz = this; // @NOTE: workaround for correct serialization
11457 ctx.Write(thiz);
11458 dst.WriteToContext(ctx);
11459 ctx.Send();
11460 }
11461 }
11462 else if (!GetGame().IsMultiplayer())
11463 {
11465 }
11466 }
11467
11468 void SplitIntoStackMaxCargoClient(EntityAI destination_entity, int idx, int row, int col)
11469 {
11470 if (GetGame().IsClient())
11471 {
11472 if (ScriptInputUserData.CanStoreInputUserData())
11473 {
11474 ScriptInputUserData ctx = new ScriptInputUserData;
11476 ctx.Write(2);
11477 ItemBase dummy = this; // @NOTE: workaround for correct serialization
11478 ctx.Write(dummy);
11479 ctx.Write(destination_entity);
11480 ctx.Write(true);
11481 ctx.Write(idx);
11482 ctx.Write(row);
11483 ctx.Write(col);
11484 ctx.Send();
11485 }
11486 }
11487 else if (!GetGame().IsMultiplayer())
11488 {
11489 SplitIntoStackMaxCargo(destination_entity, idx, row, col);
11490 }
11491 }
11492
11493 void SplitIntoStackMaxToInventoryLocation(notnull InventoryLocation dst)
11494 {
11496 }
11497
11498 ItemBase SplitIntoStackMaxToInventoryLocationEx(notnull InventoryLocation dst)
11499 {
11500 float quantity = GetQuantity();
11501 float split_quantity_new;
11502 ItemBase new_item;
11503 if (dst.IsValid())
11504 {
11505 int slot_id = dst.GetSlot();
11506 float stack_max = GetTargetQuantityMax(slot_id);
11507
11508 if (quantity > stack_max)
11509 split_quantity_new = stack_max;
11510 else
11511 split_quantity_new = quantity;
11512
11513 if (ShouldSplitQuantity(split_quantity_new))
11514 {
11515 new_item = ItemBase.Cast(GameInventory.LocationCreateEntity(dst, this.GetType(), ECE_IN_INVENTORY, RF_DEFAULT));
11516
11517 if (new_item)
11518 {
11519 new_item.SetResultOfSplit(true);
11520 MiscGameplayFunctions.TransferItemProperties(this,new_item);
11521 AddQuantity(-split_quantity_new, false, true);
11522 new_item.SetQuantity(split_quantity_new, false, true);
11523 }
11524
11525 return new_item;
11526 }
11527 }
11528
11529 return null;
11530 }
11531
11532 void SplitIntoStackMaxCargo(EntityAI destination_entity, int idx, int row, int col)
11533 {
11534 float quantity = GetQuantity();
11535 float split_quantity_new;
11536 ItemBase new_item;
11537 if (destination_entity)
11538 {
11539 float stackable = GetTargetQuantityMax();
11540 if (quantity > stackable)
11541 split_quantity_new = stackable;
11542 else
11543 split_quantity_new = quantity;
11544
11545 if (ShouldSplitQuantity(split_quantity_new))
11546 {
11547 new_item = ItemBase.Cast(destination_entity.GetInventory().CreateEntityInCargoEx(this.GetType(), idx, row, col, false));
11548 if (new_item)
11549 {
11550 new_item.SetResultOfSplit(true);
11551 MiscGameplayFunctions.TransferItemProperties(this,new_item);
11552 AddQuantity(-split_quantity_new, false, true);
11553 new_item.SetQuantity(split_quantity_new, false, true);
11554 }
11555 }
11556 }
11557 }
11558
11559 void SplitIntoStackMaxHandsClient(PlayerBase player)
11560 {
11561 if (GetGame().IsClient())
11562 {
11563 if (ScriptInputUserData.CanStoreInputUserData())
11564 {
11565 ScriptInputUserData ctx = new ScriptInputUserData;
11567 ctx.Write(3);
11568 ItemBase i1 = this; // @NOTE: workaround for correct serialization
11569 ctx.Write(i1);
11570 ItemBase destination_entity = this;
11571 ctx.Write(destination_entity);
11572 ctx.Write(true);
11573 ctx.Write(0);
11574 ctx.Send();
11575 }
11576 }
11577 else if (!GetGame().IsMultiplayer())
11578 {
11579 SplitIntoStackMaxHands(player);
11580 }
11581 }
11582
11583 void SplitIntoStackMaxHands(PlayerBase player)
11584 {
11585 float quantity = GetQuantity();
11586 float split_quantity_new;
11587 ref ItemBase new_item;
11588 if (player)
11589 {
11590 float stackable = GetTargetQuantityMax();
11591 if (quantity > stackable)
11592 split_quantity_new = stackable;
11593 else
11594 split_quantity_new = quantity;
11595
11596 if (ShouldSplitQuantity(split_quantity_new))
11597 {
11598 EntityAI in_hands = player.GetHumanInventory().CreateInHands(this.GetType());
11599 new_item = ItemBase.Cast(in_hands);
11600 if (new_item)
11601 {
11602 new_item.SetResultOfSplit(true);
11603 MiscGameplayFunctions.TransferItemProperties(this,new_item);
11604 AddQuantity(-split_quantity_new, false, true);
11605 new_item.SetQuantity(split_quantity_new, false, true);
11606 }
11607 }
11608 }
11609 }
11610
11611 void SplitItemToInventoryLocation(notnull InventoryLocation dst)
11612 {
11613 float quantity = GetQuantity();
11614 float split_quantity_new = Math.Floor(quantity * 0.5);
11615
11616 if (!ShouldSplitQuantity(split_quantity_new))
11617 return;
11618
11619 ItemBase new_item = ItemBase.Cast(GameInventory.LocationCreateEntity(dst, GetType(), ECE_IN_INVENTORY, RF_DEFAULT));
11620
11621 if (new_item)
11622 {
11623 if (new_item.GetQuantityMax() < split_quantity_new)
11624 {
11625 split_quantity_new = new_item.GetQuantityMax();
11626 }
11627
11628 new_item.SetResultOfSplit(true);
11629 MiscGameplayFunctions.TransferItemProperties(this, new_item);
11630
11631 if (dst.IsValid() && dst.GetType() == InventoryLocationType.ATTACHMENT && split_quantity_new > 1)
11632 {
11633 AddQuantity(-1, false, true);
11634 new_item.SetQuantity(1, false, true);
11635 }
11636 else
11637 {
11638 AddQuantity(-split_quantity_new, false, true);
11639 new_item.SetQuantity(split_quantity_new, false, true);
11640 }
11641 }
11642 }
11643
11644 void SplitItem(PlayerBase player)
11645 {
11646 float quantity = GetQuantity();
11647 float split_quantity_new = Math.Floor(quantity / 2);
11648
11649 if (!ShouldSplitQuantity(split_quantity_new))
11650 return;
11651
11652 InventoryLocation invloc = new InventoryLocation;
11653 bool found = player.GetInventory().FindFirstFreeLocationForNewEntity(GetType(), FindInventoryLocationType.ATTACHMENT, invloc);
11654
11655 ItemBase new_item;
11656 new_item = player.CreateCopyOfItemInInventoryOrGroundEx(this, true);
11657
11658 if (new_item)
11659 {
11660 if (new_item.GetQuantityMax() < split_quantity_new)
11661 {
11662 split_quantity_new = new_item.GetQuantityMax();
11663 }
11664 if (found && invloc.IsValid() && invloc.GetType() == InventoryLocationType.ATTACHMENT && split_quantity_new > 1)
11665 {
11666 AddQuantity(-1, false, true);
11667 new_item.SetQuantity(1, false, true);
11668 }
11669 else if (split_quantity_new > 1)
11670 {
11671 AddQuantity(-split_quantity_new, false, true);
11672 new_item.SetQuantity(split_quantity_new, false, true);
11673 }
11674 }
11675 }
11676
11678 void OnQuantityChanged(float delta)
11679 {
11680 SetWeightDirty();
11681 ItemBase parent = ItemBase.Cast(GetHierarchyParent());
11682
11683 if (parent)
11684 parent.OnAttachmentQuantityChangedEx(this, delta);
11685
11686 if (IsLiquidContainer())
11687 {
11688 if (GetQuantityNormalized() <= 0.0)
11689 {
11691 }
11692 else if (GetLiquidType() == LIQUID_NONE)
11693 {
11694 ErrorEx("Undefined liquid type quantity changed, please define liquid type first! Using init value.",ErrorExSeverity.INFO);
11696 }
11697 }
11698
11699 }
11700
11703 {
11704 // insert code here
11705 }
11706
11708 void OnAttachmentQuantityChangedEx(ItemBase item , float delta)
11709 {
11711 }
11712
11713 override void EEHealthLevelChanged(int oldLevel, int newLevel, string zone)
11714 {
11715 super.EEHealthLevelChanged(oldLevel,newLevel,zone);
11716
11717 if (GetGame().IsServer())
11718 {
11719 if (newLevel == GameConstants.STATE_RUINED)
11720 {
11722 EntityAI parent = GetHierarchyParent();
11723 if (parent && parent.IsFireplace())
11724 {
11725 CargoBase cargo = GetInventory().GetCargo();
11726 if (cargo)
11727 {
11728 for (int i = 0; i < cargo.GetItemCount(); ++i)
11729 {
11730 parent.GetInventory().TakeEntityToInventory(InventoryMode.SERVER, FindInventoryLocationType.CARGO, cargo.GetItem(i));
11731 }
11732 }
11733 }
11734 }
11735
11736 if (IsResultOfSplit())
11737 {
11738 // reset the splitting result flag, return to normal item behavior
11739 SetResultOfSplit(false);
11740 return;
11741 }
11742
11743 if (m_Cleanness != 0 && oldLevel < newLevel && newLevel != 0)
11744 {
11745 SetCleanness(0);//unclean the item upon damage dealt
11746 }
11747 }
11748 }
11749
11750 // just the split? TODO: verify
11751 override void OnRightClick()
11752 {
11753 super.OnRightClick();
11754
11755 if (CanBeSplit() && !GetDayZGame().IsLeftCtrlDown() && !GetGame().GetPlayer().GetInventory().HasInventoryReservation(this,null))
11756 {
11757 if (GetGame().IsClient())
11758 {
11759 if (ScriptInputUserData.CanStoreInputUserData())
11760 {
11761 EntityAI root = GetHierarchyRoot();
11762 Man playerOwner = GetHierarchyRootPlayer();
11763 InventoryLocation dst = new InventoryLocation;
11764
11765 // 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
11766 if (!playerOwner && root && root == this)
11767 {
11769 }
11770 else
11771 {
11772 // 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
11773 GetInventory().GetCurrentInventoryLocation(dst);
11774 if (!dst.GetParent() || dst.GetParent() && !dst.GetParent().GetInventory().FindFreeLocationFor(this, FindInventoryLocationType.CARGO, dst))
11775 {
11776 PlayerBase player = PlayerBase.Cast(GetGame().GetPlayer());
11777 if (!player.GetInventory().FindFreeLocationFor(this, FindInventoryLocationType.CARGO, dst) || !playerOwner)
11778 {
11780 }
11781 else
11782 {
11783 dst.SetCargo(dst.GetParent(), this, dst.GetIdx(), dst.GetRow(), dst.GetCol(), dst.GetFlip());
11784 /* hacky solution to check reservation of "this" item instead of null since the gamecode is checking null against null and returning reservation=true incorrectly
11785 this shouldnt cause issues within this scope*/
11786 if (GetGame().GetPlayer().GetInventory().HasInventoryReservation(this, dst))
11787 {
11789 }
11790 else
11791 {
11792 GetGame().GetPlayer().GetInventory().AddInventoryReservationEx(null, dst, GameInventory.c_InventoryReservationTimeoutShortMS);
11793 }
11794 }
11795 }
11796 }
11797
11798 ScriptInputUserData ctx = new ScriptInputUserData;
11800 ctx.Write(4);
11801 ItemBase thiz = this; // @NOTE: workaround for correct serialization
11802 ctx.Write(thiz);
11803 dst.WriteToContext(ctx);
11804 ctx.Write(true); // dummy
11805 ctx.Send();
11806 }
11807 }
11808 else if (!GetGame().IsMultiplayer())
11809 {
11810 SplitItem(PlayerBase.Cast(GetGame().GetPlayer()));
11811 }
11812 }
11813 }
11814
11815 protected void SetInventoryLocationToVicinityOrCurrent(EntityAI root, inout InventoryLocation dst)
11816 {
11817 if (root)
11818 {
11819 vector m4[4];
11820 root.GetTransform(m4);
11821 dst.SetGround(this, m4);
11822 }
11823 else
11824 {
11825 GetInventory().GetCurrentInventoryLocation(dst);
11826 }
11827 }
11828
11829 override bool CanBeCombined(EntityAI other_item, bool reservation_check = true, bool stack_max_limit = false)
11830 {
11831 //TODO: delete check zero quantity check after fix double posts hands fsm events
11832 if (!other_item || GetType() != other_item.GetType() || (IsFullQuantity() && other_item.GetQuantity() > 0) || other_item == this)
11833 return false;
11834
11835 if (GetHealthLevel() == GameConstants.STATE_RUINED || other_item.GetHealthLevel() == GameConstants.STATE_RUINED)
11836 return false;
11837
11838 //can_this_be_combined = ConfigGetBool("canBeSplit");
11840 return false;
11841
11842
11843 Magazine mag = Magazine.Cast(this);
11844 if (mag)
11845 {
11846 if (mag.GetAmmoCount() >= mag.GetAmmoMax())
11847 return false;
11848
11849 if (stack_max_limit)
11850 {
11851 Magazine other_mag = Magazine.Cast(other_item);
11852 if (other_item)
11853 {
11854 if (mag.GetAmmoCount() + other_mag.GetAmmoCount() > mag.GetAmmoMax())
11855 return false;
11856 }
11857
11858 }
11859 }
11860 else
11861 {
11862 //TODO: delete check zero quantity check after fix double posts hands fsm events
11863 if (GetQuantity() >= GetQuantityMax() && other_item.GetQuantity() > 0 )
11864 return false;
11865
11866 if (stack_max_limit && (GetQuantity() + other_item.GetQuantity() > GetQuantityMax()))
11867 return false;
11868 }
11869
11870 PlayerBase player = null;
11871 if (CastTo(player, GetHierarchyRootPlayer())) //false when attached to player's attachment slot
11872 {
11873 if (player.GetInventory().HasAttachment(this))
11874 return false;
11875
11876 if (player.IsItemsToDelete())
11877 return false;
11878 }
11879
11880 if (reservation_check && (GetInventory().HasInventoryReservation(this, null) || other_item.GetInventory().HasInventoryReservation(other_item, null)))
11881 return false;
11882
11883 int slotID;
11884 string slotName;
11885 if (GetInventory().GetCurrentAttachmentSlotInfo(slotID,slotName) && GetHierarchyParent().GetInventory().GetSlotLock(slotID))
11886 return false;
11887
11888 return true;
11889 }
11890
11891 bool IsCombineAll(ItemBase other_item, bool use_stack_max = false)
11892 {
11893 return ComputeQuantityUsed(other_item, use_stack_max) == other_item.GetQuantity();
11894 }
11895
11896 bool IsResultOfSplit()
11897 {
11898 return m_IsResultOfSplit;
11899 }
11900
11901 void SetResultOfSplit(bool value)
11902 {
11903 m_IsResultOfSplit = value;
11904 }
11905
11906 int ComputeQuantityUsed(ItemBase other_item, bool use_stack_max = true)
11907 {
11908 return ComputeQuantityUsedEx(other_item, use_stack_max);
11909 }
11910
11911 float ComputeQuantityUsedEx(ItemBase other_item, bool use_stack_max = true)
11912 {
11913 float other_item_quantity = other_item.GetQuantity();
11914 float this_free_space;
11915
11916 float stack_max = GetQuantityMax();
11917
11918 this_free_space = stack_max - GetQuantity();
11919
11920 if (other_item_quantity > this_free_space)
11921 {
11922 return this_free_space;
11923 }
11924 else
11925 {
11926 return other_item_quantity;
11927 }
11928 }
11929
11930 override void CombineItemsEx(EntityAI entity2, bool use_stack_max = true)
11931 {
11932 CombineItems(ItemBase.Cast(entity2),use_stack_max);
11933 }
11934
11935 void CombineItems(ItemBase other_item, bool use_stack_max = true)
11936 {
11937 if (!CanBeCombined(other_item, false))
11938 return;
11939
11940 if (!IsMagazine() && other_item)
11941 {
11942 float quantity_used = ComputeQuantityUsedEx(other_item,use_stack_max);
11943 if (quantity_used != 0)
11944 {
11945 float hp1 = GetHealth01("","");
11946 float hp2 = other_item.GetHealth01("","");
11947 float hpResult = ((hp1*GetQuantity()) + (hp2*quantity_used));
11948 hpResult = hpResult / (GetQuantity() + quantity_used);
11949
11950 hpResult *= GetMaxHealth();
11951 Math.Round(hpResult);
11952 SetHealth("", "Health", hpResult);
11953
11954 AddQuantity(quantity_used);
11955 other_item.AddQuantity(-quantity_used);
11956 }
11957 }
11958 OnCombine(other_item);
11959 }
11960
11961 void OnCombine(ItemBase other_item)
11962 {
11963 #ifdef SERVER
11964 if (!GetHierarchyRootPlayer() && GetHierarchyParent())
11965 GetHierarchyParent().IncreaseLifetimeUp();
11966 #endif
11967 };
11968
11969 void GetRecipesActions(Man player, out TSelectableActionInfoArray outputList)
11970 {
11971 PlayerBase p = PlayerBase.Cast(player);
11972
11973 array<int> recipesIds = p.m_Recipes;
11974 PluginRecipesManager moduleRecipesManager = PluginRecipesManager.Cast(GetPlugin(PluginRecipesManager));
11975 if (moduleRecipesManager)
11976 {
11977 EntityAI itemInHands = player.GetHumanInventory().GetEntityInHands();
11978 moduleRecipesManager.GetValidRecipes(ItemBase.Cast(this), ItemBase.Cast(itemInHands), recipesIds, p);
11979 }
11980
11981 for (int i = 0;i < recipesIds.Count(); i++)
11982 {
11983 int key = recipesIds.Get(i);
11984 string recipeName = moduleRecipesManager.GetRecipeName(key);
11985 outputList.Insert(new TSelectableActionInfo(SAT_CRAFTING, key, recipeName));
11986 }
11987 }
11988
11989 // -------------------------------------------------------------------------
11990 override void GetDebugActions(out TSelectableActionInfoArrayEx outputList)
11991 {
11992 super.GetDebugActions(outputList);
11993
11994 //quantity
11995 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.ADD_QUANTITY, "Quantity +20%", FadeColors.LIGHT_GREY));
11996 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.REMOVE_QUANTITY, "Quantity -20%", FadeColors.LIGHT_GREY));
11997 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SET_QUANTITY_0, "Set Quantity 0", FadeColors.LIGHT_GREY));
11998 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SET_MAX_QUANTITY, "Set Quantity Max", FadeColors.LIGHT_GREY));
11999 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SEPARATOR, "___________________________", FadeColors.RED));
12000
12001 //health
12002 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.ADD_HEALTH, "Health +20%", FadeColors.LIGHT_GREY));
12003 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.REMOVE_HEALTH, "Health -20%", FadeColors.LIGHT_GREY));
12004 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.DESTROY_HEALTH, "Health 0", FadeColors.LIGHT_GREY));
12005 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SEPARATOR, "___________________________", FadeColors.RED));
12006 //temperature
12007 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.ADD_TEMPERATURE, "Temperature +20", FadeColors.LIGHT_GREY));
12008 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.REMOVE_TEMPERATURE, "Temperature -20", FadeColors.LIGHT_GREY));
12009 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.FLIP_FROZEN, "Toggle Frozen", FadeColors.LIGHT_GREY));
12010 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SEPARATOR, "___________________________", FadeColors.RED));
12011
12012 //wet
12013 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.ADD_WETNESS, "Wetness +20", FadeColors.LIGHT_GREY));
12014 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.REMOVE_WETNESS, "Wetness -20", FadeColors.LIGHT_GREY));
12015 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SEPARATOR, "___________________________", FadeColors.RED));
12016
12017 //liquidtype
12018 if (IsLiquidContainer())
12019 {
12020 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.LIQUIDTYPE_UP, "LiquidType Next", FadeColors.LIGHT_GREY));
12021 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.LIQUIDTYPE_DOWN, "LiquidType Previous", FadeColors.LIGHT_GREY));
12022 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SEPARATOR, "___________________________", FadeColors.RED));
12023 }
12024
12025 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.MAKE_SPECIAL, "Make Special", FadeColors.LIGHT_GREY));
12026 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SEPARATOR, "___________________________", FadeColors.RED));
12027
12028 // watch
12029 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.WATCH_ITEM, "Watch (CTRL-Z)", FadeColors.LIGHT_GREY));
12030 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.WATCH_PLAYER, "Watch Player", FadeColors.LIGHT_GREY));
12031 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SEPARATOR, "___________________________", FadeColors.RED));
12032
12033 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.DELETE, "Delete", FadeColors.RED));
12034
12035 InventoryLocation loc = new InventoryLocation();
12036 GetInventory().GetCurrentInventoryLocation(loc);
12037 if (!loc || loc.GetType() == InventoryLocationType.GROUND)
12038 {
12039 if (Gizmo_IsSupported())
12040 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.GIZMO_OBJECT, "Gizmo Object", FadeColors.LIGHT_GREY));
12041 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.GIZMO_PHYSICS, "Gizmo Physics (SP Only)", FadeColors.LIGHT_GREY)); // intentionally allowed for testing physics desync
12042 }
12043
12044 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SEPARATOR, "___________________________", FadeColors.RED));
12045 }
12046
12047 // -------------------------------------------------------------------------
12048 // -------------------------------------------------------------------------
12049 // -------------------------------------------------------------------------
12050 override bool OnAction(int action_id, Man player, ParamsReadContext ctx)
12051 {
12052 super.OnAction(action_id, player, ctx);
12053
12054 if (GetGame().IsClient() || !GetGame().IsMultiplayer())
12055 {
12056 switch (action_id)
12057 {
12058 case EActions.GIZMO_OBJECT:
12059 GetGame().GizmoSelectObject(this);
12060 return true;
12061 case EActions.GIZMO_PHYSICS:
12062 GetGame().GizmoSelectPhysics(GetPhysics());
12063 return true;
12064 }
12065 }
12066
12067 if (GetGame().IsServer())
12068 {
12069 switch (action_id)
12070 {
12071 case EActions.DELETE:
12072 Delete();
12073 return true;
12074 }
12075 }
12076
12077 if (action_id >= EActions.RECIPES_RANGE_START && action_id < EActions.RECIPES_RANGE_END)
12078 {
12079 PluginRecipesManager plugin_recipes_manager = PluginRecipesManager.Cast(GetPlugin(PluginRecipesManager));
12080 int idWithoutOffset = action_id - EActions.RECIPES_RANGE_START;
12081 PlayerBase p = PlayerBase.Cast(player);
12082 if (EActions.RECIPES_RANGE_START < 1000)
12083 {
12084 float anim_length = plugin_recipes_manager.GetRecipeLengthInSecs(idWithoutOffset);
12085 float specialty_weight = plugin_recipes_manager.GetRecipeSpecialty(idWithoutOffset);
12086 }
12087 }
12088 #ifndef SERVER
12089 else if (action_id == EActions.WATCH_PLAYER)
12090 {
12091 PluginDeveloper.SetDeveloperItemClientEx(player);
12092 }
12093 #endif
12094 if (GetGame().IsServer())
12095 {
12096 if (action_id >= EActions.DEBUG_ITEM_WATCH_BUTTON_RANGE_START && action_id < EActions.DEBUG_ITEM_WATCH_BUTTON_RANGE_END)
12097 {
12098 int id = action_id - EActions.DEBUG_ITEM_WATCH_BUTTON_RANGE_START;
12099 OnDebugButtonPressServer(id + 1);
12100 }
12101
12102 else if (action_id >= EActions.DEBUG_AGENTS_RANGE_INJECT_START && action_id < EActions.DEBUG_AGENTS_RANGE_INJECT_END)
12103 {
12104 int agent_id = action_id - EActions.DEBUG_AGENTS_RANGE_INJECT_START;
12105 InsertAgent(agent_id,100);
12106 }
12107
12108 else if (action_id >= EActions.DEBUG_AGENTS_RANGE_REMOVE_START && action_id < EActions.DEBUG_AGENTS_RANGE_REMOVE_END)
12109 {
12110 int agent_id2 = action_id - EActions.DEBUG_AGENTS_RANGE_REMOVE_START;
12111 RemoveAgent(agent_id2);
12112 }
12113
12114 else if (action_id == EActions.ADD_QUANTITY)
12115 {
12116 if (IsMagazine())
12117 {
12118 Magazine mag = Magazine.Cast(this);
12119 mag.ServerSetAmmoCount(mag.GetAmmoCount() + mag.GetAmmoMax() * 0.2);
12120 }
12121 else
12122 {
12123 AddQuantity(GetQuantityMax() * 0.2);
12124 }
12125
12126 if (m_EM)
12127 {
12128 m_EM.AddEnergy(m_EM.GetEnergyMax() * 0.2);
12129 }
12130 //PrintVariables();
12131 }
12132
12133 else if (action_id == EActions.REMOVE_QUANTITY) //Quantity -20%
12134 {
12135 if (IsMagazine())
12136 {
12137 Magazine mag2 = Magazine.Cast(this);
12138 mag2.ServerSetAmmoCount(mag2.GetAmmoCount() - mag2.GetAmmoMax() * 0.2);
12139 }
12140 else
12141 {
12142 AddQuantity(- GetQuantityMax() * 0.2);
12143 }
12144 if (m_EM)
12145 {
12146 m_EM.AddEnergy(- m_EM.GetEnergyMax() * 0.2);
12147 }
12148 //PrintVariables();
12149 }
12150
12151 else if (action_id == EActions.SET_QUANTITY_0) //SetMaxQuantity
12152 {
12153 SetQuantity(0);
12154
12155 if (m_EM)
12156 {
12157 m_EM.SetEnergy(0);
12158 }
12159 }
12160
12161 else if (action_id == EActions.SET_MAX_QUANTITY) //SetMaxQuantity
12162 {
12164
12165 if (m_EM)
12166 {
12167 m_EM.SetEnergy(m_EM.GetEnergyMax());
12168 }
12169 }
12170
12171 else if (action_id == EActions.ADD_HEALTH)
12172 {
12173 AddHealth("","",GetMaxHealth("","Health")/5);
12174 }
12175 else if (action_id == EActions.REMOVE_HEALTH)
12176 {
12177 AddHealth("","",-GetMaxHealth("","Health")/5);
12178 }
12179 else if (action_id == EActions.DESTROY_HEALTH)
12180 {
12181 SetHealth01("","",0);
12182 }
12183 else if (action_id == EActions.WATCH_ITEM)
12184 {
12186 mid.RegisterDebugItem(ItemBase.Cast(this), PlayerBase.Cast(player));
12187 #ifdef DEVELOPER
12188 SetDebugDeveloper_item(this);
12189 #endif
12190 }
12191
12192 else if (action_id == EActions.ADD_TEMPERATURE)
12193 {
12194 AddTemperature(20);
12195 //PrintVariables();
12196 }
12197
12198 else if (action_id == EActions.REMOVE_TEMPERATURE)
12199 {
12200 AddTemperature(-20);
12201 //PrintVariables();
12202 }
12203
12204 else if (action_id == EActions.FLIP_FROZEN)
12205 {
12206 SetFrozen(!GetIsFrozen());
12207 //PrintVariables();
12208 }
12209
12210 else if (action_id == EActions.ADD_WETNESS)
12211 {
12212 AddWet(GetWetMax()/5);
12213 //PrintVariables();
12214 }
12215
12216 else if (action_id == EActions.REMOVE_WETNESS)
12217 {
12218 AddWet(-GetWetMax()/5);
12219 //PrintVariables();
12220 }
12221
12222 else if (action_id == EActions.LIQUIDTYPE_UP)
12223 {
12224 int curr_type = GetLiquidType();
12225 SetLiquidType(curr_type * 2);
12226 //AddWet(1);
12227 //PrintVariables();
12228 }
12229
12230 else if (action_id == EActions.LIQUIDTYPE_DOWN)
12231 {
12232 int curr_type2 = GetLiquidType();
12233 SetLiquidType(curr_type2 / 2);
12234 }
12235
12236 else if (action_id == EActions.MAKE_SPECIAL)
12237 {
12238 auto debugParams = DebugSpawnParams.WithPlayer(player);
12239 OnDebugSpawnEx(debugParams);
12240 }
12241
12242 }
12243
12244
12245 return false;
12246 }
12247
12248 // -------------------------------------------------------------------------
12249
12250
12253 void OnActivatedByTripWire();
12254
12256 void OnActivatedByItem(notnull ItemBase item);
12257
12258 //----------------------------------------------------------------
12259 //returns true if item is able to explode when put in fire
12260 bool CanExplodeInFire()
12261 {
12262 return false;
12263 }
12264
12265 //----------------------------------------------------------------
12266 bool CanEat()
12267 {
12268 return true;
12269 }
12270
12271 //----------------------------------------------------------------
12272 override bool IsIgnoredByConstruction()
12273 {
12274 return true;
12275 }
12276
12277 //----------------------------------------------------------------
12278 //has FoodStages in config?
12279 bool HasFoodStage()
12280 {
12281 string config_path = string.Format("CfgVehicles %1 Food FoodStages", GetType());
12282 return GetGame().ConfigIsExisting(config_path);
12283 }
12284
12286 FoodStage GetFoodStage()
12287 {
12288 return null;
12289 }
12290
12291 bool CanBeCooked()
12292 {
12293 return false;
12294 }
12295
12296 bool CanBeCookedOnStick()
12297 {
12298 return false;
12299 }
12300
12302 void RefreshAudioVisualsOnClient( CookingMethodType cooking_method, bool is_done, bool is_empty, bool is_burned );
12304
12305 //----------------------------------------------------------------
12306 bool CanRepair(ItemBase item_repair_kit)
12307 {
12308 PluginRepairing module_repairing = PluginRepairing.Cast(GetPlugin(PluginRepairing));
12309 return module_repairing.CanRepair(this, item_repair_kit);
12310 }
12311
12312 //----------------------------------------------------------------
12313 bool Repair(PlayerBase player, ItemBase item_repair_kit, float specialty_weight)
12314 {
12315 PluginRepairing module_repairing = PluginRepairing.Cast(GetPlugin(PluginRepairing));
12316 return module_repairing.Repair(player, this, item_repair_kit, specialty_weight);
12317 }
12318
12319 //----------------------------------------------------------------
12320 int GetItemSize()
12321 {
12322 /*
12323 vector v_size = this.ConfigGetVector("itemSize");
12324 int v_size_x = v_size[0];
12325 int v_size_y = v_size[1];
12326 int size = v_size_x * v_size_y;
12327 return size;
12328 */
12329
12330 return 1;
12331 }
12332
12333 //----------------------------------------------------------------
12334 //Override for allowing seemingly unallowed moves when two clients send a conflicting message simultaneously
12335 bool CanBeMovedOverride()
12336 {
12337 return m_CanBeMovedOverride;
12338 }
12339
12340 //----------------------------------------------------------------
12341 //Override for allowing seemingly unallowed moves when two clients send a conflicting message simultaneously
12342 void SetCanBeMovedOverride(bool setting)
12343 {
12344 m_CanBeMovedOverride = setting;
12345 }
12346
12347 //----------------------------------------------------------------
12355 void MessageToOwnerStatus(string text)
12356 {
12357 PlayerBase player = PlayerBase.Cast(this.GetHierarchyRootPlayer());
12358
12359 if (player)
12360 {
12361 player.MessageStatus(text);
12362 }
12363 }
12364
12365 //----------------------------------------------------------------
12373 void MessageToOwnerAction(string text)
12374 {
12375 PlayerBase player = PlayerBase.Cast(this.GetHierarchyRootPlayer());
12376
12377 if (player)
12378 {
12379 player.MessageAction(text);
12380 }
12381 }
12382
12383 //----------------------------------------------------------------
12391 void MessageToOwnerFriendly(string text)
12392 {
12393 PlayerBase player = PlayerBase.Cast(this.GetHierarchyRootPlayer());
12394
12395 if (player)
12396 {
12397 player.MessageFriendly(text);
12398 }
12399 }
12400
12401 //----------------------------------------------------------------
12409 void MessageToOwnerImportant(string text)
12410 {
12411 PlayerBase player = PlayerBase.Cast(this.GetHierarchyRootPlayer());
12412
12413 if (player)
12414 {
12415 player.MessageImportant(text);
12416 }
12417 }
12418
12419 override bool IsItemBase()
12420 {
12421 return true;
12422 }
12423
12424 // Checks if item is of questioned kind
12425 override bool KindOf(string tag)
12426 {
12427 bool found = false;
12428 string item_name = this.GetType();
12429 ref TStringArray item_tag_array = new TStringArray;
12430 GetGame().ConfigGetTextArray("cfgVehicles " + item_name + " itemInfo", item_tag_array);
12431
12432 int array_size = item_tag_array.Count();
12433 for (int i = 0; i < array_size; i++)
12434 {
12435 if (item_tag_array.Get(i) == tag)
12436 {
12437 found = true;
12438 break;
12439 }
12440 }
12441 return found;
12442 }
12443
12444
12445 override void OnRPC(PlayerIdentity sender, int rpc_type,ParamsReadContext ctx)
12446 {
12447 //Debug.Log("OnRPC called");
12448 super.OnRPC(sender, rpc_type,ctx);
12449
12450 //Play soundset for attachment locking (ActionLockAttachment.c)
12451 switch (rpc_type)
12452 {
12453 #ifndef SERVER
12454 case ERPCs.RPC_SOUND_LOCK_ATTACH:
12455 Param2<bool, string> p = new Param2<bool, string>(false, "");
12456
12457 if (!ctx.Read(p))
12458 return;
12459
12460 bool play = p.param1;
12461 string soundSet = p.param2;
12462
12463 if (play)
12464 {
12465 if (m_LockingSound)
12466 {
12468 {
12469 m_LockingSound = SEffectManager.PlaySound(soundSet, GetPosition(), 0, 0, true);
12470 }
12471 }
12472 else
12473 {
12474 m_LockingSound = SEffectManager.PlaySound(soundSet, GetPosition(), 0, 0, true);
12475 }
12476 }
12477 else
12478 {
12479 SEffectManager.DestroyEffect(m_LockingSound);
12480 }
12481
12482 break;
12483 #endif
12484
12485 }
12486
12487 if (GetWrittenNoteData())
12488 {
12489 GetWrittenNoteData().OnRPC(sender, rpc_type,ctx);
12490 }
12491 }
12492
12493 //-----------------------------
12494 // VARIABLE MANIPULATION SYSTEM
12495 //-----------------------------
12496 int NameToID(string name)
12497 {
12498 PluginVariables plugin = PluginVariables.Cast(GetPlugin(PluginVariables));
12499 return plugin.GetID(name);
12500 }
12501
12502 string IDToName(int id)
12503 {
12504 PluginVariables plugin = PluginVariables.Cast(GetPlugin(PluginVariables));
12505 return plugin.GetName(id);
12506 }
12507
12509 void OnSyncVariables(ParamsReadContext ctx)//with ID optimization
12510 {
12511 //Debug.Log("OnSyncVariables called for item: "+ ToString(this.GetType()),"varSync");
12512 //read the flags
12513 int varFlags;
12514 if (!ctx.Read(varFlags))
12515 return;
12516
12517 if (varFlags & ItemVariableFlags.FLOAT)
12518 {
12519 ReadVarsFromCTX(ctx);
12520 }
12521 }
12522
12523 override void SerializeNumericalVars(array<float> floats_out)
12524 {
12525 //some variables handled on EntityAI level already!
12526 super.SerializeNumericalVars(floats_out);
12527
12528 // the order of serialization must be the same as the order of de-serialization
12529 //--------------------------------------------
12530 if (IsVariableSet(VARIABLE_QUANTITY))
12531 {
12532 floats_out.Insert(m_VarQuantity);
12533 }
12534 //--------------------------------------------
12535 if (IsVariableSet(VARIABLE_WET))
12536 {
12537 floats_out.Insert(m_VarWet);
12538 }
12539 //--------------------------------------------
12540 if (IsVariableSet(VARIABLE_LIQUIDTYPE))
12541 {
12542 floats_out.Insert(m_VarLiquidType);
12543 }
12544 //--------------------------------------------
12545 if (IsVariableSet(VARIABLE_COLOR))
12546 {
12547 floats_out.Insert(m_ColorComponentR);
12548 floats_out.Insert(m_ColorComponentG);
12549 floats_out.Insert(m_ColorComponentB);
12550 floats_out.Insert(m_ColorComponentA);
12551 }
12552 //--------------------------------------------
12553 if (IsVariableSet(VARIABLE_CLEANNESS))
12554 {
12555 floats_out.Insert(m_Cleanness);
12556 }
12557 }
12558
12559 override void DeSerializeNumericalVars(array<float> floats)
12560 {
12561 //some variables handled on EntityAI level already!
12562 super.DeSerializeNumericalVars(floats);
12563
12564 // the order of serialization must be the same as the order of de-serialization
12565 int index = 0;
12566 int mask = Math.Round(floats.Get(index));
12567
12568 index++;
12569 //--------------------------------------------
12570 if (mask & VARIABLE_QUANTITY)
12571 {
12572 if (m_IsStoreLoad)
12573 {
12574 SetStoreLoadedQuantity(floats.Get(index));
12575 }
12576 else
12577 {
12578 float quantity = floats.Get(index);
12579 SetQuantity(quantity, true, false, false, false);
12580 }
12581 index++;
12582 }
12583 //--------------------------------------------
12584 if (mask & VARIABLE_WET)
12585 {
12586 float wet = floats.Get(index);
12587 SetWet(wet);
12588 index++;
12589 }
12590 //--------------------------------------------
12591 if (mask & VARIABLE_LIQUIDTYPE)
12592 {
12593 int liquidtype = Math.Round(floats.Get(index));
12594 SetLiquidType(liquidtype);
12595 index++;
12596 }
12597 //--------------------------------------------
12598 if (mask & VARIABLE_COLOR)
12599 {
12600 m_ColorComponentR = Math.Round(floats.Get(index));
12601 index++;
12602 m_ColorComponentG = Math.Round(floats.Get(index));
12603 index++;
12604 m_ColorComponentB = Math.Round(floats.Get(index));
12605 index++;
12606 m_ColorComponentA = Math.Round(floats.Get(index));
12607 index++;
12608 }
12609 //--------------------------------------------
12610 if (mask & VARIABLE_CLEANNESS)
12611 {
12612 int cleanness = Math.Round(floats.Get(index));
12613 SetCleanness(cleanness);
12614 index++;
12615 }
12616 }
12617
12618 override void WriteVarsToCTX(ParamsWriteContext ctx)
12619 {
12620 super.WriteVarsToCTX(ctx);
12621
12622 //--------------------------------------------
12623 if (IsVariableSet(VARIABLE_QUANTITY))
12624 {
12625 ctx.Write(GetQuantity());
12626 }
12627 //--------------------------------------------
12628 if (IsVariableSet(VARIABLE_WET))
12629 {
12630 ctx.Write(GetWet());
12631 }
12632 //--------------------------------------------
12633 if (IsVariableSet(VARIABLE_LIQUIDTYPE))
12634 {
12635 ctx.Write(GetLiquidType());
12636 }
12637 //--------------------------------------------
12638 if (IsVariableSet(VARIABLE_COLOR))
12639 {
12640 int r,g,b,a;
12641 GetColor(r,g,b,a);
12642 ctx.Write(r);
12643 ctx.Write(g);
12644 ctx.Write(b);
12645 ctx.Write(a);
12646 }
12647 //--------------------------------------------
12648 if (IsVariableSet(VARIABLE_CLEANNESS))
12649 {
12650 ctx.Write(GetCleanness());
12651 }
12652 }
12653
12654 override bool ReadVarsFromCTX(ParamsReadContext ctx, int version = -1)//with ID optimization
12655 {
12656 if (!super.ReadVarsFromCTX(ctx,version))
12657 return false;
12658
12659 int intValue;
12660 float value;
12661
12662 if (version < 140)
12663 {
12664 if (!ctx.Read(intValue))
12665 return false;
12666
12667 m_VariablesMask = intValue;
12668 }
12669
12670 if (m_VariablesMask & VARIABLE_QUANTITY)
12671 {
12672 if (!ctx.Read(value))
12673 return false;
12674
12675 if (IsStoreLoad())
12676 {
12678 }
12679 else
12680 {
12681 SetQuantity(value, true, false, false, false);
12682 }
12683 }
12684 //--------------------------------------------
12685 if (version < 140)
12686 {
12687 if (m_VariablesMask & VARIABLE_TEMPERATURE)
12688 {
12689 if (!ctx.Read(value))
12690 return false;
12691 SetTemperatureDirect(value);
12692 }
12693 }
12694 //--------------------------------------------
12695 if (m_VariablesMask & VARIABLE_WET)
12696 {
12697 if (!ctx.Read(value))
12698 return false;
12699 SetWet(value);
12700 }
12701 //--------------------------------------------
12702 if (m_VariablesMask & VARIABLE_LIQUIDTYPE)
12703 {
12704 if (!ctx.Read(intValue))
12705 return false;
12706 SetLiquidType(intValue);
12707 }
12708 //--------------------------------------------
12709 if (m_VariablesMask & VARIABLE_COLOR)
12710 {
12711 int r,g,b,a;
12712 if (!ctx.Read(r))
12713 return false;
12714 if (!ctx.Read(g))
12715 return false;
12716 if (!ctx.Read(b))
12717 return false;
12718 if (!ctx.Read(a))
12719 return false;
12720
12721 SetColor(r,g,b,a);
12722 }
12723 //--------------------------------------------
12724 if (m_VariablesMask & VARIABLE_CLEANNESS)
12725 {
12726 if (!ctx.Read(intValue))
12727 return false;
12728 SetCleanness(intValue);
12729 }
12730 //--------------------------------------------
12731 if (version >= 138 && version < 140)
12732 {
12733 if (m_VariablesMask & VARIABLE_TEMPERATURE)
12734 {
12735 if (!ctx.Read(intValue))
12736 return false;
12737 SetFrozen(intValue);
12738 }
12739 }
12740
12741 return true;
12742 }
12743
12744 //----------------------------------------------------------------
12745 override bool OnStoreLoad(ParamsReadContext ctx, int version)
12746 {
12747 m_IsStoreLoad = true;
12749 {
12750 m_FixDamageSystemInit = true;
12751 }
12752
12753 if (!super.OnStoreLoad(ctx, version))
12754 {
12755 m_IsStoreLoad = false;
12756 return false;
12757 }
12758
12759 if (version >= 114)
12760 {
12761 bool hasQuickBarIndexSaved;
12762
12763 if (!ctx.Read(hasQuickBarIndexSaved))
12764 {
12765 m_IsStoreLoad = false;
12766 return false;
12767 }
12768
12769 if (hasQuickBarIndexSaved)
12770 {
12771 int itmQBIndex;
12772
12773 //Load quickbar item bind
12774 if (!ctx.Read(itmQBIndex))
12775 {
12776 m_IsStoreLoad = false;
12777 return false;
12778 }
12779
12780 PlayerBase parentPlayer = PlayerBase.Cast(GetHierarchyRootPlayer());
12781 if (itmQBIndex != -1 && parentPlayer)
12782 parentPlayer.SetLoadedQuickBarItemBind(this, itmQBIndex);
12783 }
12784 }
12785 else
12786 {
12787 // Backup of how it used to be
12788 PlayerBase player;
12789 int itemQBIndex;
12790 if (version == int.MAX)
12791 {
12792 if (!ctx.Read(itemQBIndex))
12793 {
12794 m_IsStoreLoad = false;
12795 return false;
12796 }
12797 }
12798 else if (Class.CastTo(player, GetHierarchyRootPlayer()))
12799 {
12800 //Load quickbar item bind
12801 if (!ctx.Read(itemQBIndex))
12802 {
12803 m_IsStoreLoad = false;
12804 return false;
12805 }
12806 if (itemQBIndex != -1 && player)
12807 player.SetLoadedQuickBarItemBind(this,itemQBIndex);
12808 }
12809 }
12810
12811 if (version < 140)
12812 {
12813 // variable management system
12814 if (!LoadVariables(ctx, version))
12815 {
12816 m_IsStoreLoad = false;
12817 return false;
12818 }
12819 }
12820
12821 //agent trasmission system
12822 if (!LoadAgents(ctx, version))
12823 {
12824 m_IsStoreLoad = false;
12825 return false;
12826 }
12827 if (version >= 132)
12828 {
12829 RemotelyActivatedItemBehaviour raib = GetRemotelyActivatedItemBehaviour();
12830 if (raib)
12831 {
12832 if (!raib.OnStoreLoad(ctx,version))
12833 {
12834 m_IsStoreLoad = false;
12835 return false;
12836 }
12837 }
12838 }
12839
12840 m_IsStoreLoad = false;
12841 return true;
12842 }
12843
12844 //----------------------------------------------------------------
12845
12846 override void OnStoreSave(ParamsWriteContext ctx)
12847 {
12848 super.OnStoreSave(ctx);
12849
12850 PlayerBase player;
12851 if (PlayerBase.CastTo(player,GetHierarchyRootPlayer()))
12852 {
12853 ctx.Write(true); // Keep track of if we should actually read this in or not
12854 //Save quickbar item bind
12855 int itemQBIndex = -1;
12856 itemQBIndex = player.FindQuickBarEntityIndex(this);
12857 ctx.Write(itemQBIndex);
12858 }
12859 else
12860 {
12861 ctx.Write(false); // Keep track of if we should actually read this in or not
12862 }
12863
12864 SaveAgents(ctx);//agent trasmission system
12865
12866 RemotelyActivatedItemBehaviour raib = GetRemotelyActivatedItemBehaviour();
12867 if (raib)
12868 {
12869 raib.OnStoreSave(ctx);
12870 }
12871 }
12872 //----------------------------------------------------------------
12873
12874 override void AfterStoreLoad()
12875 {
12876 super.AfterStoreLoad();
12877
12879 {
12881 }
12882
12883 if (GetStoreLoadedQuantity() != float.LOWEST)
12884 {
12886 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
12887 }
12888 }
12889
12890 override void EEOnAfterLoad()
12891 {
12892 super.EEOnAfterLoad();
12893
12895 {
12896 m_FixDamageSystemInit = false;
12897 }
12898
12901 }
12902
12903 bool CanBeDisinfected()
12904 {
12905 return false;
12906 }
12907
12908
12909 //----------------------------------------------------------------
12910 override void OnVariablesSynchronized()
12911 {
12912 if (m_Initialized)
12913 {
12914 #ifdef PLATFORM_CONSOLE
12915 //bruteforce it is
12916 if (IsSplitable())
12917 {
12918 UIScriptedMenu menu = GetGame().GetUIManager().FindMenu(MENU_INVENTORY);
12919 if (menu)
12920 {
12921 menu.Refresh();
12922 }
12923 }
12924 #endif
12925 }
12926
12928 {
12929 PlayImpactSound(m_ConfigWeight, m_ImpactSpeed, m_ImpactSoundSurfaceHash);
12930 m_WantPlayImpactSound = false;
12931 }
12932
12934 {
12935 SetWeightDirty();
12937 }
12938 if (m_VarWet != m_VarWetPrev)
12939 {
12942 }
12943
12944 if (m_SoundSyncPlay != 0)
12945 {
12946 m_ItemSoundHandler.PlayItemSoundClient(m_SoundSyncPlay);
12947 m_SoundSyncPlay = 0;
12948 }
12949 if (m_SoundSyncStop != 0)
12950 {
12951 m_ItemSoundHandler.StopItemSoundClient(m_SoundSyncStop);
12952 m_SoundSyncStop = 0;
12953 }
12954
12955 super.OnVariablesSynchronized();
12956 }
12957
12958 //------------------------- Quantity
12959 //----------------------------------------------------------------
12961 override bool SetQuantity(float value, bool destroy_config = true, bool destroy_forced = false, bool allow_client = false, bool clamp_to_stack_max = true)
12962 {
12963 if (!IsServerCheck(allow_client))
12964 return false;
12965
12966 if (!HasQuantity())
12967 return false;
12968
12969 float min = GetQuantityMin();
12970 float max = GetQuantityMax();
12971
12972 if (value <= (min + 0.001))
12973 value = min;
12974
12975 if (value == min)
12976 {
12977 if (destroy_config)
12978 {
12979 bool dstr = ConfigGetBool("varQuantityDestroyOnMin");
12980 if (dstr)
12981 {
12982 m_VarQuantity = Math.Clamp(value, min, max);
12983 this.Delete();
12984 return true;
12985 }
12986 }
12987 else if (destroy_forced)
12988 {
12989 m_VarQuantity = Math.Clamp(value, min, max);
12990 this.Delete();
12991 return true;
12992 }
12993 // we get here if destroy_config IS true AND dstr(config destroy param) IS false;
12994 RemoveAllAgents();//we remove all agents when we got to the min value, but the item is not getting deleted
12995 }
12996
12997 float delta = m_VarQuantity;
12998 m_VarQuantity = Math.Clamp(value, min, max);
12999
13000 if (GetStoreLoadedQuantity() == float.LOWEST)//any other value means we are setting quantity from storage
13001 {
13002 delta = m_VarQuantity - delta;
13003
13004 if (delta)
13005 OnQuantityChanged(delta);
13006 }
13007
13008 SetVariableMask(VARIABLE_QUANTITY);
13009
13010 return false;
13011 }
13012
13013 //----------------------------------------------------------------
13015 bool AddQuantity(float value, bool destroy_config = true, bool destroy_forced = false)
13016 {
13017 return SetQuantity(GetQuantity() + value, destroy_config, destroy_forced);
13018 }
13019 //----------------------------------------------------------------
13020 void SetQuantityMax()
13021 {
13022 float max = GetQuantityMax();
13023 SetQuantity(max);
13024 }
13025
13026 override void SetQuantityToMinimum()
13027 {
13028 float min = GetQuantityMin();
13029 SetQuantity(min);
13030 }
13031 //----------------------------------------------------------------
13033 override void SetQuantityNormalized(float value, bool destroy_config = true, bool destroy_forced = false)
13034 {
13035 float value_clamped = Math.Clamp(value, 0, 1);//just to make sure
13036 int result = Math.Round(Math.Lerp(GetQuantityMin(), GetQuantityMax(), value_clamped));
13037 SetQuantity(result, destroy_config, destroy_forced);
13038 }
13039
13040 //----------------------------------------------------------------
13042 override float GetQuantityNormalized()
13043 {
13044 return Math.InverseLerp(GetQuantityMin(), GetQuantityMax(),m_VarQuantity);
13045 }
13046
13048 {
13049 return GetQuantityNormalized();
13050 }
13051
13052 /*void SetAmmoNormalized(float value)
13053 {
13054 float value_clamped = Math.Clamp(value, 0, 1);
13055 Magazine this_mag = Magazine.Cast(this);
13056 int max_rounds = this_mag.GetAmmoMax();
13057 int result = value * max_rounds;//can the rounded if higher precision is required
13058 this_mag.SetAmmoCount(result);
13059 }*/
13060 //----------------------------------------------------------------
13061 override int GetQuantityMax()
13062 {
13063 int slot = -1;
13064 if (GetInventory())
13065 {
13066 InventoryLocation il = new InventoryLocation;
13067 GetInventory().GetCurrentInventoryLocation(il);
13068 slot = il.GetSlot();
13069 }
13070
13071 return GetTargetQuantityMax(slot);
13072 }
13073
13074 override int GetTargetQuantityMax(int attSlotID = -1)
13075 {
13076 float quantity_max = 0;
13077
13078 if (IsSplitable()) //only stackable/splitable items can check for stack size
13079 {
13080 if (attSlotID != -1)
13081 quantity_max = InventorySlots.GetStackMaxForSlotId(attSlotID);
13082
13083 if (quantity_max <= 0)
13084 quantity_max = m_VarStackMax;
13085 }
13086
13087 if (quantity_max <= 0)
13088 quantity_max = m_VarQuantityMax;
13089
13090 return quantity_max;
13091 }
13092 //----------------------------------------------------------------
13093 override int GetQuantityMin()
13094 {
13095 return m_VarQuantityMin;
13096 }
13097 //----------------------------------------------------------------
13098 int GetQuantityInit()
13099 {
13100 return m_VarQuantityInit;
13101 }
13102
13103 //----------------------------------------------------------------
13104 override bool HasQuantity()
13105 {
13106 return !(GetQuantityMax() - GetQuantityMin() == 0);
13107 }
13108
13109 override float GetQuantity()
13110 {
13111 return m_VarQuantity;
13112 }
13113
13114 bool IsFullQuantity()
13115 {
13116 return GetQuantity() >= GetQuantityMax();
13117 }
13118
13119 //Calculates weight of single item without attachments and cargo
13120 override float GetSingleInventoryItemWeightEx()
13121 {
13122 //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
13123 float weightEx = GetWeightEx();//overall weight of the item
13124 float special = GetInventoryAndCargoWeight();//cargo and attachment weight
13125 return weightEx - special;
13126 }
13127
13128 // Obsolete, use GetSingleInventoryItemWeightEx() instead
13130 {
13132 }
13133
13134 override protected float GetWeightSpecialized(bool forceRecalc = false)
13135 {
13136 if (IsSplitable()) //quantity determines size of the stack
13137 {
13138 #ifdef DEVELOPER
13139 if (WeightDebug.m_VerbosityFlags & WeightDebugType.RECALC_FORCED)
13140 {
13141 WeightDebugData data1 = WeightDebug.GetWeightDebug(this);
13142 data1.SetCalcDetails("TIB1: " + GetConfigWeightModifiedDebugText() +" * " + GetQuantity()+"(quantity)");
13143 }
13144 #endif
13145
13146 return GetQuantity() * GetConfigWeightModified();
13147 }
13148 else if (HasEnergyManager())// items with energy manager
13149 {
13150 #ifdef DEVELOPER
13151 if (WeightDebug.m_VerbosityFlags & WeightDebugType.RECALC_FORCED)
13152 {
13153 WeightDebugData data2 = WeightDebug.GetWeightDebug(this);
13154 data2.SetCalcDetails("TIB2: "+super.GetWeightSpecialized(forceRecalc)+"(contents weight) + " + GetConfigWeightModifiedDebugText() +" + " + GetCompEM().GetEnergy()+"(energy) * " + ConfigGetFloat("weightPerQuantityUnit") +"(weightPerQuantityUnit)");
13155 }
13156 #endif
13157 return super.GetWeightSpecialized(forceRecalc) + (GetCompEM().GetEnergy() * ConfigGetFloat("weightPerQuantityUnit")) + GetConfigWeightModified();
13158 }
13159 else//everything else
13160 {
13161 #ifdef DEVELOPER
13162 if (WeightDebug.m_VerbosityFlags & WeightDebugType.RECALC_FORCED)
13163 {
13164 WeightDebugData data3 = WeightDebug.GetWeightDebug(this);
13165 data3.SetCalcDetails("TIB3: "+super.GetWeightSpecialized(forceRecalc)+"(contents weight) + " + GetConfigWeightModifiedDebugText() +" + " + GetQuantity()+"(quantity) * " + ConfigGetFloat("weightPerQuantityUnit") +"(weightPerQuantityUnit))");
13166 }
13167 #endif
13168 return super.GetWeightSpecialized(forceRecalc) + (GetQuantity() * ConfigGetFloat("weightPerQuantityUnit")) + GetConfigWeightModified();
13169 }
13170 }
13171
13173 int GetNumberOfItems()
13174 {
13175 int item_count = 0;
13176 ItemBase item;
13177
13178 if (GetInventory().GetCargo() != NULL)
13179 {
13180 item_count = GetInventory().GetCargo().GetItemCount();
13181 }
13182
13183 for (int i = 0; i < GetInventory().AttachmentCount(); i++)
13184 {
13185 Class.CastTo(item,GetInventory().GetAttachmentFromIndex(i));
13186 if (item)
13187 item_count += item.GetNumberOfItems();
13188 }
13189 return item_count;
13190 }
13191
13193 float GetUnitWeight(bool include_wetness = true)
13194 {
13195 float weight = 0;
13196 float wetness = 1;
13197 if (include_wetness)
13198 wetness += GetWet();
13199 if (IsSplitable()) //quantity determines size of the stack
13200 {
13201 weight = wetness * m_ConfigWeight;
13202 }
13203 else if (IsLiquidContainer()) //is a liquid container, default liquid weight is set to 1. May revisit later?
13204 {
13205 weight = 1;
13206 }
13207 return weight;
13208 }
13209
13210 //-----------------------------------------------------------------
13211
13212 override void ClearInventory()
13213 {
13214 if ((GetGame().IsServer() || !GetGame().IsMultiplayer()) && GetInventory())
13215 {
13216 GameInventory inv = GetInventory();
13217 array<EntityAI> items = new array<EntityAI>;
13218 inv.EnumerateInventory(InventoryTraversalType.INORDER, items);
13219 for (int i = 0; i < items.Count(); i++)
13220 {
13221 ItemBase item = ItemBase.Cast(items.Get(i));
13222 if (item)
13223 {
13224 GetGame().ObjectDelete(item);
13225 }
13226 }
13227 }
13228 }
13229
13230 //------------------------- Energy
13231
13232 //----------------------------------------------------------------
13233 float GetEnergy()
13234 {
13235 float energy = 0;
13236 if (HasEnergyManager())
13237 {
13238 energy = GetCompEM().GetEnergy();
13239 }
13240 return energy;
13241 }
13242
13243
13244 override void OnEnergyConsumed()
13245 {
13246 super.OnEnergyConsumed();
13247
13249 }
13250
13251 override void OnEnergyAdded()
13252 {
13253 super.OnEnergyAdded();
13254
13256 }
13257
13258 // Converts energy (from Energy Manager) to quantity, if enabled.
13260 {
13261 if (GetGame().IsServer() && HasEnergyManager() && GetCompEM().HasConversionOfEnergyToQuantity())
13262 {
13263 if (HasQuantity())
13264 {
13265 float energy_0to1 = GetCompEM().GetEnergy0To1();
13266 SetQuantityNormalized(energy_0to1);
13267 }
13268 }
13269 }
13270
13271 //----------------------------------------------------------------
13272 float GetHeatIsolationInit()
13273 {
13274 return ConfigGetFloat("heatIsolation");
13275 }
13276
13277 float GetHeatIsolation()
13278 {
13279 return m_HeatIsolation;
13280 }
13281
13282 float GetDryingIncrement(string pIncrementName)
13283 {
13284 string paramPath = string.Format("CfgVehicles %1 EnvironmentWetnessIncrements Drying %2", GetType(), pIncrementName);
13285 if (GetGame().ConfigIsExisting(paramPath))
13286 return GetGame().ConfigGetFloat(paramPath);
13287
13288 return 0.0;
13289 }
13290
13291 float GetSoakingIncrement(string pIncrementName)
13292 {
13293 string paramPath = string.Format("CfgVehicles %1 EnvironmentWetnessIncrements Soaking %2", GetType(), pIncrementName);
13294 if (GetGame().ConfigIsExisting(paramPath))
13295 return GetGame().ConfigGetFloat(paramPath);
13296
13297 return 0.0;
13298 }
13299 //----------------------------------------------------------------
13300 override void SetWet(float value, bool allow_client = false)
13301 {
13302 if (!IsServerCheck(allow_client))
13303 return;
13304
13305 float min = GetWetMin();
13306 float max = GetWetMax();
13307
13308 float previousValue = m_VarWet;
13309
13310 m_VarWet = Math.Clamp(value, min, max);
13311
13312 if (previousValue != m_VarWet)
13313 {
13314 SetVariableMask(VARIABLE_WET);
13315 OnWetChanged(m_VarWet, previousValue);
13316 }
13317 }
13318 //----------------------------------------------------------------
13319 override void AddWet(float value)
13320 {
13321 SetWet(GetWet() + value);
13322 }
13323 //----------------------------------------------------------------
13324 override void SetWetMax()
13325 {
13327 }
13328 //----------------------------------------------------------------
13329 override float GetWet()
13330 {
13331 return m_VarWet;
13332 }
13333 //----------------------------------------------------------------
13334 override float GetWetMax()
13335 {
13336 return m_VarWetMax;
13337 }
13338 //----------------------------------------------------------------
13339 override float GetWetMin()
13340 {
13341 return m_VarWetMin;
13342 }
13343 //----------------------------------------------------------------
13344 override float GetWetInit()
13345 {
13346 return m_VarWetInit;
13347 }
13348 //----------------------------------------------------------------
13349 override void OnWetChanged(float newVal, float oldVal)
13350 {
13351 EWetnessLevel newLevel = GetWetLevelInternal(newVal);
13352 EWetnessLevel oldLevel = GetWetLevelInternal(oldVal);
13353 if (newLevel != oldLevel)
13354 {
13355 OnWetLevelChanged(newLevel,oldLevel);
13356 }
13357 }
13358
13359 override void OnWetLevelChanged(EWetnessLevel newLevel, EWetnessLevel oldLevel)
13360 {
13361 SetWeightDirty();
13362 }
13363
13364 override EWetnessLevel GetWetLevel()
13365 {
13366 return GetWetLevelInternal(m_VarWet);
13367 }
13368
13369 //----------------------------------------------------------------
13370
13371 override void SetStoreLoad(bool value)
13372 {
13373 m_IsStoreLoad = value;
13374 }
13375
13376 override bool IsStoreLoad()
13377 {
13378 return m_IsStoreLoad;
13379 }
13380
13381 override void SetStoreLoadedQuantity(float value)
13382 {
13383 m_StoreLoadedQuantity = value;
13384 }
13385
13386 override float GetStoreLoadedQuantity()
13387 {
13388 return m_StoreLoadedQuantity;
13389 }
13390
13391 //----------------------------------------------------------------
13392
13393 float GetItemModelLength()
13394 {
13395 if (ConfigIsExisting("itemModelLength"))
13396 {
13397 return ConfigGetFloat("itemModelLength");
13398 }
13399 return 0;
13400 }
13401
13402 float GetItemAttachOffset()
13403 {
13404 if (ConfigIsExisting("itemAttachOffset"))
13405 {
13406 return ConfigGetFloat("itemAttachOffset");
13407 }
13408 return 0;
13409 }
13410
13411 override void SetCleanness(int value, bool allow_client = false)
13412 {
13413 if (!IsServerCheck(allow_client))
13414 return;
13415
13416 int previousValue = m_Cleanness;
13417
13418 m_Cleanness = Math.Clamp(value, m_CleannessMin, m_CleannessMax);
13419
13420 if (previousValue != m_Cleanness)
13421 SetVariableMask(VARIABLE_CLEANNESS);
13422 }
13423
13424 override int GetCleanness()
13425 {
13426 return m_Cleanness;
13427 }
13428
13430 {
13431 return true;
13432 }
13433
13434 //----------------------------------------------------------------
13435 // ATTACHMENT LOCKING
13436 // Getters relevant to generic ActionLockAttachment
13437 int GetLockType()
13438 {
13439 return m_LockType;
13440 }
13441
13442 string GetLockSoundSet()
13443 {
13444 return m_LockSoundSet;
13445 }
13446
13447 //----------------------------------------------------------------
13448 //------------------------- Color
13449 // sets items color variable given color components
13450 override void SetColor(int r, int g, int b, int a)
13451 {
13456 SetVariableMask(VARIABLE_COLOR);
13457 }
13459 override void GetColor(out int r,out int g,out int b,out int a)
13460 {
13465 }
13466
13467 bool IsColorSet()
13468 {
13469 return IsVariableSet(VARIABLE_COLOR);
13470 }
13471
13473 string GetColorString()
13474 {
13475 int r,g,b,a;
13476 GetColor(r,g,b,a);
13477 r = r/255;
13478 g = g/255;
13479 b = b/255;
13480 a = a/255;
13481 return MiscGameplayFunctions.GetColorString(r, g, b, a);
13482 }
13483 //----------------------------------------------------------------
13484 //------------------------- LiquidType
13485
13486 override void SetLiquidType(int value, bool allow_client = false)
13487 {
13488 if (!IsServerCheck(allow_client))
13489 return;
13490
13491 int old = m_VarLiquidType;
13492 m_VarLiquidType = value;
13493 OnLiquidTypeChanged(old,value);
13494 SetVariableMask(VARIABLE_LIQUIDTYPE);
13495 }
13496
13497 int GetLiquidTypeInit()
13498 {
13499 return ConfigGetInt("varLiquidTypeInit");
13500 }
13501
13502 override int GetLiquidType()
13503 {
13504 return m_VarLiquidType;
13505 }
13506
13507 protected void OnLiquidTypeChanged(int oldType, int newType)
13508 {
13509 if (newType == LIQUID_NONE && GetIsFrozen())
13510 SetFrozen(false);
13511 }
13512
13514 void UpdateQuickbarShortcutVisibility(PlayerBase player)
13515 {
13516 player.SetEnableQuickBarEntityShortcut(this,!GetHierarchyParent() || GetHierarchyParent().GetInventory().AreChildrenAccessible());
13517 }
13518
13519 // -------------------------------------------------------------------------
13521 void OnInventoryEnter(Man player)
13522 {
13523 PlayerBase nplayer;
13524 if (PlayerBase.CastTo(nplayer, player))
13525 {
13526 m_CanPlayImpactSound = true;
13527 //nplayer.OnItemInventoryEnter(this);
13528 nplayer.SetEnableQuickBarEntityShortcut(this,!GetHierarchyParent() || GetHierarchyParent().GetInventory().AreChildrenAccessible());
13529 }
13530 }
13531
13532 // -------------------------------------------------------------------------
13534 void OnInventoryExit(Man player)
13535 {
13536 PlayerBase nplayer;
13537 if (PlayerBase.CastTo(nplayer,player))
13538 {
13539 //nplayer.OnItemInventoryExit(this);
13540 nplayer.SetEnableQuickBarEntityShortcut(this,false);
13541
13542 }
13543
13544 //if (!GetGame().IsDedicatedServer())
13545 player.GetHumanInventory().ClearUserReservedLocationForContainer(this);
13546
13547
13548 if (HasEnergyManager())
13549 {
13550 GetCompEM().UpdatePlugState(); // Unplug the el. device if it's necesarry.
13551 }
13552 }
13553
13554 // ADVANCED PLACEMENT EVENTS
13555 override void OnPlacementStarted(Man player)
13556 {
13557 super.OnPlacementStarted(player);
13558
13559 SetTakeable(false);
13560 }
13561
13562 override void OnPlacementComplete(Man player, vector position = "0 0 0", vector orientation = "0 0 0")
13563 {
13564 if (m_AdminLog)
13565 {
13566 m_AdminLog.OnPlacementComplete(player, this);
13567 }
13568
13569 super.OnPlacementComplete(player, position, orientation);
13570 }
13571
13572 //-----------------------------
13573 // AGENT SYSTEM
13574 //-----------------------------
13575 //--------------------------------------------------------------------------
13576 bool ContainsAgent(int agent_id)
13577 {
13578 if (agent_id & m_AttachedAgents)
13579 {
13580 return true;
13581 }
13582 else
13583 {
13584 return false;
13585 }
13586 }
13587
13588 //--------------------------------------------------------------------------
13589 override void RemoveAgent(int agent_id)
13590 {
13591 if (ContainsAgent(agent_id))
13592 {
13593 m_AttachedAgents = ~agent_id & m_AttachedAgents;
13594 }
13595 }
13596
13597 //--------------------------------------------------------------------------
13598 override void RemoveAllAgents()
13599 {
13600 m_AttachedAgents = 0;
13601 }
13602 //--------------------------------------------------------------------------
13603 override void RemoveAllAgentsExcept(int agent_to_keep)
13604 {
13605 m_AttachedAgents = m_AttachedAgents & agent_to_keep;
13606 }
13607 // -------------------------------------------------------------------------
13608 override void InsertAgent(int agent, float count = 1)
13609 {
13610 if (count < 1)
13611 return;
13612 //Debug.Log("Inserting Agent on item: " + agent.ToString() +" count: " + count.ToString());
13614 }
13615
13617 void TransferAgents(int agents)
13618 {
13620 }
13621
13622 // -------------------------------------------------------------------------
13623 override int GetAgents()
13624 {
13625 return m_AttachedAgents;
13626 }
13627 //----------------------------------------------------------------------
13628
13629 /*int GetContaminationType()
13630 {
13631 int contamination_type;
13632
13633 const int CONTAMINATED_MASK = eAgents.CHOLERA | eAgents.INFLUENZA | eAgents.SALMONELLA | eAgents.BRAIN;
13634 const int POISONED_MASK = eAgents.FOOD_POISON | eAgents.CHEMICAL_POISON;
13635 const int NERVE_GAS_MASK = eAgents.CHEMICAL_POISON;
13636 const int DIRTY_MASK = eAgents.WOUND_AGENT;
13637
13638 Edible_Base edible = Edible_Base.Cast(this);
13639 int agents = GetAgents();
13640 if (edible)
13641 {
13642 NutritionalProfile profile = Edible_Base.GetNutritionalProfile(edible);
13643 if (profile)
13644 {
13645 agents = agents | profile.GetAgents();//merge item's agents with nutritional agents
13646 }
13647 }
13648 if (agents & CONTAMINATED_MASK)
13649 {
13650 contamination_type = contamination_type | EContaminationTypes.ITEM_BADGE_CONTAMINATED;
13651 }
13652 if (agents & POISONED_MASK)
13653 {
13654 contamination_type = contamination_type | EContaminationTypes.ITEM_BADGE_POISONED;
13655 }
13656 if (agents & NERVE_GAS_MASK)
13657 {
13658 contamination_type = contamination_type | EContaminationTypes.ITEM_BADGE_NERVE_GAS;
13659 }
13660 if (agents & DIRTY_MASK)
13661 {
13662 contamination_type = contamination_type | EContaminationTypes.ITEM_BADGE_DIRTY;
13663 }
13664
13665 return agents;
13666 }*/
13667
13668 // -------------------------------------------------------------------------
13669 bool LoadAgents(ParamsReadContext ctx, int version)
13670 {
13671 if (!ctx.Read(m_AttachedAgents))
13672 return false;
13673 return true;
13674 }
13675 // -------------------------------------------------------------------------
13677 {
13678
13680 }
13681 // -------------------------------------------------------------------------
13682
13684 override void CheckForRoofLimited(float timeTresholdMS = 3000)
13685 {
13686 super.CheckForRoofLimited(timeTresholdMS);
13687
13688 float time = GetGame().GetTime();
13689 if ((time - m_PreviousRoofTestTime) >= timeTresholdMS)
13690 {
13691 m_PreviousRoofTestTime = time;
13692 SetRoofAbove(MiscGameplayFunctions.IsUnderRoof(this));
13693 }
13694 }
13695
13696 // returns item's protection level against enviromental hazard, for masks with filters, returns the filters protection for valid filter, otherwise 0
13697 float GetProtectionLevel(int type, bool consider_filter = false, int system = 0)
13698 {
13699 if (IsDamageDestroyed() || (HasQuantity() && GetQuantity() <= 0))
13700 {
13701 return 0;
13702 }
13703
13704 if (GetInventory().GetAttachmentSlotsCount() != 0)//is it an item with attachable filter ?
13705 {
13706 ItemBase filter = ItemBase.Cast(FindAttachmentBySlotName("GasMaskFilter"));
13707 if (filter)
13708 return filter.GetProtectionLevel(type, false, system);//it's a valid filter, return the protection
13709 else
13710 return 0;//otherwise return 0 when no filter attached
13711 }
13712
13713 string subclassPath, entryName;
13714
13715 switch (type)
13716 {
13717 case DEF_BIOLOGICAL:
13718 entryName = "biological";
13719 break;
13720 case DEF_CHEMICAL:
13721 entryName = "chemical";
13722 break;
13723 default:
13724 entryName = "biological";
13725 break;
13726 }
13727
13728 subclassPath = "CfgVehicles " + this.GetType() + " Protection ";
13729
13730 return GetGame().ConfigGetFloat(subclassPath + entryName);
13731 }
13732
13733
13734
13736 override void EEOnCECreate()
13737 {
13738 if (!IsMagazine())
13740
13742 }
13743
13744
13745 //-------------------------
13746 // OPEN/CLOSE USER ACTIONS
13747 //-------------------------
13749 void Open();
13750 void Close();
13751 bool IsOpen()
13752 {
13753 return true;
13754 }
13755
13756 override bool CanDisplayCargo()
13757 {
13758 return IsOpen();
13759 }
13760
13761
13762 // ------------------------------------------------------------
13763 // CONDITIONS
13764 // ------------------------------------------------------------
13765 override bool CanPutInCargo(EntityAI parent)
13766 {
13767 if (parent)
13768 {
13769 if (parent.IsInherited(DayZInfected))
13770 return true;
13771
13772 if (!parent.IsRuined())
13773 return true;
13774 }
13775
13776 return true;
13777 }
13778
13779 override bool CanPutAsAttachment(EntityAI parent)
13780 {
13781 if (!super.CanPutAsAttachment(parent))
13782 {
13783 return false;
13784 }
13785
13786 if (!IsRuined() && !parent.IsRuined())
13787 {
13788 return true;
13789 }
13790
13791 return false;
13792 }
13793
13794 override bool CanReceiveItemIntoCargo(EntityAI item)
13795 {
13796 //removed 15.06. coz of loading from storage -> after load items in cargo was lost -> waiting for proper solution
13797 //if (GetHealthLevel() == GameConstants.STATE_RUINED)
13798 // return false;
13799
13800 return super.CanReceiveItemIntoCargo(item);
13801 }
13802
13803 override bool CanReceiveAttachment(EntityAI attachment, int slotId)
13804 {
13805 //removed 15.06. coz of loading from storage -> after load items in cargo was lost -> waiting for proper solution
13806 //if (GetHealthLevel() == GameConstants.STATE_RUINED)
13807 // return false;
13808
13809 GameInventory attachmentInv = attachment.GetInventory();
13810 if (attachmentInv && attachmentInv.GetCargo() && attachmentInv.GetCargo().GetItemCount() > 0)
13811 {
13812 if (GetHierarchyParent() && !GetHierarchyParent().IsInherited(PlayerBase))
13813 return false;
13814 }
13815
13816 InventoryLocation loc = new InventoryLocation();
13817 attachment.GetInventory().GetCurrentInventoryLocation(loc);
13818 if (loc && loc.IsValid() && !GetInventory().AreChildrenAccessible())
13819 return false;
13820
13821 return super.CanReceiveAttachment(attachment, slotId);
13822 }
13823
13824 override bool CanReleaseAttachment(EntityAI attachment)
13825 {
13826 if (!super.CanReleaseAttachment(attachment))
13827 return false;
13828
13829 return GetInventory().AreChildrenAccessible();
13830 }
13831
13832 /*override bool CanLoadAttachment(EntityAI attachment)
13833 {
13834 //removed 15.06. coz of loading from storage -> after load items in cargo was lost -> waiting for proper solution
13835 //if (GetHealthLevel() == GameConstants.STATE_RUINED)
13836 // return false;
13837
13838 GameInventory attachmentInv = attachment.GetInventory();
13839 if (attachmentInv && attachmentInv.GetCargo() && attachmentInv.GetCargo().GetItemCount() > 0)
13840 {
13841 bool boo = (GetHierarchyParent() && !GetHierarchyParent().IsInherited(PlayerBase));
13842 ErrorEx("CanLoadAttachment | this: " + this + " | attachment: " + attachment + " | boo: " + boo,ErrorExSeverity.INFO);
13843
13844 if (GetHierarchyParent() && !GetHierarchyParent().IsInherited(PlayerBase))
13845 return false;
13846 }
13847
13848 return super.CanLoadAttachment(attachment);
13849 }*/
13850
13851 // Plays muzzle flash particle effects
13852 static void PlayFireParticles(ItemBase weapon, int muzzle_index, string ammoType, ItemBase muzzle_owner, ItemBase suppressor, string config_to_search)
13853 {
13854 int id = muzzle_owner.GetMuzzleID();
13855 array<ref WeaponParticlesOnFire> WPOF_array = m_OnFireEffect.Get(id);
13856
13857 if (WPOF_array)
13858 {
13859 for (int i = 0; i < WPOF_array.Count(); i++)
13860 {
13861 WeaponParticlesOnFire WPOF = WPOF_array.Get(i);
13862
13863 if (WPOF)
13864 {
13865 WPOF.OnActivate(weapon, muzzle_index, ammoType, muzzle_owner, suppressor, config_to_search);
13866 }
13867 }
13868 }
13869 }
13870
13871 // Plays bullet eject particle effects (usually just smoke, the bullet itself is a 3D model and is not part of this function)
13872 static void PlayBulletCasingEjectParticles(ItemBase weapon, string ammoType, ItemBase muzzle_owner, ItemBase suppressor, string config_to_search)
13873 {
13874 int id = muzzle_owner.GetMuzzleID();
13875 array<ref WeaponParticlesOnBulletCasingEject> WPOBE_array = m_OnBulletCasingEjectEffect.Get(id);
13876
13877 if (WPOBE_array)
13878 {
13879 for (int i = 0; i < WPOBE_array.Count(); i++)
13880 {
13881 WeaponParticlesOnBulletCasingEject WPOBE = WPOBE_array.Get(i);
13882
13883 if (WPOBE)
13884 {
13885 WPOBE.OnActivate(weapon, 0, ammoType, muzzle_owner, suppressor, config_to_search);
13886 }
13887 }
13888 }
13889 }
13890
13891 // Plays all weapon overheating particles
13892 static void PlayOverheatingParticles(ItemBase weapon, string ammoType, ItemBase muzzle_owner, ItemBase suppressor, string config_to_search)
13893 {
13894 int id = muzzle_owner.GetMuzzleID();
13895 array<ref WeaponParticlesOnOverheating> WPOOH_array = weapon.m_OnOverheatingEffect.Get(id);
13896
13897 if (WPOOH_array)
13898 {
13899 for (int i = 0; i < WPOOH_array.Count(); i++)
13900 {
13901 WeaponParticlesOnOverheating WPOOH = WPOOH_array.Get(i);
13902
13903 if (WPOOH)
13904 {
13905 WPOOH.OnActivate(weapon, 0, ammoType, muzzle_owner, suppressor, config_to_search);
13906 }
13907 }
13908 }
13909 }
13910
13911 // Updates all weapon overheating particles
13912 static void UpdateOverheatingParticles(ItemBase weapon, string ammoType, ItemBase muzzle_owner, ItemBase suppressor, string config_to_search)
13913 {
13914 int id = muzzle_owner.GetMuzzleID();
13915 array<ref WeaponParticlesOnOverheating> WPOOH_array = weapon.m_OnOverheatingEffect.Get(id);
13916
13917 if (WPOOH_array)
13918 {
13919 for (int i = 0; i < WPOOH_array.Count(); i++)
13920 {
13921 WeaponParticlesOnOverheating WPOOH = WPOOH_array.Get(i);
13922
13923 if (WPOOH)
13924 {
13925 WPOOH.OnUpdate(weapon, ammoType, muzzle_owner, suppressor, config_to_search);
13926 }
13927 }
13928 }
13929 }
13930
13931 // Stops overheating particles
13932 static void StopOverheatingParticles(ItemBase weapon, string ammoType, ItemBase muzzle_owner, ItemBase suppressor, string config_to_search)
13933 {
13934 int id = muzzle_owner.GetMuzzleID();
13935 array<ref WeaponParticlesOnOverheating> WPOOH_array = weapon.m_OnOverheatingEffect.Get(id);
13936
13937 if (WPOOH_array)
13938 {
13939 for (int i = 0; i < WPOOH_array.Count(); i++)
13940 {
13941 WeaponParticlesOnOverheating WPOOH = WPOOH_array.Get(i);
13942
13943 if (WPOOH)
13944 {
13945 WPOOH.OnDeactivate(weapon, ammoType, muzzle_owner, suppressor, config_to_search);
13946 }
13947 }
13948 }
13949 }
13950
13951 //----------------------------------------------------------------
13952 //Item Behaviour - unified approach
13953 override bool IsHeavyBehaviour()
13954 {
13955 if (m_ItemBehaviour == 0)
13956 {
13957 return true;
13958 }
13959
13960 return false;
13961 }
13962
13963 override bool IsOneHandedBehaviour()
13964 {
13965 if (m_ItemBehaviour == 1)
13966 {
13967 return true;
13968 }
13969
13970 return false;
13971 }
13972
13973 override bool IsTwoHandedBehaviour()
13974 {
13975 if (m_ItemBehaviour == 2)
13976 {
13977 return true;
13978 }
13979
13980 return false;
13981 }
13982
13983 bool IsDeployable()
13984 {
13985 return false;
13986 }
13987
13989 float GetDeployTime()
13990 {
13991 return UATimeSpent.DEFAULT_DEPLOY;
13992 }
13993
13994
13995 //----------------------------------------------------------------
13996 // Item Targeting (User Actions)
13997 override void SetTakeable(bool pState)
13998 {
13999 m_IsTakeable = pState;
14000 SetSynchDirty();
14001 }
14002
14003 override bool IsTakeable()
14004 {
14005 return m_IsTakeable;
14006 }
14007
14008 // For cases where we want to show object widget which cant be taken to hands
14010 {
14011 return false;
14012 }
14013
14015 protected void PreLoadSoundAttachmentType()
14016 {
14017 string att_type = "None";
14018
14019 if (ConfigIsExisting("soundAttType"))
14020 {
14021 att_type = ConfigGetString("soundAttType");
14022 }
14023
14024 m_SoundAttType = att_type;
14025 }
14026
14027 override string GetAttachmentSoundType()
14028 {
14029 return m_SoundAttType;
14030 }
14031
14032 //----------------------------------------------------------------
14033 //SOUNDS - ItemSoundHandler
14034 //----------------------------------------------------------------
14035
14036 string GetPlaceSoundset(); // played when deploy starts
14037 string GetLoopDeploySoundset(); // played when deploy starts and stopped when it finishes
14038 string GetDeploySoundset(); // played when deploy sucessfully finishes
14039 string GetLoopFoldSoundset(); // played when fold starts and stopped when it finishes
14040 string GetFoldSoundset(); // played when fold sucessfully finishes
14041
14043 {
14044 if (!m_ItemSoundHandler)
14046
14047 return m_ItemSoundHandler;
14048 }
14049
14050 // override to initialize sounds
14051 protected void InitItemSounds()
14052 {
14053 if (GetPlaceSoundset() == string.Empty && GetDeploySoundset() == string.Empty && GetLoopDeploySoundset() == string.Empty)
14054 return;
14055
14057
14058 if (GetPlaceSoundset() != string.Empty)
14059 handler.AddSound(SoundConstants.ITEM_PLACE, GetPlaceSoundset());
14060
14061 if (GetDeploySoundset() != string.Empty)
14062 handler.AddSound(SoundConstants.ITEM_DEPLOY, GetDeploySoundset());
14063
14064 SoundParameters params = new SoundParameters();
14065 params.m_Loop = true;
14066 if (GetLoopDeploySoundset() != string.Empty)
14067 handler.AddSound(SoundConstants.ITEM_DEPLOY_LOOP, GetLoopDeploySoundset(), params);
14068 }
14069
14070 // Start sound using ItemSoundHandler
14071 void StartItemSoundServer(int id)
14072 {
14073 if (!GetGame().IsServer())
14074 return;
14075
14076 m_SoundSyncPlay = id;
14077 SetSynchDirty();
14078
14079 GetGame().GetCallQueue(CALL_CATEGORY_SYSTEM).Remove(ClearStartItemSoundServer); // in case one is queued already
14081 }
14082
14083 // Stop sound using ItemSoundHandler
14084 void StopItemSoundServer(int id)
14085 {
14086 if (!GetGame().IsServer())
14087 return;
14088
14089 m_SoundSyncStop = id;
14090 SetSynchDirty();
14091
14092 GetGame().GetCallQueue(CALL_CATEGORY_SYSTEM).Remove(ClearStopItemSoundServer); // in case one is queued already
14094 }
14095
14096 protected void ClearStartItemSoundServer()
14097 {
14098 m_SoundSyncPlay = 0;
14099 }
14100
14101 protected void ClearStopItemSoundServer()
14102 {
14103 m_SoundSyncStop = 0;
14104 }
14105
14107 void PlayAttachSound(string slot_type)
14108 {
14109 if (!GetGame().IsDedicatedServer())
14110 {
14111 if (ConfigIsExisting("attachSoundSet"))
14112 {
14113 string cfg_path = "";
14114 string soundset = "";
14115 string type_name = GetType();
14116
14117 TStringArray cfg_soundset_array = new TStringArray;
14118 TStringArray cfg_slot_array = new TStringArray;
14119 ConfigGetTextArray("attachSoundSet",cfg_soundset_array);
14120 ConfigGetTextArray("attachSoundSlot",cfg_slot_array);
14121
14122 if (cfg_soundset_array.Count() > 0 && cfg_soundset_array.Count() == cfg_slot_array.Count())
14123 {
14124 for (int i = 0; i < cfg_soundset_array.Count(); i++)
14125 {
14126 if (cfg_slot_array[i] == slot_type)
14127 {
14128 soundset = cfg_soundset_array[i];
14129 break;
14130 }
14131 }
14132 }
14133
14134 if (soundset != "")
14135 {
14136 EffectSound sound = SEffectManager.PlaySound(soundset, GetPosition());
14137 sound.SetAutodestroy(true);
14138 }
14139 }
14140 }
14141 }
14142
14143 void PlayDetachSound(string slot_type)
14144 {
14145 //TODO - evaluate if needed and devise universal config structure if so
14146 }
14147
14148 void OnApply(PlayerBase player);
14149
14151 {
14152 return 1.0;
14153 };
14154 //returns applicable selection
14155 array<string> GetHeadHidingSelection()
14156 {
14158 }
14159
14161 {
14163 }
14164
14165 WrittenNoteData GetWrittenNoteData() {};
14166
14168 {
14169 SetDynamicPhysicsLifeTime(0.01);
14170 m_ItemBeingDroppedPhys = false;
14171 }
14172
14174 {
14175 array<string> zone_names = new array<string>;
14176 GetDamageZones(zone_names);
14177 for (int i = 0; i < zone_names.Count(); i++)
14178 {
14179 SetHealthMax(zone_names.Get(i),"Health");
14180 }
14181 SetHealthMax("","Health");
14182 }
14183
14185 void SetZoneDamageCEInit()
14186 {
14187 float global_health = GetHealth01("","Health");
14188 array<string> zones = new array<string>;
14189 GetDamageZones(zones);
14190 //set damage of all zones to match global health level
14191 for (int i = 0; i < zones.Count(); i++)
14192 {
14193 SetHealth01(zones.Get(i),"Health",global_health);
14194 }
14195 }
14196
14198 bool IsCoverFaceForShave(string slot_name)
14199 {
14200 return IsExclusionFlagPresent(PlayerBase.GetFaceCoverageShaveValues());
14201 }
14202
14203 void ProcessItemWetness(float delta, bool hasParent, bool hasRootAsPlayer, ItemBase refParentIB)
14204 {
14205 if (!hasRootAsPlayer)
14206 {
14207 if (refParentIB)
14208 {
14209 // parent is wet
14210 if ((refParentIB.GetWet() >= GameConstants.STATE_SOAKING_WET) && (m_VarWet < m_VarWetMax))
14211 AddWet(delta * GameConstants.WETNESS_RATE_WETTING_INSIDE);
14212 // parent has liquid inside
14213 else if ((refParentIB.GetLiquidType() != 0) && (refParentIB.GetQuantity() > 0) && (m_VarWet < m_VarWetMax))
14214 AddWet(delta * GameConstants.WETNESS_RATE_WETTING_LIQUID);
14215 // drying
14216 else if (m_VarWet > m_VarWetMin)
14217 AddWet(-1 * delta * GetDryingIncrement("ground") * 2);
14218 }
14219 else
14220 {
14221 // drying on ground or inside non-itembase (car, ...)
14222 if (m_VarWet > m_VarWetMin)
14223 AddWet(-1 * delta * GetDryingIncrement("ground"));
14224 }
14225 }
14226 }
14227
14228 void ProcessItemTemperature(float delta, bool hasParent, bool hasRootAsPlayer, ItemBase refParentIB)
14229 {
14231 {
14232 float target = g_Game.GetMission().GetWorldData().GetBaseEnvTemperatureAtObject(this);
14233 if (GetTemperature() != target || !IsFreezeThawProgressFinished())
14234 {
14235 float heatPermCoef = 1.0;
14236 EntityAI ent = this;
14237 while (ent)
14238 {
14239 heatPermCoef *= ent.GetHeatPermeabilityCoef();
14240 ent = ent.GetHierarchyParent();
14241 }
14242
14243 SetTemperatureEx(new TemperatureDataInterpolated(target,ETemperatureAccessTypes.ACCESS_WORLD,delta,GameConstants.TEMP_COEF_WORLD,heatPermCoef));
14244 }
14245 }
14246 }
14247
14248 void HierarchyCheck(out bool hasParent, out bool hasRootAsPlayer, out ItemBase refParentIB)
14249 {
14250 // hierarchy check for an item to decide whether it has some parent and it is in some player inventory
14251 EntityAI parent = GetHierarchyParent();
14252 if (!parent)
14253 {
14254 hasParent = false;
14255 hasRootAsPlayer = false;
14256 }
14257 else
14258 {
14259 hasParent = true;
14260 hasRootAsPlayer = (GetHierarchyRootPlayer() != null);
14261 refParentIB = ItemBase.Cast(parent);
14262 }
14263 }
14264
14265 protected void ProcessDecay(float delta, bool hasRootAsPlayer)
14266 {
14267 // this is stub, implemented on Edible_Base
14268 }
14269
14270 bool CanDecay()
14271 {
14272 // return true used on selected food clases so they can decay
14273 return false;
14274 }
14275
14276 protected bool CanProcessDecay()
14277 {
14278 // this is stub, implemented on Edible_Base class
14279 // used to determine whether it is still necessary for the food to decay
14280 return false;
14281 }
14282
14283 protected bool CanHaveWetness()
14284 {
14285 // return true used on selected items that have a wetness effect
14286 return false;
14287 }
14288
14290 bool CanBeConsumed(ConsumeConditionData data = null)
14291 {
14292 return !GetIsFrozen() && IsOpen();
14293 }
14294
14295 override void ProcessVariables()
14296 {
14297 bool hasParent = false, hasRootAsPlayer = false;
14298 ItemBase refParentIB;
14299
14300 bool wwtu = g_Game.IsWorldWetTempUpdateEnabled();
14301 bool foodDecay = g_Game.IsFoodDecayEnabled();
14302
14303 if (wwtu || foodDecay)
14304 {
14305 bool processWetness = wwtu && CanHaveWetness();
14306 bool processTemperature = wwtu && CanHaveTemperature();
14307 bool processDecay = foodDecay && CanDecay() && CanProcessDecay();
14308
14309 if (processWetness || processTemperature || processDecay)
14310 {
14311 HierarchyCheck(hasParent, hasRootAsPlayer, refParentIB);
14312
14313 if (processWetness)
14314 ProcessItemWetness(m_ElapsedSinceLastUpdate, hasParent, hasRootAsPlayer, refParentIB);
14315
14316 if (processTemperature)
14317 ProcessItemTemperature(m_ElapsedSinceLastUpdate, hasParent, hasRootAsPlayer, refParentIB);
14318
14319 if (processDecay)
14320 ProcessDecay(m_ElapsedSinceLastUpdate, hasRootAsPlayer);
14321 }
14322 }
14323 }
14324
14327 {
14328 return m_TemperaturePerQuantityWeight * GameConstants.ITEM_TEMPERATURE_QUANTITY_WEIGHT_MULTIPLIER;
14329 }
14330
14331 override float GetTemperatureFreezeThreshold()
14332 {
14334 return Liquid.GetFreezeThreshold(GetLiquidType());
14335
14336 return super.GetTemperatureFreezeThreshold();
14337 }
14338
14339 override float GetTemperatureThawThreshold()
14340 {
14342 return Liquid.GetThawThreshold(GetLiquidType());
14343
14344 return super.GetTemperatureThawThreshold();
14345 }
14346
14347 override float GetItemOverheatThreshold()
14348 {
14350 return Liquid.GetBoilThreshold(GetLiquidType());
14351
14352 return super.GetItemOverheatThreshold();
14353 }
14354
14355 override float GetTemperatureFreezeTime()
14356 {
14357 if (HasQuantity())
14358 return Math.Lerp(GameConstants.TEMPERATURE_TIME_FREEZE_MIN,Math.Max(GameConstants.TEMPERATURE_TIME_FREEZE_MIN,super.GetTemperatureFreezeTime()),GetQuantityNormalized());
14359
14360 return super.GetTemperatureFreezeTime();
14361 }
14362
14363 override float GetTemperatureThawTime()
14364 {
14365 if (HasQuantity())
14366 return Math.Lerp(GameConstants.TEMPERATURE_TIME_THAW_MIN,Math.Max(GameConstants.TEMPERATURE_TIME_FREEZE_MIN,super.GetTemperatureThawTime()),GetQuantityNormalized());
14367
14368 return super.GetTemperatureThawTime();
14369 }
14370
14372 void AffectLiquidContainerOnFill(int liquid_type, float amount);
14374 void AffectLiquidContainerOnTransfer(int liquidType, float amount, float sourceLiquidTemperature);
14375
14376 bool IsCargoException4x3(EntityAI item)
14377 {
14378 return (item.IsKindOf("Cauldron") || item.IsKindOf("Pot") || item.IsKindOf("FryingPan") || item.IsKindOf("SmallProtectorCase") || (item.IsKindOf("PortableGasStove") && item.FindAttachmentBySlotName("CookingEquipment")));
14379 }
14380
14382 {
14383 MiscGameplayFunctions.TransferItemProperties(oldItem, this);
14384 }
14385
14387 void AddLightSourceItem(ItemBase lightsource)
14388 {
14389 m_LightSourceItem = lightsource;
14390 }
14391
14393 {
14394 m_LightSourceItem = null;
14395 }
14396
14398 {
14399 return m_LightSourceItem;
14400 }
14401
14403 array<int> GetValidFinishers()
14404 {
14405 return null;
14406 }
14407
14409 bool GetActionWidgetOverride(out typename name)
14410 {
14411 return false;
14412 }
14413
14414 bool PairWithDevice(notnull ItemBase otherDevice)
14415 {
14416 if (GetGame().IsServer())
14417 {
14418 ItemBase explosive = otherDevice;
14420 if (!trg)
14421 {
14422 trg = RemoteDetonatorTrigger.Cast(otherDevice);
14423 explosive = this;
14424 }
14425
14426 explosive.PairRemote(trg);
14427 trg.SetControlledDevice(explosive);
14428
14429 int persistentID = RemotelyActivatedItemBehaviour.GeneratePersistentID();
14430 trg.SetPersistentPairID(persistentID);
14431 explosive.SetPersistentPairID(persistentID);
14432
14433 return true;
14434 }
14435 return false;
14436 }
14437
14439 float GetBaitEffectivity()
14440 {
14441 float ret = 1.0;
14442 if (HasQuantity())
14443 ret *= GetQuantityNormalized();
14444 ret *= GetHealth01();
14445
14446 return ret;
14447 }
14448
14449 #ifdef DEVELOPER
14450 override void SetDebugItem()
14451 {
14452 super.SetDebugItem();
14453 _itemBase = this;
14454 }
14455
14456 override string GetDebugText()
14457 {
14458 string text = super.GetDebugText();
14459
14460 text += string.Format("Heat isolation(raw): %1\n", GetHeatIsolation());
14461 text += string.Format("Heat isolation(modified): %1\n", MiscGameplayFunctions.GetCurrentItemHeatIsolation(this));
14462
14463 return text;
14464 }
14465 #endif
14466
14467 bool CanBeUsedForSuicide()
14468 {
14469 return true;
14470 }
14471
14473 //DEPRECATED BELOW
14475 // Backwards compatibility
14476 void ProcessItemWetnessAndTemperature(float delta, bool hasParent, bool hasRootAsPlayer, ItemBase refParentIB)
14477 {
14478 ProcessItemWetness(delta, hasParent, hasRootAsPlayer, refParentIB);
14479 ProcessItemTemperature(delta, hasParent, hasRootAsPlayer, refParentIB);
14480 }
14481
14482 // replaced by ItemSoundHandler
14483 protected EffectSound m_SoundDeployFinish;
14484 protected EffectSound m_SoundPlace;
14485 protected EffectSound m_DeployLoopSoundEx;
14486 protected EffectSound m_SoundDeploy;
14487 bool m_IsPlaceSound;
14488 bool m_IsDeploySound;
14490
14491 string GetDeployFinishSoundset();
14492 void PlayDeploySound();
14493 void PlayDeployFinishSound();
14494 void PlayPlaceSound();
14495 void PlayDeployLoopSoundEx();
14496 void StopDeployLoopSoundEx();
14497 void SoundSynchRemoteReset();
14498 void SoundSynchRemote();
14499 bool UsesGlobalDeploy(){return false;}
14500 bool CanPlayDeployLoopSound(){return false;}
14502 bool IsPlaceSound(){return m_IsPlaceSound;}
14503 bool IsDeploySound(){return m_IsDeploySound;}
14504 void SetIsPlaceSound(bool is_place_sound);
14505 void SetIsDeploySound(bool is_deploy_sound);
14506}
14507
14508EntityAI SpawnItemOnLocation(string object_name, notnull InventoryLocation loc, bool full_quantity)
14509{
14510 EntityAI entity = SpawnEntity(object_name, loc, ECE_IN_INVENTORY, RF_DEFAULT);
14511 if (entity)
14512 {
14513 bool is_item = entity.IsInherited(ItemBase);
14514 if (is_item && full_quantity)
14515 {
14516 ItemBase item = ItemBase.Cast(entity);
14517 item.SetQuantity(item.GetQuantityInit());
14518 }
14519 }
14520 else
14521 {
14522 ErrorEx("Cannot spawn entity: " + object_name,ErrorExSeverity.INFO);
14523 return NULL;
14524 }
14525 return entity;
14526}
14527
14528void SetupSpawnedItem(ItemBase item, float health, float quantity)
14529{
14530 if (item)
14531 {
14532 if (health > 0)
14533 item.SetHealth("", "", health);
14534
14535 if (item.CanHaveTemperature())
14536 {
14537 item.SetTemperatureDirect(GameConstants.ITEM_TEMPERATURE_NEUTRAL_ZONE_MIDDLE);
14538 if (item.CanFreeze())
14539 item.SetFrozen(false);
14540 }
14541
14542 if (item.HasEnergyManager())
14543 {
14544 if (quantity >= 0)
14545 {
14546 item.GetCompEM().SetEnergy0To1(quantity);
14547 }
14548 else
14549 {
14550 item.GetCompEM().SetEnergy(Math.AbsFloat(quantity));
14551 }
14552 }
14553 else if (item.IsMagazine())
14554 {
14555 Magazine mag = Magazine.Cast(item);
14556 if (quantity >= 0)
14557 {
14558 mag.ServerSetAmmoCount(mag.GetAmmoMax() * quantity);
14559 }
14560 else
14561 {
14562 mag.ServerSetAmmoCount(Math.AbsFloat(quantity));
14563 }
14564
14565 }
14566 else
14567 {
14568 if (quantity >= 0)
14569 {
14570 item.SetQuantityNormalized(quantity, false);
14571 }
14572 else
14573 {
14574 item.SetQuantity(Math.AbsFloat(quantity));
14575 }
14576
14577 }
14578 }
14579}
14580
14581#ifdef DEVELOPER
14582ItemBase _itemBase;//watched item goes here(LCTRL+RMB->Watch)
14583#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()