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

◆ RemoveLightSourceItem()

void SpawnItemOnLocation::RemoveLightSourceItem ( )
protected

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

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