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

◆ CanProcessDecay()

override bool CanProcessDecay ( )
protected

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

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

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