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

◆ CanRepair()

bool SpawnItemOnLocation::CanRepair ( ItemBase item_repair_kit)
protected

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

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