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

◆ GetRecipesActions()

void SpawnItemOnLocation::GetRecipesActions ( Man player,
out TSelectableActionInfoArray outputList )
protected

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

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