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

◆ CombineItems()

void SpawnItemOnLocation::CombineItems ( ItemBase other_item,
bool use_stack_max = true )
protected

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

7126{
7127 override bool CanPutAsAttachment(EntityAI parent)
7128 {
7129 return true;
7130 }
7131};
7132
7133//const bool QUANTITY_DEBUG_REMOVE_ME = false;
7134
7135class ItemBase extends InventoryItem
7136{
7140
7142
7143 static int m_DebugActionsMask;
7145 // ============================================
7146 // Variable Manipulation System
7147 // ============================================
7148 // Quantity
7149
7150 float m_VarQuantity;
7151 float m_VarQuantityPrev;//for client to know quantity changed during synchronization
7153 int m_VarQuantityMin;
7154 int m_VarQuantityMax;
7155 int m_Count;
7156 float m_VarStackMax;
7157 float m_StoreLoadedQuantity = float.LOWEST;
7158 // Wet
7159 float m_VarWet;
7160 float m_VarWetPrev;//for client to know wetness changed during synchronization
7161 float m_VarWetInit;
7162 float m_VarWetMin;
7163 float m_VarWetMax;
7164 // Cleanness
7165 int m_Cleanness;
7166 int m_CleannessInit;
7167 int m_CleannessMin;
7168 int m_CleannessMax;
7169 // impact sounds
7171 bool m_CanPlayImpactSound = true;
7172 float m_ImpactSpeed;
7174 //
7175 float m_HeatIsolation;
7176 float m_ItemModelLength;
7177 float m_ItemAttachOffset; // Offset length for when the item is attached e.g. to weapon
7179 int m_VarLiquidType;
7180 int m_ItemBehaviour; // -1 = not specified; 0 = heavy item; 1= onehanded item; 2 = twohanded item
7181 int m_QuickBarBonus;
7182 bool m_IsBeingPlaced;
7183 bool m_IsHologram;
7184 bool m_IsTakeable;
7185 bool m_ThrowItemOnDrop;
7188 bool m_FixDamageSystemInit = false; //can be changed on storage version check
7189 bool can_this_be_combined; //Check if item can be combined
7190 bool m_CanThisBeSplit; //Check if item can be split
7191 bool m_IsStoreLoad = false;
7192 bool m_CanShowQuantity;
7193 bool m_HasQuantityBar;
7194 protected bool m_CanBeDigged;
7195 protected bool m_IsResultOfSplit
7196
7197 string m_SoundAttType;
7198 // items color variables
7203 //-------------------------------------------------------
7204
7205 // light source managing
7207
7211
7212 //==============================================
7213 // agent system
7214 private int m_AttachedAgents;
7215
7217 void TransferModifiers(PlayerBase reciever);
7218
7219
7220 // Weapons & suppressors particle effects
7225 static int m_LastRegisteredWeaponID = 0;
7226
7227 // Overheating effects
7229 float m_OverheatingShots;
7230 ref Timer m_CheckOverheating;
7231 int m_ShotsToStartOverheating = 0; // After these many shots, the overheating effect begins
7232 int m_MaxOverheatingValue = 0; // Limits the number of shots that will be tracked
7233 float m_OverheatingDecayInterval = 1; // Timer's interval for decrementing overheat effect's lifespan
7234 ref array <ref OverheatingParticle> m_OverheatingParticles;
7235
7237 protected bool m_HideSelectionsBySlot;
7238
7239 // Admin Log
7240 PluginAdminLog m_AdminLog;
7241
7242 // misc
7243 ref Timer m_PhysDropTimer;
7244
7245 // Attachment Locking variables
7246 ref array<int> m_CompatibleLocks;
7247 protected int m_LockType;
7248 protected ref EffectSound m_LockingSound;
7249 protected string m_LockSoundSet;
7250
7251 // ItemSoundHandler
7252 protected const int ITEM_SOUNDS_MAX = 63; // optimize network synch
7253 protected int m_SoundSyncPlay; // id for sound to play
7254 protected int m_SoundSyncStop; // id for sound to stop
7256
7257 //temperature
7258 private float m_TemperaturePerQuantityWeight;
7259
7260 // -------------------------------------------------------------------------
7261 void ItemBase()
7262 {
7263 SetEventMask(EntityEvent.INIT); // Enable EOnInit event
7267
7268 if (!GetGame().IsDedicatedServer())
7269 {
7270 if (HasMuzzle())
7271 {
7273
7275 {
7277 }
7278 }
7279
7281 m_ActionsInitialize = false;
7282 }
7283
7284 m_OldLocation = null;
7285
7286 if (GetGame().IsServer())
7287 {
7288 m_AdminLog = PluginAdminLog.Cast(GetPlugin(PluginAdminLog));
7289 }
7290
7291 if (ConfigIsExisting("headSelectionsToHide"))
7292 {
7294 ConfigGetTextArray("headSelectionsToHide",m_HeadHidingSelections);
7295 }
7296
7297 m_HideSelectionsBySlot = false;
7298 if (ConfigIsExisting("hideSelectionsByinventorySlot"))
7299 {
7300 m_HideSelectionsBySlot = ConfigGetBool("hideSelectionsByinventorySlot");
7301 }
7302
7303 m_QuickBarBonus = Math.Max(0, ConfigGetInt("quickBarBonus"));
7304
7305 m_IsResultOfSplit = false;
7306
7308 }
7309
7310 override void InitItemVariables()
7311 {
7312 super.InitItemVariables();
7313
7314 m_VarQuantityInit = ConfigGetInt("varQuantityInit");
7315 m_VarQuantity = m_VarQuantityInit;//should be by the CE, this is just a precaution
7316 m_VarQuantityMin = ConfigGetInt("varQuantityMin");
7317 m_VarQuantityMax = ConfigGetInt("varQuantityMax");
7318 m_VarStackMax = ConfigGetFloat("varStackMax");
7319 m_Count = ConfigGetInt("count");
7320
7321 m_CanShowQuantity = ConfigGetBool("quantityShow");
7322 m_HasQuantityBar = ConfigGetBool("quantityBar");
7323
7324 m_CleannessInit = ConfigGetInt("varCleannessInit");
7326 m_CleannessMin = ConfigGetInt("varCleannessMin");
7327 m_CleannessMax = ConfigGetInt("varCleannessMax");
7328
7329 m_WantPlayImpactSound = false;
7330 m_ImpactSpeed = 0.0;
7331
7332 m_VarWetInit = ConfigGetFloat("varWetInit");
7334 m_VarWetMin = ConfigGetFloat("varWetMin");
7335 m_VarWetMax = ConfigGetFloat("varWetMax");
7336
7337 m_LiquidContainerMask = ConfigGetInt("liquidContainerType");
7338 if (IsLiquidContainer() && GetQuantity() != 0)
7340 m_IsBeingPlaced = false;
7341 m_IsHologram = false;
7342 m_IsTakeable = true;
7343 m_CanBeMovedOverride = false;
7347 m_CanBeDigged = ConfigGetBool("canBeDigged");
7348
7349 m_CompatibleLocks = new array<int>();
7350 ConfigGetIntArray("compatibleLocks", m_CompatibleLocks);
7351 m_LockType = ConfigGetInt("lockType");
7352
7353 //Define if item can be split and set ability to be combined accordingly
7354 m_CanThisBeSplit = false;
7355 can_this_be_combined = false;
7356 if (ConfigIsExisting("canBeSplit"))
7357 {
7358 can_this_be_combined = ConfigGetBool("canBeSplit");
7360 }
7361
7362 m_ItemBehaviour = -1;
7363 if (ConfigIsExisting("itemBehaviour"))
7364 m_ItemBehaviour = ConfigGetInt("itemBehaviour");
7365
7366 //RegisterNetSyncVariableInt("m_VariablesMask");
7367 if (HasQuantity()) RegisterNetSyncVariableFloat("m_VarQuantity", GetQuantityMin(), m_VarQuantityMax);
7368 RegisterNetSyncVariableFloat("m_VarWet", GetWetMin(), GetWetMax(), 2);
7369 RegisterNetSyncVariableInt("m_VarLiquidType");
7370 RegisterNetSyncVariableInt("m_Cleanness",0,1);
7371
7372 RegisterNetSyncVariableBoolSignal("m_WantPlayImpactSound");
7373 RegisterNetSyncVariableFloat("m_ImpactSpeed");
7374 RegisterNetSyncVariableInt("m_ImpactSoundSurfaceHash");
7375
7376 RegisterNetSyncVariableInt("m_ColorComponentR", 0, 255);
7377 RegisterNetSyncVariableInt("m_ColorComponentG", 0, 255);
7378 RegisterNetSyncVariableInt("m_ColorComponentB", 0, 255);
7379 RegisterNetSyncVariableInt("m_ColorComponentA", 0, 255);
7380
7381 RegisterNetSyncVariableBool("m_IsBeingPlaced");
7382 RegisterNetSyncVariableBool("m_IsTakeable");
7383 RegisterNetSyncVariableBool("m_IsHologram");
7384
7385 InitItemSounds();
7387 {
7388 RegisterNetSyncVariableInt("m_SoundSyncPlay", 0, ITEM_SOUNDS_MAX);
7389 RegisterNetSyncVariableInt("m_SoundSyncStop", 0, ITEM_SOUNDS_MAX);
7390 }
7391
7392 m_LockSoundSet = ConfigGetString("lockSoundSet");
7393
7395 if (ConfigIsExisting("temperaturePerQuantityWeight"))
7396 m_TemperaturePerQuantityWeight = ConfigGetFloat("temperaturePerQuantityWeight");
7397
7398 }
7399
7400 override int GetQuickBarBonus()
7401 {
7402 return m_QuickBarBonus;
7403 }
7404
7405 void InitializeActions()
7406 {
7408 if (!m_InputActionMap)
7409 {
7411 m_InputActionMap = iam;
7412 SetActions();
7414 }
7415 }
7416
7417 override void GetActions(typename action_input_type, out array<ActionBase_Basic> actions)
7418 {
7420 {
7421 m_ActionsInitialize = true;
7423 }
7424
7425 actions = m_InputActionMap.Get(action_input_type);
7426 }
7427
7428 void SetActions()
7429 {
7430 AddAction(ActionTakeItem);
7431 AddAction(ActionTakeItemToHands);
7432 AddAction(ActionWorldCraft);
7434 AddAction(ActionAttachWithSwitch);
7435 }
7436
7437 void SetActionAnimOverrides(); // Override action animation for specific item
7438
7439 void AddAction(typename actionName)
7440 {
7441 ActionBase action = ActionManagerBase.GetAction(actionName);
7442
7443 if (!action)
7444 {
7445 Debug.LogError("Action " + actionName + " dosn't exist!");
7446 return;
7447 }
7448
7449 typename ai = action.GetInputType();
7450 if (!ai)
7451 {
7452 m_ActionsInitialize = false;
7453 return;
7454 }
7455
7456 array<ActionBase_Basic> action_array = m_InputActionMap.Get(ai);
7457 if (!action_array)
7458 {
7459 action_array = new array<ActionBase_Basic>;
7460 m_InputActionMap.Insert(ai, action_array);
7461 }
7462 if (LogManager.IsActionLogEnable())
7463 {
7464 Debug.ActionLog(action.ToString() + " -> " + ai, this.ToString() , "n/a", "Add action");
7465 }
7466
7467 if (action_array.Find(action) != -1)
7468 {
7469 Debug.Log("Action " + action.Type() + " already added to " + this + ", skipping!");
7470 }
7471 else
7472 {
7473 action_array.Insert(action);
7474 }
7475 }
7476
7477 void RemoveAction(typename actionName)
7478 {
7479 PlayerBase player = PlayerBase.Cast(GetGame().GetPlayer());
7480 ActionBase action = player.GetActionManager().GetAction(actionName);
7481 typename ai = action.GetInputType();
7482 array<ActionBase_Basic> action_array = m_InputActionMap.Get(ai);
7483
7484 if (action_array)
7485 {
7486 action_array.RemoveItem(action);
7487 }
7488 }
7489
7490 // Allows override of default action command per item, defined in the SetActionAnimOverrides() of the item's class
7491 // Set -1 for params which should stay in default state
7492 void OverrideActionAnimation(typename action, int commandUID, int stanceMask = -1, int commandUIDProne = -1)
7493 {
7494 ActionOverrideData overrideData = new ActionOverrideData();
7495 overrideData.m_CommandUID = commandUID;
7496 overrideData.m_CommandUIDProne = commandUIDProne;
7497 overrideData.m_StanceMask = stanceMask;
7498
7499 TActionAnimOverrideMap actionMap = m_ItemActionOverrides.Get(action);
7500 if (!actionMap) // create new map of action > overidables map
7501 {
7502 actionMap = new TActionAnimOverrideMap();
7503 m_ItemActionOverrides.Insert(action, actionMap);
7504 }
7505
7506 actionMap.Insert(this.Type(), overrideData); // insert item -> overrides
7507
7508 }
7509
7510 void OnItemInHandsPlayerSwimStart(PlayerBase player);
7511
7512 ScriptedLightBase GetLight();
7513
7514 // Loads muzzle flash particle configuration from config and saves it to a map for faster access
7515 void LoadParticleConfigOnFire(int id)
7516 {
7517 if (!m_OnFireEffect)
7519
7522
7523 string config_to_search = "CfgVehicles";
7524 string muzzle_owner_config;
7525
7526 if (!m_OnFireEffect.Contains(id))
7527 {
7528 if (IsInherited(Weapon))
7529 config_to_search = "CfgWeapons";
7530
7531 muzzle_owner_config = config_to_search + " " + GetType() + " ";
7532
7533 string config_OnFire_class = muzzle_owner_config + "Particles " + "OnFire ";
7534
7535 int config_OnFire_subclass_count = GetGame().ConfigGetChildrenCount(config_OnFire_class);
7536
7537 if (config_OnFire_subclass_count > 0)
7538 {
7539 array<ref WeaponParticlesOnFire> WPOF_array = new array<ref WeaponParticlesOnFire>;
7540
7541 for (int i = 0; i < config_OnFire_subclass_count; i++)
7542 {
7543 string particle_class = "";
7544 GetGame().ConfigGetChildName(config_OnFire_class, i, particle_class);
7545 string config_OnFire_entry = config_OnFire_class + particle_class;
7546 WeaponParticlesOnFire WPOF = new WeaponParticlesOnFire(this, config_OnFire_entry);
7547 WPOF_array.Insert(WPOF);
7548 }
7549
7550
7551 m_OnFireEffect.Insert(id, WPOF_array);
7552 }
7553 }
7554
7555 if (!m_OnBulletCasingEjectEffect.Contains(id))
7556 {
7557 config_to_search = "CfgWeapons"; // Bullet Eject efect is supported on weapons only.
7558 muzzle_owner_config = config_to_search + " " + GetType() + " ";
7559
7560 string config_OnBulletCasingEject_class = muzzle_owner_config + "Particles " + "OnBulletCasingEject ";
7561
7562 int config_OnBulletCasingEject_count = GetGame().ConfigGetChildrenCount(config_OnBulletCasingEject_class);
7563
7564 if (config_OnBulletCasingEject_count > 0 && IsInherited(Weapon))
7565 {
7566 array<ref WeaponParticlesOnBulletCasingEject> WPOBE_array = new array<ref WeaponParticlesOnBulletCasingEject>;
7567
7568 for (i = 0; i < config_OnBulletCasingEject_count; i++)
7569 {
7570 string particle_class2 = "";
7571 GetGame().ConfigGetChildName(config_OnBulletCasingEject_class, i, particle_class2);
7572 string config_OnBulletCasingEject_entry = config_OnBulletCasingEject_class + particle_class2;
7573 WeaponParticlesOnBulletCasingEject WPOBE = new WeaponParticlesOnBulletCasingEject(this, config_OnBulletCasingEject_entry);
7574 WPOBE_array.Insert(WPOBE);
7575 }
7576
7577
7578 m_OnBulletCasingEjectEffect.Insert(id, WPOBE_array);
7579 }
7580 }
7581 }
7582
7583 // Loads muzzle flash particle configuration from config and saves it to a map for faster access
7585 {
7588
7589 if (!m_OnOverheatingEffect.Contains(id))
7590 {
7591 string config_to_search = "CfgVehicles";
7592
7593 if (IsInherited(Weapon))
7594 config_to_search = "CfgWeapons";
7595
7596 string muzzle_owner_config = config_to_search + " " + GetType() + " ";
7597 string config_OnOverheating_class = muzzle_owner_config + "Particles " + "OnOverheating ";
7598
7599 if (GetGame().ConfigIsExisting(config_OnOverheating_class))
7600 {
7601
7602 m_ShotsToStartOverheating = GetGame().ConfigGetFloat(config_OnOverheating_class + "shotsToStartOverheating");
7603
7605 {
7606 m_ShotsToStartOverheating = -1; // This prevents futher readings from config for future creations of this item
7607 string error = "Error reading config " + GetType() + ">Particles>OnOverheating - Parameter shotsToStartOverheating is configured wrong or is missing! Its value must be 1 or higher!";
7608 Error(error);
7609 return;
7610 }
7611
7612 m_OverheatingDecayInterval = GetGame().ConfigGetFloat(config_OnOverheating_class + "overheatingDecayInterval");
7613 m_MaxOverheatingValue = GetGame().ConfigGetFloat(config_OnOverheating_class + "maxOverheatingValue");
7614
7615
7616
7617 int config_OnOverheating_subclass_count = GetGame().ConfigGetChildrenCount(config_OnOverheating_class);
7618 array<ref WeaponParticlesOnOverheating> WPOOH_array = new array<ref WeaponParticlesOnOverheating>;
7619
7620 for (int i = 0; i < config_OnOverheating_subclass_count; i++)
7621 {
7622 string particle_class = "";
7623 GetGame().ConfigGetChildName(config_OnOverheating_class, i, particle_class);
7624 string config_OnOverheating_entry = config_OnOverheating_class + particle_class;
7625 int entry_type = GetGame().ConfigGetType(config_OnOverheating_entry);
7626
7627 if (entry_type == CT_CLASS)
7628 {
7629 WeaponParticlesOnOverheating WPOF = new WeaponParticlesOnOverheating(this, config_OnOverheating_entry);
7630 WPOOH_array.Insert(WPOF);
7631 }
7632 }
7633
7634
7635 m_OnOverheatingEffect.Insert(id, WPOOH_array);
7636 }
7637 }
7638 }
7639
7640 float GetOverheatingValue()
7641 {
7642 return m_OverheatingShots;
7643 }
7644
7645 void IncreaseOverheating(ItemBase weapon, string ammoType, ItemBase muzzle_owner, ItemBase suppressor, string config_to_search)
7646 {
7647 if (m_MaxOverheatingValue > 0)
7648 {
7650
7651 if (!m_CheckOverheating)
7653
7655 m_CheckOverheating.Run(m_OverheatingDecayInterval, this, "OnOverheatingDecay");
7656
7657 CheckOverheating(weapon, ammoType, muzzle_owner, suppressor, config_to_search);
7658 }
7659 }
7660
7661 void CheckOverheating(ItemBase weapon = null, string ammoType = "", ItemBase muzzle_owner = null, ItemBase suppressor = null, string config_to_search = "")
7662 {
7664 UpdateOverheating(weapon, ammoType, muzzle_owner, suppressor, config_to_search);
7665
7667 StartOverheating(weapon, ammoType, muzzle_owner, suppressor, config_to_search);
7668
7670 StopOverheating(weapon, ammoType, muzzle_owner, suppressor, config_to_search);
7671
7673 {
7675 }
7676 }
7677
7679 {
7681 }
7682
7683 void OnOverheatingDecay()
7684 {
7685 if (m_MaxOverheatingValue > 0)
7686 m_OverheatingShots -= 1 + m_OverheatingShots / m_MaxOverheatingValue; // The hotter a barrel is, the faster it needs to cool down.
7687 else
7689
7690 if (m_OverheatingShots <= 0)
7691 {
7694 }
7695 else
7696 {
7697 if (!m_CheckOverheating)
7699
7701 m_CheckOverheating.Run(m_OverheatingDecayInterval, this, "OnOverheatingDecay");
7702 }
7703
7704 CheckOverheating(this, "", this);
7705 }
7706
7707 void StartOverheating(ItemBase weapon = null, string ammoType = "", ItemBase muzzle_owner = null, ItemBase suppressor = null, string config_to_search = "")
7708 {
7710 ItemBase.PlayOverheatingParticles(this, ammoType, this, suppressor, "CfgWeapons");
7711 }
7712
7713 void UpdateOverheating(ItemBase weapon = null, string ammoType = "", ItemBase muzzle_owner = null, ItemBase suppressor = null, string config_to_search = "")
7714 {
7716 ItemBase.UpdateOverheatingParticles(this, ammoType, this, suppressor, "CfgWeapons");
7718 }
7719
7720 void StopOverheating(ItemBase weapon = null, string ammoType = "", ItemBase muzzle_owner = null, ItemBase suppressor = null, string config_to_search = "")
7721 {
7723 ItemBase.StopOverheatingParticles(weapon, ammoType, muzzle_owner, suppressor, config_to_search);
7724 }
7725
7726 void RegisterOverheatingParticle(Particle p, float min_heat_coef, float max_heat_coef, int particle_id, Object parent, vector local_pos, vector local_ori)
7727 {
7729 m_OverheatingParticles = new array<ref OverheatingParticle>;
7730
7731 OverheatingParticle OP = new OverheatingParticle();
7732 OP.RegisterParticle(p);
7733 OP.SetOverheatingLimitMin(min_heat_coef);
7734 OP.SetOverheatingLimitMax(max_heat_coef);
7735 OP.SetParticleParams(particle_id, parent, local_pos, local_ori);
7736
7737 m_OverheatingParticles.Insert(OP);
7738 }
7739
7740 float GetOverheatingCoef()
7741 {
7742 if (m_MaxOverheatingValue > 0)
7744
7745 return -1;
7746 }
7747
7749 {
7751 {
7752 float overheat_coef = GetOverheatingCoef();
7753 int count = m_OverheatingParticles.Count();
7754
7755 for (int i = count; i > 0; --i)
7756 {
7757 int id = i - 1;
7758 OverheatingParticle OP = m_OverheatingParticles.Get(id);
7759 Particle p = OP.GetParticle();
7760
7761 float overheat_min = OP.GetOverheatingLimitMin();
7762 float overheat_max = OP.GetOverheatingLimitMax();
7763
7764 if (overheat_coef < overheat_min && overheat_coef >= overheat_max)
7765 {
7766 if (p)
7767 {
7768 p.Stop();
7769 OP.RegisterParticle(null);
7770 }
7771 }
7772 }
7773 }
7774 }
7775
7777 {
7779 {
7780 for (int i = m_OverheatingParticles.Count(); i > 0; i--)
7781 {
7782 int id = i - 1;
7783 OverheatingParticle OP = m_OverheatingParticles.Get(id);
7784
7785 if (OP)
7786 {
7787 Particle p = OP.GetParticle();
7788
7789 if (p)
7790 {
7791 p.Stop();
7792 }
7793
7794 delete OP;
7795 }
7796 }
7797
7798 m_OverheatingParticles.Clear();
7800 }
7801 }
7802
7804 float GetInfectionChance(int system = 0, Param param = null)
7805 {
7806 return 0.0;
7807 }
7808
7809
7810 float GetDisinfectQuantity(int system = 0, Param param1 = null)
7811 {
7812 return 250;//default value
7813 }
7814
7815 float GetFilterDamageRatio()
7816 {
7817 return 0;
7818 }
7819
7821 bool HasMuzzle()
7822 {
7823 if (IsInherited(Weapon) || IsInherited(SuppressorBase))
7824 return true;
7825
7826 return false;
7827 }
7828
7830 int GetMuzzleID()
7831 {
7832 if (!m_WeaponTypeToID)
7834
7835 if (m_WeaponTypeToID.Contains(GetType()))
7836 {
7837 return m_WeaponTypeToID.Get(GetType());
7838 }
7839 else
7840 {
7841 // Register new weapon ID
7843 }
7844
7846 }
7847
7854 {
7855 return -1;
7856 }
7857
7858
7859
7860 // -------------------------------------------------------------------------
7861 void ~ItemBase()
7862 {
7863 if (GetGame() && GetGame().GetPlayer() && (!GetGame().IsDedicatedServer()))
7864 {
7865 PlayerBase player = PlayerBase.Cast(GetGame().GetPlayer());
7866 int r_index = player.GetHumanInventory().FindUserReservedLocationIndex(this);
7867
7868 if (r_index >= 0)
7869 {
7870 InventoryLocation r_il = new InventoryLocation;
7871 player.GetHumanInventory().GetUserReservedLocation(r_index,r_il);
7872
7873 player.GetHumanInventory().ClearUserReservedLocationAtIndex(r_index);
7874 int r_type = r_il.GetType();
7875 if (r_type == InventoryLocationType.CARGO || r_type == InventoryLocationType.PROXYCARGO)
7876 {
7877 r_il.GetParent().GetOnReleaseLock().Invoke(this);
7878 }
7879 else if (r_type == InventoryLocationType.ATTACHMENT)
7880 {
7881 r_il.GetParent().GetOnAttachmentReleaseLock().Invoke(this, r_il.GetSlot());
7882 }
7883
7884 }
7885
7886 player.GetHumanInventory().ClearUserReservedLocation(this);
7887 }
7888
7889 if (m_LockingSound)
7890 SEffectManager.DestroyEffect(m_LockingSound);
7891 }
7892
7893
7894
7895 // -------------------------------------------------------------------------
7896 static int GetDebugActionsMask()
7897 {
7898 return ItemBase.m_DebugActionsMask;
7899 }
7900
7901 static bool HasDebugActionsMask(int mask)
7902 {
7903 return ItemBase.m_DebugActionsMask & mask;
7904 }
7905
7906 static void SetDebugActionsMask(int mask)
7907 {
7908 ItemBase.m_DebugActionsMask = mask;
7909 }
7910
7911 static void AddDebugActionsMask(int mask)
7912 {
7913 ItemBase.m_DebugActionsMask |= mask;
7914 }
7915
7916 static void RemoveDebugActionsMask(int mask)
7917 {
7918 ItemBase.m_DebugActionsMask &= ~mask;
7919 }
7920
7921 static void ToggleDebugActionsMask(int mask)
7922 {
7923 if (HasDebugActionsMask(mask))
7924 {
7926 }
7927 else
7928 {
7929 AddDebugActionsMask(mask);
7930 }
7931 }
7932
7933 // -------------------------------------------------------------------------
7934 void SetCEBasedQuantity()
7935 {
7936 if (GetEconomyProfile())
7937 {
7938 float q_max = GetEconomyProfile().GetQuantityMax();
7939 if (q_max > 0)
7940 {
7941 float q_min = GetEconomyProfile().GetQuantityMin();
7942 float quantity_randomized = Math.RandomFloatInclusive(q_min, q_max);
7943
7944 if (HasComponent(COMP_TYPE_ENERGY_MANAGER))//more direct access for speed
7945 {
7946 ComponentEnergyManager comp = GetCompEM();
7947 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
7948 {
7949 comp.SetEnergy0To1(quantity_randomized);
7950 }
7951 }
7952 else if (HasQuantity())
7953 {
7954 SetQuantityNormalized(quantity_randomized, false);
7955 //PrintString("<==> Normalized quantity for item: "+ GetType()+", qmin:"+q_min.ToString()+"; qmax:"+q_max.ToString()+";quantity:" +quantity_randomized.ToString());
7956 }
7957
7958 }
7959 }
7960 }
7961
7963 void LockToParent()
7964 {
7965 EntityAI parent = GetHierarchyParent();
7966
7967 if (parent)
7968 {
7969 InventoryLocation inventory_location_to_lock = new InventoryLocation;
7970 GetInventory().GetCurrentInventoryLocation(inventory_location_to_lock);
7971 parent.GetInventory().SetSlotLock(inventory_location_to_lock.GetSlot(), true);
7972 }
7973 }
7974
7976 void UnlockFromParent()
7977 {
7978 EntityAI parent = GetHierarchyParent();
7979
7980 if (parent)
7981 {
7982 InventoryLocation inventory_location_to_unlock = new InventoryLocation;
7983 GetInventory().GetCurrentInventoryLocation(inventory_location_to_unlock);
7984 parent.GetInventory().SetSlotLock(inventory_location_to_unlock.GetSlot(), false);
7985 }
7986 }
7987
7988 override void CombineItemsClient(EntityAI entity2, bool use_stack_max = true)
7989 {
7990 /*
7991 ref Param1<EntityAI> item = new Param1<EntityAI>(entity2);
7992 RPCSingleParam(ERPCs.RPC_ITEM_COMBINE, item, GetGame().GetPlayer());
7993 */
7994 ItemBase item2 = ItemBase.Cast(entity2);
7995
7996 if (GetGame().IsClient())
7997 {
7998 if (ScriptInputUserData.CanStoreInputUserData())
7999 {
8000 ScriptInputUserData ctx = new ScriptInputUserData;
8002 ctx.Write(-1);
8003 ItemBase i1 = this; // @NOTE: workaround for correct serialization
8004 ctx.Write(i1);
8005 ctx.Write(item2);
8006 ctx.Write(use_stack_max);
8007 ctx.Write(-1);
8008 ctx.Send();
8009
8010 if (IsCombineAll(item2, use_stack_max))
8011 {
8012 GetGame().GetPlayer().GetInventory().AddInventoryReservationEx(item2,null,GameInventory.c_InventoryReservationTimeoutShortMS);
8013 }
8014 }
8015 }
8016 else if (!GetGame().IsMultiplayer())
8017 {
8018 CombineItems(item2, use_stack_max);
8019 }
8020 }
8021
8022 bool IsLiquidPresent()
8023 {
8024 return (GetLiquidType() != 0 && HasQuantity());
8025 }
8026
8027 bool IsLiquidContainer()
8028 {
8029 return m_LiquidContainerMask != 0;
8030 }
8031
8033 {
8034 return m_LiquidContainerMask;
8035 }
8036
8037 bool IsBloodContainer()
8038 {
8039 //m_LiquidContainerMask & GROUP_LIQUID_BLOOD ???
8040 return false;
8041 }
8042
8043 bool IsNVG()
8044 {
8045 return false;
8046 }
8047
8050 bool IsExplosive()
8051 {
8052 return false;
8053 }
8054
8056 {
8057 return "";
8058 }
8059
8061
8062 bool IsLightSource()
8063 {
8064 return false;
8065 }
8066
8068 {
8069 return true;
8070 }
8071
8072 //--- ACTION CONDITIONS
8073 //direction
8074 bool IsFacingPlayer(PlayerBase player, string selection)
8075 {
8076 return true;
8077 }
8078
8079 bool IsPlayerInside(PlayerBase player, string selection)
8080 {
8081 return true;
8082 }
8083
8084 override bool CanObstruct()
8085 {
8086 PlayerBase player = PlayerBase.Cast(g_Game.GetPlayer());
8087 return !player || !IsPlayerInside(player, "");
8088 }
8089
8090 override bool IsBeingPlaced()
8091 {
8092 return m_IsBeingPlaced;
8093 }
8094
8095 void SetIsBeingPlaced(bool is_being_placed)
8096 {
8097 m_IsBeingPlaced = is_being_placed;
8098 if (!is_being_placed)
8100 SetSynchDirty();
8101 }
8102
8103 //server-side
8104 void OnEndPlacement() {}
8105
8106 override bool IsHologram()
8107 {
8108 return m_IsHologram;
8109 }
8110
8111 bool CanBeDigged()
8112 {
8113 return m_CanBeDigged;
8114 }
8115
8117 {
8118 return 1;
8119 }
8120
8121 bool CanMakeGardenplot()
8122 {
8123 return false;
8124 }
8125
8126 void SetIsHologram(bool is_hologram)
8127 {
8128 m_IsHologram = is_hologram;
8129 SetSynchDirty();
8130 }
8131 /*
8132 protected float GetNutritionalEnergy()
8133 {
8134 Edible_Base edible = Edible_Base.Cast(this);
8135 return edible.GetFoodEnergy();
8136 }
8137
8138 protected float GetNutritionalWaterContent()
8139 {
8140 Edible_Base edible = Edible_Base.Cast(this);
8141 return edible.GetFoodWater();
8142 }
8143
8144 protected float GetNutritionalIndex()
8145 {
8146 Edible_Base edible = Edible_Base.Cast(this);
8147 return edible.GetFoodNutritionalIndex();
8148 }
8149
8150 protected float GetNutritionalFullnessIndex()
8151 {
8152 Edible_Base edible = Edible_Base.Cast(this);
8153 return edible.GetFoodTotalVolume();
8154 }
8155
8156 protected float GetNutritionalToxicity()
8157 {
8158 Edible_Base edible = Edible_Base.Cast(this);
8159 return edible.GetFoodToxicity();
8160
8161 }
8162 */
8163
8164
8165 // -------------------------------------------------------------------------
8166 override void OnMovedInsideCargo(EntityAI container)
8167 {
8168 super.OnMovedInsideCargo(container);
8169
8170 MiscGameplayFunctions.RemoveAllAttachedChildrenByTypename(this, {Bolt_Base});
8171 }
8172
8173 override void EEItemLocationChanged(notnull InventoryLocation oldLoc, notnull InventoryLocation newLoc)
8174 {
8175 super.EEItemLocationChanged(oldLoc,newLoc);
8176
8177 PlayerBase new_player = null;
8178 PlayerBase old_player = null;
8179
8180 if (newLoc.GetParent())
8181 new_player = PlayerBase.Cast(newLoc.GetParent().GetHierarchyRootPlayer());
8182
8183 if (oldLoc.GetParent())
8184 old_player = PlayerBase.Cast(oldLoc.GetParent().GetHierarchyRootPlayer());
8185
8186 if (old_player && oldLoc.GetType() == InventoryLocationType.HANDS)
8187 {
8188 int r_index = old_player.GetHumanInventory().FindUserReservedLocationIndex(this);
8189
8190 if (r_index >= 0)
8191 {
8192 InventoryLocation r_il = new InventoryLocation;
8193 old_player.GetHumanInventory().GetUserReservedLocation(r_index,r_il);
8194
8195 old_player.GetHumanInventory().ClearUserReservedLocationAtIndex(r_index);
8196 int r_type = r_il.GetType();
8197 if (r_type == InventoryLocationType.CARGO || r_type == InventoryLocationType.PROXYCARGO)
8198 {
8199 r_il.GetParent().GetOnReleaseLock().Invoke(this);
8200 }
8201 else if (r_type == InventoryLocationType.ATTACHMENT)
8202 {
8203 r_il.GetParent().GetOnAttachmentReleaseLock().Invoke(this, r_il.GetSlot());
8204 }
8205
8206 }
8207 }
8208
8209 if (newLoc.GetType() == InventoryLocationType.HANDS)
8210 {
8211 if (new_player)
8212 new_player.ForceStandUpForHeavyItems(newLoc.GetItem());
8213
8214 if (new_player == old_player)
8215 {
8216
8217 if (oldLoc.GetParent() && new_player.GetHumanInventory().LocationGetEntity(oldLoc) == NULL)
8218 {
8219 if (oldLoc.GetType() == InventoryLocationType.CARGO)
8220 {
8221 if (oldLoc.GetParent().GetInventory().TestAddEntityInCargoExLoc(oldLoc, false, false, false, true, false, false))
8222 {
8223 new_player.GetHumanInventory().SetUserReservedLocation(this,oldLoc);
8224 }
8225 }
8226 else
8227 {
8228 new_player.GetHumanInventory().SetUserReservedLocation(this,oldLoc);
8229 }
8230 }
8231
8232 if (new_player.GetHumanInventory().FindUserReservedLocationIndex(this) >= 0)
8233 {
8234 int type = oldLoc.GetType();
8235 if (type == InventoryLocationType.CARGO || type == InventoryLocationType.PROXYCARGO)
8236 {
8237 oldLoc.GetParent().GetOnSetLock().Invoke(this);
8238 }
8239 else if (type == InventoryLocationType.ATTACHMENT)
8240 {
8241 oldLoc.GetParent().GetOnAttachmentSetLock().Invoke(this, oldLoc.GetSlot());
8242 }
8243 }
8244 if (!m_OldLocation)
8245 {
8246 m_OldLocation = new InventoryLocation;
8247 }
8248 m_OldLocation.Copy(oldLoc);
8249 }
8250 else
8251 {
8252 if (m_OldLocation)
8253 {
8254 m_OldLocation.Reset();
8255 }
8256 }
8257
8259 }
8260 else
8261 {
8262 if (new_player)
8263 {
8264 int res_index = new_player.GetHumanInventory().FindCollidingUserReservedLocationIndex(this, newLoc);
8265 if (res_index >= 0)
8266 {
8267 InventoryLocation il = new InventoryLocation;
8268 new_player.GetHumanInventory().GetUserReservedLocation(res_index,il);
8269 ItemBase it = ItemBase.Cast(il.GetItem());
8270 new_player.GetHumanInventory().ClearUserReservedLocationAtIndex(res_index);
8271 int rel_type = il.GetType();
8272 if (rel_type == InventoryLocationType.CARGO || rel_type == InventoryLocationType.PROXYCARGO)
8273 {
8274 il.GetParent().GetOnReleaseLock().Invoke(it);
8275 }
8276 else if (rel_type == InventoryLocationType.ATTACHMENT)
8277 {
8278 il.GetParent().GetOnAttachmentReleaseLock().Invoke(it, il.GetSlot());
8279 }
8280 //it.GetOnReleaseLock().Invoke(it);
8281 }
8282 }
8283 else if (old_player && newLoc.GetType() == InventoryLocationType.GROUND && m_ThrowItemOnDrop)
8284 {
8285 //ThrowPhysically(old_player, vector.Zero);
8286 m_ThrowItemOnDrop = false;
8287 }
8288
8289 if (m_OldLocation)
8290 {
8291 m_OldLocation.Reset();
8292 }
8293 }
8294 }
8295
8296 override void EOnContact(IEntity other, Contact extra)
8297 {
8299 {
8300 int liquidType = -1;
8301 float impactSpeed = ProcessImpactSoundEx(other, extra, m_ConfigWeight, m_ImpactSoundSurfaceHash, liquidType);
8302 if (impactSpeed > 0.0)
8303 {
8304 m_ImpactSpeed = impactSpeed;
8305 #ifndef SERVER
8306 PlayImpactSound(m_ConfigWeight, m_ImpactSpeed, m_ImpactSoundSurfaceHash);
8307 #else
8308 m_WantPlayImpactSound = true;
8309 SetSynchDirty();
8310 #endif
8311 m_CanPlayImpactSound = (liquidType == -1);// prevents further playing of the sound when the surface is a liquid type
8312 }
8313 }
8314
8315 #ifdef SERVER
8316 if (GetCompEM() && GetCompEM().IsPlugged())
8317 {
8318 if (GetCompEM().GetCordLength() < vector.Distance(GetPosition(), GetCompEM().GetEnergySource().GetPosition()))
8319 GetCompEM().UnplugThis();
8320 }
8321 #endif
8322 }
8323
8324 void RefreshPhysics();
8325
8326 override void OnCreatePhysics()
8327 {
8329 }
8330
8331 override void OnItemAttachmentSlotChanged(notnull InventoryLocation oldLoc, notnull InventoryLocation newLoc)
8332 {
8333
8334 }
8335 // -------------------------------------------------------------------------
8336 override void OnItemLocationChanged(EntityAI old_owner, EntityAI new_owner)
8337 {
8338 super.OnItemLocationChanged(old_owner, new_owner);
8339
8340 PlayerBase relatedPlayer = PlayerBase.Cast(old_owner);
8341 PlayerBase playerNew = PlayerBase.Cast(new_owner);
8342
8343 if (!relatedPlayer && playerNew)
8344 relatedPlayer = playerNew;
8345
8346 if (relatedPlayer && relatedPlayer.GetPerformedActionID() != -1)
8347 {
8348 ActionManagerBase actionMgr = relatedPlayer.GetActionManager();
8349 if (actionMgr)
8350 {
8351 ActionBase currentAction = actionMgr.GetRunningAction();
8352 if (currentAction)
8353 currentAction.OnItemLocationChanged(this);
8354 }
8355 }
8356
8357 Man ownerPlayerOld = null;
8358 Man ownerPlayerNew = null;
8359
8360 if (old_owner)
8361 {
8362 if (old_owner.IsMan())
8363 {
8364 ownerPlayerOld = Man.Cast(old_owner);
8365 }
8366 else
8367 {
8368 ownerPlayerOld = Man.Cast(old_owner.GetHierarchyRootPlayer());
8369 }
8370 }
8371 else
8372 {
8373 if (new_owner && IsElectricAppliance() && GetCompEM() && GetCompEM().IsPlugged())
8374 {
8375 ActionBase action = ActionManagerBase.GetAction(ActionRepositionPluggedItem);
8376
8377 if (!action || !playerNew || playerNew.GetPerformedActionID() != action.GetID())
8378 {
8379 GetCompEM().UnplugThis();
8380 }
8381 }
8382 }
8383
8384 if (new_owner)
8385 {
8386 if (new_owner.IsMan())
8387 {
8388 ownerPlayerNew = Man.Cast(new_owner);
8389 }
8390 else
8391 {
8392 ownerPlayerNew = Man.Cast(new_owner.GetHierarchyRootPlayer());
8393 }
8394 }
8395
8396 if (ownerPlayerOld != ownerPlayerNew)
8397 {
8398 if (ownerPlayerOld)
8399 {
8400 array<EntityAI> subItemsExit = new array<EntityAI>;
8401 GetInventory().EnumerateInventory(InventoryTraversalType.PREORDER,subItemsExit);
8402 for (int i = 0; i < subItemsExit.Count(); i++)
8403 {
8404 ItemBase itemExit = ItemBase.Cast(subItemsExit.Get(i));
8405 itemExit.OnInventoryExit(ownerPlayerOld);
8406 }
8407 }
8408
8409 if (ownerPlayerNew)
8410 {
8411 array<EntityAI> subItemsEnter = new array<EntityAI>;
8412 GetInventory().EnumerateInventory(InventoryTraversalType.PREORDER,subItemsEnter);
8413 for (int j = 0; j < subItemsEnter.Count(); j++)
8414 {
8415 ItemBase itemEnter = ItemBase.Cast(subItemsEnter.Get(j));
8416 itemEnter.OnInventoryEnter(ownerPlayerNew);
8417 }
8418 }
8419 }
8420 else if (ownerPlayerNew != null)
8421 {
8422 PlayerBase nplayer;
8423 if (PlayerBase.CastTo(nplayer, ownerPlayerNew))
8424 {
8425 array<EntityAI> subItemsUpdate = new array<EntityAI>;
8426 GetInventory().EnumerateInventory(InventoryTraversalType.PREORDER,subItemsUpdate);
8427 for (int k = 0; k < subItemsUpdate.Count(); k++)
8428 {
8429 ItemBase itemUpdate = ItemBase.Cast(subItemsUpdate.Get(k));
8430 itemUpdate.UpdateQuickbarShortcutVisibility(nplayer);
8431 }
8432 }
8433 }
8434
8435 if (old_owner)
8436 old_owner.OnChildItemRemoved(this);
8437 if (new_owner)
8438 new_owner.OnChildItemReceived(this);
8439 }
8440
8441 // -------------------------------------------------------------------------------
8442 override void EEDelete(EntityAI parent)
8443 {
8444 super.EEDelete(parent);
8445 PlayerBase player = PlayerBase.Cast(GetHierarchyRootPlayer());
8446 if (player)
8447 {
8448 OnInventoryExit(player);
8449
8450 if (player.IsAlive())
8451 {
8452 int r_index = player.GetHumanInventory().FindUserReservedLocationIndex(this);
8453 if (r_index >= 0)
8454 {
8455 InventoryLocation r_il = new InventoryLocation;
8456 player.GetHumanInventory().GetUserReservedLocation(r_index,r_il);
8457
8458 player.GetHumanInventory().ClearUserReservedLocationAtIndex(r_index);
8459 int r_type = r_il.GetType();
8460 if (r_type == InventoryLocationType.CARGO || r_type == InventoryLocationType.PROXYCARGO)
8461 {
8462 r_il.GetParent().GetOnReleaseLock().Invoke(this);
8463 }
8464 else if (r_type == InventoryLocationType.ATTACHMENT)
8465 {
8466 r_il.GetParent().GetOnAttachmentReleaseLock().Invoke(this, r_il.GetSlot());
8467 }
8468
8469 }
8470
8471 player.RemoveQuickBarEntityShortcut(this);
8472 }
8473 }
8474 }
8475 // -------------------------------------------------------------------------------
8476 override void EEKilled(Object killer)
8477 {
8478 super.EEKilled(killer);
8479
8481 if (killer && killer.IsFireplace() && CanExplodeInFire())
8482 {
8483 if (GetTemperature() >= GameConstants.ITEM_TEMPERATURE_TO_EXPLODE_MIN)
8484 {
8485 if (IsMagazine())
8486 {
8487 if (Magazine.Cast(this).GetAmmoCount() > 0)
8488 {
8489 ExplodeAmmo();
8490 }
8491 }
8492 else
8493 {
8494 Explode(DamageType.EXPLOSION);
8495 }
8496 }
8497 }
8498 }
8499
8500 override void OnWasAttached(EntityAI parent, int slot_id)
8501 {
8502 MiscGameplayFunctions.RemoveAllAttachedChildrenByTypename(this, {Bolt_Base});
8503
8504 super.OnWasAttached(parent, slot_id);
8505
8506 if (HasQuantity())
8507 UpdateNetSyncVariableFloat("m_VarQuantity", GetQuantityMin(), m_VarQuantityMax);
8508
8509 PlayAttachSound(InventorySlots.GetSlotName(slot_id));
8510 }
8511
8512 override void OnWasDetached(EntityAI parent, int slot_id)
8513 {
8514 super.OnWasDetached(parent, slot_id);
8515
8516 if (HasQuantity())
8517 UpdateNetSyncVariableFloat("m_VarQuantity", GetQuantityMin(), m_VarQuantityMax);
8518 }
8519
8520 override string ChangeIntoOnAttach(string slot)
8521 {
8522 int idx;
8523 TStringArray inventory_slots = new TStringArray;
8524 TStringArray attach_types = new TStringArray;
8525
8526 ConfigGetTextArray("ChangeInventorySlot",inventory_slots);
8527 if (inventory_slots.Count() < 1) //is string
8528 {
8529 inventory_slots.Insert(ConfigGetString("ChangeInventorySlot"));
8530 attach_types.Insert(ConfigGetString("ChangeIntoOnAttach"));
8531 }
8532 else //is array
8533 {
8534 ConfigGetTextArray("ChangeIntoOnAttach",attach_types);
8535 }
8536
8537 idx = inventory_slots.Find(slot);
8538 if (idx < 0)
8539 return "";
8540
8541 return attach_types.Get(idx);
8542 }
8543
8544 override string ChangeIntoOnDetach()
8545 {
8546 int idx = -1;
8547 string slot;
8548
8549 TStringArray inventory_slots = new TStringArray;
8550 TStringArray detach_types = new TStringArray;
8551
8552 this.ConfigGetTextArray("ChangeInventorySlot",inventory_slots);
8553 if (inventory_slots.Count() < 1) //is string
8554 {
8555 inventory_slots.Insert(this.ConfigGetString("ChangeInventorySlot"));
8556 detach_types.Insert(this.ConfigGetString("ChangeIntoOnDetach"));
8557 }
8558 else //is array
8559 {
8560 this.ConfigGetTextArray("ChangeIntoOnDetach",detach_types);
8561 if (detach_types.Count() < 1)
8562 detach_types.Insert(this.ConfigGetString("ChangeIntoOnDetach"));
8563 }
8564
8565 for (int i = 0; i < inventory_slots.Count(); i++)
8566 {
8567 slot = inventory_slots.Get(i);
8568 }
8569
8570 if (slot != "")
8571 {
8572 if (detach_types.Count() == 1)
8573 idx = 0;
8574 else
8575 idx = inventory_slots.Find(slot);
8576 }
8577 if (idx < 0)
8578 return "";
8579
8580 return detach_types.Get(idx);
8581 }
8582
8583 void ExplodeAmmo()
8584 {
8585 //timer
8586 ref Timer explode_timer = new Timer(CALL_CATEGORY_SYSTEM);
8587
8588 //min/max time
8589 float min_time = 1;
8590 float max_time = 3;
8591 float delay = Math.RandomFloat(min_time, max_time);
8592
8593 explode_timer.Run(delay, this, "DoAmmoExplosion");
8594 }
8595
8596 void DoAmmoExplosion()
8597 {
8598 Magazine magazine = Magazine.Cast(this);
8599 int pop_sounds_count = 6;
8600 string pop_sounds[ 6 ] = { "ammopops_1","ammopops_2","ammopops_3","ammopops_4","ammopops_5","ammopops_6" };
8601
8602 //play sound
8603 int sound_idx = Math.RandomInt(0, pop_sounds_count - 1);
8604 string sound_name = pop_sounds[ sound_idx ];
8605 GetGame().CreateSoundOnObject(this, sound_name, 20, false);
8606
8607 //remove ammo count
8608 magazine.ServerAddAmmoCount(-1);
8609
8610 //if condition then repeat -> ExplodeAmmo
8611 float min_temp_to_explode = 100; //min temperature for item to explode
8612
8613 if (magazine.GetAmmoCount() > 0 && GetTemperature() >= min_temp_to_explode) //TODO ? add check for parent -> fireplace
8614 {
8615 ExplodeAmmo();
8616 }
8617 }
8618
8619 // -------------------------------------------------------------------------------
8620 override void EEHitBy(TotalDamageResult damageResult, int damageType, EntityAI source, int component, string dmgZone, string ammo, vector modelPos, float speedCoef)
8621 {
8622 super.EEHitBy(damageResult, damageType, source, component, dmgZone, ammo, modelPos, speedCoef);
8623
8624 const int CHANCE_DAMAGE_CARGO = 4;
8625 const int CHANCE_DAMAGE_ATTACHMENT = 1;
8626 const int CHANCE_DAMAGE_NOTHING = 2;
8627
8628 if (IsClothing() || IsContainer() || IsItemTent())
8629 {
8630 float dmg = damageResult.GetDamage("","Health") * -0.5;
8631 int chances;
8632 int rnd;
8633
8634 if (GetInventory().GetCargo())
8635 {
8636 chances = CHANCE_DAMAGE_CARGO + CHANCE_DAMAGE_ATTACHMENT + CHANCE_DAMAGE_NOTHING;
8637 rnd = Math.RandomInt(0,chances);
8638
8639 if (rnd < CHANCE_DAMAGE_CARGO)
8640 {
8641 DamageItemInCargo(dmg);
8642 }
8643 else if (rnd < (chances - CHANCE_DAMAGE_NOTHING))
8644 {
8646 }
8647 }
8648 else
8649 {
8650 chances = CHANCE_DAMAGE_ATTACHMENT + CHANCE_DAMAGE_NOTHING;
8651 rnd = Math.RandomInt(0,chances);
8652
8653 if (rnd < CHANCE_DAMAGE_ATTACHMENT)
8654 {
8656 }
8657 }
8658 }
8659 }
8660
8661 bool DamageItemInCargo(float damage)
8662 {
8663 if (GetInventory().GetCargo())
8664 {
8665 int item_count = GetInventory().GetCargo().GetItemCount();
8666 if (item_count > 0)
8667 {
8668 int random_pick = Math.RandomInt(0, item_count);
8669 ItemBase item = ItemBase.Cast(GetInventory().GetCargo().GetItem(random_pick));
8670 if (!item.IsExplosive())
8671 {
8672 item.AddHealth("","",damage);
8673 return true;
8674 }
8675 }
8676 }
8677 return false;
8678 }
8679
8680 bool DamageItemAttachments(float damage)
8681 {
8682 int attachment_count = GetInventory().AttachmentCount();
8683 if (attachment_count > 0)
8684 {
8685 int random_pick = Math.RandomInt(0, attachment_count);
8686 ItemBase attachment = ItemBase.Cast(GetInventory().GetAttachmentFromIndex(random_pick));
8687 if (!attachment.IsExplosive())
8688 {
8689 attachment.AddHealth("","",damage);
8690 return true;
8691 }
8692 }
8693 return false;
8694 }
8695
8696 override bool IsSplitable()
8697 {
8698 return m_CanThisBeSplit;
8699 }
8700 //----------------
8701 override bool CanBeSplit()
8702 {
8703 if (IsSplitable() && (GetQuantity() > 1))
8704 return GetInventory().CanRemoveEntity();
8705
8706 return false;
8707 }
8708
8709 protected bool ShouldSplitQuantity(float quantity)
8710 {
8711 // don't call 'CanBeSplit' here, too strict and will introduce a freeze-crash when dismantling fence with a fireplace nearby
8712 if (!IsSplitable())
8713 return false;
8714
8715 // nothing to split?
8716 if (GetQuantity() <= 1)
8717 return false;
8718
8719 // check if we should re-use the item instead of creating a new copy?
8720 // implicit cast to int, if 'IsSplitable' returns true, these values are assumed ints
8721 int delta = GetQuantity() - quantity;
8722 if (delta == 0)
8723 return false;
8724
8725 // valid to split
8726 return true;
8727 }
8728
8729 override void SplitIntoStackMaxClient(EntityAI destination_entity, int slot_id )
8730 {
8731 if (GetGame().IsClient())
8732 {
8733 if (ScriptInputUserData.CanStoreInputUserData())
8734 {
8735 ScriptInputUserData ctx = new ScriptInputUserData;
8737 ctx.Write(1);
8738 ItemBase i1 = this; // @NOTE: workaround for correct serialization
8739 ctx.Write(i1);
8740 ctx.Write(destination_entity);
8741 ctx.Write(true);
8742 ctx.Write(slot_id);
8743 ctx.Send();
8744 }
8745 }
8746 else if (!GetGame().IsMultiplayer())
8747 {
8748 SplitIntoStackMax(destination_entity, slot_id, PlayerBase.Cast(GetGame().GetPlayer()));
8749 }
8750 }
8751
8752 void SplitIntoStackMax(EntityAI destination_entity, int slot_id, PlayerBase player)
8753 {
8754 float split_quantity_new;
8755 ItemBase new_item;
8756 float quantity = GetQuantity();
8757 float stack_max = GetTargetQuantityMax(slot_id);
8758 InventoryLocation loc = new InventoryLocation;
8759
8760 if (destination_entity && slot_id != -1 && InventorySlots.IsSlotIdValid(slot_id))
8761 {
8762 if (stack_max <= GetQuantity())
8763 split_quantity_new = stack_max;
8764 else
8765 split_quantity_new = GetQuantity();
8766
8767 if (ShouldSplitQuantity(split_quantity_new))
8768 {
8769 new_item = ItemBase.Cast(destination_entity.GetInventory().CreateAttachmentEx(this.GetType(), slot_id));
8770 if (new_item)
8771 {
8772 new_item.SetResultOfSplit(true);
8773 MiscGameplayFunctions.TransferItemProperties(this, new_item);
8774 AddQuantity(-split_quantity_new, false, true);
8775 new_item.SetQuantity(split_quantity_new, false, true);
8776 }
8777 }
8778 }
8779 else if (destination_entity && slot_id == -1)
8780 {
8781 if (quantity > stack_max)
8782 split_quantity_new = stack_max;
8783 else
8784 split_quantity_new = quantity;
8785
8786 if (ShouldSplitQuantity(split_quantity_new))
8787 {
8788 if (destination_entity.GetInventory().FindFreeLocationFor(this, FindInventoryLocationType.ANY, loc))
8789 {
8790 Object o = destination_entity.GetInventory().LocationCreateEntity(loc, GetType(), ECE_IN_INVENTORY, RF_DEFAULT);
8791 new_item = ItemBase.Cast(o);
8792 }
8793
8794 if (new_item)
8795 {
8796 new_item.SetResultOfSplit(true);
8797 MiscGameplayFunctions.TransferItemProperties(this, new_item);
8798 AddQuantity(-split_quantity_new, false, true);
8799 new_item.SetQuantity(split_quantity_new, false, true);
8800 }
8801 }
8802 }
8803 else
8804 {
8805 if (stack_max != 0)
8806 {
8807 if (stack_max < GetQuantity())
8808 {
8809 split_quantity_new = GetQuantity() - stack_max;
8810 }
8811
8812 if (split_quantity_new == 0)
8813 {
8814 if (!GetGame().IsMultiplayer())
8815 player.PhysicalPredictiveDropItem(this);
8816 else
8817 player.ServerDropEntity(this);
8818 return;
8819 }
8820
8821 if (ShouldSplitQuantity(split_quantity_new))
8822 {
8823 new_item = ItemBase.Cast(GetGame().CreateObjectEx(GetType(), player.GetWorldPosition(), ECE_PLACE_ON_SURFACE));
8824
8825 if (new_item)
8826 {
8827 new_item.SetResultOfSplit(true);
8828 MiscGameplayFunctions.TransferItemProperties(this, new_item);
8829 SetQuantity(split_quantity_new, false, true);
8830 new_item.SetQuantity(stack_max, false, true);
8831 new_item.PlaceOnSurface();
8832 }
8833 }
8834 }
8835 }
8836 }
8837
8838 override void SplitIntoStackMaxEx(EntityAI destination_entity, int slot_id)
8839 {
8840 float split_quantity_new;
8841 ItemBase new_item;
8842 float quantity = GetQuantity();
8843 float stack_max = GetTargetQuantityMax(slot_id);
8844 InventoryLocation loc = new InventoryLocation;
8845
8846 if (destination_entity && slot_id != -1 && InventorySlots.IsSlotIdValid(slot_id))
8847 {
8848 if (stack_max <= GetQuantity())
8849 split_quantity_new = stack_max;
8850 else
8851 split_quantity_new = GetQuantity();
8852
8853 if (ShouldSplitQuantity(split_quantity_new))
8854 {
8855 new_item = ItemBase.Cast(destination_entity.GetInventory().CreateAttachmentEx(this.GetType(), slot_id));
8856 if (new_item)
8857 {
8858 new_item.SetResultOfSplit(true);
8859 MiscGameplayFunctions.TransferItemProperties(this, new_item);
8860 AddQuantity(-split_quantity_new, false, true);
8861 new_item.SetQuantity(split_quantity_new, false, true);
8862 }
8863 }
8864 }
8865 else if (destination_entity && slot_id == -1)
8866 {
8867 if (quantity > stack_max)
8868 split_quantity_new = stack_max;
8869 else
8870 split_quantity_new = quantity;
8871
8872 if (ShouldSplitQuantity(split_quantity_new))
8873 {
8874 if (destination_entity.GetInventory().FindFreeLocationFor(this, FindInventoryLocationType.ANY, loc))
8875 {
8876 Object o = destination_entity.GetInventory().LocationCreateEntity(loc, GetType(), ECE_IN_INVENTORY, RF_DEFAULT);
8877 new_item = ItemBase.Cast(o);
8878 }
8879
8880 if (new_item)
8881 {
8882 new_item.SetResultOfSplit(true);
8883 MiscGameplayFunctions.TransferItemProperties(this, new_item);
8884 AddQuantity(-split_quantity_new, false, true);
8885 new_item.SetQuantity(split_quantity_new, false, true);
8886 }
8887 }
8888 }
8889 else
8890 {
8891 if (stack_max != 0)
8892 {
8893 if (stack_max < GetQuantity())
8894 {
8895 split_quantity_new = GetQuantity() - stack_max;
8896 }
8897
8898 if (ShouldSplitQuantity(split_quantity_new))
8899 {
8900 new_item = ItemBase.Cast(GetGame().CreateObjectEx(GetType(),GetWorldPosition(), ECE_PLACE_ON_SURFACE));
8901
8902 if (new_item)
8903 {
8904 new_item.SetResultOfSplit(true);
8905 MiscGameplayFunctions.TransferItemProperties(this, new_item);
8906 SetQuantity(split_quantity_new, false, true);
8907 new_item.SetQuantity(stack_max, false, true);
8908 new_item.PlaceOnSurface();
8909 }
8910 }
8911 }
8912 }
8913 }
8914
8915 void SplitIntoStackMaxToInventoryLocationClient(notnull InventoryLocation dst)
8916 {
8917 if (GetGame().IsClient())
8918 {
8919 if (ScriptInputUserData.CanStoreInputUserData())
8920 {
8921 ScriptInputUserData ctx = new ScriptInputUserData;
8923 ctx.Write(4);
8924 ItemBase thiz = this; // @NOTE: workaround for correct serialization
8925 ctx.Write(thiz);
8926 dst.WriteToContext(ctx);
8927 ctx.Send();
8928 }
8929 }
8930 else if (!GetGame().IsMultiplayer())
8931 {
8933 }
8934 }
8935
8936 void SplitIntoStackMaxCargoClient(EntityAI destination_entity, int idx, int row, int col)
8937 {
8938 if (GetGame().IsClient())
8939 {
8940 if (ScriptInputUserData.CanStoreInputUserData())
8941 {
8942 ScriptInputUserData ctx = new ScriptInputUserData;
8944 ctx.Write(2);
8945 ItemBase dummy = this; // @NOTE: workaround for correct serialization
8946 ctx.Write(dummy);
8947 ctx.Write(destination_entity);
8948 ctx.Write(true);
8949 ctx.Write(idx);
8950 ctx.Write(row);
8951 ctx.Write(col);
8952 ctx.Send();
8953 }
8954 }
8955 else if (!GetGame().IsMultiplayer())
8956 {
8957 SplitIntoStackMaxCargo(destination_entity, idx, row, col);
8958 }
8959 }
8960
8961 void SplitIntoStackMaxToInventoryLocation(notnull InventoryLocation dst)
8962 {
8964 }
8965
8966 ItemBase SplitIntoStackMaxToInventoryLocationEx(notnull InventoryLocation dst)
8967 {
8968 float quantity = GetQuantity();
8969 float split_quantity_new;
8970 ItemBase new_item;
8971 if (dst.IsValid())
8972 {
8973 int slot_id = dst.GetSlot();
8974 float stack_max = GetTargetQuantityMax(slot_id);
8975
8976 if (quantity > stack_max)
8977 split_quantity_new = stack_max;
8978 else
8979 split_quantity_new = quantity;
8980
8981 if (ShouldSplitQuantity(split_quantity_new))
8982 {
8983 new_item = ItemBase.Cast(GameInventory.LocationCreateEntity(dst, this.GetType(), ECE_IN_INVENTORY, RF_DEFAULT));
8984
8985 if (new_item)
8986 {
8987 new_item.SetResultOfSplit(true);
8988 MiscGameplayFunctions.TransferItemProperties(this,new_item);
8989 AddQuantity(-split_quantity_new, false, true);
8990 new_item.SetQuantity(split_quantity_new, false, true);
8991 }
8992
8993 return new_item;
8994 }
8995 }
8996
8997 return null;
8998 }
8999
9000 void SplitIntoStackMaxCargo(EntityAI destination_entity, int idx, int row, int col)
9001 {
9002 float quantity = GetQuantity();
9003 float split_quantity_new;
9004 ItemBase new_item;
9005 if (destination_entity)
9006 {
9007 float stackable = GetTargetQuantityMax();
9008 if (quantity > stackable)
9009 split_quantity_new = stackable;
9010 else
9011 split_quantity_new = quantity;
9012
9013 if (ShouldSplitQuantity(split_quantity_new))
9014 {
9015 new_item = ItemBase.Cast(destination_entity.GetInventory().CreateEntityInCargoEx(this.GetType(), idx, row, col, false));
9016 if (new_item)
9017 {
9018 new_item.SetResultOfSplit(true);
9019 MiscGameplayFunctions.TransferItemProperties(this,new_item);
9020 AddQuantity(-split_quantity_new, false, true);
9021 new_item.SetQuantity(split_quantity_new, false, true);
9022 }
9023 }
9024 }
9025 }
9026
9027 void SplitIntoStackMaxHandsClient(PlayerBase player)
9028 {
9029 if (GetGame().IsClient())
9030 {
9031 if (ScriptInputUserData.CanStoreInputUserData())
9032 {
9033 ScriptInputUserData ctx = new ScriptInputUserData;
9035 ctx.Write(3);
9036 ItemBase i1 = this; // @NOTE: workaround for correct serialization
9037 ctx.Write(i1);
9038 ItemBase destination_entity = this;
9039 ctx.Write(destination_entity);
9040 ctx.Write(true);
9041 ctx.Write(0);
9042 ctx.Send();
9043 }
9044 }
9045 else if (!GetGame().IsMultiplayer())
9046 {
9047 SplitIntoStackMaxHands(player);
9048 }
9049 }
9050
9051 void SplitIntoStackMaxHands(PlayerBase player)
9052 {
9053 float quantity = GetQuantity();
9054 float split_quantity_new;
9055 ref ItemBase new_item;
9056 if (player)
9057 {
9058 float stackable = GetTargetQuantityMax();
9059 if (quantity > stackable)
9060 split_quantity_new = stackable;
9061 else
9062 split_quantity_new = quantity;
9063
9064 if (ShouldSplitQuantity(split_quantity_new))
9065 {
9066 EntityAI in_hands = player.GetHumanInventory().CreateInHands(this.GetType());
9067 new_item = ItemBase.Cast(in_hands);
9068 if (new_item)
9069 {
9070 new_item.SetResultOfSplit(true);
9071 MiscGameplayFunctions.TransferItemProperties(this,new_item);
9072 AddQuantity(-split_quantity_new, false, true);
9073 new_item.SetQuantity(split_quantity_new, false, true);
9074 }
9075 }
9076 }
9077 }
9078
9079 void SplitItemToInventoryLocation(notnull InventoryLocation dst)
9080 {
9081 float quantity = GetQuantity();
9082 float split_quantity_new = Math.Floor(quantity * 0.5);
9083
9084 if (!ShouldSplitQuantity(split_quantity_new))
9085 return;
9086
9087 ItemBase new_item = ItemBase.Cast(GameInventory.LocationCreateEntity(dst, GetType(), ECE_IN_INVENTORY, RF_DEFAULT));
9088
9089 if (new_item)
9090 {
9091 if (new_item.GetQuantityMax() < split_quantity_new)
9092 {
9093 split_quantity_new = new_item.GetQuantityMax();
9094 }
9095
9096 new_item.SetResultOfSplit(true);
9097 MiscGameplayFunctions.TransferItemProperties(this, new_item);
9098
9099 if (dst.IsValid() && dst.GetType() == InventoryLocationType.ATTACHMENT && split_quantity_new > 1)
9100 {
9101 AddQuantity(-1, false, true);
9102 new_item.SetQuantity(1, false, true);
9103 }
9104 else
9105 {
9106 AddQuantity(-split_quantity_new, false, true);
9107 new_item.SetQuantity(split_quantity_new, false, true);
9108 }
9109 }
9110 }
9111
9112 void SplitItem(PlayerBase player)
9113 {
9114 float quantity = GetQuantity();
9115 float split_quantity_new = Math.Floor(quantity / 2);
9116
9117 if (!ShouldSplitQuantity(split_quantity_new))
9118 return;
9119
9120 InventoryLocation invloc = new InventoryLocation;
9121 bool found = player.GetInventory().FindFirstFreeLocationForNewEntity(GetType(), FindInventoryLocationType.ATTACHMENT, invloc);
9122
9123 ItemBase new_item;
9124 new_item = player.CreateCopyOfItemInInventoryOrGroundEx(this, true);
9125
9126 if (new_item)
9127 {
9128 if (new_item.GetQuantityMax() < split_quantity_new)
9129 {
9130 split_quantity_new = new_item.GetQuantityMax();
9131 }
9132 if (found && invloc.IsValid() && invloc.GetType() == InventoryLocationType.ATTACHMENT && split_quantity_new > 1)
9133 {
9134 AddQuantity(-1, false, true);
9135 new_item.SetQuantity(1, false, true);
9136 }
9137 else if (split_quantity_new > 1)
9138 {
9139 AddQuantity(-split_quantity_new, false, true);
9140 new_item.SetQuantity(split_quantity_new, false, true);
9141 }
9142 }
9143 }
9144
9146 void OnQuantityChanged(float delta)
9147 {
9148 SetWeightDirty();
9149 ItemBase parent = ItemBase.Cast(GetHierarchyParent());
9150
9151 if (parent)
9152 parent.OnAttachmentQuantityChangedEx(this, delta);
9153
9154 if (IsLiquidContainer())
9155 {
9156 if (GetQuantityNormalized() <= 0.0)
9157 {
9159 }
9160 else if (GetLiquidType() == LIQUID_NONE)
9161 {
9162 ErrorEx("Undefined liquid type quantity changed, please define liquid type first! Using init value.",ErrorExSeverity.INFO);
9164 }
9165 }
9166
9167 }
9168
9171 {
9172 // insert code here
9173 }
9174
9176 void OnAttachmentQuantityChangedEx(ItemBase item , float delta)
9177 {
9179 }
9180
9181 override void EEHealthLevelChanged(int oldLevel, int newLevel, string zone)
9182 {
9183 super.EEHealthLevelChanged(oldLevel,newLevel,zone);
9184
9185 if (GetGame().IsServer())
9186 {
9187 if (newLevel == GameConstants.STATE_RUINED)
9188 {
9190 EntityAI parent = GetHierarchyParent();
9191 if (parent && parent.IsFireplace())
9192 {
9193 CargoBase cargo = GetInventory().GetCargo();
9194 if (cargo)
9195 {
9196 for (int i = 0; i < cargo.GetItemCount(); ++i)
9197 {
9198 parent.GetInventory().TakeEntityToInventory(InventoryMode.SERVER, FindInventoryLocationType.CARGO, cargo.GetItem(i));
9199 }
9200 }
9201 }
9202 }
9203
9204 if (IsResultOfSplit())
9205 {
9206 // reset the splitting result flag, return to normal item behavior
9207 SetResultOfSplit(false);
9208 return;
9209 }
9210
9211 if (m_Cleanness != 0 && oldLevel < newLevel && newLevel != 0)
9212 {
9213 SetCleanness(0);//unclean the item upon damage dealt
9214 }
9215 }
9216 }
9217
9218 // just the split? TODO: verify
9219 override void OnRightClick()
9220 {
9221 super.OnRightClick();
9222
9223 if (CanBeSplit() && !GetDayZGame().IsLeftCtrlDown() && !GetGame().GetPlayer().GetInventory().HasInventoryReservation(this,null))
9224 {
9225 if (GetGame().IsClient())
9226 {
9227 if (ScriptInputUserData.CanStoreInputUserData())
9228 {
9229 EntityAI root = GetHierarchyRoot();
9230 Man playerOwner = GetHierarchyRootPlayer();
9231 InventoryLocation dst = new InventoryLocation;
9232
9233 // 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
9234 if (!playerOwner && root && root == this)
9235 {
9237 }
9238 else
9239 {
9240 // 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
9241 GetInventory().GetCurrentInventoryLocation(dst);
9242 if (!dst.GetParent() || dst.GetParent() && !dst.GetParent().GetInventory().FindFreeLocationFor(this, FindInventoryLocationType.CARGO, dst))
9243 {
9244 PlayerBase player = PlayerBase.Cast(GetGame().GetPlayer());
9245 if (!player.GetInventory().FindFreeLocationFor(this, FindInventoryLocationType.CARGO, dst) || !playerOwner)
9246 {
9248 }
9249 else
9250 {
9251 dst.SetCargo(dst.GetParent(), this, dst.GetIdx(), dst.GetRow(), dst.GetCol(), dst.GetFlip());
9252 /* hacky solution to check reservation of "this" item instead of null since the gamecode is checking null against null and returning reservation=true incorrectly
9253 this shouldnt cause issues within this scope*/
9254 if (GetGame().GetPlayer().GetInventory().HasInventoryReservation(this, dst))
9255 {
9257 }
9258 else
9259 {
9260 GetGame().GetPlayer().GetInventory().AddInventoryReservationEx(null, dst, GameInventory.c_InventoryReservationTimeoutShortMS);
9261 }
9262 }
9263 }
9264 }
9265
9266 ScriptInputUserData ctx = new ScriptInputUserData;
9268 ctx.Write(4);
9269 ItemBase thiz = this; // @NOTE: workaround for correct serialization
9270 ctx.Write(thiz);
9271 dst.WriteToContext(ctx);
9272 ctx.Write(true); // dummy
9273 ctx.Send();
9274 }
9275 }
9276 else if (!GetGame().IsMultiplayer())
9277 {
9278 SplitItem(PlayerBase.Cast(GetGame().GetPlayer()));
9279 }
9280 }
9281 }
9282
9283 protected void SetInventoryLocationToVicinityOrCurrent(EntityAI root, inout InventoryLocation dst)
9284 {
9285 if (root)
9286 {
9287 vector m4[4];
9288 root.GetTransform(m4);
9289 dst.SetGround(this, m4);
9290 }
9291 else
9292 {
9293 GetInventory().GetCurrentInventoryLocation(dst);
9294 }
9295 }
9296
9297 override bool CanBeCombined(EntityAI other_item, bool reservation_check = true, bool stack_max_limit = false)
9298 {
9299 //TODO: delete check zero quantity check after fix double posts hands fsm events
9300 if (!other_item || GetType() != other_item.GetType() || (IsFullQuantity() && other_item.GetQuantity() > 0) || other_item == this)
9301 return false;
9302
9303 if (GetHealthLevel() == GameConstants.STATE_RUINED || other_item.GetHealthLevel() == GameConstants.STATE_RUINED)
9304 return false;
9305
9306 //can_this_be_combined = ConfigGetBool("canBeSplit");
9308 return false;
9309
9310
9311 Magazine mag = Magazine.Cast(this);
9312 if (mag)
9313 {
9314 if (mag.GetAmmoCount() >= mag.GetAmmoMax())
9315 return false;
9316
9317 if (stack_max_limit)
9318 {
9319 Magazine other_mag = Magazine.Cast(other_item);
9320 if (other_item)
9321 {
9322 if (mag.GetAmmoCount() + other_mag.GetAmmoCount() > mag.GetAmmoMax())
9323 return false;
9324 }
9325
9326 }
9327 }
9328 else
9329 {
9330 //TODO: delete check zero quantity check after fix double posts hands fsm events
9331 if (GetQuantity() >= GetQuantityMax() && other_item.GetQuantity() > 0 )
9332 return false;
9333
9334 if (stack_max_limit && (GetQuantity() + other_item.GetQuantity() > GetQuantityMax()))
9335 return false;
9336 }
9337
9338 PlayerBase player = null;
9339 if (CastTo(player, GetHierarchyRootPlayer())) //false when attached to player's attachment slot
9340 {
9341 if (player.GetInventory().HasAttachment(this))
9342 return false;
9343
9344 if (player.IsItemsToDelete())
9345 return false;
9346 }
9347
9348 if (reservation_check && (GetInventory().HasInventoryReservation(this, null) || other_item.GetInventory().HasInventoryReservation(other_item, null)))
9349 return false;
9350
9351 int slotID;
9352 string slotName;
9353 if (GetInventory().GetCurrentAttachmentSlotInfo(slotID,slotName) && GetHierarchyParent().GetInventory().GetSlotLock(slotID))
9354 return false;
9355
9356 return true;
9357 }
9358
9359 bool IsCombineAll(ItemBase other_item, bool use_stack_max = false)
9360 {
9361 return ComputeQuantityUsed(other_item, use_stack_max) == other_item.GetQuantity();
9362 }
9363
9364 bool IsResultOfSplit()
9365 {
9366 return m_IsResultOfSplit;
9367 }
9368
9369 void SetResultOfSplit(bool value)
9370 {
9371 m_IsResultOfSplit = value;
9372 }
9373
9374 int ComputeQuantityUsed(ItemBase other_item, bool use_stack_max = true)
9375 {
9376 return ComputeQuantityUsedEx(other_item, use_stack_max);
9377 }
9378
9379 float ComputeQuantityUsedEx(ItemBase other_item, bool use_stack_max = true)
9380 {
9381 float other_item_quantity = other_item.GetQuantity();
9382 float this_free_space;
9383
9384 float stack_max = GetQuantityMax();
9385
9386 this_free_space = stack_max - GetQuantity();
9387
9388 if (other_item_quantity > this_free_space)
9389 {
9390 return this_free_space;
9391 }
9392 else
9393 {
9394 return other_item_quantity;
9395 }
9396 }
9397
9398 override void CombineItemsEx(EntityAI entity2, bool use_stack_max = true)
9399 {
9400 CombineItems(ItemBase.Cast(entity2),use_stack_max);
9401 }
9402
9403 void CombineItems(ItemBase other_item, bool use_stack_max = true)
9404 {
9405 if (!CanBeCombined(other_item, false))
9406 return;
9407
9408 if (!IsMagazine() && other_item)
9409 {
9410 float quantity_used = ComputeQuantityUsedEx(other_item,use_stack_max);
9411 if (quantity_used != 0)
9412 {
9413 float hp1 = GetHealth01("","");
9414 float hp2 = other_item.GetHealth01("","");
9415 float hpResult = ((hp1*GetQuantity()) + (hp2*quantity_used));
9416 hpResult = hpResult / (GetQuantity() + quantity_used);
9417
9418 hpResult *= GetMaxHealth();
9419 Math.Round(hpResult);
9420 SetHealth("", "Health", hpResult);
9421
9422 AddQuantity(quantity_used);
9423 other_item.AddQuantity(-quantity_used);
9424 }
9425 }
9426 OnCombine(other_item);
9427 }
9428
9429 void OnCombine(ItemBase other_item)
9430 {
9431 #ifdef SERVER
9432 if (!GetHierarchyRootPlayer() && GetHierarchyParent())
9433 GetHierarchyParent().IncreaseLifetimeUp();
9434 #endif
9435 };
9436
9437 void GetRecipesActions(Man player, out TSelectableActionInfoArray outputList)
9438 {
9439 PlayerBase p = PlayerBase.Cast(player);
9440
9441 array<int> recipesIds = p.m_Recipes;
9442 PluginRecipesManager moduleRecipesManager = PluginRecipesManager.Cast(GetPlugin(PluginRecipesManager));
9443 if (moduleRecipesManager)
9444 {
9445 EntityAI itemInHands = player.GetHumanInventory().GetEntityInHands();
9446 moduleRecipesManager.GetValidRecipes(ItemBase.Cast(this), ItemBase.Cast(itemInHands), recipesIds, p);
9447 }
9448
9449 for (int i = 0;i < recipesIds.Count(); i++)
9450 {
9451 int key = recipesIds.Get(i);
9452 string recipeName = moduleRecipesManager.GetRecipeName(key);
9453 outputList.Insert(new TSelectableActionInfo(SAT_CRAFTING, key, recipeName));
9454 }
9455 }
9456
9457 // -------------------------------------------------------------------------
9458 override void GetDebugActions(out TSelectableActionInfoArrayEx outputList)
9459 {
9460 super.GetDebugActions(outputList);
9461
9462 //quantity
9463 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.ADD_QUANTITY, "Quantity +20%", FadeColors.LIGHT_GREY));
9464 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.REMOVE_QUANTITY, "Quantity -20%", FadeColors.LIGHT_GREY));
9465 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SET_QUANTITY_0, "Set Quantity 0", FadeColors.LIGHT_GREY));
9466 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SET_MAX_QUANTITY, "Set Quantity Max", FadeColors.LIGHT_GREY));
9467 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SEPARATOR, "___________________________", FadeColors.RED));
9468
9469 //health
9470 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.ADD_HEALTH, "Health +20%", FadeColors.LIGHT_GREY));
9471 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.REMOVE_HEALTH, "Health -20%", FadeColors.LIGHT_GREY));
9472 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.DESTROY_HEALTH, "Health 0", FadeColors.LIGHT_GREY));
9473 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SEPARATOR, "___________________________", FadeColors.RED));
9474 //temperature
9475 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.ADD_TEMPERATURE, "Temperature +20", FadeColors.LIGHT_GREY));
9476 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.REMOVE_TEMPERATURE, "Temperature -20", FadeColors.LIGHT_GREY));
9477 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.FLIP_FROZEN, "Toggle Frozen", FadeColors.LIGHT_GREY));
9478 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SEPARATOR, "___________________________", FadeColors.RED));
9479
9480 //wet
9481 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.ADD_WETNESS, "Wetness +20", FadeColors.LIGHT_GREY));
9482 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.REMOVE_WETNESS, "Wetness -20", FadeColors.LIGHT_GREY));
9483 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SEPARATOR, "___________________________", FadeColors.RED));
9484
9485 //liquidtype
9486 if (IsLiquidContainer())
9487 {
9488 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.LIQUIDTYPE_UP, "LiquidType Next", FadeColors.LIGHT_GREY));
9489 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.LIQUIDTYPE_DOWN, "LiquidType Previous", FadeColors.LIGHT_GREY));
9490 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SEPARATOR, "___________________________", FadeColors.RED));
9491 }
9492
9493 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.MAKE_SPECIAL, "Make Special", FadeColors.LIGHT_GREY));
9494 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SEPARATOR, "___________________________", FadeColors.RED));
9495
9496 // watch
9497 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.WATCH_ITEM, "Watch (CTRL-Z)", FadeColors.LIGHT_GREY));
9498 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.WATCH_PLAYER, "Watch Player", FadeColors.LIGHT_GREY));
9499 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SEPARATOR, "___________________________", FadeColors.RED));
9500
9501 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.DELETE, "Delete", FadeColors.RED));
9502
9503 InventoryLocation loc = new InventoryLocation();
9504 GetInventory().GetCurrentInventoryLocation(loc);
9505 if (!loc || loc.GetType() == InventoryLocationType.GROUND)
9506 {
9507 if (Gizmo_IsSupported())
9508 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.GIZMO_OBJECT, "Gizmo Object", FadeColors.LIGHT_GREY));
9509 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.GIZMO_PHYSICS, "Gizmo Physics (SP Only)", FadeColors.LIGHT_GREY)); // intentionally allowed for testing physics desync
9510 }
9511
9512 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SEPARATOR, "___________________________", FadeColors.RED));
9513 }
9514
9515 // -------------------------------------------------------------------------
9516 // -------------------------------------------------------------------------
9517 // -------------------------------------------------------------------------
9518 override bool OnAction(int action_id, Man player, ParamsReadContext ctx)
9519 {
9520 super.OnAction(action_id, player, ctx);
9521
9522 if (GetGame().IsClient() || !GetGame().IsMultiplayer())
9523 {
9524 switch (action_id)
9525 {
9526 case EActions.GIZMO_OBJECT:
9527 GetGame().GizmoSelectObject(this);
9528 return true;
9529 case EActions.GIZMO_PHYSICS:
9530 GetGame().GizmoSelectPhysics(GetPhysics());
9531 return true;
9532 }
9533 }
9534
9535 if (GetGame().IsServer())
9536 {
9537 switch (action_id)
9538 {
9539 case EActions.DELETE:
9540 Delete();
9541 return true;
9542 }
9543 }
9544
9545 if (action_id >= EActions.RECIPES_RANGE_START && action_id < EActions.RECIPES_RANGE_END)
9546 {
9547 PluginRecipesManager plugin_recipes_manager = PluginRecipesManager.Cast(GetPlugin(PluginRecipesManager));
9548 int idWithoutOffset = action_id - EActions.RECIPES_RANGE_START;
9549 PlayerBase p = PlayerBase.Cast(player);
9550 if (EActions.RECIPES_RANGE_START < 1000)
9551 {
9552 float anim_length = plugin_recipes_manager.GetRecipeLengthInSecs(idWithoutOffset);
9553 float specialty_weight = plugin_recipes_manager.GetRecipeSpecialty(idWithoutOffset);
9554 }
9555 }
9556 #ifndef SERVER
9557 else if (action_id == EActions.WATCH_PLAYER)
9558 {
9559 PluginDeveloper.SetDeveloperItemClientEx(player);
9560 }
9561 #endif
9562 if (GetGame().IsServer())
9563 {
9564 if (action_id >= EActions.DEBUG_ITEM_WATCH_BUTTON_RANGE_START && action_id < EActions.DEBUG_ITEM_WATCH_BUTTON_RANGE_END)
9565 {
9566 int id = action_id - EActions.DEBUG_ITEM_WATCH_BUTTON_RANGE_START;
9567 OnDebugButtonPressServer(id + 1);
9568 }
9569
9570 else if (action_id >= EActions.DEBUG_AGENTS_RANGE_INJECT_START && action_id < EActions.DEBUG_AGENTS_RANGE_INJECT_END)
9571 {
9572 int agent_id = action_id - EActions.DEBUG_AGENTS_RANGE_INJECT_START;
9573 InsertAgent(agent_id,100);
9574 }
9575
9576 else if (action_id >= EActions.DEBUG_AGENTS_RANGE_REMOVE_START && action_id < EActions.DEBUG_AGENTS_RANGE_REMOVE_END)
9577 {
9578 int agent_id2 = action_id - EActions.DEBUG_AGENTS_RANGE_REMOVE_START;
9579 RemoveAgent(agent_id2);
9580 }
9581
9582 else if (action_id == EActions.ADD_QUANTITY)
9583 {
9584 if (IsMagazine())
9585 {
9586 Magazine mag = Magazine.Cast(this);
9587 mag.ServerSetAmmoCount(mag.GetAmmoCount() + mag.GetAmmoMax() * 0.2);
9588 }
9589 else
9590 {
9591 AddQuantity(GetQuantityMax() * 0.2);
9592 }
9593
9594 if (m_EM)
9595 {
9596 m_EM.AddEnergy(m_EM.GetEnergyMax() * 0.2);
9597 }
9598 //PrintVariables();
9599 }
9600
9601 else if (action_id == EActions.REMOVE_QUANTITY) //Quantity -20%
9602 {
9603 if (IsMagazine())
9604 {
9605 Magazine mag2 = Magazine.Cast(this);
9606 mag2.ServerSetAmmoCount(mag2.GetAmmoCount() - mag2.GetAmmoMax() * 0.2);
9607 }
9608 else
9609 {
9610 AddQuantity(- GetQuantityMax() * 0.2);
9611 }
9612 if (m_EM)
9613 {
9614 m_EM.AddEnergy(- m_EM.GetEnergyMax() * 0.2);
9615 }
9616 //PrintVariables();
9617 }
9618
9619 else if (action_id == EActions.SET_QUANTITY_0) //SetMaxQuantity
9620 {
9621 SetQuantity(0);
9622
9623 if (m_EM)
9624 {
9625 m_EM.SetEnergy(0);
9626 }
9627 }
9628
9629 else if (action_id == EActions.SET_MAX_QUANTITY) //SetMaxQuantity
9630 {
9632
9633 if (m_EM)
9634 {
9635 m_EM.SetEnergy(m_EM.GetEnergyMax());
9636 }
9637 }
9638
9639 else if (action_id == EActions.ADD_HEALTH)
9640 {
9641 AddHealth("","",GetMaxHealth("","Health")/5);
9642 }
9643 else if (action_id == EActions.REMOVE_HEALTH)
9644 {
9645 AddHealth("","",-GetMaxHealth("","Health")/5);
9646 }
9647 else if (action_id == EActions.DESTROY_HEALTH)
9648 {
9649 SetHealth01("","",0);
9650 }
9651 else if (action_id == EActions.WATCH_ITEM)
9652 {
9654 mid.RegisterDebugItem(ItemBase.Cast(this), PlayerBase.Cast(player));
9655 #ifdef DEVELOPER
9656 SetDebugDeveloper_item(this);
9657 #endif
9658 }
9659
9660 else if (action_id == EActions.ADD_TEMPERATURE)
9661 {
9662 AddTemperature(20);
9663 //PrintVariables();
9664 }
9665
9666 else if (action_id == EActions.REMOVE_TEMPERATURE)
9667 {
9668 AddTemperature(-20);
9669 //PrintVariables();
9670 }
9671
9672 else if (action_id == EActions.FLIP_FROZEN)
9673 {
9674 SetFrozen(!GetIsFrozen());
9675 //PrintVariables();
9676 }
9677
9678 else if (action_id == EActions.ADD_WETNESS)
9679 {
9680 AddWet(GetWetMax()/5);
9681 //PrintVariables();
9682 }
9683
9684 else if (action_id == EActions.REMOVE_WETNESS)
9685 {
9686 AddWet(-GetWetMax()/5);
9687 //PrintVariables();
9688 }
9689
9690 else if (action_id == EActions.LIQUIDTYPE_UP)
9691 {
9692 int curr_type = GetLiquidType();
9693 SetLiquidType(curr_type * 2);
9694 //AddWet(1);
9695 //PrintVariables();
9696 }
9697
9698 else if (action_id == EActions.LIQUIDTYPE_DOWN)
9699 {
9700 int curr_type2 = GetLiquidType();
9701 SetLiquidType(curr_type2 / 2);
9702 }
9703
9704 else if (action_id == EActions.MAKE_SPECIAL)
9705 {
9706 auto debugParams = DebugSpawnParams.WithPlayer(player);
9707 OnDebugSpawnEx(debugParams);
9708 }
9709
9710 }
9711
9712
9713 return false;
9714 }
9715
9716 // -------------------------------------------------------------------------
9717
9718
9721 void OnActivatedByTripWire();
9722
9724 void OnActivatedByItem(notnull ItemBase item);
9725
9726 //----------------------------------------------------------------
9727 //returns true if item is able to explode when put in fire
9728 bool CanExplodeInFire()
9729 {
9730 return false;
9731 }
9732
9733 //----------------------------------------------------------------
9734 bool CanEat()
9735 {
9736 return true;
9737 }
9738
9739 //----------------------------------------------------------------
9740 override bool IsIgnoredByConstruction()
9741 {
9742 return true;
9743 }
9744
9745 //----------------------------------------------------------------
9746 //has FoodStages in config?
9747 bool HasFoodStage()
9748 {
9749 string config_path = string.Format("CfgVehicles %1 Food FoodStages", GetType());
9750 return GetGame().ConfigIsExisting(config_path);
9751 }
9752
9754 FoodStage GetFoodStage()
9755 {
9756 return null;
9757 }
9758
9759 bool CanBeCooked()
9760 {
9761 return false;
9762 }
9763
9764 bool CanBeCookedOnStick()
9765 {
9766 return false;
9767 }
9768
9770 void RefreshAudioVisualsOnClient( CookingMethodType cooking_method, bool is_done, bool is_empty, bool is_burned );
9772
9773 //----------------------------------------------------------------
9774 bool CanRepair(ItemBase item_repair_kit)
9775 {
9776 PluginRepairing module_repairing = PluginRepairing.Cast(GetPlugin(PluginRepairing));
9777 return module_repairing.CanRepair(this, item_repair_kit);
9778 }
9779
9780 //----------------------------------------------------------------
9781 bool Repair(PlayerBase player, ItemBase item_repair_kit, float specialty_weight)
9782 {
9783 PluginRepairing module_repairing = PluginRepairing.Cast(GetPlugin(PluginRepairing));
9784 return module_repairing.Repair(player, this, item_repair_kit, specialty_weight);
9785 }
9786
9787 //----------------------------------------------------------------
9788 int GetItemSize()
9789 {
9790 /*
9791 vector v_size = this.ConfigGetVector("itemSize");
9792 int v_size_x = v_size[0];
9793 int v_size_y = v_size[1];
9794 int size = v_size_x * v_size_y;
9795 return size;
9796 */
9797
9798 return 1;
9799 }
9800
9801 //----------------------------------------------------------------
9802 //Override for allowing seemingly unallowed moves when two clients send a conflicting message simultaneously
9803 bool CanBeMovedOverride()
9804 {
9805 return m_CanBeMovedOverride;
9806 }
9807
9808 //----------------------------------------------------------------
9809 //Override for allowing seemingly unallowed moves when two clients send a conflicting message simultaneously
9810 void SetCanBeMovedOverride(bool setting)
9811 {
9812 m_CanBeMovedOverride = setting;
9813 }
9814
9815 //----------------------------------------------------------------
9823 void MessageToOwnerStatus(string text)
9824 {
9825 PlayerBase player = PlayerBase.Cast(this.GetHierarchyRootPlayer());
9826
9827 if (player)
9828 {
9829 player.MessageStatus(text);
9830 }
9831 }
9832
9833 //----------------------------------------------------------------
9841 void MessageToOwnerAction(string text)
9842 {
9843 PlayerBase player = PlayerBase.Cast(this.GetHierarchyRootPlayer());
9844
9845 if (player)
9846 {
9847 player.MessageAction(text);
9848 }
9849 }
9850
9851 //----------------------------------------------------------------
9859 void MessageToOwnerFriendly(string text)
9860 {
9861 PlayerBase player = PlayerBase.Cast(this.GetHierarchyRootPlayer());
9862
9863 if (player)
9864 {
9865 player.MessageFriendly(text);
9866 }
9867 }
9868
9869 //----------------------------------------------------------------
9877 void MessageToOwnerImportant(string text)
9878 {
9879 PlayerBase player = PlayerBase.Cast(this.GetHierarchyRootPlayer());
9880
9881 if (player)
9882 {
9883 player.MessageImportant(text);
9884 }
9885 }
9886
9887 override bool IsItemBase()
9888 {
9889 return true;
9890 }
9891
9892 // Checks if item is of questioned kind
9893 override bool KindOf(string tag)
9894 {
9895 bool found = false;
9896 string item_name = this.GetType();
9897 ref TStringArray item_tag_array = new TStringArray;
9898 GetGame().ConfigGetTextArray("cfgVehicles " + item_name + " itemInfo", item_tag_array);
9899
9900 int array_size = item_tag_array.Count();
9901 for (int i = 0; i < array_size; i++)
9902 {
9903 if (item_tag_array.Get(i) == tag)
9904 {
9905 found = true;
9906 break;
9907 }
9908 }
9909 return found;
9910 }
9911
9912
9913 override void OnRPC(PlayerIdentity sender, int rpc_type,ParamsReadContext ctx)
9914 {
9915 //Debug.Log("OnRPC called");
9916 super.OnRPC(sender, rpc_type,ctx);
9917
9918 //Play soundset for attachment locking (ActionLockAttachment.c)
9919 switch (rpc_type)
9920 {
9921 #ifndef SERVER
9922 case ERPCs.RPC_SOUND_LOCK_ATTACH:
9923 Param2<bool, string> p = new Param2<bool, string>(false, "");
9924
9925 if (!ctx.Read(p))
9926 return;
9927
9928 bool play = p.param1;
9929 string soundSet = p.param2;
9930
9931 if (play)
9932 {
9933 if (m_LockingSound)
9934 {
9936 {
9937 m_LockingSound = SEffectManager.PlaySound(soundSet, GetPosition(), 0, 0, true);
9938 }
9939 }
9940 else
9941 {
9942 m_LockingSound = SEffectManager.PlaySound(soundSet, GetPosition(), 0, 0, true);
9943 }
9944 }
9945 else
9946 {
9947 SEffectManager.DestroyEffect(m_LockingSound);
9948 }
9949
9950 break;
9951 #endif
9952
9953 }
9954
9955 if (GetWrittenNoteData())
9956 {
9957 GetWrittenNoteData().OnRPC(sender, rpc_type,ctx);
9958 }
9959 }
9960
9961 //-----------------------------
9962 // VARIABLE MANIPULATION SYSTEM
9963 //-----------------------------
9964 int NameToID(string name)
9965 {
9966 PluginVariables plugin = PluginVariables.Cast(GetPlugin(PluginVariables));
9967 return plugin.GetID(name);
9968 }
9969
9970 string IDToName(int id)
9971 {
9972 PluginVariables plugin = PluginVariables.Cast(GetPlugin(PluginVariables));
9973 return plugin.GetName(id);
9974 }
9975
9977 void OnSyncVariables(ParamsReadContext ctx)//with ID optimization
9978 {
9979 //Debug.Log("OnSyncVariables called for item: "+ ToString(this.GetType()),"varSync");
9980 //read the flags
9981 int varFlags;
9982 if (!ctx.Read(varFlags))
9983 return;
9984
9985 if (varFlags & ItemVariableFlags.FLOAT)
9986 {
9987 ReadVarsFromCTX(ctx);
9988 }
9989 }
9990
9991 override void SerializeNumericalVars(array<float> floats_out)
9992 {
9993 //some variables handled on EntityAI level already!
9994 super.SerializeNumericalVars(floats_out);
9995
9996 // the order of serialization must be the same as the order of de-serialization
9997 //--------------------------------------------
9998 if (IsVariableSet(VARIABLE_QUANTITY))
9999 {
10000 floats_out.Insert(m_VarQuantity);
10001 }
10002 //--------------------------------------------
10003 if (IsVariableSet(VARIABLE_WET))
10004 {
10005 floats_out.Insert(m_VarWet);
10006 }
10007 //--------------------------------------------
10008 if (IsVariableSet(VARIABLE_LIQUIDTYPE))
10009 {
10010 floats_out.Insert(m_VarLiquidType);
10011 }
10012 //--------------------------------------------
10013 if (IsVariableSet(VARIABLE_COLOR))
10014 {
10015 floats_out.Insert(m_ColorComponentR);
10016 floats_out.Insert(m_ColorComponentG);
10017 floats_out.Insert(m_ColorComponentB);
10018 floats_out.Insert(m_ColorComponentA);
10019 }
10020 //--------------------------------------------
10021 if (IsVariableSet(VARIABLE_CLEANNESS))
10022 {
10023 floats_out.Insert(m_Cleanness);
10024 }
10025 }
10026
10027 override void DeSerializeNumericalVars(array<float> floats)
10028 {
10029 //some variables handled on EntityAI level already!
10030 super.DeSerializeNumericalVars(floats);
10031
10032 // the order of serialization must be the same as the order of de-serialization
10033 int index = 0;
10034 int mask = Math.Round(floats.Get(index));
10035
10036 index++;
10037 //--------------------------------------------
10038 if (mask & VARIABLE_QUANTITY)
10039 {
10040 if (m_IsStoreLoad)
10041 {
10042 SetStoreLoadedQuantity(floats.Get(index));
10043 }
10044 else
10045 {
10046 float quantity = floats.Get(index);
10047 SetQuantity(quantity, true, false, false, false);
10048 }
10049 index++;
10050 }
10051 //--------------------------------------------
10052 if (mask & VARIABLE_WET)
10053 {
10054 float wet = floats.Get(index);
10055 SetWet(wet);
10056 index++;
10057 }
10058 //--------------------------------------------
10059 if (mask & VARIABLE_LIQUIDTYPE)
10060 {
10061 int liquidtype = Math.Round(floats.Get(index));
10062 SetLiquidType(liquidtype);
10063 index++;
10064 }
10065 //--------------------------------------------
10066 if (mask & VARIABLE_COLOR)
10067 {
10068 m_ColorComponentR = Math.Round(floats.Get(index));
10069 index++;
10070 m_ColorComponentG = Math.Round(floats.Get(index));
10071 index++;
10072 m_ColorComponentB = Math.Round(floats.Get(index));
10073 index++;
10074 m_ColorComponentA = Math.Round(floats.Get(index));
10075 index++;
10076 }
10077 //--------------------------------------------
10078 if (mask & VARIABLE_CLEANNESS)
10079 {
10080 int cleanness = Math.Round(floats.Get(index));
10081 SetCleanness(cleanness);
10082 index++;
10083 }
10084 }
10085
10086 override void WriteVarsToCTX(ParamsWriteContext ctx)
10087 {
10088 super.WriteVarsToCTX(ctx);
10089
10090 //--------------------------------------------
10091 if (IsVariableSet(VARIABLE_QUANTITY))
10092 {
10093 ctx.Write(GetQuantity());
10094 }
10095 //--------------------------------------------
10096 if (IsVariableSet(VARIABLE_WET))
10097 {
10098 ctx.Write(GetWet());
10099 }
10100 //--------------------------------------------
10101 if (IsVariableSet(VARIABLE_LIQUIDTYPE))
10102 {
10103 ctx.Write(GetLiquidType());
10104 }
10105 //--------------------------------------------
10106 if (IsVariableSet(VARIABLE_COLOR))
10107 {
10108 int r,g,b,a;
10109 GetColor(r,g,b,a);
10110 ctx.Write(r);
10111 ctx.Write(g);
10112 ctx.Write(b);
10113 ctx.Write(a);
10114 }
10115 //--------------------------------------------
10116 if (IsVariableSet(VARIABLE_CLEANNESS))
10117 {
10118 ctx.Write(GetCleanness());
10119 }
10120 }
10121
10122 override bool ReadVarsFromCTX(ParamsReadContext ctx, int version = -1)//with ID optimization
10123 {
10124 if (!super.ReadVarsFromCTX(ctx,version))
10125 return false;
10126
10127 int intValue;
10128 float value;
10129
10130 if (version < 140)
10131 {
10132 if (!ctx.Read(intValue))
10133 return false;
10134
10135 m_VariablesMask = intValue;
10136 }
10137
10138 if (m_VariablesMask & VARIABLE_QUANTITY)
10139 {
10140 if (!ctx.Read(value))
10141 return false;
10142
10143 if (IsStoreLoad())
10144 {
10146 }
10147 else
10148 {
10149 SetQuantity(value, true, false, false, false);
10150 }
10151 }
10152 //--------------------------------------------
10153 if (version < 140)
10154 {
10155 if (m_VariablesMask & VARIABLE_TEMPERATURE)
10156 {
10157 if (!ctx.Read(value))
10158 return false;
10159 SetTemperatureDirect(value);
10160 }
10161 }
10162 //--------------------------------------------
10163 if (m_VariablesMask & VARIABLE_WET)
10164 {
10165 if (!ctx.Read(value))
10166 return false;
10167 SetWet(value);
10168 }
10169 //--------------------------------------------
10170 if (m_VariablesMask & VARIABLE_LIQUIDTYPE)
10171 {
10172 if (!ctx.Read(intValue))
10173 return false;
10174 SetLiquidType(intValue);
10175 }
10176 //--------------------------------------------
10177 if (m_VariablesMask & VARIABLE_COLOR)
10178 {
10179 int r,g,b,a;
10180 if (!ctx.Read(r))
10181 return false;
10182 if (!ctx.Read(g))
10183 return false;
10184 if (!ctx.Read(b))
10185 return false;
10186 if (!ctx.Read(a))
10187 return false;
10188
10189 SetColor(r,g,b,a);
10190 }
10191 //--------------------------------------------
10192 if (m_VariablesMask & VARIABLE_CLEANNESS)
10193 {
10194 if (!ctx.Read(intValue))
10195 return false;
10196 SetCleanness(intValue);
10197 }
10198 //--------------------------------------------
10199 if (version >= 138 && version < 140)
10200 {
10201 if (m_VariablesMask & VARIABLE_TEMPERATURE)
10202 {
10203 if (!ctx.Read(intValue))
10204 return false;
10205 SetFrozen(intValue);
10206 }
10207 }
10208
10209 return true;
10210 }
10211
10212 //----------------------------------------------------------------
10213 override bool OnStoreLoad(ParamsReadContext ctx, int version)
10214 {
10215 m_IsStoreLoad = true;
10217 {
10218 m_FixDamageSystemInit = true;
10219 }
10220
10221 if (!super.OnStoreLoad(ctx, version))
10222 {
10223 m_IsStoreLoad = false;
10224 return false;
10225 }
10226
10227 if (version >= 114)
10228 {
10229 bool hasQuickBarIndexSaved;
10230
10231 if (!ctx.Read(hasQuickBarIndexSaved))
10232 {
10233 m_IsStoreLoad = false;
10234 return false;
10235 }
10236
10237 if (hasQuickBarIndexSaved)
10238 {
10239 int itmQBIndex;
10240
10241 //Load quickbar item bind
10242 if (!ctx.Read(itmQBIndex))
10243 {
10244 m_IsStoreLoad = false;
10245 return false;
10246 }
10247
10248 PlayerBase parentPlayer = PlayerBase.Cast(GetHierarchyRootPlayer());
10249 if (itmQBIndex != -1 && parentPlayer)
10250 parentPlayer.SetLoadedQuickBarItemBind(this, itmQBIndex);
10251 }
10252 }
10253 else
10254 {
10255 // Backup of how it used to be
10256 PlayerBase player;
10257 int itemQBIndex;
10258 if (version == int.MAX)
10259 {
10260 if (!ctx.Read(itemQBIndex))
10261 {
10262 m_IsStoreLoad = false;
10263 return false;
10264 }
10265 }
10266 else if (Class.CastTo(player, GetHierarchyRootPlayer()))
10267 {
10268 //Load quickbar item bind
10269 if (!ctx.Read(itemQBIndex))
10270 {
10271 m_IsStoreLoad = false;
10272 return false;
10273 }
10274 if (itemQBIndex != -1 && player)
10275 player.SetLoadedQuickBarItemBind(this,itemQBIndex);
10276 }
10277 }
10278
10279 if (version < 140)
10280 {
10281 // variable management system
10282 if (!LoadVariables(ctx, version))
10283 {
10284 m_IsStoreLoad = false;
10285 return false;
10286 }
10287 }
10288
10289 //agent trasmission system
10290 if (!LoadAgents(ctx, version))
10291 {
10292 m_IsStoreLoad = false;
10293 return false;
10294 }
10295 if (version >= 132)
10296 {
10297 RemotelyActivatedItemBehaviour raib = GetRemotelyActivatedItemBehaviour();
10298 if (raib)
10299 {
10300 if (!raib.OnStoreLoad(ctx,version))
10301 {
10302 m_IsStoreLoad = false;
10303 return false;
10304 }
10305 }
10306 }
10307
10308 m_IsStoreLoad = false;
10309 return true;
10310 }
10311
10312 //----------------------------------------------------------------
10313
10314 override void OnStoreSave(ParamsWriteContext ctx)
10315 {
10316 super.OnStoreSave(ctx);
10317
10318 PlayerBase player;
10319 if (PlayerBase.CastTo(player,GetHierarchyRootPlayer()))
10320 {
10321 ctx.Write(true); // Keep track of if we should actually read this in or not
10322 //Save quickbar item bind
10323 int itemQBIndex = -1;
10324 itemQBIndex = player.FindQuickBarEntityIndex(this);
10325 ctx.Write(itemQBIndex);
10326 }
10327 else
10328 {
10329 ctx.Write(false); // Keep track of if we should actually read this in or not
10330 }
10331
10332 SaveAgents(ctx);//agent trasmission system
10333
10334 RemotelyActivatedItemBehaviour raib = GetRemotelyActivatedItemBehaviour();
10335 if (raib)
10336 {
10337 raib.OnStoreSave(ctx);
10338 }
10339 }
10340 //----------------------------------------------------------------
10341
10342 override void AfterStoreLoad()
10343 {
10344 super.AfterStoreLoad();
10345
10347 {
10349 }
10350
10351 if (GetStoreLoadedQuantity() != float.LOWEST)
10352 {
10354 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
10355 }
10356 }
10357
10358 override void EEOnAfterLoad()
10359 {
10360 super.EEOnAfterLoad();
10361
10363 {
10364 m_FixDamageSystemInit = false;
10365 }
10366
10369 }
10370
10371 bool CanBeDisinfected()
10372 {
10373 return false;
10374 }
10375
10376
10377 //----------------------------------------------------------------
10378 override void OnVariablesSynchronized()
10379 {
10380 if (m_Initialized)
10381 {
10382 #ifdef PLATFORM_CONSOLE
10383 //bruteforce it is
10384 if (IsSplitable())
10385 {
10386 UIScriptedMenu menu = GetGame().GetUIManager().FindMenu(MENU_INVENTORY);
10387 if (menu)
10388 {
10389 menu.Refresh();
10390 }
10391 }
10392 #endif
10393 }
10394
10396 {
10397 PlayImpactSound(m_ConfigWeight, m_ImpactSpeed, m_ImpactSoundSurfaceHash);
10398 m_WantPlayImpactSound = false;
10399 }
10400
10402 {
10403 SetWeightDirty();
10405 }
10406 if (m_VarWet != m_VarWetPrev)
10407 {
10410 }
10411
10412 if (m_SoundSyncPlay != 0)
10413 {
10414 m_ItemSoundHandler.PlayItemSoundClient(m_SoundSyncPlay);
10415 m_SoundSyncPlay = 0;
10416 }
10417 if (m_SoundSyncStop != 0)
10418 {
10419 m_ItemSoundHandler.StopItemSoundClient(m_SoundSyncStop);
10420 m_SoundSyncStop = 0;
10421 }
10422
10423 super.OnVariablesSynchronized();
10424 }
10425
10426 //------------------------- Quantity
10427 //----------------------------------------------------------------
10429 override bool SetQuantity(float value, bool destroy_config = true, bool destroy_forced = false, bool allow_client = false, bool clamp_to_stack_max = true)
10430 {
10431 if (!IsServerCheck(allow_client))
10432 return false;
10433
10434 if (!HasQuantity())
10435 return false;
10436
10437 float min = GetQuantityMin();
10438 float max = GetQuantityMax();
10439
10440 if (value <= (min + 0.001))
10441 value = min;
10442
10443 if (value == min)
10444 {
10445 if (destroy_config)
10446 {
10447 bool dstr = ConfigGetBool("varQuantityDestroyOnMin");
10448 if (dstr)
10449 {
10450 m_VarQuantity = Math.Clamp(value, min, max);
10451 this.Delete();
10452 return true;
10453 }
10454 }
10455 else if (destroy_forced)
10456 {
10457 m_VarQuantity = Math.Clamp(value, min, max);
10458 this.Delete();
10459 return true;
10460 }
10461 // we get here if destroy_config IS true AND dstr(config destroy param) IS false;
10462 RemoveAllAgents();//we remove all agents when we got to the min value, but the item is not getting deleted
10463 }
10464
10465 float delta = m_VarQuantity;
10466 m_VarQuantity = Math.Clamp(value, min, max);
10467
10468 if (GetStoreLoadedQuantity() == float.LOWEST)//any other value means we are setting quantity from storage
10469 {
10470 delta = m_VarQuantity - delta;
10471
10472 if (delta)
10473 OnQuantityChanged(delta);
10474 }
10475
10476 SetVariableMask(VARIABLE_QUANTITY);
10477
10478 return false;
10479 }
10480
10481 //----------------------------------------------------------------
10483 bool AddQuantity(float value, bool destroy_config = true, bool destroy_forced = false)
10484 {
10485 return SetQuantity(GetQuantity() + value, destroy_config, destroy_forced);
10486 }
10487 //----------------------------------------------------------------
10488 void SetQuantityMax()
10489 {
10490 float max = GetQuantityMax();
10491 SetQuantity(max);
10492 }
10493
10494 override void SetQuantityToMinimum()
10495 {
10496 float min = GetQuantityMin();
10497 SetQuantity(min);
10498 }
10499 //----------------------------------------------------------------
10501 override void SetQuantityNormalized(float value, bool destroy_config = true, bool destroy_forced = false)
10502 {
10503 float value_clamped = Math.Clamp(value, 0, 1);//just to make sure
10504 int result = Math.Round(Math.Lerp(GetQuantityMin(), GetQuantityMax(), value_clamped));
10505 SetQuantity(result, destroy_config, destroy_forced);
10506 }
10507
10508 //----------------------------------------------------------------
10510 override float GetQuantityNormalized()
10511 {
10512 return Math.InverseLerp(GetQuantityMin(), GetQuantityMax(),m_VarQuantity);
10513 }
10514
10516 {
10517 return GetQuantityNormalized();
10518 }
10519
10520 /*void SetAmmoNormalized(float value)
10521 {
10522 float value_clamped = Math.Clamp(value, 0, 1);
10523 Magazine this_mag = Magazine.Cast(this);
10524 int max_rounds = this_mag.GetAmmoMax();
10525 int result = value * max_rounds;//can the rounded if higher precision is required
10526 this_mag.SetAmmoCount(result);
10527 }*/
10528 //----------------------------------------------------------------
10529 override int GetQuantityMax()
10530 {
10531 int slot = -1;
10532 if (GetInventory())
10533 {
10534 InventoryLocation il = new InventoryLocation;
10535 GetInventory().GetCurrentInventoryLocation(il);
10536 slot = il.GetSlot();
10537 }
10538
10539 return GetTargetQuantityMax(slot);
10540 }
10541
10542 override int GetTargetQuantityMax(int attSlotID = -1)
10543 {
10544 float quantity_max = 0;
10545
10546 if (IsSplitable()) //only stackable/splitable items can check for stack size
10547 {
10548 if (attSlotID != -1)
10549 quantity_max = InventorySlots.GetStackMaxForSlotId(attSlotID);
10550
10551 if (quantity_max <= 0)
10552 quantity_max = m_VarStackMax;
10553 }
10554
10555 if (quantity_max <= 0)
10556 quantity_max = m_VarQuantityMax;
10557
10558 return quantity_max;
10559 }
10560 //----------------------------------------------------------------
10561 override int GetQuantityMin()
10562 {
10563 return m_VarQuantityMin;
10564 }
10565 //----------------------------------------------------------------
10566 int GetQuantityInit()
10567 {
10568 return m_VarQuantityInit;
10569 }
10570
10571 //----------------------------------------------------------------
10572 override bool HasQuantity()
10573 {
10574 return !(GetQuantityMax() - GetQuantityMin() == 0);
10575 }
10576
10577 override float GetQuantity()
10578 {
10579 return m_VarQuantity;
10580 }
10581
10582 bool IsFullQuantity()
10583 {
10584 return GetQuantity() >= GetQuantityMax();
10585 }
10586
10587 //Calculates weight of single item without attachments and cargo
10588 override float GetSingleInventoryItemWeightEx()
10589 {
10590 //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
10591 float weightEx = GetWeightEx();//overall weight of the item
10592 float special = GetInventoryAndCargoWeight();//cargo and attachment weight
10593 return weightEx - special;
10594 }
10595
10596 // Obsolete, use GetSingleInventoryItemWeightEx() instead
10598 {
10600 }
10601
10602 override protected float GetWeightSpecialized(bool forceRecalc = false)
10603 {
10604 if (IsSplitable()) //quantity determines size of the stack
10605 {
10606 #ifdef DEVELOPER
10607 if (WeightDebug.m_VerbosityFlags & WeightDebugType.RECALC_FORCED)
10608 {
10609 WeightDebugData data1 = WeightDebug.GetWeightDebug(this);
10610 data1.SetCalcDetails("TIB1: " + GetConfigWeightModifiedDebugText() +" * " + GetQuantity()+"(quantity)");
10611 }
10612 #endif
10613
10614 return GetQuantity() * GetConfigWeightModified();
10615 }
10616 else if (HasEnergyManager())// items with energy manager
10617 {
10618 #ifdef DEVELOPER
10619 if (WeightDebug.m_VerbosityFlags & WeightDebugType.RECALC_FORCED)
10620 {
10621 WeightDebugData data2 = WeightDebug.GetWeightDebug(this);
10622 data2.SetCalcDetails("TIB2: "+super.GetWeightSpecialized(forceRecalc)+"(contents weight) + " + GetConfigWeightModifiedDebugText() +" + " + GetCompEM().GetEnergy()+"(energy) * " + ConfigGetFloat("weightPerQuantityUnit") +"(weightPerQuantityUnit)");
10623 }
10624 #endif
10625 return super.GetWeightSpecialized(forceRecalc) + (GetCompEM().GetEnergy() * ConfigGetFloat("weightPerQuantityUnit")) + GetConfigWeightModified();
10626 }
10627 else//everything else
10628 {
10629 #ifdef DEVELOPER
10630 if (WeightDebug.m_VerbosityFlags & WeightDebugType.RECALC_FORCED)
10631 {
10632 WeightDebugData data3 = WeightDebug.GetWeightDebug(this);
10633 data3.SetCalcDetails("TIB3: "+super.GetWeightSpecialized(forceRecalc)+"(contents weight) + " + GetConfigWeightModifiedDebugText() +" + " + GetQuantity()+"(quantity) * " + ConfigGetFloat("weightPerQuantityUnit") +"(weightPerQuantityUnit))");
10634 }
10635 #endif
10636 return super.GetWeightSpecialized(forceRecalc) + (GetQuantity() * ConfigGetFloat("weightPerQuantityUnit")) + GetConfigWeightModified();
10637 }
10638 }
10639
10641 int GetNumberOfItems()
10642 {
10643 int item_count = 0;
10644 ItemBase item;
10645
10646 if (GetInventory().GetCargo() != NULL)
10647 {
10648 item_count = GetInventory().GetCargo().GetItemCount();
10649 }
10650
10651 for (int i = 0; i < GetInventory().AttachmentCount(); i++)
10652 {
10653 Class.CastTo(item,GetInventory().GetAttachmentFromIndex(i));
10654 if (item)
10655 item_count += item.GetNumberOfItems();
10656 }
10657 return item_count;
10658 }
10659
10661 float GetUnitWeight(bool include_wetness = true)
10662 {
10663 float weight = 0;
10664 float wetness = 1;
10665 if (include_wetness)
10666 wetness += GetWet();
10667 if (IsSplitable()) //quantity determines size of the stack
10668 {
10669 weight = wetness * m_ConfigWeight;
10670 }
10671 else if (IsLiquidContainer()) //is a liquid container, default liquid weight is set to 1. May revisit later?
10672 {
10673 weight = 1;
10674 }
10675 return weight;
10676 }
10677
10678 //-----------------------------------------------------------------
10679
10680 override void ClearInventory()
10681 {
10682 if ((GetGame().IsServer() || !GetGame().IsMultiplayer()) && GetInventory())
10683 {
10684 GameInventory inv = GetInventory();
10685 array<EntityAI> items = new array<EntityAI>;
10686 inv.EnumerateInventory(InventoryTraversalType.INORDER, items);
10687 for (int i = 0; i < items.Count(); i++)
10688 {
10689 ItemBase item = ItemBase.Cast(items.Get(i));
10690 if (item)
10691 {
10692 GetGame().ObjectDelete(item);
10693 }
10694 }
10695 }
10696 }
10697
10698 //------------------------- Energy
10699
10700 //----------------------------------------------------------------
10701 float GetEnergy()
10702 {
10703 float energy = 0;
10704 if (HasEnergyManager())
10705 {
10706 energy = GetCompEM().GetEnergy();
10707 }
10708 return energy;
10709 }
10710
10711
10712 override void OnEnergyConsumed()
10713 {
10714 super.OnEnergyConsumed();
10715
10717 }
10718
10719 override void OnEnergyAdded()
10720 {
10721 super.OnEnergyAdded();
10722
10724 }
10725
10726 // Converts energy (from Energy Manager) to quantity, if enabled.
10728 {
10729 if (GetGame().IsServer() && HasEnergyManager() && GetCompEM().HasConversionOfEnergyToQuantity())
10730 {
10731 if (HasQuantity())
10732 {
10733 float energy_0to1 = GetCompEM().GetEnergy0To1();
10734 SetQuantityNormalized(energy_0to1);
10735 }
10736 }
10737 }
10738
10739 //----------------------------------------------------------------
10740 float GetHeatIsolationInit()
10741 {
10742 return ConfigGetFloat("heatIsolation");
10743 }
10744
10745 float GetHeatIsolation()
10746 {
10747 return m_HeatIsolation;
10748 }
10749
10750 float GetDryingIncrement(string pIncrementName)
10751 {
10752 string paramPath = string.Format("CfgVehicles %1 EnvironmentWetnessIncrements Drying %2", GetType(), pIncrementName);
10753 if (GetGame().ConfigIsExisting(paramPath))
10754 return GetGame().ConfigGetFloat(paramPath);
10755
10756 return 0.0;
10757 }
10758
10759 float GetSoakingIncrement(string pIncrementName)
10760 {
10761 string paramPath = string.Format("CfgVehicles %1 EnvironmentWetnessIncrements Soaking %2", GetType(), pIncrementName);
10762 if (GetGame().ConfigIsExisting(paramPath))
10763 return GetGame().ConfigGetFloat(paramPath);
10764
10765 return 0.0;
10766 }
10767 //----------------------------------------------------------------
10768 override void SetWet(float value, bool allow_client = false)
10769 {
10770 if (!IsServerCheck(allow_client))
10771 return;
10772
10773 float min = GetWetMin();
10774 float max = GetWetMax();
10775
10776 float previousValue = m_VarWet;
10777
10778 m_VarWet = Math.Clamp(value, min, max);
10779
10780 if (previousValue != m_VarWet)
10781 {
10782 SetVariableMask(VARIABLE_WET);
10783 OnWetChanged(m_VarWet, previousValue);
10784 }
10785 }
10786 //----------------------------------------------------------------
10787 override void AddWet(float value)
10788 {
10789 SetWet(GetWet() + value);
10790 }
10791 //----------------------------------------------------------------
10792 override void SetWetMax()
10793 {
10795 }
10796 //----------------------------------------------------------------
10797 override float GetWet()
10798 {
10799 return m_VarWet;
10800 }
10801 //----------------------------------------------------------------
10802 override float GetWetMax()
10803 {
10804 return m_VarWetMax;
10805 }
10806 //----------------------------------------------------------------
10807 override float GetWetMin()
10808 {
10809 return m_VarWetMin;
10810 }
10811 //----------------------------------------------------------------
10812 override float GetWetInit()
10813 {
10814 return m_VarWetInit;
10815 }
10816 //----------------------------------------------------------------
10817 override void OnWetChanged(float newVal, float oldVal)
10818 {
10819 EWetnessLevel newLevel = GetWetLevelInternal(newVal);
10820 EWetnessLevel oldLevel = GetWetLevelInternal(oldVal);
10821 if (newLevel != oldLevel)
10822 {
10823 OnWetLevelChanged(newLevel,oldLevel);
10824 }
10825 }
10826
10827 override void OnWetLevelChanged(EWetnessLevel newLevel, EWetnessLevel oldLevel)
10828 {
10829 SetWeightDirty();
10830 }
10831
10832 override EWetnessLevel GetWetLevel()
10833 {
10834 return GetWetLevelInternal(m_VarWet);
10835 }
10836
10837 //----------------------------------------------------------------
10838
10839 override void SetStoreLoad(bool value)
10840 {
10841 m_IsStoreLoad = value;
10842 }
10843
10844 override bool IsStoreLoad()
10845 {
10846 return m_IsStoreLoad;
10847 }
10848
10849 override void SetStoreLoadedQuantity(float value)
10850 {
10851 m_StoreLoadedQuantity = value;
10852 }
10853
10854 override float GetStoreLoadedQuantity()
10855 {
10856 return m_StoreLoadedQuantity;
10857 }
10858
10859 //----------------------------------------------------------------
10860
10861 float GetItemModelLength()
10862 {
10863 if (ConfigIsExisting("itemModelLength"))
10864 {
10865 return ConfigGetFloat("itemModelLength");
10866 }
10867 return 0;
10868 }
10869
10870 float GetItemAttachOffset()
10871 {
10872 if (ConfigIsExisting("itemAttachOffset"))
10873 {
10874 return ConfigGetFloat("itemAttachOffset");
10875 }
10876 return 0;
10877 }
10878
10879 override void SetCleanness(int value, bool allow_client = false)
10880 {
10881 if (!IsServerCheck(allow_client))
10882 return;
10883
10884 int previousValue = m_Cleanness;
10885
10886 m_Cleanness = Math.Clamp(value, m_CleannessMin, m_CleannessMax);
10887
10888 if (previousValue != m_Cleanness)
10889 SetVariableMask(VARIABLE_CLEANNESS);
10890 }
10891
10892 override int GetCleanness()
10893 {
10894 return m_Cleanness;
10895 }
10896
10898 {
10899 return true;
10900 }
10901
10902 //----------------------------------------------------------------
10903 // ATTACHMENT LOCKING
10904 // Getters relevant to generic ActionLockAttachment
10905 int GetLockType()
10906 {
10907 return m_LockType;
10908 }
10909
10910 string GetLockSoundSet()
10911 {
10912 return m_LockSoundSet;
10913 }
10914
10915 //----------------------------------------------------------------
10916 //------------------------- Color
10917 // sets items color variable given color components
10918 override void SetColor(int r, int g, int b, int a)
10919 {
10924 SetVariableMask(VARIABLE_COLOR);
10925 }
10927 override void GetColor(out int r,out int g,out int b,out int a)
10928 {
10933 }
10934
10935 bool IsColorSet()
10936 {
10937 return IsVariableSet(VARIABLE_COLOR);
10938 }
10939
10941 string GetColorString()
10942 {
10943 int r,g,b,a;
10944 GetColor(r,g,b,a);
10945 r = r/255;
10946 g = g/255;
10947 b = b/255;
10948 a = a/255;
10949 return MiscGameplayFunctions.GetColorString(r, g, b, a);
10950 }
10951 //----------------------------------------------------------------
10952 //------------------------- LiquidType
10953
10954 override void SetLiquidType(int value, bool allow_client = false)
10955 {
10956 if (!IsServerCheck(allow_client))
10957 return;
10958
10959 int old = m_VarLiquidType;
10960 m_VarLiquidType = value;
10961 OnLiquidTypeChanged(old,value);
10962 SetVariableMask(VARIABLE_LIQUIDTYPE);
10963 }
10964
10965 int GetLiquidTypeInit()
10966 {
10967 return ConfigGetInt("varLiquidTypeInit");
10968 }
10969
10970 override int GetLiquidType()
10971 {
10972 return m_VarLiquidType;
10973 }
10974
10975 protected void OnLiquidTypeChanged(int oldType, int newType)
10976 {
10977 if (newType == LIQUID_NONE && GetIsFrozen())
10978 SetFrozen(false);
10979 }
10980
10982 void UpdateQuickbarShortcutVisibility(PlayerBase player)
10983 {
10984 player.SetEnableQuickBarEntityShortcut(this,!GetHierarchyParent() || GetHierarchyParent().GetInventory().AreChildrenAccessible());
10985 }
10986
10987 // -------------------------------------------------------------------------
10989 void OnInventoryEnter(Man player)
10990 {
10991 PlayerBase nplayer;
10992 if (PlayerBase.CastTo(nplayer, player))
10993 {
10994 m_CanPlayImpactSound = true;
10995 //nplayer.OnItemInventoryEnter(this);
10996 nplayer.SetEnableQuickBarEntityShortcut(this,!GetHierarchyParent() || GetHierarchyParent().GetInventory().AreChildrenAccessible());
10997 }
10998 }
10999
11000 // -------------------------------------------------------------------------
11002 void OnInventoryExit(Man player)
11003 {
11004 PlayerBase nplayer;
11005 if (PlayerBase.CastTo(nplayer,player))
11006 {
11007 //nplayer.OnItemInventoryExit(this);
11008 nplayer.SetEnableQuickBarEntityShortcut(this,false);
11009
11010 }
11011
11012 //if (!GetGame().IsDedicatedServer())
11013 player.GetHumanInventory().ClearUserReservedLocationForContainer(this);
11014
11015
11016 if (HasEnergyManager())
11017 {
11018 GetCompEM().UpdatePlugState(); // Unplug the el. device if it's necesarry.
11019 }
11020 }
11021
11022 // ADVANCED PLACEMENT EVENTS
11023 override void OnPlacementStarted(Man player)
11024 {
11025 super.OnPlacementStarted(player);
11026
11027 SetTakeable(false);
11028 }
11029
11030 override void OnPlacementComplete(Man player, vector position = "0 0 0", vector orientation = "0 0 0")
11031 {
11032 if (m_AdminLog)
11033 {
11034 m_AdminLog.OnPlacementComplete(player, this);
11035 }
11036
11037 super.OnPlacementComplete(player, position, orientation);
11038 }
11039
11040 //-----------------------------
11041 // AGENT SYSTEM
11042 //-----------------------------
11043 //--------------------------------------------------------------------------
11044 bool ContainsAgent(int agent_id)
11045 {
11046 if (agent_id & m_AttachedAgents)
11047 {
11048 return true;
11049 }
11050 else
11051 {
11052 return false;
11053 }
11054 }
11055
11056 //--------------------------------------------------------------------------
11057 override void RemoveAgent(int agent_id)
11058 {
11059 if (ContainsAgent(agent_id))
11060 {
11061 m_AttachedAgents = ~agent_id & m_AttachedAgents;
11062 }
11063 }
11064
11065 //--------------------------------------------------------------------------
11066 override void RemoveAllAgents()
11067 {
11068 m_AttachedAgents = 0;
11069 }
11070 //--------------------------------------------------------------------------
11071 override void RemoveAllAgentsExcept(int agent_to_keep)
11072 {
11073 m_AttachedAgents = m_AttachedAgents & agent_to_keep;
11074 }
11075 // -------------------------------------------------------------------------
11076 override void InsertAgent(int agent, float count = 1)
11077 {
11078 if (count < 1)
11079 return;
11080 //Debug.Log("Inserting Agent on item: " + agent.ToString() +" count: " + count.ToString());
11082 }
11083
11085 void TransferAgents(int agents)
11086 {
11088 }
11089
11090 // -------------------------------------------------------------------------
11091 override int GetAgents()
11092 {
11093 return m_AttachedAgents;
11094 }
11095 //----------------------------------------------------------------------
11096
11097 /*int GetContaminationType()
11098 {
11099 int contamination_type;
11100
11101 const int CONTAMINATED_MASK = eAgents.CHOLERA | eAgents.INFLUENZA | eAgents.SALMONELLA | eAgents.BRAIN;
11102 const int POISONED_MASK = eAgents.FOOD_POISON | eAgents.CHEMICAL_POISON;
11103 const int NERVE_GAS_MASK = eAgents.CHEMICAL_POISON;
11104 const int DIRTY_MASK = eAgents.WOUND_AGENT;
11105
11106 Edible_Base edible = Edible_Base.Cast(this);
11107 int agents = GetAgents();
11108 if (edible)
11109 {
11110 NutritionalProfile profile = Edible_Base.GetNutritionalProfile(edible);
11111 if (profile)
11112 {
11113 agents = agents | profile.GetAgents();//merge item's agents with nutritional agents
11114 }
11115 }
11116 if (agents & CONTAMINATED_MASK)
11117 {
11118 contamination_type = contamination_type | EContaminationTypes.ITEM_BADGE_CONTAMINATED;
11119 }
11120 if (agents & POISONED_MASK)
11121 {
11122 contamination_type = contamination_type | EContaminationTypes.ITEM_BADGE_POISONED;
11123 }
11124 if (agents & NERVE_GAS_MASK)
11125 {
11126 contamination_type = contamination_type | EContaminationTypes.ITEM_BADGE_NERVE_GAS;
11127 }
11128 if (agents & DIRTY_MASK)
11129 {
11130 contamination_type = contamination_type | EContaminationTypes.ITEM_BADGE_DIRTY;
11131 }
11132
11133 return agents;
11134 }*/
11135
11136 // -------------------------------------------------------------------------
11137 bool LoadAgents(ParamsReadContext ctx, int version)
11138 {
11139 if (!ctx.Read(m_AttachedAgents))
11140 return false;
11141 return true;
11142 }
11143 // -------------------------------------------------------------------------
11145 {
11146
11148 }
11149 // -------------------------------------------------------------------------
11150
11152 override void CheckForRoofLimited(float timeTresholdMS = 3000)
11153 {
11154 super.CheckForRoofLimited(timeTresholdMS);
11155
11156 float time = GetGame().GetTime();
11157 if ((time - m_PreviousRoofTestTime) >= timeTresholdMS)
11158 {
11159 m_PreviousRoofTestTime = time;
11160 SetRoofAbove(MiscGameplayFunctions.IsUnderRoof(this));
11161 }
11162 }
11163
11164 // returns item's protection level against enviromental hazard, for masks with filters, returns the filters protection for valid filter, otherwise 0
11165 float GetProtectionLevel(int type, bool consider_filter = false, int system = 0)
11166 {
11167 if (IsDamageDestroyed() || (HasQuantity() && GetQuantity() <= 0))
11168 {
11169 return 0;
11170 }
11171
11172 if (GetInventory().GetAttachmentSlotsCount() != 0)//is it an item with attachable filter ?
11173 {
11174 ItemBase filter = ItemBase.Cast(FindAttachmentBySlotName("GasMaskFilter"));
11175 if (filter)
11176 return filter.GetProtectionLevel(type, false, system);//it's a valid filter, return the protection
11177 else
11178 return 0;//otherwise return 0 when no filter attached
11179 }
11180
11181 string subclassPath, entryName;
11182
11183 switch (type)
11184 {
11185 case DEF_BIOLOGICAL:
11186 entryName = "biological";
11187 break;
11188 case DEF_CHEMICAL:
11189 entryName = "chemical";
11190 break;
11191 default:
11192 entryName = "biological";
11193 break;
11194 }
11195
11196 subclassPath = "CfgVehicles " + this.GetType() + " Protection ";
11197
11198 return GetGame().ConfigGetFloat(subclassPath + entryName);
11199 }
11200
11201
11202
11204 override void EEOnCECreate()
11205 {
11206 if (!IsMagazine())
11208
11210 }
11211
11212
11213 //-------------------------
11214 // OPEN/CLOSE USER ACTIONS
11215 //-------------------------
11217 void Open();
11218 void Close();
11219 bool IsOpen()
11220 {
11221 return true;
11222 }
11223
11224 override bool CanDisplayCargo()
11225 {
11226 return IsOpen();
11227 }
11228
11229
11230 // ------------------------------------------------------------
11231 // CONDITIONS
11232 // ------------------------------------------------------------
11233 override bool CanPutInCargo(EntityAI parent)
11234 {
11235 if (parent)
11236 {
11237 if (parent.IsInherited(DayZInfected))
11238 return true;
11239
11240 if (!parent.IsRuined())
11241 return true;
11242 }
11243
11244 return true;
11245 }
11246
11247 override bool CanPutAsAttachment(EntityAI parent)
11248 {
11249 if (!super.CanPutAsAttachment(parent))
11250 {
11251 return false;
11252 }
11253
11254 if (!IsRuined() && !parent.IsRuined())
11255 {
11256 return true;
11257 }
11258
11259 return false;
11260 }
11261
11262 override bool CanReceiveItemIntoCargo(EntityAI item)
11263 {
11264 //removed 15.06. coz of loading from storage -> after load items in cargo was lost -> waiting for proper solution
11265 //if (GetHealthLevel() == GameConstants.STATE_RUINED)
11266 // return false;
11267
11268 return super.CanReceiveItemIntoCargo(item);
11269 }
11270
11271 override bool CanReceiveAttachment(EntityAI attachment, int slotId)
11272 {
11273 //removed 15.06. coz of loading from storage -> after load items in cargo was lost -> waiting for proper solution
11274 //if (GetHealthLevel() == GameConstants.STATE_RUINED)
11275 // return false;
11276
11277 GameInventory attachmentInv = attachment.GetInventory();
11278 if (attachmentInv && attachmentInv.GetCargo() && attachmentInv.GetCargo().GetItemCount() > 0)
11279 {
11280 if (GetHierarchyParent() && !GetHierarchyParent().IsInherited(PlayerBase))
11281 return false;
11282 }
11283
11284 InventoryLocation loc = new InventoryLocation();
11285 attachment.GetInventory().GetCurrentInventoryLocation(loc);
11286 if (loc && loc.IsValid() && !GetInventory().AreChildrenAccessible())
11287 return false;
11288
11289 return super.CanReceiveAttachment(attachment, slotId);
11290 }
11291
11292 override bool CanReleaseAttachment(EntityAI attachment)
11293 {
11294 if (!super.CanReleaseAttachment(attachment))
11295 return false;
11296
11297 return GetInventory().AreChildrenAccessible();
11298 }
11299
11300 /*override bool CanLoadAttachment(EntityAI attachment)
11301 {
11302 //removed 15.06. coz of loading from storage -> after load items in cargo was lost -> waiting for proper solution
11303 //if (GetHealthLevel() == GameConstants.STATE_RUINED)
11304 // return false;
11305
11306 GameInventory attachmentInv = attachment.GetInventory();
11307 if (attachmentInv && attachmentInv.GetCargo() && attachmentInv.GetCargo().GetItemCount() > 0)
11308 {
11309 bool boo = (GetHierarchyParent() && !GetHierarchyParent().IsInherited(PlayerBase));
11310 ErrorEx("CanLoadAttachment | this: " + this + " | attachment: " + attachment + " | boo: " + boo,ErrorExSeverity.INFO);
11311
11312 if (GetHierarchyParent() && !GetHierarchyParent().IsInherited(PlayerBase))
11313 return false;
11314 }
11315
11316 return super.CanLoadAttachment(attachment);
11317 }*/
11318
11319 // Plays muzzle flash particle effects
11320 static void PlayFireParticles(ItemBase weapon, int muzzle_index, string ammoType, ItemBase muzzle_owner, ItemBase suppressor, string config_to_search)
11321 {
11322 int id = muzzle_owner.GetMuzzleID();
11323 array<ref WeaponParticlesOnFire> WPOF_array = m_OnFireEffect.Get(id);
11324
11325 if (WPOF_array)
11326 {
11327 for (int i = 0; i < WPOF_array.Count(); i++)
11328 {
11329 WeaponParticlesOnFire WPOF = WPOF_array.Get(i);
11330
11331 if (WPOF)
11332 {
11333 WPOF.OnActivate(weapon, muzzle_index, ammoType, muzzle_owner, suppressor, config_to_search);
11334 }
11335 }
11336 }
11337 }
11338
11339 // Plays bullet eject particle effects (usually just smoke, the bullet itself is a 3D model and is not part of this function)
11340 static void PlayBulletCasingEjectParticles(ItemBase weapon, string ammoType, ItemBase muzzle_owner, ItemBase suppressor, string config_to_search)
11341 {
11342 int id = muzzle_owner.GetMuzzleID();
11343 array<ref WeaponParticlesOnBulletCasingEject> WPOBE_array = m_OnBulletCasingEjectEffect.Get(id);
11344
11345 if (WPOBE_array)
11346 {
11347 for (int i = 0; i < WPOBE_array.Count(); i++)
11348 {
11349 WeaponParticlesOnBulletCasingEject WPOBE = WPOBE_array.Get(i);
11350
11351 if (WPOBE)
11352 {
11353 WPOBE.OnActivate(weapon, 0, ammoType, muzzle_owner, suppressor, config_to_search);
11354 }
11355 }
11356 }
11357 }
11358
11359 // Plays all weapon overheating particles
11360 static void PlayOverheatingParticles(ItemBase weapon, string ammoType, ItemBase muzzle_owner, ItemBase suppressor, string config_to_search)
11361 {
11362 int id = muzzle_owner.GetMuzzleID();
11363 array<ref WeaponParticlesOnOverheating> WPOOH_array = weapon.m_OnOverheatingEffect.Get(id);
11364
11365 if (WPOOH_array)
11366 {
11367 for (int i = 0; i < WPOOH_array.Count(); i++)
11368 {
11369 WeaponParticlesOnOverheating WPOOH = WPOOH_array.Get(i);
11370
11371 if (WPOOH)
11372 {
11373 WPOOH.OnActivate(weapon, 0, ammoType, muzzle_owner, suppressor, config_to_search);
11374 }
11375 }
11376 }
11377 }
11378
11379 // Updates all weapon overheating particles
11380 static void UpdateOverheatingParticles(ItemBase weapon, string ammoType, ItemBase muzzle_owner, ItemBase suppressor, string config_to_search)
11381 {
11382 int id = muzzle_owner.GetMuzzleID();
11383 array<ref WeaponParticlesOnOverheating> WPOOH_array = weapon.m_OnOverheatingEffect.Get(id);
11384
11385 if (WPOOH_array)
11386 {
11387 for (int i = 0; i < WPOOH_array.Count(); i++)
11388 {
11389 WeaponParticlesOnOverheating WPOOH = WPOOH_array.Get(i);
11390
11391 if (WPOOH)
11392 {
11393 WPOOH.OnUpdate(weapon, ammoType, muzzle_owner, suppressor, config_to_search);
11394 }
11395 }
11396 }
11397 }
11398
11399 // Stops overheating particles
11400 static void StopOverheatingParticles(ItemBase weapon, string ammoType, ItemBase muzzle_owner, ItemBase suppressor, string config_to_search)
11401 {
11402 int id = muzzle_owner.GetMuzzleID();
11403 array<ref WeaponParticlesOnOverheating> WPOOH_array = weapon.m_OnOverheatingEffect.Get(id);
11404
11405 if (WPOOH_array)
11406 {
11407 for (int i = 0; i < WPOOH_array.Count(); i++)
11408 {
11409 WeaponParticlesOnOverheating WPOOH = WPOOH_array.Get(i);
11410
11411 if (WPOOH)
11412 {
11413 WPOOH.OnDeactivate(weapon, ammoType, muzzle_owner, suppressor, config_to_search);
11414 }
11415 }
11416 }
11417 }
11418
11419 //----------------------------------------------------------------
11420 //Item Behaviour - unified approach
11421 override bool IsHeavyBehaviour()
11422 {
11423 if (m_ItemBehaviour == 0)
11424 {
11425 return true;
11426 }
11427
11428 return false;
11429 }
11430
11431 override bool IsOneHandedBehaviour()
11432 {
11433 if (m_ItemBehaviour == 1)
11434 {
11435 return true;
11436 }
11437
11438 return false;
11439 }
11440
11441 override bool IsTwoHandedBehaviour()
11442 {
11443 if (m_ItemBehaviour == 2)
11444 {
11445 return true;
11446 }
11447
11448 return false;
11449 }
11450
11451 bool IsDeployable()
11452 {
11453 return false;
11454 }
11455
11457 float GetDeployTime()
11458 {
11459 return UATimeSpent.DEFAULT_DEPLOY;
11460 }
11461
11462
11463 //----------------------------------------------------------------
11464 // Item Targeting (User Actions)
11465 override void SetTakeable(bool pState)
11466 {
11467 m_IsTakeable = pState;
11468 SetSynchDirty();
11469 }
11470
11471 override bool IsTakeable()
11472 {
11473 return m_IsTakeable;
11474 }
11475
11476 // For cases where we want to show object widget which cant be taken to hands
11478 {
11479 return false;
11480 }
11481
11483 protected void PreLoadSoundAttachmentType()
11484 {
11485 string att_type = "None";
11486
11487 if (ConfigIsExisting("soundAttType"))
11488 {
11489 att_type = ConfigGetString("soundAttType");
11490 }
11491
11492 m_SoundAttType = att_type;
11493 }
11494
11495 override string GetAttachmentSoundType()
11496 {
11497 return m_SoundAttType;
11498 }
11499
11500 //----------------------------------------------------------------
11501 //SOUNDS - ItemSoundHandler
11502 //----------------------------------------------------------------
11503
11504 string GetPlaceSoundset(); // played when deploy starts
11505 string GetLoopDeploySoundset(); // played when deploy starts and stopped when it finishes
11506 string GetDeploySoundset(); // played when deploy sucessfully finishes
11507 string GetLoopFoldSoundset(); // played when fold starts and stopped when it finishes
11508 string GetFoldSoundset(); // played when fold sucessfully finishes
11509
11511 {
11512 if (!m_ItemSoundHandler)
11514
11515 return m_ItemSoundHandler;
11516 }
11517
11518 // override to initialize sounds
11519 protected void InitItemSounds()
11520 {
11521 if (GetPlaceSoundset() == string.Empty && GetDeploySoundset() == string.Empty && GetLoopDeploySoundset() == string.Empty)
11522 return;
11523
11525
11526 if (GetPlaceSoundset() != string.Empty)
11527 handler.AddSound(SoundConstants.ITEM_PLACE, GetPlaceSoundset());
11528
11529 if (GetDeploySoundset() != string.Empty)
11530 handler.AddSound(SoundConstants.ITEM_DEPLOY, GetDeploySoundset());
11531
11532 SoundParameters params = new SoundParameters();
11533 params.m_Loop = true;
11534 if (GetLoopDeploySoundset() != string.Empty)
11535 handler.AddSound(SoundConstants.ITEM_DEPLOY_LOOP, GetLoopDeploySoundset(), params);
11536 }
11537
11538 // Start sound using ItemSoundHandler
11539 void StartItemSoundServer(int id)
11540 {
11541 if (!GetGame().IsServer())
11542 return;
11543
11544 m_SoundSyncPlay = id;
11545 SetSynchDirty();
11546
11547 GetGame().GetCallQueue(CALL_CATEGORY_SYSTEM).Remove(ClearStartItemSoundServer); // in case one is queued already
11549 }
11550
11551 // Stop sound using ItemSoundHandler
11552 void StopItemSoundServer(int id)
11553 {
11554 if (!GetGame().IsServer())
11555 return;
11556
11557 m_SoundSyncStop = id;
11558 SetSynchDirty();
11559
11560 GetGame().GetCallQueue(CALL_CATEGORY_SYSTEM).Remove(ClearStopItemSoundServer); // in case one is queued already
11562 }
11563
11564 protected void ClearStartItemSoundServer()
11565 {
11566 m_SoundSyncPlay = 0;
11567 }
11568
11569 protected void ClearStopItemSoundServer()
11570 {
11571 m_SoundSyncStop = 0;
11572 }
11573
11575 void PlayAttachSound(string slot_type)
11576 {
11577 if (!GetGame().IsDedicatedServer())
11578 {
11579 if (ConfigIsExisting("attachSoundSet"))
11580 {
11581 string cfg_path = "";
11582 string soundset = "";
11583 string type_name = GetType();
11584
11585 TStringArray cfg_soundset_array = new TStringArray;
11586 TStringArray cfg_slot_array = new TStringArray;
11587 ConfigGetTextArray("attachSoundSet",cfg_soundset_array);
11588 ConfigGetTextArray("attachSoundSlot",cfg_slot_array);
11589
11590 if (cfg_soundset_array.Count() > 0 && cfg_soundset_array.Count() == cfg_slot_array.Count())
11591 {
11592 for (int i = 0; i < cfg_soundset_array.Count(); i++)
11593 {
11594 if (cfg_slot_array[i] == slot_type)
11595 {
11596 soundset = cfg_soundset_array[i];
11597 break;
11598 }
11599 }
11600 }
11601
11602 if (soundset != "")
11603 {
11604 EffectSound sound = SEffectManager.PlaySound(soundset, GetPosition());
11605 sound.SetAutodestroy(true);
11606 }
11607 }
11608 }
11609 }
11610
11611 void PlayDetachSound(string slot_type)
11612 {
11613 //TODO - evaluate if needed and devise universal config structure if so
11614 }
11615
11616 void OnApply(PlayerBase player);
11617
11619 {
11620 return 1.0;
11621 };
11622 //returns applicable selection
11623 array<string> GetHeadHidingSelection()
11624 {
11626 }
11627
11629 {
11631 }
11632
11633 WrittenNoteData GetWrittenNoteData() {};
11634
11636 {
11637 SetDynamicPhysicsLifeTime(0.01);
11638 m_ItemBeingDroppedPhys = false;
11639 }
11640
11642 {
11643 array<string> zone_names = new array<string>;
11644 GetDamageZones(zone_names);
11645 for (int i = 0; i < zone_names.Count(); i++)
11646 {
11647 SetHealthMax(zone_names.Get(i),"Health");
11648 }
11649 SetHealthMax("","Health");
11650 }
11651
11653 void SetZoneDamageCEInit()
11654 {
11655 float global_health = GetHealth01("","Health");
11656 array<string> zones = new array<string>;
11657 GetDamageZones(zones);
11658 //set damage of all zones to match global health level
11659 for (int i = 0; i < zones.Count(); i++)
11660 {
11661 SetHealth01(zones.Get(i),"Health",global_health);
11662 }
11663 }
11664
11666 bool IsCoverFaceForShave(string slot_name)
11667 {
11668 return IsExclusionFlagPresent(PlayerBase.GetFaceCoverageShaveValues());
11669 }
11670
11671 void ProcessItemWetness(float delta, bool hasParent, bool hasRootAsPlayer, ItemBase refParentIB)
11672 {
11673 if (!hasRootAsPlayer)
11674 {
11675 if (refParentIB)
11676 {
11677 // parent is wet
11678 if ((refParentIB.GetWet() >= GameConstants.STATE_SOAKING_WET) && (m_VarWet < m_VarWetMax))
11679 AddWet(delta * GameConstants.WETNESS_RATE_WETTING_INSIDE);
11680 // parent has liquid inside
11681 else if ((refParentIB.GetLiquidType() != 0) && (refParentIB.GetQuantity() > 0) && (m_VarWet < m_VarWetMax))
11682 AddWet(delta * GameConstants.WETNESS_RATE_WETTING_LIQUID);
11683 // drying
11684 else if (m_VarWet > m_VarWetMin)
11685 AddWet(-1 * delta * GetDryingIncrement("ground") * 2);
11686 }
11687 else
11688 {
11689 // drying on ground or inside non-itembase (car, ...)
11690 if (m_VarWet > m_VarWetMin)
11691 AddWet(-1 * delta * GetDryingIncrement("ground"));
11692 }
11693 }
11694 }
11695
11696 void ProcessItemTemperature(float delta, bool hasParent, bool hasRootAsPlayer, ItemBase refParentIB)
11697 {
11699 {
11700 float target = g_Game.GetMission().GetWorldData().GetBaseEnvTemperatureAtObject(this);
11701 if (GetTemperature() != target || !IsFreezeThawProgressFinished())
11702 {
11703 float heatPermCoef = 1.0;
11704 EntityAI ent = this;
11705 while (ent)
11706 {
11707 heatPermCoef *= ent.GetHeatPermeabilityCoef();
11708 ent = ent.GetHierarchyParent();
11709 }
11710
11711 SetTemperatureEx(new TemperatureDataInterpolated(target,ETemperatureAccessTypes.ACCESS_WORLD,delta,GameConstants.TEMP_COEF_WORLD,heatPermCoef));
11712 }
11713 }
11714 }
11715
11716 void HierarchyCheck(out bool hasParent, out bool hasRootAsPlayer, out ItemBase refParentIB)
11717 {
11718 // hierarchy check for an item to decide whether it has some parent and it is in some player inventory
11719 EntityAI parent = GetHierarchyParent();
11720 if (!parent)
11721 {
11722 hasParent = false;
11723 hasRootAsPlayer = false;
11724 }
11725 else
11726 {
11727 hasParent = true;
11728 hasRootAsPlayer = (GetHierarchyRootPlayer() != null);
11729 refParentIB = ItemBase.Cast(parent);
11730 }
11731 }
11732
11733 protected void ProcessDecay(float delta, bool hasRootAsPlayer)
11734 {
11735 // this is stub, implemented on Edible_Base
11736 }
11737
11738 bool CanDecay()
11739 {
11740 // return true used on selected food clases so they can decay
11741 return false;
11742 }
11743
11744 protected bool CanProcessDecay()
11745 {
11746 // this is stub, implemented on Edible_Base class
11747 // used to determine whether it is still necessary for the food to decay
11748 return false;
11749 }
11750
11751 protected bool CanHaveWetness()
11752 {
11753 // return true used on selected items that have a wetness effect
11754 return false;
11755 }
11756
11758 bool CanBeConsumed(ConsumeConditionData data = null)
11759 {
11760 return !GetIsFrozen() && IsOpen();
11761 }
11762
11763 override void ProcessVariables()
11764 {
11765 bool hasParent = false, hasRootAsPlayer = false;
11766 ItemBase refParentIB;
11767
11768 bool wwtu = g_Game.IsWorldWetTempUpdateEnabled();
11769 bool foodDecay = g_Game.IsFoodDecayEnabled();
11770
11771 if (wwtu || foodDecay)
11772 {
11773 bool processWetness = wwtu && CanHaveWetness();
11774 bool processTemperature = wwtu && CanHaveTemperature();
11775 bool processDecay = foodDecay && CanDecay() && CanProcessDecay();
11776
11777 if (processWetness || processTemperature || processDecay)
11778 {
11779 HierarchyCheck(hasParent, hasRootAsPlayer, refParentIB);
11780
11781 if (processWetness)
11782 ProcessItemWetness(m_ElapsedSinceLastUpdate, hasParent, hasRootAsPlayer, refParentIB);
11783
11784 if (processTemperature)
11785 ProcessItemTemperature(m_ElapsedSinceLastUpdate, hasParent, hasRootAsPlayer, refParentIB);
11786
11787 if (processDecay)
11788 ProcessDecay(m_ElapsedSinceLastUpdate, hasRootAsPlayer);
11789 }
11790 }
11791 }
11792
11795 {
11796 return m_TemperaturePerQuantityWeight * GameConstants.ITEM_TEMPERATURE_QUANTITY_WEIGHT_MULTIPLIER;
11797 }
11798
11799 override float GetTemperatureFreezeThreshold()
11800 {
11802 return Liquid.GetFreezeThreshold(GetLiquidType());
11803
11804 return super.GetTemperatureFreezeThreshold();
11805 }
11806
11807 override float GetTemperatureThawThreshold()
11808 {
11810 return Liquid.GetThawThreshold(GetLiquidType());
11811
11812 return super.GetTemperatureThawThreshold();
11813 }
11814
11815 override float GetItemOverheatThreshold()
11816 {
11818 return Liquid.GetBoilThreshold(GetLiquidType());
11819
11820 return super.GetItemOverheatThreshold();
11821 }
11822
11823 override float GetTemperatureFreezeTime()
11824 {
11825 if (HasQuantity())
11826 return Math.Lerp(GameConstants.TEMPERATURE_TIME_FREEZE_MIN,Math.Max(GameConstants.TEMPERATURE_TIME_FREEZE_MIN,super.GetTemperatureFreezeTime()),GetQuantityNormalized());
11827
11828 return super.GetTemperatureFreezeTime();
11829 }
11830
11831 override float GetTemperatureThawTime()
11832 {
11833 if (HasQuantity())
11834 return Math.Lerp(GameConstants.TEMPERATURE_TIME_THAW_MIN,Math.Max(GameConstants.TEMPERATURE_TIME_FREEZE_MIN,super.GetTemperatureThawTime()),GetQuantityNormalized());
11835
11836 return super.GetTemperatureThawTime();
11837 }
11838
11840 void AffectLiquidContainerOnFill(int liquid_type, float amount);
11842 void AffectLiquidContainerOnTransfer(int liquidType, float amount, float sourceLiquidTemperature);
11843
11844 bool IsCargoException4x3(EntityAI item)
11845 {
11846 return (item.IsKindOf("Cauldron") || item.IsKindOf("Pot") || item.IsKindOf("FryingPan") || item.IsKindOf("SmallProtectorCase") || (item.IsKindOf("PortableGasStove") && item.FindAttachmentBySlotName("CookingEquipment")));
11847 }
11848
11850 {
11851 MiscGameplayFunctions.TransferItemProperties(oldItem, this);
11852 }
11853
11855 void AddLightSourceItem(ItemBase lightsource)
11856 {
11857 m_LightSourceItem = lightsource;
11858 }
11859
11861 {
11862 m_LightSourceItem = null;
11863 }
11864
11866 {
11867 return m_LightSourceItem;
11868 }
11869
11871 array<int> GetValidFinishers()
11872 {
11873 return null;
11874 }
11875
11877 bool GetActionWidgetOverride(out typename name)
11878 {
11879 return false;
11880 }
11881
11882 bool PairWithDevice(notnull ItemBase otherDevice)
11883 {
11884 if (GetGame().IsServer())
11885 {
11886 ItemBase explosive = otherDevice;
11888 if (!trg)
11889 {
11890 trg = RemoteDetonatorTrigger.Cast(otherDevice);
11891 explosive = this;
11892 }
11893
11894 explosive.PairRemote(trg);
11895 trg.SetControlledDevice(explosive);
11896
11897 int persistentID = RemotelyActivatedItemBehaviour.GeneratePersistentID();
11898 trg.SetPersistentPairID(persistentID);
11899 explosive.SetPersistentPairID(persistentID);
11900
11901 return true;
11902 }
11903 return false;
11904 }
11905
11907 float GetBaitEffectivity()
11908 {
11909 float ret = 1.0;
11910 if (HasQuantity())
11911 ret *= GetQuantityNormalized();
11912 ret *= GetHealth01();
11913
11914 return ret;
11915 }
11916
11917 #ifdef DEVELOPER
11918 override void SetDebugItem()
11919 {
11920 super.SetDebugItem();
11921 _itemBase = this;
11922 }
11923
11924 override string GetDebugText()
11925 {
11926 string text = super.GetDebugText();
11927
11928 text += string.Format("Heat isolation(raw): %1\n", GetHeatIsolation());
11929 text += string.Format("Heat isolation(modified): %1\n", MiscGameplayFunctions.GetCurrentItemHeatIsolation(this));
11930
11931 return text;
11932 }
11933 #endif
11934
11935 bool CanBeUsedForSuicide()
11936 {
11937 return true;
11938 }
11939
11941 //DEPRECATED BELOW
11943 // Backwards compatibility
11944 void ProcessItemWetnessAndTemperature(float delta, bool hasParent, bool hasRootAsPlayer, ItemBase refParentIB)
11945 {
11946 ProcessItemWetness(delta, hasParent, hasRootAsPlayer, refParentIB);
11947 ProcessItemTemperature(delta, hasParent, hasRootAsPlayer, refParentIB);
11948 }
11949
11950 // replaced by ItemSoundHandler
11951 protected EffectSound m_SoundDeployFinish;
11952 protected EffectSound m_SoundPlace;
11953 protected EffectSound m_DeployLoopSoundEx;
11954 protected EffectSound m_SoundDeploy;
11955 bool m_IsPlaceSound;
11956 bool m_IsDeploySound;
11958
11959 string GetDeployFinishSoundset();
11960 void PlayDeploySound();
11961 void PlayDeployFinishSound();
11962 void PlayPlaceSound();
11963 void PlayDeployLoopSoundEx();
11964 void StopDeployLoopSoundEx();
11965 void SoundSynchRemoteReset();
11966 void SoundSynchRemote();
11967 bool UsesGlobalDeploy(){return false;}
11968 bool CanPlayDeployLoopSound(){return false;}
11970 bool IsPlaceSound(){return m_IsPlaceSound;}
11971 bool IsDeploySound(){return m_IsDeploySound;}
11972 void SetIsPlaceSound(bool is_place_sound);
11973 void SetIsDeploySound(bool is_deploy_sound);
11974}
11975
11976EntityAI SpawnItemOnLocation(string object_name, notnull InventoryLocation loc, bool full_quantity)
11977{
11978 EntityAI entity = SpawnEntity(object_name, loc, ECE_IN_INVENTORY, RF_DEFAULT);
11979 if (entity)
11980 {
11981 bool is_item = entity.IsInherited(ItemBase);
11982 if (is_item && full_quantity)
11983 {
11984 ItemBase item = ItemBase.Cast(entity);
11985 item.SetQuantity(item.GetQuantityInit());
11986 }
11987 }
11988 else
11989 {
11990 ErrorEx("Cannot spawn entity: " + object_name,ErrorExSeverity.INFO);
11991 return NULL;
11992 }
11993 return entity;
11994}
11995
11996void SetupSpawnedItem(ItemBase item, float health, float quantity)
11997{
11998 if (item)
11999 {
12000 if (health > 0)
12001 item.SetHealth("", "", health);
12002
12003 if (item.CanHaveTemperature())
12004 {
12005 item.SetTemperatureDirect(GameConstants.ITEM_TEMPERATURE_NEUTRAL_ZONE_MIDDLE);
12006 if (item.CanFreeze())
12007 item.SetFrozen(false);
12008 }
12009
12010 if (item.HasEnergyManager())
12011 {
12012 if (quantity >= 0)
12013 {
12014 item.GetCompEM().SetEnergy0To1(quantity);
12015 }
12016 else
12017 {
12018 item.GetCompEM().SetEnergy(Math.AbsFloat(quantity));
12019 }
12020 }
12021 else if (item.IsMagazine())
12022 {
12023 Magazine mag = Magazine.Cast(item);
12024 if (quantity >= 0)
12025 {
12026 mag.ServerSetAmmoCount(mag.GetAmmoMax() * quantity);
12027 }
12028 else
12029 {
12030 mag.ServerSetAmmoCount(Math.AbsFloat(quantity));
12031 }
12032
12033 }
12034 else
12035 {
12036 if (quantity >= 0)
12037 {
12038 item.SetQuantityNormalized(quantity, false);
12039 }
12040 else
12041 {
12042 item.SetQuantity(Math.AbsFloat(quantity));
12043 }
12044
12045 }
12046 }
12047}
12048
12049#ifdef DEVELOPER
12050ItemBase _itemBase;//watched item goes here(LCTRL+RMB->Watch)
12051#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()

Используется в InventoryItem::CombineItemsClient() и InventoryItem::CombineItemsEx().