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

◆ Repair()

bool SpawnItemOnLocation::Repair ( PlayerBase player,
ItemBase item_repair_kit,
float specialty_weight )
protected

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

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