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

◆ GetLightSourceItem()

ItemBase SpawnItemOnLocation::GetLightSourceItem ( )
protected

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

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