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

◆ SetResultOfSplit()

void SpawnItemOnLocation::SetResultOfSplit ( bool value)
protected

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

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

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