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

◆ OnAction()

override bool SpawnItemOnLocation::OnAction ( int action_id,
Man player,
ParamsReadContext ctx )
private

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

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