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

◆ PlayDetachSound()

void SpawnItemOnLocation::PlayDetachSound ( string slot_type)
protected

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

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