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

◆ CanRepair()

bool SpawnItemOnLocation::CanRepair ( ItemBase item_repair_kit)
protected

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

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