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

◆ OnSyncVariables()

void SpawnItemOnLocation::OnSyncVariables ( ParamsReadContext ctx)
protected

DEPRECATED (most likely)

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

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