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

◆ CanExplodeInFire()

bool SpawnItemOnLocation::CanExplodeInFire ( )
protected

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

7530{
7531 override bool CanPutAsAttachment(EntityAI parent)
7532 {
7533 return true;
7534 }
7535};
7536
7538{
7539
7540};
7541
7542//const bool QUANTITY_DEBUG_REMOVE_ME = false;
7543
7544class ItemBase extends InventoryItem
7545{
7549
7551
7552 static int m_DebugActionsMask;
7554 // ============================================
7555 // Variable Manipulation System
7556 // ============================================
7557 // Quantity
7558
7559 float m_VarQuantity;
7560 float m_VarQuantityPrev;//for client to know quantity changed during synchronization
7562 int m_VarQuantityMin;
7563 int m_VarQuantityMax;
7564 int m_Count;
7565 float m_VarStackMax;
7566 float m_StoreLoadedQuantity = float.LOWEST;
7567 // Wet
7568 float m_VarWet;
7569 float m_VarWetPrev;//for client to know wetness changed during synchronization
7570 float m_VarWetInit;
7571 float m_VarWetMin;
7572 float m_VarWetMax;
7573 // Cleanness
7574 int m_Cleanness;
7575 int m_CleannessInit;
7576 int m_CleannessMin;
7577 int m_CleannessMax;
7578 // impact sounds
7580 bool m_CanPlayImpactSound = true;
7581 float m_ImpactSpeed;
7583 //
7584 float m_HeatIsolation;
7585 float m_ItemModelLength;
7586 float m_ItemAttachOffset; // Offset length for when the item is attached e.g. to weapon
7588 int m_VarLiquidType;
7589 int m_ItemBehaviour; // -1 = not specified; 0 = heavy item; 1= onehanded item; 2 = twohanded item
7590 int m_QuickBarBonus;
7591 bool m_IsBeingPlaced;
7592 bool m_IsHologram;
7593 bool m_IsTakeable;
7594 bool m_ThrowItemOnDrop;
7597 bool m_FixDamageSystemInit = false; //can be changed on storage version check
7598 bool can_this_be_combined; //Check if item can be combined
7599 bool m_CanThisBeSplit; //Check if item can be split
7600 bool m_IsStoreLoad = false;
7601 bool m_CanShowQuantity;
7602 bool m_HasQuantityBar;
7603 protected bool m_CanBeDigged;
7604 protected bool m_IsResultOfSplit
7605
7606 string m_SoundAttType;
7607 // items color variables
7612 //-------------------------------------------------------
7613
7614 // light source managing
7616
7620
7621 //==============================================
7622 // agent system
7623 private int m_AttachedAgents;
7624
7626 void TransferModifiers(PlayerBase reciever);
7627
7628
7629 // Weapons & suppressors particle effects
7633 ref static map<string, int> m_WeaponTypeToID;
7634 static int m_LastRegisteredWeaponID = 0;
7635
7636 // Overheating effects
7638 float m_OverheatingShots;
7639 ref Timer m_CheckOverheating;
7640 int m_ShotsToStartOverheating = 0; // After these many shots, the overheating effect begins
7641 int m_MaxOverheatingValue = 0; // Limits the number of shots that will be tracked
7642 float m_OverheatingDecayInterval = 1; // Timer's interval for decrementing overheat effect's lifespan
7643 ref array <ref OverheatingParticle> m_OverheatingParticles;
7644
7646 protected bool m_HideSelectionsBySlot;
7647
7648 // Admin Log
7649 PluginAdminLog m_AdminLog;
7650
7651 // misc
7652 ref Timer m_PhysDropTimer;
7653
7654 // Attachment Locking variables
7655 ref array<int> m_CompatibleLocks;
7656 protected int m_LockType;
7657 protected ref EffectSound m_LockingSound;
7658 protected string m_LockSoundSet;
7659
7660 // ItemSoundHandler variables
7661 protected const int ITEM_SOUNDS_MAX = 63; // optimize network synch
7662 protected int m_SoundSyncPlay; // id for sound to play
7663 protected int m_SoundSyncStop; // id for sound to stop
7664 protected int m_SoundSyncSlotID = InventorySlots.INVALID; // slot id for attach/detach sound based on slot
7665
7667
7668 //temperature
7669 private float m_TemperaturePerQuantityWeight;
7670
7671 // -------------------------------------------------------------------------
7672 void ItemBase()
7673 {
7674 SetEventMask(EntityEvent.INIT); // Enable EOnInit event
7678
7679 if (!g_Game.IsDedicatedServer())
7680 {
7681 if (HasMuzzle())
7682 {
7684
7686 {
7688 }
7689 }
7690
7692 m_ActionsInitialize = false;
7693 }
7694
7695 m_OldLocation = null;
7696
7697 if (g_Game.IsServer())
7698 {
7699 m_AdminLog = PluginAdminLog.Cast(GetPlugin(PluginAdminLog));
7700 }
7701
7702 if (ConfigIsExisting("headSelectionsToHide"))
7703 {
7705 ConfigGetTextArray("headSelectionsToHide",m_HeadHidingSelections);
7706 }
7707
7708 m_HideSelectionsBySlot = false;
7709 if (ConfigIsExisting("hideSelectionsByinventorySlot"))
7710 {
7711 m_HideSelectionsBySlot = ConfigGetBool("hideSelectionsByinventorySlot");
7712 }
7713
7714 m_QuickBarBonus = Math.Max(0, ConfigGetInt("quickBarBonus"));
7715
7716 m_IsResultOfSplit = false;
7717
7719 }
7720
7721 override void InitItemVariables()
7722 {
7723 super.InitItemVariables();
7724
7725 m_VarQuantityInit = ConfigGetInt("varQuantityInit");
7726 m_VarQuantity = m_VarQuantityInit;//should be by the CE, this is just a precaution
7727 m_VarQuantityMin = ConfigGetInt("varQuantityMin");
7728 m_VarQuantityMax = ConfigGetInt("varQuantityMax");
7729 m_VarStackMax = ConfigGetFloat("varStackMax");
7730 m_Count = ConfigGetInt("count");
7731
7732 m_CanShowQuantity = ConfigGetBool("quantityShow");
7733 m_HasQuantityBar = ConfigGetBool("quantityBar");
7734
7735 m_CleannessInit = ConfigGetInt("varCleannessInit");
7737 m_CleannessMin = ConfigGetInt("varCleannessMin");
7738 m_CleannessMax = ConfigGetInt("varCleannessMax");
7739
7740 m_WantPlayImpactSound = false;
7741 m_ImpactSpeed = 0.0;
7742
7743 m_VarWetInit = ConfigGetFloat("varWetInit");
7745 m_VarWetMin = ConfigGetFloat("varWetMin");
7746 m_VarWetMax = ConfigGetFloat("varWetMax");
7747
7748 m_LiquidContainerMask = ConfigGetInt("liquidContainerType");
7749 if (IsLiquidContainer() && GetQuantity() != 0)
7751 m_IsBeingPlaced = false;
7752 m_IsHologram = false;
7753 m_IsTakeable = true;
7754 m_CanBeMovedOverride = false;
7758 m_CanBeDigged = ConfigGetBool("canBeDigged");
7759
7760 m_CompatibleLocks = new array<int>();
7761 ConfigGetIntArray("compatibleLocks", m_CompatibleLocks);
7762 m_LockType = ConfigGetInt("lockType");
7763
7764 //Define if item can be split and set ability to be combined accordingly
7765 m_CanThisBeSplit = false;
7766 can_this_be_combined = false;
7767 if (ConfigIsExisting("canBeSplit"))
7768 {
7769 can_this_be_combined = ConfigGetBool("canBeSplit");
7771 }
7772
7773 m_ItemBehaviour = -1;
7774 if (ConfigIsExisting("itemBehaviour"))
7775 m_ItemBehaviour = ConfigGetInt("itemBehaviour");
7776
7777 //RegisterNetSyncVariableInt("m_VariablesMask");
7778 if (HasQuantity()) RegisterNetSyncVariableFloat("m_VarQuantity", GetQuantityMin(), m_VarQuantityMax);
7779 RegisterNetSyncVariableFloat("m_VarWet", GetWetMin(), GetWetMax(), 2);
7780 RegisterNetSyncVariableInt("m_VarLiquidType");
7781 RegisterNetSyncVariableInt("m_Cleanness",0,1);
7782
7783 RegisterNetSyncVariableBoolSignal("m_WantPlayImpactSound");
7784 RegisterNetSyncVariableFloat("m_ImpactSpeed");
7785 RegisterNetSyncVariableInt("m_ImpactSoundSurfaceHash");
7786
7787 RegisterNetSyncVariableInt("m_ColorComponentR", 0, 255);
7788 RegisterNetSyncVariableInt("m_ColorComponentG", 0, 255);
7789 RegisterNetSyncVariableInt("m_ColorComponentB", 0, 255);
7790 RegisterNetSyncVariableInt("m_ColorComponentA", 0, 255);
7791
7792 RegisterNetSyncVariableBool("m_IsBeingPlaced");
7793 RegisterNetSyncVariableBool("m_IsTakeable");
7794 RegisterNetSyncVariableBool("m_IsHologram");
7795
7798 {
7799 RegisterNetSyncVariableInt("m_SoundSyncPlay", 0, ITEM_SOUNDS_MAX);
7800 RegisterNetSyncVariableInt("m_SoundSyncStop", 0, ITEM_SOUNDS_MAX);
7801 RegisterNetSyncVariableInt("m_SoundSyncSlotID", int.MIN, int.MAX);
7802 }
7803
7804 m_LockSoundSet = ConfigGetString("lockSoundSet");
7805
7807 if (ConfigIsExisting("temperaturePerQuantityWeight"))
7808 m_TemperaturePerQuantityWeight = ConfigGetFloat("temperaturePerQuantityWeight");
7809
7810 m_SoundSyncSlotID = -1;
7811 }
7812
7813 override int GetQuickBarBonus()
7814 {
7815 return m_QuickBarBonus;
7816 }
7817
7818 void InitializeActions()
7819 {
7821 if (!m_InputActionMap)
7822 {
7824 m_InputActionMap = iam;
7825 SetActions();
7827 }
7828 }
7829
7830 override void GetActions(typename action_input_type, out array<ActionBase_Basic> actions)
7831 {
7833 {
7834 m_ActionsInitialize = true;
7836 }
7837
7838 actions = m_InputActionMap.Get(action_input_type);
7839 }
7840
7841 void SetActions()
7842 {
7843 AddAction(ActionTakeItem);
7844 AddAction(ActionTakeItemToHands);
7845 AddAction(ActionWorldCraft);
7847 AddAction(ActionAttachWithSwitch);
7848 }
7849
7850 void SetActionAnimOverrides(); // Override action animation for specific item
7851
7852 void AddAction(typename actionName)
7853 {
7854 ActionBase action = ActionManagerBase.GetAction(actionName);
7855
7856 if (!action)
7857 {
7858 Debug.LogError("Action " + actionName + " dosn't exist!");
7859 return;
7860 }
7861
7862 typename ai = action.GetInputType();
7863 if (!ai)
7864 {
7865 m_ActionsInitialize = false;
7866 return;
7867 }
7868
7869 array<ActionBase_Basic> action_array = m_InputActionMap.Get(ai);
7870 if (!action_array)
7871 {
7872 action_array = new array<ActionBase_Basic>;
7873 m_InputActionMap.Insert(ai, action_array);
7874 }
7875 if (LogManager.IsActionLogEnable())
7876 {
7877 Debug.ActionLog(action.ToString() + " -> " + ai, this.ToString() , "n/a", "Add action");
7878 }
7879
7880 if (action_array.Find(action) != -1)
7881 {
7882 Debug.Log("Action " + action.Type() + " already added to " + this + ", skipping!");
7883 }
7884 else
7885 {
7886 action_array.Insert(action);
7887 }
7888 }
7889
7890 void RemoveAction(typename actionName)
7891 {
7892 PlayerBase player = PlayerBase.Cast(g_Game.GetPlayer());
7893 ActionBase action = player.GetActionManager().GetAction(actionName);
7894 typename ai = action.GetInputType();
7895 array<ActionBase_Basic> action_array = m_InputActionMap.Get(ai);
7896
7897 if (action_array)
7898 {
7899 action_array.RemoveItem(action);
7900 }
7901 }
7902
7903 // Allows override of default action command per item, defined in the SetActionAnimOverrides() of the item's class
7904 // Set -1 for params which should stay in default state
7905 void OverrideActionAnimation(typename action, int commandUID, int stanceMask = -1, int commandUIDProne = -1)
7906 {
7907 ActionOverrideData overrideData = new ActionOverrideData();
7908 overrideData.m_CommandUID = commandUID;
7909 overrideData.m_CommandUIDProne = commandUIDProne;
7910 overrideData.m_StanceMask = stanceMask;
7911
7912 TActionAnimOverrideMap actionMap = m_ItemActionOverrides.Get(action);
7913 if (!actionMap) // create new map of action > overidables map
7914 {
7915 actionMap = new TActionAnimOverrideMap();
7916 m_ItemActionOverrides.Insert(action, actionMap);
7917 }
7918
7919 actionMap.Insert(this.Type(), overrideData); // insert item -> overrides
7920
7921 }
7922
7923 void OnItemInHandsPlayerSwimStart(PlayerBase player);
7924
7925 ScriptedLightBase GetLight();
7926
7927 // Loads muzzle flash particle configuration from config and saves it to a map for faster access
7928 void LoadParticleConfigOnFire(int id)
7929 {
7930 if (!m_OnFireEffect)
7932
7935
7936 string config_to_search = "CfgVehicles";
7937 string muzzle_owner_config;
7938
7939 if (!m_OnFireEffect.Contains(id))
7940 {
7941 if (IsInherited(Weapon))
7942 config_to_search = "CfgWeapons";
7943
7944 muzzle_owner_config = config_to_search + " " + GetType() + " ";
7945
7946 string config_OnFire_class = muzzle_owner_config + "Particles " + "OnFire ";
7947
7948 int config_OnFire_subclass_count = g_Game.ConfigGetChildrenCount(config_OnFire_class);
7949
7950 if (config_OnFire_subclass_count > 0)
7951 {
7952 array<ref WeaponParticlesOnFire> WPOF_array = new array<ref WeaponParticlesOnFire>;
7953
7954 for (int i = 0; i < config_OnFire_subclass_count; i++)
7955 {
7956 string particle_class = "";
7957 g_Game.ConfigGetChildName(config_OnFire_class, i, particle_class);
7958 string config_OnFire_entry = config_OnFire_class + particle_class;
7959 WeaponParticlesOnFire WPOF = new WeaponParticlesOnFire(this, config_OnFire_entry);
7960 WPOF_array.Insert(WPOF);
7961 }
7962
7963
7964 m_OnFireEffect.Insert(id, WPOF_array);
7965 }
7966 }
7967
7968 if (!m_OnBulletCasingEjectEffect.Contains(id))
7969 {
7970 config_to_search = "CfgWeapons"; // Bullet Eject efect is supported on weapons only.
7971 muzzle_owner_config = config_to_search + " " + GetType() + " ";
7972
7973 string config_OnBulletCasingEject_class = muzzle_owner_config + "Particles " + "OnBulletCasingEject ";
7974
7975 int config_OnBulletCasingEject_count = g_Game.ConfigGetChildrenCount(config_OnBulletCasingEject_class);
7976
7977 if (config_OnBulletCasingEject_count > 0 && IsInherited(Weapon))
7978 {
7979 array<ref WeaponParticlesOnBulletCasingEject> WPOBE_array = new array<ref WeaponParticlesOnBulletCasingEject>;
7980
7981 for (i = 0; i < config_OnBulletCasingEject_count; i++)
7982 {
7983 string particle_class2 = "";
7984 g_Game.ConfigGetChildName(config_OnBulletCasingEject_class, i, particle_class2);
7985 string config_OnBulletCasingEject_entry = config_OnBulletCasingEject_class + particle_class2;
7986 WeaponParticlesOnBulletCasingEject WPOBE = new WeaponParticlesOnBulletCasingEject(this, config_OnBulletCasingEject_entry);
7987 WPOBE_array.Insert(WPOBE);
7988 }
7989
7990
7991 m_OnBulletCasingEjectEffect.Insert(id, WPOBE_array);
7992 }
7993 }
7994 }
7995
7996 // Loads muzzle flash particle configuration from config and saves it to a map for faster access
7998 {
8001
8002 if (!m_OnOverheatingEffect.Contains(id))
8003 {
8004 string config_to_search = "CfgVehicles";
8005
8006 if (IsInherited(Weapon))
8007 config_to_search = "CfgWeapons";
8008
8009 string muzzle_owner_config = config_to_search + " " + GetType() + " ";
8010 string config_OnOverheating_class = muzzle_owner_config + "Particles " + "OnOverheating ";
8011
8012 if (g_Game.ConfigIsExisting(config_OnOverheating_class))
8013 {
8014
8015 m_ShotsToStartOverheating = g_Game.ConfigGetFloat(config_OnOverheating_class + "shotsToStartOverheating");
8016
8018 {
8019 m_ShotsToStartOverheating = -1; // This prevents futher readings from config for future creations of this item
8020 string error = "Error reading config " + GetType() + ">Particles>OnOverheating - Parameter shotsToStartOverheating is configured wrong or is missing! Its value must be 1 or higher!";
8021 Error(error);
8022 return;
8023 }
8024
8025 m_OverheatingDecayInterval = g_Game.ConfigGetFloat(config_OnOverheating_class + "overheatingDecayInterval");
8026 m_MaxOverheatingValue = g_Game.ConfigGetFloat(config_OnOverheating_class + "maxOverheatingValue");
8027
8028
8029
8030 int config_OnOverheating_subclass_count = g_Game.ConfigGetChildrenCount(config_OnOverheating_class);
8031 array<ref WeaponParticlesOnOverheating> WPOOH_array = new array<ref WeaponParticlesOnOverheating>;
8032
8033 for (int i = 0; i < config_OnOverheating_subclass_count; i++)
8034 {
8035 string particle_class = "";
8036 g_Game.ConfigGetChildName(config_OnOverheating_class, i, particle_class);
8037 string config_OnOverheating_entry = config_OnOverheating_class + particle_class;
8038 int entry_type = g_Game.ConfigGetType(config_OnOverheating_entry);
8039
8040 if (entry_type == CT_CLASS)
8041 {
8042 WeaponParticlesOnOverheating WPOF = new WeaponParticlesOnOverheating(this, config_OnOverheating_entry);
8043 WPOOH_array.Insert(WPOF);
8044 }
8045 }
8046
8047
8048 m_OnOverheatingEffect.Insert(id, WPOOH_array);
8049 }
8050 }
8051 }
8052
8053 float GetOverheatingValue()
8054 {
8055 return m_OverheatingShots;
8056 }
8057
8058 void IncreaseOverheating(ItemBase weapon, string ammoType, ItemBase muzzle_owner, ItemBase suppressor, string config_to_search)
8059 {
8060 if (m_MaxOverheatingValue > 0)
8061 {
8063
8064 if (!m_CheckOverheating)
8066
8068 m_CheckOverheating.Run(m_OverheatingDecayInterval, this, "OnOverheatingDecay");
8069
8070 CheckOverheating(weapon, ammoType, muzzle_owner, suppressor, config_to_search);
8071 }
8072 }
8073
8074 void CheckOverheating(ItemBase weapon = null, string ammoType = "", ItemBase muzzle_owner = null, ItemBase suppressor = null, string config_to_search = "")
8075 {
8077 UpdateOverheating(weapon, ammoType, muzzle_owner, suppressor, config_to_search);
8078
8080 StartOverheating(weapon, ammoType, muzzle_owner, suppressor, config_to_search);
8081
8083 StopOverheating(weapon, ammoType, muzzle_owner, suppressor, config_to_search);
8084
8086 {
8088 }
8089 }
8090
8092 {
8094 }
8095
8096 void OnOverheatingDecay()
8097 {
8098 if (m_MaxOverheatingValue > 0)
8099 m_OverheatingShots -= 1 + m_OverheatingShots / m_MaxOverheatingValue; // The hotter a barrel is, the faster it needs to cool down.
8100 else
8102
8103 if (m_OverheatingShots <= 0)
8104 {
8107 }
8108 else
8109 {
8110 if (!m_CheckOverheating)
8112
8114 m_CheckOverheating.Run(m_OverheatingDecayInterval, this, "OnOverheatingDecay");
8115 }
8116
8117 CheckOverheating(this, "", this);
8118 }
8119
8120 void StartOverheating(ItemBase weapon = null, string ammoType = "", ItemBase muzzle_owner = null, ItemBase suppressor = null, string config_to_search = "")
8121 {
8123 ItemBase.PlayOverheatingParticles(this, ammoType, this, suppressor, "CfgWeapons");
8124 }
8125
8126 void UpdateOverheating(ItemBase weapon = null, string ammoType = "", ItemBase muzzle_owner = null, ItemBase suppressor = null, string config_to_search = "")
8127 {
8129 ItemBase.UpdateOverheatingParticles(this, ammoType, this, suppressor, "CfgWeapons");
8131 }
8132
8133 void StopOverheating(ItemBase weapon = null, string ammoType = "", ItemBase muzzle_owner = null, ItemBase suppressor = null, string config_to_search = "")
8134 {
8136 ItemBase.StopOverheatingParticles(weapon, ammoType, muzzle_owner, suppressor, config_to_search);
8137 }
8138
8139 void RegisterOverheatingParticle(Particle p, float min_heat_coef, float max_heat_coef, int particle_id, Object parent, vector local_pos, vector local_ori)
8140 {
8142 m_OverheatingParticles = new array<ref OverheatingParticle>;
8143
8144 OverheatingParticle OP = new OverheatingParticle();
8145 OP.RegisterParticle(p);
8146 OP.SetOverheatingLimitMin(min_heat_coef);
8147 OP.SetOverheatingLimitMax(max_heat_coef);
8148 OP.SetParticleParams(particle_id, parent, local_pos, local_ori);
8149
8150 m_OverheatingParticles.Insert(OP);
8151 }
8152
8153 float GetOverheatingCoef()
8154 {
8155 if (m_MaxOverheatingValue > 0)
8157
8158 return -1;
8159 }
8160
8162 {
8164 {
8165 float overheat_coef = GetOverheatingCoef();
8166 int count = m_OverheatingParticles.Count();
8167
8168 for (int i = count; i > 0; --i)
8169 {
8170 int id = i - 1;
8171 OverheatingParticle OP = m_OverheatingParticles.Get(id);
8172 Particle p = OP.GetParticle();
8173
8174 float overheat_min = OP.GetOverheatingLimitMin();
8175 float overheat_max = OP.GetOverheatingLimitMax();
8176
8177 if (overheat_coef < overheat_min && overheat_coef >= overheat_max)
8178 {
8179 if (p)
8180 {
8181 p.Stop();
8182 OP.RegisterParticle(null);
8183 }
8184 }
8185 }
8186 }
8187 }
8188
8190 {
8192 {
8193 for (int i = m_OverheatingParticles.Count(); i > 0; i--)
8194 {
8195 int id = i - 1;
8196 OverheatingParticle OP = m_OverheatingParticles.Get(id);
8197
8198 if (OP)
8199 {
8200 Particle p = OP.GetParticle();
8201
8202 if (p)
8203 {
8204 p.Stop();
8205 }
8206
8207 delete OP;
8208 }
8209 }
8210
8211 m_OverheatingParticles.Clear();
8213 }
8214 }
8215
8217 float GetInfectionChance(int system = 0, Param param = null)
8218 {
8219 return 0.0;
8220 }
8221
8222
8223 float GetDisinfectQuantity(int system = 0, Param param1 = null)
8224 {
8225 return 250;//default value
8226 }
8227
8228 float GetFilterDamageRatio()
8229 {
8230 return 0;
8231 }
8232
8234 bool HasMuzzle()
8235 {
8236 if (IsInherited(Weapon) || IsInherited(SuppressorBase))
8237 return true;
8238
8239 return false;
8240 }
8241
8243 int GetMuzzleID()
8244 {
8245 if (!m_WeaponTypeToID)
8246 m_WeaponTypeToID = new map<string, int>;
8247
8248 if (m_WeaponTypeToID.Contains(GetType()))
8249 {
8250 return m_WeaponTypeToID.Get(GetType());
8251 }
8252 else
8253 {
8254 // Register new weapon ID
8256 }
8257
8259 }
8260
8267 {
8268 return -1;
8269 }
8270
8271
8272
8273 // -------------------------------------------------------------------------
8274 void ~ItemBase()
8275 {
8276 if (g_Game && g_Game.GetPlayer() && (!g_Game.IsDedicatedServer()))
8277 {
8278 PlayerBase player = PlayerBase.Cast(g_Game.GetPlayer());
8279 int r_index = player.GetHumanInventory().FindUserReservedLocationIndex(this);
8280
8281 if (r_index >= 0)
8282 {
8283 InventoryLocation r_il = new InventoryLocation;
8284 player.GetHumanInventory().GetUserReservedLocation(r_index,r_il);
8285
8286 player.GetHumanInventory().ClearUserReservedLocationAtIndex(r_index);
8287 int r_type = r_il.GetType();
8288 if (r_type == InventoryLocationType.CARGO || r_type == InventoryLocationType.PROXYCARGO)
8289 {
8290 r_il.GetParent().GetOnReleaseLock().Invoke(this);
8291 }
8292 else if (r_type == InventoryLocationType.ATTACHMENT)
8293 {
8294 r_il.GetParent().GetOnAttachmentReleaseLock().Invoke(this, r_il.GetSlot());
8295 }
8296
8297 }
8298
8299 player.GetHumanInventory().ClearUserReservedLocation(this);
8300 }
8301
8302 if (m_LockingSound)
8303 SEffectManager.DestroyEffect(m_LockingSound);
8304 }
8305
8306
8307
8308 // -------------------------------------------------------------------------
8309 static int GetDebugActionsMask()
8310 {
8311 return ItemBase.m_DebugActionsMask;
8312 }
8313
8314 static bool HasDebugActionsMask(int mask)
8315 {
8316 return ItemBase.m_DebugActionsMask & mask;
8317 }
8318
8319 static void SetDebugActionsMask(int mask)
8320 {
8321 ItemBase.m_DebugActionsMask = mask;
8322 }
8323
8324 static void AddDebugActionsMask(int mask)
8325 {
8326 ItemBase.m_DebugActionsMask |= mask;
8327 }
8328
8329 static void RemoveDebugActionsMask(int mask)
8330 {
8331 ItemBase.m_DebugActionsMask &= ~mask;
8332 }
8333
8334 static void ToggleDebugActionsMask(int mask)
8335 {
8336 if (HasDebugActionsMask(mask))
8337 {
8339 }
8340 else
8341 {
8342 AddDebugActionsMask(mask);
8343 }
8344 }
8345
8346 // -------------------------------------------------------------------------
8347 void SetCEBasedQuantity()
8348 {
8349 if (GetEconomyProfile())
8350 {
8351 float q_max = GetEconomyProfile().GetQuantityMax();
8352 if (q_max > 0)
8353 {
8354 float q_min = GetEconomyProfile().GetQuantityMin();
8355 float quantity_randomized = Math.RandomFloatInclusive(q_min, q_max);
8356
8357 if (HasComponent(COMP_TYPE_ENERGY_MANAGER))//more direct access for speed
8358 {
8359 ComponentEnergyManager comp = GetCompEM();
8360 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
8361 {
8362 comp.SetEnergy0To1(quantity_randomized);
8363 }
8364 }
8365 else if (HasQuantity())
8366 {
8367 SetQuantityNormalized(quantity_randomized, false);
8368 //PrintString("<==> Normalized quantity for item: "+ GetType()+", qmin:"+q_min.ToString()+"; qmax:"+q_max.ToString()+";quantity:" +quantity_randomized.ToString());
8369 }
8370
8371 }
8372 }
8373 }
8374
8376 void LockToParent()
8377 {
8378 EntityAI parent = GetHierarchyParent();
8379
8380 if (parent)
8381 {
8382 InventoryLocation inventory_location_to_lock = new InventoryLocation;
8383 GetInventory().GetCurrentInventoryLocation(inventory_location_to_lock);
8384 parent.GetInventory().SetSlotLock(inventory_location_to_lock.GetSlot(), true);
8385 }
8386 }
8387
8389 void UnlockFromParent()
8390 {
8391 EntityAI parent = GetHierarchyParent();
8392
8393 if (parent)
8394 {
8395 InventoryLocation inventory_location_to_unlock = new InventoryLocation;
8396 GetInventory().GetCurrentInventoryLocation(inventory_location_to_unlock);
8397 parent.GetInventory().SetSlotLock(inventory_location_to_unlock.GetSlot(), false);
8398 }
8399 }
8400
8401 override void CombineItemsClient(EntityAI entity2, bool use_stack_max = true)
8402 {
8403 /*
8404 ref Param1<EntityAI> item = new Param1<EntityAI>(entity2);
8405 RPCSingleParam(ERPCs.RPC_ITEM_COMBINE, item, g_Game.GetPlayer());
8406 */
8407 ItemBase item2 = ItemBase.Cast(entity2);
8408
8409 if (g_Game.IsClient())
8410 {
8411 if (ScriptInputUserData.CanStoreInputUserData())
8412 {
8413 ScriptInputUserData ctx = new ScriptInputUserData;
8415 ctx.Write(-1);
8416 ItemBase i1 = this; // @NOTE: workaround for correct serialization
8417 ctx.Write(i1);
8418 ctx.Write(item2);
8419 ctx.Write(use_stack_max);
8420 ctx.Write(-1);
8421 ctx.Send();
8422
8423 if (IsCombineAll(item2, use_stack_max))
8424 {
8425 g_Game.GetPlayer().GetInventory().AddInventoryReservationEx(item2,null,GameInventory.c_InventoryReservationTimeoutShortMS);
8426 }
8427 }
8428 }
8429 else if (!g_Game.IsMultiplayer())
8430 {
8431 CombineItems(item2, use_stack_max);
8432 }
8433 }
8434
8435 bool IsLiquidPresent()
8436 {
8437 return (GetLiquidType() != 0 && HasQuantity());
8438 }
8439
8440 bool IsLiquidContainer()
8441 {
8442 return m_LiquidContainerMask != 0;
8443 }
8444
8446 {
8447 return m_LiquidContainerMask;
8448 }
8449
8450 bool IsBloodContainer()
8451 {
8452 //m_LiquidContainerMask & GROUP_LIQUID_BLOOD ???
8453 return false;
8454 }
8455
8456 bool IsNVG()
8457 {
8458 return false;
8459 }
8460
8463 bool IsExplosive()
8464 {
8465 return false;
8466 }
8467
8469 {
8470 return "";
8471 }
8472
8474
8475 bool IsLightSource()
8476 {
8477 return false;
8478 }
8479
8481 {
8482 return true;
8483 }
8484
8485 //--- ACTION CONDITIONS
8486 //direction
8487 bool IsFacingPlayer(PlayerBase player, string selection)
8488 {
8489 return true;
8490 }
8491
8492 bool IsPlayerInside(PlayerBase player, string selection)
8493 {
8494 return true;
8495 }
8496
8497 override bool CanObstruct()
8498 {
8499 PlayerBase player = PlayerBase.Cast(g_Game.GetPlayer());
8500 return !player || !IsPlayerInside(player, "");
8501 }
8502
8503 override bool IsBeingPlaced()
8504 {
8505 return m_IsBeingPlaced;
8506 }
8507
8508 void SetIsBeingPlaced(bool is_being_placed)
8509 {
8510 m_IsBeingPlaced = is_being_placed;
8511 if (!is_being_placed)
8513 SetSynchDirty();
8514 }
8515
8516 //server-side
8517 void OnEndPlacement() {}
8518
8519 override bool IsHologram()
8520 {
8521 return m_IsHologram;
8522 }
8523
8524 bool CanBeDigged()
8525 {
8526 return m_CanBeDigged;
8527 }
8528
8530 {
8531 return 1;
8532 }
8533
8534 bool CanMakeGardenplot()
8535 {
8536 return false;
8537 }
8538
8539 void SetIsHologram(bool is_hologram)
8540 {
8541 m_IsHologram = is_hologram;
8542 SetSynchDirty();
8543 }
8544 /*
8545 protected float GetNutritionalEnergy()
8546 {
8547 Edible_Base edible = Edible_Base.Cast(this);
8548 return edible.GetFoodEnergy();
8549 }
8550
8551 protected float GetNutritionalWaterContent()
8552 {
8553 Edible_Base edible = Edible_Base.Cast(this);
8554 return edible.GetFoodWater();
8555 }
8556
8557 protected float GetNutritionalIndex()
8558 {
8559 Edible_Base edible = Edible_Base.Cast(this);
8560 return edible.GetFoodNutritionalIndex();
8561 }
8562
8563 protected float GetNutritionalFullnessIndex()
8564 {
8565 Edible_Base edible = Edible_Base.Cast(this);
8566 return edible.GetFoodTotalVolume();
8567 }
8568
8569 protected float GetNutritionalToxicity()
8570 {
8571 Edible_Base edible = Edible_Base.Cast(this);
8572 return edible.GetFoodToxicity();
8573
8574 }
8575 */
8576
8577
8578 // -------------------------------------------------------------------------
8579 override void OnMovedInsideCargo(EntityAI container)
8580 {
8581 super.OnMovedInsideCargo(container);
8582
8583 MiscGameplayFunctions.RemoveAllAttachedChildrenByTypename(this, {Bolt_Base});
8584 }
8585
8586 override void EEItemLocationChanged(notnull InventoryLocation oldLoc, notnull InventoryLocation newLoc)
8587 {
8588 super.EEItemLocationChanged(oldLoc, newLoc);
8589
8590 PlayerBase newPlayer = null;
8591 PlayerBase oldPlayer = null;
8592
8593 if (newLoc.GetParent())
8594 newPlayer = PlayerBase.Cast(newLoc.GetParent().GetHierarchyRootPlayer());
8595
8596 if (oldLoc.GetParent())
8597 oldPlayer = PlayerBase.Cast(oldLoc.GetParent().GetHierarchyRootPlayer());
8598
8599 if (oldPlayer && oldLoc.GetType() == InventoryLocationType.HANDS)
8600 {
8601 int rIndex = oldPlayer.GetHumanInventory().FindUserReservedLocationIndex(this);
8602
8603 if (rIndex >= 0)
8604 {
8605 InventoryLocation rIl = new InventoryLocation;
8606 oldPlayer.GetHumanInventory().GetUserReservedLocation(rIndex, rIl);
8607
8608 oldPlayer.GetHumanInventory().ClearUserReservedLocationAtIndex(rIndex);
8609 int rType = rIl.GetType();
8610 if (rType == InventoryLocationType.CARGO || rType == InventoryLocationType.PROXYCARGO)
8611 {
8612 rIl.GetParent().GetOnReleaseLock().Invoke(this);
8613 }
8614 else if (rType == InventoryLocationType.ATTACHMENT)
8615 {
8616 rIl.GetParent().GetOnAttachmentReleaseLock().Invoke(this, rIl.GetSlot());
8617 }
8618
8619 }
8620 }
8621
8622 if (newLoc.GetType() == InventoryLocationType.HANDS && oldLoc.GetType() != InventoryLocationType.TEMP)
8623 {
8624 if (newPlayer)
8625 newPlayer.ForceStandUpForHeavyItems(newLoc.GetItem());
8626
8627 if (newPlayer == oldPlayer)
8628 {
8629 if (oldLoc.GetParent() && newPlayer.GetHumanInventory().LocationGetEntity(oldLoc) == NULL)
8630 {
8631 if (oldLoc.GetType() == InventoryLocationType.CARGO)
8632 {
8633 if (oldLoc.GetParent().GetInventory().TestAddEntityInCargoExLoc(oldLoc, false, false, false, true, false, false))
8634 {
8635 newPlayer.GetHumanInventory().SetUserReservedLocation(this,oldLoc);
8636 }
8637 }
8638 else
8639 {
8640 newPlayer.GetHumanInventory().SetUserReservedLocation(this,oldLoc);
8641 }
8642 }
8643
8644 if (newPlayer.GetHumanInventory().FindUserReservedLocationIndex(this) >= 0)
8645 {
8646 int type = oldLoc.GetType();
8647 if (type == InventoryLocationType.CARGO || type == InventoryLocationType.PROXYCARGO)
8648 {
8649 oldLoc.GetParent().GetOnSetLock().Invoke(this);
8650 }
8651 else if (type == InventoryLocationType.ATTACHMENT)
8652 {
8653 oldLoc.GetParent().GetOnAttachmentSetLock().Invoke(this, oldLoc.GetSlot());
8654 }
8655 }
8656 if (!m_OldLocation)
8657 {
8658 m_OldLocation = new InventoryLocation;
8659 }
8660 m_OldLocation.Copy(oldLoc);
8661 }
8662 else
8663 {
8664 if (m_OldLocation)
8665 {
8666 m_OldLocation.Reset();
8667 }
8668 }
8669
8670 g_Game.GetAnalyticsClient().OnItemAttachedAtPlayer(this,"Hands");
8671 }
8672 else
8673 {
8674 if (newPlayer)
8675 {
8676 int resIndex = newPlayer.GetHumanInventory().FindCollidingUserReservedLocationIndex(this, newLoc);
8677 if (resIndex >= 0)
8678 {
8679 InventoryLocation il = new InventoryLocation;
8680 newPlayer.GetHumanInventory().GetUserReservedLocation(resIndex, il);
8681 ItemBase it = ItemBase.Cast(il.GetItem());
8682 newPlayer.GetHumanInventory().ClearUserReservedLocationAtIndex(resIndex);
8683 int rel_type = il.GetType();
8684 if (rel_type == InventoryLocationType.CARGO || rel_type == InventoryLocationType.PROXYCARGO)
8685 {
8686 il.GetParent().GetOnReleaseLock().Invoke(it);
8687 }
8688 else if (rel_type == InventoryLocationType.ATTACHMENT)
8689 {
8690 il.GetParent().GetOnAttachmentReleaseLock().Invoke(it, il.GetSlot());
8691 }
8692 //it.GetOnReleaseLock().Invoke(it);
8693 }
8694 }
8695 else if (oldPlayer && newLoc.GetType() == InventoryLocationType.GROUND && m_ThrowItemOnDrop)
8696 {
8697 //ThrowPhysically(oldPlayer, vector.Zero);
8698 m_ThrowItemOnDrop = false;
8699 }
8700
8701 if (m_OldLocation)
8702 {
8703 m_OldLocation.Reset();
8704 }
8705 }
8706
8707 if (oldLoc.GetType() == InventoryLocationType.TEMP)
8708 {
8709 PluginInventoryRepair.Cast(GetPlugin(PluginInventoryRepair)).Remove(oldLoc.GetItem());
8710 }
8711
8712 if (newLoc.GetType() == InventoryLocationType.TEMP)
8713 {
8714 PluginInventoryRepair.Cast(GetPlugin(PluginInventoryRepair)).Add(oldLoc.GetItem());
8715 }
8716 }
8717
8718 override void EOnContact(IEntity other, Contact extra)
8719 {
8721 {
8722 int liquidType = -1;
8723 float impactSpeed = ProcessImpactSoundEx(other, extra, m_ConfigWeight, m_ImpactSoundSurfaceHash, liquidType);
8724 if (impactSpeed > 0.0)
8725 {
8726 m_ImpactSpeed = impactSpeed;
8727 #ifndef SERVER
8728 PlayImpactSound(m_ConfigWeight, m_ImpactSpeed, m_ImpactSoundSurfaceHash);
8729 #else
8730 m_WantPlayImpactSound = true;
8731 SetSynchDirty();
8732 #endif
8733 m_CanPlayImpactSound = (liquidType == -1);// prevents further playing of the sound when the surface is a liquid type
8734 }
8735 }
8736
8737 #ifdef SERVER
8738 if (GetCompEM() && GetCompEM().IsPlugged())
8739 {
8740 if (GetCompEM().GetCordLength() < vector.Distance(GetPosition(), GetCompEM().GetEnergySource().GetPosition()))
8741 GetCompEM().UnplugThis();
8742 }
8743 #endif
8744 }
8745
8746 void RefreshPhysics();
8747
8748 override void OnCreatePhysics()
8749 {
8751 }
8752
8753 override void OnItemAttachmentSlotChanged(notnull InventoryLocation oldLoc, notnull InventoryLocation newLoc)
8754 {
8755
8756 }
8757 // -------------------------------------------------------------------------
8758 override void OnItemLocationChanged(EntityAI old_owner, EntityAI new_owner)
8759 {
8760 super.OnItemLocationChanged(old_owner, new_owner);
8761
8762 PlayerBase relatedPlayer = PlayerBase.Cast(old_owner);
8763 PlayerBase playerNew = PlayerBase.Cast(new_owner);
8764
8765 if (!relatedPlayer && playerNew)
8766 relatedPlayer = playerNew;
8767
8768 if (relatedPlayer && relatedPlayer.GetPerformedActionID() != -1)
8769 {
8770 ActionManagerBase actionMgr = relatedPlayer.GetActionManager();
8771 if (actionMgr)
8772 {
8773 ActionBase currentAction = actionMgr.GetRunningAction();
8774 if (currentAction)
8775 currentAction.OnItemLocationChanged(this);
8776 }
8777 }
8778
8779 Man ownerPlayerOld = null;
8780 Man ownerPlayerNew = null;
8781
8782 if (old_owner)
8783 {
8784 if (old_owner.IsMan())
8785 {
8786 ownerPlayerOld = Man.Cast(old_owner);
8787 }
8788 else
8789 {
8790 ownerPlayerOld = Man.Cast(old_owner.GetHierarchyRootPlayer());
8791 }
8792 }
8793 else
8794 {
8795 if (new_owner && IsElectricAppliance() && GetCompEM() && GetCompEM().IsPlugged())
8796 {
8797 ActionBase action = ActionManagerBase.GetAction(ActionRepositionPluggedItem);
8798
8799 if (!action || !playerNew || playerNew.GetPerformedActionID() != action.GetID())
8800 {
8801 GetCompEM().UnplugThis();
8802 }
8803 }
8804 }
8805
8806 if (new_owner)
8807 {
8808 if (new_owner.IsMan())
8809 {
8810 ownerPlayerNew = Man.Cast(new_owner);
8811 }
8812 else
8813 {
8814 ownerPlayerNew = Man.Cast(new_owner.GetHierarchyRootPlayer());
8815 }
8816 }
8817
8818 if (ownerPlayerOld != ownerPlayerNew)
8819 {
8820 if (ownerPlayerOld)
8821 {
8822 array<EntityAI> subItemsExit = new array<EntityAI>;
8823 GetInventory().EnumerateInventory(InventoryTraversalType.PREORDER,subItemsExit);
8824 for (int i = 0; i < subItemsExit.Count(); i++)
8825 {
8826 ItemBase itemExit = ItemBase.Cast(subItemsExit.Get(i));
8827 itemExit.OnInventoryExit(ownerPlayerOld);
8828 }
8829 }
8830
8831 if (ownerPlayerNew)
8832 {
8833 array<EntityAI> subItemsEnter = new array<EntityAI>;
8834 GetInventory().EnumerateInventory(InventoryTraversalType.PREORDER,subItemsEnter);
8835 for (int j = 0; j < subItemsEnter.Count(); j++)
8836 {
8837 ItemBase itemEnter = ItemBase.Cast(subItemsEnter.Get(j));
8838 itemEnter.OnInventoryEnter(ownerPlayerNew);
8839 }
8840 }
8841 }
8842 else if (ownerPlayerNew != null)
8843 {
8844 PlayerBase nplayer;
8845 if (PlayerBase.CastTo(nplayer, ownerPlayerNew))
8846 {
8847 array<EntityAI> subItemsUpdate = new array<EntityAI>;
8848 GetInventory().EnumerateInventory(InventoryTraversalType.PREORDER,subItemsUpdate);
8849 for (int k = 0; k < subItemsUpdate.Count(); k++)
8850 {
8851 ItemBase itemUpdate = ItemBase.Cast(subItemsUpdate.Get(k));
8852 itemUpdate.UpdateQuickbarShortcutVisibility(nplayer);
8853 }
8854 }
8855 }
8856
8857 if (old_owner)
8858 old_owner.OnChildItemRemoved(this);
8859 if (new_owner)
8860 new_owner.OnChildItemReceived(this);
8861 }
8862
8863 // -------------------------------------------------------------------------------
8864 override void EEDelete(EntityAI parent)
8865 {
8866 super.EEDelete(parent);
8867 PlayerBase player = PlayerBase.Cast(GetHierarchyRootPlayer());
8868 if (player)
8869 {
8870 OnInventoryExit(player);
8871
8872 if (player.IsAlive())
8873 {
8874 int r_index = player.GetHumanInventory().FindUserReservedLocationIndex(this);
8875 if (r_index >= 0)
8876 {
8877 InventoryLocation r_il = new InventoryLocation;
8878 player.GetHumanInventory().GetUserReservedLocation(r_index,r_il);
8879
8880 player.GetHumanInventory().ClearUserReservedLocationAtIndex(r_index);
8881 int r_type = r_il.GetType();
8882 if (r_type == InventoryLocationType.CARGO || r_type == InventoryLocationType.PROXYCARGO)
8883 {
8884 r_il.GetParent().GetOnReleaseLock().Invoke(this);
8885 }
8886 else if (r_type == InventoryLocationType.ATTACHMENT)
8887 {
8888 r_il.GetParent().GetOnAttachmentReleaseLock().Invoke(this, r_il.GetSlot());
8889 }
8890
8891 }
8892
8893 player.RemoveQuickBarEntityShortcut(this);
8894 }
8895 }
8896 }
8897 // -------------------------------------------------------------------------------
8898 override void EEKilled(Object killer)
8899 {
8900 super.EEKilled(killer);
8901
8903 if (killer && killer.IsFireplace() && CanExplodeInFire())
8904 {
8905 if (GetTemperature() >= GameConstants.ITEM_TEMPERATURE_TO_EXPLODE_MIN)
8906 {
8907 if (IsMagazine())
8908 {
8909 if (Magazine.Cast(this).GetAmmoCount() > 0)
8910 {
8911 ExplodeAmmo();
8912 }
8913 }
8914 else
8915 {
8916 Explode(DamageType.EXPLOSION);
8917 }
8918 }
8919 }
8920 }
8921
8922 override void OnWasAttached(EntityAI parent, int slot_id)
8923 {
8924 MiscGameplayFunctions.RemoveAllAttachedChildrenByTypename(this, {Bolt_Base});
8925
8926 super.OnWasAttached(parent, slot_id);
8927
8928 if (HasQuantity())
8929 UpdateNetSyncVariableFloat("m_VarQuantity", GetQuantityMin(), m_VarQuantityMax);
8930
8931 if (g_Game.IsServer() || !g_Game.IsMultiplayer()) // single player or server side multiplayer
8932 StartItemSoundServer(SoundConstants.ITEM_ATTACH, slot_id);
8933 }
8934
8935 override void OnWasDetached(EntityAI parent, int slot_id)
8936 {
8937 super.OnWasDetached(parent, slot_id);
8938
8939 if (HasQuantity())
8940 UpdateNetSyncVariableFloat("m_VarQuantity", GetQuantityMin(), m_VarQuantityMax);
8941
8942 if (g_Game.IsServer() || !g_Game.IsMultiplayer()) // single player or server side multiplayer
8943 StartItemSoundServer(SoundConstants.ITEM_DETACH, slot_id);
8944 }
8945
8946 override string ChangeIntoOnAttach(string slot)
8947 {
8948 int idx;
8949 TStringArray inventory_slots = new TStringArray;
8950 TStringArray attach_types = new TStringArray;
8951
8952 ConfigGetTextArray("ChangeInventorySlot",inventory_slots);
8953 if (inventory_slots.Count() < 1) //is string
8954 {
8955 inventory_slots.Insert(ConfigGetString("ChangeInventorySlot"));
8956 attach_types.Insert(ConfigGetString("ChangeIntoOnAttach"));
8957 }
8958 else //is array
8959 {
8960 ConfigGetTextArray("ChangeIntoOnAttach",attach_types);
8961 }
8962
8963 idx = inventory_slots.Find(slot);
8964 if (idx < 0)
8965 return "";
8966
8967 return attach_types.Get(idx);
8968 }
8969
8970 override string ChangeIntoOnDetach()
8971 {
8972 int idx = -1;
8973 string slot;
8974
8975 TStringArray inventory_slots = new TStringArray;
8976 TStringArray detach_types = new TStringArray;
8977
8978 this.ConfigGetTextArray("ChangeInventorySlot",inventory_slots);
8979 if (inventory_slots.Count() < 1) //is string
8980 {
8981 inventory_slots.Insert(this.ConfigGetString("ChangeInventorySlot"));
8982 detach_types.Insert(this.ConfigGetString("ChangeIntoOnDetach"));
8983 }
8984 else //is array
8985 {
8986 this.ConfigGetTextArray("ChangeIntoOnDetach",detach_types);
8987 if (detach_types.Count() < 1)
8988 detach_types.Insert(this.ConfigGetString("ChangeIntoOnDetach"));
8989 }
8990
8991 for (int i = 0; i < inventory_slots.Count(); i++)
8992 {
8993 slot = inventory_slots.Get(i);
8994 }
8995
8996 if (slot != "")
8997 {
8998 if (detach_types.Count() == 1)
8999 idx = 0;
9000 else
9001 idx = inventory_slots.Find(slot);
9002 }
9003 if (idx < 0)
9004 return "";
9005
9006 return detach_types.Get(idx);
9007 }
9008
9009 void ExplodeAmmo()
9010 {
9011 //timer
9012 ref Timer explode_timer = new Timer(CALL_CATEGORY_SYSTEM);
9013
9014 //min/max time
9015 float min_time = 1;
9016 float max_time = 3;
9017 float delay = Math.RandomFloat(min_time, max_time);
9018
9019 explode_timer.Run(delay, this, "DoAmmoExplosion");
9020 }
9021
9022 void DoAmmoExplosion()
9023 {
9024 Magazine magazine = Magazine.Cast(this);
9025 int pop_sounds_count = 6;
9026 string pop_sounds[ 6 ] = { "ammopops_1","ammopops_2","ammopops_3","ammopops_4","ammopops_5","ammopops_6" };
9027
9028 //play sound
9029 int sound_idx = Math.RandomInt(0, pop_sounds_count - 1);
9030 string sound_name = pop_sounds[ sound_idx ];
9031 g_Game.CreateSoundOnObject(this, sound_name, 20, false);
9032
9033 //remove ammo count
9034 magazine.ServerAddAmmoCount(-1);
9035
9036 //if condition then repeat -> ExplodeAmmo
9037 float min_temp_to_explode = 100; //min temperature for item to explode
9038
9039 if (magazine.GetAmmoCount() > 0 && GetTemperature() >= min_temp_to_explode) //TODO ? add check for parent -> fireplace
9040 {
9041 ExplodeAmmo();
9042 }
9043 }
9044
9045 // -------------------------------------------------------------------------------
9046 override void EEHitBy(TotalDamageResult damageResult, int damageType, EntityAI source, int component, string dmgZone, string ammo, vector modelPos, float speedCoef)
9047 {
9048 super.EEHitBy(damageResult, damageType, source, component, dmgZone, ammo, modelPos, speedCoef);
9049
9050 const int CHANCE_DAMAGE_CARGO = 4;
9051 const int CHANCE_DAMAGE_ATTACHMENT = 1;
9052 const int CHANCE_DAMAGE_NOTHING = 2;
9053
9054 if (IsClothing() || IsContainer() || IsItemTent())
9055 {
9056 float dmg = damageResult.GetDamage("","Health") * -0.5;
9057 int chances;
9058 int rnd;
9059
9060 if (GetInventory().GetCargo())
9061 {
9062 chances = CHANCE_DAMAGE_CARGO + CHANCE_DAMAGE_ATTACHMENT + CHANCE_DAMAGE_NOTHING;
9063 rnd = Math.RandomInt(0,chances);
9064
9065 if (rnd < CHANCE_DAMAGE_CARGO)
9066 {
9067 DamageItemInCargo(dmg);
9068 }
9069 else if (rnd < (chances - CHANCE_DAMAGE_NOTHING))
9070 {
9072 }
9073 }
9074 else
9075 {
9076 chances = CHANCE_DAMAGE_ATTACHMENT + CHANCE_DAMAGE_NOTHING;
9077 rnd = Math.RandomInt(0,chances);
9078
9079 if (rnd < CHANCE_DAMAGE_ATTACHMENT)
9080 {
9082 }
9083 }
9084 }
9085 }
9086
9087 bool DamageItemInCargo(float damage)
9088 {
9089 CargoBase cargo = GetInventory().GetCargo();
9090 if (cargo)
9091 {
9092 int item_count = cargo.GetItemCount();
9093 if (item_count > 0)
9094 {
9095 int random_pick = Math.RandomInt(0, item_count);
9096 ItemBase item = ItemBase.Cast(cargo.GetItem(random_pick));
9097 if (!item.IsExplosive())
9098 {
9099 item.AddHealth("","",damage);
9100 return true;
9101 }
9102 }
9103 }
9104 return false;
9105 }
9106
9107 bool DamageItemAttachments(float damage)
9108 {
9109 GameInventory inventory = GetInventory();
9110 int attachment_count = inventory.AttachmentCount();
9111 if (attachment_count > 0)
9112 {
9113 int random_pick = Math.RandomInt(0, attachment_count);
9114 ItemBase attachment = ItemBase.Cast(inventory.GetAttachmentFromIndex(random_pick));
9115 if (!attachment.IsExplosive())
9116 {
9117 attachment.AddHealth("","",damage);
9118 return true;
9119 }
9120 }
9121 return false;
9122 }
9123
9124 override bool IsSplitable()
9125 {
9126 return m_CanThisBeSplit;
9127 }
9128 //----------------
9129 override bool CanBeSplit()
9130 {
9131 if (IsSplitable() && (GetQuantity() > 1))
9132 return GetInventory().CanRemoveEntity();
9133
9134 return false;
9135 }
9136
9137 protected bool ShouldSplitQuantity(float quantity)
9138 {
9139 // don't call 'CanBeSplit' here, too strict and will introduce a freeze-crash when dismantling fence with a fireplace nearby
9140 if (!IsSplitable())
9141 return false;
9142
9143 // nothing to split?
9144 if (GetQuantity() <= 1)
9145 return false;
9146
9147 // check if we should re-use the item instead of creating a new copy?
9148 // implicit cast to int, if 'IsSplitable' returns true, these values are assumed ints
9149 int delta = GetQuantity() - quantity;
9150 if (delta == 0)
9151 return false;
9152
9153 // valid to split
9154 return true;
9155 }
9156
9157 override void SplitIntoStackMaxClient(EntityAI destination_entity, int slot_id )
9158 {
9159 if (g_Game.IsClient())
9160 {
9161 if (ScriptInputUserData.CanStoreInputUserData())
9162 {
9163 ScriptInputUserData ctx = new ScriptInputUserData;
9165 ctx.Write(1);
9166 ItemBase i1 = this; // @NOTE: workaround for correct serialization
9167 ctx.Write(i1);
9168 ctx.Write(destination_entity);
9169 ctx.Write(true);
9170 ctx.Write(slot_id);
9171 ctx.Send();
9172 }
9173 }
9174 else if (!g_Game.IsMultiplayer())
9175 {
9176 SplitIntoStackMax(destination_entity, slot_id, PlayerBase.Cast(g_Game.GetPlayer()));
9177 }
9178 }
9179
9180 void SplitIntoStackMax(EntityAI destination_entity, int slot_id, PlayerBase player)
9181 {
9182 float split_quantity_new;
9183 ItemBase new_item;
9184 float quantity = GetQuantity();
9185 float stack_max = GetTargetQuantityMax(slot_id);
9186 InventoryLocation loc = new InventoryLocation;
9187
9188 if (destination_entity && slot_id != -1 && InventorySlots.IsSlotIdValid(slot_id))
9189 {
9190 if (stack_max <= GetQuantity())
9191 split_quantity_new = stack_max;
9192 else
9193 split_quantity_new = GetQuantity();
9194
9195 if (ShouldSplitQuantity(split_quantity_new))
9196 {
9197 new_item = ItemBase.Cast(destination_entity.GetInventory().CreateAttachmentEx(this.GetType(), slot_id));
9198 if (new_item)
9199 {
9200 new_item.SetResultOfSplit(true);
9201 MiscGameplayFunctions.TransferItemProperties(this, new_item);
9202 AddQuantity(-split_quantity_new, false, true);
9203 new_item.SetQuantity(split_quantity_new, false, true);
9204 }
9205 }
9206 }
9207 else if (destination_entity && slot_id == -1)
9208 {
9209 if (quantity > stack_max)
9210 split_quantity_new = stack_max;
9211 else
9212 split_quantity_new = quantity;
9213
9214 if (ShouldSplitQuantity(split_quantity_new))
9215 {
9216 GameInventory destinationInventory = destination_entity.GetInventory();
9217 if (destinationInventory.FindFreeLocationFor(this, FindInventoryLocationType.ANY, loc))
9218 {
9219 Object o = destinationInventory.LocationCreateEntity(loc, GetType(), ECE_IN_INVENTORY, RF_DEFAULT);
9220 new_item = ItemBase.Cast(o);
9221 }
9222
9223 if (new_item)
9224 {
9225 new_item.SetResultOfSplit(true);
9226 MiscGameplayFunctions.TransferItemProperties(this, new_item);
9227 AddQuantity(-split_quantity_new, false, true);
9228 new_item.SetQuantity(split_quantity_new, false, true);
9229 }
9230 }
9231 }
9232 else
9233 {
9234 if (stack_max != 0)
9235 {
9236 if (stack_max < GetQuantity())
9237 {
9238 split_quantity_new = GetQuantity() - stack_max;
9239 }
9240
9241 if (split_quantity_new == 0)
9242 {
9243 if (!g_Game.IsMultiplayer())
9244 player.PhysicalPredictiveDropItem(this);
9245 else
9246 player.ServerDropEntity(this);
9247 return;
9248 }
9249
9250 if (ShouldSplitQuantity(split_quantity_new))
9251 {
9252 new_item = ItemBase.Cast(g_Game.CreateObjectEx(GetType(), player.GetWorldPosition(), ECE_PLACE_ON_SURFACE));
9253
9254 if (new_item)
9255 {
9256 new_item.SetResultOfSplit(true);
9257 MiscGameplayFunctions.TransferItemProperties(this, new_item);
9258 SetQuantity(split_quantity_new, false, true);
9259 new_item.SetQuantity(stack_max, false, true);
9260 new_item.PlaceOnSurface();
9261 }
9262 }
9263 }
9264 }
9265 }
9266
9267 override void SplitIntoStackMaxEx(EntityAI destination_entity, int slot_id)
9268 {
9269 float split_quantity_new;
9270 ItemBase new_item;
9271 float quantity = GetQuantity();
9272 float stack_max = GetTargetQuantityMax(slot_id);
9273 InventoryLocation loc = new InventoryLocation;
9274
9275 if (destination_entity && slot_id != -1 && InventorySlots.IsSlotIdValid(slot_id))
9276 {
9277 if (stack_max <= GetQuantity())
9278 split_quantity_new = stack_max;
9279 else
9280 split_quantity_new = GetQuantity();
9281
9282 if (ShouldSplitQuantity(split_quantity_new))
9283 {
9284 new_item = ItemBase.Cast(destination_entity.GetInventory().CreateAttachmentEx(this.GetType(), slot_id));
9285 if (new_item)
9286 {
9287 new_item.SetResultOfSplit(true);
9288 MiscGameplayFunctions.TransferItemProperties(this, new_item);
9289 AddQuantity(-split_quantity_new, false, true);
9290 new_item.SetQuantity(split_quantity_new, false, true);
9291 }
9292 }
9293 }
9294 else if (destination_entity && slot_id == -1)
9295 {
9296 if (quantity > stack_max)
9297 split_quantity_new = stack_max;
9298 else
9299 split_quantity_new = quantity;
9300
9301 if (ShouldSplitQuantity(split_quantity_new))
9302 {
9303 GameInventory destinationInventory = destination_entity.GetInventory();
9304 if (destinationInventory.FindFreeLocationFor(this, FindInventoryLocationType.ANY, loc))
9305 {
9306 Object o = destinationInventory.LocationCreateEntity(loc, GetType(), ECE_IN_INVENTORY, RF_DEFAULT);
9307 new_item = ItemBase.Cast(o);
9308 }
9309
9310 if (new_item)
9311 {
9312 new_item.SetResultOfSplit(true);
9313 MiscGameplayFunctions.TransferItemProperties(this, new_item);
9314 AddQuantity(-split_quantity_new, false, true);
9315 new_item.SetQuantity(split_quantity_new, false, true);
9316 }
9317 }
9318 }
9319 else
9320 {
9321 if (stack_max != 0)
9322 {
9323 if (stack_max < GetQuantity())
9324 {
9325 split_quantity_new = GetQuantity() - stack_max;
9326 }
9327
9328 if (ShouldSplitQuantity(split_quantity_new))
9329 {
9330 new_item = ItemBase.Cast(g_Game.CreateObjectEx(GetType(),GetWorldPosition(), ECE_PLACE_ON_SURFACE));
9331
9332 if (new_item)
9333 {
9334 new_item.SetResultOfSplit(true);
9335 MiscGameplayFunctions.TransferItemProperties(this, new_item);
9336 SetQuantity(split_quantity_new, false, true);
9337 new_item.SetQuantity(stack_max, false, true);
9338 new_item.PlaceOnSurface();
9339 }
9340 }
9341 }
9342 }
9343 }
9344
9345 void SplitIntoStackMaxToInventoryLocationClient(notnull InventoryLocation dst)
9346 {
9347 if (g_Game.IsClient())
9348 {
9349 if (ScriptInputUserData.CanStoreInputUserData())
9350 {
9351 ScriptInputUserData ctx = new ScriptInputUserData;
9353 ctx.Write(4);
9354 ItemBase thiz = this; // @NOTE: workaround for correct serialization
9355 ctx.Write(thiz);
9356 dst.WriteToContext(ctx);
9357 ctx.Send();
9358 }
9359 }
9360 else if (!g_Game.IsMultiplayer())
9361 {
9363 }
9364 }
9365
9366 void SplitIntoStackMaxCargoClient(EntityAI destination_entity, int idx, int row, int col)
9367 {
9368 if (g_Game.IsClient())
9369 {
9370 if (ScriptInputUserData.CanStoreInputUserData())
9371 {
9372 ScriptInputUserData ctx = new ScriptInputUserData;
9374 ctx.Write(2);
9375 ItemBase dummy = this; // @NOTE: workaround for correct serialization
9376 ctx.Write(dummy);
9377 ctx.Write(destination_entity);
9378 ctx.Write(true);
9379 ctx.Write(idx);
9380 ctx.Write(row);
9381 ctx.Write(col);
9382 ctx.Send();
9383 }
9384 }
9385 else if (!g_Game.IsMultiplayer())
9386 {
9387 SplitIntoStackMaxCargo(destination_entity, idx, row, col);
9388 }
9389 }
9390
9391 void SplitIntoStackMaxToInventoryLocation(notnull InventoryLocation dst)
9392 {
9394 }
9395
9396 ItemBase SplitIntoStackMaxToInventoryLocationEx(notnull InventoryLocation dst)
9397 {
9398 float quantity = GetQuantity();
9399 float split_quantity_new;
9400 ItemBase new_item;
9401 if (dst.IsValid())
9402 {
9403 int slot_id = dst.GetSlot();
9404 float stack_max = GetTargetQuantityMax(slot_id);
9405
9406 if (quantity > stack_max)
9407 split_quantity_new = stack_max;
9408 else
9409 split_quantity_new = quantity;
9410
9411 if (ShouldSplitQuantity(split_quantity_new))
9412 {
9413 new_item = ItemBase.Cast(GameInventory.LocationCreateEntity(dst, this.GetType(), ECE_IN_INVENTORY, RF_DEFAULT));
9414
9415 if (new_item)
9416 {
9417 new_item.SetResultOfSplit(true);
9418 MiscGameplayFunctions.TransferItemProperties(this,new_item);
9419 AddQuantity(-split_quantity_new, false, true);
9420 new_item.SetQuantity(split_quantity_new, false, true);
9421 }
9422
9423 return new_item;
9424 }
9425 }
9426
9427 return null;
9428 }
9429
9430 void SplitIntoStackMaxCargo(EntityAI destination_entity, int idx, int row, int col)
9431 {
9432 float quantity = GetQuantity();
9433 float split_quantity_new;
9434 ItemBase new_item;
9435 if (destination_entity)
9436 {
9437 float stackable = GetTargetQuantityMax();
9438 if (quantity > stackable)
9439 split_quantity_new = stackable;
9440 else
9441 split_quantity_new = quantity;
9442
9443 if (ShouldSplitQuantity(split_quantity_new))
9444 {
9445 new_item = ItemBase.Cast(destination_entity.GetInventory().CreateEntityInCargoEx(this.GetType(), idx, row, col, false));
9446 if (new_item)
9447 {
9448 new_item.SetResultOfSplit(true);
9449 MiscGameplayFunctions.TransferItemProperties(this,new_item);
9450 AddQuantity(-split_quantity_new, false, true);
9451 new_item.SetQuantity(split_quantity_new, false, true);
9452 }
9453 }
9454 }
9455 }
9456
9457 void SplitIntoStackMaxHandsClient(PlayerBase player)
9458 {
9459 if (g_Game.IsClient())
9460 {
9461 if (ScriptInputUserData.CanStoreInputUserData())
9462 {
9463 ScriptInputUserData ctx = new ScriptInputUserData;
9465 ctx.Write(3);
9466 ItemBase i1 = this; // @NOTE: workaround for correct serialization
9467 ctx.Write(i1);
9468 ItemBase destination_entity = this;
9469 ctx.Write(destination_entity);
9470 ctx.Write(true);
9471 ctx.Write(0);
9472 ctx.Send();
9473 }
9474 }
9475 else if (!g_Game.IsMultiplayer())
9476 {
9477 SplitIntoStackMaxHands(player);
9478 }
9479 }
9480
9481 void SplitIntoStackMaxHands(PlayerBase player)
9482 {
9483 float quantity = GetQuantity();
9484 float split_quantity_new;
9485 ref ItemBase new_item;
9486 if (player)
9487 {
9488 float stackable = GetTargetQuantityMax();
9489 if (quantity > stackable)
9490 split_quantity_new = stackable;
9491 else
9492 split_quantity_new = quantity;
9493
9494 if (ShouldSplitQuantity(split_quantity_new))
9495 {
9496 EntityAI in_hands = player.GetHumanInventory().CreateInHands(this.GetType());
9497 new_item = ItemBase.Cast(in_hands);
9498 if (new_item)
9499 {
9500 new_item.SetResultOfSplit(true);
9501 MiscGameplayFunctions.TransferItemProperties(this,new_item);
9502 AddQuantity(-split_quantity_new, false, true);
9503 new_item.SetQuantity(split_quantity_new, false, true);
9504 }
9505 }
9506 }
9507 }
9508
9509 void SplitItemToInventoryLocation(notnull InventoryLocation dst)
9510 {
9511 float quantity = GetQuantity();
9512 float split_quantity_new = Math.Floor(quantity * 0.5);
9513
9514 if (!ShouldSplitQuantity(split_quantity_new))
9515 return;
9516
9517 ItemBase new_item = ItemBase.Cast(GameInventory.LocationCreateEntity(dst, GetType(), ECE_IN_INVENTORY, RF_DEFAULT));
9518
9519 if (new_item)
9520 {
9521 if (new_item.GetQuantityMax() < split_quantity_new)
9522 {
9523 split_quantity_new = new_item.GetQuantityMax();
9524 }
9525
9526 new_item.SetResultOfSplit(true);
9527 MiscGameplayFunctions.TransferItemProperties(this, new_item);
9528
9529 if (dst.IsValid() && dst.GetType() == InventoryLocationType.ATTACHMENT && split_quantity_new > 1)
9530 {
9531 AddQuantity(-1, false, true);
9532 new_item.SetQuantity(1, false, true);
9533 }
9534 else
9535 {
9536 AddQuantity(-split_quantity_new, false, true);
9537 new_item.SetQuantity(split_quantity_new, false, true);
9538 }
9539 }
9540 }
9541
9542 void SplitItem(PlayerBase player)
9543 {
9544 float quantity = GetQuantity();
9545 float split_quantity_new = Math.Floor(quantity / 2);
9546
9547 if (!ShouldSplitQuantity(split_quantity_new))
9548 return;
9549
9550 InventoryLocation invloc = new InventoryLocation;
9551 bool found = player.GetInventory().FindFirstFreeLocationForNewEntity(GetType(), FindInventoryLocationType.ATTACHMENT, invloc);
9552
9553 ItemBase new_item;
9554 new_item = player.CreateCopyOfItemInInventoryOrGroundEx(this, true);
9555
9556 if (new_item)
9557 {
9558 if (new_item.GetQuantityMax() < split_quantity_new)
9559 {
9560 split_quantity_new = new_item.GetQuantityMax();
9561 }
9562 if (found && invloc.IsValid() && invloc.GetType() == InventoryLocationType.ATTACHMENT && split_quantity_new > 1)
9563 {
9564 AddQuantity(-1, false, true);
9565 new_item.SetQuantity(1, false, true);
9566 }
9567 else if (split_quantity_new > 1)
9568 {
9569 AddQuantity(-split_quantity_new, false, true);
9570 new_item.SetQuantity(split_quantity_new, false, true);
9571 }
9572 }
9573 }
9574
9576 void OnQuantityChanged(float delta)
9577 {
9578 SetWeightDirty();
9579 ItemBase parent = ItemBase.Cast(GetHierarchyParent());
9580
9581 if (parent)
9582 parent.OnAttachmentQuantityChangedEx(this, delta);
9583
9584 if (IsLiquidContainer())
9585 {
9586 if (GetQuantityNormalized() <= 0.0)
9587 {
9589 }
9590 else if (GetLiquidType() == LIQUID_NONE)
9591 {
9592 ErrorEx("Undefined liquid type quantity changed, please define liquid type first! Using init value.",ErrorExSeverity.INFO);
9594 }
9595 }
9596 }
9597
9600 {
9601 // insert code here
9602 }
9603
9605 void OnAttachmentQuantityChangedEx(ItemBase item , float delta)
9606 {
9608 }
9609
9610 override void EEHealthLevelChanged(int oldLevel, int newLevel, string zone)
9611 {
9612 super.EEHealthLevelChanged(oldLevel,newLevel,zone);
9613
9614 if (g_Game.IsServer())
9615 {
9616 if (newLevel == GameConstants.STATE_RUINED)
9617 {
9619 EntityAI parent = GetHierarchyParent();
9620 if (parent && parent.IsFireplace())
9621 {
9622 CargoBase cargo = GetInventory().GetCargo();
9623 if (cargo)
9624 {
9625 for (int i = 0; i < cargo.GetItemCount(); ++i)
9626 {
9627 parent.GetInventory().TakeEntityToInventory(InventoryMode.SERVER, FindInventoryLocationType.CARGO, cargo.GetItem(i));
9628 }
9629 }
9630 }
9631 }
9632
9633 if (IsResultOfSplit())
9634 {
9635 // reset the splitting result flag, return to normal item behavior
9636 SetResultOfSplit(false);
9637 return;
9638 }
9639
9640 if (m_Cleanness != 0 && oldLevel < newLevel && newLevel != 0)
9641 {
9642 SetCleanness(0);//unclean the item upon damage dealt
9643 }
9644 }
9645 }
9646
9647 // just the split? TODO: verify
9648 override void OnRightClick()
9649 {
9650 super.OnRightClick();
9651
9652 if (CanBeSplit() && !GetDayZGame().IsLeftCtrlDown() && !g_Game.GetPlayer().GetInventory().HasInventoryReservation(this,null))
9653 {
9654 if (g_Game.IsClient())
9655 {
9656 if (ScriptInputUserData.CanStoreInputUserData())
9657 {
9658 EntityAI root = GetHierarchyRoot();
9659 Man playerOwner = GetHierarchyRootPlayer();
9660 InventoryLocation dst = new InventoryLocation;
9661
9662 // 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
9663 if (!playerOwner && root && root == this)
9664 {
9666 }
9667 else
9668 {
9669 // 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
9670 GetInventory().GetCurrentInventoryLocation(dst);
9671 if (!dst.GetParent() || dst.GetParent() && !dst.GetParent().GetInventory().FindFreeLocationFor(this, FindInventoryLocationType.CARGO, dst))
9672 {
9673 PlayerBase player = PlayerBase.Cast(g_Game.GetPlayer());
9674 if (!player.GetInventory().FindFreeLocationFor(this, FindInventoryLocationType.CARGO, dst) || !playerOwner)
9675 {
9677 }
9678 else
9679 {
9680 dst.SetCargo(dst.GetParent(), this, dst.GetIdx(), dst.GetRow(), dst.GetCol(), dst.GetFlip());
9681 /* hacky solution to check reservation of "this" item instead of null since the gamecode is checking null against null and returning reservation=true incorrectly
9682 this shouldnt cause issues within this scope*/
9683 if (g_Game.GetPlayer().GetInventory().HasInventoryReservation(this, dst))
9684 {
9686 }
9687 else
9688 {
9689 g_Game.GetPlayer().GetInventory().AddInventoryReservationEx(null, dst, GameInventory.c_InventoryReservationTimeoutShortMS);
9690 }
9691 }
9692 }
9693 }
9694
9695 ScriptInputUserData ctx = new ScriptInputUserData;
9697 ctx.Write(4);
9698 ItemBase thiz = this; // @NOTE: workaround for correct serialization
9699 ctx.Write(thiz);
9700 dst.WriteToContext(ctx);
9701 ctx.Write(true); // dummy
9702 ctx.Send();
9703 }
9704 }
9705 else if (!g_Game.IsMultiplayer())
9706 {
9707 SplitItem(PlayerBase.Cast(g_Game.GetPlayer()));
9708 }
9709 }
9710 }
9711
9712 protected void SetInventoryLocationToVicinityOrCurrent(EntityAI root, inout InventoryLocation dst)
9713 {
9714 if (root)
9715 {
9716 vector m4[4];
9717 root.GetTransform(m4);
9718 dst.SetGround(this, m4);
9719 }
9720 else
9721 {
9722 GetInventory().GetCurrentInventoryLocation(dst);
9723 }
9724 }
9725
9726 override bool CanBeCombined(EntityAI other_item, bool reservation_check = true, bool stack_max_limit = false)
9727 {
9728 //TODO: delete check zero quantity check after fix double posts hands fsm events
9729 if (!other_item || GetType() != other_item.GetType() || (IsFullQuantity() && other_item.GetQuantity() > 0) || other_item == this)
9730 return false;
9731
9732 if (GetHealthLevel() == GameConstants.STATE_RUINED || other_item.GetHealthLevel() == GameConstants.STATE_RUINED)
9733 return false;
9734
9735 //can_this_be_combined = ConfigGetBool("canBeSplit");
9737 return false;
9738
9739
9740 Magazine mag = Magazine.Cast(this);
9741 if (mag)
9742 {
9743 if (mag.GetAmmoCount() >= mag.GetAmmoMax())
9744 return false;
9745
9746 if (stack_max_limit)
9747 {
9748 Magazine other_mag = Magazine.Cast(other_item);
9749 if (other_item)
9750 {
9751 if (mag.GetAmmoCount() + other_mag.GetAmmoCount() > mag.GetAmmoMax())
9752 return false;
9753 }
9754
9755 }
9756 }
9757 else
9758 {
9759 //TODO: delete check zero quantity check after fix double posts hands fsm events
9760 if (GetQuantity() >= GetQuantityMax() && other_item.GetQuantity() > 0 )
9761 return false;
9762
9763 if (stack_max_limit && (GetQuantity() + other_item.GetQuantity() > GetQuantityMax()))
9764 return false;
9765 }
9766
9767 PlayerBase player = null;
9768 if (CastTo(player, GetHierarchyRootPlayer())) //false when attached to player's attachment slot
9769 {
9770 if (player.GetInventory().HasAttachment(this))
9771 return false;
9772
9773 if (player.IsItemsToDelete())
9774 return false;
9775 }
9776
9777 if (reservation_check && (GetInventory().HasInventoryReservation(this, null) || other_item.GetInventory().HasInventoryReservation(other_item, null)))
9778 return false;
9779
9780 int slotID;
9781 string slotName;
9782 if (GetInventory().GetCurrentAttachmentSlotInfo(slotID,slotName) && GetHierarchyParent().GetInventory().GetSlotLock(slotID))
9783 return false;
9784
9785 return true;
9786 }
9787
9788 bool IsCombineAll(ItemBase other_item, bool use_stack_max = false)
9789 {
9790 return ComputeQuantityUsed(other_item, use_stack_max) == other_item.GetQuantity();
9791 }
9792
9793 bool IsResultOfSplit()
9794 {
9795 return m_IsResultOfSplit;
9796 }
9797
9798 void SetResultOfSplit(bool value)
9799 {
9800 m_IsResultOfSplit = value;
9801 }
9802
9803 int ComputeQuantityUsed(ItemBase other_item, bool use_stack_max = true)
9804 {
9805 return ComputeQuantityUsedEx(other_item, use_stack_max);
9806 }
9807
9808 float ComputeQuantityUsedEx(ItemBase other_item, bool use_stack_max = true)
9809 {
9810 float other_item_quantity = other_item.GetQuantity();
9811 float this_free_space;
9812
9813 float stack_max = GetQuantityMax();
9814
9815 this_free_space = stack_max - GetQuantity();
9816
9817 if (other_item_quantity > this_free_space)
9818 {
9819 return this_free_space;
9820 }
9821 else
9822 {
9823 return other_item_quantity;
9824 }
9825 }
9826
9827 override void CombineItemsEx(EntityAI entity2, bool use_stack_max = true)
9828 {
9829 CombineItems(ItemBase.Cast(entity2),use_stack_max);
9830 }
9831
9832 void CombineItems(ItemBase other_item, bool use_stack_max = true)
9833 {
9834 if (!CanBeCombined(other_item, false))
9835 return;
9836
9837 if (!IsMagazine() && other_item)
9838 {
9839 float quantity_used = ComputeQuantityUsedEx(other_item,use_stack_max);
9840 if (quantity_used != 0)
9841 {
9842 float hp1 = GetHealth01("","");
9843 float hp2 = other_item.GetHealth01("","");
9844 float hpResult = ((hp1*GetQuantity()) + (hp2*quantity_used));
9845 hpResult = hpResult / (GetQuantity() + quantity_used);
9846
9847 hpResult *= GetMaxHealth();
9848 Math.Round(hpResult);
9849 SetHealth("", "Health", hpResult);
9850
9851 AddQuantity(quantity_used);
9852 other_item.AddQuantity(-quantity_used);
9853 }
9854 }
9855 OnCombine(other_item);
9856 }
9857
9858 void OnCombine(ItemBase other_item)
9859 {
9860 #ifdef SERVER
9861 if (!GetHierarchyRootPlayer() && GetHierarchyParent())
9862 GetHierarchyParent().IncreaseLifetimeUp();
9863 #endif
9864 };
9865
9866 void GetRecipesActions(Man player, out TSelectableActionInfoArray outputList)
9867 {
9868 PlayerBase p = PlayerBase.Cast(player);
9869
9870 array<int> recipesIds = p.m_Recipes;
9871 PluginRecipesManager moduleRecipesManager = PluginRecipesManager.Cast(GetPlugin(PluginRecipesManager));
9872 if (moduleRecipesManager)
9873 {
9874 EntityAI itemInHands = player.GetEntityInHands();
9875 moduleRecipesManager.GetValidRecipes(ItemBase.Cast(this), ItemBase.Cast(itemInHands), recipesIds, p);
9876 }
9877
9878 for (int i = 0;i < recipesIds.Count(); i++)
9879 {
9880 int key = recipesIds.Get(i);
9881 string recipeName = moduleRecipesManager.GetRecipeName(key);
9882 outputList.Insert(new TSelectableActionInfo(SAT_CRAFTING, key, recipeName));
9883 }
9884 }
9885
9886 // -------------------------------------------------------------------------
9887 override void GetDebugActions(out TSelectableActionInfoArrayEx outputList)
9888 {
9889 super.GetDebugActions(outputList);
9890
9891 //quantity
9892 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.ADD_QUANTITY, "Quantity +20%", FadeColors.LIGHT_GREY));
9893 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.REMOVE_QUANTITY, "Quantity -20%", FadeColors.LIGHT_GREY));
9894 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SET_QUANTITY_0, "Set Quantity 0", FadeColors.LIGHT_GREY));
9895 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SET_MAX_QUANTITY, "Set Quantity Max", FadeColors.LIGHT_GREY));
9896 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SEPARATOR, "___________________________", FadeColors.RED));
9897
9898 //health
9899 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.ADD_HEALTH, "Health +20%", FadeColors.LIGHT_GREY));
9900 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.REMOVE_HEALTH, "Health -20%", FadeColors.LIGHT_GREY));
9901 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.DESTROY_HEALTH, "Health 0", FadeColors.LIGHT_GREY));
9902 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SEPARATOR, "___________________________", FadeColors.RED));
9903 //temperature
9904 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.ADD_TEMPERATURE, "Temperature +20", FadeColors.LIGHT_GREY));
9905 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.REMOVE_TEMPERATURE, "Temperature -20", FadeColors.LIGHT_GREY));
9906 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.FLIP_FROZEN, "Toggle Frozen", FadeColors.LIGHT_GREY));
9907 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SEPARATOR, "___________________________", FadeColors.RED));
9908
9909 //wet
9910 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.ADD_WETNESS, "Wetness +20", FadeColors.LIGHT_GREY));
9911 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.REMOVE_WETNESS, "Wetness -20", FadeColors.LIGHT_GREY));
9912 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SEPARATOR, "___________________________", FadeColors.RED));
9913
9914 //liquidtype
9915 if (IsLiquidContainer())
9916 {
9917 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.LIQUIDTYPE_UP, "LiquidType Next", FadeColors.LIGHT_GREY));
9918 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.LIQUIDTYPE_DOWN, "LiquidType Previous", FadeColors.LIGHT_GREY));
9919 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SEPARATOR, "___________________________", FadeColors.RED));
9920 }
9921
9922 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.MAKE_SPECIAL, "Make Special", FadeColors.LIGHT_GREY));
9923 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SEPARATOR, "___________________________", FadeColors.RED));
9924
9925 // watch
9926 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.WATCH_ITEM, "Watch (CTRL-Z)", FadeColors.LIGHT_GREY));
9927 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.WATCH_PLAYER, "Watch Player", FadeColors.LIGHT_GREY));
9928 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SEPARATOR, "___________________________", FadeColors.RED));
9929
9930 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.DELETE, "Delete", FadeColors.RED));
9931
9932 InventoryLocation loc = new InventoryLocation();
9933 GetInventory().GetCurrentInventoryLocation(loc);
9934 if (!loc || loc.GetType() == InventoryLocationType.GROUND)
9935 {
9936 if (Gizmo_IsSupported())
9937 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.GIZMO_OBJECT, "Gizmo Object", FadeColors.LIGHT_GREY));
9938 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.GIZMO_PHYSICS, "Gizmo Physics (SP Only)", FadeColors.LIGHT_GREY)); // intentionally allowed for testing physics desync
9939 }
9940
9941 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SEPARATOR, "___________________________", FadeColors.RED));
9942 }
9943
9944 // -------------------------------------------------------------------------
9945 // -------------------------------------------------------------------------
9946 // -------------------------------------------------------------------------
9947 override bool OnAction(int action_id, Man player, ParamsReadContext ctx)
9948 {
9949 super.OnAction(action_id, player, ctx);
9950
9951 if (g_Game.IsClient() || !g_Game.IsMultiplayer())
9952 {
9953 switch (action_id)
9954 {
9955 case EActions.GIZMO_OBJECT:
9956 if (GetGizmoApi())
9957 GetGizmoApi().SelectObject(this);
9958 return true;
9959 case EActions.GIZMO_PHYSICS:
9960 if (GetGizmoApi())
9961 GetGizmoApi().SelectPhysics(GetPhysics());
9962 return true;
9963 }
9964 }
9965
9966 if (g_Game.IsServer())
9967 {
9968 switch (action_id)
9969 {
9970 case EActions.DELETE:
9971 Delete();
9972 return true;
9973 }
9974 }
9975
9976 if (action_id >= EActions.RECIPES_RANGE_START && action_id < EActions.RECIPES_RANGE_END)
9977 {
9978 PluginRecipesManager plugin_recipes_manager = PluginRecipesManager.Cast(GetPlugin(PluginRecipesManager));
9979 int idWithoutOffset = action_id - EActions.RECIPES_RANGE_START;
9980 PlayerBase p = PlayerBase.Cast(player);
9981 if (EActions.RECIPES_RANGE_START < 1000)
9982 {
9983 float anim_length = plugin_recipes_manager.GetRecipeLengthInSecs(idWithoutOffset);
9984 float specialty_weight = plugin_recipes_manager.GetRecipeSpecialty(idWithoutOffset);
9985 }
9986 }
9987 #ifndef SERVER
9988 else if (action_id == EActions.WATCH_PLAYER)
9989 {
9990 PluginDeveloper.SetDeveloperItemClientEx(player);
9991 }
9992 #endif
9993 if (g_Game.IsServer())
9994 {
9995 if (action_id >= EActions.DEBUG_ITEM_WATCH_BUTTON_RANGE_START && action_id < EActions.DEBUG_ITEM_WATCH_BUTTON_RANGE_END)
9996 {
9997 int id = action_id - EActions.DEBUG_ITEM_WATCH_BUTTON_RANGE_START;
9998 OnDebugButtonPressServer(id + 1);
9999 }
10000
10001 else if (action_id >= EActions.DEBUG_AGENTS_RANGE_INJECT_START && action_id < EActions.DEBUG_AGENTS_RANGE_INJECT_END)
10002 {
10003 int agent_id = action_id - EActions.DEBUG_AGENTS_RANGE_INJECT_START;
10004 InsertAgent(agent_id,100);
10005 }
10006
10007 else if (action_id >= EActions.DEBUG_AGENTS_RANGE_REMOVE_START && action_id < EActions.DEBUG_AGENTS_RANGE_REMOVE_END)
10008 {
10009 int agent_id2 = action_id - EActions.DEBUG_AGENTS_RANGE_REMOVE_START;
10010 RemoveAgent(agent_id2);
10011 }
10012
10013 else if (action_id == EActions.ADD_QUANTITY)
10014 {
10015 if (IsMagazine())
10016 {
10017 Magazine mag = Magazine.Cast(this);
10018 mag.ServerSetAmmoCount(mag.GetAmmoCount() + mag.GetAmmoMax() * 0.2);
10019 }
10020 else
10021 {
10022 AddQuantity(GetQuantityMax() * 0.2);
10023 }
10024
10025 if (m_EM)
10026 {
10027 m_EM.AddEnergy(m_EM.GetEnergyMax() * 0.2);
10028 }
10029 //PrintVariables();
10030 }
10031
10032 else if (action_id == EActions.REMOVE_QUANTITY) //Quantity -20%
10033 {
10034 if (IsMagazine())
10035 {
10036 Magazine mag2 = Magazine.Cast(this);
10037 mag2.ServerSetAmmoCount(mag2.GetAmmoCount() - mag2.GetAmmoMax() * 0.2);
10038 }
10039 else
10040 {
10041 AddQuantity(- GetQuantityMax() * 0.2);
10042 }
10043 if (m_EM)
10044 {
10045 m_EM.AddEnergy(- m_EM.GetEnergyMax() * 0.2);
10046 }
10047 //PrintVariables();
10048 }
10049
10050 else if (action_id == EActions.SET_QUANTITY_0) //SetMaxQuantity
10051 {
10052 SetQuantity(0);
10053
10054 if (m_EM)
10055 {
10056 m_EM.SetEnergy(0);
10057 }
10058 }
10059
10060 else if (action_id == EActions.SET_MAX_QUANTITY) //SetMaxQuantity
10061 {
10063
10064 if (m_EM)
10065 {
10066 m_EM.SetEnergy(m_EM.GetEnergyMax());
10067 }
10068 }
10069
10070 else if (action_id == EActions.ADD_HEALTH)
10071 {
10072 AddHealth("","",GetMaxHealth("","Health")/5);
10073 }
10074 else if (action_id == EActions.REMOVE_HEALTH)
10075 {
10076 AddHealth("","",-GetMaxHealth("","Health")/5);
10077 }
10078 else if (action_id == EActions.DESTROY_HEALTH)
10079 {
10080 SetHealth01("","",0);
10081 }
10082 else if (action_id == EActions.WATCH_ITEM)
10083 {
10085 mid.RegisterDebugItem(ItemBase.Cast(this), PlayerBase.Cast(player));
10086 #ifdef DEVELOPER
10087 SetDebugDeveloper_item(this);
10088 #endif
10089 }
10090
10091 else if (action_id == EActions.ADD_TEMPERATURE)
10092 {
10093 AddTemperature(20);
10094 //PrintVariables();
10095 }
10096
10097 else if (action_id == EActions.REMOVE_TEMPERATURE)
10098 {
10099 AddTemperature(-20);
10100 //PrintVariables();
10101 }
10102
10103 else if (action_id == EActions.FLIP_FROZEN)
10104 {
10105 SetFrozen(!GetIsFrozen());
10106 //PrintVariables();
10107 }
10108
10109 else if (action_id == EActions.ADD_WETNESS)
10110 {
10111 AddWet(GetWetMax()/5);
10112 //PrintVariables();
10113 }
10114
10115 else if (action_id == EActions.REMOVE_WETNESS)
10116 {
10117 AddWet(-GetWetMax()/5);
10118 //PrintVariables();
10119 }
10120
10121 else if (action_id == EActions.LIQUIDTYPE_UP)
10122 {
10123 int curr_type = GetLiquidType();
10124 SetLiquidType(curr_type * 2);
10125 //AddWet(1);
10126 //PrintVariables();
10127 }
10128
10129 else if (action_id == EActions.LIQUIDTYPE_DOWN)
10130 {
10131 int curr_type2 = GetLiquidType();
10132 SetLiquidType(curr_type2 / 2);
10133 }
10134
10135 else if (action_id == EActions.MAKE_SPECIAL)
10136 {
10137 auto debugParams = DebugSpawnParams.WithPlayer(player);
10138 OnDebugSpawnEx(debugParams);
10139 }
10140
10141 }
10142
10143
10144 return false;
10145 }
10146
10147 // -------------------------------------------------------------------------
10148
10149
10152 void OnActivatedByTripWire();
10153
10155 void OnActivatedByItem(notnull ItemBase item);
10156
10157 //----------------------------------------------------------------
10158 //returns true if item is able to explode when put in fire
10159 bool CanExplodeInFire()
10160 {
10161 return false;
10162 }
10163
10164 //----------------------------------------------------------------
10165 bool CanEat()
10166 {
10167 return true;
10168 }
10169
10170 //----------------------------------------------------------------
10171 override bool IsIgnoredByConstruction()
10172 {
10173 return true;
10174 }
10175
10176 //----------------------------------------------------------------
10177 //has FoodStages in config?
10178 bool HasFoodStage()
10179 {
10180 string config_path = string.Format("CfgVehicles %1 Food FoodStages", GetType());
10181 return g_Game.ConfigIsExisting(config_path);
10182 }
10183
10185 FoodStage GetFoodStage()
10186 {
10187 return null;
10188 }
10189
10190 bool CanBeCooked()
10191 {
10192 return false;
10193 }
10194
10195 bool CanBeCookedOnStick()
10196 {
10197 return false;
10198 }
10199
10201 void RefreshAudioVisualsOnClient( CookingMethodType cooking_method, bool is_done, bool is_empty, bool is_burned );
10203
10204 //----------------------------------------------------------------
10205 bool CanRepair(ItemBase item_repair_kit)
10206 {
10207 PluginRepairing module_repairing = PluginRepairing.Cast(GetPlugin(PluginRepairing));
10208 return module_repairing.CanRepair(this, item_repair_kit);
10209 }
10210
10211 //----------------------------------------------------------------
10212 bool Repair(PlayerBase player, ItemBase item_repair_kit, float specialty_weight)
10213 {
10214 PluginRepairing module_repairing = PluginRepairing.Cast(GetPlugin(PluginRepairing));
10215 return module_repairing.Repair(player, this, item_repair_kit, specialty_weight);
10216 }
10217
10218 //----------------------------------------------------------------
10219 int GetItemSize()
10220 {
10221 /*
10222 vector v_size = this.ConfigGetVector("itemSize");
10223 int v_size_x = v_size[0];
10224 int v_size_y = v_size[1];
10225 int size = v_size_x * v_size_y;
10226 return size;
10227 */
10228
10229 return 1;
10230 }
10231
10232 //----------------------------------------------------------------
10233 //Override for allowing seemingly unallowed moves when two clients send a conflicting message simultaneously
10234 bool CanBeMovedOverride()
10235 {
10236 return m_CanBeMovedOverride;
10237 }
10238
10239 //----------------------------------------------------------------
10240 //Override for allowing seemingly unallowed moves when two clients send a conflicting message simultaneously
10241 void SetCanBeMovedOverride(bool setting)
10242 {
10243 m_CanBeMovedOverride = setting;
10244 }
10245
10246 //----------------------------------------------------------------
10254 void MessageToOwnerStatus(string text)
10255 {
10256 PlayerBase player = PlayerBase.Cast(this.GetHierarchyRootPlayer());
10257
10258 if (player)
10259 {
10260 player.MessageStatus(text);
10261 }
10262 }
10263
10264 //----------------------------------------------------------------
10272 void MessageToOwnerAction(string text)
10273 {
10274 PlayerBase player = PlayerBase.Cast(this.GetHierarchyRootPlayer());
10275
10276 if (player)
10277 {
10278 player.MessageAction(text);
10279 }
10280 }
10281
10282 //----------------------------------------------------------------
10290 void MessageToOwnerFriendly(string text)
10291 {
10292 PlayerBase player = PlayerBase.Cast(this.GetHierarchyRootPlayer());
10293
10294 if (player)
10295 {
10296 player.MessageFriendly(text);
10297 }
10298 }
10299
10300 //----------------------------------------------------------------
10308 void MessageToOwnerImportant(string text)
10309 {
10310 PlayerBase player = PlayerBase.Cast(this.GetHierarchyRootPlayer());
10311
10312 if (player)
10313 {
10314 player.MessageImportant(text);
10315 }
10316 }
10317
10318 override bool IsItemBase()
10319 {
10320 return true;
10321 }
10322
10323 // Checks if item is of questioned kind
10324 override bool KindOf(string tag)
10325 {
10326 bool found = false;
10327 string item_name = this.GetType();
10328 ref TStringArray item_tag_array = new TStringArray;
10329 g_Game.ConfigGetTextArray("cfgVehicles " + item_name + " itemInfo", item_tag_array);
10330
10331 int array_size = item_tag_array.Count();
10332 for (int i = 0; i < array_size; i++)
10333 {
10334 if (item_tag_array.Get(i) == tag)
10335 {
10336 found = true;
10337 break;
10338 }
10339 }
10340 return found;
10341 }
10342
10343
10344 override void OnRPC(PlayerIdentity sender, int rpc_type,ParamsReadContext ctx)
10345 {
10346 //Debug.Log("OnRPC called");
10347 super.OnRPC(sender, rpc_type,ctx);
10348
10349 //Play soundset for attachment locking (ActionLockAttachment.c)
10350 switch (rpc_type)
10351 {
10352 #ifndef SERVER
10353 case ERPCs.RPC_SOUND_LOCK_ATTACH:
10354 Param2<bool, string> p = new Param2<bool, string>(false, "");
10355
10356 if (!ctx.Read(p))
10357 return;
10358
10359 bool play = p.param1;
10360 string soundSet = p.param2;
10361
10362 if (play)
10363 {
10364 if (m_LockingSound)
10365 {
10367 {
10368 m_LockingSound = SEffectManager.PlaySound(soundSet, GetPosition(), 0, 0, true);
10369 }
10370 }
10371 else
10372 {
10373 m_LockingSound = SEffectManager.PlaySound(soundSet, GetPosition(), 0, 0, true);
10374 }
10375 }
10376 else
10377 {
10378 SEffectManager.DestroyEffect(m_LockingSound);
10379 }
10380
10381 break;
10382 #endif
10383
10384 }
10385
10386 if (GetWrittenNoteData())
10387 {
10388 GetWrittenNoteData().OnRPC(sender, rpc_type,ctx);
10389 }
10390 }
10391
10392 //-----------------------------
10393 // VARIABLE MANIPULATION SYSTEM
10394 //-----------------------------
10395 int NameToID(string name)
10396 {
10397 PluginVariables plugin = PluginVariables.Cast(GetPlugin(PluginVariables));
10398 return plugin.GetID(name);
10399 }
10400
10401 string IDToName(int id)
10402 {
10403 PluginVariables plugin = PluginVariables.Cast(GetPlugin(PluginVariables));
10404 return plugin.GetName(id);
10405 }
10406
10408 void OnSyncVariables(ParamsReadContext ctx)//with ID optimization
10409 {
10410 //Debug.Log("OnSyncVariables called for item: "+ ToString(this.GetType()),"varSync");
10411 //read the flags
10412 int varFlags;
10413 if (!ctx.Read(varFlags))
10414 return;
10415
10416 if (varFlags & ItemVariableFlags.FLOAT)
10417 {
10418 ReadVarsFromCTX(ctx);
10419 }
10420 }
10421
10422 override void SerializeNumericalVars(array<float> floats_out)
10423 {
10424 //some variables handled on EntityAI level already!
10425 super.SerializeNumericalVars(floats_out);
10426
10427 // the order of serialization must be the same as the order of de-serialization
10428 //--------------------------------------------
10429 if (IsVariableSet(VARIABLE_QUANTITY))
10430 {
10431 floats_out.Insert(m_VarQuantity);
10432 }
10433 //--------------------------------------------
10434 if (IsVariableSet(VARIABLE_WET))
10435 {
10436 floats_out.Insert(m_VarWet);
10437 }
10438 //--------------------------------------------
10439 if (IsVariableSet(VARIABLE_LIQUIDTYPE))
10440 {
10441 floats_out.Insert(m_VarLiquidType);
10442 }
10443 //--------------------------------------------
10444 if (IsVariableSet(VARIABLE_COLOR))
10445 {
10446 floats_out.Insert(m_ColorComponentR);
10447 floats_out.Insert(m_ColorComponentG);
10448 floats_out.Insert(m_ColorComponentB);
10449 floats_out.Insert(m_ColorComponentA);
10450 }
10451 //--------------------------------------------
10452 if (IsVariableSet(VARIABLE_CLEANNESS))
10453 {
10454 floats_out.Insert(m_Cleanness);
10455 }
10456 }
10457
10458 override void DeSerializeNumericalVars(array<float> floats)
10459 {
10460 //some variables handled on EntityAI level already!
10461 super.DeSerializeNumericalVars(floats);
10462
10463 // the order of serialization must be the same as the order of de-serialization
10464 int index = 0;
10465 int mask = Math.Round(floats.Get(index));
10466
10467 index++;
10468 //--------------------------------------------
10469 if (mask & VARIABLE_QUANTITY)
10470 {
10471 if (m_IsStoreLoad)
10472 {
10473 SetStoreLoadedQuantity(floats.Get(index));
10474 }
10475 else
10476 {
10477 float quantity = floats.Get(index);
10478 SetQuantity(quantity, true, false, false, false);
10479 }
10480 index++;
10481 }
10482 //--------------------------------------------
10483 if (mask & VARIABLE_WET)
10484 {
10485 float wet = floats.Get(index);
10486 SetWet(wet);
10487 index++;
10488 }
10489 //--------------------------------------------
10490 if (mask & VARIABLE_LIQUIDTYPE)
10491 {
10492 int liquidtype = Math.Round(floats.Get(index));
10493 SetLiquidType(liquidtype);
10494 index++;
10495 }
10496 //--------------------------------------------
10497 if (mask & VARIABLE_COLOR)
10498 {
10499 m_ColorComponentR = Math.Round(floats.Get(index));
10500 index++;
10501 m_ColorComponentG = Math.Round(floats.Get(index));
10502 index++;
10503 m_ColorComponentB = Math.Round(floats.Get(index));
10504 index++;
10505 m_ColorComponentA = Math.Round(floats.Get(index));
10506 index++;
10507 }
10508 //--------------------------------------------
10509 if (mask & VARIABLE_CLEANNESS)
10510 {
10511 int cleanness = Math.Round(floats.Get(index));
10512 SetCleanness(cleanness);
10513 index++;
10514 }
10515 }
10516
10517 override void WriteVarsToCTX(ParamsWriteContext ctx)
10518 {
10519 super.WriteVarsToCTX(ctx);
10520
10521 //--------------------------------------------
10522 if (IsVariableSet(VARIABLE_QUANTITY))
10523 {
10524 ctx.Write(GetQuantity());
10525 }
10526 //--------------------------------------------
10527 if (IsVariableSet(VARIABLE_WET))
10528 {
10529 ctx.Write(GetWet());
10530 }
10531 //--------------------------------------------
10532 if (IsVariableSet(VARIABLE_LIQUIDTYPE))
10533 {
10534 ctx.Write(GetLiquidType());
10535 }
10536 //--------------------------------------------
10537 if (IsVariableSet(VARIABLE_COLOR))
10538 {
10539 int r,g,b,a;
10540 GetColor(r,g,b,a);
10541 ctx.Write(r);
10542 ctx.Write(g);
10543 ctx.Write(b);
10544 ctx.Write(a);
10545 }
10546 //--------------------------------------------
10547 if (IsVariableSet(VARIABLE_CLEANNESS))
10548 {
10549 ctx.Write(GetCleanness());
10550 }
10551 }
10552
10553 override bool ReadVarsFromCTX(ParamsReadContext ctx, int version = -1)//with ID optimization
10554 {
10555 if (!super.ReadVarsFromCTX(ctx,version))
10556 return false;
10557
10558 int intValue;
10559 float value;
10560
10561 if (version < 140)
10562 {
10563 if (!ctx.Read(intValue))
10564 return false;
10565
10566 m_VariablesMask = intValue;
10567 }
10568
10569 if (m_VariablesMask & VARIABLE_QUANTITY)
10570 {
10571 if (!ctx.Read(value))
10572 return false;
10573
10574 if (IsStoreLoad())
10575 {
10577 }
10578 else
10579 {
10580 SetQuantity(value, true, false, false, false);
10581 }
10582 }
10583 //--------------------------------------------
10584 if (version < 140)
10585 {
10586 if (m_VariablesMask & VARIABLE_TEMPERATURE)
10587 {
10588 if (!ctx.Read(value))
10589 return false;
10590 SetTemperatureDirect(value);
10591 }
10592 }
10593 //--------------------------------------------
10594 if (m_VariablesMask & VARIABLE_WET)
10595 {
10596 if (!ctx.Read(value))
10597 return false;
10598 SetWet(value);
10599 }
10600 //--------------------------------------------
10601 if (m_VariablesMask & VARIABLE_LIQUIDTYPE)
10602 {
10603 if (!ctx.Read(intValue))
10604 return false;
10605 SetLiquidType(intValue);
10606 }
10607 //--------------------------------------------
10608 if (m_VariablesMask & VARIABLE_COLOR)
10609 {
10610 int r,g,b,a;
10611 if (!ctx.Read(r))
10612 return false;
10613 if (!ctx.Read(g))
10614 return false;
10615 if (!ctx.Read(b))
10616 return false;
10617 if (!ctx.Read(a))
10618 return false;
10619
10620 SetColor(r,g,b,a);
10621 }
10622 //--------------------------------------------
10623 if (m_VariablesMask & VARIABLE_CLEANNESS)
10624 {
10625 if (!ctx.Read(intValue))
10626 return false;
10627 SetCleanness(intValue);
10628 }
10629 //--------------------------------------------
10630 if (version >= 138 && version < 140)
10631 {
10632 if (m_VariablesMask & VARIABLE_TEMPERATURE)
10633 {
10634 if (!ctx.Read(intValue))
10635 return false;
10636 SetFrozen(intValue);
10637 }
10638 }
10639
10640 return true;
10641 }
10642
10643 //----------------------------------------------------------------
10644 override bool OnStoreLoad(ParamsReadContext ctx, int version)
10645 {
10646 m_IsStoreLoad = true;
10648 {
10649 m_FixDamageSystemInit = true;
10650 }
10651
10652 if (!super.OnStoreLoad(ctx, version))
10653 {
10654 m_IsStoreLoad = false;
10655 return false;
10656 }
10657
10658 if (version >= 114)
10659 {
10660 bool hasQuickBarIndexSaved;
10661
10662 if (!ctx.Read(hasQuickBarIndexSaved))
10663 {
10664 m_IsStoreLoad = false;
10665 return false;
10666 }
10667
10668 if (hasQuickBarIndexSaved)
10669 {
10670 int itmQBIndex;
10671
10672 //Load quickbar item bind
10673 if (!ctx.Read(itmQBIndex))
10674 {
10675 m_IsStoreLoad = false;
10676 return false;
10677 }
10678
10679 PlayerBase parentPlayer = PlayerBase.Cast(GetHierarchyRootPlayer());
10680 if (itmQBIndex != -1 && parentPlayer)
10681 parentPlayer.SetLoadedQuickBarItemBind(this, itmQBIndex);
10682 }
10683 }
10684 else
10685 {
10686 // Backup of how it used to be
10687 PlayerBase player;
10688 int itemQBIndex;
10689 if (version == int.MAX)
10690 {
10691 if (!ctx.Read(itemQBIndex))
10692 {
10693 m_IsStoreLoad = false;
10694 return false;
10695 }
10696 }
10697 else if (Class.CastTo(player, GetHierarchyRootPlayer()))
10698 {
10699 //Load quickbar item bind
10700 if (!ctx.Read(itemQBIndex))
10701 {
10702 m_IsStoreLoad = false;
10703 return false;
10704 }
10705 if (itemQBIndex != -1 && player)
10706 player.SetLoadedQuickBarItemBind(this,itemQBIndex);
10707 }
10708 }
10709
10710 if (version < 140)
10711 {
10712 // variable management system
10713 if (!LoadVariables(ctx, version))
10714 {
10715 m_IsStoreLoad = false;
10716 return false;
10717 }
10718 }
10719
10720 //agent trasmission system
10721 if (!LoadAgents(ctx, version))
10722 {
10723 m_IsStoreLoad = false;
10724 return false;
10725 }
10726 if (version >= 132)
10727 {
10728 RemotelyActivatedItemBehaviour raib = GetRemotelyActivatedItemBehaviour();
10729 if (raib)
10730 {
10731 if (!raib.OnStoreLoad(ctx,version))
10732 {
10733 m_IsStoreLoad = false;
10734 return false;
10735 }
10736 }
10737 }
10738
10739 m_IsStoreLoad = false;
10740 return true;
10741 }
10742
10743 //----------------------------------------------------------------
10744
10745 override void OnStoreSave(ParamsWriteContext ctx)
10746 {
10747 super.OnStoreSave(ctx);
10748
10749 PlayerBase player;
10750 if (PlayerBase.CastTo(player,GetHierarchyRootPlayer()))
10751 {
10752 ctx.Write(true); // Keep track of if we should actually read this in or not
10753 //Save quickbar item bind
10754 int itemQBIndex = -1;
10755 itemQBIndex = player.FindQuickBarEntityIndex(this);
10756 ctx.Write(itemQBIndex);
10757 }
10758 else
10759 {
10760 ctx.Write(false); // Keep track of if we should actually read this in or not
10761 }
10762
10763 SaveAgents(ctx);//agent trasmission system
10764
10765 RemotelyActivatedItemBehaviour raib = GetRemotelyActivatedItemBehaviour();
10766 if (raib)
10767 {
10768 raib.OnStoreSave(ctx);
10769 }
10770 }
10771 //----------------------------------------------------------------
10772
10773 override void AfterStoreLoad()
10774 {
10775 super.AfterStoreLoad();
10776
10778 {
10780 }
10781
10782 if (GetStoreLoadedQuantity() != float.LOWEST)
10783 {
10785 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
10786 }
10787 }
10788
10789 override void EEOnAfterLoad()
10790 {
10791 super.EEOnAfterLoad();
10792
10794 {
10795 m_FixDamageSystemInit = false;
10796 }
10797
10800 }
10801
10802 bool CanBeDisinfected()
10803 {
10804 return false;
10805 }
10806
10807
10808 //----------------------------------------------------------------
10809 override void OnVariablesSynchronized()
10810 {
10811 if (m_Initialized)
10812 {
10813 #ifdef PLATFORM_CONSOLE
10814 //bruteforce it is
10815 if (IsSplitable())
10816 {
10817 UIScriptedMenu menu = g_Game.GetUIManager().FindMenu(MENU_INVENTORY);
10818 if (menu)
10819 {
10820 menu.Refresh();
10821 }
10822 }
10823 #endif
10824 }
10825
10827 {
10828 PlayImpactSound(m_ConfigWeight, m_ImpactSpeed, m_ImpactSoundSurfaceHash);
10829 m_WantPlayImpactSound = false;
10830 }
10831
10833 {
10834 SetWeightDirty();
10836 }
10837 if (m_VarWet != m_VarWetPrev)
10838 {
10841 }
10842
10843 if (m_SoundSyncPlay != 0)
10844 {
10847
10848 m_SoundSyncPlay = 0;
10849 m_SoundSyncSlotID = -1;
10850 }
10851 if (m_SoundSyncStop != 0)
10852 {
10854 m_ItemSoundHandler.StopItemSoundClient(m_SoundSyncStop);
10855 m_SoundSyncStop = 0;
10856 }
10857
10858 super.OnVariablesSynchronized();
10859 }
10860
10861 //------------------------- Quantity
10862 //----------------------------------------------------------------
10864 override bool SetQuantity(float value, bool destroy_config = true, bool destroy_forced = false, bool allow_client = false, bool clamp_to_stack_max = true)
10865 {
10866 if (!IsServerCheck(allow_client))
10867 return false;
10868
10869 if (!HasQuantity())
10870 return false;
10871
10872 float min = GetQuantityMin();
10873 float max = GetQuantityMax();
10874
10875 if (value <= (min + 0.001))
10876 value = min;
10877
10878 if (value == min)
10879 {
10880 if (destroy_config)
10881 {
10882 bool dstr = ConfigGetBool("varQuantityDestroyOnMin");
10883 if (dstr)
10884 {
10885 m_VarQuantity = Math.Clamp(value, min, max);
10886 this.Delete();
10887 return true;
10888 }
10889 }
10890 else if (destroy_forced)
10891 {
10892 m_VarQuantity = Math.Clamp(value, min, max);
10893 this.Delete();
10894 return true;
10895 }
10896 // we get here if destroy_config IS true AND dstr(config destroy param) IS false;
10897 RemoveAllAgents();//we remove all agents when we got to the min value, but the item is not getting deleted
10898 }
10899
10900 float delta = m_VarQuantity;
10901 m_VarQuantity = Math.Clamp(value, min, max);
10902
10903 if (g_Game.IsServer() || !g_Game.IsMultiplayer()) // single player or server side multiplayer
10904 {
10905 EntityAI parent = GetHierarchyRoot();
10906 InventoryLocation iLoc = new InventoryLocation();
10907 GetInventory().GetCurrentInventoryLocation(iLoc);
10908 if (iLoc && iLoc.IsValid() && delta != m_VarQuantity)
10909 {
10910 int iLocSlot = iLoc.GetSlot();
10911 if (delta < m_VarQuantity && iLoc.GetType() != InventoryLocationType.GROUND)
10912 {
10913 StartItemSoundServer(SoundConstants.ITEM_ATTACH, iLocSlot);
10914 }
10915 if (delta > m_VarQuantity && m_VarQuantity != 0 && !IsPrepareToDelete() && iLoc.GetType() == InventoryLocationType.ATTACHMENT)
10916 {
10917 StartItemSoundServer(SoundConstants.ITEM_DETACH, iLocSlot);
10918 }
10919 }
10920 }
10921
10922 if (GetStoreLoadedQuantity() == float.LOWEST)//any other value means we are setting quantity from storage
10923 {
10924 delta = m_VarQuantity - delta;
10925
10926 if (delta)
10927 OnQuantityChanged(delta);
10928 }
10929
10930 SetVariableMask(VARIABLE_QUANTITY);
10931
10932 return false;
10933 }
10934
10935 //----------------------------------------------------------------
10937 bool AddQuantity(float value, bool destroy_config = true, bool destroy_forced = false)
10938 {
10939 return SetQuantity(GetQuantity() + value, destroy_config, destroy_forced);
10940 }
10941 //----------------------------------------------------------------
10942 void SetQuantityMax()
10943 {
10944 float max = GetQuantityMax();
10945 SetQuantity(max);
10946 }
10947
10948 override void SetQuantityToMinimum()
10949 {
10950 float min = GetQuantityMin();
10951 SetQuantity(min);
10952 }
10953 //----------------------------------------------------------------
10955 override void SetQuantityNormalized(float value, bool destroy_config = true, bool destroy_forced = false)
10956 {
10957 float value_clamped = Math.Clamp(value, 0, 1);//just to make sure
10958 int result = Math.Round(Math.Lerp(GetQuantityMin(), GetQuantityMax(), value_clamped));
10959 SetQuantity(result, destroy_config, destroy_forced);
10960 }
10961
10962 //----------------------------------------------------------------
10964 override float GetQuantityNormalized()
10965 {
10966 return Math.InverseLerp(GetQuantityMin(), GetQuantityMax(),m_VarQuantity);
10967 }
10968
10970 {
10971 return GetQuantityNormalized();
10972 }
10973
10974 /*void SetAmmoNormalized(float value)
10975 {
10976 float value_clamped = Math.Clamp(value, 0, 1);
10977 Magazine this_mag = Magazine.Cast(this);
10978 int max_rounds = this_mag.GetAmmoMax();
10979 int result = value * max_rounds;//can the rounded if higher precision is required
10980 this_mag.SetAmmoCount(result);
10981 }*/
10982 //----------------------------------------------------------------
10983 override int GetQuantityMax()
10984 {
10985 int slot = -1;
10986 GameInventory inventory = GetInventory();
10987 if (inventory)
10988 {
10989 InventoryLocation il = new InventoryLocation;
10990 inventory.GetCurrentInventoryLocation(il);
10991 slot = il.GetSlot();
10992 }
10993
10994 return GetTargetQuantityMax(slot);
10995 }
10996
10997 override int GetTargetQuantityMax(int attSlotID = -1)
10998 {
10999 float quantity_max = 0;
11000
11001 if (IsSplitable()) //only stackable/splitable items can check for stack size
11002 {
11003 if (attSlotID != -1)
11004 quantity_max = InventorySlots.GetStackMaxForSlotId(attSlotID);
11005
11006 if (quantity_max <= 0)
11007 quantity_max = m_VarStackMax;
11008 }
11009
11010 if (quantity_max <= 0)
11011 quantity_max = m_VarQuantityMax;
11012
11013 return quantity_max;
11014 }
11015 //----------------------------------------------------------------
11016 override int GetQuantityMin()
11017 {
11018 return m_VarQuantityMin;
11019 }
11020 //----------------------------------------------------------------
11021 int GetQuantityInit()
11022 {
11023 return m_VarQuantityInit;
11024 }
11025
11026 //----------------------------------------------------------------
11027 override bool HasQuantity()
11028 {
11029 return !(GetQuantityMax() - GetQuantityMin() == 0);
11030 }
11031
11032 override float GetQuantity()
11033 {
11034 return m_VarQuantity;
11035 }
11036
11037 bool IsFullQuantity()
11038 {
11039 return GetQuantity() >= GetQuantityMax();
11040 }
11041
11042 //Calculates weight of single item without attachments and cargo
11043 override float GetSingleInventoryItemWeightEx()
11044 {
11045 //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
11046 float weightEx = GetWeightEx();//overall weight of the item
11047 float special = GetInventoryAndCargoWeight();//cargo and attachment weight
11048 return weightEx - special;
11049 }
11050
11051 // Obsolete, use GetSingleInventoryItemWeightEx() instead
11053 {
11055 }
11056
11057 override protected float GetWeightSpecialized(bool forceRecalc = false)
11058 {
11059 if (IsSplitable()) //quantity determines size of the stack
11060 {
11061 #ifdef DEVELOPER
11062 if (WeightDebug.m_VerbosityFlags & WeightDebugType.RECALC_FORCED)
11063 {
11064 WeightDebugData data1 = WeightDebug.GetWeightDebug(this);
11065 data1.SetCalcDetails("TIB1: " + GetConfigWeightModifiedDebugText() +" * " + GetQuantity()+"(quantity)");
11066 }
11067 #endif
11068
11069 return GetQuantity() * GetConfigWeightModified();
11070 }
11071 else if (HasEnergyManager())// items with energy manager
11072 {
11073 #ifdef DEVELOPER
11074 if (WeightDebug.m_VerbosityFlags & WeightDebugType.RECALC_FORCED)
11075 {
11076 WeightDebugData data2 = WeightDebug.GetWeightDebug(this);
11077 data2.SetCalcDetails("TIB2: "+super.GetWeightSpecialized(forceRecalc)+"(contents weight) + " + GetConfigWeightModifiedDebugText() +" + " + GetCompEM().GetEnergy()+"(energy) * " + ConfigGetFloat("weightPerQuantityUnit") +"(weightPerQuantityUnit)");
11078 }
11079 #endif
11080 return super.GetWeightSpecialized(forceRecalc) + (GetCompEM().GetEnergy() * ConfigGetFloat("weightPerQuantityUnit")) + GetConfigWeightModified();
11081 }
11082 else//everything else
11083 {
11084 #ifdef DEVELOPER
11085 if (WeightDebug.m_VerbosityFlags & WeightDebugType.RECALC_FORCED)
11086 {
11087 WeightDebugData data3 = WeightDebug.GetWeightDebug(this);
11088 data3.SetCalcDetails("TIB3: "+super.GetWeightSpecialized(forceRecalc)+"(contents weight) + " + GetConfigWeightModifiedDebugText() +" + " + GetQuantity()+"(quantity) * " + ConfigGetFloat("weightPerQuantityUnit") +"(weightPerQuantityUnit))");
11089 }
11090 #endif
11091 return super.GetWeightSpecialized(forceRecalc) + (GetQuantity() * ConfigGetFloat("weightPerQuantityUnit")) + GetConfigWeightModified();
11092 }
11093 }
11094
11096 int GetNumberOfItems()
11097 {
11098 int item_count = 0;
11099 ItemBase item;
11100
11101 GameInventory inventory = GetInventory();
11102 CargoBase cargo = inventory.GetCargo();
11103 if (cargo != NULL)
11104 {
11105 item_count = cargo.GetItemCount();
11106 }
11107
11108 int nAttachments = inventory.AttachmentCount();
11109 for (int i = 0; i < nAttachments; ++i)
11110 {
11111 Class.CastTo(item, inventory.GetAttachmentFromIndex(i));
11112 if (item)
11113 item_count += item.GetNumberOfItems();
11114 }
11115 return item_count;
11116 }
11117
11119 float GetUnitWeight(bool include_wetness = true)
11120 {
11121 float weight = 0;
11122 float wetness = 1;
11123 if (include_wetness)
11124 wetness += GetWet();
11125 if (IsSplitable()) //quantity determines size of the stack
11126 {
11127 weight = wetness * m_ConfigWeight;
11128 }
11129 else if (IsLiquidContainer()) //is a liquid container, default liquid weight is set to 1. May revisit later?
11130 {
11131 weight = 1;
11132 }
11133 return weight;
11134 }
11135
11136 //-----------------------------------------------------------------
11137
11138 override void ClearInventory()
11139 {
11140 GameInventory inventory = GetInventory();
11141 if ((g_Game.IsServer() || !g_Game.IsMultiplayer()) && inventory)
11142 {
11143 array<EntityAI> items = new array<EntityAI>;
11144 inventory.EnumerateInventory(InventoryTraversalType.INORDER, items);
11145 for (int i = 0; i < items.Count(); ++i)
11146 {
11147 ItemBase item = ItemBase.Cast(items.Get(i));
11148 if (item)
11149 {
11150 g_Game.ObjectDelete(item);
11151 }
11152 }
11153 }
11154 }
11155
11156 //------------------------- Energy
11157
11158 //----------------------------------------------------------------
11159 float GetEnergy()
11160 {
11161 float energy = 0;
11162 if (HasEnergyManager())
11163 {
11164 energy = GetCompEM().GetEnergy();
11165 }
11166 return energy;
11167 }
11168
11169
11170 override void OnEnergyConsumed()
11171 {
11172 super.OnEnergyConsumed();
11173
11175 }
11176
11177 override void OnEnergyAdded()
11178 {
11179 super.OnEnergyAdded();
11180
11182 }
11183
11184 // Converts energy (from Energy Manager) to quantity, if enabled.
11186 {
11187 if (g_Game.IsServer() && HasEnergyManager() && GetCompEM().HasConversionOfEnergyToQuantity())
11188 {
11189 if (HasQuantity())
11190 {
11191 float energy_0to1 = GetCompEM().GetEnergy0To1();
11192 SetQuantityNormalized(energy_0to1);
11193 }
11194 }
11195 }
11196
11197 //----------------------------------------------------------------
11198 float GetHeatIsolationInit()
11199 {
11200 return ConfigGetFloat("heatIsolation");
11201 }
11202
11203 float GetHeatIsolation()
11204 {
11205 return m_HeatIsolation;
11206 }
11207
11208 float GetDryingIncrement(string pIncrementName)
11209 {
11210 string paramPath = string.Format("CfgVehicles %1 EnvironmentWetnessIncrements Drying %2", GetType(), pIncrementName);
11211 if (g_Game.ConfigIsExisting(paramPath))
11212 return g_Game.ConfigGetFloat(paramPath);
11213
11214 return 0.0;
11215 }
11216
11217 float GetSoakingIncrement(string pIncrementName)
11218 {
11219 string paramPath = string.Format("CfgVehicles %1 EnvironmentWetnessIncrements Soaking %2", GetType(), pIncrementName);
11220 if (g_Game.ConfigIsExisting(paramPath))
11221 return g_Game.ConfigGetFloat(paramPath);
11222
11223 return 0.0;
11224 }
11225 //----------------------------------------------------------------
11226 override void SetWet(float value, bool allow_client = false)
11227 {
11228 if (!IsServerCheck(allow_client))
11229 return;
11230
11231 float min = GetWetMin();
11232 float max = GetWetMax();
11233
11234 float previousValue = m_VarWet;
11235
11236 m_VarWet = Math.Clamp(value, min, max);
11237
11238 if (previousValue != m_VarWet)
11239 {
11240 SetVariableMask(VARIABLE_WET);
11241 OnWetChanged(m_VarWet, previousValue);
11242 }
11243 }
11244 //----------------------------------------------------------------
11245 override void AddWet(float value)
11246 {
11247 SetWet(GetWet() + value);
11248 }
11249 //----------------------------------------------------------------
11250 override void SetWetMax()
11251 {
11253 }
11254 //----------------------------------------------------------------
11255 override float GetWet()
11256 {
11257 return m_VarWet;
11258 }
11259 //----------------------------------------------------------------
11260 override float GetWetMax()
11261 {
11262 return m_VarWetMax;
11263 }
11264 //----------------------------------------------------------------
11265 override float GetWetMin()
11266 {
11267 return m_VarWetMin;
11268 }
11269 //----------------------------------------------------------------
11270 override float GetWetInit()
11271 {
11272 return m_VarWetInit;
11273 }
11274 //----------------------------------------------------------------
11275 override void OnWetChanged(float newVal, float oldVal)
11276 {
11277 EWetnessLevel newLevel = GetWetLevelInternal(newVal);
11278 EWetnessLevel oldLevel = GetWetLevelInternal(oldVal);
11279 if (newLevel != oldLevel)
11280 {
11281 OnWetLevelChanged(newLevel,oldLevel);
11282 }
11283 }
11284
11285 override void OnWetLevelChanged(EWetnessLevel newLevel, EWetnessLevel oldLevel)
11286 {
11287 SetWeightDirty();
11288 }
11289
11290 override EWetnessLevel GetWetLevel()
11291 {
11292 return GetWetLevelInternal(m_VarWet);
11293 }
11294
11295 //----------------------------------------------------------------
11296
11297 override void SetStoreLoad(bool value)
11298 {
11299 m_IsStoreLoad = value;
11300 }
11301
11302 override bool IsStoreLoad()
11303 {
11304 return m_IsStoreLoad;
11305 }
11306
11307 override void SetStoreLoadedQuantity(float value)
11308 {
11309 m_StoreLoadedQuantity = value;
11310 }
11311
11312 override float GetStoreLoadedQuantity()
11313 {
11314 return m_StoreLoadedQuantity;
11315 }
11316
11317 //----------------------------------------------------------------
11318
11319 float GetItemModelLength()
11320 {
11321 if (ConfigIsExisting("itemModelLength"))
11322 {
11323 return ConfigGetFloat("itemModelLength");
11324 }
11325 return 0;
11326 }
11327
11328 float GetItemAttachOffset()
11329 {
11330 if (ConfigIsExisting("itemAttachOffset"))
11331 {
11332 return ConfigGetFloat("itemAttachOffset");
11333 }
11334 return 0;
11335 }
11336
11337 override void SetCleanness(int value, bool allow_client = false)
11338 {
11339 if (!IsServerCheck(allow_client))
11340 return;
11341
11342 int previousValue = m_Cleanness;
11343
11344 m_Cleanness = Math.Clamp(value, m_CleannessMin, m_CleannessMax);
11345
11346 if (previousValue != m_Cleanness)
11347 SetVariableMask(VARIABLE_CLEANNESS);
11348 }
11349
11350 override int GetCleanness()
11351 {
11352 return m_Cleanness;
11353 }
11354
11356 {
11357 return true;
11358 }
11359
11360 //----------------------------------------------------------------
11361 // ATTACHMENT LOCKING
11362 // Getters relevant to generic ActionLockAttachment
11363 int GetLockType()
11364 {
11365 return m_LockType;
11366 }
11367
11368 string GetLockSoundSet()
11369 {
11370 return m_LockSoundSet;
11371 }
11372
11373 //----------------------------------------------------------------
11374 //------------------------- Color
11375 // sets items color variable given color components
11376 override void SetColor(int r, int g, int b, int a)
11377 {
11382 SetVariableMask(VARIABLE_COLOR);
11383 }
11385 override void GetColor(out int r,out int g,out int b,out int a)
11386 {
11391 }
11392
11393 bool IsColorSet()
11394 {
11395 return IsVariableSet(VARIABLE_COLOR);
11396 }
11397
11399 string GetColorString()
11400 {
11401 int r,g,b,a;
11402 GetColor(r,g,b,a);
11403 r = r/255;
11404 g = g/255;
11405 b = b/255;
11406 a = a/255;
11407 return MiscGameplayFunctions.GetColorString(r, g, b, a);
11408 }
11409 //----------------------------------------------------------------
11410 //------------------------- LiquidType
11411
11412 override void SetLiquidType(int value, bool allow_client = false)
11413 {
11414 if (!IsServerCheck(allow_client))
11415 return;
11416
11417 int old = m_VarLiquidType;
11418 m_VarLiquidType = value;
11419 OnLiquidTypeChanged(old,value);
11420 SetVariableMask(VARIABLE_LIQUIDTYPE);
11421 }
11422
11423 int GetLiquidTypeInit()
11424 {
11425 return ConfigGetInt("varLiquidTypeInit");
11426 }
11427
11428 override int GetLiquidType()
11429 {
11430 return m_VarLiquidType;
11431 }
11432
11433 protected void OnLiquidTypeChanged(int oldType, int newType)
11434 {
11435 if (newType == LIQUID_NONE && GetIsFrozen())
11436 SetFrozen(false);
11437 }
11438
11440 void UpdateQuickbarShortcutVisibility(PlayerBase player)
11441 {
11442 player.SetEnableQuickBarEntityShortcut(this,!GetHierarchyParent() || GetHierarchyParent().GetInventory().AreChildrenAccessible());
11443 }
11444
11445 // -------------------------------------------------------------------------
11447 void OnInventoryEnter(Man player)
11448 {
11449 PlayerBase nplayer;
11450 if (PlayerBase.CastTo(nplayer, player))
11451 {
11452 m_CanPlayImpactSound = true;
11453 nplayer.SetEnableQuickBarEntityShortcut(this,!GetHierarchyParent() || GetHierarchyParent().GetInventory().AreChildrenAccessible());
11454 }
11455 }
11456
11457 // -------------------------------------------------------------------------
11459 void OnInventoryExit(Man player)
11460 {
11461 PlayerBase nplayer;
11462 if (PlayerBase.CastTo(nplayer,player))
11463 {
11464 nplayer.SetEnableQuickBarEntityShortcut(this, false);
11465 }
11466
11467 player.GetHumanInventory().ClearUserReservedLocationForContainer(this);
11468
11469 if (HasEnergyManager())
11470 {
11471 GetCompEM().UpdatePlugState(); // Unplug the el. device if it's necesarry.
11472 }
11473 }
11474
11475 // ADVANCED PLACEMENT EVENTS
11476 override void OnPlacementStarted(Man player)
11477 {
11478 super.OnPlacementStarted(player);
11479
11480 SetTakeable(false);
11481 }
11482
11483 override void OnPlacementComplete(Man player, vector position = "0 0 0", vector orientation = "0 0 0")
11484 {
11485 if (m_AdminLog)
11486 {
11487 m_AdminLog.OnPlacementComplete(player, this);
11488 }
11489
11490 super.OnPlacementComplete(player, position, orientation);
11491 }
11492
11493 //-----------------------------
11494 // AGENT SYSTEM
11495 //-----------------------------
11496 //--------------------------------------------------------------------------
11497 bool ContainsAgent(int agent_id)
11498 {
11499 if (agent_id & m_AttachedAgents)
11500 {
11501 return true;
11502 }
11503 else
11504 {
11505 return false;
11506 }
11507 }
11508
11509 //--------------------------------------------------------------------------
11510 override void RemoveAgent(int agent_id)
11511 {
11512 if (ContainsAgent(agent_id))
11513 {
11514 m_AttachedAgents = ~agent_id & m_AttachedAgents;
11515 }
11516 }
11517
11518 //--------------------------------------------------------------------------
11519 override void RemoveAllAgents()
11520 {
11521 m_AttachedAgents = 0;
11522 }
11523 //--------------------------------------------------------------------------
11524 override void RemoveAllAgentsExcept(int agent_to_keep)
11525 {
11526 m_AttachedAgents = m_AttachedAgents & agent_to_keep;
11527 }
11528 // -------------------------------------------------------------------------
11529 override void InsertAgent(int agent, float count = 1)
11530 {
11531 if (count < 1)
11532 return;
11533 //Debug.Log("Inserting Agent on item: " + agent.ToString() +" count: " + count.ToString());
11535 }
11536
11538 void TransferAgents(int agents)
11539 {
11541 }
11542
11543 // -------------------------------------------------------------------------
11544 override int GetAgents()
11545 {
11546 return m_AttachedAgents;
11547 }
11548 //----------------------------------------------------------------------
11549
11550 /*int GetContaminationType()
11551 {
11552 int contamination_type;
11553
11554 const int CONTAMINATED_MASK = eAgents.CHOLERA | eAgents.INFLUENZA | eAgents.SALMONELLA | eAgents.BRAIN;
11555 const int POISONED_MASK = eAgents.FOOD_POISON | eAgents.CHEMICAL_POISON;
11556 const int NERVE_GAS_MASK = eAgents.CHEMICAL_POISON;
11557 const int DIRTY_MASK = eAgents.WOUND_AGENT;
11558
11559 Edible_Base edible = Edible_Base.Cast(this);
11560 int agents = GetAgents();
11561 if (edible)
11562 {
11563 NutritionalProfile profile = Edible_Base.GetNutritionalProfile(edible);
11564 if (profile)
11565 {
11566 agents = agents | profile.GetAgents();//merge item's agents with nutritional agents
11567 }
11568 }
11569 if (agents & CONTAMINATED_MASK)
11570 {
11571 contamination_type = contamination_type | EContaminationTypes.ITEM_BADGE_CONTAMINATED;
11572 }
11573 if (agents & POISONED_MASK)
11574 {
11575 contamination_type = contamination_type | EContaminationTypes.ITEM_BADGE_POISONED;
11576 }
11577 if (agents & NERVE_GAS_MASK)
11578 {
11579 contamination_type = contamination_type | EContaminationTypes.ITEM_BADGE_NERVE_GAS;
11580 }
11581 if (agents & DIRTY_MASK)
11582 {
11583 contamination_type = contamination_type | EContaminationTypes.ITEM_BADGE_DIRTY;
11584 }
11585
11586 return agents;
11587 }*/
11588
11589 // -------------------------------------------------------------------------
11590 bool LoadAgents(ParamsReadContext ctx, int version)
11591 {
11592 if (!ctx.Read(m_AttachedAgents))
11593 return false;
11594 return true;
11595 }
11596 // -------------------------------------------------------------------------
11598 {
11599
11601 }
11602 // -------------------------------------------------------------------------
11603
11605 override void CheckForRoofLimited(float timeTresholdMS = 3000)
11606 {
11607 super.CheckForRoofLimited(timeTresholdMS);
11608
11609 float time = g_Game.GetTime();
11610 if ((time - m_PreviousRoofTestTime) >= timeTresholdMS)
11611 {
11612 m_PreviousRoofTestTime = time;
11613 SetRoofAbove(MiscGameplayFunctions.IsUnderRoof(this));
11614 }
11615 }
11616
11617 // returns item's protection level against enviromental hazard, for masks with filters, returns the filters protection for valid filter, otherwise 0
11618 float GetProtectionLevel(int type, bool consider_filter = false, int system = 0)
11619 {
11620 if (IsDamageDestroyed() || (HasQuantity() && GetQuantity() <= 0))
11621 {
11622 return 0;
11623 }
11624
11625 if (GetInventory().GetAttachmentSlotsCount() != 0)//is it an item with attachable filter ?
11626 {
11627 ItemBase filter = ItemBase.Cast(FindAttachmentBySlotName("GasMaskFilter"));
11628 if (filter)
11629 return filter.GetProtectionLevel(type, false, system);//it's a valid filter, return the protection
11630 else
11631 return 0;//otherwise return 0 when no filter attached
11632 }
11633
11634 string subclassPath, entryName;
11635
11636 switch (type)
11637 {
11638 case DEF_BIOLOGICAL:
11639 entryName = "biological";
11640 break;
11641 case DEF_CHEMICAL:
11642 entryName = "chemical";
11643 break;
11644 default:
11645 entryName = "biological";
11646 break;
11647 }
11648
11649 subclassPath = "CfgVehicles " + this.GetType() + " Protection ";
11650
11651 return g_Game.ConfigGetFloat(subclassPath + entryName);
11652 }
11653
11654
11655
11657 override void EEOnCECreate()
11658 {
11659 if (!IsMagazine())
11661
11663 }
11664
11665
11666 //-------------------------
11667 // OPEN/CLOSE USER ACTIONS
11668 //-------------------------
11670 void Open();
11671 void Close();
11672 bool IsOpen()
11673 {
11674 return true;
11675 }
11676
11677 override bool CanDisplayCargo()
11678 {
11679 return IsOpen();
11680 }
11681
11682
11683 // ------------------------------------------------------------
11684 // CONDITIONS
11685 // ------------------------------------------------------------
11686 override bool CanPutInCargo(EntityAI parent)
11687 {
11688 if (parent)
11689 {
11690 if (parent.IsInherited(DayZInfected))
11691 return true;
11692
11693 if (!parent.IsRuined())
11694 return true;
11695 }
11696
11697 return true;
11698 }
11699
11700 override bool CanPutAsAttachment(EntityAI parent)
11701 {
11702 if (!super.CanPutAsAttachment(parent))
11703 {
11704 return false;
11705 }
11706
11707 if (!IsRuined() && !parent.IsRuined())
11708 {
11709 return true;
11710 }
11711
11712 return false;
11713 }
11714
11715 override bool CanReceiveItemIntoCargo(EntityAI item)
11716 {
11717 //removed 15.06. coz of loading from storage -> after load items in cargo was lost -> waiting for proper solution
11718 //if (GetHealthLevel() == GameConstants.STATE_RUINED)
11719 // return false;
11720
11721 return super.CanReceiveItemIntoCargo(item);
11722 }
11723
11724 override bool CanReceiveAttachment(EntityAI attachment, int slotId)
11725 {
11726 //removed 15.06. coz of loading from storage -> after load items in cargo was lost -> waiting for proper solution
11727 //if (GetHealthLevel() == GameConstants.STATE_RUINED)
11728 // return false;
11729
11730 GameInventory attachmentInv = attachment.GetInventory();
11731 if (attachmentInv && attachmentInv.GetCargo() && attachmentInv.GetCargo().GetItemCount() > 0)
11732 {
11733 if (GetHierarchyParent() && !GetHierarchyParent().IsInherited(PlayerBase))
11734 return false;
11735 }
11736
11737 InventoryLocation loc = new InventoryLocation();
11738 attachment.GetInventory().GetCurrentInventoryLocation(loc);
11739 if (loc && loc.IsValid() && !GetInventory().AreChildrenAccessible())
11740 return false;
11741
11742 return super.CanReceiveAttachment(attachment, slotId);
11743 }
11744
11745 override bool CanReleaseAttachment(EntityAI attachment)
11746 {
11747 if (!super.CanReleaseAttachment(attachment))
11748 return false;
11749
11750 return GetInventory().AreChildrenAccessible();
11751 }
11752
11753 /*override bool CanLoadAttachment(EntityAI attachment)
11754 {
11755 //removed 15.06. coz of loading from storage -> after load items in cargo was lost -> waiting for proper solution
11756 //if (GetHealthLevel() == GameConstants.STATE_RUINED)
11757 // return false;
11758
11759 GameInventory attachmentInv = attachment.GetInventory();
11760 if (attachmentInv && attachmentInv.GetCargo() && attachmentInv.GetCargo().GetItemCount() > 0)
11761 {
11762 bool boo = (GetHierarchyParent() && !GetHierarchyParent().IsInherited(PlayerBase));
11763 ErrorEx("CanLoadAttachment | this: " + this + " | attachment: " + attachment + " | boo: " + boo,ErrorExSeverity.INFO);
11764
11765 if (GetHierarchyParent() && !GetHierarchyParent().IsInherited(PlayerBase))
11766 return false;
11767 }
11768
11769 return super.CanLoadAttachment(attachment);
11770 }*/
11771
11772 // Plays muzzle flash particle effects
11773 static void PlayFireParticles(ItemBase weapon, int muzzle_index, string ammoType, ItemBase muzzle_owner, ItemBase suppressor, string config_to_search)
11774 {
11775 int id = muzzle_owner.GetMuzzleID();
11776 array<ref WeaponParticlesOnFire> WPOF_array = m_OnFireEffect.Get(id);
11777
11778 if (WPOF_array)
11779 {
11780 for (int i = 0; i < WPOF_array.Count(); i++)
11781 {
11782 WeaponParticlesOnFire WPOF = WPOF_array.Get(i);
11783
11784 if (WPOF)
11785 {
11786 WPOF.OnActivate(weapon, muzzle_index, ammoType, muzzle_owner, suppressor, config_to_search);
11787 }
11788 }
11789 }
11790 }
11791
11792 // Plays bullet eject particle effects (usually just smoke, the bullet itself is a 3D model and is not part of this function)
11793 static void PlayBulletCasingEjectParticles(ItemBase weapon, string ammoType, ItemBase muzzle_owner, ItemBase suppressor, string config_to_search)
11794 {
11795 int id = muzzle_owner.GetMuzzleID();
11796 array<ref WeaponParticlesOnBulletCasingEject> WPOBE_array = m_OnBulletCasingEjectEffect.Get(id);
11797
11798 if (WPOBE_array)
11799 {
11800 for (int i = 0; i < WPOBE_array.Count(); i++)
11801 {
11802 WeaponParticlesOnBulletCasingEject WPOBE = WPOBE_array.Get(i);
11803
11804 if (WPOBE)
11805 {
11806 WPOBE.OnActivate(weapon, 0, ammoType, muzzle_owner, suppressor, config_to_search);
11807 }
11808 }
11809 }
11810 }
11811
11812 // Plays all weapon overheating particles
11813 static void PlayOverheatingParticles(ItemBase weapon, string ammoType, ItemBase muzzle_owner, ItemBase suppressor, string config_to_search)
11814 {
11815 int id = muzzle_owner.GetMuzzleID();
11816 array<ref WeaponParticlesOnOverheating> WPOOH_array = weapon.m_OnOverheatingEffect.Get(id);
11817
11818 if (WPOOH_array)
11819 {
11820 for (int i = 0; i < WPOOH_array.Count(); i++)
11821 {
11822 WeaponParticlesOnOverheating WPOOH = WPOOH_array.Get(i);
11823
11824 if (WPOOH)
11825 {
11826 WPOOH.OnActivate(weapon, 0, ammoType, muzzle_owner, suppressor, config_to_search);
11827 }
11828 }
11829 }
11830 }
11831
11832 // Updates all weapon overheating particles
11833 static void UpdateOverheatingParticles(ItemBase weapon, string ammoType, ItemBase muzzle_owner, ItemBase suppressor, string config_to_search)
11834 {
11835 int id = muzzle_owner.GetMuzzleID();
11836 array<ref WeaponParticlesOnOverheating> WPOOH_array = weapon.m_OnOverheatingEffect.Get(id);
11837
11838 if (WPOOH_array)
11839 {
11840 for (int i = 0; i < WPOOH_array.Count(); i++)
11841 {
11842 WeaponParticlesOnOverheating WPOOH = WPOOH_array.Get(i);
11843
11844 if (WPOOH)
11845 {
11846 WPOOH.OnUpdate(weapon, ammoType, muzzle_owner, suppressor, config_to_search);
11847 }
11848 }
11849 }
11850 }
11851
11852 // Stops overheating particles
11853 static void StopOverheatingParticles(ItemBase weapon, string ammoType, ItemBase muzzle_owner, ItemBase suppressor, string config_to_search)
11854 {
11855 int id = muzzle_owner.GetMuzzleID();
11856 array<ref WeaponParticlesOnOverheating> WPOOH_array = weapon.m_OnOverheatingEffect.Get(id);
11857
11858 if (WPOOH_array)
11859 {
11860 for (int i = 0; i < WPOOH_array.Count(); i++)
11861 {
11862 WeaponParticlesOnOverheating WPOOH = WPOOH_array.Get(i);
11863
11864 if (WPOOH)
11865 {
11866 WPOOH.OnDeactivate(weapon, ammoType, muzzle_owner, suppressor, config_to_search);
11867 }
11868 }
11869 }
11870 }
11871
11872 //----------------------------------------------------------------
11873 //Item Behaviour - unified approach
11874 override bool IsHeavyBehaviour()
11875 {
11876 if (m_ItemBehaviour == 0)
11877 {
11878 return true;
11879 }
11880
11881 return false;
11882 }
11883
11884 override bool IsOneHandedBehaviour()
11885 {
11886 if (m_ItemBehaviour == 1)
11887 {
11888 return true;
11889 }
11890
11891 return false;
11892 }
11893
11894 override bool IsTwoHandedBehaviour()
11895 {
11896 if (m_ItemBehaviour == 2)
11897 {
11898 return true;
11899 }
11900
11901 return false;
11902 }
11903
11904 bool IsDeployable()
11905 {
11906 return false;
11907 }
11908
11910 float GetDeployTime()
11911 {
11912 return UATimeSpent.DEFAULT_DEPLOY;
11913 }
11914
11915
11916 //----------------------------------------------------------------
11917 // Item Targeting (User Actions)
11918 override void SetTakeable(bool pState)
11919 {
11920 m_IsTakeable = pState;
11921 SetSynchDirty();
11922 }
11923
11924 override bool IsTakeable()
11925 {
11926 return m_IsTakeable;
11927 }
11928
11929 // For cases where we want to show object widget which cant be taken to hands
11931 {
11932 return false;
11933 }
11934
11936 protected void PreLoadSoundAttachmentType()
11937 {
11938 string att_type = "None";
11939
11940 if (ConfigIsExisting("soundAttType"))
11941 {
11942 att_type = ConfigGetString("soundAttType");
11943 }
11944
11945 m_SoundAttType = att_type;
11946 }
11947
11948 override string GetAttachmentSoundType()
11949 {
11950 return m_SoundAttType;
11951 }
11952
11953 //----------------------------------------------------------------
11954 //SOUNDS - ItemSoundHandler
11955 //----------------------------------------------------------------
11956
11957 string GetPlaceSoundset(); // played when deploy starts
11958 string GetLoopDeploySoundset(); // played when deploy starts and stopped when it finishes
11959 string GetDeploySoundset(); // played when deploy sucessfully finishes
11960 string GetLoopFoldSoundset(); // played when fold starts and stopped when it finishes
11961 string GetFoldSoundset(); // played when fold sucessfully finishes
11962
11964 {
11965 if (!m_ItemSoundHandler)
11967
11968 return m_ItemSoundHandler;
11969 }
11970
11971 // override to initialize sounds
11972 protected void InitItemSounds()
11973 {
11974 if (GetPlaceSoundset() == string.Empty && GetDeploySoundset() == string.Empty && GetLoopDeploySoundset() == string.Empty && !GetInventoryItemType().SetDetachSoundEvent() && !GetInventoryItemType().SetAttachSoundEvent())
11975 return;
11976
11978
11979 if (GetPlaceSoundset() != string.Empty)
11980 handler.AddSound(SoundConstants.ITEM_PLACE, GetPlaceSoundset());
11981
11982 if (GetDeploySoundset() != string.Empty)
11983 handler.AddSound(SoundConstants.ITEM_DEPLOY, GetDeploySoundset());
11984
11985 SoundParameters params = new SoundParameters();
11986 params.m_Loop = true;
11987 if (GetLoopDeploySoundset() != string.Empty)
11988 handler.AddSound(SoundConstants.ITEM_DEPLOY_LOOP, GetLoopDeploySoundset(), params);
11989 }
11990
11991 // Start sound using ItemSoundHandler
11992 void StartItemSoundServer(int id, int slotId)
11993 {
11994 if (g_Game.IsServer() || !g_Game.IsMultiplayer()) // single player or server side multiplayer
11995 {
11996 m_SoundSyncSlotID = slotId;
11997 m_SoundSyncPlay = id;
11998
11999 SetSynchDirty();
12000
12001 g_Game.GetCallQueue(CALL_CATEGORY_SYSTEM).Remove(ClearStartItemSoundServer); // in case one is queued already
12002 g_Game.GetCallQueue(CALL_CATEGORY_SYSTEM).CallLater(ClearStartItemSoundServer, 100);
12003 }
12004 }
12005
12006 void StartItemSoundServer(int id)
12007 {
12008 StartItemSoundServer(id, InventorySlots.INVALID);
12009 }
12010
12011 // Stop sound using ItemSoundHandler
12012 void StopItemSoundServer(int id)
12013 {
12014 if (!g_Game.IsServer())
12015 return;
12016
12017 m_SoundSyncStop = id;
12018 SetSynchDirty();
12019
12020 g_Game.GetCallQueue(CALL_CATEGORY_SYSTEM).Remove(ClearStopItemSoundServer); // in case one is queued already
12021 g_Game.GetCallQueue(CALL_CATEGORY_SYSTEM).CallLater(ClearStopItemSoundServer, 100);
12022 }
12023
12024 protected void ClearStartItemSoundServer()
12025 {
12026 m_SoundSyncPlay = 0;
12027 m_SoundSyncSlotID = InventorySlots.INVALID;
12028 }
12029
12030 protected void ClearStopItemSoundServer()
12031 {
12032 m_SoundSyncStop = 0;
12033 }
12034
12035 void OnApply(PlayerBase player);
12036
12038 {
12039 return 1.0;
12040 };
12041 //returns applicable selection
12042 array<string> GetHeadHidingSelection()
12043 {
12045 }
12046
12048 {
12050 }
12051
12052 WrittenNoteData GetWrittenNoteData() {};
12053
12055 {
12056 SetDynamicPhysicsLifeTime(0.01);
12057 m_ItemBeingDroppedPhys = false;
12058 }
12059
12061 {
12062 array<string> zone_names = new array<string>;
12063 GetDamageZones(zone_names);
12064 for (int i = 0; i < zone_names.Count(); i++)
12065 {
12066 SetHealthMax(zone_names.Get(i),"Health");
12067 }
12068 SetHealthMax("","Health");
12069 }
12070
12072 void SetZoneDamageCEInit()
12073 {
12074 float global_health = GetHealth01("","Health");
12075 array<string> zones = new array<string>;
12076 GetDamageZones(zones);
12077 //set damage of all zones to match global health level
12078 for (int i = 0; i < zones.Count(); i++)
12079 {
12080 SetHealth01(zones.Get(i),"Health",global_health);
12081 }
12082 }
12083
12085 bool IsCoverFaceForShave(string slot_name)
12086 {
12087 return IsExclusionFlagPresent(PlayerBase.GetFaceCoverageShaveValues());
12088 }
12089
12090 void ProcessItemWetness(float delta, bool hasParent, bool hasRootAsPlayer, ItemBase refParentIB)
12091 {
12092 if (!hasRootAsPlayer)
12093 {
12094 if (refParentIB)
12095 {
12096 // parent is wet
12097 if ((refParentIB.GetWet() >= GameConstants.STATE_SOAKING_WET) && (m_VarWet < m_VarWetMax))
12098 AddWet(delta * GameConstants.WETNESS_RATE_WETTING_INSIDE);
12099 // parent has liquid inside
12100 else if ((refParentIB.GetLiquidType() != 0) && (refParentIB.GetQuantity() > 0) && (m_VarWet < m_VarWetMax))
12101 AddWet(delta * GameConstants.WETNESS_RATE_WETTING_LIQUID);
12102 // drying
12103 else if (m_VarWet > m_VarWetMin)
12104 AddWet(-1 * delta * GetDryingIncrement("ground") * 2);
12105 }
12106 else
12107 {
12108 // drying on ground or inside non-itembase (car, ...)
12109 if (m_VarWet > m_VarWetMin)
12110 AddWet(-1 * delta * GetDryingIncrement("ground"));
12111 }
12112 }
12113 }
12114
12115 void ProcessItemTemperature(float delta, bool hasParent, bool hasRootAsPlayer, ItemBase refParentIB)
12116 {
12118 {
12119 float target = g_Game.GetMission().GetWorldData().GetBaseEnvTemperatureAtObject(this);
12120 if (GetTemperature() != target || !IsFreezeThawProgressFinished())
12121 {
12122 float heatPermCoef = 1.0;
12123 EntityAI ent = this;
12124 while (ent)
12125 {
12126 heatPermCoef *= ent.GetHeatPermeabilityCoef();
12127 ent = ent.GetHierarchyParent();
12128 }
12129
12130 SetTemperatureEx(new TemperatureDataInterpolated(target,ETemperatureAccessTypes.ACCESS_WORLD,delta,GameConstants.TEMP_COEF_WORLD,heatPermCoef));
12131 }
12132 }
12133 }
12134
12135 void HierarchyCheck(out bool hasParent, out bool hasRootAsPlayer, out ItemBase refParentIB)
12136 {
12137 // hierarchy check for an item to decide whether it has some parent and it is in some player inventory
12138 EntityAI parent = GetHierarchyParent();
12139 if (!parent)
12140 {
12141 hasParent = false;
12142 hasRootAsPlayer = false;
12143 }
12144 else
12145 {
12146 hasParent = true;
12147 hasRootAsPlayer = (GetHierarchyRootPlayer() != null);
12148 refParentIB = ItemBase.Cast(parent);
12149 }
12150 }
12151
12152 protected void ProcessDecay(float delta, bool hasRootAsPlayer)
12153 {
12154 // this is stub, implemented on Edible_Base
12155 }
12156
12157 bool CanDecay()
12158 {
12159 // return true used on selected food clases so they can decay
12160 return false;
12161 }
12162
12163 protected bool CanProcessDecay()
12164 {
12165 // this is stub, implemented on Edible_Base class
12166 // used to determine whether it is still necessary for the food to decay
12167 return false;
12168 }
12169
12170 protected bool CanHaveWetness()
12171 {
12172 // return true used on selected items that have a wetness effect
12173 return false;
12174 }
12175
12177 bool CanBeConsumed(ConsumeConditionData data = null)
12178 {
12179 return !GetIsFrozen() && IsOpen();
12180 }
12181
12182 override void ProcessVariables()
12183 {
12184 bool hasParent = false, hasRootAsPlayer = false;
12185 ItemBase refParentIB;
12186
12187 bool wwtu = g_Game.IsWorldWetTempUpdateEnabled();
12188 bool foodDecay = g_Game.IsFoodDecayEnabled();
12189
12190 if (wwtu || foodDecay)
12191 {
12192 bool processWetness = wwtu && CanHaveWetness();
12193 bool processTemperature = wwtu && CanHaveTemperature();
12194 bool processDecay = foodDecay && CanDecay() && CanProcessDecay();
12195
12196 if (processWetness || processTemperature || processDecay)
12197 {
12198 HierarchyCheck(hasParent, hasRootAsPlayer, refParentIB);
12199
12200 if (processWetness)
12201 ProcessItemWetness(m_ElapsedSinceLastUpdate, hasParent, hasRootAsPlayer, refParentIB);
12202
12203 if (processTemperature)
12204 ProcessItemTemperature(m_ElapsedSinceLastUpdate, hasParent, hasRootAsPlayer, refParentIB);
12205
12206 if (processDecay)
12207 ProcessDecay(m_ElapsedSinceLastUpdate, hasRootAsPlayer);
12208 }
12209 }
12210 }
12211
12214 {
12215 return m_TemperaturePerQuantityWeight * GameConstants.ITEM_TEMPERATURE_QUANTITY_WEIGHT_MULTIPLIER;
12216 }
12217
12218 override float GetTemperatureFreezeThreshold()
12219 {
12221 return Liquid.GetFreezeThreshold(GetLiquidType());
12222
12223 return super.GetTemperatureFreezeThreshold();
12224 }
12225
12226 override float GetTemperatureThawThreshold()
12227 {
12229 return Liquid.GetThawThreshold(GetLiquidType());
12230
12231 return super.GetTemperatureThawThreshold();
12232 }
12233
12234 override float GetItemOverheatThreshold()
12235 {
12237 return Liquid.GetBoilThreshold(GetLiquidType());
12238
12239 return super.GetItemOverheatThreshold();
12240 }
12241
12242 override float GetTemperatureFreezeTime()
12243 {
12244 if (HasQuantity())
12245 return Math.Lerp(GameConstants.TEMPERATURE_TIME_FREEZE_MIN,Math.Max(GameConstants.TEMPERATURE_TIME_FREEZE_MIN,super.GetTemperatureFreezeTime()),GetQuantityNormalized());
12246
12247 return super.GetTemperatureFreezeTime();
12248 }
12249
12250 override float GetTemperatureThawTime()
12251 {
12252 if (HasQuantity())
12253 return Math.Lerp(GameConstants.TEMPERATURE_TIME_THAW_MIN,Math.Max(GameConstants.TEMPERATURE_TIME_FREEZE_MIN,super.GetTemperatureThawTime()),GetQuantityNormalized());
12254
12255 return super.GetTemperatureThawTime();
12256 }
12257
12259 void AffectLiquidContainerOnFill(int liquid_type, float amount);
12261 void AffectLiquidContainerOnTransfer(int liquidType, float amount, float sourceLiquidTemperature);
12262
12263 bool IsCargoException4x3(EntityAI item)
12264 {
12265 return (item.IsKindOf("Cauldron") || item.IsKindOf("Pot") || item.IsKindOf("FryingPan") || item.IsKindOf("SmallProtectorCase") || (item.IsKindOf("PortableGasStove") && item.FindAttachmentBySlotName("CookingEquipment")));
12266 }
12267
12269 {
12270 MiscGameplayFunctions.TransferItemProperties(oldItem, this);
12271 }
12272
12274 void AddLightSourceItem(ItemBase lightsource)
12275 {
12276 m_LightSourceItem = lightsource;
12277 }
12278
12280 {
12281 m_LightSourceItem = null;
12282 }
12283
12285 {
12286 return m_LightSourceItem;
12287 }
12288
12290 array<int> GetValidFinishers()
12291 {
12292 return null;
12293 }
12294
12296 bool GetActionWidgetOverride(out typename name)
12297 {
12298 return false;
12299 }
12300
12301 bool PairWithDevice(notnull ItemBase otherDevice)
12302 {
12303 if (g_Game.IsServer())
12304 {
12305 ItemBase explosive = otherDevice;
12307 if (!trg)
12308 {
12309 trg = RemoteDetonatorTrigger.Cast(otherDevice);
12310 explosive = this;
12311 }
12312
12313 explosive.PairRemote(trg);
12314 trg.SetControlledDevice(explosive);
12315
12316 int persistentID = RemotelyActivatedItemBehaviour.GeneratePersistentID();
12317 trg.SetPersistentPairID(persistentID);
12318 explosive.SetPersistentPairID(persistentID);
12319
12320 return true;
12321 }
12322 return false;
12323 }
12324
12326 float GetBaitEffectivity()
12327 {
12328 float ret = 1.0;
12329 if (HasQuantity())
12330 ret *= GetQuantityNormalized();
12331 ret *= GetHealth01();
12332
12333 return ret;
12334 }
12335
12336 #ifdef DEVELOPER
12337 override void SetDebugItem()
12338 {
12339 super.SetDebugItem();
12340 _itemBase = this;
12341 }
12342
12343 override string GetDebugText()
12344 {
12345 string text = super.GetDebugText();
12346
12347 text += string.Format("Heat isolation(raw): %1\n", GetHeatIsolation());
12348 text += string.Format("Heat isolation(modified): %1\n", MiscGameplayFunctions.GetCurrentItemHeatIsolation(this));
12349
12350 return text;
12351 }
12352 #endif
12353
12354 bool CanBeUsedForSuicide()
12355 {
12356 return true;
12357 }
12358
12360 //DEPRECATED BELOW
12362 // Backwards compatibility
12363 void ProcessItemWetnessAndTemperature(float delta, bool hasParent, bool hasRootAsPlayer, ItemBase refParentIB)
12364 {
12365 ProcessItemWetness(delta, hasParent, hasRootAsPlayer, refParentIB);
12366 ProcessItemTemperature(delta, hasParent, hasRootAsPlayer, refParentIB);
12367 }
12368
12369 // replaced by ItemSoundHandler
12370 protected EffectSound m_SoundDeployFinish;
12371 protected EffectSound m_SoundPlace;
12372 protected EffectSound m_DeployLoopSoundEx;
12373 protected EffectSound m_SoundDeploy;
12374 bool m_IsPlaceSound;
12375 bool m_IsDeploySound;
12377
12378 string GetDeployFinishSoundset();
12379 void PlayDeploySound();
12380 void PlayDeployFinishSound();
12381 void PlayPlaceSound();
12382 void PlayDeployLoopSoundEx();
12383 void StopDeployLoopSoundEx();
12384 void SoundSynchRemoteReset();
12385 void SoundSynchRemote();
12386 bool UsesGlobalDeploy(){return false;}
12387 bool CanPlayDeployLoopSound(){return false;}
12389 bool IsPlaceSound(){return m_IsPlaceSound;}
12390 bool IsDeploySound(){return m_IsDeploySound;}
12391 void SetIsPlaceSound(bool is_place_sound);
12392 void SetIsDeploySound(bool is_deploy_sound);
12393
12394 [Obsolete("Use ItemSoundHandler instead")]
12396 void PlayAttachSound(string slot_type)
12397 {
12398 if (!g_Game.IsDedicatedServer())
12399 {
12400 if (ConfigIsExisting("attachSoundSet"))
12401 {
12402 string cfg_path = "";
12403 string soundset = "";
12404 string type_name = GetType();
12405
12406 TStringArray cfg_soundset_array = new TStringArray;
12407 TStringArray cfg_slot_array = new TStringArray;
12408 ConfigGetTextArray("attachSoundSet",cfg_soundset_array);
12409 ConfigGetTextArray("attachSoundSlot",cfg_slot_array);
12410
12411 if (cfg_soundset_array.Count() > 0 && cfg_soundset_array.Count() == cfg_slot_array.Count())
12412 {
12413 for (int i = 0; i < cfg_soundset_array.Count(); i++)
12414 {
12415 if (cfg_slot_array[i] == slot_type)
12416 {
12417 soundset = cfg_soundset_array[i];
12418 break;
12419 }
12420 }
12421 }
12422
12423 if (soundset != "")
12424 {
12425 EffectSound sound = SEffectManager.PlaySound(soundset, GetPosition());
12426 sound.SetAutodestroy(true);
12427 }
12428 }
12429 }
12430 }
12431
12432 void PlayDetachSound(string slot_type) {}
12433}
12434
12435EntityAI SpawnItemOnLocation(string object_name, notnull InventoryLocation loc, bool full_quantity)
12436{
12437 EntityAI entity = SpawnEntity(object_name, loc, ECE_IN_INVENTORY, RF_DEFAULT);
12438 if (entity)
12439 {
12440 bool is_item = entity.IsInherited(ItemBase);
12441 if (is_item && full_quantity)
12442 {
12443 ItemBase item = ItemBase.Cast(entity);
12444 item.SetQuantity(item.GetQuantityInit());
12445 }
12446 }
12447 else
12448 {
12449 ErrorEx("Cannot spawn entity: " + object_name,ErrorExSeverity.INFO);
12450 return NULL;
12451 }
12452 return entity;
12453}
12454
12455void SetupSpawnedItem(ItemBase item, float health, float quantity)
12456{
12457 if (item)
12458 {
12459 if (health > 0)
12460 item.SetHealth("", "", health);
12461
12462 if (item.CanHaveTemperature())
12463 {
12464 item.SetTemperatureDirect(GameConstants.ITEM_TEMPERATURE_NEUTRAL_ZONE_MIDDLE);
12465 if (item.CanFreeze())
12466 item.SetFrozen(false);
12467 }
12468
12469 if (item.HasEnergyManager())
12470 {
12471 if (quantity >= 0)
12472 {
12473 item.GetCompEM().SetEnergy0To1(quantity);
12474 }
12475 else
12476 {
12477 item.GetCompEM().SetEnergy(Math.AbsFloat(quantity));
12478 }
12479 }
12480 else if (item.IsMagazine())
12481 {
12482 Magazine mag = Magazine.Cast(item);
12483 if (quantity >= 0)
12484 {
12485 mag.ServerSetAmmoCount(mag.GetAmmoMax() * quantity);
12486 }
12487 else
12488 {
12489 mag.ServerSetAmmoCount(Math.AbsFloat(quantity));
12490 }
12491
12492 }
12493 else
12494 {
12495 if (quantity >= 0)
12496 {
12497 item.SetQuantityNormalized(quantity, false);
12498 }
12499 else
12500 {
12501 item.SetQuantity(Math.AbsFloat(quantity));
12502 }
12503
12504 }
12505 }
12506}
12507
12508#ifdef DEVELOPER
12509ItemBase _itemBase;//watched item goes here(LCTRL+RMB->Watch)
12510#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()