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

◆ MessageToOwnerImportant()

void SpawnItemOnLocation::MessageToOwnerImportant ( string text)
protected

Send message to owner player in red color.

Возвращает
void
item_stone.MessageToOwnerImportant("Some Important Message");

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

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