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

◆ AddQuantity()

bool SpawnItemOnLocation::AddQuantity ( float value,
bool destroy_config = true,
bool destroy_forced = false )
private

add item quantity[related to varQuantity... config entry], destroy_config = true > if the quantity reaches varQuantityMin or lower and the item config contains the varQuantityDestroyOnMin = true entry, the item gets destroyed. destroy_forced = true means item gets destroyed when quantity reaches varQuantityMin or lower regardless of config setting, returns true if the item gets deleted

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

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

Используется в InventoryItem::CombineItems(), Edible_Base::Consume(), InventoryItem::OnAction(), ItemBase::OnIgnitedTarget(), ItemBase::OnIgnitedTargetFailed(), ItemBase::RemovePlanks(), InventoryItem::SplitIntoStackMax(), InventoryItem::SplitIntoStackMaxCargo(), InventoryItem::SplitIntoStackMaxEx(), InventoryItem::SplitIntoStackMaxHands(), InventoryItem::SplitIntoStackMaxToInventoryLocationEx(), InventoryItem::SplitItem() и InventoryItem::SplitItemToInventoryLocation().