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

◆ PlayAttachSound()

void SpawnItemOnLocation::PlayAttachSound ( string slot_type)
protected

Plays sound on item attach. Be advised, the config structure may slightly change in 1.11 update to allow for more complex use.

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

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