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

◆ OnCombine()

void SpawnItemOnLocation::OnCombine ( ItemBase other_item)
protected

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

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