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

◆ CombineItemsEx()

override void SpawnItemOnLocation::CombineItemsEx ( EntityAI entity2,
bool use_stack_max = true )
protected

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

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