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

◆ PairWithDevice()

bool SpawnItemOnLocation::PairWithDevice ( notnull ItemBase otherDevice)
protected

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

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

Используется в ClaymoreMine::OnDebugSpawn() и ClaymoreMine::OnPlacementComplete().