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

◆ ProcessVariables()

override void SpawnItemOnLocation::ProcessVariables ( )
protected

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

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

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