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

◆ GetTemperatureThawThreshold()

override float SpawnItemOnLocation::GetTemperatureThawThreshold ( )
protected

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

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