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

◆ CanHaveWetness()

bool SpawnItemOnLocation::CanHaveWetness ( )
protected

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

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