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

◆ GetBaitEffectivity()

float SpawnItemOnLocation::GetBaitEffectivity ( )
protected

generic effectivity as a bait for animal catching

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

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