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

◆ OnStoreLoad()

override bool SpawnItemOnLocation::OnStoreLoad ( ParamsReadContext ctx,
int version )
protected

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

8015{
8016 override bool CanPutAsAttachment(EntityAI parent)
8017 {
8018 return true;
8019 }
8020};
8021
8023{
8024
8025};
8026
8027//const bool QUANTITY_DEBUG_REMOVE_ME = false;
8028
8029class ItemBase extends InventoryItem
8030{
8034
8036
8037 static int m_DebugActionsMask;
8039 // ============================================
8040 // Variable Manipulation System
8041 // ============================================
8042 // Quantity
8043
8044 float m_VarQuantity;
8045 float m_VarQuantityPrev;//for client to know quantity changed during synchronization
8047 int m_VarQuantityMin;
8048 int m_VarQuantityMax;
8049 int m_Count;
8050 float m_VarStackMax;
8051 float m_StoreLoadedQuantity = float.LOWEST;
8052 // Wet
8053 float m_VarWet;
8054 float m_VarWetPrev;//for client to know wetness changed during synchronization
8055 float m_VarWetInit;
8056 float m_VarWetMin;
8057 float m_VarWetMax;
8058 // Cleanness
8059 int m_Cleanness;
8060 int m_CleannessInit;
8061 int m_CleannessMin;
8062 int m_CleannessMax;
8063 // impact sounds
8065 bool m_CanPlayImpactSound = true;
8066 float m_ImpactSpeed;
8068 //
8069 float m_HeatIsolation;
8070 float m_ItemModelLength;
8071 float m_ItemAttachOffset; // Offset length for when the item is attached e.g. to weapon
8073 int m_VarLiquidType;
8074 int m_ItemBehaviour; // -1 = not specified; 0 = heavy item; 1= onehanded item; 2 = twohanded item
8075 int m_QuickBarBonus;
8076 bool m_IsBeingPlaced;
8077 bool m_IsHologram;
8078 bool m_IsTakeable;
8079 bool m_ThrowItemOnDrop;
8082 bool m_FixDamageSystemInit = false; //can be changed on storage version check
8083 bool can_this_be_combined; //Check if item can be combined
8084 bool m_CanThisBeSplit; //Check if item can be split
8085 bool m_IsStoreLoad = false;
8086 bool m_CanShowQuantity;
8087 bool m_HasQuantityBar;
8088 protected bool m_CanBeDigged;
8089 protected bool m_IsResultOfSplit
8090
8091 string m_SoundAttType;
8092 // items color variables
8097 //-------------------------------------------------------
8098
8099 // light source managing
8101
8105
8106 //==============================================
8107 // agent system
8108 private int m_AttachedAgents;
8109
8111 void TransferModifiers(PlayerBase reciever);
8112
8113
8114 // Weapons & suppressors particle effects
8118 ref static map<string, int> m_WeaponTypeToID;
8119 static int m_LastRegisteredWeaponID = 0;
8120
8121 // Overheating effects
8123 float m_OverheatingShots;
8124 ref Timer m_CheckOverheating;
8125 int m_ShotsToStartOverheating = 0; // After these many shots, the overheating effect begins
8126 int m_MaxOverheatingValue = 0; // Limits the number of shots that will be tracked
8127 float m_OverheatingDecayInterval = 1; // Timer's interval for decrementing overheat effect's lifespan
8128 ref array <ref OverheatingParticle> m_OverheatingParticles;
8129
8131 protected bool m_HideSelectionsBySlot;
8132
8133 // Admin Log
8134 PluginAdminLog m_AdminLog;
8135
8136 // misc
8137 ref Timer m_PhysDropTimer;
8138
8139 // Attachment Locking variables
8140 ref array<int> m_CompatibleLocks;
8141 protected int m_LockType;
8142 protected ref EffectSound m_LockingSound;
8143 protected string m_LockSoundSet;
8144
8145 // ItemSoundHandler variables
8146 protected const int ITEM_SOUNDS_MAX = 63; // optimize network synch
8147 protected int m_SoundSyncPlay; // id for sound to play
8148 protected int m_SoundSyncStop; // id for sound to stop
8149 protected int m_SoundSyncSlotID = InventorySlots.INVALID; // slot id for attach/detach sound based on slot
8150
8152
8153 //temperature
8154 private float m_TemperaturePerQuantityWeight;
8155
8156 // -------------------------------------------------------------------------
8157 void ItemBase()
8158 {
8159 SetEventMask(EntityEvent.INIT); // Enable EOnInit event
8163
8164 if (!g_Game.IsDedicatedServer())
8165 {
8166 if (HasMuzzle())
8167 {
8169
8171 {
8173 }
8174 }
8175
8177 m_ActionsInitialize = false;
8178 }
8179
8180 m_OldLocation = null;
8181
8182 if (g_Game.IsServer())
8183 {
8184 m_AdminLog = PluginAdminLog.Cast(GetPlugin(PluginAdminLog));
8185 }
8186
8187 if (ConfigIsExisting("headSelectionsToHide"))
8188 {
8190 ConfigGetTextArray("headSelectionsToHide",m_HeadHidingSelections);
8191 }
8192
8193 m_HideSelectionsBySlot = false;
8194 if (ConfigIsExisting("hideSelectionsByinventorySlot"))
8195 {
8196 m_HideSelectionsBySlot = ConfigGetBool("hideSelectionsByinventorySlot");
8197 }
8198
8199 m_QuickBarBonus = Math.Max(0, ConfigGetInt("quickBarBonus"));
8200
8201 m_IsResultOfSplit = false;
8202
8204 }
8205
8206 override void InitItemVariables()
8207 {
8208 super.InitItemVariables();
8209
8210 m_VarQuantityInit = ConfigGetInt("varQuantityInit");
8211 m_VarQuantity = m_VarQuantityInit;//should be by the CE, this is just a precaution
8212 m_VarQuantityMin = ConfigGetInt("varQuantityMin");
8213 m_VarQuantityMax = ConfigGetInt("varQuantityMax");
8214 m_VarStackMax = ConfigGetFloat("varStackMax");
8215 m_Count = ConfigGetInt("count");
8216
8217 m_CanShowQuantity = ConfigGetBool("quantityShow");
8218 m_HasQuantityBar = ConfigGetBool("quantityBar");
8219
8220 m_CleannessInit = ConfigGetInt("varCleannessInit");
8222 m_CleannessMin = ConfigGetInt("varCleannessMin");
8223 m_CleannessMax = ConfigGetInt("varCleannessMax");
8224
8225 m_WantPlayImpactSound = false;
8226 m_ImpactSpeed = 0.0;
8227
8228 m_VarWetInit = ConfigGetFloat("varWetInit");
8230 m_VarWetMin = ConfigGetFloat("varWetMin");
8231 m_VarWetMax = ConfigGetFloat("varWetMax");
8232
8233 m_LiquidContainerMask = ConfigGetInt("liquidContainerType");
8234 if (IsLiquidContainer() && GetQuantity() != 0)
8236 m_IsBeingPlaced = false;
8237 m_IsHologram = false;
8238 m_IsTakeable = true;
8239 m_CanBeMovedOverride = false;
8243 m_CanBeDigged = ConfigGetBool("canBeDigged");
8244
8245 m_CompatibleLocks = new array<int>();
8246 ConfigGetIntArray("compatibleLocks", m_CompatibleLocks);
8247 m_LockType = ConfigGetInt("lockType");
8248
8249 //Define if item can be split and set ability to be combined accordingly
8250 m_CanThisBeSplit = false;
8251 can_this_be_combined = false;
8252 if (ConfigIsExisting("canBeSplit"))
8253 {
8254 can_this_be_combined = ConfigGetBool("canBeSplit");
8256 }
8257
8258 m_ItemBehaviour = -1;
8259 if (ConfigIsExisting("itemBehaviour"))
8260 m_ItemBehaviour = ConfigGetInt("itemBehaviour");
8261
8262 //RegisterNetSyncVariableInt("m_VariablesMask");
8263 if (HasQuantity()) RegisterNetSyncVariableFloat("m_VarQuantity", GetQuantityMin(), m_VarQuantityMax);
8264 RegisterNetSyncVariableFloat("m_VarWet", GetWetMin(), GetWetMax(), 2);
8265 RegisterNetSyncVariableInt("m_VarLiquidType");
8266 RegisterNetSyncVariableInt("m_Cleanness",0,1);
8267
8268 RegisterNetSyncVariableBoolSignal("m_WantPlayImpactSound");
8269 RegisterNetSyncVariableFloat("m_ImpactSpeed");
8270 RegisterNetSyncVariableInt("m_ImpactSoundSurfaceHash");
8271
8272 RegisterNetSyncVariableInt("m_ColorComponentR", 0, 255);
8273 RegisterNetSyncVariableInt("m_ColorComponentG", 0, 255);
8274 RegisterNetSyncVariableInt("m_ColorComponentB", 0, 255);
8275 RegisterNetSyncVariableInt("m_ColorComponentA", 0, 255);
8276
8277 RegisterNetSyncVariableBool("m_IsBeingPlaced");
8278 RegisterNetSyncVariableBool("m_IsTakeable");
8279 RegisterNetSyncVariableBool("m_IsHologram");
8280
8283 {
8284 RegisterNetSyncVariableInt("m_SoundSyncPlay", 0, ITEM_SOUNDS_MAX);
8285 RegisterNetSyncVariableInt("m_SoundSyncStop", 0, ITEM_SOUNDS_MAX);
8286 RegisterNetSyncVariableInt("m_SoundSyncSlotID", int.MIN, int.MAX);
8287 }
8288
8289 m_LockSoundSet = ConfigGetString("lockSoundSet");
8290
8292 if (ConfigIsExisting("temperaturePerQuantityWeight"))
8293 m_TemperaturePerQuantityWeight = ConfigGetFloat("temperaturePerQuantityWeight");
8294
8295 m_SoundSyncSlotID = -1;
8296 }
8297
8298 override int GetQuickBarBonus()
8299 {
8300 return m_QuickBarBonus;
8301 }
8302
8303 void InitializeActions()
8304 {
8306 if (!m_InputActionMap)
8307 {
8309 m_InputActionMap = iam;
8310 SetActions();
8312 }
8313 }
8314
8315 override void GetActions(typename action_input_type, out array<ActionBase_Basic> actions)
8316 {
8318 {
8319 m_ActionsInitialize = true;
8321 }
8322
8323 actions = m_InputActionMap.Get(action_input_type);
8324 }
8325
8326 void SetActions()
8327 {
8328 AddAction(ActionTakeItem);
8329 AddAction(ActionTakeItemToHands);
8330 AddAction(ActionWorldCraft);
8332 AddAction(ActionAttachWithSwitch);
8333 }
8334
8335 void SetActionAnimOverrides(); // Override action animation for specific item
8336
8337 void AddAction(typename actionName)
8338 {
8339 ActionBase action = ActionManagerBase.GetAction(actionName);
8340
8341 if (!action)
8342 {
8343 Debug.LogError("Action " + actionName + " dosn't exist!");
8344 return;
8345 }
8346
8347 typename ai = action.GetInputType();
8348 if (!ai)
8349 {
8350 m_ActionsInitialize = false;
8351 return;
8352 }
8353
8354 array<ActionBase_Basic> action_array = m_InputActionMap.Get(ai);
8355 if (!action_array)
8356 {
8357 action_array = new array<ActionBase_Basic>;
8358 m_InputActionMap.Insert(ai, action_array);
8359 }
8360 if (LogManager.IsActionLogEnable())
8361 {
8362 Debug.ActionLog(action.ToString() + " -> " + ai, this.ToString() , "n/a", "Add action");
8363 }
8364
8365 if (action_array.Find(action) != -1)
8366 {
8367 Debug.Log("Action " + action.Type() + " already added to " + this + ", skipping!");
8368 }
8369 else
8370 {
8371 action_array.Insert(action);
8372 }
8373 }
8374
8375 void RemoveAction(typename actionName)
8376 {
8377 PlayerBase player = PlayerBase.Cast(g_Game.GetPlayer());
8378 ActionBase action = player.GetActionManager().GetAction(actionName);
8379 typename ai = action.GetInputType();
8380 array<ActionBase_Basic> action_array = m_InputActionMap.Get(ai);
8381
8382 if (action_array)
8383 {
8384 action_array.RemoveItem(action);
8385 }
8386 }
8387
8388 // Allows override of default action command per item, defined in the SetActionAnimOverrides() of the item's class
8389 // Set -1 for params which should stay in default state
8390 void OverrideActionAnimation(typename action, int commandUID, int stanceMask = -1, int commandUIDProne = -1)
8391 {
8392 ActionOverrideData overrideData = new ActionOverrideData();
8393 overrideData.m_CommandUID = commandUID;
8394 overrideData.m_CommandUIDProne = commandUIDProne;
8395 overrideData.m_StanceMask = stanceMask;
8396
8397 TActionAnimOverrideMap actionMap = m_ItemActionOverrides.Get(action);
8398 if (!actionMap) // create new map of action > overidables map
8399 {
8400 actionMap = new TActionAnimOverrideMap();
8401 m_ItemActionOverrides.Insert(action, actionMap);
8402 }
8403
8404 actionMap.Insert(this.Type(), overrideData); // insert item -> overrides
8405
8406 }
8407
8408 void OnItemInHandsPlayerSwimStart(PlayerBase player);
8409
8410 ScriptedLightBase GetLight();
8411
8412 // Loads muzzle flash particle configuration from config and saves it to a map for faster access
8413 void LoadParticleConfigOnFire(int id)
8414 {
8415 if (!m_OnFireEffect)
8417
8420
8421 string config_to_search = "CfgVehicles";
8422 string muzzle_owner_config;
8423
8424 if (!m_OnFireEffect.Contains(id))
8425 {
8426 if (IsInherited(Weapon))
8427 config_to_search = "CfgWeapons";
8428
8429 muzzle_owner_config = config_to_search + " " + GetType() + " ";
8430
8431 string config_OnFire_class = muzzle_owner_config + "Particles " + "OnFire ";
8432
8433 int config_OnFire_subclass_count = g_Game.ConfigGetChildrenCount(config_OnFire_class);
8434
8435 if (config_OnFire_subclass_count > 0)
8436 {
8437 array<ref WeaponParticlesOnFire> WPOF_array = new array<ref WeaponParticlesOnFire>;
8438
8439 for (int i = 0; i < config_OnFire_subclass_count; i++)
8440 {
8441 string particle_class = "";
8442 g_Game.ConfigGetChildName(config_OnFire_class, i, particle_class);
8443 string config_OnFire_entry = config_OnFire_class + particle_class;
8444 WeaponParticlesOnFire WPOF = new WeaponParticlesOnFire(this, config_OnFire_entry);
8445 WPOF_array.Insert(WPOF);
8446 }
8447
8448
8449 m_OnFireEffect.Insert(id, WPOF_array);
8450 }
8451 }
8452
8453 if (!m_OnBulletCasingEjectEffect.Contains(id))
8454 {
8455 config_to_search = "CfgWeapons"; // Bullet Eject efect is supported on weapons only.
8456 muzzle_owner_config = config_to_search + " " + GetType() + " ";
8457
8458 string config_OnBulletCasingEject_class = muzzle_owner_config + "Particles " + "OnBulletCasingEject ";
8459
8460 int config_OnBulletCasingEject_count = g_Game.ConfigGetChildrenCount(config_OnBulletCasingEject_class);
8461
8462 if (config_OnBulletCasingEject_count > 0 && IsInherited(Weapon))
8463 {
8464 array<ref WeaponParticlesOnBulletCasingEject> WPOBE_array = new array<ref WeaponParticlesOnBulletCasingEject>;
8465
8466 for (i = 0; i < config_OnBulletCasingEject_count; i++)
8467 {
8468 string particle_class2 = "";
8469 g_Game.ConfigGetChildName(config_OnBulletCasingEject_class, i, particle_class2);
8470 string config_OnBulletCasingEject_entry = config_OnBulletCasingEject_class + particle_class2;
8471 WeaponParticlesOnBulletCasingEject WPOBE = new WeaponParticlesOnBulletCasingEject(this, config_OnBulletCasingEject_entry);
8472 WPOBE_array.Insert(WPOBE);
8473 }
8474
8475
8476 m_OnBulletCasingEjectEffect.Insert(id, WPOBE_array);
8477 }
8478 }
8479 }
8480
8481 // Loads muzzle flash particle configuration from config and saves it to a map for faster access
8483 {
8486
8487 if (!m_OnOverheatingEffect.Contains(id))
8488 {
8489 string config_to_search = "CfgVehicles";
8490
8491 if (IsInherited(Weapon))
8492 config_to_search = "CfgWeapons";
8493
8494 string muzzle_owner_config = config_to_search + " " + GetType() + " ";
8495 string config_OnOverheating_class = muzzle_owner_config + "Particles " + "OnOverheating ";
8496
8497 if (g_Game.ConfigIsExisting(config_OnOverheating_class))
8498 {
8499
8500 m_ShotsToStartOverheating = g_Game.ConfigGetFloat(config_OnOverheating_class + "shotsToStartOverheating");
8501
8503 {
8504 m_ShotsToStartOverheating = -1; // This prevents futher readings from config for future creations of this item
8505 string error = "Error reading config " + GetType() + ">Particles>OnOverheating - Parameter shotsToStartOverheating is configured wrong or is missing! Its value must be 1 or higher!";
8506 Error(error);
8507 return;
8508 }
8509
8510 m_OverheatingDecayInterval = g_Game.ConfigGetFloat(config_OnOverheating_class + "overheatingDecayInterval");
8511 m_MaxOverheatingValue = g_Game.ConfigGetFloat(config_OnOverheating_class + "maxOverheatingValue");
8512
8513
8514
8515 int config_OnOverheating_subclass_count = g_Game.ConfigGetChildrenCount(config_OnOverheating_class);
8516 array<ref WeaponParticlesOnOverheating> WPOOH_array = new array<ref WeaponParticlesOnOverheating>;
8517
8518 for (int i = 0; i < config_OnOverheating_subclass_count; i++)
8519 {
8520 string particle_class = "";
8521 g_Game.ConfigGetChildName(config_OnOverheating_class, i, particle_class);
8522 string config_OnOverheating_entry = config_OnOverheating_class + particle_class;
8523 int entry_type = g_Game.ConfigGetType(config_OnOverheating_entry);
8524
8525 if (entry_type == CT_CLASS)
8526 {
8527 WeaponParticlesOnOverheating WPOF = new WeaponParticlesOnOverheating(this, config_OnOverheating_entry);
8528 WPOOH_array.Insert(WPOF);
8529 }
8530 }
8531
8532
8533 m_OnOverheatingEffect.Insert(id, WPOOH_array);
8534 }
8535 }
8536 }
8537
8538 float GetOverheatingValue()
8539 {
8540 return m_OverheatingShots;
8541 }
8542
8543 void IncreaseOverheating(ItemBase weapon, string ammoType, ItemBase muzzle_owner, ItemBase suppressor, string config_to_search)
8544 {
8545 if (m_MaxOverheatingValue > 0)
8546 {
8548
8549 if (!m_CheckOverheating)
8551
8553 m_CheckOverheating.Run(m_OverheatingDecayInterval, this, "OnOverheatingDecay");
8554
8555 CheckOverheating(weapon, ammoType, muzzle_owner, suppressor, config_to_search);
8556 }
8557 }
8558
8559 void CheckOverheating(ItemBase weapon = null, string ammoType = "", ItemBase muzzle_owner = null, ItemBase suppressor = null, string config_to_search = "")
8560 {
8562 UpdateOverheating(weapon, ammoType, muzzle_owner, suppressor, config_to_search);
8563
8565 StartOverheating(weapon, ammoType, muzzle_owner, suppressor, config_to_search);
8566
8568 StopOverheating(weapon, ammoType, muzzle_owner, suppressor, config_to_search);
8569
8571 {
8573 }
8574 }
8575
8577 {
8579 }
8580
8581 void OnOverheatingDecay()
8582 {
8583 if (m_MaxOverheatingValue > 0)
8584 m_OverheatingShots -= 1 + m_OverheatingShots / m_MaxOverheatingValue; // The hotter a barrel is, the faster it needs to cool down.
8585 else
8587
8588 if (m_OverheatingShots <= 0)
8589 {
8592 }
8593 else
8594 {
8595 if (!m_CheckOverheating)
8597
8599 m_CheckOverheating.Run(m_OverheatingDecayInterval, this, "OnOverheatingDecay");
8600 }
8601
8602 CheckOverheating(this, "", this);
8603 }
8604
8605 void StartOverheating(ItemBase weapon = null, string ammoType = "", ItemBase muzzle_owner = null, ItemBase suppressor = null, string config_to_search = "")
8606 {
8608 ItemBase.PlayOverheatingParticles(this, ammoType, this, suppressor, "CfgWeapons");
8609 }
8610
8611 void UpdateOverheating(ItemBase weapon = null, string ammoType = "", ItemBase muzzle_owner = null, ItemBase suppressor = null, string config_to_search = "")
8612 {
8614 ItemBase.UpdateOverheatingParticles(this, ammoType, this, suppressor, "CfgWeapons");
8616 }
8617
8618 void StopOverheating(ItemBase weapon = null, string ammoType = "", ItemBase muzzle_owner = null, ItemBase suppressor = null, string config_to_search = "")
8619 {
8621 ItemBase.StopOverheatingParticles(weapon, ammoType, muzzle_owner, suppressor, config_to_search);
8622 }
8623
8624 void RegisterOverheatingParticle(Particle p, float min_heat_coef, float max_heat_coef, int particle_id, Object parent, vector local_pos, vector local_ori)
8625 {
8627 m_OverheatingParticles = new array<ref OverheatingParticle>;
8628
8629 OverheatingParticle OP = new OverheatingParticle();
8630 OP.RegisterParticle(p);
8631 OP.SetOverheatingLimitMin(min_heat_coef);
8632 OP.SetOverheatingLimitMax(max_heat_coef);
8633 OP.SetParticleParams(particle_id, parent, local_pos, local_ori);
8634
8635 m_OverheatingParticles.Insert(OP);
8636 }
8637
8638 float GetOverheatingCoef()
8639 {
8640 if (m_MaxOverheatingValue > 0)
8642
8643 return -1;
8644 }
8645
8647 {
8649 {
8650 float overheat_coef = GetOverheatingCoef();
8651 int count = m_OverheatingParticles.Count();
8652
8653 for (int i = count; i > 0; --i)
8654 {
8655 int id = i - 1;
8656 OverheatingParticle OP = m_OverheatingParticles.Get(id);
8657 Particle p = OP.GetParticle();
8658
8659 float overheat_min = OP.GetOverheatingLimitMin();
8660 float overheat_max = OP.GetOverheatingLimitMax();
8661
8662 if (overheat_coef < overheat_min && overheat_coef >= overheat_max)
8663 {
8664 if (p)
8665 {
8666 p.Stop();
8667 OP.RegisterParticle(null);
8668 }
8669 }
8670 }
8671 }
8672 }
8673
8675 {
8677 {
8678 for (int i = m_OverheatingParticles.Count(); i > 0; i--)
8679 {
8680 int id = i - 1;
8681 OverheatingParticle OP = m_OverheatingParticles.Get(id);
8682
8683 if (OP)
8684 {
8685 Particle p = OP.GetParticle();
8686
8687 if (p)
8688 {
8689 p.Stop();
8690 }
8691
8692 delete OP;
8693 }
8694 }
8695
8696 m_OverheatingParticles.Clear();
8698 }
8699 }
8700
8702 float GetInfectionChance(int system = 0, Param param = null)
8703 {
8704 return 0.0;
8705 }
8706
8707
8708 float GetDisinfectQuantity(int system = 0, Param param1 = null)
8709 {
8710 return 250;//default value
8711 }
8712
8713 float GetFilterDamageRatio()
8714 {
8715 return 0;
8716 }
8717
8719 bool HasMuzzle()
8720 {
8721 if (IsInherited(Weapon) || IsInherited(SuppressorBase))
8722 return true;
8723
8724 return false;
8725 }
8726
8728 int GetMuzzleID()
8729 {
8730 if (!m_WeaponTypeToID)
8731 m_WeaponTypeToID = new map<string, int>;
8732
8733 if (m_WeaponTypeToID.Contains(GetType()))
8734 {
8735 return m_WeaponTypeToID.Get(GetType());
8736 }
8737 else
8738 {
8739 // Register new weapon ID
8741 }
8742
8744 }
8745
8752 {
8753 return -1;
8754 }
8755
8756
8757
8758 // -------------------------------------------------------------------------
8759 void ~ItemBase()
8760 {
8761 if (g_Game && g_Game.GetPlayer() && (!g_Game.IsDedicatedServer()))
8762 {
8763 PlayerBase player = PlayerBase.Cast(g_Game.GetPlayer());
8764 int r_index = player.GetHumanInventory().FindUserReservedLocationIndex(this);
8765
8766 if (r_index >= 0)
8767 {
8768 InventoryLocation r_il = new InventoryLocation;
8769 player.GetHumanInventory().GetUserReservedLocation(r_index,r_il);
8770
8771 player.GetHumanInventory().ClearUserReservedLocationAtIndex(r_index);
8772 int r_type = r_il.GetType();
8773 if (r_type == InventoryLocationType.CARGO || r_type == InventoryLocationType.PROXYCARGO)
8774 {
8775 r_il.GetParent().GetOnReleaseLock().Invoke(this);
8776 }
8777 else if (r_type == InventoryLocationType.ATTACHMENT)
8778 {
8779 r_il.GetParent().GetOnAttachmentReleaseLock().Invoke(this, r_il.GetSlot());
8780 }
8781
8782 }
8783
8784 player.GetHumanInventory().ClearUserReservedLocation(this);
8785 }
8786
8787 if (m_LockingSound)
8788 SEffectManager.DestroyEffect(m_LockingSound);
8789 }
8790
8791
8792
8793 // -------------------------------------------------------------------------
8794 static int GetDebugActionsMask()
8795 {
8796 return ItemBase.m_DebugActionsMask;
8797 }
8798
8799 static bool HasDebugActionsMask(int mask)
8800 {
8801 return ItemBase.m_DebugActionsMask & mask;
8802 }
8803
8804 static void SetDebugActionsMask(int mask)
8805 {
8806 ItemBase.m_DebugActionsMask = mask;
8807 }
8808
8809 static void AddDebugActionsMask(int mask)
8810 {
8811 ItemBase.m_DebugActionsMask |= mask;
8812 }
8813
8814 static void RemoveDebugActionsMask(int mask)
8815 {
8816 ItemBase.m_DebugActionsMask &= ~mask;
8817 }
8818
8819 static void ToggleDebugActionsMask(int mask)
8820 {
8821 if (HasDebugActionsMask(mask))
8822 {
8824 }
8825 else
8826 {
8827 AddDebugActionsMask(mask);
8828 }
8829 }
8830
8831 // -------------------------------------------------------------------------
8832 void SetCEBasedQuantity()
8833 {
8834 if (GetEconomyProfile())
8835 {
8836 float q_max = GetEconomyProfile().GetQuantityMax();
8837 if (q_max > 0)
8838 {
8839 float q_min = GetEconomyProfile().GetQuantityMin();
8840 float quantity_randomized = Math.RandomFloatInclusive(q_min, q_max);
8841
8842 if (HasComponent(COMP_TYPE_ENERGY_MANAGER))//more direct access for speed
8843 {
8844 ComponentEnergyManager comp = GetCompEM();
8845 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
8846 {
8847 comp.SetEnergy0To1(quantity_randomized);
8848 }
8849 }
8850 else if (HasQuantity())
8851 {
8852 SetQuantityNormalized(quantity_randomized, false);
8853 //PrintString("<==> Normalized quantity for item: "+ GetType()+", qmin:"+q_min.ToString()+"; qmax:"+q_max.ToString()+";quantity:" +quantity_randomized.ToString());
8854 }
8855
8856 }
8857 }
8858 }
8859
8861 void LockToParent()
8862 {
8863 EntityAI parent = GetHierarchyParent();
8864
8865 if (parent)
8866 {
8867 InventoryLocation inventory_location_to_lock = new InventoryLocation;
8868 GetInventory().GetCurrentInventoryLocation(inventory_location_to_lock);
8869 parent.GetInventory().SetSlotLock(inventory_location_to_lock.GetSlot(), true);
8870 }
8871 }
8872
8874 void UnlockFromParent()
8875 {
8876 EntityAI parent = GetHierarchyParent();
8877
8878 if (parent)
8879 {
8880 InventoryLocation inventory_location_to_unlock = new InventoryLocation;
8881 GetInventory().GetCurrentInventoryLocation(inventory_location_to_unlock);
8882 parent.GetInventory().SetSlotLock(inventory_location_to_unlock.GetSlot(), false);
8883 }
8884 }
8885
8886 override void CombineItemsClient(EntityAI entity2, bool use_stack_max = true)
8887 {
8888 /*
8889 ref Param1<EntityAI> item = new Param1<EntityAI>(entity2);
8890 RPCSingleParam(ERPCs.RPC_ITEM_COMBINE, item, g_Game.GetPlayer());
8891 */
8892 ItemBase item2 = ItemBase.Cast(entity2);
8893
8894 if (g_Game.IsClient())
8895 {
8896 if (ScriptInputUserData.CanStoreInputUserData())
8897 {
8898 ScriptInputUserData ctx = new ScriptInputUserData;
8900 ctx.Write(-1);
8901 ItemBase i1 = this; // @NOTE: workaround for correct serialization
8902 ctx.Write(i1);
8903 ctx.Write(item2);
8904 ctx.Write(use_stack_max);
8905 ctx.Write(-1);
8906 ctx.Send();
8907
8908 if (IsCombineAll(item2, use_stack_max))
8909 {
8910 g_Game.GetPlayer().GetInventory().AddInventoryReservationEx(item2,null,GameInventory.c_InventoryReservationTimeoutShortMS);
8911 }
8912 }
8913 }
8914 else if (!g_Game.IsMultiplayer())
8915 {
8916 CombineItems(item2, use_stack_max);
8917 }
8918 }
8919
8920 bool IsLiquidPresent()
8921 {
8922 return (GetLiquidType() != 0 && HasQuantity());
8923 }
8924
8925 bool IsLiquidContainer()
8926 {
8927 return m_LiquidContainerMask != 0;
8928 }
8929
8931 {
8932 return m_LiquidContainerMask;
8933 }
8934
8935 bool IsBloodContainer()
8936 {
8937 //m_LiquidContainerMask & GROUP_LIQUID_BLOOD ???
8938 return false;
8939 }
8940
8941 bool IsNVG()
8942 {
8943 return false;
8944 }
8945
8948 bool IsExplosive()
8949 {
8950 return false;
8951 }
8952
8954 {
8955 return "";
8956 }
8957
8959
8960 bool IsLightSource()
8961 {
8962 return false;
8963 }
8964
8966 {
8967 return true;
8968 }
8969
8970 //--- ACTION CONDITIONS
8971 //direction
8972 bool IsFacingPlayer(PlayerBase player, string selection)
8973 {
8974 return true;
8975 }
8976
8977 bool IsPlayerInside(PlayerBase player, string selection)
8978 {
8979 return true;
8980 }
8981
8982 override bool CanObstruct()
8983 {
8984 PlayerBase player = PlayerBase.Cast(g_Game.GetPlayer());
8985 return !player || !IsPlayerInside(player, "");
8986 }
8987
8988 override bool IsBeingPlaced()
8989 {
8990 return m_IsBeingPlaced;
8991 }
8992
8993 void SetIsBeingPlaced(bool is_being_placed)
8994 {
8995 m_IsBeingPlaced = is_being_placed;
8996 if (!is_being_placed)
8998 SetSynchDirty();
8999 }
9000
9001 //server-side
9002 void OnEndPlacement() {}
9003
9004 override bool IsHologram()
9005 {
9006 return m_IsHologram;
9007 }
9008
9009 bool CanBeDigged()
9010 {
9011 return m_CanBeDigged;
9012 }
9013
9015 {
9016 return 1;
9017 }
9018
9019 bool CanMakeGardenplot()
9020 {
9021 return false;
9022 }
9023
9024 void SetIsHologram(bool is_hologram)
9025 {
9026 m_IsHologram = is_hologram;
9027 SetSynchDirty();
9028 }
9029 /*
9030 protected float GetNutritionalEnergy()
9031 {
9032 Edible_Base edible = Edible_Base.Cast(this);
9033 return edible.GetFoodEnergy();
9034 }
9035
9036 protected float GetNutritionalWaterContent()
9037 {
9038 Edible_Base edible = Edible_Base.Cast(this);
9039 return edible.GetFoodWater();
9040 }
9041
9042 protected float GetNutritionalIndex()
9043 {
9044 Edible_Base edible = Edible_Base.Cast(this);
9045 return edible.GetFoodNutritionalIndex();
9046 }
9047
9048 protected float GetNutritionalFullnessIndex()
9049 {
9050 Edible_Base edible = Edible_Base.Cast(this);
9051 return edible.GetFoodTotalVolume();
9052 }
9053
9054 protected float GetNutritionalToxicity()
9055 {
9056 Edible_Base edible = Edible_Base.Cast(this);
9057 return edible.GetFoodToxicity();
9058
9059 }
9060 */
9061
9062
9063 // -------------------------------------------------------------------------
9064 override void OnMovedInsideCargo(EntityAI container)
9065 {
9066 super.OnMovedInsideCargo(container);
9067
9068 MiscGameplayFunctions.RemoveAllAttachedChildrenByTypename(this, {Bolt_Base});
9069 }
9070
9071 override void EEItemLocationChanged(notnull InventoryLocation oldLoc, notnull InventoryLocation newLoc)
9072 {
9073 super.EEItemLocationChanged(oldLoc, newLoc);
9074
9075 PlayerBase newPlayer = null;
9076 PlayerBase oldPlayer = null;
9077
9078 if (newLoc.GetParent())
9079 newPlayer = PlayerBase.Cast(newLoc.GetParent().GetHierarchyRootPlayer());
9080
9081 if (oldLoc.GetParent())
9082 oldPlayer = PlayerBase.Cast(oldLoc.GetParent().GetHierarchyRootPlayer());
9083
9084 if (oldPlayer && oldLoc.GetType() == InventoryLocationType.HANDS)
9085 {
9086 int rIndex = oldPlayer.GetHumanInventory().FindUserReservedLocationIndex(this);
9087
9088 if (rIndex >= 0)
9089 {
9090 InventoryLocation rIl = new InventoryLocation;
9091 oldPlayer.GetHumanInventory().GetUserReservedLocation(rIndex, rIl);
9092
9093 oldPlayer.GetHumanInventory().ClearUserReservedLocationAtIndex(rIndex);
9094 int rType = rIl.GetType();
9095 if (rType == InventoryLocationType.CARGO || rType == InventoryLocationType.PROXYCARGO)
9096 {
9097 rIl.GetParent().GetOnReleaseLock().Invoke(this);
9098 }
9099 else if (rType == InventoryLocationType.ATTACHMENT)
9100 {
9101 rIl.GetParent().GetOnAttachmentReleaseLock().Invoke(this, rIl.GetSlot());
9102 }
9103
9104 }
9105 }
9106
9107 if (newLoc.GetType() == InventoryLocationType.HANDS && oldLoc.GetType() != InventoryLocationType.TEMP)
9108 {
9109 if (newPlayer)
9110 newPlayer.ForceStandUpForHeavyItems(newLoc.GetItem());
9111
9112 if (newPlayer == oldPlayer)
9113 {
9114 if (oldLoc.GetParent() && newPlayer.GetHumanInventory().LocationGetEntity(oldLoc) == NULL)
9115 {
9116 if (oldLoc.GetType() == InventoryLocationType.CARGO)
9117 {
9118 if (oldLoc.GetParent().GetInventory().TestAddEntityInCargoExLoc(oldLoc, false, false, false, true, false, false))
9119 {
9120 newPlayer.GetHumanInventory().SetUserReservedLocation(this,oldLoc);
9121 }
9122 }
9123 else
9124 {
9125 newPlayer.GetHumanInventory().SetUserReservedLocation(this,oldLoc);
9126 }
9127 }
9128
9129 if (newPlayer.GetHumanInventory().FindUserReservedLocationIndex(this) >= 0)
9130 {
9131 int type = oldLoc.GetType();
9132 if (type == InventoryLocationType.CARGO || type == InventoryLocationType.PROXYCARGO)
9133 {
9134 oldLoc.GetParent().GetOnSetLock().Invoke(this);
9135 }
9136 else if (type == InventoryLocationType.ATTACHMENT)
9137 {
9138 oldLoc.GetParent().GetOnAttachmentSetLock().Invoke(this, oldLoc.GetSlot());
9139 }
9140 }
9141 if (!m_OldLocation)
9142 {
9143 m_OldLocation = new InventoryLocation;
9144 }
9145 m_OldLocation.Copy(oldLoc);
9146 }
9147 else
9148 {
9149 if (m_OldLocation)
9150 {
9151 m_OldLocation.Reset();
9152 }
9153 }
9154
9155 g_Game.GetAnalyticsClient().OnItemAttachedAtPlayer(this,"Hands");
9156 }
9157 else
9158 {
9159 if (newPlayer)
9160 {
9161 int resIndex = newPlayer.GetHumanInventory().FindCollidingUserReservedLocationIndex(this, newLoc);
9162 if (resIndex >= 0)
9163 {
9164 InventoryLocation il = new InventoryLocation;
9165 newPlayer.GetHumanInventory().GetUserReservedLocation(resIndex, il);
9166 ItemBase it = ItemBase.Cast(il.GetItem());
9167 newPlayer.GetHumanInventory().ClearUserReservedLocationAtIndex(resIndex);
9168 int rel_type = il.GetType();
9169 if (rel_type == InventoryLocationType.CARGO || rel_type == InventoryLocationType.PROXYCARGO)
9170 {
9171 il.GetParent().GetOnReleaseLock().Invoke(it);
9172 }
9173 else if (rel_type == InventoryLocationType.ATTACHMENT)
9174 {
9175 il.GetParent().GetOnAttachmentReleaseLock().Invoke(it, il.GetSlot());
9176 }
9177 //it.GetOnReleaseLock().Invoke(it);
9178 }
9179 }
9180 else if (oldPlayer && newLoc.GetType() == InventoryLocationType.GROUND && m_ThrowItemOnDrop)
9181 {
9182 //ThrowPhysically(oldPlayer, vector.Zero);
9183 m_ThrowItemOnDrop = false;
9184 }
9185
9186 if (m_OldLocation)
9187 {
9188 m_OldLocation.Reset();
9189 }
9190 }
9191
9192 if (oldLoc.GetType() == InventoryLocationType.TEMP)
9193 {
9194 PluginInventoryRepair.Cast(GetPlugin(PluginInventoryRepair)).Remove(oldLoc.GetItem());
9195 }
9196
9197 if (newLoc.GetType() == InventoryLocationType.TEMP)
9198 {
9199 PluginInventoryRepair.Cast(GetPlugin(PluginInventoryRepair)).Add(oldLoc.GetItem());
9200 }
9201 }
9202
9203 override void EOnContact(IEntity other, Contact extra)
9204 {
9206 {
9207 int liquidType = -1;
9208 float impactSpeed = ProcessImpactSoundEx(other, extra, m_ConfigWeight, m_ImpactSoundSurfaceHash, liquidType);
9209 if (impactSpeed > 0.0)
9210 {
9211 m_ImpactSpeed = impactSpeed;
9212 #ifndef SERVER
9213 PlayImpactSound(m_ConfigWeight, m_ImpactSpeed, m_ImpactSoundSurfaceHash);
9214 #else
9215 m_WantPlayImpactSound = true;
9216 SetSynchDirty();
9217 #endif
9218 m_CanPlayImpactSound = (liquidType == -1);// prevents further playing of the sound when the surface is a liquid type
9219 }
9220 }
9221
9222 #ifdef SERVER
9223 if (GetCompEM() && GetCompEM().IsPlugged())
9224 {
9225 if (GetCompEM().GetCordLength() < vector.Distance(GetPosition(), GetCompEM().GetEnergySource().GetPosition()))
9226 GetCompEM().UnplugThis();
9227 }
9228 #endif
9229 }
9230
9231 void RefreshPhysics();
9232
9233 override void OnCreatePhysics()
9234 {
9236 }
9237
9238 override void OnItemAttachmentSlotChanged(notnull InventoryLocation oldLoc, notnull InventoryLocation newLoc)
9239 {
9240
9241 }
9242 // -------------------------------------------------------------------------
9243 override void OnItemLocationChanged(EntityAI old_owner, EntityAI new_owner)
9244 {
9245 super.OnItemLocationChanged(old_owner, new_owner);
9246
9247 PlayerBase relatedPlayer = PlayerBase.Cast(old_owner);
9248 PlayerBase playerNew = PlayerBase.Cast(new_owner);
9249
9250 if (!relatedPlayer && playerNew)
9251 relatedPlayer = playerNew;
9252
9253 if (relatedPlayer && relatedPlayer.GetPerformedActionID() != -1)
9254 {
9255 ActionManagerBase actionMgr = relatedPlayer.GetActionManager();
9256 if (actionMgr)
9257 {
9258 ActionBase currentAction = actionMgr.GetRunningAction();
9259 if (currentAction)
9260 currentAction.OnItemLocationChanged(this);
9261 }
9262 }
9263
9264 Man ownerPlayerOld = null;
9265 Man ownerPlayerNew = null;
9266
9267 if (old_owner)
9268 {
9269 if (old_owner.IsMan())
9270 {
9271 ownerPlayerOld = Man.Cast(old_owner);
9272 }
9273 else
9274 {
9275 ownerPlayerOld = Man.Cast(old_owner.GetHierarchyRootPlayer());
9276 }
9277 }
9278 else
9279 {
9280 if (new_owner && IsElectricAppliance() && GetCompEM() && GetCompEM().IsPlugged())
9281 {
9282 ActionBase action = ActionManagerBase.GetAction(ActionRepositionPluggedItem);
9283
9284 if (!action || !playerNew || playerNew.GetPerformedActionID() != action.GetID())
9285 {
9286 GetCompEM().UnplugThis();
9287 }
9288 }
9289 }
9290
9291 if (new_owner)
9292 {
9293 if (new_owner.IsMan())
9294 {
9295 ownerPlayerNew = Man.Cast(new_owner);
9296 }
9297 else
9298 {
9299 ownerPlayerNew = Man.Cast(new_owner.GetHierarchyRootPlayer());
9300 }
9301 }
9302
9303 if (ownerPlayerOld != ownerPlayerNew)
9304 {
9305 if (ownerPlayerOld)
9306 {
9307 array<EntityAI> subItemsExit = new array<EntityAI>;
9308 GetInventory().EnumerateInventory(InventoryTraversalType.PREORDER,subItemsExit);
9309 for (int i = 0; i < subItemsExit.Count(); i++)
9310 {
9311 ItemBase itemExit = ItemBase.Cast(subItemsExit.Get(i));
9312 itemExit.OnInventoryExit(ownerPlayerOld);
9313 }
9314 }
9315
9316 if (ownerPlayerNew)
9317 {
9318 array<EntityAI> subItemsEnter = new array<EntityAI>;
9319 GetInventory().EnumerateInventory(InventoryTraversalType.PREORDER,subItemsEnter);
9320 for (int j = 0; j < subItemsEnter.Count(); j++)
9321 {
9322 ItemBase itemEnter = ItemBase.Cast(subItemsEnter.Get(j));
9323 itemEnter.OnInventoryEnter(ownerPlayerNew);
9324 }
9325 }
9326 }
9327 else if (ownerPlayerNew != null)
9328 {
9329 PlayerBase nplayer;
9330 if (PlayerBase.CastTo(nplayer, ownerPlayerNew))
9331 {
9332 array<EntityAI> subItemsUpdate = new array<EntityAI>;
9333 GetInventory().EnumerateInventory(InventoryTraversalType.PREORDER,subItemsUpdate);
9334 for (int k = 0; k < subItemsUpdate.Count(); k++)
9335 {
9336 ItemBase itemUpdate = ItemBase.Cast(subItemsUpdate.Get(k));
9337 itemUpdate.UpdateQuickbarShortcutVisibility(nplayer);
9338 }
9339 }
9340 }
9341
9342 if (old_owner)
9343 old_owner.OnChildItemRemoved(this);
9344 if (new_owner)
9345 new_owner.OnChildItemReceived(this);
9346 }
9347
9348 // -------------------------------------------------------------------------------
9349 override void EEDelete(EntityAI parent)
9350 {
9351 super.EEDelete(parent);
9352 PlayerBase player = PlayerBase.Cast(GetHierarchyRootPlayer());
9353 if (player)
9354 {
9355 OnInventoryExit(player);
9356
9357 if (player.IsAlive())
9358 {
9359 int r_index = player.GetHumanInventory().FindUserReservedLocationIndex(this);
9360 if (r_index >= 0)
9361 {
9362 InventoryLocation r_il = new InventoryLocation;
9363 player.GetHumanInventory().GetUserReservedLocation(r_index,r_il);
9364
9365 player.GetHumanInventory().ClearUserReservedLocationAtIndex(r_index);
9366 int r_type = r_il.GetType();
9367 if (r_type == InventoryLocationType.CARGO || r_type == InventoryLocationType.PROXYCARGO)
9368 {
9369 r_il.GetParent().GetOnReleaseLock().Invoke(this);
9370 }
9371 else if (r_type == InventoryLocationType.ATTACHMENT)
9372 {
9373 r_il.GetParent().GetOnAttachmentReleaseLock().Invoke(this, r_il.GetSlot());
9374 }
9375
9376 }
9377
9378 player.RemoveQuickBarEntityShortcut(this);
9379 }
9380 }
9381 }
9382 // -------------------------------------------------------------------------------
9383 override void EEKilled(Object killer)
9384 {
9385 super.EEKilled(killer);
9386
9388 if (killer && killer.IsFireplace() && CanExplodeInFire())
9389 {
9390 if (GetTemperature() >= GameConstants.ITEM_TEMPERATURE_TO_EXPLODE_MIN)
9391 {
9392 if (IsMagazine())
9393 {
9394 if (Magazine.Cast(this).GetAmmoCount() > 0)
9395 {
9396 ExplodeAmmo();
9397 }
9398 }
9399 else
9400 {
9401 Explode(DamageType.EXPLOSION);
9402 }
9403 }
9404 }
9405 }
9406
9407 override void OnWasAttached(EntityAI parent, int slot_id)
9408 {
9409 MiscGameplayFunctions.RemoveAllAttachedChildrenByTypename(this, {Bolt_Base});
9410
9411 super.OnWasAttached(parent, slot_id);
9412
9413 if (HasQuantity())
9414 UpdateNetSyncVariableFloat("m_VarQuantity", GetQuantityMin(), m_VarQuantityMax);
9415
9416 if (g_Game.IsServer() || !g_Game.IsMultiplayer()) // single player or server side multiplayer
9417 StartItemSoundServer(SoundConstants.ITEM_ATTACH, slot_id);
9418 }
9419
9420 override void OnWasDetached(EntityAI parent, int slot_id)
9421 {
9422 super.OnWasDetached(parent, slot_id);
9423
9424 if (HasQuantity())
9425 UpdateNetSyncVariableFloat("m_VarQuantity", GetQuantityMin(), m_VarQuantityMax);
9426
9427 if (g_Game.IsServer() || !g_Game.IsMultiplayer()) // single player or server side multiplayer
9428 StartItemSoundServer(SoundConstants.ITEM_DETACH, slot_id);
9429 }
9430
9431 override string ChangeIntoOnAttach(string slot)
9432 {
9433 int idx;
9434 TStringArray inventory_slots = new TStringArray;
9435 TStringArray attach_types = new TStringArray;
9436
9437 ConfigGetTextArray("ChangeInventorySlot",inventory_slots);
9438 if (inventory_slots.Count() < 1) //is string
9439 {
9440 inventory_slots.Insert(ConfigGetString("ChangeInventorySlot"));
9441 attach_types.Insert(ConfigGetString("ChangeIntoOnAttach"));
9442 }
9443 else //is array
9444 {
9445 ConfigGetTextArray("ChangeIntoOnAttach",attach_types);
9446 }
9447
9448 idx = inventory_slots.Find(slot);
9449 if (idx < 0)
9450 return "";
9451
9452 return attach_types.Get(idx);
9453 }
9454
9455 override string ChangeIntoOnDetach()
9456 {
9457 int idx = -1;
9458 string slot;
9459
9460 TStringArray inventory_slots = new TStringArray;
9461 TStringArray detach_types = new TStringArray;
9462
9463 this.ConfigGetTextArray("ChangeInventorySlot",inventory_slots);
9464 if (inventory_slots.Count() < 1) //is string
9465 {
9466 inventory_slots.Insert(this.ConfigGetString("ChangeInventorySlot"));
9467 detach_types.Insert(this.ConfigGetString("ChangeIntoOnDetach"));
9468 }
9469 else //is array
9470 {
9471 this.ConfigGetTextArray("ChangeIntoOnDetach",detach_types);
9472 if (detach_types.Count() < 1)
9473 detach_types.Insert(this.ConfigGetString("ChangeIntoOnDetach"));
9474 }
9475
9476 for (int i = 0; i < inventory_slots.Count(); i++)
9477 {
9478 slot = inventory_slots.Get(i);
9479 }
9480
9481 if (slot != "")
9482 {
9483 if (detach_types.Count() == 1)
9484 idx = 0;
9485 else
9486 idx = inventory_slots.Find(slot);
9487 }
9488 if (idx < 0)
9489 return "";
9490
9491 return detach_types.Get(idx);
9492 }
9493
9494 void ExplodeAmmo()
9495 {
9496 //timer
9497 ref Timer explode_timer = new Timer(CALL_CATEGORY_SYSTEM);
9498
9499 //min/max time
9500 float min_time = 1;
9501 float max_time = 3;
9502 float delay = Math.RandomFloat(min_time, max_time);
9503
9504 explode_timer.Run(delay, this, "DoAmmoExplosion");
9505 }
9506
9507 void DoAmmoExplosion()
9508 {
9509 Magazine magazine = Magazine.Cast(this);
9510 int pop_sounds_count = 6;
9511 string pop_sounds[ 6 ] = { "ammopops_1","ammopops_2","ammopops_3","ammopops_4","ammopops_5","ammopops_6" };
9512
9513 //play sound
9514 int sound_idx = Math.RandomInt(0, pop_sounds_count - 1);
9515 string sound_name = pop_sounds[ sound_idx ];
9516 g_Game.CreateSoundOnObject(this, sound_name, 20, false);
9517
9518 //remove ammo count
9519 magazine.ServerAddAmmoCount(-1);
9520
9521 //if condition then repeat -> ExplodeAmmo
9522 float min_temp_to_explode = 100; //min temperature for item to explode
9523
9524 if (magazine.GetAmmoCount() > 0 && GetTemperature() >= min_temp_to_explode) //TODO ? add check for parent -> fireplace
9525 {
9526 ExplodeAmmo();
9527 }
9528 }
9529
9530 // -------------------------------------------------------------------------------
9531 override void EEHitBy(TotalDamageResult damageResult, int damageType, EntityAI source, int component, string dmgZone, string ammo, vector modelPos, float speedCoef)
9532 {
9533 super.EEHitBy(damageResult, damageType, source, component, dmgZone, ammo, modelPos, speedCoef);
9534
9535 const int CHANCE_DAMAGE_CARGO = 4;
9536 const int CHANCE_DAMAGE_ATTACHMENT = 1;
9537 const int CHANCE_DAMAGE_NOTHING = 2;
9538
9539 if (IsClothing() || IsContainer() || IsItemTent())
9540 {
9541 float dmg = damageResult.GetDamage("","Health") * -0.5;
9542 int chances;
9543 int rnd;
9544
9545 if (GetInventory().GetCargo())
9546 {
9547 chances = CHANCE_DAMAGE_CARGO + CHANCE_DAMAGE_ATTACHMENT + CHANCE_DAMAGE_NOTHING;
9548 rnd = Math.RandomInt(0,chances);
9549
9550 if (rnd < CHANCE_DAMAGE_CARGO)
9551 {
9552 DamageItemInCargo(dmg);
9553 }
9554 else if (rnd < (chances - CHANCE_DAMAGE_NOTHING))
9555 {
9557 }
9558 }
9559 else
9560 {
9561 chances = CHANCE_DAMAGE_ATTACHMENT + CHANCE_DAMAGE_NOTHING;
9562 rnd = Math.RandomInt(0,chances);
9563
9564 if (rnd < CHANCE_DAMAGE_ATTACHMENT)
9565 {
9567 }
9568 }
9569 }
9570 }
9571
9572 bool DamageItemInCargo(float damage)
9573 {
9574 CargoBase cargo = GetInventory().GetCargo();
9575 if (cargo)
9576 {
9577 int item_count = cargo.GetItemCount();
9578 if (item_count > 0)
9579 {
9580 int random_pick = Math.RandomInt(0, item_count);
9581 ItemBase item = ItemBase.Cast(cargo.GetItem(random_pick));
9582 if (!item.IsExplosive())
9583 {
9584 item.AddHealth("","",damage);
9585 return true;
9586 }
9587 }
9588 }
9589 return false;
9590 }
9591
9592 bool DamageItemAttachments(float damage)
9593 {
9594 GameInventory inventory = GetInventory();
9595 int attachment_count = inventory.AttachmentCount();
9596 if (attachment_count > 0)
9597 {
9598 int random_pick = Math.RandomInt(0, attachment_count);
9599 ItemBase attachment = ItemBase.Cast(inventory.GetAttachmentFromIndex(random_pick));
9600 if (!attachment.IsExplosive())
9601 {
9602 attachment.AddHealth("","",damage);
9603 return true;
9604 }
9605 }
9606 return false;
9607 }
9608
9609 override bool IsSplitable()
9610 {
9611 return m_CanThisBeSplit;
9612 }
9613 //----------------
9614 override bool CanBeSplit()
9615 {
9616 if (IsSplitable() && (GetQuantity() > 1))
9617 return GetInventory().CanRemoveEntity();
9618
9619 return false;
9620 }
9621
9622 protected bool ShouldSplitQuantity(float quantity)
9623 {
9624 // don't call 'CanBeSplit' here, too strict and will introduce a freeze-crash when dismantling fence with a fireplace nearby
9625 if (!IsSplitable())
9626 return false;
9627
9628 // nothing to split?
9629 if (GetQuantity() <= 1)
9630 return false;
9631
9632 // check if we should re-use the item instead of creating a new copy?
9633 // implicit cast to int, if 'IsSplitable' returns true, these values are assumed ints
9634 int delta = GetQuantity() - quantity;
9635 if (delta == 0)
9636 return false;
9637
9638 // valid to split
9639 return true;
9640 }
9641
9642 override void SplitIntoStackMaxClient(EntityAI destination_entity, int slot_id )
9643 {
9644 if (g_Game.IsClient())
9645 {
9646 if (ScriptInputUserData.CanStoreInputUserData())
9647 {
9648 ScriptInputUserData ctx = new ScriptInputUserData;
9650 ctx.Write(1);
9651 ItemBase i1 = this; // @NOTE: workaround for correct serialization
9652 ctx.Write(i1);
9653 ctx.Write(destination_entity);
9654 ctx.Write(true);
9655 ctx.Write(slot_id);
9656 ctx.Send();
9657 }
9658 }
9659 else if (!g_Game.IsMultiplayer())
9660 {
9661 SplitIntoStackMax(destination_entity, slot_id, PlayerBase.Cast(g_Game.GetPlayer()));
9662 }
9663 }
9664
9665 void SplitIntoStackMax(EntityAI destination_entity, int slot_id, PlayerBase player)
9666 {
9667 float split_quantity_new;
9668 ItemBase new_item;
9669 float quantity = GetQuantity();
9670 float stack_max = GetTargetQuantityMax(slot_id);
9671 InventoryLocation loc = new InventoryLocation;
9672
9673 if (destination_entity && slot_id != -1 && InventorySlots.IsSlotIdValid(slot_id))
9674 {
9675 if (stack_max <= GetQuantity())
9676 split_quantity_new = stack_max;
9677 else
9678 split_quantity_new = GetQuantity();
9679
9680 if (ShouldSplitQuantity(split_quantity_new))
9681 {
9682 new_item = ItemBase.Cast(destination_entity.GetInventory().CreateAttachmentEx(this.GetType(), slot_id));
9683 if (new_item)
9684 {
9685 new_item.SetResultOfSplit(true);
9686 MiscGameplayFunctions.TransferItemProperties(this, new_item);
9687 AddQuantity(-split_quantity_new, false, true);
9688 new_item.SetQuantity(split_quantity_new, false, true);
9689 }
9690 }
9691 }
9692 else if (destination_entity && slot_id == -1)
9693 {
9694 if (quantity > stack_max)
9695 split_quantity_new = stack_max;
9696 else
9697 split_quantity_new = quantity;
9698
9699 if (ShouldSplitQuantity(split_quantity_new))
9700 {
9701 GameInventory destinationInventory = destination_entity.GetInventory();
9702 if (destinationInventory.FindFreeLocationFor(this, FindInventoryLocationType.ANY, loc))
9703 {
9704 Object o = destinationInventory.LocationCreateEntity(loc, GetType(), ECE_IN_INVENTORY, RF_DEFAULT);
9705 new_item = ItemBase.Cast(o);
9706 }
9707
9708 if (new_item)
9709 {
9710 new_item.SetResultOfSplit(true);
9711 MiscGameplayFunctions.TransferItemProperties(this, new_item);
9712 AddQuantity(-split_quantity_new, false, true);
9713 new_item.SetQuantity(split_quantity_new, false, true);
9714 }
9715 }
9716 }
9717 else
9718 {
9719 if (stack_max != 0)
9720 {
9721 if (stack_max < GetQuantity())
9722 {
9723 split_quantity_new = GetQuantity() - stack_max;
9724 }
9725
9726 if (split_quantity_new == 0)
9727 {
9728 if (!g_Game.IsMultiplayer())
9729 player.PhysicalPredictiveDropItem(this);
9730 else
9731 player.ServerDropEntity(this);
9732 return;
9733 }
9734
9735 if (ShouldSplitQuantity(split_quantity_new))
9736 {
9737 new_item = ItemBase.Cast(g_Game.CreateObjectEx(GetType(), player.GetWorldPosition(), ECE_PLACE_ON_SURFACE));
9738
9739 if (new_item)
9740 {
9741 new_item.SetResultOfSplit(true);
9742 MiscGameplayFunctions.TransferItemProperties(this, new_item);
9743 SetQuantity(split_quantity_new, false, true);
9744 new_item.SetQuantity(stack_max, false, true);
9745 new_item.PlaceOnSurface();
9746 }
9747 }
9748 }
9749 }
9750 }
9751
9752 override void SplitIntoStackMaxEx(EntityAI destination_entity, int slot_id)
9753 {
9754 float split_quantity_new;
9755 ItemBase new_item;
9756 float quantity = GetQuantity();
9757 float stack_max = GetTargetQuantityMax(slot_id);
9758 InventoryLocation loc = new InventoryLocation;
9759
9760 if (destination_entity && slot_id != -1 && InventorySlots.IsSlotIdValid(slot_id))
9761 {
9762 if (stack_max <= GetQuantity())
9763 split_quantity_new = stack_max;
9764 else
9765 split_quantity_new = GetQuantity();
9766
9767 if (ShouldSplitQuantity(split_quantity_new))
9768 {
9769 new_item = ItemBase.Cast(destination_entity.GetInventory().CreateAttachmentEx(this.GetType(), slot_id));
9770 if (new_item)
9771 {
9772 new_item.SetResultOfSplit(true);
9773 MiscGameplayFunctions.TransferItemProperties(this, new_item);
9774 AddQuantity(-split_quantity_new, false, true);
9775 new_item.SetQuantity(split_quantity_new, false, true);
9776 }
9777 }
9778 }
9779 else if (destination_entity && slot_id == -1)
9780 {
9781 if (quantity > stack_max)
9782 split_quantity_new = stack_max;
9783 else
9784 split_quantity_new = quantity;
9785
9786 if (ShouldSplitQuantity(split_quantity_new))
9787 {
9788 GameInventory destinationInventory = destination_entity.GetInventory();
9789 if (destinationInventory.FindFreeLocationFor(this, FindInventoryLocationType.ANY, loc))
9790 {
9791 Object o = destinationInventory.LocationCreateEntity(loc, GetType(), ECE_IN_INVENTORY, RF_DEFAULT);
9792 new_item = ItemBase.Cast(o);
9793 }
9794
9795 if (new_item)
9796 {
9797 new_item.SetResultOfSplit(true);
9798 MiscGameplayFunctions.TransferItemProperties(this, new_item);
9799 AddQuantity(-split_quantity_new, false, true);
9800 new_item.SetQuantity(split_quantity_new, false, true);
9801 }
9802 }
9803 }
9804 else
9805 {
9806 if (stack_max != 0)
9807 {
9808 if (stack_max < GetQuantity())
9809 {
9810 split_quantity_new = GetQuantity() - stack_max;
9811 }
9812
9813 if (ShouldSplitQuantity(split_quantity_new))
9814 {
9815 new_item = ItemBase.Cast(g_Game.CreateObjectEx(GetType(),GetWorldPosition(), ECE_PLACE_ON_SURFACE));
9816
9817 if (new_item)
9818 {
9819 new_item.SetResultOfSplit(true);
9820 MiscGameplayFunctions.TransferItemProperties(this, new_item);
9821 SetQuantity(split_quantity_new, false, true);
9822 new_item.SetQuantity(stack_max, false, true);
9823 new_item.PlaceOnSurface();
9824 }
9825 }
9826 }
9827 }
9828 }
9829
9830 void SplitIntoStackMaxToInventoryLocationClient(notnull InventoryLocation dst)
9831 {
9832 if (g_Game.IsClient())
9833 {
9834 if (ScriptInputUserData.CanStoreInputUserData())
9835 {
9836 ScriptInputUserData ctx = new ScriptInputUserData;
9838 ctx.Write(4);
9839 ItemBase thiz = this; // @NOTE: workaround for correct serialization
9840 ctx.Write(thiz);
9841 dst.WriteToContext(ctx);
9842 ctx.Send();
9843 }
9844 }
9845 else if (!g_Game.IsMultiplayer())
9846 {
9848 }
9849 }
9850
9851 void SplitIntoStackMaxCargoClient(EntityAI destination_entity, int idx, int row, int col)
9852 {
9853 if (g_Game.IsClient())
9854 {
9855 if (ScriptInputUserData.CanStoreInputUserData())
9856 {
9857 ScriptInputUserData ctx = new ScriptInputUserData;
9859 ctx.Write(2);
9860 ItemBase dummy = this; // @NOTE: workaround for correct serialization
9861 ctx.Write(dummy);
9862 ctx.Write(destination_entity);
9863 ctx.Write(true);
9864 ctx.Write(idx);
9865 ctx.Write(row);
9866 ctx.Write(col);
9867 ctx.Send();
9868 }
9869 }
9870 else if (!g_Game.IsMultiplayer())
9871 {
9872 SplitIntoStackMaxCargo(destination_entity, idx, row, col);
9873 }
9874 }
9875
9876 void SplitIntoStackMaxToInventoryLocation(notnull InventoryLocation dst)
9877 {
9879 }
9880
9881 ItemBase SplitIntoStackMaxToInventoryLocationEx(notnull InventoryLocation dst)
9882 {
9883 float quantity = GetQuantity();
9884 float split_quantity_new;
9885 ItemBase new_item;
9886 if (dst.IsValid())
9887 {
9888 int slot_id = dst.GetSlot();
9889 float stack_max = GetTargetQuantityMax(slot_id);
9890
9891 if (quantity > stack_max)
9892 split_quantity_new = stack_max;
9893 else
9894 split_quantity_new = quantity;
9895
9896 if (ShouldSplitQuantity(split_quantity_new))
9897 {
9898 new_item = ItemBase.Cast(GameInventory.LocationCreateEntity(dst, this.GetType(), ECE_IN_INVENTORY, RF_DEFAULT));
9899
9900 if (new_item)
9901 {
9902 new_item.SetResultOfSplit(true);
9903 MiscGameplayFunctions.TransferItemProperties(this,new_item);
9904 AddQuantity(-split_quantity_new, false, true);
9905 new_item.SetQuantity(split_quantity_new, false, true);
9906 }
9907
9908 return new_item;
9909 }
9910 }
9911
9912 return null;
9913 }
9914
9915 void SplitIntoStackMaxCargo(EntityAI destination_entity, int idx, int row, int col)
9916 {
9917 float quantity = GetQuantity();
9918 float split_quantity_new;
9919 ItemBase new_item;
9920 if (destination_entity)
9921 {
9922 float stackable = GetTargetQuantityMax();
9923 if (quantity > stackable)
9924 split_quantity_new = stackable;
9925 else
9926 split_quantity_new = quantity;
9927
9928 if (ShouldSplitQuantity(split_quantity_new))
9929 {
9930 new_item = ItemBase.Cast(destination_entity.GetInventory().CreateEntityInCargoEx(this.GetType(), idx, row, col, false));
9931 if (new_item)
9932 {
9933 new_item.SetResultOfSplit(true);
9934 MiscGameplayFunctions.TransferItemProperties(this,new_item);
9935 AddQuantity(-split_quantity_new, false, true);
9936 new_item.SetQuantity(split_quantity_new, false, true);
9937 }
9938 }
9939 }
9940 }
9941
9942 void SplitIntoStackMaxHandsClient(PlayerBase player)
9943 {
9944 if (g_Game.IsClient())
9945 {
9946 if (ScriptInputUserData.CanStoreInputUserData())
9947 {
9948 ScriptInputUserData ctx = new ScriptInputUserData;
9950 ctx.Write(3);
9951 ItemBase i1 = this; // @NOTE: workaround for correct serialization
9952 ctx.Write(i1);
9953 ItemBase destination_entity = this;
9954 ctx.Write(destination_entity);
9955 ctx.Write(true);
9956 ctx.Write(0);
9957 ctx.Send();
9958 }
9959 }
9960 else if (!g_Game.IsMultiplayer())
9961 {
9962 SplitIntoStackMaxHands(player);
9963 }
9964 }
9965
9966 void SplitIntoStackMaxHands(PlayerBase player)
9967 {
9968 float quantity = GetQuantity();
9969 float split_quantity_new;
9970 ref ItemBase new_item;
9971 if (player)
9972 {
9973 float stackable = GetTargetQuantityMax();
9974 if (quantity > stackable)
9975 split_quantity_new = stackable;
9976 else
9977 split_quantity_new = quantity;
9978
9979 if (ShouldSplitQuantity(split_quantity_new))
9980 {
9981 EntityAI in_hands = player.GetHumanInventory().CreateInHands(this.GetType());
9982 new_item = ItemBase.Cast(in_hands);
9983 if (new_item)
9984 {
9985 new_item.SetResultOfSplit(true);
9986 MiscGameplayFunctions.TransferItemProperties(this,new_item);
9987 AddQuantity(-split_quantity_new, false, true);
9988 new_item.SetQuantity(split_quantity_new, false, true);
9989 }
9990 }
9991 }
9992 }
9993
9994 void SplitItemToInventoryLocation(notnull InventoryLocation dst)
9995 {
9996 float quantity = GetQuantity();
9997 float split_quantity_new = Math.Floor(quantity * 0.5);
9998
9999 if (!ShouldSplitQuantity(split_quantity_new))
10000 return;
10001
10002 ItemBase new_item = ItemBase.Cast(GameInventory.LocationCreateEntity(dst, GetType(), ECE_IN_INVENTORY, RF_DEFAULT));
10003
10004 if (new_item)
10005 {
10006 if (new_item.GetQuantityMax() < split_quantity_new)
10007 {
10008 split_quantity_new = new_item.GetQuantityMax();
10009 }
10010
10011 new_item.SetResultOfSplit(true);
10012 MiscGameplayFunctions.TransferItemProperties(this, new_item);
10013
10014 if (dst.IsValid() && dst.GetType() == InventoryLocationType.ATTACHMENT && split_quantity_new > 1)
10015 {
10016 AddQuantity(-1, false, true);
10017 new_item.SetQuantity(1, false, true);
10018 }
10019 else
10020 {
10021 AddQuantity(-split_quantity_new, false, true);
10022 new_item.SetQuantity(split_quantity_new, false, true);
10023 }
10024 }
10025 }
10026
10027 void SplitItem(PlayerBase player)
10028 {
10029 float quantity = GetQuantity();
10030 float split_quantity_new = Math.Floor(quantity / 2);
10031
10032 if (!ShouldSplitQuantity(split_quantity_new))
10033 return;
10034
10035 InventoryLocation invloc = new InventoryLocation;
10036 bool found = player.GetInventory().FindFirstFreeLocationForNewEntity(GetType(), FindInventoryLocationType.ATTACHMENT, invloc);
10037
10038 ItemBase new_item;
10039 new_item = player.CreateCopyOfItemInInventoryOrGroundEx(this, true);
10040
10041 if (new_item)
10042 {
10043 if (new_item.GetQuantityMax() < split_quantity_new)
10044 {
10045 split_quantity_new = new_item.GetQuantityMax();
10046 }
10047 if (found && invloc.IsValid() && invloc.GetType() == InventoryLocationType.ATTACHMENT && split_quantity_new > 1)
10048 {
10049 AddQuantity(-1, false, true);
10050 new_item.SetQuantity(1, false, true);
10051 }
10052 else if (split_quantity_new > 1)
10053 {
10054 AddQuantity(-split_quantity_new, false, true);
10055 new_item.SetQuantity(split_quantity_new, false, true);
10056 }
10057 }
10058 }
10059
10061 void OnQuantityChanged(float delta)
10062 {
10063 SetWeightDirty();
10064 ItemBase parent = ItemBase.Cast(GetHierarchyParent());
10065
10066 if (parent)
10067 parent.OnAttachmentQuantityChangedEx(this, delta);
10068
10069 if (IsLiquidContainer())
10070 {
10071 if (GetQuantityNormalized() <= 0.0)
10072 {
10074 }
10075 else if (GetLiquidType() == LIQUID_NONE)
10076 {
10077 ErrorEx("Undefined liquid type quantity changed, please define liquid type first! Using init value.",ErrorExSeverity.INFO);
10079 }
10080 }
10081 }
10082
10085 {
10086 // insert code here
10087 }
10088
10090 void OnAttachmentQuantityChangedEx(ItemBase item , float delta)
10091 {
10093 }
10094
10095 override void EEHealthLevelChanged(int oldLevel, int newLevel, string zone)
10096 {
10097 super.EEHealthLevelChanged(oldLevel,newLevel,zone);
10098
10099 if (g_Game.IsServer())
10100 {
10101 if (newLevel == GameConstants.STATE_RUINED)
10102 {
10104 EntityAI parent = GetHierarchyParent();
10105 if (parent && parent.IsFireplace())
10106 {
10107 CargoBase cargo = GetInventory().GetCargo();
10108 if (cargo)
10109 {
10110 for (int i = 0; i < cargo.GetItemCount(); ++i)
10111 {
10112 parent.GetInventory().TakeEntityToInventory(InventoryMode.SERVER, FindInventoryLocationType.CARGO, cargo.GetItem(i));
10113 }
10114 }
10115 }
10116 }
10117
10118 if (IsResultOfSplit())
10119 {
10120 // reset the splitting result flag, return to normal item behavior
10121 SetResultOfSplit(false);
10122 return;
10123 }
10124
10125 if (m_Cleanness != 0 && oldLevel < newLevel && newLevel != 0)
10126 {
10127 SetCleanness(0);//unclean the item upon damage dealt
10128 }
10129 }
10130 }
10131
10132 // just the split? TODO: verify
10133 override void OnRightClick()
10134 {
10135 super.OnRightClick();
10136
10137 if (CanBeSplit() && !GetDayZGame().IsLeftCtrlDown() && !g_Game.GetPlayer().GetInventory().HasInventoryReservation(this,null))
10138 {
10139 if (g_Game.IsClient())
10140 {
10141 if (ScriptInputUserData.CanStoreInputUserData())
10142 {
10143 EntityAI root = GetHierarchyRoot();
10144 Man playerOwner = GetHierarchyRootPlayer();
10145 InventoryLocation dst = new InventoryLocation;
10146
10147 // 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
10148 if (!playerOwner && root && root == this)
10149 {
10151 }
10152 else
10153 {
10154 // 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
10155 GetInventory().GetCurrentInventoryLocation(dst);
10156 if (!dst.GetParent() || dst.GetParent() && !dst.GetParent().GetInventory().FindFreeLocationFor(this, FindInventoryLocationType.CARGO, dst))
10157 {
10158 PlayerBase player = PlayerBase.Cast(g_Game.GetPlayer());
10159 if (!player.GetInventory().FindFreeLocationFor(this, FindInventoryLocationType.CARGO, dst) || !playerOwner)
10160 {
10162 }
10163 else
10164 {
10165 dst.SetCargo(dst.GetParent(), this, dst.GetIdx(), dst.GetRow(), dst.GetCol(), dst.GetFlip());
10166 /* hacky solution to check reservation of "this" item instead of null since the gamecode is checking null against null and returning reservation=true incorrectly
10167 this shouldnt cause issues within this scope*/
10168 if (g_Game.GetPlayer().GetInventory().HasInventoryReservation(this, dst))
10169 {
10171 }
10172 else
10173 {
10174 g_Game.GetPlayer().GetInventory().AddInventoryReservationEx(null, dst, GameInventory.c_InventoryReservationTimeoutShortMS);
10175 }
10176 }
10177 }
10178 }
10179
10180 ScriptInputUserData ctx = new ScriptInputUserData;
10182 ctx.Write(4);
10183 ItemBase thiz = this; // @NOTE: workaround for correct serialization
10184 ctx.Write(thiz);
10185 dst.WriteToContext(ctx);
10186 ctx.Write(true); // dummy
10187 ctx.Send();
10188 }
10189 }
10190 else if (!g_Game.IsMultiplayer())
10191 {
10192 SplitItem(PlayerBase.Cast(g_Game.GetPlayer()));
10193 }
10194 }
10195 }
10196
10197 protected void SetInventoryLocationToVicinityOrCurrent(EntityAI root, inout InventoryLocation dst)
10198 {
10199 if (root)
10200 {
10201 vector m4[4];
10202 root.GetTransform(m4);
10203 dst.SetGround(this, m4);
10204 }
10205 else
10206 {
10207 GetInventory().GetCurrentInventoryLocation(dst);
10208 }
10209 }
10210
10211 override bool CanBeCombined(EntityAI other_item, bool reservation_check = true, bool stack_max_limit = false)
10212 {
10213 //TODO: delete check zero quantity check after fix double posts hands fsm events
10214 if (!other_item || GetType() != other_item.GetType() || (IsFullQuantity() && other_item.GetQuantity() > 0) || other_item == this)
10215 return false;
10216
10217 if (GetHealthLevel() == GameConstants.STATE_RUINED || other_item.GetHealthLevel() == GameConstants.STATE_RUINED)
10218 return false;
10219
10220 //can_this_be_combined = ConfigGetBool("canBeSplit");
10222 return false;
10223
10224
10225 Magazine mag = Magazine.Cast(this);
10226 if (mag)
10227 {
10228 if (mag.GetAmmoCount() >= mag.GetAmmoMax())
10229 return false;
10230
10231 if (stack_max_limit)
10232 {
10233 Magazine other_mag = Magazine.Cast(other_item);
10234 if (other_item)
10235 {
10236 if (mag.GetAmmoCount() + other_mag.GetAmmoCount() > mag.GetAmmoMax())
10237 return false;
10238 }
10239
10240 }
10241 }
10242 else
10243 {
10244 //TODO: delete check zero quantity check after fix double posts hands fsm events
10245 if (GetQuantity() >= GetQuantityMax() && other_item.GetQuantity() > 0 )
10246 return false;
10247
10248 if (stack_max_limit && (GetQuantity() + other_item.GetQuantity() > GetQuantityMax()))
10249 return false;
10250 }
10251
10252 PlayerBase player = null;
10253 if (CastTo(player, GetHierarchyRootPlayer())) //false when attached to player's attachment slot
10254 {
10255 if (player.GetInventory().HasAttachment(this))
10256 return false;
10257
10258 if (player.IsItemsToDelete())
10259 return false;
10260 }
10261
10262 if (reservation_check && (GetInventory().HasInventoryReservation(this, null) || other_item.GetInventory().HasInventoryReservation(other_item, null)))
10263 return false;
10264
10265 int slotID;
10266 string slotName;
10267 if (GetInventory().GetCurrentAttachmentSlotInfo(slotID,slotName) && GetHierarchyParent().GetInventory().GetSlotLock(slotID))
10268 return false;
10269
10270 return true;
10271 }
10272
10273 bool IsCombineAll(ItemBase other_item, bool use_stack_max = false)
10274 {
10275 return ComputeQuantityUsed(other_item, use_stack_max) == other_item.GetQuantity();
10276 }
10277
10278 bool IsResultOfSplit()
10279 {
10280 return m_IsResultOfSplit;
10281 }
10282
10283 void SetResultOfSplit(bool value)
10284 {
10285 m_IsResultOfSplit = value;
10286 }
10287
10288 int ComputeQuantityUsed(ItemBase other_item, bool use_stack_max = true)
10289 {
10290 return ComputeQuantityUsedEx(other_item, use_stack_max);
10291 }
10292
10293 float ComputeQuantityUsedEx(ItemBase other_item, bool use_stack_max = true)
10294 {
10295 float other_item_quantity = other_item.GetQuantity();
10296 float this_free_space;
10297
10298 float stack_max = GetQuantityMax();
10299
10300 this_free_space = stack_max - GetQuantity();
10301
10302 if (other_item_quantity > this_free_space)
10303 {
10304 return this_free_space;
10305 }
10306 else
10307 {
10308 return other_item_quantity;
10309 }
10310 }
10311
10312 override void CombineItemsEx(EntityAI entity2, bool use_stack_max = true)
10313 {
10314 CombineItems(ItemBase.Cast(entity2),use_stack_max);
10315 }
10316
10317 void CombineItems(ItemBase other_item, bool use_stack_max = true)
10318 {
10319 if (!CanBeCombined(other_item, false))
10320 return;
10321
10322 if (!IsMagazine() && other_item)
10323 {
10324 float quantity_used = ComputeQuantityUsedEx(other_item,use_stack_max);
10325 if (quantity_used != 0)
10326 {
10327 float hp1 = GetHealth01("","");
10328 float hp2 = other_item.GetHealth01("","");
10329 float hpResult = ((hp1*GetQuantity()) + (hp2*quantity_used));
10330 hpResult = hpResult / (GetQuantity() + quantity_used);
10331
10332 hpResult *= GetMaxHealth();
10333 Math.Round(hpResult);
10334 SetHealth("", "Health", hpResult);
10335
10336 AddQuantity(quantity_used);
10337 other_item.AddQuantity(-quantity_used);
10338 }
10339 }
10340 OnCombine(other_item);
10341 }
10342
10343 void OnCombine(ItemBase other_item)
10344 {
10345 #ifdef SERVER
10346 if (!GetHierarchyRootPlayer() && GetHierarchyParent())
10347 GetHierarchyParent().IncreaseLifetimeUp();
10348 #endif
10349 };
10350
10351 void GetRecipesActions(Man player, out TSelectableActionInfoArray outputList)
10352 {
10353 PlayerBase p = PlayerBase.Cast(player);
10354
10355 array<int> recipesIds = p.m_Recipes;
10356 PluginRecipesManager moduleRecipesManager = PluginRecipesManager.Cast(GetPlugin(PluginRecipesManager));
10357 if (moduleRecipesManager)
10358 {
10359 EntityAI itemInHands = player.GetEntityInHands();
10360 moduleRecipesManager.GetValidRecipes(ItemBase.Cast(this), ItemBase.Cast(itemInHands), recipesIds, p);
10361 }
10362
10363 for (int i = 0;i < recipesIds.Count(); i++)
10364 {
10365 int key = recipesIds.Get(i);
10366 string recipeName = moduleRecipesManager.GetRecipeName(key);
10367 outputList.Insert(new TSelectableActionInfo(SAT_CRAFTING, key, recipeName));
10368 }
10369 }
10370
10371 // -------------------------------------------------------------------------
10372 override void GetDebugActions(out TSelectableActionInfoArrayEx outputList)
10373 {
10374 super.GetDebugActions(outputList);
10375
10376 //quantity
10377 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.ADD_QUANTITY, "Quantity +20%", FadeColors.LIGHT_GREY));
10378 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.REMOVE_QUANTITY, "Quantity -20%", FadeColors.LIGHT_GREY));
10379 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SET_QUANTITY_0, "Set Quantity 0", FadeColors.LIGHT_GREY));
10380 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SET_MAX_QUANTITY, "Set Quantity Max", FadeColors.LIGHT_GREY));
10381 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SEPARATOR, "___________________________", FadeColors.RED));
10382
10383 //health
10384 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.ADD_HEALTH, "Health +20%", FadeColors.LIGHT_GREY));
10385 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.REMOVE_HEALTH, "Health -20%", FadeColors.LIGHT_GREY));
10386 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.DESTROY_HEALTH, "Health 0", FadeColors.LIGHT_GREY));
10387 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SEPARATOR, "___________________________", FadeColors.RED));
10388 //temperature
10389 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.ADD_TEMPERATURE, "Temperature +20", FadeColors.LIGHT_GREY));
10390 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.REMOVE_TEMPERATURE, "Temperature -20", FadeColors.LIGHT_GREY));
10391 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.FLIP_FROZEN, "Toggle Frozen", FadeColors.LIGHT_GREY));
10392 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SEPARATOR, "___________________________", FadeColors.RED));
10393
10394 //wet
10395 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.ADD_WETNESS, "Wetness +20", FadeColors.LIGHT_GREY));
10396 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.REMOVE_WETNESS, "Wetness -20", FadeColors.LIGHT_GREY));
10397 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SEPARATOR, "___________________________", FadeColors.RED));
10398
10399 //liquidtype
10400 if (IsLiquidContainer())
10401 {
10402 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.LIQUIDTYPE_UP, "LiquidType Next", FadeColors.LIGHT_GREY));
10403 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.LIQUIDTYPE_DOWN, "LiquidType Previous", FadeColors.LIGHT_GREY));
10404 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SEPARATOR, "___________________________", FadeColors.RED));
10405 }
10406
10407 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.MAKE_SPECIAL, "Make Special", FadeColors.LIGHT_GREY));
10408 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SEPARATOR, "___________________________", FadeColors.RED));
10409
10410 // watch
10411 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.WATCH_ITEM, "Watch (CTRL-Z)", FadeColors.LIGHT_GREY));
10412 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.WATCH_PLAYER, "Watch Player", FadeColors.LIGHT_GREY));
10413 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SEPARATOR, "___________________________", FadeColors.RED));
10414
10415 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.DELETE, "Delete", FadeColors.RED));
10416
10417 InventoryLocation loc = new InventoryLocation();
10418 GetInventory().GetCurrentInventoryLocation(loc);
10419 if (!loc || loc.GetType() == InventoryLocationType.GROUND)
10420 {
10421 if (Gizmo_IsSupported())
10422 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.GIZMO_OBJECT, "Gizmo Object", FadeColors.LIGHT_GREY));
10423 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.GIZMO_PHYSICS, "Gizmo Physics (SP Only)", FadeColors.LIGHT_GREY)); // intentionally allowed for testing physics desync
10424 }
10425
10426 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SEPARATOR, "___________________________", FadeColors.RED));
10427 }
10428
10429 // -------------------------------------------------------------------------
10430 // -------------------------------------------------------------------------
10431 // -------------------------------------------------------------------------
10432 override bool OnAction(int action_id, Man player, ParamsReadContext ctx)
10433 {
10434 super.OnAction(action_id, player, ctx);
10435
10436 if (g_Game.IsClient() || !g_Game.IsMultiplayer())
10437 {
10438 switch (action_id)
10439 {
10440 case EActions.GIZMO_OBJECT:
10441 if (GetGizmoApi())
10442 GetGizmoApi().SelectObject(this);
10443 return true;
10444 case EActions.GIZMO_PHYSICS:
10445 if (GetGizmoApi())
10446 GetGizmoApi().SelectPhysics(GetPhysics());
10447 return true;
10448 }
10449 }
10450
10451 if (g_Game.IsServer())
10452 {
10453 switch (action_id)
10454 {
10455 case EActions.DELETE:
10456 Delete();
10457 return true;
10458 }
10459 }
10460
10461 if (action_id >= EActions.RECIPES_RANGE_START && action_id < EActions.RECIPES_RANGE_END)
10462 {
10463 PluginRecipesManager plugin_recipes_manager = PluginRecipesManager.Cast(GetPlugin(PluginRecipesManager));
10464 int idWithoutOffset = action_id - EActions.RECIPES_RANGE_START;
10465 PlayerBase p = PlayerBase.Cast(player);
10466 if (EActions.RECIPES_RANGE_START < 1000)
10467 {
10468 float anim_length = plugin_recipes_manager.GetRecipeLengthInSecs(idWithoutOffset);
10469 float specialty_weight = plugin_recipes_manager.GetRecipeSpecialty(idWithoutOffset);
10470 }
10471 }
10472 #ifndef SERVER
10473 else if (action_id == EActions.WATCH_PLAYER)
10474 {
10475 PluginDeveloper.SetDeveloperItemClientEx(player);
10476 }
10477 #endif
10478 if (g_Game.IsServer())
10479 {
10480 if (action_id >= EActions.DEBUG_ITEM_WATCH_BUTTON_RANGE_START && action_id < EActions.DEBUG_ITEM_WATCH_BUTTON_RANGE_END)
10481 {
10482 int id = action_id - EActions.DEBUG_ITEM_WATCH_BUTTON_RANGE_START;
10483 OnDebugButtonPressServer(id + 1);
10484 }
10485
10486 else if (action_id >= EActions.DEBUG_AGENTS_RANGE_INJECT_START && action_id < EActions.DEBUG_AGENTS_RANGE_INJECT_END)
10487 {
10488 int agent_id = action_id - EActions.DEBUG_AGENTS_RANGE_INJECT_START;
10489 InsertAgent(agent_id,100);
10490 }
10491
10492 else if (action_id >= EActions.DEBUG_AGENTS_RANGE_REMOVE_START && action_id < EActions.DEBUG_AGENTS_RANGE_REMOVE_END)
10493 {
10494 int agent_id2 = action_id - EActions.DEBUG_AGENTS_RANGE_REMOVE_START;
10495 RemoveAgent(agent_id2);
10496 }
10497
10498 else if (action_id == EActions.ADD_QUANTITY)
10499 {
10500 if (IsMagazine())
10501 {
10502 Magazine mag = Magazine.Cast(this);
10503 mag.ServerSetAmmoCount(mag.GetAmmoCount() + mag.GetAmmoMax() * 0.2);
10504 }
10505 else
10506 {
10507 AddQuantity(GetQuantityMax() * 0.2);
10508 }
10509
10510 if (m_EM)
10511 {
10512 m_EM.AddEnergy(m_EM.GetEnergyMax() * 0.2);
10513 }
10514 //PrintVariables();
10515 }
10516
10517 else if (action_id == EActions.REMOVE_QUANTITY) //Quantity -20%
10518 {
10519 if (IsMagazine())
10520 {
10521 Magazine mag2 = Magazine.Cast(this);
10522 mag2.ServerSetAmmoCount(mag2.GetAmmoCount() - mag2.GetAmmoMax() * 0.2);
10523 }
10524 else
10525 {
10526 AddQuantity(- GetQuantityMax() * 0.2);
10527 }
10528 if (m_EM)
10529 {
10530 m_EM.AddEnergy(- m_EM.GetEnergyMax() * 0.2);
10531 }
10532 //PrintVariables();
10533 }
10534
10535 else if (action_id == EActions.SET_QUANTITY_0) //SetMaxQuantity
10536 {
10537 SetQuantity(0);
10538
10539 if (m_EM)
10540 {
10541 m_EM.SetEnergy(0);
10542 }
10543 }
10544
10545 else if (action_id == EActions.SET_MAX_QUANTITY) //SetMaxQuantity
10546 {
10548
10549 if (m_EM)
10550 {
10551 m_EM.SetEnergy(m_EM.GetEnergyMax());
10552 }
10553 }
10554
10555 else if (action_id == EActions.ADD_HEALTH)
10556 {
10557 AddHealth("","",GetMaxHealth("","Health")/5);
10558 }
10559 else if (action_id == EActions.REMOVE_HEALTH)
10560 {
10561 AddHealth("","",-GetMaxHealth("","Health")/5);
10562 }
10563 else if (action_id == EActions.DESTROY_HEALTH)
10564 {
10565 SetHealth01("","",0);
10566 }
10567 else if (action_id == EActions.WATCH_ITEM)
10568 {
10570 mid.RegisterDebugItem(ItemBase.Cast(this), PlayerBase.Cast(player));
10571 #ifdef DEVELOPER
10572 SetDebugDeveloper_item(this);
10573 #endif
10574 }
10575
10576 else if (action_id == EActions.ADD_TEMPERATURE)
10577 {
10578 AddTemperature(20);
10579 //PrintVariables();
10580 }
10581
10582 else if (action_id == EActions.REMOVE_TEMPERATURE)
10583 {
10584 AddTemperature(-20);
10585 //PrintVariables();
10586 }
10587
10588 else if (action_id == EActions.FLIP_FROZEN)
10589 {
10590 SetFrozen(!GetIsFrozen());
10591 //PrintVariables();
10592 }
10593
10594 else if (action_id == EActions.ADD_WETNESS)
10595 {
10596 AddWet(GetWetMax()/5);
10597 //PrintVariables();
10598 }
10599
10600 else if (action_id == EActions.REMOVE_WETNESS)
10601 {
10602 AddWet(-GetWetMax()/5);
10603 //PrintVariables();
10604 }
10605
10606 else if (action_id == EActions.LIQUIDTYPE_UP)
10607 {
10608 int curr_type = GetLiquidType();
10609 SetLiquidType(curr_type * 2);
10610 //AddWet(1);
10611 //PrintVariables();
10612 }
10613
10614 else if (action_id == EActions.LIQUIDTYPE_DOWN)
10615 {
10616 int curr_type2 = GetLiquidType();
10617 SetLiquidType(curr_type2 / 2);
10618 }
10619
10620 else if (action_id == EActions.MAKE_SPECIAL)
10621 {
10622 auto debugParams = DebugSpawnParams.WithPlayer(player);
10623 OnDebugSpawnEx(debugParams);
10624 }
10625
10626 }
10627
10628
10629 return false;
10630 }
10631
10632 // -------------------------------------------------------------------------
10633
10634
10637 void OnActivatedByTripWire();
10638
10640 void OnActivatedByItem(notnull ItemBase item);
10641
10642 //----------------------------------------------------------------
10643 //returns true if item is able to explode when put in fire
10644 bool CanExplodeInFire()
10645 {
10646 return false;
10647 }
10648
10649 //----------------------------------------------------------------
10650 bool CanEat()
10651 {
10652 return true;
10653 }
10654
10655 //----------------------------------------------------------------
10656 override bool IsIgnoredByConstruction()
10657 {
10658 return true;
10659 }
10660
10661 //----------------------------------------------------------------
10662 //has FoodStages in config?
10663 bool HasFoodStage()
10664 {
10665 string config_path = string.Format("CfgVehicles %1 Food FoodStages", GetType());
10666 return g_Game.ConfigIsExisting(config_path);
10667 }
10668
10670 FoodStage GetFoodStage()
10671 {
10672 return null;
10673 }
10674
10675 bool CanBeCooked()
10676 {
10677 return false;
10678 }
10679
10680 bool CanBeCookedOnStick()
10681 {
10682 return false;
10683 }
10684
10686 void RefreshAudioVisualsOnClient( CookingMethodType cooking_method, bool is_done, bool is_empty, bool is_burned );
10688
10689 //----------------------------------------------------------------
10690 bool CanRepair(ItemBase item_repair_kit)
10691 {
10692 PluginRepairing module_repairing = PluginRepairing.Cast(GetPlugin(PluginRepairing));
10693 return module_repairing.CanRepair(this, item_repair_kit);
10694 }
10695
10696 //----------------------------------------------------------------
10697 bool Repair(PlayerBase player, ItemBase item_repair_kit, float specialty_weight)
10698 {
10699 PluginRepairing module_repairing = PluginRepairing.Cast(GetPlugin(PluginRepairing));
10700 return module_repairing.Repair(player, this, item_repair_kit, specialty_weight);
10701 }
10702
10703 //----------------------------------------------------------------
10704 int GetItemSize()
10705 {
10706 /*
10707 vector v_size = this.ConfigGetVector("itemSize");
10708 int v_size_x = v_size[0];
10709 int v_size_y = v_size[1];
10710 int size = v_size_x * v_size_y;
10711 return size;
10712 */
10713
10714 return 1;
10715 }
10716
10717 //----------------------------------------------------------------
10718 //Override for allowing seemingly unallowed moves when two clients send a conflicting message simultaneously
10719 bool CanBeMovedOverride()
10720 {
10721 return m_CanBeMovedOverride;
10722 }
10723
10724 //----------------------------------------------------------------
10725 //Override for allowing seemingly unallowed moves when two clients send a conflicting message simultaneously
10726 void SetCanBeMovedOverride(bool setting)
10727 {
10728 m_CanBeMovedOverride = setting;
10729 }
10730
10731 //----------------------------------------------------------------
10739 void MessageToOwnerStatus(string text)
10740 {
10741 PlayerBase player = PlayerBase.Cast(this.GetHierarchyRootPlayer());
10742
10743 if (player)
10744 {
10745 player.MessageStatus(text);
10746 }
10747 }
10748
10749 //----------------------------------------------------------------
10757 void MessageToOwnerAction(string text)
10758 {
10759 PlayerBase player = PlayerBase.Cast(this.GetHierarchyRootPlayer());
10760
10761 if (player)
10762 {
10763 player.MessageAction(text);
10764 }
10765 }
10766
10767 //----------------------------------------------------------------
10775 void MessageToOwnerFriendly(string text)
10776 {
10777 PlayerBase player = PlayerBase.Cast(this.GetHierarchyRootPlayer());
10778
10779 if (player)
10780 {
10781 player.MessageFriendly(text);
10782 }
10783 }
10784
10785 //----------------------------------------------------------------
10793 void MessageToOwnerImportant(string text)
10794 {
10795 PlayerBase player = PlayerBase.Cast(this.GetHierarchyRootPlayer());
10796
10797 if (player)
10798 {
10799 player.MessageImportant(text);
10800 }
10801 }
10802
10803 override bool IsItemBase()
10804 {
10805 return true;
10806 }
10807
10808 // Checks if item is of questioned kind
10809 override bool KindOf(string tag)
10810 {
10811 bool found = false;
10812 string item_name = this.GetType();
10813 ref TStringArray item_tag_array = new TStringArray;
10814 g_Game.ConfigGetTextArray("cfgVehicles " + item_name + " itemInfo", item_tag_array);
10815
10816 int array_size = item_tag_array.Count();
10817 for (int i = 0; i < array_size; i++)
10818 {
10819 if (item_tag_array.Get(i) == tag)
10820 {
10821 found = true;
10822 break;
10823 }
10824 }
10825 return found;
10826 }
10827
10828
10829 override void OnRPC(PlayerIdentity sender, int rpc_type,ParamsReadContext ctx)
10830 {
10831 //Debug.Log("OnRPC called");
10832 super.OnRPC(sender, rpc_type,ctx);
10833
10834 //Play soundset for attachment locking (ActionLockAttachment.c)
10835 switch (rpc_type)
10836 {
10837 #ifndef SERVER
10838 case ERPCs.RPC_SOUND_LOCK_ATTACH:
10839 Param2<bool, string> p = new Param2<bool, string>(false, "");
10840
10841 if (!ctx.Read(p))
10842 return;
10843
10844 bool play = p.param1;
10845 string soundSet = p.param2;
10846
10847 if (play)
10848 {
10849 if (m_LockingSound)
10850 {
10852 {
10853 m_LockingSound = SEffectManager.PlaySound(soundSet, GetPosition(), 0, 0, true);
10854 }
10855 }
10856 else
10857 {
10858 m_LockingSound = SEffectManager.PlaySound(soundSet, GetPosition(), 0, 0, true);
10859 }
10860 }
10861 else
10862 {
10863 SEffectManager.DestroyEffect(m_LockingSound);
10864 }
10865
10866 break;
10867 #endif
10868
10869 }
10870
10871 if (GetWrittenNoteData())
10872 {
10873 GetWrittenNoteData().OnRPC(sender, rpc_type,ctx);
10874 }
10875 }
10876
10877 //-----------------------------
10878 // VARIABLE MANIPULATION SYSTEM
10879 //-----------------------------
10880 int NameToID(string name)
10881 {
10882 PluginVariables plugin = PluginVariables.Cast(GetPlugin(PluginVariables));
10883 return plugin.GetID(name);
10884 }
10885
10886 string IDToName(int id)
10887 {
10888 PluginVariables plugin = PluginVariables.Cast(GetPlugin(PluginVariables));
10889 return plugin.GetName(id);
10890 }
10891
10893 void OnSyncVariables(ParamsReadContext ctx)//with ID optimization
10894 {
10895 //Debug.Log("OnSyncVariables called for item: "+ ToString(this.GetType()),"varSync");
10896 //read the flags
10897 int varFlags;
10898 if (!ctx.Read(varFlags))
10899 return;
10900
10901 if (varFlags & ItemVariableFlags.FLOAT)
10902 {
10903 ReadVarsFromCTX(ctx);
10904 }
10905 }
10906
10907 override void SerializeNumericalVars(array<float> floats_out)
10908 {
10909 //some variables handled on EntityAI level already!
10910 super.SerializeNumericalVars(floats_out);
10911
10912 // the order of serialization must be the same as the order of de-serialization
10913 //--------------------------------------------
10914 if (IsVariableSet(VARIABLE_QUANTITY))
10915 {
10916 floats_out.Insert(m_VarQuantity);
10917 }
10918 //--------------------------------------------
10919 if (IsVariableSet(VARIABLE_WET))
10920 {
10921 floats_out.Insert(m_VarWet);
10922 }
10923 //--------------------------------------------
10924 if (IsVariableSet(VARIABLE_LIQUIDTYPE))
10925 {
10926 floats_out.Insert(m_VarLiquidType);
10927 }
10928 //--------------------------------------------
10929 if (IsVariableSet(VARIABLE_COLOR))
10930 {
10931 floats_out.Insert(m_ColorComponentR);
10932 floats_out.Insert(m_ColorComponentG);
10933 floats_out.Insert(m_ColorComponentB);
10934 floats_out.Insert(m_ColorComponentA);
10935 }
10936 //--------------------------------------------
10937 if (IsVariableSet(VARIABLE_CLEANNESS))
10938 {
10939 floats_out.Insert(m_Cleanness);
10940 }
10941 }
10942
10943 override void DeSerializeNumericalVars(array<float> floats)
10944 {
10945 //some variables handled on EntityAI level already!
10946 super.DeSerializeNumericalVars(floats);
10947
10948 // the order of serialization must be the same as the order of de-serialization
10949 int index = 0;
10950 int mask = Math.Round(floats.Get(index));
10951
10952 index++;
10953 //--------------------------------------------
10954 if (mask & VARIABLE_QUANTITY)
10955 {
10956 if (m_IsStoreLoad)
10957 {
10958 SetStoreLoadedQuantity(floats.Get(index));
10959 }
10960 else
10961 {
10962 float quantity = floats.Get(index);
10963 SetQuantity(quantity, true, false, false, false);
10964 }
10965 index++;
10966 }
10967 //--------------------------------------------
10968 if (mask & VARIABLE_WET)
10969 {
10970 float wet = floats.Get(index);
10971 SetWet(wet);
10972 index++;
10973 }
10974 //--------------------------------------------
10975 if (mask & VARIABLE_LIQUIDTYPE)
10976 {
10977 int liquidtype = Math.Round(floats.Get(index));
10978 SetLiquidType(liquidtype);
10979 index++;
10980 }
10981 //--------------------------------------------
10982 if (mask & VARIABLE_COLOR)
10983 {
10984 m_ColorComponentR = Math.Round(floats.Get(index));
10985 index++;
10986 m_ColorComponentG = Math.Round(floats.Get(index));
10987 index++;
10988 m_ColorComponentB = Math.Round(floats.Get(index));
10989 index++;
10990 m_ColorComponentA = Math.Round(floats.Get(index));
10991 index++;
10992 }
10993 //--------------------------------------------
10994 if (mask & VARIABLE_CLEANNESS)
10995 {
10996 int cleanness = Math.Round(floats.Get(index));
10997 SetCleanness(cleanness);
10998 index++;
10999 }
11000 }
11001
11002 override void WriteVarsToCTX(ParamsWriteContext ctx)
11003 {
11004 super.WriteVarsToCTX(ctx);
11005
11006 //--------------------------------------------
11007 if (IsVariableSet(VARIABLE_QUANTITY))
11008 {
11009 ctx.Write(GetQuantity());
11010 }
11011 //--------------------------------------------
11012 if (IsVariableSet(VARIABLE_WET))
11013 {
11014 ctx.Write(GetWet());
11015 }
11016 //--------------------------------------------
11017 if (IsVariableSet(VARIABLE_LIQUIDTYPE))
11018 {
11019 ctx.Write(GetLiquidType());
11020 }
11021 //--------------------------------------------
11022 if (IsVariableSet(VARIABLE_COLOR))
11023 {
11024 int r,g,b,a;
11025 GetColor(r,g,b,a);
11026 ctx.Write(r);
11027 ctx.Write(g);
11028 ctx.Write(b);
11029 ctx.Write(a);
11030 }
11031 //--------------------------------------------
11032 if (IsVariableSet(VARIABLE_CLEANNESS))
11033 {
11034 ctx.Write(GetCleanness());
11035 }
11036 }
11037
11038 override bool ReadVarsFromCTX(ParamsReadContext ctx, int version = -1)//with ID optimization
11039 {
11040 if (!super.ReadVarsFromCTX(ctx,version))
11041 return false;
11042
11043 int intValue;
11044 float value;
11045
11046 if (version < 140)
11047 {
11048 if (!ctx.Read(intValue))
11049 return false;
11050
11051 m_VariablesMask = intValue;
11052 }
11053
11054 if (m_VariablesMask & VARIABLE_QUANTITY)
11055 {
11056 if (!ctx.Read(value))
11057 return false;
11058
11059 if (IsStoreLoad())
11060 {
11062 }
11063 else
11064 {
11065 SetQuantity(value, true, false, false, false);
11066 }
11067 }
11068 //--------------------------------------------
11069 if (version < 140)
11070 {
11071 if (m_VariablesMask & VARIABLE_TEMPERATURE)
11072 {
11073 if (!ctx.Read(value))
11074 return false;
11075 SetTemperatureDirect(value);
11076 }
11077 }
11078 //--------------------------------------------
11079 if (m_VariablesMask & VARIABLE_WET)
11080 {
11081 if (!ctx.Read(value))
11082 return false;
11083 SetWet(value);
11084 }
11085 //--------------------------------------------
11086 if (m_VariablesMask & VARIABLE_LIQUIDTYPE)
11087 {
11088 if (!ctx.Read(intValue))
11089 return false;
11090 SetLiquidType(intValue);
11091 }
11092 //--------------------------------------------
11093 if (m_VariablesMask & VARIABLE_COLOR)
11094 {
11095 int r,g,b,a;
11096 if (!ctx.Read(r))
11097 return false;
11098 if (!ctx.Read(g))
11099 return false;
11100 if (!ctx.Read(b))
11101 return false;
11102 if (!ctx.Read(a))
11103 return false;
11104
11105 SetColor(r,g,b,a);
11106 }
11107 //--------------------------------------------
11108 if (m_VariablesMask & VARIABLE_CLEANNESS)
11109 {
11110 if (!ctx.Read(intValue))
11111 return false;
11112 SetCleanness(intValue);
11113 }
11114 //--------------------------------------------
11115 if (version >= 138 && version < 140)
11116 {
11117 if (m_VariablesMask & VARIABLE_TEMPERATURE)
11118 {
11119 if (!ctx.Read(intValue))
11120 return false;
11121 SetFrozen(intValue);
11122 }
11123 }
11124
11125 return true;
11126 }
11127
11128 //----------------------------------------------------------------
11129 override bool OnStoreLoad(ParamsReadContext ctx, int version)
11130 {
11131 m_IsStoreLoad = true;
11133 {
11134 m_FixDamageSystemInit = true;
11135 }
11136
11137 if (!super.OnStoreLoad(ctx, version))
11138 {
11139 m_IsStoreLoad = false;
11140 return false;
11141 }
11142
11143 if (version >= 114)
11144 {
11145 bool hasQuickBarIndexSaved;
11146
11147 if (!ctx.Read(hasQuickBarIndexSaved))
11148 {
11149 m_IsStoreLoad = false;
11150 return false;
11151 }
11152
11153 if (hasQuickBarIndexSaved)
11154 {
11155 int itmQBIndex;
11156
11157 //Load quickbar item bind
11158 if (!ctx.Read(itmQBIndex))
11159 {
11160 m_IsStoreLoad = false;
11161 return false;
11162 }
11163
11164 PlayerBase parentPlayer = PlayerBase.Cast(GetHierarchyRootPlayer());
11165 if (itmQBIndex != -1 && parentPlayer)
11166 parentPlayer.SetLoadedQuickBarItemBind(this, itmQBIndex);
11167 }
11168 }
11169 else
11170 {
11171 // Backup of how it used to be
11172 PlayerBase player;
11173 int itemQBIndex;
11174 if (version == int.MAX)
11175 {
11176 if (!ctx.Read(itemQBIndex))
11177 {
11178 m_IsStoreLoad = false;
11179 return false;
11180 }
11181 }
11182 else if (Class.CastTo(player, GetHierarchyRootPlayer()))
11183 {
11184 //Load quickbar item bind
11185 if (!ctx.Read(itemQBIndex))
11186 {
11187 m_IsStoreLoad = false;
11188 return false;
11189 }
11190 if (itemQBIndex != -1 && player)
11191 player.SetLoadedQuickBarItemBind(this,itemQBIndex);
11192 }
11193 }
11194
11195 if (version < 140)
11196 {
11197 // variable management system
11198 if (!LoadVariables(ctx, version))
11199 {
11200 m_IsStoreLoad = false;
11201 return false;
11202 }
11203 }
11204
11205 //agent trasmission system
11206 if (!LoadAgents(ctx, version))
11207 {
11208 m_IsStoreLoad = false;
11209 return false;
11210 }
11211 if (version >= 132)
11212 {
11213 RemotelyActivatedItemBehaviour raib = GetRemotelyActivatedItemBehaviour();
11214 if (raib)
11215 {
11216 if (!raib.OnStoreLoad(ctx,version))
11217 {
11218 m_IsStoreLoad = false;
11219 return false;
11220 }
11221 }
11222 }
11223
11224 m_IsStoreLoad = false;
11225 return true;
11226 }
11227
11228 //----------------------------------------------------------------
11229
11230 override void OnStoreSave(ParamsWriteContext ctx)
11231 {
11232 super.OnStoreSave(ctx);
11233
11234 PlayerBase player;
11235 if (PlayerBase.CastTo(player,GetHierarchyRootPlayer()))
11236 {
11237 ctx.Write(true); // Keep track of if we should actually read this in or not
11238 //Save quickbar item bind
11239 int itemQBIndex = -1;
11240 itemQBIndex = player.FindQuickBarEntityIndex(this);
11241 ctx.Write(itemQBIndex);
11242 }
11243 else
11244 {
11245 ctx.Write(false); // Keep track of if we should actually read this in or not
11246 }
11247
11248 SaveAgents(ctx);//agent trasmission system
11249
11250 RemotelyActivatedItemBehaviour raib = GetRemotelyActivatedItemBehaviour();
11251 if (raib)
11252 {
11253 raib.OnStoreSave(ctx);
11254 }
11255 }
11256 //----------------------------------------------------------------
11257
11258 override void AfterStoreLoad()
11259 {
11260 super.AfterStoreLoad();
11261
11263 {
11265 }
11266
11267 if (GetStoreLoadedQuantity() != float.LOWEST)
11268 {
11270 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
11271 }
11272 }
11273
11274 override void EEOnAfterLoad()
11275 {
11276 super.EEOnAfterLoad();
11277
11279 {
11280 m_FixDamageSystemInit = false;
11281 }
11282
11285 }
11286
11287 bool CanBeDisinfected()
11288 {
11289 return false;
11290 }
11291
11292
11293 //----------------------------------------------------------------
11294 override void OnVariablesSynchronized()
11295 {
11296 if (m_Initialized)
11297 {
11298 #ifdef PLATFORM_CONSOLE
11299 //bruteforce it is
11300 if (IsSplitable())
11301 {
11302 UIScriptedMenu menu = g_Game.GetUIManager().FindMenu(MENU_INVENTORY);
11303 if (menu)
11304 {
11305 menu.Refresh();
11306 }
11307 }
11308 #endif
11309 }
11310
11312 {
11313 PlayImpactSound(m_ConfigWeight, m_ImpactSpeed, m_ImpactSoundSurfaceHash);
11314 m_WantPlayImpactSound = false;
11315 }
11316
11318 {
11319 SetWeightDirty();
11321 }
11322 if (m_VarWet != m_VarWetPrev)
11323 {
11326 }
11327
11328 if (m_SoundSyncPlay != 0)
11329 {
11332
11333 m_SoundSyncPlay = 0;
11334 m_SoundSyncSlotID = -1;
11335 }
11336 if (m_SoundSyncStop != 0)
11337 {
11339 m_ItemSoundHandler.StopItemSoundClient(m_SoundSyncStop);
11340 m_SoundSyncStop = 0;
11341 }
11342
11343 super.OnVariablesSynchronized();
11344 }
11345
11346 //------------------------- Quantity
11347 //----------------------------------------------------------------
11349 override bool SetQuantity(float value, bool destroy_config = true, bool destroy_forced = false, bool allow_client = false, bool clamp_to_stack_max = true)
11350 {
11351 if (!IsServerCheck(allow_client))
11352 return false;
11353
11354 if (!HasQuantity())
11355 return false;
11356
11357 float min = GetQuantityMin();
11358 float max = GetQuantityMax();
11359
11360 if (value <= (min + 0.001))
11361 value = min;
11362
11363 if (value == min)
11364 {
11365 if (destroy_config)
11366 {
11367 bool dstr = ConfigGetBool("varQuantityDestroyOnMin");
11368 if (dstr)
11369 {
11370 m_VarQuantity = Math.Clamp(value, min, max);
11371 this.Delete();
11372 return true;
11373 }
11374 }
11375 else if (destroy_forced)
11376 {
11377 m_VarQuantity = Math.Clamp(value, min, max);
11378 this.Delete();
11379 return true;
11380 }
11381 // we get here if destroy_config IS true AND dstr(config destroy param) IS false;
11382 RemoveAllAgents();//we remove all agents when we got to the min value, but the item is not getting deleted
11383 }
11384
11385 float delta = m_VarQuantity;
11386 m_VarQuantity = Math.Clamp(value, min, max);
11387
11388 if (g_Game.IsServer() || !g_Game.IsMultiplayer()) // single player or server side multiplayer
11389 {
11390 EntityAI parent = GetHierarchyRoot();
11391 InventoryLocation iLoc = new InventoryLocation();
11392 GetInventory().GetCurrentInventoryLocation(iLoc);
11393 if (iLoc && iLoc.IsValid() && delta != m_VarQuantity)
11394 {
11395 int iLocSlot = iLoc.GetSlot();
11396 if (delta < m_VarQuantity && iLoc.GetType() != InventoryLocationType.GROUND)
11397 {
11398 StartItemSoundServer(SoundConstants.ITEM_ATTACH, iLocSlot);
11399 }
11400 if (delta > m_VarQuantity && m_VarQuantity != 0 && !IsPrepareToDelete() && iLoc.GetType() == InventoryLocationType.ATTACHMENT)
11401 {
11402 StartItemSoundServer(SoundConstants.ITEM_DETACH, iLocSlot);
11403 }
11404 }
11405 }
11406
11407 if (GetStoreLoadedQuantity() == float.LOWEST)//any other value means we are setting quantity from storage
11408 {
11409 delta = m_VarQuantity - delta;
11410
11411 if (delta)
11412 OnQuantityChanged(delta);
11413 }
11414
11415 SetVariableMask(VARIABLE_QUANTITY);
11416
11417 return false;
11418 }
11419
11420 //----------------------------------------------------------------
11422 bool AddQuantity(float value, bool destroy_config = true, bool destroy_forced = false)
11423 {
11424 return SetQuantity(GetQuantity() + value, destroy_config, destroy_forced);
11425 }
11426 //----------------------------------------------------------------
11427 void SetQuantityMax()
11428 {
11429 float max = GetQuantityMax();
11430 SetQuantity(max);
11431 }
11432
11433 override void SetQuantityToMinimum()
11434 {
11435 float min = GetQuantityMin();
11436 SetQuantity(min);
11437 }
11438 //----------------------------------------------------------------
11440 override void SetQuantityNormalized(float value, bool destroy_config = true, bool destroy_forced = false)
11441 {
11442 float value_clamped = Math.Clamp(value, 0, 1);//just to make sure
11443 int result = Math.Round(Math.Lerp(GetQuantityMin(), GetQuantityMax(), value_clamped));
11444 SetQuantity(result, destroy_config, destroy_forced);
11445 }
11446
11447 //----------------------------------------------------------------
11449 override float GetQuantityNormalized()
11450 {
11451 return Math.InverseLerp(GetQuantityMin(), GetQuantityMax(),m_VarQuantity);
11452 }
11453
11455 {
11456 return GetQuantityNormalized();
11457 }
11458
11459 /*void SetAmmoNormalized(float value)
11460 {
11461 float value_clamped = Math.Clamp(value, 0, 1);
11462 Magazine this_mag = Magazine.Cast(this);
11463 int max_rounds = this_mag.GetAmmoMax();
11464 int result = value * max_rounds;//can the rounded if higher precision is required
11465 this_mag.SetAmmoCount(result);
11466 }*/
11467 //----------------------------------------------------------------
11468 override int GetQuantityMax()
11469 {
11470 int slot = -1;
11471 GameInventory inventory = GetInventory();
11472 if (inventory)
11473 {
11474 InventoryLocation il = new InventoryLocation;
11475 inventory.GetCurrentInventoryLocation(il);
11476 slot = il.GetSlot();
11477 }
11478
11479 return GetTargetQuantityMax(slot);
11480 }
11481
11482 override int GetTargetQuantityMax(int attSlotID = -1)
11483 {
11484 float quantity_max = 0;
11485
11486 if (IsSplitable()) //only stackable/splitable items can check for stack size
11487 {
11488 if (attSlotID != -1)
11489 quantity_max = InventorySlots.GetStackMaxForSlotId(attSlotID);
11490
11491 if (quantity_max <= 0)
11492 quantity_max = m_VarStackMax;
11493 }
11494
11495 if (quantity_max <= 0)
11496 quantity_max = m_VarQuantityMax;
11497
11498 return quantity_max;
11499 }
11500 //----------------------------------------------------------------
11501 override int GetQuantityMin()
11502 {
11503 return m_VarQuantityMin;
11504 }
11505 //----------------------------------------------------------------
11506 int GetQuantityInit()
11507 {
11508 return m_VarQuantityInit;
11509 }
11510
11511 //----------------------------------------------------------------
11512 override bool HasQuantity()
11513 {
11514 return !(GetQuantityMax() - GetQuantityMin() == 0);
11515 }
11516
11517 override float GetQuantity()
11518 {
11519 return m_VarQuantity;
11520 }
11521
11522 bool IsFullQuantity()
11523 {
11524 return GetQuantity() >= GetQuantityMax();
11525 }
11526
11527 //Calculates weight of single item without attachments and cargo
11528 override float GetSingleInventoryItemWeightEx()
11529 {
11530 //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
11531 float weightEx = GetWeightEx();//overall weight of the item
11532 float special = GetInventoryAndCargoWeight();//cargo and attachment weight
11533 return weightEx - special;
11534 }
11535
11536 // Obsolete, use GetSingleInventoryItemWeightEx() instead
11538 {
11540 }
11541
11542 override protected float GetWeightSpecialized(bool forceRecalc = false)
11543 {
11544 if (IsSplitable()) //quantity determines size of the stack
11545 {
11546 #ifdef DEVELOPER
11547 if (WeightDebug.m_VerbosityFlags & WeightDebugType.RECALC_FORCED)
11548 {
11549 WeightDebugData data1 = WeightDebug.GetWeightDebug(this);
11550 data1.SetCalcDetails("TIB1: " + GetConfigWeightModifiedDebugText() +" * " + GetQuantity()+"(quantity)");
11551 }
11552 #endif
11553
11554 return GetQuantity() * GetConfigWeightModified();
11555 }
11556 else if (HasEnergyManager())// items with energy manager
11557 {
11558 #ifdef DEVELOPER
11559 if (WeightDebug.m_VerbosityFlags & WeightDebugType.RECALC_FORCED)
11560 {
11561 WeightDebugData data2 = WeightDebug.GetWeightDebug(this);
11562 data2.SetCalcDetails("TIB2: "+super.GetWeightSpecialized(forceRecalc)+"(contents weight) + " + GetConfigWeightModifiedDebugText() +" + " + GetCompEM().GetEnergy()+"(energy) * " + ConfigGetFloat("weightPerQuantityUnit") +"(weightPerQuantityUnit)");
11563 }
11564 #endif
11565 return super.GetWeightSpecialized(forceRecalc) + (GetCompEM().GetEnergy() * ConfigGetFloat("weightPerQuantityUnit")) + GetConfigWeightModified();
11566 }
11567 else//everything else
11568 {
11569 #ifdef DEVELOPER
11570 if (WeightDebug.m_VerbosityFlags & WeightDebugType.RECALC_FORCED)
11571 {
11572 WeightDebugData data3 = WeightDebug.GetWeightDebug(this);
11573 data3.SetCalcDetails("TIB3: "+super.GetWeightSpecialized(forceRecalc)+"(contents weight) + " + GetConfigWeightModifiedDebugText() +" + " + GetQuantity()+"(quantity) * " + ConfigGetFloat("weightPerQuantityUnit") +"(weightPerQuantityUnit))");
11574 }
11575 #endif
11576 return super.GetWeightSpecialized(forceRecalc) + (GetQuantity() * ConfigGetFloat("weightPerQuantityUnit")) + GetConfigWeightModified();
11577 }
11578 }
11579
11581 int GetNumberOfItems()
11582 {
11583 int item_count = 0;
11584 ItemBase item;
11585
11586 GameInventory inventory = GetInventory();
11587 CargoBase cargo = inventory.GetCargo();
11588 if (cargo != NULL)
11589 {
11590 item_count = cargo.GetItemCount();
11591 }
11592
11593 int nAttachments = inventory.AttachmentCount();
11594 for (int i = 0; i < nAttachments; ++i)
11595 {
11596 Class.CastTo(item, inventory.GetAttachmentFromIndex(i));
11597 if (item)
11598 item_count += item.GetNumberOfItems();
11599 }
11600 return item_count;
11601 }
11602
11604 float GetUnitWeight(bool include_wetness = true)
11605 {
11606 float weight = 0;
11607 float wetness = 1;
11608 if (include_wetness)
11609 wetness += GetWet();
11610 if (IsSplitable()) //quantity determines size of the stack
11611 {
11612 weight = wetness * m_ConfigWeight;
11613 }
11614 else if (IsLiquidContainer()) //is a liquid container, default liquid weight is set to 1. May revisit later?
11615 {
11616 weight = 1;
11617 }
11618 return weight;
11619 }
11620
11621 //-----------------------------------------------------------------
11622
11623 override void ClearInventory()
11624 {
11625 GameInventory inventory = GetInventory();
11626 if ((g_Game.IsServer() || !g_Game.IsMultiplayer()) && inventory)
11627 {
11628 array<EntityAI> items = new array<EntityAI>;
11629 inventory.EnumerateInventory(InventoryTraversalType.INORDER, items);
11630 for (int i = 0; i < items.Count(); ++i)
11631 {
11632 ItemBase item = ItemBase.Cast(items.Get(i));
11633 if (item)
11634 {
11635 g_Game.ObjectDelete(item);
11636 }
11637 }
11638 }
11639 }
11640
11641 //------------------------- Energy
11642
11643 //----------------------------------------------------------------
11644 float GetEnergy()
11645 {
11646 float energy = 0;
11647 if (HasEnergyManager())
11648 {
11649 energy = GetCompEM().GetEnergy();
11650 }
11651 return energy;
11652 }
11653
11654
11655 override void OnEnergyConsumed()
11656 {
11657 super.OnEnergyConsumed();
11658
11660 }
11661
11662 override void OnEnergyAdded()
11663 {
11664 super.OnEnergyAdded();
11665
11667 }
11668
11669 // Converts energy (from Energy Manager) to quantity, if enabled.
11671 {
11672 if (g_Game.IsServer() && HasEnergyManager() && GetCompEM().HasConversionOfEnergyToQuantity())
11673 {
11674 if (HasQuantity())
11675 {
11676 float energy_0to1 = GetCompEM().GetEnergy0To1();
11677 SetQuantityNormalized(energy_0to1);
11678 }
11679 }
11680 }
11681
11682 //----------------------------------------------------------------
11683 float GetHeatIsolationInit()
11684 {
11685 return ConfigGetFloat("heatIsolation");
11686 }
11687
11688 float GetHeatIsolation()
11689 {
11690 return m_HeatIsolation;
11691 }
11692
11693 float GetDryingIncrement(string pIncrementName)
11694 {
11695 string paramPath = string.Format("CfgVehicles %1 EnvironmentWetnessIncrements Drying %2", GetType(), pIncrementName);
11696 if (g_Game.ConfigIsExisting(paramPath))
11697 return g_Game.ConfigGetFloat(paramPath);
11698
11699 return 0.0;
11700 }
11701
11702 float GetSoakingIncrement(string pIncrementName)
11703 {
11704 string paramPath = string.Format("CfgVehicles %1 EnvironmentWetnessIncrements Soaking %2", GetType(), pIncrementName);
11705 if (g_Game.ConfigIsExisting(paramPath))
11706 return g_Game.ConfigGetFloat(paramPath);
11707
11708 return 0.0;
11709 }
11710 //----------------------------------------------------------------
11711 override void SetWet(float value, bool allow_client = false)
11712 {
11713 if (!IsServerCheck(allow_client))
11714 return;
11715
11716 float min = GetWetMin();
11717 float max = GetWetMax();
11718
11719 float previousValue = m_VarWet;
11720
11721 m_VarWet = Math.Clamp(value, min, max);
11722
11723 if (previousValue != m_VarWet)
11724 {
11725 SetVariableMask(VARIABLE_WET);
11726 OnWetChanged(m_VarWet, previousValue);
11727 }
11728 }
11729 //----------------------------------------------------------------
11730 override void AddWet(float value)
11731 {
11732 SetWet(GetWet() + value);
11733 }
11734 //----------------------------------------------------------------
11735 override void SetWetMax()
11736 {
11738 }
11739 //----------------------------------------------------------------
11740 override float GetWet()
11741 {
11742 return m_VarWet;
11743 }
11744 //----------------------------------------------------------------
11745 override float GetWetMax()
11746 {
11747 return m_VarWetMax;
11748 }
11749 //----------------------------------------------------------------
11750 override float GetWetMin()
11751 {
11752 return m_VarWetMin;
11753 }
11754 //----------------------------------------------------------------
11755 override float GetWetInit()
11756 {
11757 return m_VarWetInit;
11758 }
11759 //----------------------------------------------------------------
11760 override void OnWetChanged(float newVal, float oldVal)
11761 {
11762 EWetnessLevel newLevel = GetWetLevelInternal(newVal);
11763 EWetnessLevel oldLevel = GetWetLevelInternal(oldVal);
11764 if (newLevel != oldLevel)
11765 {
11766 OnWetLevelChanged(newLevel,oldLevel);
11767 }
11768 }
11769
11770 override void OnWetLevelChanged(EWetnessLevel newLevel, EWetnessLevel oldLevel)
11771 {
11772 SetWeightDirty();
11773 }
11774
11775 override EWetnessLevel GetWetLevel()
11776 {
11777 return GetWetLevelInternal(m_VarWet);
11778 }
11779
11780 //----------------------------------------------------------------
11781
11782 override void SetStoreLoad(bool value)
11783 {
11784 m_IsStoreLoad = value;
11785 }
11786
11787 override bool IsStoreLoad()
11788 {
11789 return m_IsStoreLoad;
11790 }
11791
11792 override void SetStoreLoadedQuantity(float value)
11793 {
11794 m_StoreLoadedQuantity = value;
11795 }
11796
11797 override float GetStoreLoadedQuantity()
11798 {
11799 return m_StoreLoadedQuantity;
11800 }
11801
11802 //----------------------------------------------------------------
11803
11804 float GetItemModelLength()
11805 {
11806 if (ConfigIsExisting("itemModelLength"))
11807 {
11808 return ConfigGetFloat("itemModelLength");
11809 }
11810 return 0;
11811 }
11812
11813 float GetItemAttachOffset()
11814 {
11815 if (ConfigIsExisting("itemAttachOffset"))
11816 {
11817 return ConfigGetFloat("itemAttachOffset");
11818 }
11819 return 0;
11820 }
11821
11822 override void SetCleanness(int value, bool allow_client = false)
11823 {
11824 if (!IsServerCheck(allow_client))
11825 return;
11826
11827 int previousValue = m_Cleanness;
11828
11829 m_Cleanness = Math.Clamp(value, m_CleannessMin, m_CleannessMax);
11830
11831 if (previousValue != m_Cleanness)
11832 SetVariableMask(VARIABLE_CLEANNESS);
11833 }
11834
11835 override int GetCleanness()
11836 {
11837 return m_Cleanness;
11838 }
11839
11841 {
11842 return true;
11843 }
11844
11845 //----------------------------------------------------------------
11846 // ATTACHMENT LOCKING
11847 // Getters relevant to generic ActionLockAttachment
11848 int GetLockType()
11849 {
11850 return m_LockType;
11851 }
11852
11853 string GetLockSoundSet()
11854 {
11855 return m_LockSoundSet;
11856 }
11857
11858 //----------------------------------------------------------------
11859 //------------------------- Color
11860 // sets items color variable given color components
11861 override void SetColor(int r, int g, int b, int a)
11862 {
11867 SetVariableMask(VARIABLE_COLOR);
11868 }
11870 override void GetColor(out int r,out int g,out int b,out int a)
11871 {
11876 }
11877
11878 bool IsColorSet()
11879 {
11880 return IsVariableSet(VARIABLE_COLOR);
11881 }
11882
11884 string GetColorString()
11885 {
11886 int r,g,b,a;
11887 GetColor(r,g,b,a);
11888 r = r/255;
11889 g = g/255;
11890 b = b/255;
11891 a = a/255;
11892 return MiscGameplayFunctions.GetColorString(r, g, b, a);
11893 }
11894 //----------------------------------------------------------------
11895 //------------------------- LiquidType
11896
11897 override void SetLiquidType(int value, bool allow_client = false)
11898 {
11899 if (!IsServerCheck(allow_client))
11900 return;
11901
11902 int old = m_VarLiquidType;
11903 m_VarLiquidType = value;
11904 OnLiquidTypeChanged(old,value);
11905 SetVariableMask(VARIABLE_LIQUIDTYPE);
11906 }
11907
11908 int GetLiquidTypeInit()
11909 {
11910 return ConfigGetInt("varLiquidTypeInit");
11911 }
11912
11913 override int GetLiquidType()
11914 {
11915 return m_VarLiquidType;
11916 }
11917
11918 protected void OnLiquidTypeChanged(int oldType, int newType)
11919 {
11920 if (newType == LIQUID_NONE && GetIsFrozen())
11921 SetFrozen(false);
11922 }
11923
11925 void UpdateQuickbarShortcutVisibility(PlayerBase player)
11926 {
11927 player.SetEnableQuickBarEntityShortcut(this,!GetHierarchyParent() || GetHierarchyParent().GetInventory().AreChildrenAccessible());
11928 }
11929
11930 // -------------------------------------------------------------------------
11932 void OnInventoryEnter(Man player)
11933 {
11934 PlayerBase nplayer;
11935 if (PlayerBase.CastTo(nplayer, player))
11936 {
11937 m_CanPlayImpactSound = true;
11938 nplayer.SetEnableQuickBarEntityShortcut(this,!GetHierarchyParent() || GetHierarchyParent().GetInventory().AreChildrenAccessible());
11939 }
11940 }
11941
11942 // -------------------------------------------------------------------------
11944 void OnInventoryExit(Man player)
11945 {
11946 PlayerBase nplayer;
11947 if (PlayerBase.CastTo(nplayer,player))
11948 {
11949 nplayer.SetEnableQuickBarEntityShortcut(this, false);
11950 }
11951
11952 player.GetHumanInventory().ClearUserReservedLocationForContainer(this);
11953
11954 if (HasEnergyManager())
11955 {
11956 GetCompEM().UpdatePlugState(); // Unplug the el. device if it's necesarry.
11957 }
11958 }
11959
11960 // ADVANCED PLACEMENT EVENTS
11961 override void OnPlacementStarted(Man player)
11962 {
11963 super.OnPlacementStarted(player);
11964
11965 SetTakeable(false);
11966 }
11967
11968 override void OnPlacementComplete(Man player, vector position = "0 0 0", vector orientation = "0 0 0")
11969 {
11970 if (m_AdminLog)
11971 {
11972 m_AdminLog.OnPlacementComplete(player, this);
11973 }
11974
11975 super.OnPlacementComplete(player, position, orientation);
11976 }
11977
11978 //-----------------------------
11979 // AGENT SYSTEM
11980 //-----------------------------
11981 //--------------------------------------------------------------------------
11982 bool ContainsAgent(int agent_id)
11983 {
11984 if (agent_id & m_AttachedAgents)
11985 {
11986 return true;
11987 }
11988 else
11989 {
11990 return false;
11991 }
11992 }
11993
11994 //--------------------------------------------------------------------------
11995 override void RemoveAgent(int agent_id)
11996 {
11997 if (ContainsAgent(agent_id))
11998 {
11999 m_AttachedAgents = ~agent_id & m_AttachedAgents;
12000 }
12001 }
12002
12003 //--------------------------------------------------------------------------
12004 override void RemoveAllAgents()
12005 {
12006 m_AttachedAgents = 0;
12007 }
12008 //--------------------------------------------------------------------------
12009 override void RemoveAllAgentsExcept(int agent_to_keep)
12010 {
12011 m_AttachedAgents = m_AttachedAgents & agent_to_keep;
12012 }
12013 // -------------------------------------------------------------------------
12014 override void InsertAgent(int agent, float count = 1)
12015 {
12016 if (count < 1)
12017 return;
12018 //Debug.Log("Inserting Agent on item: " + agent.ToString() +" count: " + count.ToString());
12020 }
12021
12023 void TransferAgents(int agents)
12024 {
12026 }
12027
12028 // -------------------------------------------------------------------------
12029 override int GetAgents()
12030 {
12031 return m_AttachedAgents;
12032 }
12033 //----------------------------------------------------------------------
12034
12035 /*int GetContaminationType()
12036 {
12037 int contamination_type;
12038
12039 const int CONTAMINATED_MASK = eAgents.CHOLERA | eAgents.INFLUENZA | eAgents.SALMONELLA | eAgents.BRAIN;
12040 const int POISONED_MASK = eAgents.FOOD_POISON | eAgents.CHEMICAL_POISON;
12041 const int NERVE_GAS_MASK = eAgents.CHEMICAL_POISON;
12042 const int DIRTY_MASK = eAgents.WOUND_AGENT;
12043
12044 Edible_Base edible = Edible_Base.Cast(this);
12045 int agents = GetAgents();
12046 if (edible)
12047 {
12048 NutritionalProfile profile = Edible_Base.GetNutritionalProfile(edible);
12049 if (profile)
12050 {
12051 agents = agents | profile.GetAgents();//merge item's agents with nutritional agents
12052 }
12053 }
12054 if (agents & CONTAMINATED_MASK)
12055 {
12056 contamination_type = contamination_type | EContaminationTypes.ITEM_BADGE_CONTAMINATED;
12057 }
12058 if (agents & POISONED_MASK)
12059 {
12060 contamination_type = contamination_type | EContaminationTypes.ITEM_BADGE_POISONED;
12061 }
12062 if (agents & NERVE_GAS_MASK)
12063 {
12064 contamination_type = contamination_type | EContaminationTypes.ITEM_BADGE_NERVE_GAS;
12065 }
12066 if (agents & DIRTY_MASK)
12067 {
12068 contamination_type = contamination_type | EContaminationTypes.ITEM_BADGE_DIRTY;
12069 }
12070
12071 return agents;
12072 }*/
12073
12074 // -------------------------------------------------------------------------
12075 bool LoadAgents(ParamsReadContext ctx, int version)
12076 {
12077 if (!ctx.Read(m_AttachedAgents))
12078 return false;
12079 return true;
12080 }
12081 // -------------------------------------------------------------------------
12083 {
12084
12086 }
12087 // -------------------------------------------------------------------------
12088
12090 override void CheckForRoofLimited(float timeTresholdMS = 3000)
12091 {
12092 super.CheckForRoofLimited(timeTresholdMS);
12093
12094 float time = g_Game.GetTime();
12095 if ((time - m_PreviousRoofTestTime) >= timeTresholdMS)
12096 {
12097 m_PreviousRoofTestTime = time;
12098 SetRoofAbove(MiscGameplayFunctions.IsUnderRoof(this));
12099 }
12100 }
12101
12102 // returns item's protection level against enviromental hazard, for masks with filters, returns the filters protection for valid filter, otherwise 0
12103 float GetProtectionLevel(int type, bool consider_filter = false, int system = 0)
12104 {
12105 if (IsDamageDestroyed() || (HasQuantity() && GetQuantity() <= 0))
12106 {
12107 return 0;
12108 }
12109
12110 if (GetInventory().GetAttachmentSlotsCount() != 0)//is it an item with attachable filter ?
12111 {
12112 ItemBase filter = ItemBase.Cast(FindAttachmentBySlotName("GasMaskFilter"));
12113 if (filter)
12114 return filter.GetProtectionLevel(type, false, system);//it's a valid filter, return the protection
12115 else
12116 return 0;//otherwise return 0 when no filter attached
12117 }
12118
12119 string subclassPath, entryName;
12120
12121 switch (type)
12122 {
12123 case DEF_BIOLOGICAL:
12124 entryName = "biological";
12125 break;
12126 case DEF_CHEMICAL:
12127 entryName = "chemical";
12128 break;
12129 default:
12130 entryName = "biological";
12131 break;
12132 }
12133
12134 subclassPath = "CfgVehicles " + this.GetType() + " Protection ";
12135
12136 return g_Game.ConfigGetFloat(subclassPath + entryName);
12137 }
12138
12139
12140
12142 override void EEOnCECreate()
12143 {
12144 if (!IsMagazine())
12146
12148 }
12149
12150
12151 //-------------------------
12152 // OPEN/CLOSE USER ACTIONS
12153 //-------------------------
12155 void Open();
12156 void Close();
12157 bool IsOpen()
12158 {
12159 return true;
12160 }
12161
12162 override bool CanDisplayCargo()
12163 {
12164 return IsOpen();
12165 }
12166
12167
12168 // ------------------------------------------------------------
12169 // CONDITIONS
12170 // ------------------------------------------------------------
12171 override bool CanPutInCargo(EntityAI parent)
12172 {
12173 if (parent)
12174 {
12175 if (parent.IsInherited(DayZInfected))
12176 return true;
12177
12178 if (!parent.IsRuined())
12179 return true;
12180 }
12181
12182 return true;
12183 }
12184
12185 override bool CanPutAsAttachment(EntityAI parent)
12186 {
12187 if (!super.CanPutAsAttachment(parent))
12188 {
12189 return false;
12190 }
12191
12192 if (!IsRuined() && !parent.IsRuined())
12193 {
12194 return true;
12195 }
12196
12197 return false;
12198 }
12199
12200 override bool CanReceiveItemIntoCargo(EntityAI item)
12201 {
12202 //removed 15.06. coz of loading from storage -> after load items in cargo was lost -> waiting for proper solution
12203 //if (GetHealthLevel() == GameConstants.STATE_RUINED)
12204 // return false;
12205
12206 return super.CanReceiveItemIntoCargo(item);
12207 }
12208
12209 override bool CanReceiveAttachment(EntityAI attachment, int slotId)
12210 {
12211 //removed 15.06. coz of loading from storage -> after load items in cargo was lost -> waiting for proper solution
12212 //if (GetHealthLevel() == GameConstants.STATE_RUINED)
12213 // return false;
12214
12215 GameInventory attachmentInv = attachment.GetInventory();
12216 if (attachmentInv && attachmentInv.GetCargo() && attachmentInv.GetCargo().GetItemCount() > 0)
12217 {
12218 if (GetHierarchyParent() && !GetHierarchyParent().IsInherited(PlayerBase))
12219 return false;
12220 }
12221
12222 InventoryLocation loc = new InventoryLocation();
12223 attachment.GetInventory().GetCurrentInventoryLocation(loc);
12224 if (loc && loc.IsValid() && !GetInventory().AreChildrenAccessible())
12225 return false;
12226
12227 return super.CanReceiveAttachment(attachment, slotId);
12228 }
12229
12230 override bool CanReleaseAttachment(EntityAI attachment)
12231 {
12232 if (!super.CanReleaseAttachment(attachment))
12233 return false;
12234
12235 return GetInventory().AreChildrenAccessible();
12236 }
12237
12238 /*override bool CanLoadAttachment(EntityAI attachment)
12239 {
12240 //removed 15.06. coz of loading from storage -> after load items in cargo was lost -> waiting for proper solution
12241 //if (GetHealthLevel() == GameConstants.STATE_RUINED)
12242 // return false;
12243
12244 GameInventory attachmentInv = attachment.GetInventory();
12245 if (attachmentInv && attachmentInv.GetCargo() && attachmentInv.GetCargo().GetItemCount() > 0)
12246 {
12247 bool boo = (GetHierarchyParent() && !GetHierarchyParent().IsInherited(PlayerBase));
12248 ErrorEx("CanLoadAttachment | this: " + this + " | attachment: " + attachment + " | boo: " + boo,ErrorExSeverity.INFO);
12249
12250 if (GetHierarchyParent() && !GetHierarchyParent().IsInherited(PlayerBase))
12251 return false;
12252 }
12253
12254 return super.CanLoadAttachment(attachment);
12255 }*/
12256
12257 // Plays muzzle flash particle effects
12258 static void PlayFireParticles(ItemBase weapon, int muzzle_index, string ammoType, ItemBase muzzle_owner, ItemBase suppressor, string config_to_search)
12259 {
12260 int id = muzzle_owner.GetMuzzleID();
12261 array<ref WeaponParticlesOnFire> WPOF_array = m_OnFireEffect.Get(id);
12262
12263 if (WPOF_array)
12264 {
12265 for (int i = 0; i < WPOF_array.Count(); i++)
12266 {
12267 WeaponParticlesOnFire WPOF = WPOF_array.Get(i);
12268
12269 if (WPOF)
12270 {
12271 WPOF.OnActivate(weapon, muzzle_index, ammoType, muzzle_owner, suppressor, config_to_search);
12272 }
12273 }
12274 }
12275 }
12276
12277 // Plays bullet eject particle effects (usually just smoke, the bullet itself is a 3D model and is not part of this function)
12278 static void PlayBulletCasingEjectParticles(ItemBase weapon, string ammoType, ItemBase muzzle_owner, ItemBase suppressor, string config_to_search)
12279 {
12280 int id = muzzle_owner.GetMuzzleID();
12281 array<ref WeaponParticlesOnBulletCasingEject> WPOBE_array = m_OnBulletCasingEjectEffect.Get(id);
12282
12283 if (WPOBE_array)
12284 {
12285 for (int i = 0; i < WPOBE_array.Count(); i++)
12286 {
12287 WeaponParticlesOnBulletCasingEject WPOBE = WPOBE_array.Get(i);
12288
12289 if (WPOBE)
12290 {
12291 WPOBE.OnActivate(weapon, 0, ammoType, muzzle_owner, suppressor, config_to_search);
12292 }
12293 }
12294 }
12295 }
12296
12297 // Plays all weapon overheating particles
12298 static void PlayOverheatingParticles(ItemBase weapon, string ammoType, ItemBase muzzle_owner, ItemBase suppressor, string config_to_search)
12299 {
12300 int id = muzzle_owner.GetMuzzleID();
12301 array<ref WeaponParticlesOnOverheating> WPOOH_array = weapon.m_OnOverheatingEffect.Get(id);
12302
12303 if (WPOOH_array)
12304 {
12305 for (int i = 0; i < WPOOH_array.Count(); i++)
12306 {
12307 WeaponParticlesOnOverheating WPOOH = WPOOH_array.Get(i);
12308
12309 if (WPOOH)
12310 {
12311 WPOOH.OnActivate(weapon, 0, ammoType, muzzle_owner, suppressor, config_to_search);
12312 }
12313 }
12314 }
12315 }
12316
12317 // Updates all weapon overheating particles
12318 static void UpdateOverheatingParticles(ItemBase weapon, string ammoType, ItemBase muzzle_owner, ItemBase suppressor, string config_to_search)
12319 {
12320 int id = muzzle_owner.GetMuzzleID();
12321 array<ref WeaponParticlesOnOverheating> WPOOH_array = weapon.m_OnOverheatingEffect.Get(id);
12322
12323 if (WPOOH_array)
12324 {
12325 for (int i = 0; i < WPOOH_array.Count(); i++)
12326 {
12327 WeaponParticlesOnOverheating WPOOH = WPOOH_array.Get(i);
12328
12329 if (WPOOH)
12330 {
12331 WPOOH.OnUpdate(weapon, ammoType, muzzle_owner, suppressor, config_to_search);
12332 }
12333 }
12334 }
12335 }
12336
12337 // Stops overheating particles
12338 static void StopOverheatingParticles(ItemBase weapon, string ammoType, ItemBase muzzle_owner, ItemBase suppressor, string config_to_search)
12339 {
12340 int id = muzzle_owner.GetMuzzleID();
12341 array<ref WeaponParticlesOnOverheating> WPOOH_array = weapon.m_OnOverheatingEffect.Get(id);
12342
12343 if (WPOOH_array)
12344 {
12345 for (int i = 0; i < WPOOH_array.Count(); i++)
12346 {
12347 WeaponParticlesOnOverheating WPOOH = WPOOH_array.Get(i);
12348
12349 if (WPOOH)
12350 {
12351 WPOOH.OnDeactivate(weapon, ammoType, muzzle_owner, suppressor, config_to_search);
12352 }
12353 }
12354 }
12355 }
12356
12357 //----------------------------------------------------------------
12358 //Item Behaviour - unified approach
12359 override bool IsHeavyBehaviour()
12360 {
12361 if (m_ItemBehaviour == 0)
12362 {
12363 return true;
12364 }
12365
12366 return false;
12367 }
12368
12369 override bool IsOneHandedBehaviour()
12370 {
12371 if (m_ItemBehaviour == 1)
12372 {
12373 return true;
12374 }
12375
12376 return false;
12377 }
12378
12379 override bool IsTwoHandedBehaviour()
12380 {
12381 if (m_ItemBehaviour == 2)
12382 {
12383 return true;
12384 }
12385
12386 return false;
12387 }
12388
12389 bool IsDeployable()
12390 {
12391 return false;
12392 }
12393
12395 float GetDeployTime()
12396 {
12397 return UATimeSpent.DEFAULT_DEPLOY;
12398 }
12399
12400
12401 //----------------------------------------------------------------
12402 // Item Targeting (User Actions)
12403 override void SetTakeable(bool pState)
12404 {
12405 m_IsTakeable = pState;
12406 SetSynchDirty();
12407 }
12408
12409 override bool IsTakeable()
12410 {
12411 return m_IsTakeable;
12412 }
12413
12414 // For cases where we want to show object widget which cant be taken to hands
12416 {
12417 return false;
12418 }
12419
12421 protected void PreLoadSoundAttachmentType()
12422 {
12423 string att_type = "None";
12424
12425 if (ConfigIsExisting("soundAttType"))
12426 {
12427 att_type = ConfigGetString("soundAttType");
12428 }
12429
12430 m_SoundAttType = att_type;
12431 }
12432
12433 override string GetAttachmentSoundType()
12434 {
12435 return m_SoundAttType;
12436 }
12437
12438 //----------------------------------------------------------------
12439 //SOUNDS - ItemSoundHandler
12440 //----------------------------------------------------------------
12441
12442 string GetPlaceSoundset(); // played when deploy starts
12443 string GetLoopDeploySoundset(); // played when deploy starts and stopped when it finishes
12444 string GetDeploySoundset(); // played when deploy sucessfully finishes
12445 string GetLoopFoldSoundset(); // played when fold starts and stopped when it finishes
12446 string GetFoldSoundset(); // played when fold sucessfully finishes
12447
12449 {
12450 if (!m_ItemSoundHandler)
12452
12453 return m_ItemSoundHandler;
12454 }
12455
12456 // override to initialize sounds
12457 protected void InitItemSounds()
12458 {
12459 if (GetPlaceSoundset() == string.Empty && GetDeploySoundset() == string.Empty && GetLoopDeploySoundset() == string.Empty && !GetInventoryItemType().SetDetachSoundEvent() && !GetInventoryItemType().SetAttachSoundEvent())
12460 return;
12461
12463
12464 if (GetPlaceSoundset() != string.Empty)
12465 handler.AddSound(SoundConstants.ITEM_PLACE, GetPlaceSoundset());
12466
12467 if (GetDeploySoundset() != string.Empty)
12468 handler.AddSound(SoundConstants.ITEM_DEPLOY, GetDeploySoundset());
12469
12470 SoundParameters params = new SoundParameters();
12471 params.m_Loop = true;
12472 if (GetLoopDeploySoundset() != string.Empty)
12473 handler.AddSound(SoundConstants.ITEM_DEPLOY_LOOP, GetLoopDeploySoundset(), params);
12474 }
12475
12476 // Start sound using ItemSoundHandler
12477 void StartItemSoundServer(int id, int slotId)
12478 {
12479 if (g_Game.IsServer() || !g_Game.IsMultiplayer()) // single player or server side multiplayer
12480 {
12481 m_SoundSyncSlotID = slotId;
12482 m_SoundSyncPlay = id;
12483
12484 SetSynchDirty();
12485
12486 g_Game.GetCallQueue(CALL_CATEGORY_SYSTEM).Remove(ClearStartItemSoundServer); // in case one is queued already
12487 g_Game.GetCallQueue(CALL_CATEGORY_SYSTEM).CallLater(ClearStartItemSoundServer, 100);
12488 }
12489 }
12490
12491 void StartItemSoundServer(int id)
12492 {
12493 StartItemSoundServer(id, InventorySlots.INVALID);
12494 }
12495
12496 // Stop sound using ItemSoundHandler
12497 void StopItemSoundServer(int id)
12498 {
12499 if (!g_Game.IsServer())
12500 return;
12501
12502 m_SoundSyncStop = id;
12503 SetSynchDirty();
12504
12505 g_Game.GetCallQueue(CALL_CATEGORY_SYSTEM).Remove(ClearStopItemSoundServer); // in case one is queued already
12506 g_Game.GetCallQueue(CALL_CATEGORY_SYSTEM).CallLater(ClearStopItemSoundServer, 100);
12507 }
12508
12509 protected void ClearStartItemSoundServer()
12510 {
12511 m_SoundSyncPlay = 0;
12512 m_SoundSyncSlotID = InventorySlots.INVALID;
12513 }
12514
12515 protected void ClearStopItemSoundServer()
12516 {
12517 m_SoundSyncStop = 0;
12518 }
12519
12520 void OnApply(PlayerBase player);
12521
12523 {
12524 return 1.0;
12525 };
12526 //returns applicable selection
12527 array<string> GetHeadHidingSelection()
12528 {
12530 }
12531
12533 {
12535 }
12536
12537 WrittenNoteData GetWrittenNoteData() {};
12538
12540 {
12541 SetDynamicPhysicsLifeTime(0.01);
12542 m_ItemBeingDroppedPhys = false;
12543 }
12544
12546 {
12547 array<string> zone_names = new array<string>;
12548 GetDamageZones(zone_names);
12549 for (int i = 0; i < zone_names.Count(); i++)
12550 {
12551 SetHealthMax(zone_names.Get(i),"Health");
12552 }
12553 SetHealthMax("","Health");
12554 }
12555
12557 void SetZoneDamageCEInit()
12558 {
12559 float global_health = GetHealth01("","Health");
12560 array<string> zones = new array<string>;
12561 GetDamageZones(zones);
12562 //set damage of all zones to match global health level
12563 for (int i = 0; i < zones.Count(); i++)
12564 {
12565 SetHealth01(zones.Get(i),"Health",global_health);
12566 }
12567 }
12568
12570 bool IsCoverFaceForShave(string slot_name)
12571 {
12572 return IsExclusionFlagPresent(PlayerBase.GetFaceCoverageShaveValues());
12573 }
12574
12575 void ProcessItemWetness(float delta, bool hasParent, bool hasRootAsPlayer, ItemBase refParentIB)
12576 {
12577 if (!hasRootAsPlayer)
12578 {
12579 if (refParentIB)
12580 {
12581 // parent is wet
12582 if ((refParentIB.GetWet() >= GameConstants.STATE_SOAKING_WET) && (m_VarWet < m_VarWetMax))
12583 AddWet(delta * GameConstants.WETNESS_RATE_WETTING_INSIDE);
12584 // parent has liquid inside
12585 else if ((refParentIB.GetLiquidType() != 0) && (refParentIB.GetQuantity() > 0) && (m_VarWet < m_VarWetMax))
12586 AddWet(delta * GameConstants.WETNESS_RATE_WETTING_LIQUID);
12587 // drying
12588 else if (m_VarWet > m_VarWetMin)
12589 AddWet(-1 * delta * GetDryingIncrement("ground") * 2);
12590 }
12591 else
12592 {
12593 // drying on ground or inside non-itembase (car, ...)
12594 if (m_VarWet > m_VarWetMin)
12595 AddWet(-1 * delta * GetDryingIncrement("ground"));
12596 }
12597 }
12598 }
12599
12600 void ProcessItemTemperature(float delta, bool hasParent, bool hasRootAsPlayer, ItemBase refParentIB)
12601 {
12603 {
12604 float target = g_Game.GetMission().GetWorldData().GetBaseEnvTemperatureAtObject(this);
12605 if (GetTemperature() != target || !IsFreezeThawProgressFinished())
12606 {
12607 float heatPermCoef = 1.0;
12608 EntityAI ent = this;
12609 while (ent)
12610 {
12611 heatPermCoef *= ent.GetHeatPermeabilityCoef();
12612 ent = ent.GetHierarchyParent();
12613 }
12614
12615 SetTemperatureEx(new TemperatureDataInterpolated(target,ETemperatureAccessTypes.ACCESS_WORLD,delta,GameConstants.TEMP_COEF_WORLD,heatPermCoef));
12616 }
12617 }
12618 }
12619
12620 void HierarchyCheck(out bool hasParent, out bool hasRootAsPlayer, out ItemBase refParentIB)
12621 {
12622 // hierarchy check for an item to decide whether it has some parent and it is in some player inventory
12623 EntityAI parent = GetHierarchyParent();
12624 if (!parent)
12625 {
12626 hasParent = false;
12627 hasRootAsPlayer = false;
12628 }
12629 else
12630 {
12631 hasParent = true;
12632 hasRootAsPlayer = (GetHierarchyRootPlayer() != null);
12633 refParentIB = ItemBase.Cast(parent);
12634 }
12635 }
12636
12637 protected void ProcessDecay(float delta, bool hasRootAsPlayer)
12638 {
12639 // this is stub, implemented on Edible_Base
12640 }
12641
12642 bool CanDecay()
12643 {
12644 // return true used on selected food clases so they can decay
12645 return false;
12646 }
12647
12648 protected bool CanProcessDecay()
12649 {
12650 // this is stub, implemented on Edible_Base class
12651 // used to determine whether it is still necessary for the food to decay
12652 return false;
12653 }
12654
12655 protected bool CanHaveWetness()
12656 {
12657 // return true used on selected items that have a wetness effect
12658 return false;
12659 }
12660
12662 bool CanBeConsumed(ConsumeConditionData data = null)
12663 {
12664 return !GetIsFrozen() && IsOpen();
12665 }
12666
12667 override void ProcessVariables()
12668 {
12669 bool hasParent = false, hasRootAsPlayer = false;
12670 ItemBase refParentIB;
12671
12672 bool wwtu = g_Game.IsWorldWetTempUpdateEnabled();
12673 bool foodDecay = g_Game.IsFoodDecayEnabled();
12674
12675 if (wwtu || foodDecay)
12676 {
12677 bool processWetness = wwtu && CanHaveWetness();
12678 bool processTemperature = wwtu && CanHaveTemperature();
12679 bool processDecay = foodDecay && CanDecay() && CanProcessDecay();
12680
12681 if (processWetness || processTemperature || processDecay)
12682 {
12683 HierarchyCheck(hasParent, hasRootAsPlayer, refParentIB);
12684
12685 if (processWetness)
12686 ProcessItemWetness(m_ElapsedSinceLastUpdate, hasParent, hasRootAsPlayer, refParentIB);
12687
12688 if (processTemperature)
12689 ProcessItemTemperature(m_ElapsedSinceLastUpdate, hasParent, hasRootAsPlayer, refParentIB);
12690
12691 if (processDecay)
12692 ProcessDecay(m_ElapsedSinceLastUpdate, hasRootAsPlayer);
12693 }
12694 }
12695 }
12696
12699 {
12700 return m_TemperaturePerQuantityWeight * GameConstants.ITEM_TEMPERATURE_QUANTITY_WEIGHT_MULTIPLIER;
12701 }
12702
12703 override float GetTemperatureFreezeThreshold()
12704 {
12706 return Liquid.GetFreezeThreshold(GetLiquidType());
12707
12708 return super.GetTemperatureFreezeThreshold();
12709 }
12710
12711 override float GetTemperatureThawThreshold()
12712 {
12714 return Liquid.GetThawThreshold(GetLiquidType());
12715
12716 return super.GetTemperatureThawThreshold();
12717 }
12718
12719 override float GetItemOverheatThreshold()
12720 {
12722 return Liquid.GetBoilThreshold(GetLiquidType());
12723
12724 return super.GetItemOverheatThreshold();
12725 }
12726
12727 override float GetTemperatureFreezeTime()
12728 {
12729 if (HasQuantity())
12730 return Math.Lerp(GameConstants.TEMPERATURE_TIME_FREEZE_MIN,Math.Max(GameConstants.TEMPERATURE_TIME_FREEZE_MIN,super.GetTemperatureFreezeTime()),GetQuantityNormalized());
12731
12732 return super.GetTemperatureFreezeTime();
12733 }
12734
12735 override float GetTemperatureThawTime()
12736 {
12737 if (HasQuantity())
12738 return Math.Lerp(GameConstants.TEMPERATURE_TIME_THAW_MIN,Math.Max(GameConstants.TEMPERATURE_TIME_FREEZE_MIN,super.GetTemperatureThawTime()),GetQuantityNormalized());
12739
12740 return super.GetTemperatureThawTime();
12741 }
12742
12744 void AffectLiquidContainerOnFill(int liquid_type, float amount);
12746 void AffectLiquidContainerOnTransfer(int liquidType, float amount, float sourceLiquidTemperature);
12747
12748 bool IsCargoException4x3(EntityAI item)
12749 {
12750 return (item.IsKindOf("Cauldron") || item.IsKindOf("Pot") || item.IsKindOf("FryingPan") || item.IsKindOf("SmallProtectorCase") || (item.IsKindOf("PortableGasStove") && item.FindAttachmentBySlotName("CookingEquipment")));
12751 }
12752
12754 {
12755 MiscGameplayFunctions.TransferItemProperties(oldItem, this);
12756 }
12757
12759 void AddLightSourceItem(ItemBase lightsource)
12760 {
12761 m_LightSourceItem = lightsource;
12762 }
12763
12765 {
12766 m_LightSourceItem = null;
12767 }
12768
12770 {
12771 return m_LightSourceItem;
12772 }
12773
12775 array<int> GetValidFinishers()
12776 {
12777 return null;
12778 }
12779
12781 bool GetActionWidgetOverride(out typename name)
12782 {
12783 return false;
12784 }
12785
12786 bool PairWithDevice(notnull ItemBase otherDevice)
12787 {
12788 if (g_Game.IsServer())
12789 {
12790 ItemBase explosive = otherDevice;
12792 if (!trg)
12793 {
12794 trg = RemoteDetonatorTrigger.Cast(otherDevice);
12795 explosive = this;
12796 }
12797
12798 explosive.PairRemote(trg);
12799 trg.SetControlledDevice(explosive);
12800
12801 int persistentID = RemotelyActivatedItemBehaviour.GeneratePersistentID();
12802 trg.SetPersistentPairID(persistentID);
12803 explosive.SetPersistentPairID(persistentID);
12804
12805 return true;
12806 }
12807 return false;
12808 }
12809
12811 float GetBaitEffectivity()
12812 {
12813 float ret = 1.0;
12814 if (HasQuantity())
12815 ret *= GetQuantityNormalized();
12816 ret *= GetHealth01();
12817
12818 return ret;
12819 }
12820
12821 #ifdef DEVELOPER
12822 override void SetDebugItem()
12823 {
12824 super.SetDebugItem();
12825 _itemBase = this;
12826 }
12827
12828 override string GetDebugText()
12829 {
12830 string text = super.GetDebugText();
12831
12832 text += string.Format("Heat isolation(raw): %1\n", GetHeatIsolation());
12833 text += string.Format("Heat isolation(modified): %1\n", MiscGameplayFunctions.GetCurrentItemHeatIsolation(this));
12834
12835 return text;
12836 }
12837 #endif
12838
12839 bool CanBeUsedForSuicide()
12840 {
12841 return true;
12842 }
12843
12845 //DEPRECATED BELOW
12847 // Backwards compatibility
12848 void ProcessItemWetnessAndTemperature(float delta, bool hasParent, bool hasRootAsPlayer, ItemBase refParentIB)
12849 {
12850 ProcessItemWetness(delta, hasParent, hasRootAsPlayer, refParentIB);
12851 ProcessItemTemperature(delta, hasParent, hasRootAsPlayer, refParentIB);
12852 }
12853
12854 // replaced by ItemSoundHandler
12855 protected EffectSound m_SoundDeployFinish;
12856 protected EffectSound m_SoundPlace;
12857 protected EffectSound m_DeployLoopSoundEx;
12858 protected EffectSound m_SoundDeploy;
12859 bool m_IsPlaceSound;
12860 bool m_IsDeploySound;
12862
12863 string GetDeployFinishSoundset();
12864 void PlayDeploySound();
12865 void PlayDeployFinishSound();
12866 void PlayPlaceSound();
12867 void PlayDeployLoopSoundEx();
12868 void StopDeployLoopSoundEx();
12869 void SoundSynchRemoteReset();
12870 void SoundSynchRemote();
12871 bool UsesGlobalDeploy(){return false;}
12872 bool CanPlayDeployLoopSound(){return false;}
12874 bool IsPlaceSound(){return m_IsPlaceSound;}
12875 bool IsDeploySound(){return m_IsDeploySound;}
12876 void SetIsPlaceSound(bool is_place_sound);
12877 void SetIsDeploySound(bool is_deploy_sound);
12878
12879 [Obsolete("Use ItemSoundHandler instead")]
12881 void PlayAttachSound(string slot_type)
12882 {
12883 if (!g_Game.IsDedicatedServer())
12884 {
12885 if (ConfigIsExisting("attachSoundSet"))
12886 {
12887 string cfg_path = "";
12888 string soundset = "";
12889 string type_name = GetType();
12890
12891 TStringArray cfg_soundset_array = new TStringArray;
12892 TStringArray cfg_slot_array = new TStringArray;
12893 ConfigGetTextArray("attachSoundSet",cfg_soundset_array);
12894 ConfigGetTextArray("attachSoundSlot",cfg_slot_array);
12895
12896 if (cfg_soundset_array.Count() > 0 && cfg_soundset_array.Count() == cfg_slot_array.Count())
12897 {
12898 for (int i = 0; i < cfg_soundset_array.Count(); i++)
12899 {
12900 if (cfg_slot_array[i] == slot_type)
12901 {
12902 soundset = cfg_soundset_array[i];
12903 break;
12904 }
12905 }
12906 }
12907
12908 if (soundset != "")
12909 {
12910 EffectSound sound = SEffectManager.PlaySound(soundset, GetPosition());
12911 sound.SetAutodestroy(true);
12912 }
12913 }
12914 }
12915 }
12916
12917 void PlayDetachSound(string slot_type) {}
12918}
12919
12920EntityAI SpawnItemOnLocation(string object_name, notnull InventoryLocation loc, bool full_quantity)
12921{
12922 EntityAI entity = SpawnEntity(object_name, loc, ECE_IN_INVENTORY, RF_DEFAULT);
12923 if (entity)
12924 {
12925 bool is_item = entity.IsInherited(ItemBase);
12926 if (is_item && full_quantity)
12927 {
12928 ItemBase item = ItemBase.Cast(entity);
12929 item.SetQuantity(item.GetQuantityInit());
12930 }
12931 }
12932 else
12933 {
12934 ErrorEx("Cannot spawn entity: " + object_name,ErrorExSeverity.INFO);
12935 return NULL;
12936 }
12937 return entity;
12938}
12939
12940void SetupSpawnedItem(ItemBase item, float health, float quantity)
12941{
12942 if (item)
12943 {
12944 if (health > 0)
12945 item.SetHealth("", "", health);
12946
12947 if (item.CanHaveTemperature())
12948 {
12949 item.SetTemperatureDirect(GameConstants.ITEM_TEMPERATURE_NEUTRAL_ZONE_MIDDLE);
12950 if (item.CanFreeze())
12951 item.SetFrozen(false);
12952 }
12953
12954 if (item.HasEnergyManager())
12955 {
12956 if (quantity >= 0)
12957 {
12958 item.GetCompEM().SetEnergy0To1(quantity);
12959 }
12960 else
12961 {
12962 item.GetCompEM().SetEnergy(Math.AbsFloat(quantity));
12963 }
12964 }
12965 else if (item.IsMagazine())
12966 {
12967 Magazine mag = Magazine.Cast(item);
12968 if (quantity >= 0)
12969 {
12970 mag.ServerSetAmmoCount(mag.GetAmmoMax() * quantity);
12971 }
12972 else
12973 {
12974 mag.ServerSetAmmoCount(Math.AbsFloat(quantity));
12975 }
12976
12977 }
12978 else
12979 {
12980 if (quantity >= 0)
12981 {
12982 item.SetQuantityNormalized(quantity, false);
12983 }
12984 else
12985 {
12986 item.SetQuantity(Math.AbsFloat(quantity));
12987 }
12988
12989 }
12990 }
12991}
12992
12993#ifdef DEVELOPER
12994ItemBase _itemBase;//watched item goes here(LCTRL+RMB->Watch)
12995#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()