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

◆ CanBeMovedOverride()

bool SpawnItemOnLocation::CanBeMovedOverride ( )
protected

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

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