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

◆ GetTemperaturePerQuantityWeight()

float SpawnItemOnLocation::GetTemperaturePerQuantityWeight ( )
protected

Used in heat comfort calculations only!

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

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