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

◆ DamageItemInCargo()

bool SpawnItemOnLocation::DamageItemInCargo ( float damage)
private

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

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