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

◆ CanPlayDeployLoopSound()

bool SpawnItemOnLocation::CanPlayDeployLoopSound ( )
protected

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

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