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

◆ CanBeConsumed()

bool SpawnItemOnLocation::CanBeConsumed ( ConsumeConditionData data = null)
protected

Items cannot be consumed if frozen by default. Override for exceptions.

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

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