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

◆ CanEat()

bool SpawnItemOnLocation::CanEat ( )
protected

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

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