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

◆ SplitIntoStackMaxClient()

override void SpawnItemOnLocation::SplitIntoStackMaxClient ( EntityAI destination_entity,
int slot_id )
protected

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

6452{
6453 override bool CanPutAsAttachment(EntityAI parent)
6454 {
6455 return true;
6456 }
6457};
6458
6459//const bool QUANTITY_DEBUG_REMOVE_ME = false;
6460
6461class ItemBase extends InventoryItem
6462{
6466
6468
6469 static int m_DebugActionsMask;
6471 // ============================================
6472 // Variable Manipulation System
6473 // ============================================
6474 // Quantity
6475
6476 float m_VarQuantity;
6477 float m_VarQuantityPrev;//for client to know quantity changed during synchronization
6479 int m_VarQuantityMin;
6480 int m_VarQuantityMax;
6481 int m_Count;
6482 float m_VarStackMax;
6483 float m_StoreLoadedQuantity = float.LOWEST;
6484 // Wet
6485 float m_VarWet;
6486 float m_VarWetPrev;//for client to know wetness changed during synchronization
6487 float m_VarWetInit;
6488 float m_VarWetMin;
6489 float m_VarWetMax;
6490 // Cleanness
6491 int m_Cleanness;
6492 int m_CleannessInit;
6493 int m_CleannessMin;
6494 int m_CleannessMax;
6495 // impact sounds
6497 bool m_CanPlayImpactSound = true;
6498 float m_ImpactSpeed;
6500 //
6501 float m_HeatIsolation;
6502 float m_ItemModelLength;
6503 float m_ItemAttachOffset; // Offset length for when the item is attached e.g. to weapon
6505 int m_VarLiquidType;
6506 int m_ItemBehaviour; // -1 = not specified; 0 = heavy item; 1= onehanded item; 2 = twohanded item
6507 int m_QuickBarBonus;
6508 bool m_IsBeingPlaced;
6509 bool m_IsHologram;
6510 bool m_IsTakeable;
6511 bool m_ThrowItemOnDrop;
6514 bool m_FixDamageSystemInit = false; //can be changed on storage version check
6515 bool can_this_be_combined; //Check if item can be combined
6516 bool m_CanThisBeSplit; //Check if item can be split
6517 bool m_IsStoreLoad = false;
6518 bool m_CanShowQuantity;
6519 bool m_HasQuantityBar;
6520 protected bool m_CanBeDigged;
6521 protected bool m_IsResultOfSplit
6522
6523 string m_SoundAttType;
6524 // items color variables
6529 //-------------------------------------------------------
6530
6531 // light source managing
6533
6537
6538 //==============================================
6539 // agent system
6540 private int m_AttachedAgents;
6541
6543 void TransferModifiers(PlayerBase reciever);
6544
6545
6546 // Weapons & suppressors particle effects
6551 static int m_LastRegisteredWeaponID = 0;
6552
6553 // Overheating effects
6555 float m_OverheatingShots;
6556 ref Timer m_CheckOverheating;
6557 int m_ShotsToStartOverheating = 0; // After these many shots, the overheating effect begins
6558 int m_MaxOverheatingValue = 0; // Limits the number of shots that will be tracked
6559 float m_OverheatingDecayInterval = 1; // Timer's interval for decrementing overheat effect's lifespan
6560 ref array <ref OverheatingParticle> m_OverheatingParticles;
6561
6563 protected bool m_HideSelectionsBySlot;
6564
6565 // Admin Log
6566 PluginAdminLog m_AdminLog;
6567
6568 // misc
6569 ref Timer m_PhysDropTimer;
6570
6571 // Attachment Locking variables
6572 ref array<int> m_CompatibleLocks;
6573 protected int m_LockType;
6574 protected ref EffectSound m_LockingSound;
6575 protected string m_LockSoundSet;
6576
6577 // ItemSoundHandler
6578 protected const int ITEM_SOUNDS_MAX = 63; // optimize network synch
6579 protected int m_SoundSyncPlay; // id for sound to play
6580 protected int m_SoundSyncStop; // id for sound to stop
6582
6583 //temperature
6584 private float m_TemperaturePerQuantityWeight;
6585
6586 // -------------------------------------------------------------------------
6587 void ItemBase()
6588 {
6589 SetEventMask(EntityEvent.INIT); // Enable EOnInit event
6593
6594 if (!GetGame().IsDedicatedServer())
6595 {
6596 if (HasMuzzle())
6597 {
6599
6601 {
6603 }
6604 }
6605
6607 m_ActionsInitialize = false;
6608 }
6609
6610 m_OldLocation = null;
6611
6612 if (GetGame().IsServer())
6613 {
6614 m_AdminLog = PluginAdminLog.Cast(GetPlugin(PluginAdminLog));
6615 }
6616
6617 if (ConfigIsExisting("headSelectionsToHide"))
6618 {
6620 ConfigGetTextArray("headSelectionsToHide",m_HeadHidingSelections);
6621 }
6622
6623 m_HideSelectionsBySlot = false;
6624 if (ConfigIsExisting("hideSelectionsByinventorySlot"))
6625 {
6626 m_HideSelectionsBySlot = ConfigGetBool("hideSelectionsByinventorySlot");
6627 }
6628
6629 m_QuickBarBonus = Math.Max(0, ConfigGetInt("quickBarBonus"));
6630
6631 m_IsResultOfSplit = false;
6632
6634 }
6635
6636 override void InitItemVariables()
6637 {
6638 super.InitItemVariables();
6639
6640 m_VarQuantityInit = ConfigGetInt("varQuantityInit");
6641 m_VarQuantity = m_VarQuantityInit;//should be by the CE, this is just a precaution
6642 m_VarQuantityMin = ConfigGetInt("varQuantityMin");
6643 m_VarQuantityMax = ConfigGetInt("varQuantityMax");
6644 m_VarStackMax = ConfigGetFloat("varStackMax");
6645 m_Count = ConfigGetInt("count");
6646
6647 m_CanShowQuantity = ConfigGetBool("quantityShow");
6648 m_HasQuantityBar = ConfigGetBool("quantityBar");
6649
6650 m_CleannessInit = ConfigGetInt("varCleannessInit");
6652 m_CleannessMin = ConfigGetInt("varCleannessMin");
6653 m_CleannessMax = ConfigGetInt("varCleannessMax");
6654
6655 m_WantPlayImpactSound = false;
6656 m_ImpactSpeed = 0.0;
6657
6658 m_VarWetInit = ConfigGetFloat("varWetInit");
6660 m_VarWetMin = ConfigGetFloat("varWetMin");
6661 m_VarWetMax = ConfigGetFloat("varWetMax");
6662
6663 m_LiquidContainerMask = ConfigGetInt("liquidContainerType");
6664 if (IsLiquidContainer() && GetQuantity() != 0)
6666 m_IsBeingPlaced = false;
6667 m_IsHologram = false;
6668 m_IsTakeable = true;
6669 m_CanBeMovedOverride = false;
6673 m_CanBeDigged = ConfigGetBool("canBeDigged");
6674
6675 m_CompatibleLocks = new array<int>();
6676 ConfigGetIntArray("compatibleLocks", m_CompatibleLocks);
6677 m_LockType = ConfigGetInt("lockType");
6678
6679 //Define if item can be split and set ability to be combined accordingly
6680 m_CanThisBeSplit = false;
6681 can_this_be_combined = false;
6682 if (ConfigIsExisting("canBeSplit"))
6683 {
6684 can_this_be_combined = ConfigGetBool("canBeSplit");
6686 }
6687
6688 m_ItemBehaviour = -1;
6689 if (ConfigIsExisting("itemBehaviour"))
6690 m_ItemBehaviour = ConfigGetInt("itemBehaviour");
6691
6692 //RegisterNetSyncVariableInt("m_VariablesMask");
6693 if (HasQuantity()) RegisterNetSyncVariableFloat("m_VarQuantity", GetQuantityMin(), m_VarQuantityMax);
6694 RegisterNetSyncVariableFloat("m_VarWet", GetWetMin(), GetWetMax(), 2);
6695 RegisterNetSyncVariableInt("m_VarLiquidType");
6696 RegisterNetSyncVariableInt("m_Cleanness",0,1);
6697
6698 RegisterNetSyncVariableBoolSignal("m_WantPlayImpactSound");
6699 RegisterNetSyncVariableFloat("m_ImpactSpeed");
6700 RegisterNetSyncVariableInt("m_ImpactSoundSurfaceHash");
6701
6702 RegisterNetSyncVariableInt("m_ColorComponentR", 0, 255);
6703 RegisterNetSyncVariableInt("m_ColorComponentG", 0, 255);
6704 RegisterNetSyncVariableInt("m_ColorComponentB", 0, 255);
6705 RegisterNetSyncVariableInt("m_ColorComponentA", 0, 255);
6706
6707 RegisterNetSyncVariableBool("m_IsBeingPlaced");
6708 RegisterNetSyncVariableBool("m_IsTakeable");
6709 RegisterNetSyncVariableBool("m_IsHologram");
6710
6711 InitItemSounds();
6713 {
6714 RegisterNetSyncVariableInt("m_SoundSyncPlay", 0, ITEM_SOUNDS_MAX);
6715 RegisterNetSyncVariableInt("m_SoundSyncStop", 0, ITEM_SOUNDS_MAX);
6716 }
6717
6718 m_LockSoundSet = ConfigGetString("lockSoundSet");
6719
6721 if (ConfigIsExisting("temperaturePerQuantityWeight"))
6722 m_TemperaturePerQuantityWeight = ConfigGetFloat("temperaturePerQuantityWeight");
6723
6724 }
6725
6726 override int GetQuickBarBonus()
6727 {
6728 return m_QuickBarBonus;
6729 }
6730
6731 void InitializeActions()
6732 {
6734 if (!m_InputActionMap)
6735 {
6737 m_InputActionMap = iam;
6738 SetActions();
6740 }
6741 }
6742
6743 override void GetActions(typename action_input_type, out array<ActionBase_Basic> actions)
6744 {
6746 {
6747 m_ActionsInitialize = true;
6749 }
6750
6751 actions = m_InputActionMap.Get(action_input_type);
6752 }
6753
6754 void SetActions()
6755 {
6756 AddAction(ActionTakeItem);
6757 AddAction(ActionTakeItemToHands);
6758 AddAction(ActionWorldCraft);
6760 AddAction(ActionAttachWithSwitch);
6761 }
6762
6763 void SetActionAnimOverrides(); // Override action animation for specific item
6764
6765 void AddAction(typename actionName)
6766 {
6767 ActionBase action = ActionManagerBase.GetAction(actionName);
6768
6769 if (!action)
6770 {
6771 Debug.LogError("Action " + actionName + " dosn't exist!");
6772 return;
6773 }
6774
6775 typename ai = action.GetInputType();
6776 if (!ai)
6777 {
6778 m_ActionsInitialize = false;
6779 return;
6780 }
6781
6782 array<ActionBase_Basic> action_array = m_InputActionMap.Get(ai);
6783 if (!action_array)
6784 {
6785 action_array = new array<ActionBase_Basic>;
6786 m_InputActionMap.Insert(ai, action_array);
6787 }
6788 if (LogManager.IsActionLogEnable())
6789 {
6790 Debug.ActionLog(action.ToString() + " -> " + ai, this.ToString() , "n/a", "Add action");
6791 }
6792
6793 if (action_array.Find(action) != -1)
6794 {
6795 Debug.Log("Action " + action.Type() + " already added to " + this + ", skipping!");
6796 }
6797 else
6798 {
6799 action_array.Insert(action);
6800 }
6801 }
6802
6803 void RemoveAction(typename actionName)
6804 {
6805 PlayerBase player = PlayerBase.Cast(GetGame().GetPlayer());
6806 ActionBase action = player.GetActionManager().GetAction(actionName);
6807 typename ai = action.GetInputType();
6808 array<ActionBase_Basic> action_array = m_InputActionMap.Get(ai);
6809
6810 if (action_array)
6811 {
6812 action_array.RemoveItem(action);
6813 }
6814 }
6815
6816 // Allows override of default action command per item, defined in the SetActionAnimOverrides() of the item's class
6817 // Set -1 for params which should stay in default state
6818 void OverrideActionAnimation(typename action, int commandUID, int stanceMask = -1, int commandUIDProne = -1)
6819 {
6820 ActionOverrideData overrideData = new ActionOverrideData();
6821 overrideData.m_CommandUID = commandUID;
6822 overrideData.m_CommandUIDProne = commandUIDProne;
6823 overrideData.m_StanceMask = stanceMask;
6824
6825 TActionAnimOverrideMap actionMap = m_ItemActionOverrides.Get(action);
6826 if (!actionMap) // create new map of action > overidables map
6827 {
6828 actionMap = new TActionAnimOverrideMap();
6829 m_ItemActionOverrides.Insert(action, actionMap);
6830 }
6831
6832 actionMap.Insert(this.Type(), overrideData); // insert item -> overrides
6833
6834 }
6835
6836 void OnItemInHandsPlayerSwimStart(PlayerBase player);
6837
6838 ScriptedLightBase GetLight();
6839
6840 // Loads muzzle flash particle configuration from config and saves it to a map for faster access
6841 void LoadParticleConfigOnFire(int id)
6842 {
6843 if (!m_OnFireEffect)
6845
6848
6849 string config_to_search = "CfgVehicles";
6850 string muzzle_owner_config;
6851
6852 if (!m_OnFireEffect.Contains(id))
6853 {
6854 if (IsInherited(Weapon))
6855 config_to_search = "CfgWeapons";
6856
6857 muzzle_owner_config = config_to_search + " " + GetType() + " ";
6858
6859 string config_OnFire_class = muzzle_owner_config + "Particles " + "OnFire ";
6860
6861 int config_OnFire_subclass_count = GetGame().ConfigGetChildrenCount(config_OnFire_class);
6862
6863 if (config_OnFire_subclass_count > 0)
6864 {
6865 array<ref WeaponParticlesOnFire> WPOF_array = new array<ref WeaponParticlesOnFire>;
6866
6867 for (int i = 0; i < config_OnFire_subclass_count; i++)
6868 {
6869 string particle_class = "";
6870 GetGame().ConfigGetChildName(config_OnFire_class, i, particle_class);
6871 string config_OnFire_entry = config_OnFire_class + particle_class;
6872 WeaponParticlesOnFire WPOF = new WeaponParticlesOnFire(this, config_OnFire_entry);
6873 WPOF_array.Insert(WPOF);
6874 }
6875
6876
6877 m_OnFireEffect.Insert(id, WPOF_array);
6878 }
6879 }
6880
6881 if (!m_OnBulletCasingEjectEffect.Contains(id))
6882 {
6883 config_to_search = "CfgWeapons"; // Bullet Eject efect is supported on weapons only.
6884 muzzle_owner_config = config_to_search + " " + GetType() + " ";
6885
6886 string config_OnBulletCasingEject_class = muzzle_owner_config + "Particles " + "OnBulletCasingEject ";
6887
6888 int config_OnBulletCasingEject_count = GetGame().ConfigGetChildrenCount(config_OnBulletCasingEject_class);
6889
6890 if (config_OnBulletCasingEject_count > 0 && IsInherited(Weapon))
6891 {
6892 array<ref WeaponParticlesOnBulletCasingEject> WPOBE_array = new array<ref WeaponParticlesOnBulletCasingEject>;
6893
6894 for (i = 0; i < config_OnBulletCasingEject_count; i++)
6895 {
6896 string particle_class2 = "";
6897 GetGame().ConfigGetChildName(config_OnBulletCasingEject_class, i, particle_class2);
6898 string config_OnBulletCasingEject_entry = config_OnBulletCasingEject_class + particle_class2;
6899 WeaponParticlesOnBulletCasingEject WPOBE = new WeaponParticlesOnBulletCasingEject(this, config_OnBulletCasingEject_entry);
6900 WPOBE_array.Insert(WPOBE);
6901 }
6902
6903
6904 m_OnBulletCasingEjectEffect.Insert(id, WPOBE_array);
6905 }
6906 }
6907 }
6908
6909 // Loads muzzle flash particle configuration from config and saves it to a map for faster access
6911 {
6914
6915 if (!m_OnOverheatingEffect.Contains(id))
6916 {
6917 string config_to_search = "CfgVehicles";
6918
6919 if (IsInherited(Weapon))
6920 config_to_search = "CfgWeapons";
6921
6922 string muzzle_owner_config = config_to_search + " " + GetType() + " ";
6923 string config_OnOverheating_class = muzzle_owner_config + "Particles " + "OnOverheating ";
6924
6925 if (GetGame().ConfigIsExisting(config_OnOverheating_class))
6926 {
6927
6928 m_ShotsToStartOverheating = GetGame().ConfigGetFloat(config_OnOverheating_class + "shotsToStartOverheating");
6929
6931 {
6932 m_ShotsToStartOverheating = -1; // This prevents futher readings from config for future creations of this item
6933 string error = "Error reading config " + GetType() + ">Particles>OnOverheating - Parameter shotsToStartOverheating is configured wrong or is missing! Its value must be 1 or higher!";
6934 Error(error);
6935 return;
6936 }
6937
6938 m_OverheatingDecayInterval = GetGame().ConfigGetFloat(config_OnOverheating_class + "overheatingDecayInterval");
6939 m_MaxOverheatingValue = GetGame().ConfigGetFloat(config_OnOverheating_class + "maxOverheatingValue");
6940
6941
6942
6943 int config_OnOverheating_subclass_count = GetGame().ConfigGetChildrenCount(config_OnOverheating_class);
6944 array<ref WeaponParticlesOnOverheating> WPOOH_array = new array<ref WeaponParticlesOnOverheating>;
6945
6946 for (int i = 0; i < config_OnOverheating_subclass_count; i++)
6947 {
6948 string particle_class = "";
6949 GetGame().ConfigGetChildName(config_OnOverheating_class, i, particle_class);
6950 string config_OnOverheating_entry = config_OnOverheating_class + particle_class;
6951 int entry_type = GetGame().ConfigGetType(config_OnOverheating_entry);
6952
6953 if (entry_type == CT_CLASS)
6954 {
6955 WeaponParticlesOnOverheating WPOF = new WeaponParticlesOnOverheating(this, config_OnOverheating_entry);
6956 WPOOH_array.Insert(WPOF);
6957 }
6958 }
6959
6960
6961 m_OnOverheatingEffect.Insert(id, WPOOH_array);
6962 }
6963 }
6964 }
6965
6966 float GetOverheatingValue()
6967 {
6968 return m_OverheatingShots;
6969 }
6970
6971 void IncreaseOverheating(ItemBase weapon, string ammoType, ItemBase muzzle_owner, ItemBase suppressor, string config_to_search)
6972 {
6973 if (m_MaxOverheatingValue > 0)
6974 {
6976
6977 if (!m_CheckOverheating)
6979
6981 m_CheckOverheating.Run(m_OverheatingDecayInterval, this, "OnOverheatingDecay");
6982
6983 CheckOverheating(weapon, ammoType, muzzle_owner, suppressor, config_to_search);
6984 }
6985 }
6986
6987 void CheckOverheating(ItemBase weapon = null, string ammoType = "", ItemBase muzzle_owner = null, ItemBase suppressor = null, string config_to_search = "")
6988 {
6990 UpdateOverheating(weapon, ammoType, muzzle_owner, suppressor, config_to_search);
6991
6993 StartOverheating(weapon, ammoType, muzzle_owner, suppressor, config_to_search);
6994
6996 StopOverheating(weapon, ammoType, muzzle_owner, suppressor, config_to_search);
6997
6999 {
7001 }
7002 }
7003
7005 {
7007 }
7008
7009 void OnOverheatingDecay()
7010 {
7011 if (m_MaxOverheatingValue > 0)
7012 m_OverheatingShots -= 1 + m_OverheatingShots / m_MaxOverheatingValue; // The hotter a barrel is, the faster it needs to cool down.
7013 else
7015
7016 if (m_OverheatingShots <= 0)
7017 {
7020 }
7021 else
7022 {
7023 if (!m_CheckOverheating)
7025
7027 m_CheckOverheating.Run(m_OverheatingDecayInterval, this, "OnOverheatingDecay");
7028 }
7029
7030 CheckOverheating(this, "", this);
7031 }
7032
7033 void StartOverheating(ItemBase weapon = null, string ammoType = "", ItemBase muzzle_owner = null, ItemBase suppressor = null, string config_to_search = "")
7034 {
7036 ItemBase.PlayOverheatingParticles(this, ammoType, this, suppressor, "CfgWeapons");
7037 }
7038
7039 void UpdateOverheating(ItemBase weapon = null, string ammoType = "", ItemBase muzzle_owner = null, ItemBase suppressor = null, string config_to_search = "")
7040 {
7042 ItemBase.UpdateOverheatingParticles(this, ammoType, this, suppressor, "CfgWeapons");
7044 }
7045
7046 void StopOverheating(ItemBase weapon = null, string ammoType = "", ItemBase muzzle_owner = null, ItemBase suppressor = null, string config_to_search = "")
7047 {
7049 ItemBase.StopOverheatingParticles(weapon, ammoType, muzzle_owner, suppressor, config_to_search);
7050 }
7051
7052 void RegisterOverheatingParticle(Particle p, float min_heat_coef, float max_heat_coef, int particle_id, Object parent, vector local_pos, vector local_ori)
7053 {
7055 m_OverheatingParticles = new array<ref OverheatingParticle>;
7056
7057 OverheatingParticle OP = new OverheatingParticle();
7058 OP.RegisterParticle(p);
7059 OP.SetOverheatingLimitMin(min_heat_coef);
7060 OP.SetOverheatingLimitMax(max_heat_coef);
7061 OP.SetParticleParams(particle_id, parent, local_pos, local_ori);
7062
7063 m_OverheatingParticles.Insert(OP);
7064 }
7065
7066 float GetOverheatingCoef()
7067 {
7068 if (m_MaxOverheatingValue > 0)
7070
7071 return -1;
7072 }
7073
7075 {
7077 {
7078 float overheat_coef = GetOverheatingCoef();
7079 int count = m_OverheatingParticles.Count();
7080
7081 for (int i = count; i > 0; --i)
7082 {
7083 int id = i - 1;
7084 OverheatingParticle OP = m_OverheatingParticles.Get(id);
7085 Particle p = OP.GetParticle();
7086
7087 float overheat_min = OP.GetOverheatingLimitMin();
7088 float overheat_max = OP.GetOverheatingLimitMax();
7089
7090 if (overheat_coef < overheat_min && overheat_coef >= overheat_max)
7091 {
7092 if (p)
7093 {
7094 p.Stop();
7095 OP.RegisterParticle(null);
7096 }
7097 }
7098 }
7099 }
7100 }
7101
7103 {
7105 {
7106 for (int i = m_OverheatingParticles.Count(); i > 0; i--)
7107 {
7108 int id = i - 1;
7109 OverheatingParticle OP = m_OverheatingParticles.Get(id);
7110
7111 if (OP)
7112 {
7113 Particle p = OP.GetParticle();
7114
7115 if (p)
7116 {
7117 p.Stop();
7118 }
7119
7120 delete OP;
7121 }
7122 }
7123
7124 m_OverheatingParticles.Clear();
7126 }
7127 }
7128
7130 float GetInfectionChance(int system = 0, Param param = null)
7131 {
7132 return 0.0;
7133 }
7134
7135
7136 float GetDisinfectQuantity(int system = 0, Param param1 = null)
7137 {
7138 return 250;//default value
7139 }
7140
7141 float GetFilterDamageRatio()
7142 {
7143 return 0;
7144 }
7145
7147 bool HasMuzzle()
7148 {
7149 if (IsInherited(Weapon) || IsInherited(SuppressorBase))
7150 return true;
7151
7152 return false;
7153 }
7154
7156 int GetMuzzleID()
7157 {
7158 if (!m_WeaponTypeToID)
7160
7161 if (m_WeaponTypeToID.Contains(GetType()))
7162 {
7163 return m_WeaponTypeToID.Get(GetType());
7164 }
7165 else
7166 {
7167 // Register new weapon ID
7169 }
7170
7172 }
7173
7180 {
7181 return -1;
7182 }
7183
7184
7185
7186 // -------------------------------------------------------------------------
7187 void ~ItemBase()
7188 {
7189 if (GetGame() && GetGame().GetPlayer() && (!GetGame().IsDedicatedServer()))
7190 {
7191 PlayerBase player = PlayerBase.Cast(GetGame().GetPlayer());
7192 int r_index = player.GetHumanInventory().FindUserReservedLocationIndex(this);
7193
7194 if (r_index >= 0)
7195 {
7196 InventoryLocation r_il = new InventoryLocation;
7197 player.GetHumanInventory().GetUserReservedLocation(r_index,r_il);
7198
7199 player.GetHumanInventory().ClearUserReservedLocationAtIndex(r_index);
7200 int r_type = r_il.GetType();
7201 if (r_type == InventoryLocationType.CARGO || r_type == InventoryLocationType.PROXYCARGO)
7202 {
7203 r_il.GetParent().GetOnReleaseLock().Invoke(this);
7204 }
7205 else if (r_type == InventoryLocationType.ATTACHMENT)
7206 {
7207 r_il.GetParent().GetOnAttachmentReleaseLock().Invoke(this, r_il.GetSlot());
7208 }
7209
7210 }
7211
7212 player.GetHumanInventory().ClearUserReservedLocation(this);
7213 }
7214
7215 if (m_LockingSound)
7216 SEffectManager.DestroyEffect(m_LockingSound);
7217 }
7218
7219
7220
7221 // -------------------------------------------------------------------------
7222 static int GetDebugActionsMask()
7223 {
7224 return ItemBase.m_DebugActionsMask;
7225 }
7226
7227 static bool HasDebugActionsMask(int mask)
7228 {
7229 return ItemBase.m_DebugActionsMask & mask;
7230 }
7231
7232 static void SetDebugActionsMask(int mask)
7233 {
7234 ItemBase.m_DebugActionsMask = mask;
7235 }
7236
7237 static void AddDebugActionsMask(int mask)
7238 {
7239 ItemBase.m_DebugActionsMask |= mask;
7240 }
7241
7242 static void RemoveDebugActionsMask(int mask)
7243 {
7244 ItemBase.m_DebugActionsMask &= ~mask;
7245 }
7246
7247 static void ToggleDebugActionsMask(int mask)
7248 {
7249 if (HasDebugActionsMask(mask))
7250 {
7252 }
7253 else
7254 {
7255 AddDebugActionsMask(mask);
7256 }
7257 }
7258
7259 // -------------------------------------------------------------------------
7260 void SetCEBasedQuantity()
7261 {
7262 if (GetEconomyProfile())
7263 {
7264 float q_max = GetEconomyProfile().GetQuantityMax();
7265 if (q_max > 0)
7266 {
7267 float q_min = GetEconomyProfile().GetQuantityMin();
7268 float quantity_randomized = Math.RandomFloatInclusive(q_min, q_max);
7269
7270 if (HasComponent(COMP_TYPE_ENERGY_MANAGER))//more direct access for speed
7271 {
7272 ComponentEnergyManager comp = GetCompEM();
7273 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
7274 {
7275 comp.SetEnergy0To1(quantity_randomized);
7276 }
7277 }
7278 else if (HasQuantity())
7279 {
7280 SetQuantityNormalized(quantity_randomized, false);
7281 //PrintString("<==> Normalized quantity for item: "+ GetType()+", qmin:"+q_min.ToString()+"; qmax:"+q_max.ToString()+";quantity:" +quantity_randomized.ToString());
7282 }
7283
7284 }
7285 }
7286 }
7287
7289 void LockToParent()
7290 {
7291 EntityAI parent = GetHierarchyParent();
7292
7293 if (parent)
7294 {
7295 InventoryLocation inventory_location_to_lock = new InventoryLocation;
7296 GetInventory().GetCurrentInventoryLocation(inventory_location_to_lock);
7297 parent.GetInventory().SetSlotLock(inventory_location_to_lock.GetSlot(), true);
7298 }
7299 }
7300
7302 void UnlockFromParent()
7303 {
7304 EntityAI parent = GetHierarchyParent();
7305
7306 if (parent)
7307 {
7308 InventoryLocation inventory_location_to_unlock = new InventoryLocation;
7309 GetInventory().GetCurrentInventoryLocation(inventory_location_to_unlock);
7310 parent.GetInventory().SetSlotLock(inventory_location_to_unlock.GetSlot(), false);
7311 }
7312 }
7313
7314 override void CombineItemsClient(EntityAI entity2, bool use_stack_max = true)
7315 {
7316 /*
7317 ref Param1<EntityAI> item = new Param1<EntityAI>(entity2);
7318 RPCSingleParam(ERPCs.RPC_ITEM_COMBINE, item, GetGame().GetPlayer());
7319 */
7320 ItemBase item2 = ItemBase.Cast(entity2);
7321
7322 if (GetGame().IsClient())
7323 {
7324 if (ScriptInputUserData.CanStoreInputUserData())
7325 {
7326 ScriptInputUserData ctx = new ScriptInputUserData;
7328 ctx.Write(-1);
7329 ItemBase i1 = this; // @NOTE: workaround for correct serialization
7330 ctx.Write(i1);
7331 ctx.Write(item2);
7332 ctx.Write(use_stack_max);
7333 ctx.Write(-1);
7334 ctx.Send();
7335
7336 if (IsCombineAll(item2, use_stack_max))
7337 {
7338 GetGame().GetPlayer().GetInventory().AddInventoryReservationEx(item2,null,GameInventory.c_InventoryReservationTimeoutShortMS);
7339 }
7340 }
7341 }
7342 else if (!GetGame().IsMultiplayer())
7343 {
7344 CombineItems(item2, use_stack_max);
7345 }
7346 }
7347
7348 bool IsLiquidPresent()
7349 {
7350 return (GetLiquidType() != 0 && HasQuantity());
7351 }
7352
7353 bool IsLiquidContainer()
7354 {
7355 return m_LiquidContainerMask != 0;
7356 }
7357
7359 {
7360 return m_LiquidContainerMask;
7361 }
7362
7363 bool IsBloodContainer()
7364 {
7365 //m_LiquidContainerMask & GROUP_LIQUID_BLOOD ???
7366 return false;
7367 }
7368
7369 bool IsNVG()
7370 {
7371 return false;
7372 }
7373
7376 bool IsExplosive()
7377 {
7378 return false;
7379 }
7380
7382 {
7383 return "";
7384 }
7385
7387
7388 bool IsLightSource()
7389 {
7390 return false;
7391 }
7392
7394 {
7395 return true;
7396 }
7397
7398 //--- ACTION CONDITIONS
7399 //direction
7400 bool IsFacingPlayer(PlayerBase player, string selection)
7401 {
7402 return true;
7403 }
7404
7405 bool IsPlayerInside(PlayerBase player, string selection)
7406 {
7407 return true;
7408 }
7409
7410 override bool CanObstruct()
7411 {
7412 PlayerBase player = PlayerBase.Cast(g_Game.GetPlayer());
7413 return !player || !IsPlayerInside(player, "");
7414 }
7415
7416 override bool IsBeingPlaced()
7417 {
7418 return m_IsBeingPlaced;
7419 }
7420
7421 void SetIsBeingPlaced(bool is_being_placed)
7422 {
7423 m_IsBeingPlaced = is_being_placed;
7424 if (!is_being_placed)
7426 SetSynchDirty();
7427 }
7428
7429 //server-side
7430 void OnEndPlacement() {}
7431
7432 override bool IsHologram()
7433 {
7434 return m_IsHologram;
7435 }
7436
7437 bool CanBeDigged()
7438 {
7439 return m_CanBeDigged;
7440 }
7441
7443 {
7444 return 1;
7445 }
7446
7447 bool CanMakeGardenplot()
7448 {
7449 return false;
7450 }
7451
7452 void SetIsHologram(bool is_hologram)
7453 {
7454 m_IsHologram = is_hologram;
7455 SetSynchDirty();
7456 }
7457 /*
7458 protected float GetNutritionalEnergy()
7459 {
7460 Edible_Base edible = Edible_Base.Cast(this);
7461 return edible.GetFoodEnergy();
7462 }
7463
7464 protected float GetNutritionalWaterContent()
7465 {
7466 Edible_Base edible = Edible_Base.Cast(this);
7467 return edible.GetFoodWater();
7468 }
7469
7470 protected float GetNutritionalIndex()
7471 {
7472 Edible_Base edible = Edible_Base.Cast(this);
7473 return edible.GetFoodNutritionalIndex();
7474 }
7475
7476 protected float GetNutritionalFullnessIndex()
7477 {
7478 Edible_Base edible = Edible_Base.Cast(this);
7479 return edible.GetFoodTotalVolume();
7480 }
7481
7482 protected float GetNutritionalToxicity()
7483 {
7484 Edible_Base edible = Edible_Base.Cast(this);
7485 return edible.GetFoodToxicity();
7486
7487 }
7488 */
7489
7490
7491 // -------------------------------------------------------------------------
7492 override void OnMovedInsideCargo(EntityAI container)
7493 {
7494 super.OnMovedInsideCargo(container);
7495
7496 MiscGameplayFunctions.RemoveAllAttachedChildrenByTypename(this, {Bolt_Base});
7497 }
7498
7499 override void EEItemLocationChanged(notnull InventoryLocation oldLoc, notnull InventoryLocation newLoc)
7500 {
7501 super.EEItemLocationChanged(oldLoc,newLoc);
7502
7503 PlayerBase new_player = null;
7504 PlayerBase old_player = null;
7505
7506 if (newLoc.GetParent())
7507 new_player = PlayerBase.Cast(newLoc.GetParent().GetHierarchyRootPlayer());
7508
7509 if (oldLoc.GetParent())
7510 old_player = PlayerBase.Cast(oldLoc.GetParent().GetHierarchyRootPlayer());
7511
7512 if (old_player && oldLoc.GetType() == InventoryLocationType.HANDS)
7513 {
7514 int r_index = old_player.GetHumanInventory().FindUserReservedLocationIndex(this);
7515
7516 if (r_index >= 0)
7517 {
7518 InventoryLocation r_il = new InventoryLocation;
7519 old_player.GetHumanInventory().GetUserReservedLocation(r_index,r_il);
7520
7521 old_player.GetHumanInventory().ClearUserReservedLocationAtIndex(r_index);
7522 int r_type = r_il.GetType();
7523 if (r_type == InventoryLocationType.CARGO || r_type == InventoryLocationType.PROXYCARGO)
7524 {
7525 r_il.GetParent().GetOnReleaseLock().Invoke(this);
7526 }
7527 else if (r_type == InventoryLocationType.ATTACHMENT)
7528 {
7529 r_il.GetParent().GetOnAttachmentReleaseLock().Invoke(this, r_il.GetSlot());
7530 }
7531
7532 }
7533 }
7534
7535 if (newLoc.GetType() == InventoryLocationType.HANDS)
7536 {
7537 if (new_player)
7538 new_player.ForceStandUpForHeavyItems(newLoc.GetItem());
7539
7540 if (new_player == old_player)
7541 {
7542
7543 if (oldLoc.GetParent() && new_player.GetHumanInventory().LocationGetEntity(oldLoc) == NULL)
7544 {
7545 if (oldLoc.GetType() == InventoryLocationType.CARGO)
7546 {
7547 if (oldLoc.GetParent().GetInventory().TestAddEntityInCargoExLoc(oldLoc, false, false, false, true, false, false))
7548 {
7549 new_player.GetHumanInventory().SetUserReservedLocation(this,oldLoc);
7550 }
7551 }
7552 else
7553 {
7554 new_player.GetHumanInventory().SetUserReservedLocation(this,oldLoc);
7555 }
7556 }
7557
7558 if (new_player.GetHumanInventory().FindUserReservedLocationIndex(this) >= 0)
7559 {
7560 int type = oldLoc.GetType();
7561 if (type == InventoryLocationType.CARGO || type == InventoryLocationType.PROXYCARGO)
7562 {
7563 oldLoc.GetParent().GetOnSetLock().Invoke(this);
7564 }
7565 else if (type == InventoryLocationType.ATTACHMENT)
7566 {
7567 oldLoc.GetParent().GetOnAttachmentSetLock().Invoke(this, oldLoc.GetSlot());
7568 }
7569 }
7570 if (!m_OldLocation)
7571 {
7572 m_OldLocation = new InventoryLocation;
7573 }
7574 m_OldLocation.Copy(oldLoc);
7575 }
7576 else
7577 {
7578 if (m_OldLocation)
7579 {
7580 m_OldLocation.Reset();
7581 }
7582 }
7583
7585 }
7586 else
7587 {
7588 if (new_player)
7589 {
7590 int res_index = new_player.GetHumanInventory().FindCollidingUserReservedLocationIndex(this, newLoc);
7591 if (res_index >= 0)
7592 {
7593 InventoryLocation il = new InventoryLocation;
7594 new_player.GetHumanInventory().GetUserReservedLocation(res_index,il);
7595 ItemBase it = ItemBase.Cast(il.GetItem());
7596 new_player.GetHumanInventory().ClearUserReservedLocationAtIndex(res_index);
7597 int rel_type = il.GetType();
7598 if (rel_type == InventoryLocationType.CARGO || rel_type == InventoryLocationType.PROXYCARGO)
7599 {
7600 il.GetParent().GetOnReleaseLock().Invoke(it);
7601 }
7602 else if (rel_type == InventoryLocationType.ATTACHMENT)
7603 {
7604 il.GetParent().GetOnAttachmentReleaseLock().Invoke(it, il.GetSlot());
7605 }
7606 //it.GetOnReleaseLock().Invoke(it);
7607 }
7608 }
7609 else if (old_player && newLoc.GetType() == InventoryLocationType.GROUND && m_ThrowItemOnDrop)
7610 {
7611 //ThrowPhysically(old_player, vector.Zero);
7612 m_ThrowItemOnDrop = false;
7613 }
7614
7615 if (m_OldLocation)
7616 {
7617 m_OldLocation.Reset();
7618 }
7619 }
7620 }
7621
7622 override void EOnContact(IEntity other, Contact extra)
7623 {
7625 {
7626 int liquidType = -1;
7627 float impactSpeed = ProcessImpactSoundEx(other, extra, m_ConfigWeight, m_ImpactSoundSurfaceHash, liquidType);
7628 if (impactSpeed > 0.0)
7629 {
7630 m_ImpactSpeed = impactSpeed;
7631 #ifndef SERVER
7632 PlayImpactSound(m_ConfigWeight, m_ImpactSpeed, m_ImpactSoundSurfaceHash);
7633 #else
7634 m_WantPlayImpactSound = true;
7635 SetSynchDirty();
7636 #endif
7637 m_CanPlayImpactSound = (liquidType == -1);// prevents further playing of the sound when the surface is a liquid type
7638 }
7639 }
7640
7641 #ifdef SERVER
7642 if (GetCompEM() && GetCompEM().IsPlugged())
7643 {
7644 if (GetCompEM().GetCordLength() < vector.Distance(GetPosition(), GetCompEM().GetEnergySource().GetPosition()))
7645 GetCompEM().UnplugThis();
7646 }
7647 #endif
7648 }
7649
7650 void RefreshPhysics();
7651
7652 override void OnCreatePhysics()
7653 {
7655 }
7656
7657 override void OnItemAttachmentSlotChanged(notnull InventoryLocation oldLoc, notnull InventoryLocation newLoc)
7658 {
7659
7660 }
7661 // -------------------------------------------------------------------------
7662 override void OnItemLocationChanged(EntityAI old_owner, EntityAI new_owner)
7663 {
7664 super.OnItemLocationChanged(old_owner, new_owner);
7665
7666 PlayerBase relatedPlayer = PlayerBase.Cast(old_owner);
7667 PlayerBase playerNew = PlayerBase.Cast(new_owner);
7668
7669 if (!relatedPlayer && playerNew)
7670 relatedPlayer = playerNew;
7671
7672 if (relatedPlayer && relatedPlayer.GetPerformedActionID() != -1)
7673 {
7674 ActionManagerBase actionMgr = relatedPlayer.GetActionManager();
7675 if (actionMgr)
7676 {
7677 ActionBase currentAction = actionMgr.GetRunningAction();
7678 if (currentAction)
7679 currentAction.OnItemLocationChanged(this);
7680 }
7681 }
7682
7683 Man ownerPlayerOld = null;
7684 Man ownerPlayerNew = null;
7685
7686 if (old_owner)
7687 {
7688 if (old_owner.IsMan())
7689 {
7690 ownerPlayerOld = Man.Cast(old_owner);
7691 }
7692 else
7693 {
7694 ownerPlayerOld = Man.Cast(old_owner.GetHierarchyRootPlayer());
7695 }
7696 }
7697 else
7698 {
7699 if (new_owner && IsElectricAppliance() && GetCompEM() && GetCompEM().IsPlugged())
7700 {
7701 ActionBase action = ActionManagerBase.GetAction(ActionRepositionPluggedItem);
7702
7703 if (!action || !playerNew || playerNew.GetPerformedActionID() != action.GetID())
7704 {
7705 GetCompEM().UnplugThis();
7706 }
7707 }
7708 }
7709
7710 if (new_owner)
7711 {
7712 if (new_owner.IsMan())
7713 {
7714 ownerPlayerNew = Man.Cast(new_owner);
7715 }
7716 else
7717 {
7718 ownerPlayerNew = Man.Cast(new_owner.GetHierarchyRootPlayer());
7719 }
7720 }
7721
7722 if (ownerPlayerOld != ownerPlayerNew)
7723 {
7724 if (ownerPlayerOld)
7725 {
7726 array<EntityAI> subItemsExit = new array<EntityAI>;
7727 GetInventory().EnumerateInventory(InventoryTraversalType.PREORDER,subItemsExit);
7728 for (int i = 0; i < subItemsExit.Count(); i++)
7729 {
7730 ItemBase itemExit = ItemBase.Cast(subItemsExit.Get(i));
7731 itemExit.OnInventoryExit(ownerPlayerOld);
7732 }
7733 }
7734
7735 if (ownerPlayerNew)
7736 {
7737 array<EntityAI> subItemsEnter = new array<EntityAI>;
7738 GetInventory().EnumerateInventory(InventoryTraversalType.PREORDER,subItemsEnter);
7739 for (int j = 0; j < subItemsEnter.Count(); j++)
7740 {
7741 ItemBase itemEnter = ItemBase.Cast(subItemsEnter.Get(j));
7742 itemEnter.OnInventoryEnter(ownerPlayerNew);
7743 }
7744 }
7745 }
7746 else if (ownerPlayerNew != null)
7747 {
7748 PlayerBase nplayer;
7749 if (PlayerBase.CastTo(nplayer, ownerPlayerNew))
7750 {
7751 array<EntityAI> subItemsUpdate = new array<EntityAI>;
7752 GetInventory().EnumerateInventory(InventoryTraversalType.PREORDER,subItemsUpdate);
7753 for (int k = 0; k < subItemsUpdate.Count(); k++)
7754 {
7755 ItemBase itemUpdate = ItemBase.Cast(subItemsUpdate.Get(k));
7756 itemUpdate.UpdateQuickbarShortcutVisibility(nplayer);
7757 }
7758 }
7759 }
7760
7761 if (old_owner)
7762 old_owner.OnChildItemRemoved(this);
7763 if (new_owner)
7764 new_owner.OnChildItemReceived(this);
7765 }
7766
7767 // -------------------------------------------------------------------------------
7768 override void EEDelete(EntityAI parent)
7769 {
7770 super.EEDelete(parent);
7771 PlayerBase player = PlayerBase.Cast(GetHierarchyRootPlayer());
7772 if (player)
7773 {
7774 OnInventoryExit(player);
7775
7776 if (player.IsAlive())
7777 {
7778 int r_index = player.GetHumanInventory().FindUserReservedLocationIndex(this);
7779 if (r_index >= 0)
7780 {
7781 InventoryLocation r_il = new InventoryLocation;
7782 player.GetHumanInventory().GetUserReservedLocation(r_index,r_il);
7783
7784 player.GetHumanInventory().ClearUserReservedLocationAtIndex(r_index);
7785 int r_type = r_il.GetType();
7786 if (r_type == InventoryLocationType.CARGO || r_type == InventoryLocationType.PROXYCARGO)
7787 {
7788 r_il.GetParent().GetOnReleaseLock().Invoke(this);
7789 }
7790 else if (r_type == InventoryLocationType.ATTACHMENT)
7791 {
7792 r_il.GetParent().GetOnAttachmentReleaseLock().Invoke(this, r_il.GetSlot());
7793 }
7794
7795 }
7796
7797 player.RemoveQuickBarEntityShortcut(this);
7798 }
7799 }
7800 }
7801 // -------------------------------------------------------------------------------
7802 override void EEKilled(Object killer)
7803 {
7804 super.EEKilled(killer);
7805
7807 if (killer && killer.IsFireplace() && CanExplodeInFire())
7808 {
7809 if (GetTemperature() >= GameConstants.ITEM_TEMPERATURE_TO_EXPLODE_MIN)
7810 {
7811 if (IsMagazine())
7812 {
7813 if (Magazine.Cast(this).GetAmmoCount() > 0)
7814 {
7815 ExplodeAmmo();
7816 }
7817 }
7818 else
7819 {
7820 Explode(DamageType.EXPLOSION);
7821 }
7822 }
7823 }
7824 }
7825
7826 override void OnWasAttached(EntityAI parent, int slot_id)
7827 {
7828 MiscGameplayFunctions.RemoveAllAttachedChildrenByTypename(this, {Bolt_Base});
7829
7830 super.OnWasAttached(parent, slot_id);
7831
7832 if (HasQuantity())
7833 UpdateNetSyncVariableFloat("m_VarQuantity", GetQuantityMin(), m_VarQuantityMax);
7834
7835 PlayAttachSound(InventorySlots.GetSlotName(slot_id));
7836 }
7837
7838 override void OnWasDetached(EntityAI parent, int slot_id)
7839 {
7840 super.OnWasDetached(parent, slot_id);
7841
7842 if (HasQuantity())
7843 UpdateNetSyncVariableFloat("m_VarQuantity", GetQuantityMin(), m_VarQuantityMax);
7844 }
7845
7846 override string ChangeIntoOnAttach(string slot)
7847 {
7848 int idx;
7849 TStringArray inventory_slots = new TStringArray;
7850 TStringArray attach_types = new TStringArray;
7851
7852 ConfigGetTextArray("ChangeInventorySlot",inventory_slots);
7853 if (inventory_slots.Count() < 1) //is string
7854 {
7855 inventory_slots.Insert(ConfigGetString("ChangeInventorySlot"));
7856 attach_types.Insert(ConfigGetString("ChangeIntoOnAttach"));
7857 }
7858 else //is array
7859 {
7860 ConfigGetTextArray("ChangeIntoOnAttach",attach_types);
7861 }
7862
7863 idx = inventory_slots.Find(slot);
7864 if (idx < 0)
7865 return "";
7866
7867 return attach_types.Get(idx);
7868 }
7869
7870 override string ChangeIntoOnDetach()
7871 {
7872 int idx = -1;
7873 string slot;
7874
7875 TStringArray inventory_slots = new TStringArray;
7876 TStringArray detach_types = new TStringArray;
7877
7878 this.ConfigGetTextArray("ChangeInventorySlot",inventory_slots);
7879 if (inventory_slots.Count() < 1) //is string
7880 {
7881 inventory_slots.Insert(this.ConfigGetString("ChangeInventorySlot"));
7882 detach_types.Insert(this.ConfigGetString("ChangeIntoOnDetach"));
7883 }
7884 else //is array
7885 {
7886 this.ConfigGetTextArray("ChangeIntoOnDetach",detach_types);
7887 if (detach_types.Count() < 1)
7888 detach_types.Insert(this.ConfigGetString("ChangeIntoOnDetach"));
7889 }
7890
7891 for (int i = 0; i < inventory_slots.Count(); i++)
7892 {
7893 slot = inventory_slots.Get(i);
7894 }
7895
7896 if (slot != "")
7897 {
7898 if (detach_types.Count() == 1)
7899 idx = 0;
7900 else
7901 idx = inventory_slots.Find(slot);
7902 }
7903 if (idx < 0)
7904 return "";
7905
7906 return detach_types.Get(idx);
7907 }
7908
7909 void ExplodeAmmo()
7910 {
7911 //timer
7912 ref Timer explode_timer = new Timer(CALL_CATEGORY_SYSTEM);
7913
7914 //min/max time
7915 float min_time = 1;
7916 float max_time = 3;
7917 float delay = Math.RandomFloat(min_time, max_time);
7918
7919 explode_timer.Run(delay, this, "DoAmmoExplosion");
7920 }
7921
7922 void DoAmmoExplosion()
7923 {
7924 Magazine magazine = Magazine.Cast(this);
7925 int pop_sounds_count = 6;
7926 string pop_sounds[ 6 ] = { "ammopops_1","ammopops_2","ammopops_3","ammopops_4","ammopops_5","ammopops_6" };
7927
7928 //play sound
7929 int sound_idx = Math.RandomInt(0, pop_sounds_count - 1);
7930 string sound_name = pop_sounds[ sound_idx ];
7931 GetGame().CreateSoundOnObject(this, sound_name, 20, false);
7932
7933 //remove ammo count
7934 magazine.ServerAddAmmoCount(-1);
7935
7936 //if condition then repeat -> ExplodeAmmo
7937 float min_temp_to_explode = 100; //min temperature for item to explode
7938
7939 if (magazine.GetAmmoCount() > 0 && GetTemperature() >= min_temp_to_explode) //TODO ? add check for parent -> fireplace
7940 {
7941 ExplodeAmmo();
7942 }
7943 }
7944
7945 // -------------------------------------------------------------------------------
7946 override void EEHitBy(TotalDamageResult damageResult, int damageType, EntityAI source, int component, string dmgZone, string ammo, vector modelPos, float speedCoef)
7947 {
7948 super.EEHitBy(damageResult, damageType, source, component, dmgZone, ammo, modelPos, speedCoef);
7949
7950 const int CHANCE_DAMAGE_CARGO = 4;
7951 const int CHANCE_DAMAGE_ATTACHMENT = 1;
7952 const int CHANCE_DAMAGE_NOTHING = 2;
7953
7954 if (IsClothing() || IsContainer() || IsItemTent())
7955 {
7956 float dmg = damageResult.GetDamage("","Health") * -0.5;
7957 int chances;
7958 int rnd;
7959
7960 if (GetInventory().GetCargo())
7961 {
7962 chances = CHANCE_DAMAGE_CARGO + CHANCE_DAMAGE_ATTACHMENT + CHANCE_DAMAGE_NOTHING;
7963 rnd = Math.RandomInt(0,chances);
7964
7965 if (rnd < CHANCE_DAMAGE_CARGO)
7966 {
7967 DamageItemInCargo(dmg);
7968 }
7969 else if (rnd < (chances - CHANCE_DAMAGE_NOTHING))
7970 {
7972 }
7973 }
7974 else
7975 {
7976 chances = CHANCE_DAMAGE_ATTACHMENT + CHANCE_DAMAGE_NOTHING;
7977 rnd = Math.RandomInt(0,chances);
7978
7979 if (rnd < CHANCE_DAMAGE_ATTACHMENT)
7980 {
7982 }
7983 }
7984 }
7985 }
7986
7987 bool DamageItemInCargo(float damage)
7988 {
7989 if (GetInventory().GetCargo())
7990 {
7991 int item_count = GetInventory().GetCargo().GetItemCount();
7992 if (item_count > 0)
7993 {
7994 int random_pick = Math.RandomInt(0, item_count);
7995 ItemBase item = ItemBase.Cast(GetInventory().GetCargo().GetItem(random_pick));
7996 if (!item.IsExplosive())
7997 {
7998 item.AddHealth("","",damage);
7999 return true;
8000 }
8001 }
8002 }
8003 return false;
8004 }
8005
8006 bool DamageItemAttachments(float damage)
8007 {
8008 int attachment_count = GetInventory().AttachmentCount();
8009 if (attachment_count > 0)
8010 {
8011 int random_pick = Math.RandomInt(0, attachment_count);
8012 ItemBase attachment = ItemBase.Cast(GetInventory().GetAttachmentFromIndex(random_pick));
8013 if (!attachment.IsExplosive())
8014 {
8015 attachment.AddHealth("","",damage);
8016 return true;
8017 }
8018 }
8019 return false;
8020 }
8021
8022 override bool IsSplitable()
8023 {
8024 return m_CanThisBeSplit;
8025 }
8026 //----------------
8027 override bool CanBeSplit()
8028 {
8029 if (IsSplitable() && (GetQuantity() > 1))
8030 return GetInventory().CanRemoveEntity();
8031
8032 return false;
8033 }
8034
8035 protected bool ShouldSplitQuantity(float quantity)
8036 {
8037 // don't call 'CanBeSplit' here, too strict and will introduce a freeze-crash when dismantling fence with a fireplace nearby
8038 if (!IsSplitable())
8039 return false;
8040
8041 // nothing to split?
8042 if (GetQuantity() <= 1)
8043 return false;
8044
8045 // check if we should re-use the item instead of creating a new copy?
8046 // implicit cast to int, if 'IsSplitable' returns true, these values are assumed ints
8047 int delta = GetQuantity() - quantity;
8048 if (delta == 0)
8049 return false;
8050
8051 // valid to split
8052 return true;
8053 }
8054
8055 override void SplitIntoStackMaxClient(EntityAI destination_entity, int slot_id )
8056 {
8057 if (GetGame().IsClient())
8058 {
8059 if (ScriptInputUserData.CanStoreInputUserData())
8060 {
8061 ScriptInputUserData ctx = new ScriptInputUserData;
8063 ctx.Write(1);
8064 ItemBase i1 = this; // @NOTE: workaround for correct serialization
8065 ctx.Write(i1);
8066 ctx.Write(destination_entity);
8067 ctx.Write(true);
8068 ctx.Write(slot_id);
8069 ctx.Send();
8070 }
8071 }
8072 else if (!GetGame().IsMultiplayer())
8073 {
8074 SplitIntoStackMax(destination_entity, slot_id, PlayerBase.Cast(GetGame().GetPlayer()));
8075 }
8076 }
8077
8078 void SplitIntoStackMax(EntityAI destination_entity, int slot_id, PlayerBase player)
8079 {
8080 float split_quantity_new;
8081 ItemBase new_item;
8082 float quantity = GetQuantity();
8083 float stack_max = GetTargetQuantityMax(slot_id);
8084 InventoryLocation loc = new InventoryLocation;
8085
8086 if (destination_entity && slot_id != -1 && InventorySlots.IsSlotIdValid(slot_id))
8087 {
8088 if (stack_max <= GetQuantity())
8089 split_quantity_new = stack_max;
8090 else
8091 split_quantity_new = GetQuantity();
8092
8093 if (ShouldSplitQuantity(split_quantity_new))
8094 {
8095 new_item = ItemBase.Cast(destination_entity.GetInventory().CreateAttachmentEx(this.GetType(), slot_id));
8096 if (new_item)
8097 {
8098 new_item.SetResultOfSplit(true);
8099 MiscGameplayFunctions.TransferItemProperties(this, new_item);
8100 AddQuantity(-split_quantity_new, false, true);
8101 new_item.SetQuantity(split_quantity_new, false, true);
8102 }
8103 }
8104 }
8105 else if (destination_entity && slot_id == -1)
8106 {
8107 if (quantity > stack_max)
8108 split_quantity_new = stack_max;
8109 else
8110 split_quantity_new = quantity;
8111
8112 if (ShouldSplitQuantity(split_quantity_new))
8113 {
8114 if (destination_entity.GetInventory().FindFreeLocationFor(this, FindInventoryLocationType.ANY, loc))
8115 {
8116 Object o = destination_entity.GetInventory().LocationCreateEntity(loc, GetType(), ECE_IN_INVENTORY, RF_DEFAULT);
8117 new_item = ItemBase.Cast(o);
8118 }
8119
8120 if (new_item)
8121 {
8122 new_item.SetResultOfSplit(true);
8123 MiscGameplayFunctions.TransferItemProperties(this, new_item);
8124 AddQuantity(-split_quantity_new, false, true);
8125 new_item.SetQuantity(split_quantity_new, false, true);
8126 }
8127 }
8128 }
8129 else
8130 {
8131 if (stack_max != 0)
8132 {
8133 if (stack_max < GetQuantity())
8134 {
8135 split_quantity_new = GetQuantity() - stack_max;
8136 }
8137
8138 if (split_quantity_new == 0)
8139 {
8140 if (!GetGame().IsMultiplayer())
8141 player.PhysicalPredictiveDropItem(this);
8142 else
8143 player.ServerDropEntity(this);
8144 return;
8145 }
8146
8147 if (ShouldSplitQuantity(split_quantity_new))
8148 {
8149 new_item = ItemBase.Cast(GetGame().CreateObjectEx(GetType(), player.GetWorldPosition(), ECE_PLACE_ON_SURFACE));
8150
8151 if (new_item)
8152 {
8153 new_item.SetResultOfSplit(true);
8154 MiscGameplayFunctions.TransferItemProperties(this, new_item);
8155 SetQuantity(split_quantity_new, false, true);
8156 new_item.SetQuantity(stack_max, false, true);
8157 new_item.PlaceOnSurface();
8158 }
8159 }
8160 }
8161 }
8162 }
8163
8164 override void SplitIntoStackMaxEx(EntityAI destination_entity, int slot_id)
8165 {
8166 float split_quantity_new;
8167 ItemBase new_item;
8168 float quantity = GetQuantity();
8169 float stack_max = GetTargetQuantityMax(slot_id);
8170 InventoryLocation loc = new InventoryLocation;
8171
8172 if (destination_entity && slot_id != -1 && InventorySlots.IsSlotIdValid(slot_id))
8173 {
8174 if (stack_max <= GetQuantity())
8175 split_quantity_new = stack_max;
8176 else
8177 split_quantity_new = GetQuantity();
8178
8179 if (ShouldSplitQuantity(split_quantity_new))
8180 {
8181 new_item = ItemBase.Cast(destination_entity.GetInventory().CreateAttachmentEx(this.GetType(), slot_id));
8182 if (new_item)
8183 {
8184 new_item.SetResultOfSplit(true);
8185 MiscGameplayFunctions.TransferItemProperties(this, new_item);
8186 AddQuantity(-split_quantity_new, false, true);
8187 new_item.SetQuantity(split_quantity_new, false, true);
8188 }
8189 }
8190 }
8191 else if (destination_entity && slot_id == -1)
8192 {
8193 if (quantity > stack_max)
8194 split_quantity_new = stack_max;
8195 else
8196 split_quantity_new = quantity;
8197
8198 if (ShouldSplitQuantity(split_quantity_new))
8199 {
8200 if (destination_entity.GetInventory().FindFreeLocationFor(this, FindInventoryLocationType.ANY, loc))
8201 {
8202 Object o = destination_entity.GetInventory().LocationCreateEntity(loc, GetType(), ECE_IN_INVENTORY, RF_DEFAULT);
8203 new_item = ItemBase.Cast(o);
8204 }
8205
8206 if (new_item)
8207 {
8208 new_item.SetResultOfSplit(true);
8209 MiscGameplayFunctions.TransferItemProperties(this, new_item);
8210 AddQuantity(-split_quantity_new, false, true);
8211 new_item.SetQuantity(split_quantity_new, false, true);
8212 }
8213 }
8214 }
8215 else
8216 {
8217 if (stack_max != 0)
8218 {
8219 if (stack_max < GetQuantity())
8220 {
8221 split_quantity_new = GetQuantity() - stack_max;
8222 }
8223
8224 if (ShouldSplitQuantity(split_quantity_new))
8225 {
8226 new_item = ItemBase.Cast(GetGame().CreateObjectEx(GetType(),GetWorldPosition(), ECE_PLACE_ON_SURFACE));
8227
8228 if (new_item)
8229 {
8230 new_item.SetResultOfSplit(true);
8231 MiscGameplayFunctions.TransferItemProperties(this, new_item);
8232 SetQuantity(split_quantity_new, false, true);
8233 new_item.SetQuantity(stack_max, false, true);
8234 new_item.PlaceOnSurface();
8235 }
8236 }
8237 }
8238 }
8239 }
8240
8241 void SplitIntoStackMaxToInventoryLocationClient(notnull InventoryLocation dst)
8242 {
8243 if (GetGame().IsClient())
8244 {
8245 if (ScriptInputUserData.CanStoreInputUserData())
8246 {
8247 ScriptInputUserData ctx = new ScriptInputUserData;
8249 ctx.Write(4);
8250 ItemBase thiz = this; // @NOTE: workaround for correct serialization
8251 ctx.Write(thiz);
8252 dst.WriteToContext(ctx);
8253 ctx.Send();
8254 }
8255 }
8256 else if (!GetGame().IsMultiplayer())
8257 {
8259 }
8260 }
8261
8262 void SplitIntoStackMaxCargoClient(EntityAI destination_entity, int idx, int row, int col)
8263 {
8264 if (GetGame().IsClient())
8265 {
8266 if (ScriptInputUserData.CanStoreInputUserData())
8267 {
8268 ScriptInputUserData ctx = new ScriptInputUserData;
8270 ctx.Write(2);
8271 ItemBase dummy = this; // @NOTE: workaround for correct serialization
8272 ctx.Write(dummy);
8273 ctx.Write(destination_entity);
8274 ctx.Write(true);
8275 ctx.Write(idx);
8276 ctx.Write(row);
8277 ctx.Write(col);
8278 ctx.Send();
8279 }
8280 }
8281 else if (!GetGame().IsMultiplayer())
8282 {
8283 SplitIntoStackMaxCargo(destination_entity, idx, row, col);
8284 }
8285 }
8286
8287 void SplitIntoStackMaxToInventoryLocation(notnull InventoryLocation dst)
8288 {
8290 }
8291
8292 ItemBase SplitIntoStackMaxToInventoryLocationEx(notnull InventoryLocation dst)
8293 {
8294 float quantity = GetQuantity();
8295 float split_quantity_new;
8296 ItemBase new_item;
8297 if (dst.IsValid())
8298 {
8299 int slot_id = dst.GetSlot();
8300 float stack_max = GetTargetQuantityMax(slot_id);
8301
8302 if (quantity > stack_max)
8303 split_quantity_new = stack_max;
8304 else
8305 split_quantity_new = quantity;
8306
8307 if (ShouldSplitQuantity(split_quantity_new))
8308 {
8309 new_item = ItemBase.Cast(GameInventory.LocationCreateEntity(dst, this.GetType(), ECE_IN_INVENTORY, RF_DEFAULT));
8310
8311 if (new_item)
8312 {
8313 new_item.SetResultOfSplit(true);
8314 MiscGameplayFunctions.TransferItemProperties(this,new_item);
8315 AddQuantity(-split_quantity_new, false, true);
8316 new_item.SetQuantity(split_quantity_new, false, true);
8317 }
8318
8319 return new_item;
8320 }
8321 }
8322
8323 return null;
8324 }
8325
8326 void SplitIntoStackMaxCargo(EntityAI destination_entity, int idx, int row, int col)
8327 {
8328 float quantity = GetQuantity();
8329 float split_quantity_new;
8330 ItemBase new_item;
8331 if (destination_entity)
8332 {
8333 float stackable = GetTargetQuantityMax();
8334 if (quantity > stackable)
8335 split_quantity_new = stackable;
8336 else
8337 split_quantity_new = quantity;
8338
8339 if (ShouldSplitQuantity(split_quantity_new))
8340 {
8341 new_item = ItemBase.Cast(destination_entity.GetInventory().CreateEntityInCargoEx(this.GetType(), idx, row, col, false));
8342 if (new_item)
8343 {
8344 new_item.SetResultOfSplit(true);
8345 MiscGameplayFunctions.TransferItemProperties(this,new_item);
8346 AddQuantity(-split_quantity_new, false, true);
8347 new_item.SetQuantity(split_quantity_new, false, true);
8348 }
8349 }
8350 }
8351 }
8352
8353 void SplitIntoStackMaxHandsClient(PlayerBase player)
8354 {
8355 if (GetGame().IsClient())
8356 {
8357 if (ScriptInputUserData.CanStoreInputUserData())
8358 {
8359 ScriptInputUserData ctx = new ScriptInputUserData;
8361 ctx.Write(3);
8362 ItemBase i1 = this; // @NOTE: workaround for correct serialization
8363 ctx.Write(i1);
8364 ItemBase destination_entity = this;
8365 ctx.Write(destination_entity);
8366 ctx.Write(true);
8367 ctx.Write(0);
8368 ctx.Send();
8369 }
8370 }
8371 else if (!GetGame().IsMultiplayer())
8372 {
8373 SplitIntoStackMaxHands(player);
8374 }
8375 }
8376
8377 void SplitIntoStackMaxHands(PlayerBase player)
8378 {
8379 float quantity = GetQuantity();
8380 float split_quantity_new;
8381 ref ItemBase new_item;
8382 if (player)
8383 {
8384 float stackable = GetTargetQuantityMax();
8385 if (quantity > stackable)
8386 split_quantity_new = stackable;
8387 else
8388 split_quantity_new = quantity;
8389
8390 if (ShouldSplitQuantity(split_quantity_new))
8391 {
8392 EntityAI in_hands = player.GetHumanInventory().CreateInHands(this.GetType());
8393 new_item = ItemBase.Cast(in_hands);
8394 if (new_item)
8395 {
8396 new_item.SetResultOfSplit(true);
8397 MiscGameplayFunctions.TransferItemProperties(this,new_item);
8398 AddQuantity(-split_quantity_new, false, true);
8399 new_item.SetQuantity(split_quantity_new, false, true);
8400 }
8401 }
8402 }
8403 }
8404
8405 void SplitItemToInventoryLocation(notnull InventoryLocation dst)
8406 {
8407 float quantity = GetQuantity();
8408 float split_quantity_new = Math.Floor(quantity * 0.5);
8409
8410 if (!ShouldSplitQuantity(split_quantity_new))
8411 return;
8412
8413 ItemBase new_item = ItemBase.Cast(GameInventory.LocationCreateEntity(dst, GetType(), ECE_IN_INVENTORY, RF_DEFAULT));
8414
8415 if (new_item)
8416 {
8417 if (new_item.GetQuantityMax() < split_quantity_new)
8418 {
8419 split_quantity_new = new_item.GetQuantityMax();
8420 }
8421
8422 new_item.SetResultOfSplit(true);
8423 MiscGameplayFunctions.TransferItemProperties(this, new_item);
8424
8425 if (dst.IsValid() && dst.GetType() == InventoryLocationType.ATTACHMENT && split_quantity_new > 1)
8426 {
8427 AddQuantity(-1, false, true);
8428 new_item.SetQuantity(1, false, true);
8429 }
8430 else
8431 {
8432 AddQuantity(-split_quantity_new, false, true);
8433 new_item.SetQuantity(split_quantity_new, false, true);
8434 }
8435 }
8436 }
8437
8438 void SplitItem(PlayerBase player)
8439 {
8440 float quantity = GetQuantity();
8441 float split_quantity_new = Math.Floor(quantity / 2);
8442
8443 if (!ShouldSplitQuantity(split_quantity_new))
8444 return;
8445
8446 InventoryLocation invloc = new InventoryLocation;
8447 bool found = player.GetInventory().FindFirstFreeLocationForNewEntity(GetType(), FindInventoryLocationType.ATTACHMENT, invloc);
8448
8449 ItemBase new_item;
8450 new_item = player.CreateCopyOfItemInInventoryOrGroundEx(this, true);
8451
8452 if (new_item)
8453 {
8454 if (new_item.GetQuantityMax() < split_quantity_new)
8455 {
8456 split_quantity_new = new_item.GetQuantityMax();
8457 }
8458 if (found && invloc.IsValid() && invloc.GetType() == InventoryLocationType.ATTACHMENT && split_quantity_new > 1)
8459 {
8460 AddQuantity(-1, false, true);
8461 new_item.SetQuantity(1, false, true);
8462 }
8463 else if (split_quantity_new > 1)
8464 {
8465 AddQuantity(-split_quantity_new, false, true);
8466 new_item.SetQuantity(split_quantity_new, false, true);
8467 }
8468 }
8469 }
8470
8472 void OnQuantityChanged(float delta)
8473 {
8474 SetWeightDirty();
8475 ItemBase parent = ItemBase.Cast(GetHierarchyParent());
8476
8477 if (parent)
8478 parent.OnAttachmentQuantityChangedEx(this, delta);
8479
8480 if (IsLiquidContainer())
8481 {
8482 if (GetQuantityNormalized() <= 0.0)
8483 {
8485 }
8486 else if (GetLiquidType() == LIQUID_NONE)
8487 {
8488 ErrorEx("Undefined liquid type quantity changed, please define liquid type first! Using init value.",ErrorExSeverity.INFO);
8490 }
8491 }
8492
8493 }
8494
8497 {
8498 // insert code here
8499 }
8500
8502 void OnAttachmentQuantityChangedEx(ItemBase item , float delta)
8503 {
8505 }
8506
8507 override void EEHealthLevelChanged(int oldLevel, int newLevel, string zone)
8508 {
8509 super.EEHealthLevelChanged(oldLevel,newLevel,zone);
8510
8511 if (GetGame().IsServer())
8512 {
8513 if (newLevel == GameConstants.STATE_RUINED)
8514 {
8516 EntityAI parent = GetHierarchyParent();
8517 if (parent && parent.IsFireplace())
8518 {
8519 CargoBase cargo = GetInventory().GetCargo();
8520 if (cargo)
8521 {
8522 for (int i = 0; i < cargo.GetItemCount(); ++i)
8523 {
8524 parent.GetInventory().TakeEntityToInventory(InventoryMode.SERVER, FindInventoryLocationType.CARGO, cargo.GetItem(i));
8525 }
8526 }
8527 }
8528 }
8529
8530 if (IsResultOfSplit())
8531 {
8532 // reset the splitting result flag, return to normal item behavior
8533 SetResultOfSplit(false);
8534 return;
8535 }
8536
8537 if (m_Cleanness != 0 && oldLevel < newLevel && newLevel != 0)
8538 {
8539 SetCleanness(0);//unclean the item upon damage dealt
8540 }
8541 }
8542 }
8543
8544 // just the split? TODO: verify
8545 override void OnRightClick()
8546 {
8547 super.OnRightClick();
8548
8549 if (CanBeSplit() && !GetDayZGame().IsLeftCtrlDown() && !GetGame().GetPlayer().GetInventory().HasInventoryReservation(this,null))
8550 {
8551 if (GetGame().IsClient())
8552 {
8553 if (ScriptInputUserData.CanStoreInputUserData())
8554 {
8555 EntityAI root = GetHierarchyRoot();
8556 Man playerOwner = GetHierarchyRootPlayer();
8557 InventoryLocation dst = new InventoryLocation;
8558
8559 // 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
8560 if (!playerOwner && root && root == this)
8561 {
8563 }
8564 else
8565 {
8566 // 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
8567 GetInventory().GetCurrentInventoryLocation(dst);
8568 if (!dst.GetParent() || dst.GetParent() && !dst.GetParent().GetInventory().FindFreeLocationFor(this, FindInventoryLocationType.CARGO, dst))
8569 {
8570 PlayerBase player = PlayerBase.Cast(GetGame().GetPlayer());
8571 if (!player.GetInventory().FindFreeLocationFor(this, FindInventoryLocationType.CARGO, dst) || !playerOwner)
8572 {
8574 }
8575 else
8576 {
8577 dst.SetCargo(dst.GetParent(), this, dst.GetIdx(), dst.GetRow(), dst.GetCol(), dst.GetFlip());
8578 /* hacky solution to check reservation of "this" item instead of null since the gamecode is checking null against null and returning reservation=true incorrectly
8579 this shouldnt cause issues within this scope*/
8580 if (GetGame().GetPlayer().GetInventory().HasInventoryReservation(this, dst))
8581 {
8583 }
8584 else
8585 {
8586 GetGame().GetPlayer().GetInventory().AddInventoryReservationEx(null, dst, GameInventory.c_InventoryReservationTimeoutShortMS);
8587 }
8588 }
8589 }
8590 }
8591
8592 ScriptInputUserData ctx = new ScriptInputUserData;
8594 ctx.Write(4);
8595 ItemBase thiz = this; // @NOTE: workaround for correct serialization
8596 ctx.Write(thiz);
8597 dst.WriteToContext(ctx);
8598 ctx.Write(true); // dummy
8599 ctx.Send();
8600 }
8601 }
8602 else if (!GetGame().IsMultiplayer())
8603 {
8604 SplitItem(PlayerBase.Cast(GetGame().GetPlayer()));
8605 }
8606 }
8607 }
8608
8609 protected void SetInventoryLocationToVicinityOrCurrent(EntityAI root, inout InventoryLocation dst)
8610 {
8611 if (root)
8612 {
8613 vector m4[4];
8614 root.GetTransform(m4);
8615 dst.SetGround(this, m4);
8616 }
8617 else
8618 {
8619 GetInventory().GetCurrentInventoryLocation(dst);
8620 }
8621 }
8622
8623 override bool CanBeCombined(EntityAI other_item, bool reservation_check = true, bool stack_max_limit = false)
8624 {
8625 //TODO: delete check zero quantity check after fix double posts hands fsm events
8626 if (!other_item || GetType() != other_item.GetType() || (IsFullQuantity() && other_item.GetQuantity() > 0) || other_item == this)
8627 return false;
8628
8629 if (GetHealthLevel() == GameConstants.STATE_RUINED || other_item.GetHealthLevel() == GameConstants.STATE_RUINED)
8630 return false;
8631
8632 //can_this_be_combined = ConfigGetBool("canBeSplit");
8634 return false;
8635
8636
8637 Magazine mag = Magazine.Cast(this);
8638 if (mag)
8639 {
8640 if (mag.GetAmmoCount() >= mag.GetAmmoMax())
8641 return false;
8642
8643 if (stack_max_limit)
8644 {
8645 Magazine other_mag = Magazine.Cast(other_item);
8646 if (other_item)
8647 {
8648 if (mag.GetAmmoCount() + other_mag.GetAmmoCount() > mag.GetAmmoMax())
8649 return false;
8650 }
8651
8652 }
8653 }
8654 else
8655 {
8656 //TODO: delete check zero quantity check after fix double posts hands fsm events
8657 if (GetQuantity() >= GetQuantityMax() && other_item.GetQuantity() > 0 )
8658 return false;
8659
8660 if (stack_max_limit && (GetQuantity() + other_item.GetQuantity() > GetQuantityMax()))
8661 return false;
8662 }
8663
8664 PlayerBase player = null;
8665 if (CastTo(player, GetHierarchyRootPlayer())) //false when attached to player's attachment slot
8666 {
8667 if (player.GetInventory().HasAttachment(this))
8668 return false;
8669
8670 if (player.IsItemsToDelete())
8671 return false;
8672 }
8673
8674 if (reservation_check && (GetInventory().HasInventoryReservation(this, null) || other_item.GetInventory().HasInventoryReservation(other_item, null)))
8675 return false;
8676
8677 int slotID;
8678 string slotName;
8679 if (GetInventory().GetCurrentAttachmentSlotInfo(slotID,slotName) && GetHierarchyParent().GetInventory().GetSlotLock(slotID))
8680 return false;
8681
8682 return true;
8683 }
8684
8685 bool IsCombineAll(ItemBase other_item, bool use_stack_max = false)
8686 {
8687 return ComputeQuantityUsed(other_item, use_stack_max) == other_item.GetQuantity();
8688 }
8689
8690 bool IsResultOfSplit()
8691 {
8692 return m_IsResultOfSplit;
8693 }
8694
8695 void SetResultOfSplit(bool value)
8696 {
8697 m_IsResultOfSplit = value;
8698 }
8699
8700 int ComputeQuantityUsed(ItemBase other_item, bool use_stack_max = true)
8701 {
8702 return ComputeQuantityUsedEx(other_item, use_stack_max);
8703 }
8704
8705 float ComputeQuantityUsedEx(ItemBase other_item, bool use_stack_max = true)
8706 {
8707 float other_item_quantity = other_item.GetQuantity();
8708 float this_free_space;
8709
8710 float stack_max = GetQuantityMax();
8711
8712 this_free_space = stack_max - GetQuantity();
8713
8714 if (other_item_quantity > this_free_space)
8715 {
8716 return this_free_space;
8717 }
8718 else
8719 {
8720 return other_item_quantity;
8721 }
8722 }
8723
8724 override void CombineItemsEx(EntityAI entity2, bool use_stack_max = true)
8725 {
8726 CombineItems(ItemBase.Cast(entity2),use_stack_max);
8727 }
8728
8729 void CombineItems(ItemBase other_item, bool use_stack_max = true)
8730 {
8731 if (!CanBeCombined(other_item, false))
8732 return;
8733
8734 if (!IsMagazine() && other_item)
8735 {
8736 float quantity_used = ComputeQuantityUsedEx(other_item,use_stack_max);
8737 if (quantity_used != 0)
8738 {
8739 float hp1 = GetHealth01("","");
8740 float hp2 = other_item.GetHealth01("","");
8741 float hpResult = ((hp1*GetQuantity()) + (hp2*quantity_used));
8742 hpResult = hpResult / (GetQuantity() + quantity_used);
8743
8744 hpResult *= GetMaxHealth();
8745 Math.Round(hpResult);
8746 SetHealth("", "Health", hpResult);
8747
8748 AddQuantity(quantity_used);
8749 other_item.AddQuantity(-quantity_used);
8750 }
8751 }
8752 OnCombine(other_item);
8753 }
8754
8755 void OnCombine(ItemBase other_item)
8756 {
8757 #ifdef SERVER
8758 if (!GetHierarchyRootPlayer() && GetHierarchyParent())
8759 GetHierarchyParent().IncreaseLifetimeUp();
8760 #endif
8761 };
8762
8763 void GetRecipesActions(Man player, out TSelectableActionInfoArray outputList)
8764 {
8765 PlayerBase p = PlayerBase.Cast(player);
8766
8767 array<int> recipesIds = p.m_Recipes;
8768 PluginRecipesManager moduleRecipesManager = PluginRecipesManager.Cast(GetPlugin(PluginRecipesManager));
8769 if (moduleRecipesManager)
8770 {
8771 EntityAI itemInHands = player.GetHumanInventory().GetEntityInHands();
8772 moduleRecipesManager.GetValidRecipes(ItemBase.Cast(this), ItemBase.Cast(itemInHands), recipesIds, p);
8773 }
8774
8775 for (int i = 0;i < recipesIds.Count(); i++)
8776 {
8777 int key = recipesIds.Get(i);
8778 string recipeName = moduleRecipesManager.GetRecipeName(key);
8779 outputList.Insert(new TSelectableActionInfo(SAT_CRAFTING, key, recipeName));
8780 }
8781 }
8782
8783 // -------------------------------------------------------------------------
8784 override void GetDebugActions(out TSelectableActionInfoArrayEx outputList)
8785 {
8786 super.GetDebugActions(outputList);
8787
8788 //quantity
8789 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.ADD_QUANTITY, "Quantity +20%", FadeColors.LIGHT_GREY));
8790 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.REMOVE_QUANTITY, "Quantity -20%", FadeColors.LIGHT_GREY));
8791 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SET_QUANTITY_0, "Set Quantity 0", FadeColors.LIGHT_GREY));
8792 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SET_MAX_QUANTITY, "Set Quantity Max", FadeColors.LIGHT_GREY));
8793 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SEPARATOR, "___________________________", FadeColors.RED));
8794
8795 //health
8796 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.ADD_HEALTH, "Health +20%", FadeColors.LIGHT_GREY));
8797 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.REMOVE_HEALTH, "Health -20%", FadeColors.LIGHT_GREY));
8798 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.DESTROY_HEALTH, "Health 0", FadeColors.LIGHT_GREY));
8799 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SEPARATOR, "___________________________", FadeColors.RED));
8800 //temperature
8801 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.ADD_TEMPERATURE, "Temperature +20", FadeColors.LIGHT_GREY));
8802 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.REMOVE_TEMPERATURE, "Temperature -20", FadeColors.LIGHT_GREY));
8803 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.FLIP_FROZEN, "Toggle Frozen", FadeColors.LIGHT_GREY));
8804 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SEPARATOR, "___________________________", FadeColors.RED));
8805
8806 //wet
8807 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.ADD_WETNESS, "Wetness +20", FadeColors.LIGHT_GREY));
8808 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.REMOVE_WETNESS, "Wetness -20", FadeColors.LIGHT_GREY));
8809 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SEPARATOR, "___________________________", FadeColors.RED));
8810
8811 //liquidtype
8812 if (IsLiquidContainer())
8813 {
8814 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.LIQUIDTYPE_UP, "LiquidType Next", FadeColors.LIGHT_GREY));
8815 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.LIQUIDTYPE_DOWN, "LiquidType Previous", FadeColors.LIGHT_GREY));
8816 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SEPARATOR, "___________________________", FadeColors.RED));
8817 }
8818
8819 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.MAKE_SPECIAL, "Make Special", FadeColors.LIGHT_GREY));
8820 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SEPARATOR, "___________________________", FadeColors.RED));
8821
8822 // watch
8823 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.WATCH_ITEM, "Watch (CTRL-Z)", FadeColors.LIGHT_GREY));
8824 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.WATCH_PLAYER, "Watch Player", FadeColors.LIGHT_GREY));
8825 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SEPARATOR, "___________________________", FadeColors.RED));
8826
8827 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.DELETE, "Delete", FadeColors.RED));
8828
8829 InventoryLocation loc = new InventoryLocation();
8830 GetInventory().GetCurrentInventoryLocation(loc);
8831 if (!loc || loc.GetType() == InventoryLocationType.GROUND)
8832 {
8833 if (Gizmo_IsSupported())
8834 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.GIZMO_OBJECT, "Gizmo Object", FadeColors.LIGHT_GREY));
8835 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.GIZMO_PHYSICS, "Gizmo Physics (SP Only)", FadeColors.LIGHT_GREY)); // intentionally allowed for testing physics desync
8836 }
8837
8838 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SEPARATOR, "___________________________", FadeColors.RED));
8839 }
8840
8841 // -------------------------------------------------------------------------
8842 // -------------------------------------------------------------------------
8843 // -------------------------------------------------------------------------
8844 override bool OnAction(int action_id, Man player, ParamsReadContext ctx)
8845 {
8846 super.OnAction(action_id, player, ctx);
8847
8848 if (GetGame().IsClient() || !GetGame().IsMultiplayer())
8849 {
8850 switch (action_id)
8851 {
8852 case EActions.GIZMO_OBJECT:
8853 GetGame().GizmoSelectObject(this);
8854 return true;
8855 case EActions.GIZMO_PHYSICS:
8856 GetGame().GizmoSelectPhysics(GetPhysics());
8857 return true;
8858 }
8859 }
8860
8861 if (GetGame().IsServer())
8862 {
8863 switch (action_id)
8864 {
8865 case EActions.DELETE:
8866 Delete();
8867 return true;
8868 }
8869 }
8870
8871 if (action_id >= EActions.RECIPES_RANGE_START && action_id < EActions.RECIPES_RANGE_END)
8872 {
8873 PluginRecipesManager plugin_recipes_manager = PluginRecipesManager.Cast(GetPlugin(PluginRecipesManager));
8874 int idWithoutOffset = action_id - EActions.RECIPES_RANGE_START;
8875 PlayerBase p = PlayerBase.Cast(player);
8876 if (EActions.RECIPES_RANGE_START < 1000)
8877 {
8878 float anim_length = plugin_recipes_manager.GetRecipeLengthInSecs(idWithoutOffset);
8879 float specialty_weight = plugin_recipes_manager.GetRecipeSpecialty(idWithoutOffset);
8880 }
8881 }
8882 #ifndef SERVER
8883 else if (action_id == EActions.WATCH_PLAYER)
8884 {
8885 PluginDeveloper.SetDeveloperItemClientEx(player);
8886 }
8887 #endif
8888 if (GetGame().IsServer())
8889 {
8890 if (action_id >= EActions.DEBUG_ITEM_WATCH_BUTTON_RANGE_START && action_id < EActions.DEBUG_ITEM_WATCH_BUTTON_RANGE_END)
8891 {
8892 int id = action_id - EActions.DEBUG_ITEM_WATCH_BUTTON_RANGE_START;
8893 OnDebugButtonPressServer(id + 1);
8894 }
8895
8896 else if (action_id >= EActions.DEBUG_AGENTS_RANGE_INJECT_START && action_id < EActions.DEBUG_AGENTS_RANGE_INJECT_END)
8897 {
8898 int agent_id = action_id - EActions.DEBUG_AGENTS_RANGE_INJECT_START;
8899 InsertAgent(agent_id,100);
8900 }
8901
8902 else if (action_id >= EActions.DEBUG_AGENTS_RANGE_REMOVE_START && action_id < EActions.DEBUG_AGENTS_RANGE_REMOVE_END)
8903 {
8904 int agent_id2 = action_id - EActions.DEBUG_AGENTS_RANGE_REMOVE_START;
8905 RemoveAgent(agent_id2);
8906 }
8907
8908 else if (action_id == EActions.ADD_QUANTITY)
8909 {
8910 if (IsMagazine())
8911 {
8912 Magazine mag = Magazine.Cast(this);
8913 mag.ServerSetAmmoCount(mag.GetAmmoCount() + mag.GetAmmoMax() * 0.2);
8914 }
8915 else
8916 {
8917 AddQuantity(GetQuantityMax() * 0.2);
8918 }
8919
8920 if (m_EM)
8921 {
8922 m_EM.AddEnergy(m_EM.GetEnergyMax() * 0.2);
8923 }
8924 //PrintVariables();
8925 }
8926
8927 else if (action_id == EActions.REMOVE_QUANTITY) //Quantity -20%
8928 {
8929 if (IsMagazine())
8930 {
8931 Magazine mag2 = Magazine.Cast(this);
8932 mag2.ServerSetAmmoCount(mag2.GetAmmoCount() - mag2.GetAmmoMax() * 0.2);
8933 }
8934 else
8935 {
8936 AddQuantity(- GetQuantityMax() * 0.2);
8937 }
8938 if (m_EM)
8939 {
8940 m_EM.AddEnergy(- m_EM.GetEnergyMax() * 0.2);
8941 }
8942 //PrintVariables();
8943 }
8944
8945 else if (action_id == EActions.SET_QUANTITY_0) //SetMaxQuantity
8946 {
8947 SetQuantity(0);
8948
8949 if (m_EM)
8950 {
8951 m_EM.SetEnergy(0);
8952 }
8953 }
8954
8955 else if (action_id == EActions.SET_MAX_QUANTITY) //SetMaxQuantity
8956 {
8958
8959 if (m_EM)
8960 {
8961 m_EM.SetEnergy(m_EM.GetEnergyMax());
8962 }
8963 }
8964
8965 else if (action_id == EActions.ADD_HEALTH)
8966 {
8967 AddHealth("","",GetMaxHealth("","Health")/5);
8968 }
8969 else if (action_id == EActions.REMOVE_HEALTH)
8970 {
8971 AddHealth("","",-GetMaxHealth("","Health")/5);
8972 }
8973 else if (action_id == EActions.DESTROY_HEALTH)
8974 {
8975 SetHealth01("","",0);
8976 }
8977 else if (action_id == EActions.WATCH_ITEM)
8978 {
8980 mid.RegisterDebugItem(ItemBase.Cast(this), PlayerBase.Cast(player));
8981 #ifdef DEVELOPER
8982 SetDebugDeveloper_item(this);
8983 #endif
8984 }
8985
8986 else if (action_id == EActions.ADD_TEMPERATURE)
8987 {
8988 AddTemperature(20);
8989 //PrintVariables();
8990 }
8991
8992 else if (action_id == EActions.REMOVE_TEMPERATURE)
8993 {
8994 AddTemperature(-20);
8995 //PrintVariables();
8996 }
8997
8998 else if (action_id == EActions.FLIP_FROZEN)
8999 {
9000 SetFrozen(!GetIsFrozen());
9001 //PrintVariables();
9002 }
9003
9004 else if (action_id == EActions.ADD_WETNESS)
9005 {
9006 AddWet(GetWetMax()/5);
9007 //PrintVariables();
9008 }
9009
9010 else if (action_id == EActions.REMOVE_WETNESS)
9011 {
9012 AddWet(-GetWetMax()/5);
9013 //PrintVariables();
9014 }
9015
9016 else if (action_id == EActions.LIQUIDTYPE_UP)
9017 {
9018 int curr_type = GetLiquidType();
9019 SetLiquidType(curr_type * 2);
9020 //AddWet(1);
9021 //PrintVariables();
9022 }
9023
9024 else if (action_id == EActions.LIQUIDTYPE_DOWN)
9025 {
9026 int curr_type2 = GetLiquidType();
9027 SetLiquidType(curr_type2 / 2);
9028 }
9029
9030 else if (action_id == EActions.MAKE_SPECIAL)
9031 {
9032 auto debugParams = DebugSpawnParams.WithPlayer(player);
9033 OnDebugSpawnEx(debugParams);
9034 }
9035
9036 }
9037
9038
9039 return false;
9040 }
9041
9042 // -------------------------------------------------------------------------
9043
9044
9047 void OnActivatedByTripWire();
9048
9050 void OnActivatedByItem(notnull ItemBase item);
9051
9052 //----------------------------------------------------------------
9053 //returns true if item is able to explode when put in fire
9054 bool CanExplodeInFire()
9055 {
9056 return false;
9057 }
9058
9059 //----------------------------------------------------------------
9060 bool CanEat()
9061 {
9062 return true;
9063 }
9064
9065 //----------------------------------------------------------------
9066 override bool IsIgnoredByConstruction()
9067 {
9068 return true;
9069 }
9070
9071 //----------------------------------------------------------------
9072 //has FoodStages in config?
9073 bool HasFoodStage()
9074 {
9075 string config_path = string.Format("CfgVehicles %1 Food FoodStages", GetType());
9076 return GetGame().ConfigIsExisting(config_path);
9077 }
9078
9080 FoodStage GetFoodStage()
9081 {
9082 return null;
9083 }
9084
9085 bool CanBeCooked()
9086 {
9087 return false;
9088 }
9089
9090 bool CanBeCookedOnStick()
9091 {
9092 return false;
9093 }
9094
9096 void RefreshAudioVisualsOnClient( CookingMethodType cooking_method, bool is_done, bool is_empty, bool is_burned );
9098
9099 //----------------------------------------------------------------
9100 bool CanRepair(ItemBase item_repair_kit)
9101 {
9102 PluginRepairing module_repairing = PluginRepairing.Cast(GetPlugin(PluginRepairing));
9103 return module_repairing.CanRepair(this, item_repair_kit);
9104 }
9105
9106 //----------------------------------------------------------------
9107 bool Repair(PlayerBase player, ItemBase item_repair_kit, float specialty_weight)
9108 {
9109 PluginRepairing module_repairing = PluginRepairing.Cast(GetPlugin(PluginRepairing));
9110 return module_repairing.Repair(player, this, item_repair_kit, specialty_weight);
9111 }
9112
9113 //----------------------------------------------------------------
9114 int GetItemSize()
9115 {
9116 /*
9117 vector v_size = this.ConfigGetVector("itemSize");
9118 int v_size_x = v_size[0];
9119 int v_size_y = v_size[1];
9120 int size = v_size_x * v_size_y;
9121 return size;
9122 */
9123
9124 return 1;
9125 }
9126
9127 //----------------------------------------------------------------
9128 //Override for allowing seemingly unallowed moves when two clients send a conflicting message simultaneously
9129 bool CanBeMovedOverride()
9130 {
9131 return m_CanBeMovedOverride;
9132 }
9133
9134 //----------------------------------------------------------------
9135 //Override for allowing seemingly unallowed moves when two clients send a conflicting message simultaneously
9136 void SetCanBeMovedOverride(bool setting)
9137 {
9138 m_CanBeMovedOverride = setting;
9139 }
9140
9141 //----------------------------------------------------------------
9149 void MessageToOwnerStatus(string text)
9150 {
9151 PlayerBase player = PlayerBase.Cast(this.GetHierarchyRootPlayer());
9152
9153 if (player)
9154 {
9155 player.MessageStatus(text);
9156 }
9157 }
9158
9159 //----------------------------------------------------------------
9167 void MessageToOwnerAction(string text)
9168 {
9169 PlayerBase player = PlayerBase.Cast(this.GetHierarchyRootPlayer());
9170
9171 if (player)
9172 {
9173 player.MessageAction(text);
9174 }
9175 }
9176
9177 //----------------------------------------------------------------
9185 void MessageToOwnerFriendly(string text)
9186 {
9187 PlayerBase player = PlayerBase.Cast(this.GetHierarchyRootPlayer());
9188
9189 if (player)
9190 {
9191 player.MessageFriendly(text);
9192 }
9193 }
9194
9195 //----------------------------------------------------------------
9203 void MessageToOwnerImportant(string text)
9204 {
9205 PlayerBase player = PlayerBase.Cast(this.GetHierarchyRootPlayer());
9206
9207 if (player)
9208 {
9209 player.MessageImportant(text);
9210 }
9211 }
9212
9213 override bool IsItemBase()
9214 {
9215 return true;
9216 }
9217
9218 // Checks if item is of questioned kind
9219 override bool KindOf(string tag)
9220 {
9221 bool found = false;
9222 string item_name = this.GetType();
9223 ref TStringArray item_tag_array = new TStringArray;
9224 GetGame().ConfigGetTextArray("cfgVehicles " + item_name + " itemInfo", item_tag_array);
9225
9226 int array_size = item_tag_array.Count();
9227 for (int i = 0; i < array_size; i++)
9228 {
9229 if (item_tag_array.Get(i) == tag)
9230 {
9231 found = true;
9232 break;
9233 }
9234 }
9235 return found;
9236 }
9237
9238
9239 override void OnRPC(PlayerIdentity sender, int rpc_type,ParamsReadContext ctx)
9240 {
9241 //Debug.Log("OnRPC called");
9242 super.OnRPC(sender, rpc_type,ctx);
9243
9244 //Play soundset for attachment locking (ActionLockAttachment.c)
9245 switch (rpc_type)
9246 {
9247 #ifndef SERVER
9248 case ERPCs.RPC_SOUND_LOCK_ATTACH:
9249 Param2<bool, string> p = new Param2<bool, string>(false, "");
9250
9251 if (!ctx.Read(p))
9252 return;
9253
9254 bool play = p.param1;
9255 string soundSet = p.param2;
9256
9257 if (play)
9258 {
9259 if (m_LockingSound)
9260 {
9262 {
9263 m_LockingSound = SEffectManager.PlaySound(soundSet, GetPosition(), 0, 0, true);
9264 }
9265 }
9266 else
9267 {
9268 m_LockingSound = SEffectManager.PlaySound(soundSet, GetPosition(), 0, 0, true);
9269 }
9270 }
9271 else
9272 {
9273 SEffectManager.DestroyEffect(m_LockingSound);
9274 }
9275
9276 break;
9277 #endif
9278
9279 }
9280
9281 if (GetWrittenNoteData())
9282 {
9283 GetWrittenNoteData().OnRPC(sender, rpc_type,ctx);
9284 }
9285 }
9286
9287 //-----------------------------
9288 // VARIABLE MANIPULATION SYSTEM
9289 //-----------------------------
9290 int NameToID(string name)
9291 {
9292 PluginVariables plugin = PluginVariables.Cast(GetPlugin(PluginVariables));
9293 return plugin.GetID(name);
9294 }
9295
9296 string IDToName(int id)
9297 {
9298 PluginVariables plugin = PluginVariables.Cast(GetPlugin(PluginVariables));
9299 return plugin.GetName(id);
9300 }
9301
9303 void OnSyncVariables(ParamsReadContext ctx)//with ID optimization
9304 {
9305 //Debug.Log("OnSyncVariables called for item: "+ ToString(this.GetType()),"varSync");
9306 //read the flags
9307 int varFlags;
9308 if (!ctx.Read(varFlags))
9309 return;
9310
9311 if (varFlags & ItemVariableFlags.FLOAT)
9312 {
9313 ReadVarsFromCTX(ctx);
9314 }
9315 }
9316
9317 override void SerializeNumericalVars(array<float> floats_out)
9318 {
9319 //some variables handled on EntityAI level already!
9320 super.SerializeNumericalVars(floats_out);
9321
9322 // the order of serialization must be the same as the order of de-serialization
9323 //--------------------------------------------
9324 if (IsVariableSet(VARIABLE_QUANTITY))
9325 {
9326 floats_out.Insert(m_VarQuantity);
9327 }
9328 //--------------------------------------------
9329 if (IsVariableSet(VARIABLE_WET))
9330 {
9331 floats_out.Insert(m_VarWet);
9332 }
9333 //--------------------------------------------
9334 if (IsVariableSet(VARIABLE_LIQUIDTYPE))
9335 {
9336 floats_out.Insert(m_VarLiquidType);
9337 }
9338 //--------------------------------------------
9339 if (IsVariableSet(VARIABLE_COLOR))
9340 {
9341 floats_out.Insert(m_ColorComponentR);
9342 floats_out.Insert(m_ColorComponentG);
9343 floats_out.Insert(m_ColorComponentB);
9344 floats_out.Insert(m_ColorComponentA);
9345 }
9346 //--------------------------------------------
9347 if (IsVariableSet(VARIABLE_CLEANNESS))
9348 {
9349 floats_out.Insert(m_Cleanness);
9350 }
9351 }
9352
9353 override void DeSerializeNumericalVars(array<float> floats)
9354 {
9355 //some variables handled on EntityAI level already!
9356 super.DeSerializeNumericalVars(floats);
9357
9358 // the order of serialization must be the same as the order of de-serialization
9359 int index = 0;
9360 int mask = Math.Round(floats.Get(index));
9361
9362 index++;
9363 //--------------------------------------------
9364 if (mask & VARIABLE_QUANTITY)
9365 {
9366 if (m_IsStoreLoad)
9367 {
9368 SetStoreLoadedQuantity(floats.Get(index));
9369 }
9370 else
9371 {
9372 float quantity = floats.Get(index);
9373 SetQuantity(quantity, true, false, false, false);
9374 }
9375 index++;
9376 }
9377 //--------------------------------------------
9378 if (mask & VARIABLE_WET)
9379 {
9380 float wet = floats.Get(index);
9381 SetWet(wet);
9382 index++;
9383 }
9384 //--------------------------------------------
9385 if (mask & VARIABLE_LIQUIDTYPE)
9386 {
9387 int liquidtype = Math.Round(floats.Get(index));
9388 SetLiquidType(liquidtype);
9389 index++;
9390 }
9391 //--------------------------------------------
9392 if (mask & VARIABLE_COLOR)
9393 {
9394 m_ColorComponentR = Math.Round(floats.Get(index));
9395 index++;
9396 m_ColorComponentG = Math.Round(floats.Get(index));
9397 index++;
9398 m_ColorComponentB = Math.Round(floats.Get(index));
9399 index++;
9400 m_ColorComponentA = Math.Round(floats.Get(index));
9401 index++;
9402 }
9403 //--------------------------------------------
9404 if (mask & VARIABLE_CLEANNESS)
9405 {
9406 int cleanness = Math.Round(floats.Get(index));
9407 SetCleanness(cleanness);
9408 index++;
9409 }
9410 }
9411
9412 override void WriteVarsToCTX(ParamsWriteContext ctx)
9413 {
9414 super.WriteVarsToCTX(ctx);
9415
9416 //--------------------------------------------
9417 if (IsVariableSet(VARIABLE_QUANTITY))
9418 {
9419 ctx.Write(GetQuantity());
9420 }
9421 //--------------------------------------------
9422 if (IsVariableSet(VARIABLE_WET))
9423 {
9424 ctx.Write(GetWet());
9425 }
9426 //--------------------------------------------
9427 if (IsVariableSet(VARIABLE_LIQUIDTYPE))
9428 {
9429 ctx.Write(GetLiquidType());
9430 }
9431 //--------------------------------------------
9432 if (IsVariableSet(VARIABLE_COLOR))
9433 {
9434 int r,g,b,a;
9435 GetColor(r,g,b,a);
9436 ctx.Write(r);
9437 ctx.Write(g);
9438 ctx.Write(b);
9439 ctx.Write(a);
9440 }
9441 //--------------------------------------------
9442 if (IsVariableSet(VARIABLE_CLEANNESS))
9443 {
9444 ctx.Write(GetCleanness());
9445 }
9446 }
9447
9448 override bool ReadVarsFromCTX(ParamsReadContext ctx, int version = -1)//with ID optimization
9449 {
9450 if (!super.ReadVarsFromCTX(ctx,version))
9451 return false;
9452
9453 int intValue;
9454 float value;
9455
9456 if (version < 140)
9457 {
9458 if (!ctx.Read(intValue))
9459 return false;
9460
9461 m_VariablesMask = intValue;
9462 }
9463
9464 if (m_VariablesMask & VARIABLE_QUANTITY)
9465 {
9466 if (!ctx.Read(value))
9467 return false;
9468
9469 if (IsStoreLoad())
9470 {
9472 }
9473 else
9474 {
9475 SetQuantity(value, true, false, false, false);
9476 }
9477 }
9478 //--------------------------------------------
9479 if (version < 140)
9480 {
9481 if (m_VariablesMask & VARIABLE_TEMPERATURE)
9482 {
9483 if (!ctx.Read(value))
9484 return false;
9485 SetTemperatureDirect(value);
9486 }
9487 }
9488 //--------------------------------------------
9489 if (m_VariablesMask & VARIABLE_WET)
9490 {
9491 if (!ctx.Read(value))
9492 return false;
9493 SetWet(value);
9494 }
9495 //--------------------------------------------
9496 if (m_VariablesMask & VARIABLE_LIQUIDTYPE)
9497 {
9498 if (!ctx.Read(intValue))
9499 return false;
9500 SetLiquidType(intValue);
9501 }
9502 //--------------------------------------------
9503 if (m_VariablesMask & VARIABLE_COLOR)
9504 {
9505 int r,g,b,a;
9506 if (!ctx.Read(r))
9507 return false;
9508 if (!ctx.Read(g))
9509 return false;
9510 if (!ctx.Read(b))
9511 return false;
9512 if (!ctx.Read(a))
9513 return false;
9514
9515 SetColor(r,g,b,a);
9516 }
9517 //--------------------------------------------
9518 if (m_VariablesMask & VARIABLE_CLEANNESS)
9519 {
9520 if (!ctx.Read(intValue))
9521 return false;
9522 SetCleanness(intValue);
9523 }
9524 //--------------------------------------------
9525 if (version >= 138 && version < 140)
9526 {
9527 if (m_VariablesMask & VARIABLE_TEMPERATURE)
9528 {
9529 if (!ctx.Read(intValue))
9530 return false;
9531 SetFrozen(intValue);
9532 }
9533 }
9534
9535 return true;
9536 }
9537
9538 //----------------------------------------------------------------
9539 override bool OnStoreLoad(ParamsReadContext ctx, int version)
9540 {
9541 m_IsStoreLoad = true;
9543 {
9544 m_FixDamageSystemInit = true;
9545 }
9546
9547 if (!super.OnStoreLoad(ctx, version))
9548 {
9549 m_IsStoreLoad = false;
9550 return false;
9551 }
9552
9553 if (version >= 114)
9554 {
9555 bool hasQuickBarIndexSaved;
9556
9557 if (!ctx.Read(hasQuickBarIndexSaved))
9558 {
9559 m_IsStoreLoad = false;
9560 return false;
9561 }
9562
9563 if (hasQuickBarIndexSaved)
9564 {
9565 int itmQBIndex;
9566
9567 //Load quickbar item bind
9568 if (!ctx.Read(itmQBIndex))
9569 {
9570 m_IsStoreLoad = false;
9571 return false;
9572 }
9573
9574 PlayerBase parentPlayer = PlayerBase.Cast(GetHierarchyRootPlayer());
9575 if (itmQBIndex != -1 && parentPlayer)
9576 parentPlayer.SetLoadedQuickBarItemBind(this, itmQBIndex);
9577 }
9578 }
9579 else
9580 {
9581 // Backup of how it used to be
9582 PlayerBase player;
9583 int itemQBIndex;
9584 if (version == int.MAX)
9585 {
9586 if (!ctx.Read(itemQBIndex))
9587 {
9588 m_IsStoreLoad = false;
9589 return false;
9590 }
9591 }
9592 else if (Class.CastTo(player, GetHierarchyRootPlayer()))
9593 {
9594 //Load quickbar item bind
9595 if (!ctx.Read(itemQBIndex))
9596 {
9597 m_IsStoreLoad = false;
9598 return false;
9599 }
9600 if (itemQBIndex != -1 && player)
9601 player.SetLoadedQuickBarItemBind(this,itemQBIndex);
9602 }
9603 }
9604
9605 if (version < 140)
9606 {
9607 // variable management system
9608 if (!LoadVariables(ctx, version))
9609 {
9610 m_IsStoreLoad = false;
9611 return false;
9612 }
9613 }
9614
9615 //agent trasmission system
9616 if (!LoadAgents(ctx, version))
9617 {
9618 m_IsStoreLoad = false;
9619 return false;
9620 }
9621 if (version >= 132)
9622 {
9623 RemotelyActivatedItemBehaviour raib = GetRemotelyActivatedItemBehaviour();
9624 if (raib)
9625 {
9626 if (!raib.OnStoreLoad(ctx,version))
9627 {
9628 m_IsStoreLoad = false;
9629 return false;
9630 }
9631 }
9632 }
9633
9634 m_IsStoreLoad = false;
9635 return true;
9636 }
9637
9638 //----------------------------------------------------------------
9639
9640 override void OnStoreSave(ParamsWriteContext ctx)
9641 {
9642 super.OnStoreSave(ctx);
9643
9644 PlayerBase player;
9645 if (PlayerBase.CastTo(player,GetHierarchyRootPlayer()))
9646 {
9647 ctx.Write(true); // Keep track of if we should actually read this in or not
9648 //Save quickbar item bind
9649 int itemQBIndex = -1;
9650 itemQBIndex = player.FindQuickBarEntityIndex(this);
9651 ctx.Write(itemQBIndex);
9652 }
9653 else
9654 {
9655 ctx.Write(false); // Keep track of if we should actually read this in or not
9656 }
9657
9658 SaveAgents(ctx);//agent trasmission system
9659
9660 RemotelyActivatedItemBehaviour raib = GetRemotelyActivatedItemBehaviour();
9661 if (raib)
9662 {
9663 raib.OnStoreSave(ctx);
9664 }
9665 }
9666 //----------------------------------------------------------------
9667
9668 override void AfterStoreLoad()
9669 {
9670 super.AfterStoreLoad();
9671
9673 {
9675 }
9676
9677 if (GetStoreLoadedQuantity() != float.LOWEST)
9678 {
9680 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
9681 }
9682 }
9683
9684 override void EEOnAfterLoad()
9685 {
9686 super.EEOnAfterLoad();
9687
9689 {
9690 m_FixDamageSystemInit = false;
9691 }
9692
9695 }
9696
9697 bool CanBeDisinfected()
9698 {
9699 return false;
9700 }
9701
9702
9703 //----------------------------------------------------------------
9704 override void OnVariablesSynchronized()
9705 {
9706 if (m_Initialized)
9707 {
9708 #ifdef PLATFORM_CONSOLE
9709 //bruteforce it is
9710 if (IsSplitable())
9711 {
9712 UIScriptedMenu menu = GetGame().GetUIManager().FindMenu(MENU_INVENTORY);
9713 if (menu)
9714 {
9715 menu.Refresh();
9716 }
9717 }
9718 #endif
9719 }
9720
9722 {
9723 PlayImpactSound(m_ConfigWeight, m_ImpactSpeed, m_ImpactSoundSurfaceHash);
9724 m_WantPlayImpactSound = false;
9725 }
9726
9728 {
9729 SetWeightDirty();
9731 }
9732 if (m_VarWet != m_VarWetPrev)
9733 {
9736 }
9737
9738 if (m_SoundSyncPlay != 0)
9739 {
9740 m_ItemSoundHandler.PlayItemSoundClient(m_SoundSyncPlay);
9741 m_SoundSyncPlay = 0;
9742 }
9743 if (m_SoundSyncStop != 0)
9744 {
9745 m_ItemSoundHandler.StopItemSoundClient(m_SoundSyncStop);
9746 m_SoundSyncStop = 0;
9747 }
9748
9749 super.OnVariablesSynchronized();
9750 }
9751
9752 //------------------------- Quantity
9753 //----------------------------------------------------------------
9755 override bool SetQuantity(float value, bool destroy_config = true, bool destroy_forced = false, bool allow_client = false, bool clamp_to_stack_max = true)
9756 {
9757 if (!IsServerCheck(allow_client))
9758 return false;
9759
9760 if (!HasQuantity())
9761 return false;
9762
9763 float min = GetQuantityMin();
9764 float max = GetQuantityMax();
9765
9766 if (value <= (min + 0.001))
9767 value = min;
9768
9769 if (value == min)
9770 {
9771 if (destroy_config)
9772 {
9773 bool dstr = ConfigGetBool("varQuantityDestroyOnMin");
9774 if (dstr)
9775 {
9776 m_VarQuantity = Math.Clamp(value, min, max);
9777 this.Delete();
9778 return true;
9779 }
9780 }
9781 else if (destroy_forced)
9782 {
9783 m_VarQuantity = Math.Clamp(value, min, max);
9784 this.Delete();
9785 return true;
9786 }
9787 // we get here if destroy_config IS true AND dstr(config destroy param) IS false;
9788 RemoveAllAgents();//we remove all agents when we got to the min value, but the item is not getting deleted
9789 }
9790
9791 float delta = m_VarQuantity;
9792 m_VarQuantity = Math.Clamp(value, min, max);
9793
9794 if (GetStoreLoadedQuantity() == float.LOWEST)//any other value means we are setting quantity from storage
9795 {
9796 delta = m_VarQuantity - delta;
9797
9798 if (delta)
9799 OnQuantityChanged(delta);
9800 }
9801
9802 SetVariableMask(VARIABLE_QUANTITY);
9803
9804 return false;
9805 }
9806
9807 //----------------------------------------------------------------
9809 bool AddQuantity(float value, bool destroy_config = true, bool destroy_forced = false)
9810 {
9811 return SetQuantity(GetQuantity() + value, destroy_config, destroy_forced);
9812 }
9813 //----------------------------------------------------------------
9814 void SetQuantityMax()
9815 {
9816 float max = GetQuantityMax();
9817 SetQuantity(max);
9818 }
9819
9820 override void SetQuantityToMinimum()
9821 {
9822 float min = GetQuantityMin();
9823 SetQuantity(min);
9824 }
9825 //----------------------------------------------------------------
9827 override void SetQuantityNormalized(float value, bool destroy_config = true, bool destroy_forced = false)
9828 {
9829 float value_clamped = Math.Clamp(value, 0, 1);//just to make sure
9830 int result = Math.Round(Math.Lerp(GetQuantityMin(), GetQuantityMax(), value_clamped));
9831 SetQuantity(result, destroy_config, destroy_forced);
9832 }
9833
9834 //----------------------------------------------------------------
9836 override float GetQuantityNormalized()
9837 {
9838 return Math.InverseLerp(GetQuantityMin(), GetQuantityMax(),m_VarQuantity);
9839 }
9840
9842 {
9843 return GetQuantityNormalized();
9844 }
9845
9846 /*void SetAmmoNormalized(float value)
9847 {
9848 float value_clamped = Math.Clamp(value, 0, 1);
9849 Magazine this_mag = Magazine.Cast(this);
9850 int max_rounds = this_mag.GetAmmoMax();
9851 int result = value * max_rounds;//can the rounded if higher precision is required
9852 this_mag.SetAmmoCount(result);
9853 }*/
9854 //----------------------------------------------------------------
9855 override int GetQuantityMax()
9856 {
9857 int slot = -1;
9858 if (GetInventory())
9859 {
9860 InventoryLocation il = new InventoryLocation;
9861 GetInventory().GetCurrentInventoryLocation(il);
9862 slot = il.GetSlot();
9863 }
9864
9865 return GetTargetQuantityMax(slot);
9866 }
9867
9868 override int GetTargetQuantityMax(int attSlotID = -1)
9869 {
9870 float quantity_max = 0;
9871
9872 if (IsSplitable()) //only stackable/splitable items can check for stack size
9873 {
9874 if (attSlotID != -1)
9875 quantity_max = InventorySlots.GetStackMaxForSlotId(attSlotID);
9876
9877 if (quantity_max <= 0)
9878 quantity_max = m_VarStackMax;
9879 }
9880
9881 if (quantity_max <= 0)
9882 quantity_max = m_VarQuantityMax;
9883
9884 return quantity_max;
9885 }
9886 //----------------------------------------------------------------
9887 override int GetQuantityMin()
9888 {
9889 return m_VarQuantityMin;
9890 }
9891 //----------------------------------------------------------------
9892 int GetQuantityInit()
9893 {
9894 return m_VarQuantityInit;
9895 }
9896
9897 //----------------------------------------------------------------
9898 override bool HasQuantity()
9899 {
9900 return !(GetQuantityMax() - GetQuantityMin() == 0);
9901 }
9902
9903 override float GetQuantity()
9904 {
9905 return m_VarQuantity;
9906 }
9907
9908 bool IsFullQuantity()
9909 {
9910 return GetQuantity() >= GetQuantityMax();
9911 }
9912
9913 //Calculates weight of single item without attachments and cargo
9914 override float GetSingleInventoryItemWeightEx()
9915 {
9916 //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
9917 float weightEx = GetWeightEx();//overall weight of the item
9918 float special = GetInventoryAndCargoWeight();//cargo and attachment weight
9919 return weightEx - special;
9920 }
9921
9922 // Obsolete, use GetSingleInventoryItemWeightEx() instead
9924 {
9926 }
9927
9928 override protected float GetWeightSpecialized(bool forceRecalc = false)
9929 {
9930 if (IsSplitable()) //quantity determines size of the stack
9931 {
9932 #ifdef DEVELOPER
9933 if (WeightDebug.m_VerbosityFlags & WeightDebugType.RECALC_FORCED)
9934 {
9935 WeightDebugData data1 = WeightDebug.GetWeightDebug(this);
9936 data1.SetCalcDetails("TIB1: " + GetConfigWeightModifiedDebugText() +" * " + GetQuantity()+"(quantity)");
9937 }
9938 #endif
9939
9940 return GetQuantity() * GetConfigWeightModified();
9941 }
9942 else if (HasEnergyManager())// items with energy manager
9943 {
9944 #ifdef DEVELOPER
9945 if (WeightDebug.m_VerbosityFlags & WeightDebugType.RECALC_FORCED)
9946 {
9947 WeightDebugData data2 = WeightDebug.GetWeightDebug(this);
9948 data2.SetCalcDetails("TIB2: "+super.GetWeightSpecialized(forceRecalc)+"(contents weight) + " + GetConfigWeightModifiedDebugText() +" + " + GetCompEM().GetEnergy()+"(energy) * " + ConfigGetFloat("weightPerQuantityUnit") +"(weightPerQuantityUnit)");
9949 }
9950 #endif
9951 return super.GetWeightSpecialized(forceRecalc) + (GetCompEM().GetEnergy() * ConfigGetFloat("weightPerQuantityUnit")) + GetConfigWeightModified();
9952 }
9953 else//everything else
9954 {
9955 #ifdef DEVELOPER
9956 if (WeightDebug.m_VerbosityFlags & WeightDebugType.RECALC_FORCED)
9957 {
9958 WeightDebugData data3 = WeightDebug.GetWeightDebug(this);
9959 data3.SetCalcDetails("TIB3: "+super.GetWeightSpecialized(forceRecalc)+"(contents weight) + " + GetConfigWeightModifiedDebugText() +" + " + GetQuantity()+"(quantity) * " + ConfigGetFloat("weightPerQuantityUnit") +"(weightPerQuantityUnit))");
9960 }
9961 #endif
9962 return super.GetWeightSpecialized(forceRecalc) + (GetQuantity() * ConfigGetFloat("weightPerQuantityUnit")) + GetConfigWeightModified();
9963 }
9964 }
9965
9967 int GetNumberOfItems()
9968 {
9969 int item_count = 0;
9970 ItemBase item;
9971
9972 if (GetInventory().GetCargo() != NULL)
9973 {
9974 item_count = GetInventory().GetCargo().GetItemCount();
9975 }
9976
9977 for (int i = 0; i < GetInventory().AttachmentCount(); i++)
9978 {
9979 Class.CastTo(item,GetInventory().GetAttachmentFromIndex(i));
9980 if (item)
9981 item_count += item.GetNumberOfItems();
9982 }
9983 return item_count;
9984 }
9985
9987 float GetUnitWeight(bool include_wetness = true)
9988 {
9989 float weight = 0;
9990 float wetness = 1;
9991 if (include_wetness)
9992 wetness += GetWet();
9993 if (IsSplitable()) //quantity determines size of the stack
9994 {
9995 weight = wetness * m_ConfigWeight;
9996 }
9997 else if (IsLiquidContainer()) //is a liquid container, default liquid weight is set to 1. May revisit later?
9998 {
9999 weight = 1;
10000 }
10001 return weight;
10002 }
10003
10004 //-----------------------------------------------------------------
10005
10006 override void ClearInventory()
10007 {
10008 if ((GetGame().IsServer() || !GetGame().IsMultiplayer()) && GetInventory())
10009 {
10010 GameInventory inv = GetInventory();
10011 array<EntityAI> items = new array<EntityAI>;
10012 inv.EnumerateInventory(InventoryTraversalType.INORDER, items);
10013 for (int i = 0; i < items.Count(); i++)
10014 {
10015 ItemBase item = ItemBase.Cast(items.Get(i));
10016 if (item)
10017 {
10018 GetGame().ObjectDelete(item);
10019 }
10020 }
10021 }
10022 }
10023
10024 //------------------------- Energy
10025
10026 //----------------------------------------------------------------
10027 float GetEnergy()
10028 {
10029 float energy = 0;
10030 if (HasEnergyManager())
10031 {
10032 energy = GetCompEM().GetEnergy();
10033 }
10034 return energy;
10035 }
10036
10037
10038 override void OnEnergyConsumed()
10039 {
10040 super.OnEnergyConsumed();
10041
10043 }
10044
10045 override void OnEnergyAdded()
10046 {
10047 super.OnEnergyAdded();
10048
10050 }
10051
10052 // Converts energy (from Energy Manager) to quantity, if enabled.
10054 {
10055 if (GetGame().IsServer() && HasEnergyManager() && GetCompEM().HasConversionOfEnergyToQuantity())
10056 {
10057 if (HasQuantity())
10058 {
10059 float energy_0to1 = GetCompEM().GetEnergy0To1();
10060 SetQuantityNormalized(energy_0to1);
10061 }
10062 }
10063 }
10064
10065 //----------------------------------------------------------------
10066 float GetHeatIsolationInit()
10067 {
10068 return ConfigGetFloat("heatIsolation");
10069 }
10070
10071 float GetHeatIsolation()
10072 {
10073 return m_HeatIsolation;
10074 }
10075
10076 float GetDryingIncrement(string pIncrementName)
10077 {
10078 string paramPath = string.Format("CfgVehicles %1 EnvironmentWetnessIncrements Drying %2", GetType(), pIncrementName);
10079 if (GetGame().ConfigIsExisting(paramPath))
10080 return GetGame().ConfigGetFloat(paramPath);
10081
10082 return 0.0;
10083 }
10084
10085 float GetSoakingIncrement(string pIncrementName)
10086 {
10087 string paramPath = string.Format("CfgVehicles %1 EnvironmentWetnessIncrements Soaking %2", GetType(), pIncrementName);
10088 if (GetGame().ConfigIsExisting(paramPath))
10089 return GetGame().ConfigGetFloat(paramPath);
10090
10091 return 0.0;
10092 }
10093 //----------------------------------------------------------------
10094 override void SetWet(float value, bool allow_client = false)
10095 {
10096 if (!IsServerCheck(allow_client))
10097 return;
10098
10099 float min = GetWetMin();
10100 float max = GetWetMax();
10101
10102 float previousValue = m_VarWet;
10103
10104 m_VarWet = Math.Clamp(value, min, max);
10105
10106 if (previousValue != m_VarWet)
10107 {
10108 SetVariableMask(VARIABLE_WET);
10109 OnWetChanged(m_VarWet, previousValue);
10110 }
10111 }
10112 //----------------------------------------------------------------
10113 override void AddWet(float value)
10114 {
10115 SetWet(GetWet() + value);
10116 }
10117 //----------------------------------------------------------------
10118 override void SetWetMax()
10119 {
10121 }
10122 //----------------------------------------------------------------
10123 override float GetWet()
10124 {
10125 return m_VarWet;
10126 }
10127 //----------------------------------------------------------------
10128 override float GetWetMax()
10129 {
10130 return m_VarWetMax;
10131 }
10132 //----------------------------------------------------------------
10133 override float GetWetMin()
10134 {
10135 return m_VarWetMin;
10136 }
10137 //----------------------------------------------------------------
10138 override float GetWetInit()
10139 {
10140 return m_VarWetInit;
10141 }
10142 //----------------------------------------------------------------
10143 override void OnWetChanged(float newVal, float oldVal)
10144 {
10145 EWetnessLevel newLevel = GetWetLevelInternal(newVal);
10146 EWetnessLevel oldLevel = GetWetLevelInternal(oldVal);
10147 if (newLevel != oldLevel)
10148 {
10149 OnWetLevelChanged(newLevel,oldLevel);
10150 }
10151 }
10152
10153 override void OnWetLevelChanged(EWetnessLevel newLevel, EWetnessLevel oldLevel)
10154 {
10155 SetWeightDirty();
10156 }
10157
10158 override EWetnessLevel GetWetLevel()
10159 {
10160 return GetWetLevelInternal(m_VarWet);
10161 }
10162
10163 //----------------------------------------------------------------
10164
10165 override void SetStoreLoad(bool value)
10166 {
10167 m_IsStoreLoad = value;
10168 }
10169
10170 override bool IsStoreLoad()
10171 {
10172 return m_IsStoreLoad;
10173 }
10174
10175 override void SetStoreLoadedQuantity(float value)
10176 {
10177 m_StoreLoadedQuantity = value;
10178 }
10179
10180 override float GetStoreLoadedQuantity()
10181 {
10182 return m_StoreLoadedQuantity;
10183 }
10184
10185 //----------------------------------------------------------------
10186
10187 float GetItemModelLength()
10188 {
10189 if (ConfigIsExisting("itemModelLength"))
10190 {
10191 return ConfigGetFloat("itemModelLength");
10192 }
10193 return 0;
10194 }
10195
10196 float GetItemAttachOffset()
10197 {
10198 if (ConfigIsExisting("itemAttachOffset"))
10199 {
10200 return ConfigGetFloat("itemAttachOffset");
10201 }
10202 return 0;
10203 }
10204
10205 override void SetCleanness(int value, bool allow_client = false)
10206 {
10207 if (!IsServerCheck(allow_client))
10208 return;
10209
10210 int previousValue = m_Cleanness;
10211
10212 m_Cleanness = Math.Clamp(value, m_CleannessMin, m_CleannessMax);
10213
10214 if (previousValue != m_Cleanness)
10215 SetVariableMask(VARIABLE_CLEANNESS);
10216 }
10217
10218 override int GetCleanness()
10219 {
10220 return m_Cleanness;
10221 }
10222
10224 {
10225 return true;
10226 }
10227
10228 //----------------------------------------------------------------
10229 // ATTACHMENT LOCKING
10230 // Getters relevant to generic ActionLockAttachment
10231 int GetLockType()
10232 {
10233 return m_LockType;
10234 }
10235
10236 string GetLockSoundSet()
10237 {
10238 return m_LockSoundSet;
10239 }
10240
10241 //----------------------------------------------------------------
10242 //------------------------- Color
10243 // sets items color variable given color components
10244 override void SetColor(int r, int g, int b, int a)
10245 {
10250 SetVariableMask(VARIABLE_COLOR);
10251 }
10253 override void GetColor(out int r,out int g,out int b,out int a)
10254 {
10259 }
10260
10261 bool IsColorSet()
10262 {
10263 return IsVariableSet(VARIABLE_COLOR);
10264 }
10265
10267 string GetColorString()
10268 {
10269 int r,g,b,a;
10270 GetColor(r,g,b,a);
10271 r = r/255;
10272 g = g/255;
10273 b = b/255;
10274 a = a/255;
10275 return MiscGameplayFunctions.GetColorString(r, g, b, a);
10276 }
10277 //----------------------------------------------------------------
10278 //------------------------- LiquidType
10279
10280 override void SetLiquidType(int value, bool allow_client = false)
10281 {
10282 if (!IsServerCheck(allow_client))
10283 return;
10284
10285 int old = m_VarLiquidType;
10286 m_VarLiquidType = value;
10287 OnLiquidTypeChanged(old,value);
10288 SetVariableMask(VARIABLE_LIQUIDTYPE);
10289 }
10290
10291 int GetLiquidTypeInit()
10292 {
10293 return ConfigGetInt("varLiquidTypeInit");
10294 }
10295
10296 override int GetLiquidType()
10297 {
10298 return m_VarLiquidType;
10299 }
10300
10301 protected void OnLiquidTypeChanged(int oldType, int newType)
10302 {
10303 if (newType == LIQUID_NONE && GetIsFrozen())
10304 SetFrozen(false);
10305 }
10306
10308 void UpdateQuickbarShortcutVisibility(PlayerBase player)
10309 {
10310 player.SetEnableQuickBarEntityShortcut(this,!GetHierarchyParent() || GetHierarchyParent().GetInventory().AreChildrenAccessible());
10311 }
10312
10313 // -------------------------------------------------------------------------
10315 void OnInventoryEnter(Man player)
10316 {
10317 PlayerBase nplayer;
10318 if (PlayerBase.CastTo(nplayer, player))
10319 {
10320 m_CanPlayImpactSound = true;
10321 //nplayer.OnItemInventoryEnter(this);
10322 nplayer.SetEnableQuickBarEntityShortcut(this,!GetHierarchyParent() || GetHierarchyParent().GetInventory().AreChildrenAccessible());
10323 }
10324 }
10325
10326 // -------------------------------------------------------------------------
10328 void OnInventoryExit(Man player)
10329 {
10330 PlayerBase nplayer;
10331 if (PlayerBase.CastTo(nplayer,player))
10332 {
10333 //nplayer.OnItemInventoryExit(this);
10334 nplayer.SetEnableQuickBarEntityShortcut(this,false);
10335
10336 }
10337
10338 //if (!GetGame().IsDedicatedServer())
10339 player.GetHumanInventory().ClearUserReservedLocationForContainer(this);
10340
10341
10342 if (HasEnergyManager())
10343 {
10344 GetCompEM().UpdatePlugState(); // Unplug the el. device if it's necesarry.
10345 }
10346 }
10347
10348 // ADVANCED PLACEMENT EVENTS
10349 override void OnPlacementStarted(Man player)
10350 {
10351 super.OnPlacementStarted(player);
10352
10353 SetTakeable(false);
10354 }
10355
10356 override void OnPlacementComplete(Man player, vector position = "0 0 0", vector orientation = "0 0 0")
10357 {
10358 if (m_AdminLog)
10359 {
10360 m_AdminLog.OnPlacementComplete(player, this);
10361 }
10362
10363 super.OnPlacementComplete(player, position, orientation);
10364 }
10365
10366 //-----------------------------
10367 // AGENT SYSTEM
10368 //-----------------------------
10369 //--------------------------------------------------------------------------
10370 bool ContainsAgent(int agent_id)
10371 {
10372 if (agent_id & m_AttachedAgents)
10373 {
10374 return true;
10375 }
10376 else
10377 {
10378 return false;
10379 }
10380 }
10381
10382 //--------------------------------------------------------------------------
10383 override void RemoveAgent(int agent_id)
10384 {
10385 if (ContainsAgent(agent_id))
10386 {
10387 m_AttachedAgents = ~agent_id & m_AttachedAgents;
10388 }
10389 }
10390
10391 //--------------------------------------------------------------------------
10392 override void RemoveAllAgents()
10393 {
10394 m_AttachedAgents = 0;
10395 }
10396 //--------------------------------------------------------------------------
10397 override void RemoveAllAgentsExcept(int agent_to_keep)
10398 {
10399 m_AttachedAgents = m_AttachedAgents & agent_to_keep;
10400 }
10401 // -------------------------------------------------------------------------
10402 override void InsertAgent(int agent, float count = 1)
10403 {
10404 if (count < 1)
10405 return;
10406 //Debug.Log("Inserting Agent on item: " + agent.ToString() +" count: " + count.ToString());
10408 }
10409
10411 void TransferAgents(int agents)
10412 {
10414 }
10415
10416 // -------------------------------------------------------------------------
10417 override int GetAgents()
10418 {
10419 return m_AttachedAgents;
10420 }
10421 //----------------------------------------------------------------------
10422
10423 /*int GetContaminationType()
10424 {
10425 int contamination_type;
10426
10427 const int CONTAMINATED_MASK = eAgents.CHOLERA | eAgents.INFLUENZA | eAgents.SALMONELLA | eAgents.BRAIN;
10428 const int POISONED_MASK = eAgents.FOOD_POISON | eAgents.CHEMICAL_POISON;
10429 const int NERVE_GAS_MASK = eAgents.CHEMICAL_POISON;
10430 const int DIRTY_MASK = eAgents.WOUND_AGENT;
10431
10432 Edible_Base edible = Edible_Base.Cast(this);
10433 int agents = GetAgents();
10434 if (edible)
10435 {
10436 NutritionalProfile profile = Edible_Base.GetNutritionalProfile(edible);
10437 if (profile)
10438 {
10439 agents = agents | profile.GetAgents();//merge item's agents with nutritional agents
10440 }
10441 }
10442 if (agents & CONTAMINATED_MASK)
10443 {
10444 contamination_type = contamination_type | EContaminationTypes.ITEM_BADGE_CONTAMINATED;
10445 }
10446 if (agents & POISONED_MASK)
10447 {
10448 contamination_type = contamination_type | EContaminationTypes.ITEM_BADGE_POISONED;
10449 }
10450 if (agents & NERVE_GAS_MASK)
10451 {
10452 contamination_type = contamination_type | EContaminationTypes.ITEM_BADGE_NERVE_GAS;
10453 }
10454 if (agents & DIRTY_MASK)
10455 {
10456 contamination_type = contamination_type | EContaminationTypes.ITEM_BADGE_DIRTY;
10457 }
10458
10459 return agents;
10460 }*/
10461
10462 // -------------------------------------------------------------------------
10463 bool LoadAgents(ParamsReadContext ctx, int version)
10464 {
10465 if (!ctx.Read(m_AttachedAgents))
10466 return false;
10467 return true;
10468 }
10469 // -------------------------------------------------------------------------
10471 {
10472
10474 }
10475 // -------------------------------------------------------------------------
10476
10478 override void CheckForRoofLimited(float timeTresholdMS = 3000)
10479 {
10480 super.CheckForRoofLimited(timeTresholdMS);
10481
10482 float time = GetGame().GetTime();
10483 if ((time - m_PreviousRoofTestTime) >= timeTresholdMS)
10484 {
10485 m_PreviousRoofTestTime = time;
10486 SetRoofAbove(MiscGameplayFunctions.IsUnderRoof(this));
10487 }
10488 }
10489
10490 // returns item's protection level against enviromental hazard, for masks with filters, returns the filters protection for valid filter, otherwise 0
10491 float GetProtectionLevel(int type, bool consider_filter = false, int system = 0)
10492 {
10493 if (IsDamageDestroyed() || (HasQuantity() && GetQuantity() <= 0))
10494 {
10495 return 0;
10496 }
10497
10498 if (GetInventory().GetAttachmentSlotsCount() != 0)//is it an item with attachable filter ?
10499 {
10500 ItemBase filter = ItemBase.Cast(FindAttachmentBySlotName("GasMaskFilter"));
10501 if (filter)
10502 return filter.GetProtectionLevel(type, false, system);//it's a valid filter, return the protection
10503 else
10504 return 0;//otherwise return 0 when no filter attached
10505 }
10506
10507 string subclassPath, entryName;
10508
10509 switch (type)
10510 {
10511 case DEF_BIOLOGICAL:
10512 entryName = "biological";
10513 break;
10514 case DEF_CHEMICAL:
10515 entryName = "chemical";
10516 break;
10517 default:
10518 entryName = "biological";
10519 break;
10520 }
10521
10522 subclassPath = "CfgVehicles " + this.GetType() + " Protection ";
10523
10524 return GetGame().ConfigGetFloat(subclassPath + entryName);
10525 }
10526
10527
10528
10530 override void EEOnCECreate()
10531 {
10532 if (!IsMagazine())
10534
10536 }
10537
10538
10539 //-------------------------
10540 // OPEN/CLOSE USER ACTIONS
10541 //-------------------------
10543 void Open();
10544 void Close();
10545 bool IsOpen()
10546 {
10547 return true;
10548 }
10549
10550 override bool CanDisplayCargo()
10551 {
10552 return IsOpen();
10553 }
10554
10555
10556 // ------------------------------------------------------------
10557 // CONDITIONS
10558 // ------------------------------------------------------------
10559 override bool CanPutInCargo(EntityAI parent)
10560 {
10561 if (parent)
10562 {
10563 if (parent.IsInherited(DayZInfected))
10564 return true;
10565
10566 if (!parent.IsRuined())
10567 return true;
10568 }
10569
10570 return true;
10571 }
10572
10573 override bool CanPutAsAttachment(EntityAI parent)
10574 {
10575 if (!super.CanPutAsAttachment(parent))
10576 {
10577 return false;
10578 }
10579
10580 if (!IsRuined() && !parent.IsRuined())
10581 {
10582 return true;
10583 }
10584
10585 return false;
10586 }
10587
10588 override bool CanReceiveItemIntoCargo(EntityAI item)
10589 {
10590 //removed 15.06. coz of loading from storage -> after load items in cargo was lost -> waiting for proper solution
10591 //if (GetHealthLevel() == GameConstants.STATE_RUINED)
10592 // return false;
10593
10594 return super.CanReceiveItemIntoCargo(item);
10595 }
10596
10597 override bool CanReceiveAttachment(EntityAI attachment, int slotId)
10598 {
10599 //removed 15.06. coz of loading from storage -> after load items in cargo was lost -> waiting for proper solution
10600 //if (GetHealthLevel() == GameConstants.STATE_RUINED)
10601 // return false;
10602
10603 GameInventory attachmentInv = attachment.GetInventory();
10604 if (attachmentInv && attachmentInv.GetCargo() && attachmentInv.GetCargo().GetItemCount() > 0)
10605 {
10606 if (GetHierarchyParent() && !GetHierarchyParent().IsInherited(PlayerBase))
10607 return false;
10608 }
10609
10610 InventoryLocation loc = new InventoryLocation();
10611 attachment.GetInventory().GetCurrentInventoryLocation(loc);
10612 if (loc && loc.IsValid() && !GetInventory().AreChildrenAccessible())
10613 return false;
10614
10615 return super.CanReceiveAttachment(attachment, slotId);
10616 }
10617
10618 override bool CanReleaseAttachment(EntityAI attachment)
10619 {
10620 if (!super.CanReleaseAttachment(attachment))
10621 return false;
10622
10623 return GetInventory().AreChildrenAccessible();
10624 }
10625
10626 /*override bool CanLoadAttachment(EntityAI attachment)
10627 {
10628 //removed 15.06. coz of loading from storage -> after load items in cargo was lost -> waiting for proper solution
10629 //if (GetHealthLevel() == GameConstants.STATE_RUINED)
10630 // return false;
10631
10632 GameInventory attachmentInv = attachment.GetInventory();
10633 if (attachmentInv && attachmentInv.GetCargo() && attachmentInv.GetCargo().GetItemCount() > 0)
10634 {
10635 bool boo = (GetHierarchyParent() && !GetHierarchyParent().IsInherited(PlayerBase));
10636 ErrorEx("CanLoadAttachment | this: " + this + " | attachment: " + attachment + " | boo: " + boo,ErrorExSeverity.INFO);
10637
10638 if (GetHierarchyParent() && !GetHierarchyParent().IsInherited(PlayerBase))
10639 return false;
10640 }
10641
10642 return super.CanLoadAttachment(attachment);
10643 }*/
10644
10645 // Plays muzzle flash particle effects
10646 static void PlayFireParticles(ItemBase weapon, int muzzle_index, string ammoType, ItemBase muzzle_owner, ItemBase suppressor, string config_to_search)
10647 {
10648 int id = muzzle_owner.GetMuzzleID();
10649 array<ref WeaponParticlesOnFire> WPOF_array = m_OnFireEffect.Get(id);
10650
10651 if (WPOF_array)
10652 {
10653 for (int i = 0; i < WPOF_array.Count(); i++)
10654 {
10655 WeaponParticlesOnFire WPOF = WPOF_array.Get(i);
10656
10657 if (WPOF)
10658 {
10659 WPOF.OnActivate(weapon, muzzle_index, ammoType, muzzle_owner, suppressor, config_to_search);
10660 }
10661 }
10662 }
10663 }
10664
10665 // Plays bullet eject particle effects (usually just smoke, the bullet itself is a 3D model and is not part of this function)
10666 static void PlayBulletCasingEjectParticles(ItemBase weapon, string ammoType, ItemBase muzzle_owner, ItemBase suppressor, string config_to_search)
10667 {
10668 int id = muzzle_owner.GetMuzzleID();
10669 array<ref WeaponParticlesOnBulletCasingEject> WPOBE_array = m_OnBulletCasingEjectEffect.Get(id);
10670
10671 if (WPOBE_array)
10672 {
10673 for (int i = 0; i < WPOBE_array.Count(); i++)
10674 {
10675 WeaponParticlesOnBulletCasingEject WPOBE = WPOBE_array.Get(i);
10676
10677 if (WPOBE)
10678 {
10679 WPOBE.OnActivate(weapon, 0, ammoType, muzzle_owner, suppressor, config_to_search);
10680 }
10681 }
10682 }
10683 }
10684
10685 // Plays all weapon overheating particles
10686 static void PlayOverheatingParticles(ItemBase weapon, string ammoType, ItemBase muzzle_owner, ItemBase suppressor, string config_to_search)
10687 {
10688 int id = muzzle_owner.GetMuzzleID();
10689 array<ref WeaponParticlesOnOverheating> WPOOH_array = weapon.m_OnOverheatingEffect.Get(id);
10690
10691 if (WPOOH_array)
10692 {
10693 for (int i = 0; i < WPOOH_array.Count(); i++)
10694 {
10695 WeaponParticlesOnOverheating WPOOH = WPOOH_array.Get(i);
10696
10697 if (WPOOH)
10698 {
10699 WPOOH.OnActivate(weapon, 0, ammoType, muzzle_owner, suppressor, config_to_search);
10700 }
10701 }
10702 }
10703 }
10704
10705 // Updates all weapon overheating particles
10706 static void UpdateOverheatingParticles(ItemBase weapon, string ammoType, ItemBase muzzle_owner, ItemBase suppressor, string config_to_search)
10707 {
10708 int id = muzzle_owner.GetMuzzleID();
10709 array<ref WeaponParticlesOnOverheating> WPOOH_array = weapon.m_OnOverheatingEffect.Get(id);
10710
10711 if (WPOOH_array)
10712 {
10713 for (int i = 0; i < WPOOH_array.Count(); i++)
10714 {
10715 WeaponParticlesOnOverheating WPOOH = WPOOH_array.Get(i);
10716
10717 if (WPOOH)
10718 {
10719 WPOOH.OnUpdate(weapon, ammoType, muzzle_owner, suppressor, config_to_search);
10720 }
10721 }
10722 }
10723 }
10724
10725 // Stops overheating particles
10726 static void StopOverheatingParticles(ItemBase weapon, string ammoType, ItemBase muzzle_owner, ItemBase suppressor, string config_to_search)
10727 {
10728 int id = muzzle_owner.GetMuzzleID();
10729 array<ref WeaponParticlesOnOverheating> WPOOH_array = weapon.m_OnOverheatingEffect.Get(id);
10730
10731 if (WPOOH_array)
10732 {
10733 for (int i = 0; i < WPOOH_array.Count(); i++)
10734 {
10735 WeaponParticlesOnOverheating WPOOH = WPOOH_array.Get(i);
10736
10737 if (WPOOH)
10738 {
10739 WPOOH.OnDeactivate(weapon, ammoType, muzzle_owner, suppressor, config_to_search);
10740 }
10741 }
10742 }
10743 }
10744
10745 //----------------------------------------------------------------
10746 //Item Behaviour - unified approach
10747 override bool IsHeavyBehaviour()
10748 {
10749 if (m_ItemBehaviour == 0)
10750 {
10751 return true;
10752 }
10753
10754 return false;
10755 }
10756
10757 override bool IsOneHandedBehaviour()
10758 {
10759 if (m_ItemBehaviour == 1)
10760 {
10761 return true;
10762 }
10763
10764 return false;
10765 }
10766
10767 override bool IsTwoHandedBehaviour()
10768 {
10769 if (m_ItemBehaviour == 2)
10770 {
10771 return true;
10772 }
10773
10774 return false;
10775 }
10776
10777 bool IsDeployable()
10778 {
10779 return false;
10780 }
10781
10783 float GetDeployTime()
10784 {
10785 return UATimeSpent.DEFAULT_DEPLOY;
10786 }
10787
10788
10789 //----------------------------------------------------------------
10790 // Item Targeting (User Actions)
10791 override void SetTakeable(bool pState)
10792 {
10793 m_IsTakeable = pState;
10794 SetSynchDirty();
10795 }
10796
10797 override bool IsTakeable()
10798 {
10799 return m_IsTakeable;
10800 }
10801
10802 // For cases where we want to show object widget which cant be taken to hands
10804 {
10805 return false;
10806 }
10807
10809 protected void PreLoadSoundAttachmentType()
10810 {
10811 string att_type = "None";
10812
10813 if (ConfigIsExisting("soundAttType"))
10814 {
10815 att_type = ConfigGetString("soundAttType");
10816 }
10817
10818 m_SoundAttType = att_type;
10819 }
10820
10821 override string GetAttachmentSoundType()
10822 {
10823 return m_SoundAttType;
10824 }
10825
10826 //----------------------------------------------------------------
10827 //SOUNDS - ItemSoundHandler
10828 //----------------------------------------------------------------
10829
10830 string GetPlaceSoundset(); // played when deploy starts
10831 string GetLoopDeploySoundset(); // played when deploy starts and stopped when it finishes
10832 string GetDeploySoundset(); // played when deploy sucessfully finishes
10833 string GetLoopFoldSoundset(); // played when fold starts and stopped when it finishes
10834 string GetFoldSoundset(); // played when fold sucessfully finishes
10835
10837 {
10838 if (!m_ItemSoundHandler)
10840
10841 return m_ItemSoundHandler;
10842 }
10843
10844 // override to initialize sounds
10845 protected void InitItemSounds()
10846 {
10847 if (GetPlaceSoundset() == string.Empty && GetDeploySoundset() == string.Empty && GetLoopDeploySoundset() == string.Empty)
10848 return;
10849
10851
10852 if (GetPlaceSoundset() != string.Empty)
10853 handler.AddSound(SoundConstants.ITEM_PLACE, GetPlaceSoundset());
10854
10855 if (GetDeploySoundset() != string.Empty)
10856 handler.AddSound(SoundConstants.ITEM_DEPLOY, GetDeploySoundset());
10857
10858 SoundParameters params = new SoundParameters();
10859 params.m_Loop = true;
10860 if (GetLoopDeploySoundset() != string.Empty)
10861 handler.AddSound(SoundConstants.ITEM_DEPLOY_LOOP, GetLoopDeploySoundset(), params);
10862 }
10863
10864 // Start sound using ItemSoundHandler
10865 void StartItemSoundServer(int id)
10866 {
10867 if (!GetGame().IsServer())
10868 return;
10869
10870 m_SoundSyncPlay = id;
10871 SetSynchDirty();
10872
10873 GetGame().GetCallQueue(CALL_CATEGORY_SYSTEM).Remove(ClearStartItemSoundServer); // in case one is queued already
10875 }
10876
10877 // Stop sound using ItemSoundHandler
10878 void StopItemSoundServer(int id)
10879 {
10880 if (!GetGame().IsServer())
10881 return;
10882
10883 m_SoundSyncStop = id;
10884 SetSynchDirty();
10885
10886 GetGame().GetCallQueue(CALL_CATEGORY_SYSTEM).Remove(ClearStopItemSoundServer); // in case one is queued already
10888 }
10889
10890 protected void ClearStartItemSoundServer()
10891 {
10892 m_SoundSyncPlay = 0;
10893 }
10894
10895 protected void ClearStopItemSoundServer()
10896 {
10897 m_SoundSyncStop = 0;
10898 }
10899
10901 void PlayAttachSound(string slot_type)
10902 {
10903 if (!GetGame().IsDedicatedServer())
10904 {
10905 if (ConfigIsExisting("attachSoundSet"))
10906 {
10907 string cfg_path = "";
10908 string soundset = "";
10909 string type_name = GetType();
10910
10911 TStringArray cfg_soundset_array = new TStringArray;
10912 TStringArray cfg_slot_array = new TStringArray;
10913 ConfigGetTextArray("attachSoundSet",cfg_soundset_array);
10914 ConfigGetTextArray("attachSoundSlot",cfg_slot_array);
10915
10916 if (cfg_soundset_array.Count() > 0 && cfg_soundset_array.Count() == cfg_slot_array.Count())
10917 {
10918 for (int i = 0; i < cfg_soundset_array.Count(); i++)
10919 {
10920 if (cfg_slot_array[i] == slot_type)
10921 {
10922 soundset = cfg_soundset_array[i];
10923 break;
10924 }
10925 }
10926 }
10927
10928 if (soundset != "")
10929 {
10930 EffectSound sound = SEffectManager.PlaySound(soundset, GetPosition());
10931 sound.SetAutodestroy(true);
10932 }
10933 }
10934 }
10935 }
10936
10937 void PlayDetachSound(string slot_type)
10938 {
10939 //TODO - evaluate if needed and devise universal config structure if so
10940 }
10941
10942 void OnApply(PlayerBase player);
10943
10945 {
10946 return 1.0;
10947 };
10948 //returns applicable selection
10949 array<string> GetHeadHidingSelection()
10950 {
10952 }
10953
10955 {
10957 }
10958
10959 WrittenNoteData GetWrittenNoteData() {};
10960
10962 {
10963 SetDynamicPhysicsLifeTime(0.01);
10964 m_ItemBeingDroppedPhys = false;
10965 }
10966
10968 {
10969 array<string> zone_names = new array<string>;
10970 GetDamageZones(zone_names);
10971 for (int i = 0; i < zone_names.Count(); i++)
10972 {
10973 SetHealthMax(zone_names.Get(i),"Health");
10974 }
10975 SetHealthMax("","Health");
10976 }
10977
10979 void SetZoneDamageCEInit()
10980 {
10981 float global_health = GetHealth01("","Health");
10982 array<string> zones = new array<string>;
10983 GetDamageZones(zones);
10984 //set damage of all zones to match global health level
10985 for (int i = 0; i < zones.Count(); i++)
10986 {
10987 SetHealth01(zones.Get(i),"Health",global_health);
10988 }
10989 }
10990
10992 bool IsCoverFaceForShave(string slot_name)
10993 {
10994 return IsExclusionFlagPresent(PlayerBase.GetFaceCoverageShaveValues());
10995 }
10996
10997 void ProcessItemWetness(float delta, bool hasParent, bool hasRootAsPlayer, ItemBase refParentIB)
10998 {
10999 if (!hasRootAsPlayer)
11000 {
11001 if (refParentIB)
11002 {
11003 // parent is wet
11004 if ((refParentIB.GetWet() >= GameConstants.STATE_SOAKING_WET) && (m_VarWet < m_VarWetMax))
11005 AddWet(delta * GameConstants.WETNESS_RATE_WETTING_INSIDE);
11006 // parent has liquid inside
11007 else if ((refParentIB.GetLiquidType() != 0) && (refParentIB.GetQuantity() > 0) && (m_VarWet < m_VarWetMax))
11008 AddWet(delta * GameConstants.WETNESS_RATE_WETTING_LIQUID);
11009 // drying
11010 else if (m_VarWet > m_VarWetMin)
11011 AddWet(-1 * delta * GetDryingIncrement("ground") * 2);
11012 }
11013 else
11014 {
11015 // drying on ground or inside non-itembase (car, ...)
11016 if (m_VarWet > m_VarWetMin)
11017 AddWet(-1 * delta * GetDryingIncrement("ground"));
11018 }
11019 }
11020 }
11021
11022 void ProcessItemTemperature(float delta, bool hasParent, bool hasRootAsPlayer, ItemBase refParentIB)
11023 {
11025 {
11026 float target = g_Game.GetMission().GetWorldData().GetBaseEnvTemperatureAtObject(this);
11027 if (GetTemperature() != target || !IsFreezeThawProgressFinished())
11028 {
11029 float heatPermCoef = 1.0;
11030 EntityAI ent = this;
11031 while (ent)
11032 {
11033 heatPermCoef *= ent.GetHeatPermeabilityCoef();
11034 ent = ent.GetHierarchyParent();
11035 }
11036
11037 SetTemperatureEx(new TemperatureDataInterpolated(target,ETemperatureAccessTypes.ACCESS_WORLD,delta,GameConstants.TEMP_COEF_WORLD,heatPermCoef));
11038 }
11039 }
11040 }
11041
11042 void HierarchyCheck(out bool hasParent, out bool hasRootAsPlayer, out ItemBase refParentIB)
11043 {
11044 // hierarchy check for an item to decide whether it has some parent and it is in some player inventory
11045 EntityAI parent = GetHierarchyParent();
11046 if (!parent)
11047 {
11048 hasParent = false;
11049 hasRootAsPlayer = false;
11050 }
11051 else
11052 {
11053 hasParent = true;
11054 hasRootAsPlayer = (GetHierarchyRootPlayer() != null);
11055 refParentIB = ItemBase.Cast(parent);
11056 }
11057 }
11058
11059 protected void ProcessDecay(float delta, bool hasRootAsPlayer)
11060 {
11061 // this is stub, implemented on Edible_Base
11062 }
11063
11064 bool CanDecay()
11065 {
11066 // return true used on selected food clases so they can decay
11067 return false;
11068 }
11069
11070 protected bool CanProcessDecay()
11071 {
11072 // this is stub, implemented on Edible_Base class
11073 // used to determine whether it is still necessary for the food to decay
11074 return false;
11075 }
11076
11077 protected bool CanHaveWetness()
11078 {
11079 // return true used on selected items that have a wetness effect
11080 return false;
11081 }
11082
11084 bool CanBeConsumed(ConsumeConditionData data = null)
11085 {
11086 return !GetIsFrozen() && IsOpen();
11087 }
11088
11089 override void ProcessVariables()
11090 {
11091 bool hasParent = false, hasRootAsPlayer = false;
11092 ItemBase refParentIB;
11093
11094 bool wwtu = g_Game.IsWorldWetTempUpdateEnabled();
11095 bool foodDecay = g_Game.IsFoodDecayEnabled();
11096
11097 if (wwtu || foodDecay)
11098 {
11099 bool processWetness = wwtu && CanHaveWetness();
11100 bool processTemperature = wwtu && CanHaveTemperature();
11101 bool processDecay = foodDecay && CanDecay() && CanProcessDecay();
11102
11103 if (processWetness || processTemperature || processDecay)
11104 {
11105 HierarchyCheck(hasParent, hasRootAsPlayer, refParentIB);
11106
11107 if (processWetness)
11108 ProcessItemWetness(m_ElapsedSinceLastUpdate, hasParent, hasRootAsPlayer, refParentIB);
11109
11110 if (processTemperature)
11111 ProcessItemTemperature(m_ElapsedSinceLastUpdate, hasParent, hasRootAsPlayer, refParentIB);
11112
11113 if (processDecay)
11114 ProcessDecay(m_ElapsedSinceLastUpdate, hasRootAsPlayer);
11115 }
11116 }
11117 }
11118
11121 {
11122 return m_TemperaturePerQuantityWeight * GameConstants.ITEM_TEMPERATURE_QUANTITY_WEIGHT_MULTIPLIER;
11123 }
11124
11125 override float GetTemperatureFreezeThreshold()
11126 {
11128 return Liquid.GetFreezeThreshold(GetLiquidType());
11129
11130 return super.GetTemperatureFreezeThreshold();
11131 }
11132
11133 override float GetTemperatureThawThreshold()
11134 {
11136 return Liquid.GetThawThreshold(GetLiquidType());
11137
11138 return super.GetTemperatureThawThreshold();
11139 }
11140
11141 override float GetItemOverheatThreshold()
11142 {
11144 return Liquid.GetBoilThreshold(GetLiquidType());
11145
11146 return super.GetItemOverheatThreshold();
11147 }
11148
11149 override float GetTemperatureFreezeTime()
11150 {
11151 if (HasQuantity())
11152 return Math.Lerp(GameConstants.TEMPERATURE_TIME_FREEZE_MIN,Math.Max(GameConstants.TEMPERATURE_TIME_FREEZE_MIN,super.GetTemperatureFreezeTime()),GetQuantityNormalized());
11153
11154 return super.GetTemperatureFreezeTime();
11155 }
11156
11157 override float GetTemperatureThawTime()
11158 {
11159 if (HasQuantity())
11160 return Math.Lerp(GameConstants.TEMPERATURE_TIME_THAW_MIN,Math.Max(GameConstants.TEMPERATURE_TIME_FREEZE_MIN,super.GetTemperatureThawTime()),GetQuantityNormalized());
11161
11162 return super.GetTemperatureThawTime();
11163 }
11164
11166 void AffectLiquidContainerOnFill(int liquid_type, float amount);
11168 void AffectLiquidContainerOnTransfer(int liquidType, float amount, float sourceLiquidTemperature);
11169
11170 bool IsCargoException4x3(EntityAI item)
11171 {
11172 return (item.IsKindOf("Cauldron") || item.IsKindOf("Pot") || item.IsKindOf("FryingPan") || item.IsKindOf("SmallProtectorCase") || (item.IsKindOf("PortableGasStove") && item.FindAttachmentBySlotName("CookingEquipment")));
11173 }
11174
11176 {
11177 MiscGameplayFunctions.TransferItemProperties(oldItem, this);
11178 }
11179
11181 void AddLightSourceItem(ItemBase lightsource)
11182 {
11183 m_LightSourceItem = lightsource;
11184 }
11185
11187 {
11188 m_LightSourceItem = null;
11189 }
11190
11192 {
11193 return m_LightSourceItem;
11194 }
11195
11197 array<int> GetValidFinishers()
11198 {
11199 return null;
11200 }
11201
11203 bool GetActionWidgetOverride(out typename name)
11204 {
11205 return false;
11206 }
11207
11208 bool PairWithDevice(notnull ItemBase otherDevice)
11209 {
11210 if (GetGame().IsServer())
11211 {
11212 ItemBase explosive = otherDevice;
11214 if (!trg)
11215 {
11216 trg = RemoteDetonatorTrigger.Cast(otherDevice);
11217 explosive = this;
11218 }
11219
11220 explosive.PairRemote(trg);
11221 trg.SetControlledDevice(explosive);
11222
11223 int persistentID = RemotelyActivatedItemBehaviour.GeneratePersistentID();
11224 trg.SetPersistentPairID(persistentID);
11225 explosive.SetPersistentPairID(persistentID);
11226
11227 return true;
11228 }
11229 return false;
11230 }
11231
11233 float GetBaitEffectivity()
11234 {
11235 float ret = 1.0;
11236 if (HasQuantity())
11237 ret *= GetQuantityNormalized();
11238 ret *= GetHealth01();
11239
11240 return ret;
11241 }
11242
11243 #ifdef DEVELOPER
11244 override void SetDebugItem()
11245 {
11246 super.SetDebugItem();
11247 _itemBase = this;
11248 }
11249
11250 override string GetDebugText()
11251 {
11252 string text = super.GetDebugText();
11253
11254 text += string.Format("Heat isolation(raw): %1\n", GetHeatIsolation());
11255 text += string.Format("Heat isolation(modified): %1\n", MiscGameplayFunctions.GetCurrentItemHeatIsolation(this));
11256
11257 return text;
11258 }
11259 #endif
11260
11261 bool CanBeUsedForSuicide()
11262 {
11263 return true;
11264 }
11265
11267 //DEPRECATED BELOW
11269 // Backwards compatibility
11270 void ProcessItemWetnessAndTemperature(float delta, bool hasParent, bool hasRootAsPlayer, ItemBase refParentIB)
11271 {
11272 ProcessItemWetness(delta, hasParent, hasRootAsPlayer, refParentIB);
11273 ProcessItemTemperature(delta, hasParent, hasRootAsPlayer, refParentIB);
11274 }
11275
11276 // replaced by ItemSoundHandler
11277 protected EffectSound m_SoundDeployFinish;
11278 protected EffectSound m_SoundPlace;
11279 protected EffectSound m_DeployLoopSoundEx;
11280 protected EffectSound m_SoundDeploy;
11281 bool m_IsPlaceSound;
11282 bool m_IsDeploySound;
11284
11285 string GetDeployFinishSoundset();
11286 void PlayDeploySound();
11287 void PlayDeployFinishSound();
11288 void PlayPlaceSound();
11289 void PlayDeployLoopSoundEx();
11290 void StopDeployLoopSoundEx();
11291 void SoundSynchRemoteReset();
11292 void SoundSynchRemote();
11293 bool UsesGlobalDeploy(){return false;}
11294 bool CanPlayDeployLoopSound(){return false;}
11296 bool IsPlaceSound(){return m_IsPlaceSound;}
11297 bool IsDeploySound(){return m_IsDeploySound;}
11298 void SetIsPlaceSound(bool is_place_sound);
11299 void SetIsDeploySound(bool is_deploy_sound);
11300}
11301
11302EntityAI SpawnItemOnLocation(string object_name, notnull InventoryLocation loc, bool full_quantity)
11303{
11304 EntityAI entity = SpawnEntity(object_name, loc, ECE_IN_INVENTORY, RF_DEFAULT);
11305 if (entity)
11306 {
11307 bool is_item = entity.IsInherited(ItemBase);
11308 if (is_item && full_quantity)
11309 {
11310 ItemBase item = ItemBase.Cast(entity);
11311 item.SetQuantity(item.GetQuantityInit());
11312 }
11313 }
11314 else
11315 {
11316 ErrorEx("Cannot spawn entity: " + object_name,ErrorExSeverity.INFO);
11317 return NULL;
11318 }
11319 return entity;
11320}
11321
11322void SetupSpawnedItem(ItemBase item, float health, float quantity)
11323{
11324 if (item)
11325 {
11326 if (health > 0)
11327 item.SetHealth("", "", health);
11328
11329 if (item.CanHaveTemperature())
11330 {
11331 item.SetTemperatureDirect(GameConstants.ITEM_TEMPERATURE_NEUTRAL_ZONE_MIDDLE);
11332 if (item.CanFreeze())
11333 item.SetFrozen(false);
11334 }
11335
11336 if (item.HasEnergyManager())
11337 {
11338 if (quantity >= 0)
11339 {
11340 item.GetCompEM().SetEnergy0To1(quantity);
11341 }
11342 else
11343 {
11344 item.GetCompEM().SetEnergy(Math.AbsFloat(quantity));
11345 }
11346 }
11347 else if (item.IsMagazine())
11348 {
11349 Magazine mag = Magazine.Cast(item);
11350 if (quantity >= 0)
11351 {
11352 mag.ServerSetAmmoCount(mag.GetAmmoMax() * quantity);
11353 }
11354 else
11355 {
11356 mag.ServerSetAmmoCount(Math.AbsFloat(quantity));
11357 }
11358
11359 }
11360 else
11361 {
11362 if (quantity >= 0)
11363 {
11364 item.SetQuantityNormalized(quantity, false);
11365 }
11366 else
11367 {
11368 item.SetQuantity(Math.AbsFloat(quantity));
11369 }
11370
11371 }
11372 }
11373}
11374
11375#ifdef DEVELOPER
11376ItemBase _itemBase;//watched item goes here(LCTRL+RMB->Watch)
11377#endif
Param4< int, int, string, int > TSelectableActionInfoWithColor
Определения 3_Game/Entities/EntityAI.c:97
Param3 TSelectableActionInfo
EWetnessLevel
Определения 3_Game/Entities/EntityAI.c:2
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:14
void ActionManagerBase(PlayerBase player)
Определения ActionManagerBase.c:63
map< typename, ref array< ActionBase_Basic > > TInputActionMap
Определения ActionManagerClient.c:1
void AddAction(typename actionName)
Определения AdvancedCommunication.c:220
void RemoveAction(typename actionName)
Определения AdvancedCommunication.c:252
TInputActionMap m_InputActionMap
Определения AdvancedCommunication.c:137
bool m_ActionsInitialize
Определения AdvancedCommunication.c:138
override void GetActions(typename action_input_type, out array< ActionBase_Basic > actions)
Определения AdvancedCommunication.c:202
void InitializeActions()
Определения AdvancedCommunication.c:190
int GetLiquidType()
Определения CCTWaterSurface.c:129
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:3868
DayZGame GetDayZGame()
Определения DayZGame.c:3870
EActions
Определения EActions.c:2
ERPCs
Определения ERPCs.c:2
PluginAdminLog m_AdminLog
Определения EmoteManager.c:142
const int MAX
Определения EnConvert.c:27
float GetTemperature()
Определения Environment.c:497
override bool IsExplosive()
Определения ExplosivesBase.c:59
override bool CanHaveTemperature()
Определения FireplaceBase.c:559
class GP5GasMask extends MaskBase ItemBase
Empty
Определения Hand_States.c:14
FindInventoryLocationType
flags for searching locations in inventory
Определения InventoryLocation.c:17
InventoryLocationType
types of Inventory Location
Определения InventoryLocation.c:4
class BoxCollidingParams component
ComponentInfo for BoxCollidingResult.
bool DamageItemInCargo(float damage)
Определения ItemBase.c:6380
static bool HasDebugActionsMask(int mask)
Определения ItemBase.c:5620
bool HidesSelectionBySlot()
Определения ItemBase.c:9347
float m_VarWetMin
Определения ItemBase.c:4881
void SplitItem(PlayerBase player)
Определения ItemBase.c:6831
void CopyScriptPropertiesFrom(EntityAI oldItem)
Определения ItemBase.c:9568
override void InsertAgent(int agent, float count=1)
Определения ItemBase.c:8795
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:8229
static void SetDebugActionsMask(int mask)
Определения ItemBase.c:5625
void SetIsDeploySound(bool is_deploy_sound)
bool IsOpen()
Определения ItemBase.c:8938
void SplitItemToInventoryLocation(notnull InventoryLocation dst)
Определения ItemBase.c:6798
override bool IsHeavyBehaviour()
Определения ItemBase.c:9140
override void SetWetMax()
Определения ItemBase.c:8511
bool IsCoverFaceForShave(string slot_name)
DEPRECATED in use, but returns correct values nontheless. Check performed elsewhere.
Определения ItemBase.c:9385
void ClearStartItemSoundServer()
Определения ItemBase.c:9283
float m_VarWet
Определения ItemBase.c:4878
void ProcessItemTemperature(float delta, bool hasParent, bool hasRootAsPlayer, ItemBase refParentIB)
Определения ItemBase.c:9415
map< typename, ref ActionOverrideData > TActionAnimOverrideMap
Определения ItemBase.c:2
override void RemoveAllAgentsExcept(int agent_to_keep)
Определения ItemBase.c:8790
static ref map< int, ref array< ref WeaponParticlesOnBulletCasingEject > > m_OnBulletCasingEjectEffect
Определения ItemBase.c:4941
bool CanBeMovedOverride()
Определения ItemBase.c:7522
override void SetWet(float value, bool allow_client=false)
Определения ItemBase.c:8487
ref TIntArray m_SingleUseActions
Определения ItemBase.c:4927
override void ProcessVariables()
Определения ItemBase.c:9482
ref TStringArray m_HeadHidingSelections
Определения ItemBase.c:4955
float GetWeightSpecialized(bool forceRecalc=false)
Определения ItemBase.c:8321
bool LoadAgents(ParamsReadContext ctx, int version)
Определения ItemBase.c:8856
void UpdateQuickbarShortcutVisibility(PlayerBase player)
To be called on moving item within character's inventory; 'player' should never be null.
Определения ItemBase.c:8701
void OverrideActionAnimation(typename action, int commandUID, int stanceMask=-1, int commandUIDProne=-1)
Определения ItemBase.c:5211
ref array< ref OverheatingParticle > m_OverheatingParticles
Определения ItemBase.c:4953
override float GetTemperatureFreezeThreshold()
Определения ItemBase.c:9518
bool m_IsSoundSynchRemote
Определения ItemBase.c:9676
float m_OverheatingShots
Определения ItemBase.c:4948
void StopItemSoundServer(int id)
Определения ItemBase.c:9271
static void ToggleDebugActionsMask(int mask)
Определения ItemBase.c:5640
void IncreaseOverheating(ItemBase weapon, string ammoType, ItemBase muzzle_owner, ItemBase suppressor, string config_to_search)
Определения ItemBase.c:5364
override float GetTemperatureFreezeTime()
Определения ItemBase.c:9542
ref array< int > m_CompatibleLocks
Определения ItemBase.c:4965
bool CanBeCooked()
Определения ItemBase.c:7478
override void CombineItemsClient(EntityAI entity2, bool use_stack_max=true)
Определения ItemBase.c:5707
float m_TemperaturePerQuantityWeight
Определения ItemBase.c:4977
bool m_RecipesInitialized
Определения ItemBase.c:4863
void SplitIntoStackMax(EntityAI destination_entity, int slot_id, PlayerBase player)
Определения ItemBase.c:6471
override float GetTemperatureThawThreshold()
Определения ItemBase.c:9526
override void OnEnergyConsumed()
Определения ItemBase.c:8431
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:8360
override EWetnessLevel GetWetLevel()
Определения ItemBase.c:8551
float GetSingleInventoryItemWeight()
Определения ItemBase.c:8316
ref TIntArray m_InteractActions
Определения ItemBase.c:4929
void MessageToOwnerStatus(string text)
Send message to owner player in grey color.
Определения ItemBase.c:7542
float m_VarQuantity
Определения ItemBase.c:4869
bool CanPlayDeployLoopSound()
Определения ItemBase.c:9687
override float GetWetMax()
Определения ItemBase.c:8521
bool CanBeUsedForSuicide()
Определения ItemBase.c:9654
override void CombineItemsEx(EntityAI entity2, bool use_stack_max=true)
Определения ItemBase.c:7117
void OnItemInHandsPlayerSwimStart(PlayerBase player)
void SetIsHologram(bool is_hologram)
Определения ItemBase.c:5845
void OnSyncVariables(ParamsReadContext ctx)
DEPRECATED (most likely)
Определения ItemBase.c:7696
void StartItemSoundServer(int id)
Определения ItemBase.c:9258
void DoAmmoExplosion()
Определения ItemBase.c:6315
static ref map< int, ref array< ref WeaponParticlesOnFire > > m_OnFireEffect
Определения ItemBase.c:4940
void SplitIntoStackMaxCargoClient(EntityAI destination_entity, int idx, int row, int col)
Определения ItemBase.c:6655
int GetItemSize()
Определения ItemBase.c:7507
bool m_CanBeMovedOverride
Определения ItemBase.c:4906
override string ChangeIntoOnAttach(string slot)
Определения ItemBase.c:6239
void UpdateOverheating(ItemBase weapon=null, string ammoType="", ItemBase muzzle_owner=null, ItemBase suppressor=null, string config_to_search="")
Определения ItemBase.c:5432
bool CanDecay()
Определения ItemBase.c:9457
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:8202
void SetQuantityMax()
Определения ItemBase.c:8207
override float GetQuantity()
Определения ItemBase.c:8296
int m_ColorComponentR
Определения ItemBase.c:4918
int m_ShotsToStartOverheating
Определения ItemBase.c:4950
override void OnWetChanged(float newVal, float oldVal)
Определения ItemBase.c:8536
void StopOverheating(ItemBase weapon=null, string ammoType="", ItemBase muzzle_owner=null, ItemBase suppressor=null, string config_to_search="")
Определения ItemBase.c:5439
static void PlayFireParticles(ItemBase weapon, int muzzle_index, string ammoType, ItemBase muzzle_owner, ItemBase suppressor, string config_to_search)
Определения ItemBase.c:9039
void OnOverheatingDecay()
Определения ItemBase.c:5402
float GetDryingIncrement(string pIncrementName)
Определения ItemBase.c:8469
void SoundSynchRemoteReset()
int m_Cleanness
Определения ItemBase.c:4884
bool HasMuzzle()
Returns true if this item has a muzzle (weapons, suppressors)
Определения ItemBase.c:5540
bool UsesGlobalDeploy()
Определения ItemBase.c:9686
int m_ItemBehaviour
Определения ItemBase.c:4899
override bool CanReleaseAttachment(EntityAI attachment)
Определения ItemBase.c:9011
float m_HeatIsolation
Определения ItemBase.c:4894
float m_VarWetInit
Определения ItemBase.c:4880
override void OnMovedInsideCargo(EntityAI container)
Определения ItemBase.c:5885
void SetCEBasedQuantity()
Определения ItemBase.c:5653
bool m_CanPlayImpactSound
Определения ItemBase.c:4890
override string GetAttachmentSoundType()
Определения ItemBase.c:9214
float GetOverheatingCoef()
Определения ItemBase.c:5459
array< string > GetHeadHidingSelection()
Определения ItemBase.c:9342
void PlayAttachSound(string slot_type)
Plays sound on item attach. Be advised, the config structure may slightly change in 1....
Определения ItemBase.c:9294
override bool IsStoreLoad()
Определения ItemBase.c:8563
int ComputeQuantityUsed(ItemBase other_item, bool use_stack_max=true)
Определения ItemBase.c:7093
bool IsLightSource()
Определения ItemBase.c:5781
bool m_HasQuantityBar
Определения ItemBase.c:4912
void SetResultOfSplit(bool value)
Определения ItemBase.c:7088
void SplitIntoStackMaxCargo(EntityAI destination_entity, int idx, int row, int col)
Определения ItemBase.c:6719
void OnAttachmentQuantityChanged(ItemBase item)
Called on server side when some attachment's quantity is changed. Call super.OnAttachmentQuantityChan...
Определения ItemBase.c:6889
void UpdateAllOverheatingParticles()
Определения ItemBase.c:5467
float GetSoakingIncrement(string pIncrementName)
Определения ItemBase.c:8478
static void StopOverheatingParticles(ItemBase weapon, string ammoType, ItemBase muzzle_owner, ItemBase suppressor, string config_to_search)
Определения ItemBase.c:9119
override float GetStoreLoadedQuantity()
Определения ItemBase.c:8573
int m_LockType
Определения ItemBase.c:4966
const int ITEM_SOUNDS_MAX
Определения ItemBase.c:4971
bool m_CanBeDigged
Определения ItemBase.c:4913
float m_ItemAttachOffset
Определения ItemBase.c:4896
float GetItemModelLength()
Определения ItemBase.c:8580
bool m_ThrowItemOnDrop
Определения ItemBase.c:4904
override bool ReadVarsFromCTX(ParamsReadContext ctx, int version=-1)
Определения ItemBase.c:7841
override void CheckForRoofLimited(float timeTresholdMS=3000)
Roof check for entity, limited by time (anti-spam solution)
Определения ItemBase.c:8871
void Close()
float GetHeatIsolation()
Определения ItemBase.c:8464
void CombineItems(ItemBase other_item, bool use_stack_max=true)
Определения ItemBase.c:7122
void TransferModifiers(PlayerBase reciever)
appears to be deprecated, legacy code
float GetTemperaturePerQuantityWeight()
Used in heat comfort calculations only!
Определения ItemBase.c:9513
bool CanHaveWetness()
Определения ItemBase.c:9470
int m_CleannessMin
Определения ItemBase.c:4886
void TransferAgents(int agents)
transfer agents from another item
Определения ItemBase.c:8804
string IDToName(int id)
Определения ItemBase.c:7689
bool CanBeConsumed(ConsumeConditionData data=null)
Items cannot be consumed if frozen by default. Override for exceptions.
Определения ItemBase.c:9477
float GetHeatIsolationInit()
Определения ItemBase.c:8459
void PlayPlaceSound()
void SetCanBeMovedOverride(bool setting)
Определения ItemBase.c:7529
override bool HasQuantity()
Определения ItemBase.c:8291
float m_VarWetPrev
Определения ItemBase.c:4879
int m_SoundSyncStop
Определения ItemBase.c:4973
bool IsCargoException4x3(EntityAI item)
Определения ItemBase.c:9563
ref TIntArray m_ContinuousActions
Определения ItemBase.c:4928
int GetMuzzleID()
Returns global muzzle ID. If not found, then it gets automatically registered.
Определения ItemBase.c:5549
void LoadParticleConfigOnFire(int id)
Определения ItemBase.c:5234
int m_VarLiquidType
Определения ItemBase.c:4898
int m_QuickBarBonus
Определения ItemBase.c:4900
void PreLoadSoundAttachmentType()
Attachment Sound Type getting from config file.
Определения ItemBase.c:9202
override float GetWetInit()
Определения ItemBase.c:8531
int m_ImpactSoundSurfaceHash
Определения ItemBase.c:4892
int m_SoundSyncPlay
Определения ItemBase.c:4972
int m_MaxOverheatingValue
Определения ItemBase.c:4951
void SetupSpawnedItem(ItemBase item, float health, float quantity)
Определения ItemBase.c:4875
bool m_IsTakeable
Определения ItemBase.c:4903
bool ShouldSplitQuantity(float quantity)
Определения ItemBase.c:6428
static ref map< string, int > m_WeaponTypeToID
Определения ItemBase.c:4943
string GetLockSoundSet()
Определения ItemBase.c:8629
string GetColorString()
Returns item's PROCEDURAL color as formated string, i.e. "#(argb,8,8,3)color(0.15,...
Определения ItemBase.c:8660
array< int > GetValidFinishers()
returns an array of possible finishers
Определения ItemBase.c:9590
void OnAttachmentQuantityChangedEx(ItemBase item, float delta)
Called on server side when some attachment's quantity is changed. Call super.OnAttachmentQuantityChan...
Определения ItemBase.c:6895
class ItemBase extends InventoryItem SpawnItemOnLocation(string object_name, notnull InventoryLocation loc, bool full_quantity)
Определения ItemBase.c:4855
ItemSoundHandler GetItemSoundHandler()
Определения ItemBase.c:9229
override int GetQuantityMin()
Определения ItemBase.c:8280
void SplitIntoStackMaxToInventoryLocationClient(notnull InventoryLocation dst)
Определения ItemBase.c:6634
override int GetQuickBarBonus()
Определения ItemBase.c:5119
override void SetTakeable(bool pState)
Определения ItemBase.c:9184
float m_OverheatingDecayInterval
Определения ItemBase.c:4952
void SetIsPlaceSound(bool is_place_sound)
override void SplitIntoStackMaxClient(EntityAI destination_entity, int slot_id)
Определения ItemBase.c:6448
void HierarchyCheck(out bool hasParent, out bool hasRootAsPlayer, out ItemBase refParentIB)
Определения ItemBase.c:9435
bool CanProcessDecay()
Определения ItemBase.c:9463
void RemoveAudioVisualsOnClient()
Определения Bottle_Base.c:151
void SoundSynchRemote()
static void AddDebugActionsMask(int mask)
Определения ItemBase.c:5630
void PlayDeployLoopSoundEx()
void RemoveLightSourceItem()
Определения ItemBase.c:9579
bool CanRepair(ItemBase item_repair_kit)
Определения ItemBase.c:7493
bool can_this_be_combined
Определения ItemBase.c:4908
EffectSound m_SoundDeploy
Определения ItemBase.c:9673
int m_Count
Определения ItemBase.c:4874
float GetBaitEffectivity()
generic effectivity as a bait for animal catching
Определения ItemBase.c:9626
float GetDeployTime()
how long it takes to deploy this item in seconds
Определения ItemBase.c:9176
override bool IsSplitable()
Определения ItemBase.c:6415
bool DamageItemAttachments(float damage)
Определения ItemBase.c:6399
override void WriteVarsToCTX(ParamsWriteContext ctx)
Определения ItemBase.c:7805
void ConvertEnergyToQuantity()
Определения ItemBase.c:8446
override void RemoveAllAgents()
Определения ItemBase.c:8785
override void SetQuantityToMinimum()
Определения ItemBase.c:8213
bool m_WantPlayImpactSound
Определения ItemBase.c:4889
override float GetTemperatureThawTime()
Определения ItemBase.c:9550
ref map< int, ref array< ref WeaponParticlesOnOverheating > > m_OnOverheatingEffect
Определения ItemBase.c:4942
int m_ColorComponentG
Определения ItemBase.c:4919
float m_StoreLoadedQuantity
Определения ItemBase.c:4876
void MessageToOwnerAction(string text)
Send message to owner player in yellow color.
Определения ItemBase.c:7560
int m_ColorComponentA
Определения ItemBase.c:4921
int m_VarQuantityInit
Определения ItemBase.c:4871
float GetFilterDamageRatio()
Определения ItemBase.c:5534
override void SetLiquidType(int value, bool allow_client=false)
Определения ItemBase.c:8673
void OnQuantityChanged(float delta)
Called on server side when this item's quantity is changed. Call super.OnQuantityChanged(); first whe...
Определения ItemBase.c:6865
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:8220
bool m_HideSelectionsBySlot
Определения ItemBase.c:4956
bool IsOverheatingEffectActive()
Определения ItemBase.c:5397
void SetIsBeingPlaced(bool is_being_placed)
Определения ItemBase.c:5814
int GetLiquidContainerMask()
Определения ItemBase.c:5751
void SetInventoryLocationToVicinityOrCurrent(EntityAI root, inout InventoryLocation dst)
Определения ItemBase.c:7002
ref Timer m_CheckOverheating
Определения ItemBase.c:4949
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:5445
float GetEnergy()
Определения ItemBase.c:8420
bool CanBeDigged()
Определения ItemBase.c:5830
bool GetActionWidgetOverride(out typename name)
If we need a different (handheld)item action widget displayed, the logic goes in here.
Определения ItemBase.c:9596
bool IsNVG()
Определения ItemBase.c:5762
float GetUnitWeight(bool include_wetness=true)
Obsolete, use GetWeightEx instead.
Определения ItemBase.c:8380
void SetZoneDamageCEInit()
Sets zone damages to match randomized global health set by CE (CE spawn only)
Определения ItemBase.c:9372
bool m_IsDeploySound
Определения ItemBase.c:9675
bool CanEat()
Определения ItemBase.c:7453
static void PlayOverheatingParticles(ItemBase weapon, string ammoType, ItemBase muzzle_owner, ItemBase suppressor, string config_to_search)
Определения ItemBase.c:9079
override bool IsOneHandedBehaviour()
Определения ItemBase.c:9150
void AddLightSourceItem(ItemBase lightsource)
Adds a light source child.
Определения ItemBase.c:9574
bool IsLiquidContainer()
Определения ItemBase.c:5746
FoodStage GetFoodStage()
overridden on Edible_Base; so we don't have to parse configs all the time
Определения ItemBase.c:7473
override float GetSingleInventoryItemWeightEx()
Определения ItemBase.c:8307
void SaveAgents(ParamsWriteContext ctx)
Определения ItemBase.c:8863
override int GetTargetQuantityMax(int attSlotID=-1)
Определения ItemBase.c:8261
int m_CleannessInit
Определения ItemBase.c:4885
float GetDisinfectQuantity(int system=0, Param param1=null)
Определения ItemBase.c:5529
override int GetAgents()
Определения ItemBase.c:8810
int m_VarQuantityMax
Определения ItemBase.c:4873
override bool IsHologram()
Определения ItemBase.c:5825
float GetItemAttachOffset()
Определения ItemBase.c:8589
bool IsPlaceSound()
Определения ItemBase.c:9689
static int GetDebugActionsMask()
Определения ItemBase.c:5615
void ProcessDecay(float delta, bool hasRootAsPlayer)
Определения ItemBase.c:9452
override bool IsItemBase()
Определения ItemBase.c:7606
void PlayDeploySound()
override bool IsTwoHandedBehaviour()
Определения ItemBase.c:9160
void ExplodeAmmo()
Определения ItemBase.c:6302
bool IsCombineAll(ItemBase other_item, bool use_stack_max=false)
Определения ItemBase.c:7078
float GetProtectionLevel(int type, bool consider_filter=false, int system=0)
Определения ItemBase.c:8884
static void PlayBulletCasingEjectParticles(ItemBase weapon, string ammoType, ItemBase muzzle_owner, ItemBase suppressor, string config_to_search)
Определения ItemBase.c:9059
override void OnEnergyAdded()
Определения ItemBase.c:8438
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:5774
EffectSound m_DeployLoopSoundEx
Определения ItemBase.c:9672
override void DeSerializeNumericalVars(array< float > floats)
Определения ItemBase.c:7746
void StopItemDynamicPhysics()
Определения ItemBase.c:9354
bool HasFoodStage()
Определения ItemBase.c:7466
override void SetStoreLoad(bool value)
Определения ItemBase.c:8558
float GetOverheatingValue()
Определения ItemBase.c:5359
bool ContainsAgent(int agent_id)
Определения ItemBase.c:8763
override void AddWet(float value)
Определения ItemBase.c:8506
bool IsLiquidPresent()
Определения ItemBase.c:5741
bool IsFullQuantity()
Определения ItemBase.c:8301
override void EOnContact(IEntity other, Contact extra)
Определения ItemBase.c:6015
void SplitIntoStackMaxHands(PlayerBase player)
Определения ItemBase.c:6770
void SplitIntoStackMaxHandsClient(PlayerBase player)
Определения ItemBase.c:6746
int m_CleannessMax
Определения ItemBase.c:4887
float m_VarStackMax
Определения ItemBase.c:4875
ref Timer m_PhysDropTimer
Определения ItemBase.c:4962
void MessageToOwnerFriendly(string text)
Send message to owner player in green color.
Определения ItemBase.c:7578
override void SetStoreLoadedQuantity(float value)
Определения ItemBase.c:8568
bool m_IsResultOfSplit string m_SoundAttType
distinguish if item has been created as new or it came from splitting (server only flag)
Определения ItemBase.c:4916
void CheckOverheating(ItemBase weapon=null, string ammoType="", ItemBase muzzle_owner=null, ItemBase suppressor=null, string config_to_search="")
Определения ItemBase.c:5380
void UnlockFromParent()
Unlocks this item from its attachment slot of its parent.
Определения ItemBase.c:5695
bool Repair(PlayerBase player, ItemBase item_repair_kit, float specialty_weight)
Определения ItemBase.c:7500
void OnLiquidTypeChanged(int oldType, int newType)
Определения ItemBase.c:8694
void StartOverheating(ItemBase weapon=null, string ammoType="", ItemBase muzzle_owner=null, ItemBase suppressor=null, string config_to_search="")
Определения ItemBase.c:5426
void PlayDeployFinishSound()
bool AllowFoodConsumption()
Определения ItemBase.c:8616
bool m_IsOverheatingEffectActive
Определения ItemBase.c:4947
int m_LiquidContainerMask
Определения ItemBase.c:4897
void ProcessItemWetness(float delta, bool hasParent, bool hasRootAsPlayer, ItemBase refParentIB)
Определения ItemBase.c:9390
override int GetCleanness()
Определения ItemBase.c:8611
bool PairWithDevice(notnull ItemBase otherDevice)
Определения ItemBase.c:9601
bool IsDeploySound()
Определения ItemBase.c:9690
static void RemoveDebugActionsMask(int mask)
Определения ItemBase.c:5635
static void UpdateOverheatingParticles(ItemBase weapon, string ammoType, ItemBase muzzle_owner, ItemBase suppressor, string config_to_search)
Определения ItemBase.c:9099
int m_VarQuantityMin
Определения ItemBase.c:4872
void PerformDamageSystemReinit()
Определения ItemBase.c:9360
override void ClearInventory()
Определения ItemBase.c:8399
static int m_LastRegisteredWeaponID
Определения ItemBase.c:4944
ItemBase GetLightSourceItem()
Определения ItemBase.c:9584
void MessageToOwnerImportant(string text)
Send message to owner player in red color.
Определения ItemBase.c:7596
override float GetItemOverheatThreshold()
Определения ItemBase.c:9534
void StopDeployLoopSoundEx()
bool m_CanThisBeSplit
Определения ItemBase.c:4909
override void SerializeNumericalVars(array< float > floats_out)
Определения ItemBase.c:7710
ItemBase SplitIntoStackMaxToInventoryLocationEx(notnull InventoryLocation dst)
Определения ItemBase.c:6685
float m_ItemModelLength
Определения ItemBase.c:4895
bool m_IsHologram
Определения ItemBase.c:4902
static int m_DebugActionsMask
Определения ItemBase.c:4862
void KillAllOverheatingParticles()
Определения ItemBase.c:5495
bool CanBeCookedOnStick()
Определения ItemBase.c:7483
override int GetQuantityMax()
Определения ItemBase.c:8248
void GetRecipesActions(Man player, out TSelectableActionInfoArray outputList)
Определения ItemBase.c:7156
void OnActivatedByTripWire()
bool IsColorSet()
Определения ItemBase.c:8654
override void RemoveAgent(int agent_id)
Определения ItemBase.c:8776
bool m_ItemBeingDroppedPhys
Определения ItemBase.c:4905
override bool CanPutAsAttachment(EntityAI parent)
Определения ItemBase.c:8966
void PlayDetachSound(string slot_type)
Определения ItemBase.c:9330
static ref map< typename, ref TInputActionMap > m_ItemTypeActionsMap
Определения ItemBase.c:4856
void ProcessItemWetnessAndTemperature(float delta, bool hasParent, bool hasRootAsPlayer, ItemBase refParentIB)
Определения ItemBase.c:9663
override bool IsBeingPlaced()
Определения ItemBase.c:5809
int GetQuantityInit()
Определения ItemBase.c:8285
float ComputeQuantityUsedEx(ItemBase other_item, bool use_stack_max=true)
Определения ItemBase.c:7098
bool IsResultOfSplit()
Определения ItemBase.c:7083
bool m_FixDamageSystemInit
Определения ItemBase.c:4907
float m_ImpactSpeed
Определения ItemBase.c:4891
bool m_IsStoreLoad
Определения ItemBase.c:4910
int GetLiquidTypeInit()
Определения ItemBase.c:8684
string GetDeployFinishSoundset()
ItemBase m_LightSourceItem
Определения ItemBase.c:4925
void LockToParent()
Locks this item in it's current attachment slot of its parent. This makes the "locked" icon visible i...
Определения ItemBase.c:5682
override void SplitIntoStackMaxEx(EntityAI destination_entity, int slot_id)
Определения ItemBase.c:6557
int m_AttachedAgents
Определения ItemBase.c:4933
string m_LockSoundSet
Определения ItemBase.c:4968
void LoadParticleConfigOnOverheating(int id)
Определения ItemBase.c:5303
float m_VarQuantityPrev
Определения ItemBase.c:4870
bool IsSoundSynchRemote()
Определения ItemBase.c:9688
bool m_CanShowQuantity
Определения ItemBase.c:4911
override void OnRightClick()
Определения ItemBase.c:6938
int m_ColorComponentB
Определения ItemBase.c:4920
static ref map< typename, ref TActionAnimOverrideMap > m_ItemActionOverrides
Определения ItemBase.c:4858
bool IsActionTargetVisible()
Определения ItemBase.c:9196
override void OnItemAttachmentSlotChanged(notnull InventoryLocation oldLoc, notnull InventoryLocation newLoc)
Определения ItemBase.c:6050
override void EEHitBy(TotalDamageResult damageResult, int damageType, EntityAI source, int component, string dmgZone, string ammo, vector modelPos, float speedCoef)
Определения ItemBase.c:6339
bool m_IsBeingPlaced
Определения ItemBase.c:4901
int NameToID(string name)
Определения ItemBase.c:7683
void ~ItemBase()
Определения ItemBase.c:5580
override void OnWetLevelChanged(EWetnessLevel newLevel, EWetnessLevel oldLevel)
Определения ItemBase.c:8546
void ClearStopItemSoundServer()
Определения ItemBase.c:9288
override string ChangeIntoOnDetach()
Определения ItemBase.c:6263
float m_VarWetMax
Определения ItemBase.c:4882
void SplitIntoStackMaxToInventoryLocation(notnull InventoryLocation dst)
Определения ItemBase.c:6680
int GetLockType()
Определения ItemBase.c:8624
EffectSound m_SoundDeployFinish
Определения ItemBase.c:9670
override float GetWet()
Определения ItemBase.c:8516
EffectSound m_SoundPlace
Определения ItemBase.c:9671
float GetQuantityNormalizedScripted()
Определения ItemBase.c:8234
override void SetCleanness(int value, bool allow_client=false)
Определения ItemBase.c:8598
bool m_IsPlaceSound
Определения ItemBase.c:9674
override float GetWetMin()
Определения ItemBase.c:8526
ref ItemSoundHandler m_ItemSoundHandler
Определения ItemBase.c:4974
override bool KindOf(string tag)
Определения ItemBase.c:7612
void ItemSoundHandler(ItemBase parent)
Определения ItemSoundHandler.c:31
string Type
Определения JsonDataContaminatedArea.c:11
EffectSound m_LockingSound
Определения Land_Underground_Entrance.c:321
string GetDebugText()
Определения ModifierBase.c:71
PlayerBase GetPlayer()
Определения ModifierBase.c:51
@ LOWEST
Определения PPEConstants.c:54
void PluginItemDiagnostic()
Определения PluginItemDiagnostic.c:74
PluginBase GetPlugin(typename plugin_type)
Определения PluginManager.c:316
EntityAI GetItem()
Определения RadialQuickbarMenu.c:37
override RemotelyActivatedItemBehaviour GetRemotelyActivatedItemBehaviour()
Определения RemoteDetonator.c:272
void RemoteDetonatorTrigger()
Определения RemoteDetonator.c:233
override void OnActivatedByItem(notnull ItemBase item)
Called when this item is activated by other.
Определения RemoteDetonator.c:305
int particle_id
Определения SmokeSimulation.c:28
ETemperatureAccessTypes
Определения TemperatureAccessConstants.c:2
override void Explode(int damageType, string ammoType="")
Определения Trap_LandMine.c:220
bool m_Initialized
Определения UiHintPanel.c:317
void Debug()
Определения UniversalTemperatureSource.c:349
int GetID()
Определения ActionBase.c:1360
void OnItemLocationChanged(ItemBase item)
Определения ActionBase.c:998
GetInputType()
Определения ActionBase.c:215
int m_StanceMask
Определения ActionBase.c:25
int m_CommandUIDProne
Определения ActionBase.c:24
int m_CommandUID
Определения ActionBase.c:23
void OnItemAttachedAtPlayer(EntityAI item, string slot_name)
Определения AnalyticsManagerClient.c:77
proto native UIManager GetUIManager()
proto bool ConfigGetChildName(string path, int index, out string name)
Get name of subclass in config class on path.
proto native float ConfigGetFloat(string path)
Get float value from config on path.
override ScriptCallQueue GetCallQueue(int call_category)
Определения DayZGame.c:1187
proto native void GizmoSelectObject(Object object)
proto native bool ConfigIsExisting(string path)
proto native void ConfigGetTextArray(string path, out TStringArray values)
Get array of strings from config on path.
proto native DayZPlayer GetPlayer()
proto native void GizmoSelectPhysics(Physics physics)
proto int GetTime()
returns mission time in milliseconds
proto native int ConfigGetType(string path)
Returns type of config value.
AnalyticsManagerClient GetAnalyticsClient()
Определения Global/game.c:1568
proto native int ConfigGetChildrenCount(string path)
Get count of subclasses in config class on path.
proto native SoundOnVehicle CreateSoundOnObject(Object source, string sound_name, float distance, bool looped, bool create_local=false)
proto native void ObjectDelete(Object obj)
proto native int GetItemCount()
proto native EntityAI GetItem(int index)
float GetEnergyAtSpawn()
Определения ComponentEnergyManager.c:1280
void SetEnergy0To1(float energy01)
Energy manager: Sets stored energy for this device between 0 and MAX based on relative input value be...
Определения ComponentEnergyManager.c:541
float GetEnergyMaxPristine()
Energy manager: Returns the maximum amount of energy this device can store. It's damage is NOT taken ...
Определения ComponentEnergyManager.c:1275
override void SetAutodestroy(bool auto_destroy)
Sets whether Effect automatically cleans up when it stops.
Определения EffectSound.c:603
bool IsSoundPlaying()
Get whether EffectSound is currently playing.
Определения EffectSound.c:274
override bool IsMan()
Определения 3_Game/Entities/Man.c:44
proto native bool EnumerateInventory(InventoryTraversalType tt, out array< EntityAI > items)
enumerate inventory using traversal type and filling items array
proto native CargoBase GetCargo()
cargo
Определения ItemBase.c:15
proto native bool IsValid()
verify current set inventory location
proto native EntityAI GetParent()
returns parent of current inventory location
proto native int GetSlot()
returns slot id if current type is Attachment
proto native int GetCol()
returns column of cargo if current type is Cargo / ProxyCargo
proto native int GetRow()
returns row of cargo if current type is Cargo / ProxyCargo
bool WriteToContext(ParamsWriteContext ctx)
Определения InventoryLocation.c:469
proto native int GetType()
returns type of InventoryLocation
proto native int GetIdx()
returns index of cargo if current type is Cargo / ProxyCargo
proto native void SetCargo(notnull EntityAI parent, EntityAI e, int idx, int row, int col, bool flip)
sets current inventory location type to Cargo with coordinates (idx, row, col)
proto native bool GetFlip()
returns flip status of cargo
proto native EntityAI GetItem()
returns item of current inventory location
InventoryLocation.
Определения InventoryLocation.c:29
override bool CanDisplayCargo()
Определения UndergroundStash.c:24
override void OnInventoryEnter(Man player)
Определения BarbedWire.c:203
override string GetFoldSoundset()
Определения BaseBuildingBase.c:108
override bool CanPutAsAttachment(EntityAI parent)
Определения ItemBase.c:6
override bool CanReceiveItemIntoCargo(EntityAI item)
Определения TentBase.c:913
override bool OnStoreLoad(ParamsReadContext ctx, int version)
Определения GardenBase.c: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 void SetActions()
override string GetLoopFoldSoundset()
Определения BaseBuildingBase.c:113
override bool CanMakeGardenplot()
Определения FieldShovel.c:3
override void GetDebugActions(out TSelectableActionInfoArrayEx outputList)
Определения PowerGenerator.c:412
override void EEItemLocationChanged(notnull InventoryLocation oldLoc, notnull InventoryLocation newLoc)
Определения HandcuffsLocked.c:12
override WrittenNoteData GetWrittenNoteData()
Определения Paper.c:30
override int GetDamageSystemVersionChange()
Определения BaseBuildingBase.c: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:424
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 IsClothing()
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
Определения EnMath.c:7
float GetOverheatingLimitMax()
Определения WeaponParticles.c:417
void SetOverheatingLimitMax(float max)
Определения WeaponParticles.c:407
void SetParticleParams(int particle_id, Object parent, vector local_pos, vector local_ori)
Определения WeaponParticles.c:422
float GetOverheatingLimitMin()
Определения WeaponParticles.c:412
Particle GetParticle()
Определения WeaponParticles.c:397
void SetOverheatingLimitMin(float min)
Определения WeaponParticles.c:402
void RegisterParticle(Particle p)
Определения WeaponParticles.c:392
void Stop()
Legacy function for backwards compatibility with 1.14 and below.
Определения Particle.c:266
void SetControlledDevice(EntityAI pDevice)
Определения RemoteDetonator.c:140
bool OnStoreLoad(ParamsReadContext ctx, int version)
void OnStoreSave(ParamsWriteContext ctx)
proto void Remove(func fn)
remove specific call from queue
proto void CallLater(func fn, int delay=0, bool repeat=false, void param1=NULL, void param2=NULL, void param3=NULL, void param4=NULL, void param5=NULL, void param6=NULL, void param7=NULL, void param8=NULL, void param9=NULL)
adds call into the queue with given parameters and arguments (arguments are held in memory until the ...
proto native void Send()
proto bool Write(void value_out)
proto bool Read(void value_in)
bool m_Loop
Определения ItemSoundHandler.c:5
override void Stop()
Определения DayZPlayerImplement.c:64
proto native float GetDamage(string zoneName, string healthType)
UIScriptedMenu FindMenu(int id)
Returns menu with specific ID if it is open (see MenuID)
Определения UIManager.c:160
override void Refresh()
Определения ChatInputMenu.c:70
void SetCalcDetails(string details)
Определения 3_Game/tools/Debug.c:816
void OnRPC(PlayerIdentity sender, int rpc_type, ParamsReadContext ctx)
Определения WrittenNoteData.c:13
const float LOWEST
Определения EnConvert.c:100
Serializer ParamsReadContext
Определения gameplay.c:15
class LOD Object
InventoryTraversalType
tree traversal type, for more see http://en.wikipedia.org/wiki/Tree_traversal
Определения gameplay.c:6
proto native CGame GetGame()
Serializer ParamsWriteContext
Определения gameplay.c:16
const int DEF_BIOLOGICAL
Определения 3_Game/constants.c:512
const int DEF_CHEMICAL
Определения 3_Game/constants.c:513
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:709
array< int > TIntArray
Определения EnScript.c:711
EntityEvent
Entity events for event-mask, or throwing event from code.
Определения EnEntity.c:45
static const float ITEM_TEMPERATURE_NEUTRAL_ZONE_MIDDLE
Определения 3_Game/constants.c:808
const int VARIABLE_LIQUIDTYPE
Определения 3_Game/constants.c:632
const int VARIABLE_CLEANNESS
Определения 3_Game/constants.c:635
const int VARIABLE_COLOR
Определения 3_Game/constants.c:634
const int VARIABLE_TEMPERATURE
Определения 3_Game/constants.c:630
const int VARIABLE_QUANTITY
Определения 3_Game/constants.c:628
const int VARIABLE_WET
Определения 3_Game/constants.c:631
const int LIQUID_NONE
Определения 3_Game/constants.c:529
static proto float AbsFloat(float f)
Returns absolute value.
const int MENU_INVENTORY
Определения 3_Game/constants.c:180
proto native bool dBodyIsDynamic(notnull IEntity ent)
const int SAT_CRAFTING
Определения 3_Game/constants.c:453
const int SAT_DEBUG_ACTION
Определения 3_Game/constants.c:454
class JsonUndergroundAreaTriggerData GetPosition
Определения UndergroundAreaLoader.c:9
static proto string Format(string fmt, void param1=NULL, void param2=NULL, void param3=NULL, void param4=NULL, void param5=NULL, void param6=NULL, void param7=NULL, void param8=NULL, void param9=NULL)
Gets n-th character from string.
const int CALL_CATEGORY_GAMEPLAY
Определения 3_Game/tools/tools.c:10
const int CALL_CATEGORY_SYSTEM
Определения 3_Game/tools/tools.c:8
proto native int GetColor()