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

◆ GetTemperatureFreezeThreshold()

override float SpawnItemOnLocation::GetTemperatureFreezeThreshold ( )
protected

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

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