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

◆ ShouldSplitQuantity()

bool SpawnItemOnLocation::ShouldSplitQuantity ( float quantity)
protected

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

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

Используется в InventoryItem::SplitIntoStackMax(), InventoryItem::SplitIntoStackMaxCargo(), InventoryItem::SplitIntoStackMaxEx(), InventoryItem::SplitIntoStackMaxHands(), InventoryItem::SplitIntoStackMaxToInventoryLocationEx(), InventoryItem::SplitItem() и InventoryItem::SplitItemToInventoryLocation().