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

◆ OnVariablesSynchronized()

override void SpawnItemOnLocation::OnVariablesSynchronized ( )
protected

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

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