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

◆ MessageToOwnerFriendly()

void SpawnItemOnLocation::MessageToOwnerFriendly ( string text)
protected

Send message to owner player in green color.

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

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

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