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

◆ GetValidFinishers()

array< int > SpawnItemOnLocation::GetValidFinishers ( )
protected

returns an array of possible finishers

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

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