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

◆ GetSingleInventoryItemWeightEx()

override float SpawnItemOnLocation::GetSingleInventoryItemWeightEx ( )
protected

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

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

Используется в InventoryItem::GetSingleInventoryItemWeight() и Entity::OnAction().