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

◆ SetCanBeMovedOverride()

void SpawnItemOnLocation::SetCanBeMovedOverride ( bool setting)
protected

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

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