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

◆ OnRPC()

override void SpawnItemOnLocation::OnRPC ( PlayerIdentity sender,
int rpc_type,
ParamsReadContext ctx )
protected

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

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