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

◆ ProcessDecay()

void SpawnItemOnLocation::ProcessDecay ( float delta,
bool hasRootAsPlayer )
protected

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

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

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