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

◆ IsPlaceSound()

bool SpawnItemOnLocation::IsPlaceSound ( )
protected

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

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