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

◆ MessageToOwnerAction()

void SpawnItemOnLocation::MessageToOwnerAction ( string text)
protected

Send message to owner player in yellow color.

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

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

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