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

◆ OnRPC()

override void SpawnItemOnLocation::OnRPC ( PlayerIdentity sender,
int rpc_type,
ParamsReadContext ctx )
protected

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

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