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

◆ SerializeNumericalVars()

override void SpawnItemOnLocation::SerializeNumericalVars ( array< float > floats_out)
protected

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

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

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