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

◆ DamageItemAttachments()

bool SpawnItemOnLocation::DamageItemAttachments ( float damage)
private

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

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