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

◆ KindOf()

override bool SpawnItemOnLocation::KindOf ( string tag)
protected

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

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