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

◆ CanProcessDecay()

override bool CanProcessDecay ( )
protected

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

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

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