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

◆ GetActionWidgetOverride()

bool SpawnItemOnLocation::GetActionWidgetOverride ( out typename name)
protected

If we need a different (handheld)item action widget displayed, the logic goes in here.

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

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