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

◆ HasFoodStage()

bool SpawnItemOnLocation::HasFoodStage ( )
protected

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

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

Используется в Edible_Base::Edible_Base().