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

◆ GetItemOverheatThreshold()

override float SpawnItemOnLocation::GetItemOverheatThreshold ( )
protected

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

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

Используется в Entity::SetTemperatureEx().