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

◆ GetFoodStage()

FoodStage SpawnItemOnLocation::GetFoodStage ( )
protected

overridden on Edible_Base; so we don't have to parse configs all the time

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

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