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

◆ CopyScriptPropertiesFrom()

void SpawnItemOnLocation::CopyScriptPropertiesFrom ( EntityAI oldItem)
protected

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

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