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

◆ OnStoreLoad()

override bool SpawnItemOnLocation::OnStoreLoad ( ParamsReadContext ctx,
int version )
protected

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

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