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

◆ GetItemSize()

int SpawnItemOnLocation::GetItemSize ( )
protected

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

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