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

◆ KindOf()

override bool SpawnItemOnLocation::KindOf ( string tag)
protected

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

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