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

◆ IsDeploySound()

bool SpawnItemOnLocation::IsDeploySound ( )
protected

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

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