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

◆ OnQuantityChanged()

void SpawnItemOnLocation::OnQuantityChanged ( float delta)
protected

Called on server side when this item's quantity is changed. Call super.OnQuantityChanged(); first when overriding this event.

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

6869{
6870 override bool CanPutAsAttachment(EntityAI parent)
6871 {
6872 return true;
6873 }
6874};
6875
6876//const bool QUANTITY_DEBUG_REMOVE_ME = false;
6877
6878class ItemBase extends InventoryItem
6879{
6883
6885
6886 static int m_DebugActionsMask;
6888 // ============================================
6889 // Variable Manipulation System
6890 // ============================================
6891 // Quantity
6892
6893 float m_VarQuantity;
6894 float m_VarQuantityPrev;//for client to know quantity changed during synchronization
6896 int m_VarQuantityMin;
6897 int m_VarQuantityMax;
6898 int m_Count;
6899 float m_VarStackMax;
6900 float m_StoreLoadedQuantity = float.LOWEST;
6901 // Wet
6902 float m_VarWet;
6903 float m_VarWetPrev;//for client to know wetness changed during synchronization
6904 float m_VarWetInit;
6905 float m_VarWetMin;
6906 float m_VarWetMax;
6907 // Cleanness
6908 int m_Cleanness;
6909 int m_CleannessInit;
6910 int m_CleannessMin;
6911 int m_CleannessMax;
6912 // impact sounds
6914 bool m_CanPlayImpactSound = true;
6915 float m_ImpactSpeed;
6917 //
6918 float m_HeatIsolation;
6919 float m_ItemModelLength;
6920 float m_ItemAttachOffset; // Offset length for when the item is attached e.g. to weapon
6922 int m_VarLiquidType;
6923 int m_ItemBehaviour; // -1 = not specified; 0 = heavy item; 1= onehanded item; 2 = twohanded item
6924 int m_QuickBarBonus;
6925 bool m_IsBeingPlaced;
6926 bool m_IsHologram;
6927 bool m_IsTakeable;
6928 bool m_ThrowItemOnDrop;
6931 bool m_FixDamageSystemInit = false; //can be changed on storage version check
6932 bool can_this_be_combined; //Check if item can be combined
6933 bool m_CanThisBeSplit; //Check if item can be split
6934 bool m_IsStoreLoad = false;
6935 bool m_CanShowQuantity;
6936 bool m_HasQuantityBar;
6937 protected bool m_CanBeDigged;
6938 protected bool m_IsResultOfSplit
6939
6940 string m_SoundAttType;
6941 // items color variables
6946 //-------------------------------------------------------
6947
6948 // light source managing
6950
6954
6955 //==============================================
6956 // agent system
6957 private int m_AttachedAgents;
6958
6960 void TransferModifiers(PlayerBase reciever);
6961
6962
6963 // Weapons & suppressors particle effects
6968 static int m_LastRegisteredWeaponID = 0;
6969
6970 // Overheating effects
6972 float m_OverheatingShots;
6973 ref Timer m_CheckOverheating;
6974 int m_ShotsToStartOverheating = 0; // After these many shots, the overheating effect begins
6975 int m_MaxOverheatingValue = 0; // Limits the number of shots that will be tracked
6976 float m_OverheatingDecayInterval = 1; // Timer's interval for decrementing overheat effect's lifespan
6977 ref array <ref OverheatingParticle> m_OverheatingParticles;
6978
6980 protected bool m_HideSelectionsBySlot;
6981
6982 // Admin Log
6983 PluginAdminLog m_AdminLog;
6984
6985 // misc
6986 ref Timer m_PhysDropTimer;
6987
6988 // Attachment Locking variables
6989 ref array<int> m_CompatibleLocks;
6990 protected int m_LockType;
6991 protected ref EffectSound m_LockingSound;
6992 protected string m_LockSoundSet;
6993
6994 // ItemSoundHandler
6995 protected const int ITEM_SOUNDS_MAX = 63; // optimize network synch
6996 protected int m_SoundSyncPlay; // id for sound to play
6997 protected int m_SoundSyncStop; // id for sound to stop
6999
7000 //temperature
7001 private float m_TemperaturePerQuantityWeight;
7002
7003 // -------------------------------------------------------------------------
7004 void ItemBase()
7005 {
7006 SetEventMask(EntityEvent.INIT); // Enable EOnInit event
7010
7011 if (!GetGame().IsDedicatedServer())
7012 {
7013 if (HasMuzzle())
7014 {
7016
7018 {
7020 }
7021 }
7022
7024 m_ActionsInitialize = false;
7025 }
7026
7027 m_OldLocation = null;
7028
7029 if (GetGame().IsServer())
7030 {
7031 m_AdminLog = PluginAdminLog.Cast(GetPlugin(PluginAdminLog));
7032 }
7033
7034 if (ConfigIsExisting("headSelectionsToHide"))
7035 {
7037 ConfigGetTextArray("headSelectionsToHide",m_HeadHidingSelections);
7038 }
7039
7040 m_HideSelectionsBySlot = false;
7041 if (ConfigIsExisting("hideSelectionsByinventorySlot"))
7042 {
7043 m_HideSelectionsBySlot = ConfigGetBool("hideSelectionsByinventorySlot");
7044 }
7045
7046 m_QuickBarBonus = Math.Max(0, ConfigGetInt("quickBarBonus"));
7047
7048 m_IsResultOfSplit = false;
7049
7051 }
7052
7053 override void InitItemVariables()
7054 {
7055 super.InitItemVariables();
7056
7057 m_VarQuantityInit = ConfigGetInt("varQuantityInit");
7058 m_VarQuantity = m_VarQuantityInit;//should be by the CE, this is just a precaution
7059 m_VarQuantityMin = ConfigGetInt("varQuantityMin");
7060 m_VarQuantityMax = ConfigGetInt("varQuantityMax");
7061 m_VarStackMax = ConfigGetFloat("varStackMax");
7062 m_Count = ConfigGetInt("count");
7063
7064 m_CanShowQuantity = ConfigGetBool("quantityShow");
7065 m_HasQuantityBar = ConfigGetBool("quantityBar");
7066
7067 m_CleannessInit = ConfigGetInt("varCleannessInit");
7069 m_CleannessMin = ConfigGetInt("varCleannessMin");
7070 m_CleannessMax = ConfigGetInt("varCleannessMax");
7071
7072 m_WantPlayImpactSound = false;
7073 m_ImpactSpeed = 0.0;
7074
7075 m_VarWetInit = ConfigGetFloat("varWetInit");
7077 m_VarWetMin = ConfigGetFloat("varWetMin");
7078 m_VarWetMax = ConfigGetFloat("varWetMax");
7079
7080 m_LiquidContainerMask = ConfigGetInt("liquidContainerType");
7081 if (IsLiquidContainer() && GetQuantity() != 0)
7083 m_IsBeingPlaced = false;
7084 m_IsHologram = false;
7085 m_IsTakeable = true;
7086 m_CanBeMovedOverride = false;
7090 m_CanBeDigged = ConfigGetBool("canBeDigged");
7091
7092 m_CompatibleLocks = new array<int>();
7093 ConfigGetIntArray("compatibleLocks", m_CompatibleLocks);
7094 m_LockType = ConfigGetInt("lockType");
7095
7096 //Define if item can be split and set ability to be combined accordingly
7097 m_CanThisBeSplit = false;
7098 can_this_be_combined = false;
7099 if (ConfigIsExisting("canBeSplit"))
7100 {
7101 can_this_be_combined = ConfigGetBool("canBeSplit");
7103 }
7104
7105 m_ItemBehaviour = -1;
7106 if (ConfigIsExisting("itemBehaviour"))
7107 m_ItemBehaviour = ConfigGetInt("itemBehaviour");
7108
7109 //RegisterNetSyncVariableInt("m_VariablesMask");
7110 if (HasQuantity()) RegisterNetSyncVariableFloat("m_VarQuantity", GetQuantityMin(), m_VarQuantityMax);
7111 RegisterNetSyncVariableFloat("m_VarWet", GetWetMin(), GetWetMax(), 2);
7112 RegisterNetSyncVariableInt("m_VarLiquidType");
7113 RegisterNetSyncVariableInt("m_Cleanness",0,1);
7114
7115 RegisterNetSyncVariableBoolSignal("m_WantPlayImpactSound");
7116 RegisterNetSyncVariableFloat("m_ImpactSpeed");
7117 RegisterNetSyncVariableInt("m_ImpactSoundSurfaceHash");
7118
7119 RegisterNetSyncVariableInt("m_ColorComponentR", 0, 255);
7120 RegisterNetSyncVariableInt("m_ColorComponentG", 0, 255);
7121 RegisterNetSyncVariableInt("m_ColorComponentB", 0, 255);
7122 RegisterNetSyncVariableInt("m_ColorComponentA", 0, 255);
7123
7124 RegisterNetSyncVariableBool("m_IsBeingPlaced");
7125 RegisterNetSyncVariableBool("m_IsTakeable");
7126 RegisterNetSyncVariableBool("m_IsHologram");
7127
7128 InitItemSounds();
7130 {
7131 RegisterNetSyncVariableInt("m_SoundSyncPlay", 0, ITEM_SOUNDS_MAX);
7132 RegisterNetSyncVariableInt("m_SoundSyncStop", 0, ITEM_SOUNDS_MAX);
7133 }
7134
7135 m_LockSoundSet = ConfigGetString("lockSoundSet");
7136
7138 if (ConfigIsExisting("temperaturePerQuantityWeight"))
7139 m_TemperaturePerQuantityWeight = ConfigGetFloat("temperaturePerQuantityWeight");
7140
7141 }
7142
7143 override int GetQuickBarBonus()
7144 {
7145 return m_QuickBarBonus;
7146 }
7147
7148 void InitializeActions()
7149 {
7151 if (!m_InputActionMap)
7152 {
7154 m_InputActionMap = iam;
7155 SetActions();
7157 }
7158 }
7159
7160 override void GetActions(typename action_input_type, out array<ActionBase_Basic> actions)
7161 {
7163 {
7164 m_ActionsInitialize = true;
7166 }
7167
7168 actions = m_InputActionMap.Get(action_input_type);
7169 }
7170
7171 void SetActions()
7172 {
7173 AddAction(ActionTakeItem);
7174 AddAction(ActionTakeItemToHands);
7175 AddAction(ActionWorldCraft);
7177 AddAction(ActionAttachWithSwitch);
7178 }
7179
7180 void SetActionAnimOverrides(); // Override action animation for specific item
7181
7182 void AddAction(typename actionName)
7183 {
7184 ActionBase action = ActionManagerBase.GetAction(actionName);
7185
7186 if (!action)
7187 {
7188 Debug.LogError("Action " + actionName + " dosn't exist!");
7189 return;
7190 }
7191
7192 typename ai = action.GetInputType();
7193 if (!ai)
7194 {
7195 m_ActionsInitialize = false;
7196 return;
7197 }
7198
7199 array<ActionBase_Basic> action_array = m_InputActionMap.Get(ai);
7200 if (!action_array)
7201 {
7202 action_array = new array<ActionBase_Basic>;
7203 m_InputActionMap.Insert(ai, action_array);
7204 }
7205 if (LogManager.IsActionLogEnable())
7206 {
7207 Debug.ActionLog(action.ToString() + " -> " + ai, this.ToString() , "n/a", "Add action");
7208 }
7209
7210 if (action_array.Find(action) != -1)
7211 {
7212 Debug.Log("Action " + action.Type() + " already added to " + this + ", skipping!");
7213 }
7214 else
7215 {
7216 action_array.Insert(action);
7217 }
7218 }
7219
7220 void RemoveAction(typename actionName)
7221 {
7222 PlayerBase player = PlayerBase.Cast(GetGame().GetPlayer());
7223 ActionBase action = player.GetActionManager().GetAction(actionName);
7224 typename ai = action.GetInputType();
7225 array<ActionBase_Basic> action_array = m_InputActionMap.Get(ai);
7226
7227 if (action_array)
7228 {
7229 action_array.RemoveItem(action);
7230 }
7231 }
7232
7233 // Allows override of default action command per item, defined in the SetActionAnimOverrides() of the item's class
7234 // Set -1 for params which should stay in default state
7235 void OverrideActionAnimation(typename action, int commandUID, int stanceMask = -1, int commandUIDProne = -1)
7236 {
7237 ActionOverrideData overrideData = new ActionOverrideData();
7238 overrideData.m_CommandUID = commandUID;
7239 overrideData.m_CommandUIDProne = commandUIDProne;
7240 overrideData.m_StanceMask = stanceMask;
7241
7242 TActionAnimOverrideMap actionMap = m_ItemActionOverrides.Get(action);
7243 if (!actionMap) // create new map of action > overidables map
7244 {
7245 actionMap = new TActionAnimOverrideMap();
7246 m_ItemActionOverrides.Insert(action, actionMap);
7247 }
7248
7249 actionMap.Insert(this.Type(), overrideData); // insert item -> overrides
7250
7251 }
7252
7253 void OnItemInHandsPlayerSwimStart(PlayerBase player);
7254
7255 ScriptedLightBase GetLight();
7256
7257 // Loads muzzle flash particle configuration from config and saves it to a map for faster access
7258 void LoadParticleConfigOnFire(int id)
7259 {
7260 if (!m_OnFireEffect)
7262
7265
7266 string config_to_search = "CfgVehicles";
7267 string muzzle_owner_config;
7268
7269 if (!m_OnFireEffect.Contains(id))
7270 {
7271 if (IsInherited(Weapon))
7272 config_to_search = "CfgWeapons";
7273
7274 muzzle_owner_config = config_to_search + " " + GetType() + " ";
7275
7276 string config_OnFire_class = muzzle_owner_config + "Particles " + "OnFire ";
7277
7278 int config_OnFire_subclass_count = GetGame().ConfigGetChildrenCount(config_OnFire_class);
7279
7280 if (config_OnFire_subclass_count > 0)
7281 {
7282 array<ref WeaponParticlesOnFire> WPOF_array = new array<ref WeaponParticlesOnFire>;
7283
7284 for (int i = 0; i < config_OnFire_subclass_count; i++)
7285 {
7286 string particle_class = "";
7287 GetGame().ConfigGetChildName(config_OnFire_class, i, particle_class);
7288 string config_OnFire_entry = config_OnFire_class + particle_class;
7289 WeaponParticlesOnFire WPOF = new WeaponParticlesOnFire(this, config_OnFire_entry);
7290 WPOF_array.Insert(WPOF);
7291 }
7292
7293
7294 m_OnFireEffect.Insert(id, WPOF_array);
7295 }
7296 }
7297
7298 if (!m_OnBulletCasingEjectEffect.Contains(id))
7299 {
7300 config_to_search = "CfgWeapons"; // Bullet Eject efect is supported on weapons only.
7301 muzzle_owner_config = config_to_search + " " + GetType() + " ";
7302
7303 string config_OnBulletCasingEject_class = muzzle_owner_config + "Particles " + "OnBulletCasingEject ";
7304
7305 int config_OnBulletCasingEject_count = GetGame().ConfigGetChildrenCount(config_OnBulletCasingEject_class);
7306
7307 if (config_OnBulletCasingEject_count > 0 && IsInherited(Weapon))
7308 {
7309 array<ref WeaponParticlesOnBulletCasingEject> WPOBE_array = new array<ref WeaponParticlesOnBulletCasingEject>;
7310
7311 for (i = 0; i < config_OnBulletCasingEject_count; i++)
7312 {
7313 string particle_class2 = "";
7314 GetGame().ConfigGetChildName(config_OnBulletCasingEject_class, i, particle_class2);
7315 string config_OnBulletCasingEject_entry = config_OnBulletCasingEject_class + particle_class2;
7316 WeaponParticlesOnBulletCasingEject WPOBE = new WeaponParticlesOnBulletCasingEject(this, config_OnBulletCasingEject_entry);
7317 WPOBE_array.Insert(WPOBE);
7318 }
7319
7320
7321 m_OnBulletCasingEjectEffect.Insert(id, WPOBE_array);
7322 }
7323 }
7324 }
7325
7326 // Loads muzzle flash particle configuration from config and saves it to a map for faster access
7328 {
7331
7332 if (!m_OnOverheatingEffect.Contains(id))
7333 {
7334 string config_to_search = "CfgVehicles";
7335
7336 if (IsInherited(Weapon))
7337 config_to_search = "CfgWeapons";
7338
7339 string muzzle_owner_config = config_to_search + " " + GetType() + " ";
7340 string config_OnOverheating_class = muzzle_owner_config + "Particles " + "OnOverheating ";
7341
7342 if (GetGame().ConfigIsExisting(config_OnOverheating_class))
7343 {
7344
7345 m_ShotsToStartOverheating = GetGame().ConfigGetFloat(config_OnOverheating_class + "shotsToStartOverheating");
7346
7348 {
7349 m_ShotsToStartOverheating = -1; // This prevents futher readings from config for future creations of this item
7350 string error = "Error reading config " + GetType() + ">Particles>OnOverheating - Parameter shotsToStartOverheating is configured wrong or is missing! Its value must be 1 or higher!";
7351 Error(error);
7352 return;
7353 }
7354
7355 m_OverheatingDecayInterval = GetGame().ConfigGetFloat(config_OnOverheating_class + "overheatingDecayInterval");
7356 m_MaxOverheatingValue = GetGame().ConfigGetFloat(config_OnOverheating_class + "maxOverheatingValue");
7357
7358
7359
7360 int config_OnOverheating_subclass_count = GetGame().ConfigGetChildrenCount(config_OnOverheating_class);
7361 array<ref WeaponParticlesOnOverheating> WPOOH_array = new array<ref WeaponParticlesOnOverheating>;
7362
7363 for (int i = 0; i < config_OnOverheating_subclass_count; i++)
7364 {
7365 string particle_class = "";
7366 GetGame().ConfigGetChildName(config_OnOverheating_class, i, particle_class);
7367 string config_OnOverheating_entry = config_OnOverheating_class + particle_class;
7368 int entry_type = GetGame().ConfigGetType(config_OnOverheating_entry);
7369
7370 if (entry_type == CT_CLASS)
7371 {
7372 WeaponParticlesOnOverheating WPOF = new WeaponParticlesOnOverheating(this, config_OnOverheating_entry);
7373 WPOOH_array.Insert(WPOF);
7374 }
7375 }
7376
7377
7378 m_OnOverheatingEffect.Insert(id, WPOOH_array);
7379 }
7380 }
7381 }
7382
7383 float GetOverheatingValue()
7384 {
7385 return m_OverheatingShots;
7386 }
7387
7388 void IncreaseOverheating(ItemBase weapon, string ammoType, ItemBase muzzle_owner, ItemBase suppressor, string config_to_search)
7389 {
7390 if (m_MaxOverheatingValue > 0)
7391 {
7393
7394 if (!m_CheckOverheating)
7396
7398 m_CheckOverheating.Run(m_OverheatingDecayInterval, this, "OnOverheatingDecay");
7399
7400 CheckOverheating(weapon, ammoType, muzzle_owner, suppressor, config_to_search);
7401 }
7402 }
7403
7404 void CheckOverheating(ItemBase weapon = null, string ammoType = "", ItemBase muzzle_owner = null, ItemBase suppressor = null, string config_to_search = "")
7405 {
7407 UpdateOverheating(weapon, ammoType, muzzle_owner, suppressor, config_to_search);
7408
7410 StartOverheating(weapon, ammoType, muzzle_owner, suppressor, config_to_search);
7411
7413 StopOverheating(weapon, ammoType, muzzle_owner, suppressor, config_to_search);
7414
7416 {
7418 }
7419 }
7420
7422 {
7424 }
7425
7426 void OnOverheatingDecay()
7427 {
7428 if (m_MaxOverheatingValue > 0)
7429 m_OverheatingShots -= 1 + m_OverheatingShots / m_MaxOverheatingValue; // The hotter a barrel is, the faster it needs to cool down.
7430 else
7432
7433 if (m_OverheatingShots <= 0)
7434 {
7437 }
7438 else
7439 {
7440 if (!m_CheckOverheating)
7442
7444 m_CheckOverheating.Run(m_OverheatingDecayInterval, this, "OnOverheatingDecay");
7445 }
7446
7447 CheckOverheating(this, "", this);
7448 }
7449
7450 void StartOverheating(ItemBase weapon = null, string ammoType = "", ItemBase muzzle_owner = null, ItemBase suppressor = null, string config_to_search = "")
7451 {
7453 ItemBase.PlayOverheatingParticles(this, ammoType, this, suppressor, "CfgWeapons");
7454 }
7455
7456 void UpdateOverheating(ItemBase weapon = null, string ammoType = "", ItemBase muzzle_owner = null, ItemBase suppressor = null, string config_to_search = "")
7457 {
7459 ItemBase.UpdateOverheatingParticles(this, ammoType, this, suppressor, "CfgWeapons");
7461 }
7462
7463 void StopOverheating(ItemBase weapon = null, string ammoType = "", ItemBase muzzle_owner = null, ItemBase suppressor = null, string config_to_search = "")
7464 {
7466 ItemBase.StopOverheatingParticles(weapon, ammoType, muzzle_owner, suppressor, config_to_search);
7467 }
7468
7469 void RegisterOverheatingParticle(Particle p, float min_heat_coef, float max_heat_coef, int particle_id, Object parent, vector local_pos, vector local_ori)
7470 {
7472 m_OverheatingParticles = new array<ref OverheatingParticle>;
7473
7474 OverheatingParticle OP = new OverheatingParticle();
7475 OP.RegisterParticle(p);
7476 OP.SetOverheatingLimitMin(min_heat_coef);
7477 OP.SetOverheatingLimitMax(max_heat_coef);
7478 OP.SetParticleParams(particle_id, parent, local_pos, local_ori);
7479
7480 m_OverheatingParticles.Insert(OP);
7481 }
7482
7483 float GetOverheatingCoef()
7484 {
7485 if (m_MaxOverheatingValue > 0)
7487
7488 return -1;
7489 }
7490
7492 {
7494 {
7495 float overheat_coef = GetOverheatingCoef();
7496 int count = m_OverheatingParticles.Count();
7497
7498 for (int i = count; i > 0; --i)
7499 {
7500 int id = i - 1;
7501 OverheatingParticle OP = m_OverheatingParticles.Get(id);
7502 Particle p = OP.GetParticle();
7503
7504 float overheat_min = OP.GetOverheatingLimitMin();
7505 float overheat_max = OP.GetOverheatingLimitMax();
7506
7507 if (overheat_coef < overheat_min && overheat_coef >= overheat_max)
7508 {
7509 if (p)
7510 {
7511 p.Stop();
7512 OP.RegisterParticle(null);
7513 }
7514 }
7515 }
7516 }
7517 }
7518
7520 {
7522 {
7523 for (int i = m_OverheatingParticles.Count(); i > 0; i--)
7524 {
7525 int id = i - 1;
7526 OverheatingParticle OP = m_OverheatingParticles.Get(id);
7527
7528 if (OP)
7529 {
7530 Particle p = OP.GetParticle();
7531
7532 if (p)
7533 {
7534 p.Stop();
7535 }
7536
7537 delete OP;
7538 }
7539 }
7540
7541 m_OverheatingParticles.Clear();
7543 }
7544 }
7545
7547 float GetInfectionChance(int system = 0, Param param = null)
7548 {
7549 return 0.0;
7550 }
7551
7552
7553 float GetDisinfectQuantity(int system = 0, Param param1 = null)
7554 {
7555 return 250;//default value
7556 }
7557
7558 float GetFilterDamageRatio()
7559 {
7560 return 0;
7561 }
7562
7564 bool HasMuzzle()
7565 {
7566 if (IsInherited(Weapon) || IsInherited(SuppressorBase))
7567 return true;
7568
7569 return false;
7570 }
7571
7573 int GetMuzzleID()
7574 {
7575 if (!m_WeaponTypeToID)
7577
7578 if (m_WeaponTypeToID.Contains(GetType()))
7579 {
7580 return m_WeaponTypeToID.Get(GetType());
7581 }
7582 else
7583 {
7584 // Register new weapon ID
7586 }
7587
7589 }
7590
7597 {
7598 return -1;
7599 }
7600
7601
7602
7603 // -------------------------------------------------------------------------
7604 void ~ItemBase()
7605 {
7606 if (GetGame() && GetGame().GetPlayer() && (!GetGame().IsDedicatedServer()))
7607 {
7608 PlayerBase player = PlayerBase.Cast(GetGame().GetPlayer());
7609 int r_index = player.GetHumanInventory().FindUserReservedLocationIndex(this);
7610
7611 if (r_index >= 0)
7612 {
7613 InventoryLocation r_il = new InventoryLocation;
7614 player.GetHumanInventory().GetUserReservedLocation(r_index,r_il);
7615
7616 player.GetHumanInventory().ClearUserReservedLocationAtIndex(r_index);
7617 int r_type = r_il.GetType();
7618 if (r_type == InventoryLocationType.CARGO || r_type == InventoryLocationType.PROXYCARGO)
7619 {
7620 r_il.GetParent().GetOnReleaseLock().Invoke(this);
7621 }
7622 else if (r_type == InventoryLocationType.ATTACHMENT)
7623 {
7624 r_il.GetParent().GetOnAttachmentReleaseLock().Invoke(this, r_il.GetSlot());
7625 }
7626
7627 }
7628
7629 player.GetHumanInventory().ClearUserReservedLocation(this);
7630 }
7631
7632 if (m_LockingSound)
7633 SEffectManager.DestroyEffect(m_LockingSound);
7634 }
7635
7636
7637
7638 // -------------------------------------------------------------------------
7639 static int GetDebugActionsMask()
7640 {
7641 return ItemBase.m_DebugActionsMask;
7642 }
7643
7644 static bool HasDebugActionsMask(int mask)
7645 {
7646 return ItemBase.m_DebugActionsMask & mask;
7647 }
7648
7649 static void SetDebugActionsMask(int mask)
7650 {
7651 ItemBase.m_DebugActionsMask = mask;
7652 }
7653
7654 static void AddDebugActionsMask(int mask)
7655 {
7656 ItemBase.m_DebugActionsMask |= mask;
7657 }
7658
7659 static void RemoveDebugActionsMask(int mask)
7660 {
7661 ItemBase.m_DebugActionsMask &= ~mask;
7662 }
7663
7664 static void ToggleDebugActionsMask(int mask)
7665 {
7666 if (HasDebugActionsMask(mask))
7667 {
7669 }
7670 else
7671 {
7672 AddDebugActionsMask(mask);
7673 }
7674 }
7675
7676 // -------------------------------------------------------------------------
7677 void SetCEBasedQuantity()
7678 {
7679 if (GetEconomyProfile())
7680 {
7681 float q_max = GetEconomyProfile().GetQuantityMax();
7682 if (q_max > 0)
7683 {
7684 float q_min = GetEconomyProfile().GetQuantityMin();
7685 float quantity_randomized = Math.RandomFloatInclusive(q_min, q_max);
7686
7687 if (HasComponent(COMP_TYPE_ENERGY_MANAGER))//more direct access for speed
7688 {
7689 ComponentEnergyManager comp = GetCompEM();
7690 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
7691 {
7692 comp.SetEnergy0To1(quantity_randomized);
7693 }
7694 }
7695 else if (HasQuantity())
7696 {
7697 SetQuantityNormalized(quantity_randomized, false);
7698 //PrintString("<==> Normalized quantity for item: "+ GetType()+", qmin:"+q_min.ToString()+"; qmax:"+q_max.ToString()+";quantity:" +quantity_randomized.ToString());
7699 }
7700
7701 }
7702 }
7703 }
7704
7706 void LockToParent()
7707 {
7708 EntityAI parent = GetHierarchyParent();
7709
7710 if (parent)
7711 {
7712 InventoryLocation inventory_location_to_lock = new InventoryLocation;
7713 GetInventory().GetCurrentInventoryLocation(inventory_location_to_lock);
7714 parent.GetInventory().SetSlotLock(inventory_location_to_lock.GetSlot(), true);
7715 }
7716 }
7717
7719 void UnlockFromParent()
7720 {
7721 EntityAI parent = GetHierarchyParent();
7722
7723 if (parent)
7724 {
7725 InventoryLocation inventory_location_to_unlock = new InventoryLocation;
7726 GetInventory().GetCurrentInventoryLocation(inventory_location_to_unlock);
7727 parent.GetInventory().SetSlotLock(inventory_location_to_unlock.GetSlot(), false);
7728 }
7729 }
7730
7731 override void CombineItemsClient(EntityAI entity2, bool use_stack_max = true)
7732 {
7733 /*
7734 ref Param1<EntityAI> item = new Param1<EntityAI>(entity2);
7735 RPCSingleParam(ERPCs.RPC_ITEM_COMBINE, item, GetGame().GetPlayer());
7736 */
7737 ItemBase item2 = ItemBase.Cast(entity2);
7738
7739 if (GetGame().IsClient())
7740 {
7741 if (ScriptInputUserData.CanStoreInputUserData())
7742 {
7743 ScriptInputUserData ctx = new ScriptInputUserData;
7745 ctx.Write(-1);
7746 ItemBase i1 = this; // @NOTE: workaround for correct serialization
7747 ctx.Write(i1);
7748 ctx.Write(item2);
7749 ctx.Write(use_stack_max);
7750 ctx.Write(-1);
7751 ctx.Send();
7752
7753 if (IsCombineAll(item2, use_stack_max))
7754 {
7755 GetGame().GetPlayer().GetInventory().AddInventoryReservationEx(item2,null,GameInventory.c_InventoryReservationTimeoutShortMS);
7756 }
7757 }
7758 }
7759 else if (!GetGame().IsMultiplayer())
7760 {
7761 CombineItems(item2, use_stack_max);
7762 }
7763 }
7764
7765 bool IsLiquidPresent()
7766 {
7767 return (GetLiquidType() != 0 && HasQuantity());
7768 }
7769
7770 bool IsLiquidContainer()
7771 {
7772 return m_LiquidContainerMask != 0;
7773 }
7774
7776 {
7777 return m_LiquidContainerMask;
7778 }
7779
7780 bool IsBloodContainer()
7781 {
7782 //m_LiquidContainerMask & GROUP_LIQUID_BLOOD ???
7783 return false;
7784 }
7785
7786 bool IsNVG()
7787 {
7788 return false;
7789 }
7790
7793 bool IsExplosive()
7794 {
7795 return false;
7796 }
7797
7799 {
7800 return "";
7801 }
7802
7804
7805 bool IsLightSource()
7806 {
7807 return false;
7808 }
7809
7811 {
7812 return true;
7813 }
7814
7815 //--- ACTION CONDITIONS
7816 //direction
7817 bool IsFacingPlayer(PlayerBase player, string selection)
7818 {
7819 return true;
7820 }
7821
7822 bool IsPlayerInside(PlayerBase player, string selection)
7823 {
7824 return true;
7825 }
7826
7827 override bool CanObstruct()
7828 {
7829 PlayerBase player = PlayerBase.Cast(g_Game.GetPlayer());
7830 return !player || !IsPlayerInside(player, "");
7831 }
7832
7833 override bool IsBeingPlaced()
7834 {
7835 return m_IsBeingPlaced;
7836 }
7837
7838 void SetIsBeingPlaced(bool is_being_placed)
7839 {
7840 m_IsBeingPlaced = is_being_placed;
7841 if (!is_being_placed)
7843 SetSynchDirty();
7844 }
7845
7846 //server-side
7847 void OnEndPlacement() {}
7848
7849 override bool IsHologram()
7850 {
7851 return m_IsHologram;
7852 }
7853
7854 bool CanBeDigged()
7855 {
7856 return m_CanBeDigged;
7857 }
7858
7860 {
7861 return 1;
7862 }
7863
7864 bool CanMakeGardenplot()
7865 {
7866 return false;
7867 }
7868
7869 void SetIsHologram(bool is_hologram)
7870 {
7871 m_IsHologram = is_hologram;
7872 SetSynchDirty();
7873 }
7874 /*
7875 protected float GetNutritionalEnergy()
7876 {
7877 Edible_Base edible = Edible_Base.Cast(this);
7878 return edible.GetFoodEnergy();
7879 }
7880
7881 protected float GetNutritionalWaterContent()
7882 {
7883 Edible_Base edible = Edible_Base.Cast(this);
7884 return edible.GetFoodWater();
7885 }
7886
7887 protected float GetNutritionalIndex()
7888 {
7889 Edible_Base edible = Edible_Base.Cast(this);
7890 return edible.GetFoodNutritionalIndex();
7891 }
7892
7893 protected float GetNutritionalFullnessIndex()
7894 {
7895 Edible_Base edible = Edible_Base.Cast(this);
7896 return edible.GetFoodTotalVolume();
7897 }
7898
7899 protected float GetNutritionalToxicity()
7900 {
7901 Edible_Base edible = Edible_Base.Cast(this);
7902 return edible.GetFoodToxicity();
7903
7904 }
7905 */
7906
7907
7908 // -------------------------------------------------------------------------
7909 override void OnMovedInsideCargo(EntityAI container)
7910 {
7911 super.OnMovedInsideCargo(container);
7912
7913 MiscGameplayFunctions.RemoveAllAttachedChildrenByTypename(this, {Bolt_Base});
7914 }
7915
7916 override void EEItemLocationChanged(notnull InventoryLocation oldLoc, notnull InventoryLocation newLoc)
7917 {
7918 super.EEItemLocationChanged(oldLoc,newLoc);
7919
7920 PlayerBase new_player = null;
7921 PlayerBase old_player = null;
7922
7923 if (newLoc.GetParent())
7924 new_player = PlayerBase.Cast(newLoc.GetParent().GetHierarchyRootPlayer());
7925
7926 if (oldLoc.GetParent())
7927 old_player = PlayerBase.Cast(oldLoc.GetParent().GetHierarchyRootPlayer());
7928
7929 if (old_player && oldLoc.GetType() == InventoryLocationType.HANDS)
7930 {
7931 int r_index = old_player.GetHumanInventory().FindUserReservedLocationIndex(this);
7932
7933 if (r_index >= 0)
7934 {
7935 InventoryLocation r_il = new InventoryLocation;
7936 old_player.GetHumanInventory().GetUserReservedLocation(r_index,r_il);
7937
7938 old_player.GetHumanInventory().ClearUserReservedLocationAtIndex(r_index);
7939 int r_type = r_il.GetType();
7940 if (r_type == InventoryLocationType.CARGO || r_type == InventoryLocationType.PROXYCARGO)
7941 {
7942 r_il.GetParent().GetOnReleaseLock().Invoke(this);
7943 }
7944 else if (r_type == InventoryLocationType.ATTACHMENT)
7945 {
7946 r_il.GetParent().GetOnAttachmentReleaseLock().Invoke(this, r_il.GetSlot());
7947 }
7948
7949 }
7950 }
7951
7952 if (newLoc.GetType() == InventoryLocationType.HANDS)
7953 {
7954 if (new_player)
7955 new_player.ForceStandUpForHeavyItems(newLoc.GetItem());
7956
7957 if (new_player == old_player)
7958 {
7959
7960 if (oldLoc.GetParent() && new_player.GetHumanInventory().LocationGetEntity(oldLoc) == NULL)
7961 {
7962 if (oldLoc.GetType() == InventoryLocationType.CARGO)
7963 {
7964 if (oldLoc.GetParent().GetInventory().TestAddEntityInCargoExLoc(oldLoc, false, false, false, true, false, false))
7965 {
7966 new_player.GetHumanInventory().SetUserReservedLocation(this,oldLoc);
7967 }
7968 }
7969 else
7970 {
7971 new_player.GetHumanInventory().SetUserReservedLocation(this,oldLoc);
7972 }
7973 }
7974
7975 if (new_player.GetHumanInventory().FindUserReservedLocationIndex(this) >= 0)
7976 {
7977 int type = oldLoc.GetType();
7978 if (type == InventoryLocationType.CARGO || type == InventoryLocationType.PROXYCARGO)
7979 {
7980 oldLoc.GetParent().GetOnSetLock().Invoke(this);
7981 }
7982 else if (type == InventoryLocationType.ATTACHMENT)
7983 {
7984 oldLoc.GetParent().GetOnAttachmentSetLock().Invoke(this, oldLoc.GetSlot());
7985 }
7986 }
7987 if (!m_OldLocation)
7988 {
7989 m_OldLocation = new InventoryLocation;
7990 }
7991 m_OldLocation.Copy(oldLoc);
7992 }
7993 else
7994 {
7995 if (m_OldLocation)
7996 {
7997 m_OldLocation.Reset();
7998 }
7999 }
8000
8002 }
8003 else
8004 {
8005 if (new_player)
8006 {
8007 int res_index = new_player.GetHumanInventory().FindCollidingUserReservedLocationIndex(this, newLoc);
8008 if (res_index >= 0)
8009 {
8010 InventoryLocation il = new InventoryLocation;
8011 new_player.GetHumanInventory().GetUserReservedLocation(res_index,il);
8012 ItemBase it = ItemBase.Cast(il.GetItem());
8013 new_player.GetHumanInventory().ClearUserReservedLocationAtIndex(res_index);
8014 int rel_type = il.GetType();
8015 if (rel_type == InventoryLocationType.CARGO || rel_type == InventoryLocationType.PROXYCARGO)
8016 {
8017 il.GetParent().GetOnReleaseLock().Invoke(it);
8018 }
8019 else if (rel_type == InventoryLocationType.ATTACHMENT)
8020 {
8021 il.GetParent().GetOnAttachmentReleaseLock().Invoke(it, il.GetSlot());
8022 }
8023 //it.GetOnReleaseLock().Invoke(it);
8024 }
8025 }
8026 else if (old_player && newLoc.GetType() == InventoryLocationType.GROUND && m_ThrowItemOnDrop)
8027 {
8028 //ThrowPhysically(old_player, vector.Zero);
8029 m_ThrowItemOnDrop = false;
8030 }
8031
8032 if (m_OldLocation)
8033 {
8034 m_OldLocation.Reset();
8035 }
8036 }
8037 }
8038
8039 override void EOnContact(IEntity other, Contact extra)
8040 {
8042 {
8043 int liquidType = -1;
8044 float impactSpeed = ProcessImpactSoundEx(other, extra, m_ConfigWeight, m_ImpactSoundSurfaceHash, liquidType);
8045 if (impactSpeed > 0.0)
8046 {
8047 m_ImpactSpeed = impactSpeed;
8048 #ifndef SERVER
8049 PlayImpactSound(m_ConfigWeight, m_ImpactSpeed, m_ImpactSoundSurfaceHash);
8050 #else
8051 m_WantPlayImpactSound = true;
8052 SetSynchDirty();
8053 #endif
8054 m_CanPlayImpactSound = (liquidType == -1);// prevents further playing of the sound when the surface is a liquid type
8055 }
8056 }
8057
8058 #ifdef SERVER
8059 if (GetCompEM() && GetCompEM().IsPlugged())
8060 {
8061 if (GetCompEM().GetCordLength() < vector.Distance(GetPosition(), GetCompEM().GetEnergySource().GetPosition()))
8062 GetCompEM().UnplugThis();
8063 }
8064 #endif
8065 }
8066
8067 void RefreshPhysics();
8068
8069 override void OnCreatePhysics()
8070 {
8072 }
8073
8074 override void OnItemAttachmentSlotChanged(notnull InventoryLocation oldLoc, notnull InventoryLocation newLoc)
8075 {
8076
8077 }
8078 // -------------------------------------------------------------------------
8079 override void OnItemLocationChanged(EntityAI old_owner, EntityAI new_owner)
8080 {
8081 super.OnItemLocationChanged(old_owner, new_owner);
8082
8083 PlayerBase relatedPlayer = PlayerBase.Cast(old_owner);
8084 PlayerBase playerNew = PlayerBase.Cast(new_owner);
8085
8086 if (!relatedPlayer && playerNew)
8087 relatedPlayer = playerNew;
8088
8089 if (relatedPlayer && relatedPlayer.GetPerformedActionID() != -1)
8090 {
8091 ActionManagerBase actionMgr = relatedPlayer.GetActionManager();
8092 if (actionMgr)
8093 {
8094 ActionBase currentAction = actionMgr.GetRunningAction();
8095 if (currentAction)
8096 currentAction.OnItemLocationChanged(this);
8097 }
8098 }
8099
8100 Man ownerPlayerOld = null;
8101 Man ownerPlayerNew = null;
8102
8103 if (old_owner)
8104 {
8105 if (old_owner.IsMan())
8106 {
8107 ownerPlayerOld = Man.Cast(old_owner);
8108 }
8109 else
8110 {
8111 ownerPlayerOld = Man.Cast(old_owner.GetHierarchyRootPlayer());
8112 }
8113 }
8114 else
8115 {
8116 if (new_owner && IsElectricAppliance() && GetCompEM() && GetCompEM().IsPlugged())
8117 {
8118 ActionBase action = ActionManagerBase.GetAction(ActionRepositionPluggedItem);
8119
8120 if (!action || !playerNew || playerNew.GetPerformedActionID() != action.GetID())
8121 {
8122 GetCompEM().UnplugThis();
8123 }
8124 }
8125 }
8126
8127 if (new_owner)
8128 {
8129 if (new_owner.IsMan())
8130 {
8131 ownerPlayerNew = Man.Cast(new_owner);
8132 }
8133 else
8134 {
8135 ownerPlayerNew = Man.Cast(new_owner.GetHierarchyRootPlayer());
8136 }
8137 }
8138
8139 if (ownerPlayerOld != ownerPlayerNew)
8140 {
8141 if (ownerPlayerOld)
8142 {
8143 array<EntityAI> subItemsExit = new array<EntityAI>;
8144 GetInventory().EnumerateInventory(InventoryTraversalType.PREORDER,subItemsExit);
8145 for (int i = 0; i < subItemsExit.Count(); i++)
8146 {
8147 ItemBase itemExit = ItemBase.Cast(subItemsExit.Get(i));
8148 itemExit.OnInventoryExit(ownerPlayerOld);
8149 }
8150 }
8151
8152 if (ownerPlayerNew)
8153 {
8154 array<EntityAI> subItemsEnter = new array<EntityAI>;
8155 GetInventory().EnumerateInventory(InventoryTraversalType.PREORDER,subItemsEnter);
8156 for (int j = 0; j < subItemsEnter.Count(); j++)
8157 {
8158 ItemBase itemEnter = ItemBase.Cast(subItemsEnter.Get(j));
8159 itemEnter.OnInventoryEnter(ownerPlayerNew);
8160 }
8161 }
8162 }
8163 else if (ownerPlayerNew != null)
8164 {
8165 PlayerBase nplayer;
8166 if (PlayerBase.CastTo(nplayer, ownerPlayerNew))
8167 {
8168 array<EntityAI> subItemsUpdate = new array<EntityAI>;
8169 GetInventory().EnumerateInventory(InventoryTraversalType.PREORDER,subItemsUpdate);
8170 for (int k = 0; k < subItemsUpdate.Count(); k++)
8171 {
8172 ItemBase itemUpdate = ItemBase.Cast(subItemsUpdate.Get(k));
8173 itemUpdate.UpdateQuickbarShortcutVisibility(nplayer);
8174 }
8175 }
8176 }
8177
8178 if (old_owner)
8179 old_owner.OnChildItemRemoved(this);
8180 if (new_owner)
8181 new_owner.OnChildItemReceived(this);
8182 }
8183
8184 // -------------------------------------------------------------------------------
8185 override void EEDelete(EntityAI parent)
8186 {
8187 super.EEDelete(parent);
8188 PlayerBase player = PlayerBase.Cast(GetHierarchyRootPlayer());
8189 if (player)
8190 {
8191 OnInventoryExit(player);
8192
8193 if (player.IsAlive())
8194 {
8195 int r_index = player.GetHumanInventory().FindUserReservedLocationIndex(this);
8196 if (r_index >= 0)
8197 {
8198 InventoryLocation r_il = new InventoryLocation;
8199 player.GetHumanInventory().GetUserReservedLocation(r_index,r_il);
8200
8201 player.GetHumanInventory().ClearUserReservedLocationAtIndex(r_index);
8202 int r_type = r_il.GetType();
8203 if (r_type == InventoryLocationType.CARGO || r_type == InventoryLocationType.PROXYCARGO)
8204 {
8205 r_il.GetParent().GetOnReleaseLock().Invoke(this);
8206 }
8207 else if (r_type == InventoryLocationType.ATTACHMENT)
8208 {
8209 r_il.GetParent().GetOnAttachmentReleaseLock().Invoke(this, r_il.GetSlot());
8210 }
8211
8212 }
8213
8214 player.RemoveQuickBarEntityShortcut(this);
8215 }
8216 }
8217 }
8218 // -------------------------------------------------------------------------------
8219 override void EEKilled(Object killer)
8220 {
8221 super.EEKilled(killer);
8222
8224 if (killer && killer.IsFireplace() && CanExplodeInFire())
8225 {
8226 if (GetTemperature() >= GameConstants.ITEM_TEMPERATURE_TO_EXPLODE_MIN)
8227 {
8228 if (IsMagazine())
8229 {
8230 if (Magazine.Cast(this).GetAmmoCount() > 0)
8231 {
8232 ExplodeAmmo();
8233 }
8234 }
8235 else
8236 {
8237 Explode(DamageType.EXPLOSION);
8238 }
8239 }
8240 }
8241 }
8242
8243 override void OnWasAttached(EntityAI parent, int slot_id)
8244 {
8245 MiscGameplayFunctions.RemoveAllAttachedChildrenByTypename(this, {Bolt_Base});
8246
8247 super.OnWasAttached(parent, slot_id);
8248
8249 if (HasQuantity())
8250 UpdateNetSyncVariableFloat("m_VarQuantity", GetQuantityMin(), m_VarQuantityMax);
8251
8252 PlayAttachSound(InventorySlots.GetSlotName(slot_id));
8253 }
8254
8255 override void OnWasDetached(EntityAI parent, int slot_id)
8256 {
8257 super.OnWasDetached(parent, slot_id);
8258
8259 if (HasQuantity())
8260 UpdateNetSyncVariableFloat("m_VarQuantity", GetQuantityMin(), m_VarQuantityMax);
8261 }
8262
8263 override string ChangeIntoOnAttach(string slot)
8264 {
8265 int idx;
8266 TStringArray inventory_slots = new TStringArray;
8267 TStringArray attach_types = new TStringArray;
8268
8269 ConfigGetTextArray("ChangeInventorySlot",inventory_slots);
8270 if (inventory_slots.Count() < 1) //is string
8271 {
8272 inventory_slots.Insert(ConfigGetString("ChangeInventorySlot"));
8273 attach_types.Insert(ConfigGetString("ChangeIntoOnAttach"));
8274 }
8275 else //is array
8276 {
8277 ConfigGetTextArray("ChangeIntoOnAttach",attach_types);
8278 }
8279
8280 idx = inventory_slots.Find(slot);
8281 if (idx < 0)
8282 return "";
8283
8284 return attach_types.Get(idx);
8285 }
8286
8287 override string ChangeIntoOnDetach()
8288 {
8289 int idx = -1;
8290 string slot;
8291
8292 TStringArray inventory_slots = new TStringArray;
8293 TStringArray detach_types = new TStringArray;
8294
8295 this.ConfigGetTextArray("ChangeInventorySlot",inventory_slots);
8296 if (inventory_slots.Count() < 1) //is string
8297 {
8298 inventory_slots.Insert(this.ConfigGetString("ChangeInventorySlot"));
8299 detach_types.Insert(this.ConfigGetString("ChangeIntoOnDetach"));
8300 }
8301 else //is array
8302 {
8303 this.ConfigGetTextArray("ChangeIntoOnDetach",detach_types);
8304 if (detach_types.Count() < 1)
8305 detach_types.Insert(this.ConfigGetString("ChangeIntoOnDetach"));
8306 }
8307
8308 for (int i = 0; i < inventory_slots.Count(); i++)
8309 {
8310 slot = inventory_slots.Get(i);
8311 }
8312
8313 if (slot != "")
8314 {
8315 if (detach_types.Count() == 1)
8316 idx = 0;
8317 else
8318 idx = inventory_slots.Find(slot);
8319 }
8320 if (idx < 0)
8321 return "";
8322
8323 return detach_types.Get(idx);
8324 }
8325
8326 void ExplodeAmmo()
8327 {
8328 //timer
8329 ref Timer explode_timer = new Timer(CALL_CATEGORY_SYSTEM);
8330
8331 //min/max time
8332 float min_time = 1;
8333 float max_time = 3;
8334 float delay = Math.RandomFloat(min_time, max_time);
8335
8336 explode_timer.Run(delay, this, "DoAmmoExplosion");
8337 }
8338
8339 void DoAmmoExplosion()
8340 {
8341 Magazine magazine = Magazine.Cast(this);
8342 int pop_sounds_count = 6;
8343 string pop_sounds[ 6 ] = { "ammopops_1","ammopops_2","ammopops_3","ammopops_4","ammopops_5","ammopops_6" };
8344
8345 //play sound
8346 int sound_idx = Math.RandomInt(0, pop_sounds_count - 1);
8347 string sound_name = pop_sounds[ sound_idx ];
8348 GetGame().CreateSoundOnObject(this, sound_name, 20, false);
8349
8350 //remove ammo count
8351 magazine.ServerAddAmmoCount(-1);
8352
8353 //if condition then repeat -> ExplodeAmmo
8354 float min_temp_to_explode = 100; //min temperature for item to explode
8355
8356 if (magazine.GetAmmoCount() > 0 && GetTemperature() >= min_temp_to_explode) //TODO ? add check for parent -> fireplace
8357 {
8358 ExplodeAmmo();
8359 }
8360 }
8361
8362 // -------------------------------------------------------------------------------
8363 override void EEHitBy(TotalDamageResult damageResult, int damageType, EntityAI source, int component, string dmgZone, string ammo, vector modelPos, float speedCoef)
8364 {
8365 super.EEHitBy(damageResult, damageType, source, component, dmgZone, ammo, modelPos, speedCoef);
8366
8367 const int CHANCE_DAMAGE_CARGO = 4;
8368 const int CHANCE_DAMAGE_ATTACHMENT = 1;
8369 const int CHANCE_DAMAGE_NOTHING = 2;
8370
8371 if (IsClothing() || IsContainer() || IsItemTent())
8372 {
8373 float dmg = damageResult.GetDamage("","Health") * -0.5;
8374 int chances;
8375 int rnd;
8376
8377 if (GetInventory().GetCargo())
8378 {
8379 chances = CHANCE_DAMAGE_CARGO + CHANCE_DAMAGE_ATTACHMENT + CHANCE_DAMAGE_NOTHING;
8380 rnd = Math.RandomInt(0,chances);
8381
8382 if (rnd < CHANCE_DAMAGE_CARGO)
8383 {
8384 DamageItemInCargo(dmg);
8385 }
8386 else if (rnd < (chances - CHANCE_DAMAGE_NOTHING))
8387 {
8389 }
8390 }
8391 else
8392 {
8393 chances = CHANCE_DAMAGE_ATTACHMENT + CHANCE_DAMAGE_NOTHING;
8394 rnd = Math.RandomInt(0,chances);
8395
8396 if (rnd < CHANCE_DAMAGE_ATTACHMENT)
8397 {
8399 }
8400 }
8401 }
8402 }
8403
8404 bool DamageItemInCargo(float damage)
8405 {
8406 if (GetInventory().GetCargo())
8407 {
8408 int item_count = GetInventory().GetCargo().GetItemCount();
8409 if (item_count > 0)
8410 {
8411 int random_pick = Math.RandomInt(0, item_count);
8412 ItemBase item = ItemBase.Cast(GetInventory().GetCargo().GetItem(random_pick));
8413 if (!item.IsExplosive())
8414 {
8415 item.AddHealth("","",damage);
8416 return true;
8417 }
8418 }
8419 }
8420 return false;
8421 }
8422
8423 bool DamageItemAttachments(float damage)
8424 {
8425 int attachment_count = GetInventory().AttachmentCount();
8426 if (attachment_count > 0)
8427 {
8428 int random_pick = Math.RandomInt(0, attachment_count);
8429 ItemBase attachment = ItemBase.Cast(GetInventory().GetAttachmentFromIndex(random_pick));
8430 if (!attachment.IsExplosive())
8431 {
8432 attachment.AddHealth("","",damage);
8433 return true;
8434 }
8435 }
8436 return false;
8437 }
8438
8439 override bool IsSplitable()
8440 {
8441 return m_CanThisBeSplit;
8442 }
8443 //----------------
8444 override bool CanBeSplit()
8445 {
8446 if (IsSplitable() && (GetQuantity() > 1))
8447 return GetInventory().CanRemoveEntity();
8448
8449 return false;
8450 }
8451
8452 protected bool ShouldSplitQuantity(float quantity)
8453 {
8454 // don't call 'CanBeSplit' here, too strict and will introduce a freeze-crash when dismantling fence with a fireplace nearby
8455 if (!IsSplitable())
8456 return false;
8457
8458 // nothing to split?
8459 if (GetQuantity() <= 1)
8460 return false;
8461
8462 // check if we should re-use the item instead of creating a new copy?
8463 // implicit cast to int, if 'IsSplitable' returns true, these values are assumed ints
8464 int delta = GetQuantity() - quantity;
8465 if (delta == 0)
8466 return false;
8467
8468 // valid to split
8469 return true;
8470 }
8471
8472 override void SplitIntoStackMaxClient(EntityAI destination_entity, int slot_id )
8473 {
8474 if (GetGame().IsClient())
8475 {
8476 if (ScriptInputUserData.CanStoreInputUserData())
8477 {
8478 ScriptInputUserData ctx = new ScriptInputUserData;
8480 ctx.Write(1);
8481 ItemBase i1 = this; // @NOTE: workaround for correct serialization
8482 ctx.Write(i1);
8483 ctx.Write(destination_entity);
8484 ctx.Write(true);
8485 ctx.Write(slot_id);
8486 ctx.Send();
8487 }
8488 }
8489 else if (!GetGame().IsMultiplayer())
8490 {
8491 SplitIntoStackMax(destination_entity, slot_id, PlayerBase.Cast(GetGame().GetPlayer()));
8492 }
8493 }
8494
8495 void SplitIntoStackMax(EntityAI destination_entity, int slot_id, PlayerBase player)
8496 {
8497 float split_quantity_new;
8498 ItemBase new_item;
8499 float quantity = GetQuantity();
8500 float stack_max = GetTargetQuantityMax(slot_id);
8501 InventoryLocation loc = new InventoryLocation;
8502
8503 if (destination_entity && slot_id != -1 && InventorySlots.IsSlotIdValid(slot_id))
8504 {
8505 if (stack_max <= GetQuantity())
8506 split_quantity_new = stack_max;
8507 else
8508 split_quantity_new = GetQuantity();
8509
8510 if (ShouldSplitQuantity(split_quantity_new))
8511 {
8512 new_item = ItemBase.Cast(destination_entity.GetInventory().CreateAttachmentEx(this.GetType(), slot_id));
8513 if (new_item)
8514 {
8515 new_item.SetResultOfSplit(true);
8516 MiscGameplayFunctions.TransferItemProperties(this, new_item);
8517 AddQuantity(-split_quantity_new, false, true);
8518 new_item.SetQuantity(split_quantity_new, false, true);
8519 }
8520 }
8521 }
8522 else if (destination_entity && slot_id == -1)
8523 {
8524 if (quantity > stack_max)
8525 split_quantity_new = stack_max;
8526 else
8527 split_quantity_new = quantity;
8528
8529 if (ShouldSplitQuantity(split_quantity_new))
8530 {
8531 if (destination_entity.GetInventory().FindFreeLocationFor(this, FindInventoryLocationType.ANY, loc))
8532 {
8533 Object o = destination_entity.GetInventory().LocationCreateEntity(loc, GetType(), ECE_IN_INVENTORY, RF_DEFAULT);
8534 new_item = ItemBase.Cast(o);
8535 }
8536
8537 if (new_item)
8538 {
8539 new_item.SetResultOfSplit(true);
8540 MiscGameplayFunctions.TransferItemProperties(this, new_item);
8541 AddQuantity(-split_quantity_new, false, true);
8542 new_item.SetQuantity(split_quantity_new, false, true);
8543 }
8544 }
8545 }
8546 else
8547 {
8548 if (stack_max != 0)
8549 {
8550 if (stack_max < GetQuantity())
8551 {
8552 split_quantity_new = GetQuantity() - stack_max;
8553 }
8554
8555 if (split_quantity_new == 0)
8556 {
8557 if (!GetGame().IsMultiplayer())
8558 player.PhysicalPredictiveDropItem(this);
8559 else
8560 player.ServerDropEntity(this);
8561 return;
8562 }
8563
8564 if (ShouldSplitQuantity(split_quantity_new))
8565 {
8566 new_item = ItemBase.Cast(GetGame().CreateObjectEx(GetType(), player.GetWorldPosition(), ECE_PLACE_ON_SURFACE));
8567
8568 if (new_item)
8569 {
8570 new_item.SetResultOfSplit(true);
8571 MiscGameplayFunctions.TransferItemProperties(this, new_item);
8572 SetQuantity(split_quantity_new, false, true);
8573 new_item.SetQuantity(stack_max, false, true);
8574 new_item.PlaceOnSurface();
8575 }
8576 }
8577 }
8578 }
8579 }
8580
8581 override void SplitIntoStackMaxEx(EntityAI destination_entity, int slot_id)
8582 {
8583 float split_quantity_new;
8584 ItemBase new_item;
8585 float quantity = GetQuantity();
8586 float stack_max = GetTargetQuantityMax(slot_id);
8587 InventoryLocation loc = new InventoryLocation;
8588
8589 if (destination_entity && slot_id != -1 && InventorySlots.IsSlotIdValid(slot_id))
8590 {
8591 if (stack_max <= GetQuantity())
8592 split_quantity_new = stack_max;
8593 else
8594 split_quantity_new = GetQuantity();
8595
8596 if (ShouldSplitQuantity(split_quantity_new))
8597 {
8598 new_item = ItemBase.Cast(destination_entity.GetInventory().CreateAttachmentEx(this.GetType(), slot_id));
8599 if (new_item)
8600 {
8601 new_item.SetResultOfSplit(true);
8602 MiscGameplayFunctions.TransferItemProperties(this, new_item);
8603 AddQuantity(-split_quantity_new, false, true);
8604 new_item.SetQuantity(split_quantity_new, false, true);
8605 }
8606 }
8607 }
8608 else if (destination_entity && slot_id == -1)
8609 {
8610 if (quantity > stack_max)
8611 split_quantity_new = stack_max;
8612 else
8613 split_quantity_new = quantity;
8614
8615 if (ShouldSplitQuantity(split_quantity_new))
8616 {
8617 if (destination_entity.GetInventory().FindFreeLocationFor(this, FindInventoryLocationType.ANY, loc))
8618 {
8619 Object o = destination_entity.GetInventory().LocationCreateEntity(loc, GetType(), ECE_IN_INVENTORY, RF_DEFAULT);
8620 new_item = ItemBase.Cast(o);
8621 }
8622
8623 if (new_item)
8624 {
8625 new_item.SetResultOfSplit(true);
8626 MiscGameplayFunctions.TransferItemProperties(this, new_item);
8627 AddQuantity(-split_quantity_new, false, true);
8628 new_item.SetQuantity(split_quantity_new, false, true);
8629 }
8630 }
8631 }
8632 else
8633 {
8634 if (stack_max != 0)
8635 {
8636 if (stack_max < GetQuantity())
8637 {
8638 split_quantity_new = GetQuantity() - stack_max;
8639 }
8640
8641 if (ShouldSplitQuantity(split_quantity_new))
8642 {
8643 new_item = ItemBase.Cast(GetGame().CreateObjectEx(GetType(),GetWorldPosition(), ECE_PLACE_ON_SURFACE));
8644
8645 if (new_item)
8646 {
8647 new_item.SetResultOfSplit(true);
8648 MiscGameplayFunctions.TransferItemProperties(this, new_item);
8649 SetQuantity(split_quantity_new, false, true);
8650 new_item.SetQuantity(stack_max, false, true);
8651 new_item.PlaceOnSurface();
8652 }
8653 }
8654 }
8655 }
8656 }
8657
8658 void SplitIntoStackMaxToInventoryLocationClient(notnull InventoryLocation dst)
8659 {
8660 if (GetGame().IsClient())
8661 {
8662 if (ScriptInputUserData.CanStoreInputUserData())
8663 {
8664 ScriptInputUserData ctx = new ScriptInputUserData;
8666 ctx.Write(4);
8667 ItemBase thiz = this; // @NOTE: workaround for correct serialization
8668 ctx.Write(thiz);
8669 dst.WriteToContext(ctx);
8670 ctx.Send();
8671 }
8672 }
8673 else if (!GetGame().IsMultiplayer())
8674 {
8676 }
8677 }
8678
8679 void SplitIntoStackMaxCargoClient(EntityAI destination_entity, int idx, int row, int col)
8680 {
8681 if (GetGame().IsClient())
8682 {
8683 if (ScriptInputUserData.CanStoreInputUserData())
8684 {
8685 ScriptInputUserData ctx = new ScriptInputUserData;
8687 ctx.Write(2);
8688 ItemBase dummy = this; // @NOTE: workaround for correct serialization
8689 ctx.Write(dummy);
8690 ctx.Write(destination_entity);
8691 ctx.Write(true);
8692 ctx.Write(idx);
8693 ctx.Write(row);
8694 ctx.Write(col);
8695 ctx.Send();
8696 }
8697 }
8698 else if (!GetGame().IsMultiplayer())
8699 {
8700 SplitIntoStackMaxCargo(destination_entity, idx, row, col);
8701 }
8702 }
8703
8704 void SplitIntoStackMaxToInventoryLocation(notnull InventoryLocation dst)
8705 {
8707 }
8708
8709 ItemBase SplitIntoStackMaxToInventoryLocationEx(notnull InventoryLocation dst)
8710 {
8711 float quantity = GetQuantity();
8712 float split_quantity_new;
8713 ItemBase new_item;
8714 if (dst.IsValid())
8715 {
8716 int slot_id = dst.GetSlot();
8717 float stack_max = GetTargetQuantityMax(slot_id);
8718
8719 if (quantity > stack_max)
8720 split_quantity_new = stack_max;
8721 else
8722 split_quantity_new = quantity;
8723
8724 if (ShouldSplitQuantity(split_quantity_new))
8725 {
8726 new_item = ItemBase.Cast(GameInventory.LocationCreateEntity(dst, this.GetType(), ECE_IN_INVENTORY, RF_DEFAULT));
8727
8728 if (new_item)
8729 {
8730 new_item.SetResultOfSplit(true);
8731 MiscGameplayFunctions.TransferItemProperties(this,new_item);
8732 AddQuantity(-split_quantity_new, false, true);
8733 new_item.SetQuantity(split_quantity_new, false, true);
8734 }
8735
8736 return new_item;
8737 }
8738 }
8739
8740 return null;
8741 }
8742
8743 void SplitIntoStackMaxCargo(EntityAI destination_entity, int idx, int row, int col)
8744 {
8745 float quantity = GetQuantity();
8746 float split_quantity_new;
8747 ItemBase new_item;
8748 if (destination_entity)
8749 {
8750 float stackable = GetTargetQuantityMax();
8751 if (quantity > stackable)
8752 split_quantity_new = stackable;
8753 else
8754 split_quantity_new = quantity;
8755
8756 if (ShouldSplitQuantity(split_quantity_new))
8757 {
8758 new_item = ItemBase.Cast(destination_entity.GetInventory().CreateEntityInCargoEx(this.GetType(), idx, row, col, false));
8759 if (new_item)
8760 {
8761 new_item.SetResultOfSplit(true);
8762 MiscGameplayFunctions.TransferItemProperties(this,new_item);
8763 AddQuantity(-split_quantity_new, false, true);
8764 new_item.SetQuantity(split_quantity_new, false, true);
8765 }
8766 }
8767 }
8768 }
8769
8770 void SplitIntoStackMaxHandsClient(PlayerBase player)
8771 {
8772 if (GetGame().IsClient())
8773 {
8774 if (ScriptInputUserData.CanStoreInputUserData())
8775 {
8776 ScriptInputUserData ctx = new ScriptInputUserData;
8778 ctx.Write(3);
8779 ItemBase i1 = this; // @NOTE: workaround for correct serialization
8780 ctx.Write(i1);
8781 ItemBase destination_entity = this;
8782 ctx.Write(destination_entity);
8783 ctx.Write(true);
8784 ctx.Write(0);
8785 ctx.Send();
8786 }
8787 }
8788 else if (!GetGame().IsMultiplayer())
8789 {
8790 SplitIntoStackMaxHands(player);
8791 }
8792 }
8793
8794 void SplitIntoStackMaxHands(PlayerBase player)
8795 {
8796 float quantity = GetQuantity();
8797 float split_quantity_new;
8798 ref ItemBase new_item;
8799 if (player)
8800 {
8801 float stackable = GetTargetQuantityMax();
8802 if (quantity > stackable)
8803 split_quantity_new = stackable;
8804 else
8805 split_quantity_new = quantity;
8806
8807 if (ShouldSplitQuantity(split_quantity_new))
8808 {
8809 EntityAI in_hands = player.GetHumanInventory().CreateInHands(this.GetType());
8810 new_item = ItemBase.Cast(in_hands);
8811 if (new_item)
8812 {
8813 new_item.SetResultOfSplit(true);
8814 MiscGameplayFunctions.TransferItemProperties(this,new_item);
8815 AddQuantity(-split_quantity_new, false, true);
8816 new_item.SetQuantity(split_quantity_new, false, true);
8817 }
8818 }
8819 }
8820 }
8821
8822 void SplitItemToInventoryLocation(notnull InventoryLocation dst)
8823 {
8824 float quantity = GetQuantity();
8825 float split_quantity_new = Math.Floor(quantity * 0.5);
8826
8827 if (!ShouldSplitQuantity(split_quantity_new))
8828 return;
8829
8830 ItemBase new_item = ItemBase.Cast(GameInventory.LocationCreateEntity(dst, GetType(), ECE_IN_INVENTORY, RF_DEFAULT));
8831
8832 if (new_item)
8833 {
8834 if (new_item.GetQuantityMax() < split_quantity_new)
8835 {
8836 split_quantity_new = new_item.GetQuantityMax();
8837 }
8838
8839 new_item.SetResultOfSplit(true);
8840 MiscGameplayFunctions.TransferItemProperties(this, new_item);
8841
8842 if (dst.IsValid() && dst.GetType() == InventoryLocationType.ATTACHMENT && split_quantity_new > 1)
8843 {
8844 AddQuantity(-1, false, true);
8845 new_item.SetQuantity(1, false, true);
8846 }
8847 else
8848 {
8849 AddQuantity(-split_quantity_new, false, true);
8850 new_item.SetQuantity(split_quantity_new, false, true);
8851 }
8852 }
8853 }
8854
8855 void SplitItem(PlayerBase player)
8856 {
8857 float quantity = GetQuantity();
8858 float split_quantity_new = Math.Floor(quantity / 2);
8859
8860 if (!ShouldSplitQuantity(split_quantity_new))
8861 return;
8862
8863 InventoryLocation invloc = new InventoryLocation;
8864 bool found = player.GetInventory().FindFirstFreeLocationForNewEntity(GetType(), FindInventoryLocationType.ATTACHMENT, invloc);
8865
8866 ItemBase new_item;
8867 new_item = player.CreateCopyOfItemInInventoryOrGroundEx(this, true);
8868
8869 if (new_item)
8870 {
8871 if (new_item.GetQuantityMax() < split_quantity_new)
8872 {
8873 split_quantity_new = new_item.GetQuantityMax();
8874 }
8875 if (found && invloc.IsValid() && invloc.GetType() == InventoryLocationType.ATTACHMENT && split_quantity_new > 1)
8876 {
8877 AddQuantity(-1, false, true);
8878 new_item.SetQuantity(1, false, true);
8879 }
8880 else if (split_quantity_new > 1)
8881 {
8882 AddQuantity(-split_quantity_new, false, true);
8883 new_item.SetQuantity(split_quantity_new, false, true);
8884 }
8885 }
8886 }
8887
8889 void OnQuantityChanged(float delta)
8890 {
8891 SetWeightDirty();
8892 ItemBase parent = ItemBase.Cast(GetHierarchyParent());
8893
8894 if (parent)
8895 parent.OnAttachmentQuantityChangedEx(this, delta);
8896
8897 if (IsLiquidContainer())
8898 {
8899 if (GetQuantityNormalized() <= 0.0)
8900 {
8902 }
8903 else if (GetLiquidType() == LIQUID_NONE)
8904 {
8905 ErrorEx("Undefined liquid type quantity changed, please define liquid type first! Using init value.",ErrorExSeverity.INFO);
8907 }
8908 }
8909
8910 }
8911
8914 {
8915 // insert code here
8916 }
8917
8919 void OnAttachmentQuantityChangedEx(ItemBase item , float delta)
8920 {
8922 }
8923
8924 override void EEHealthLevelChanged(int oldLevel, int newLevel, string zone)
8925 {
8926 super.EEHealthLevelChanged(oldLevel,newLevel,zone);
8927
8928 if (GetGame().IsServer())
8929 {
8930 if (newLevel == GameConstants.STATE_RUINED)
8931 {
8933 EntityAI parent = GetHierarchyParent();
8934 if (parent && parent.IsFireplace())
8935 {
8936 CargoBase cargo = GetInventory().GetCargo();
8937 if (cargo)
8938 {
8939 for (int i = 0; i < cargo.GetItemCount(); ++i)
8940 {
8941 parent.GetInventory().TakeEntityToInventory(InventoryMode.SERVER, FindInventoryLocationType.CARGO, cargo.GetItem(i));
8942 }
8943 }
8944 }
8945 }
8946
8947 if (IsResultOfSplit())
8948 {
8949 // reset the splitting result flag, return to normal item behavior
8950 SetResultOfSplit(false);
8951 return;
8952 }
8953
8954 if (m_Cleanness != 0 && oldLevel < newLevel && newLevel != 0)
8955 {
8956 SetCleanness(0);//unclean the item upon damage dealt
8957 }
8958 }
8959 }
8960
8961 // just the split? TODO: verify
8962 override void OnRightClick()
8963 {
8964 super.OnRightClick();
8965
8966 if (CanBeSplit() && !GetDayZGame().IsLeftCtrlDown() && !GetGame().GetPlayer().GetInventory().HasInventoryReservation(this,null))
8967 {
8968 if (GetGame().IsClient())
8969 {
8970 if (ScriptInputUserData.CanStoreInputUserData())
8971 {
8972 EntityAI root = GetHierarchyRoot();
8973 Man playerOwner = GetHierarchyRootPlayer();
8974 InventoryLocation dst = new InventoryLocation;
8975
8976 // 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
8977 if (!playerOwner && root && root == this)
8978 {
8980 }
8981 else
8982 {
8983 // 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
8984 GetInventory().GetCurrentInventoryLocation(dst);
8985 if (!dst.GetParent() || dst.GetParent() && !dst.GetParent().GetInventory().FindFreeLocationFor(this, FindInventoryLocationType.CARGO, dst))
8986 {
8987 PlayerBase player = PlayerBase.Cast(GetGame().GetPlayer());
8988 if (!player.GetInventory().FindFreeLocationFor(this, FindInventoryLocationType.CARGO, dst) || !playerOwner)
8989 {
8991 }
8992 else
8993 {
8994 dst.SetCargo(dst.GetParent(), this, dst.GetIdx(), dst.GetRow(), dst.GetCol(), dst.GetFlip());
8995 /* hacky solution to check reservation of "this" item instead of null since the gamecode is checking null against null and returning reservation=true incorrectly
8996 this shouldnt cause issues within this scope*/
8997 if (GetGame().GetPlayer().GetInventory().HasInventoryReservation(this, dst))
8998 {
9000 }
9001 else
9002 {
9003 GetGame().GetPlayer().GetInventory().AddInventoryReservationEx(null, dst, GameInventory.c_InventoryReservationTimeoutShortMS);
9004 }
9005 }
9006 }
9007 }
9008
9009 ScriptInputUserData ctx = new ScriptInputUserData;
9011 ctx.Write(4);
9012 ItemBase thiz = this; // @NOTE: workaround for correct serialization
9013 ctx.Write(thiz);
9014 dst.WriteToContext(ctx);
9015 ctx.Write(true); // dummy
9016 ctx.Send();
9017 }
9018 }
9019 else if (!GetGame().IsMultiplayer())
9020 {
9021 SplitItem(PlayerBase.Cast(GetGame().GetPlayer()));
9022 }
9023 }
9024 }
9025
9026 protected void SetInventoryLocationToVicinityOrCurrent(EntityAI root, inout InventoryLocation dst)
9027 {
9028 if (root)
9029 {
9030 vector m4[4];
9031 root.GetTransform(m4);
9032 dst.SetGround(this, m4);
9033 }
9034 else
9035 {
9036 GetInventory().GetCurrentInventoryLocation(dst);
9037 }
9038 }
9039
9040 override bool CanBeCombined(EntityAI other_item, bool reservation_check = true, bool stack_max_limit = false)
9041 {
9042 //TODO: delete check zero quantity check after fix double posts hands fsm events
9043 if (!other_item || GetType() != other_item.GetType() || (IsFullQuantity() && other_item.GetQuantity() > 0) || other_item == this)
9044 return false;
9045
9046 if (GetHealthLevel() == GameConstants.STATE_RUINED || other_item.GetHealthLevel() == GameConstants.STATE_RUINED)
9047 return false;
9048
9049 //can_this_be_combined = ConfigGetBool("canBeSplit");
9051 return false;
9052
9053
9054 Magazine mag = Magazine.Cast(this);
9055 if (mag)
9056 {
9057 if (mag.GetAmmoCount() >= mag.GetAmmoMax())
9058 return false;
9059
9060 if (stack_max_limit)
9061 {
9062 Magazine other_mag = Magazine.Cast(other_item);
9063 if (other_item)
9064 {
9065 if (mag.GetAmmoCount() + other_mag.GetAmmoCount() > mag.GetAmmoMax())
9066 return false;
9067 }
9068
9069 }
9070 }
9071 else
9072 {
9073 //TODO: delete check zero quantity check after fix double posts hands fsm events
9074 if (GetQuantity() >= GetQuantityMax() && other_item.GetQuantity() > 0 )
9075 return false;
9076
9077 if (stack_max_limit && (GetQuantity() + other_item.GetQuantity() > GetQuantityMax()))
9078 return false;
9079 }
9080
9081 PlayerBase player = null;
9082 if (CastTo(player, GetHierarchyRootPlayer())) //false when attached to player's attachment slot
9083 {
9084 if (player.GetInventory().HasAttachment(this))
9085 return false;
9086
9087 if (player.IsItemsToDelete())
9088 return false;
9089 }
9090
9091 if (reservation_check && (GetInventory().HasInventoryReservation(this, null) || other_item.GetInventory().HasInventoryReservation(other_item, null)))
9092 return false;
9093
9094 int slotID;
9095 string slotName;
9096 if (GetInventory().GetCurrentAttachmentSlotInfo(slotID,slotName) && GetHierarchyParent().GetInventory().GetSlotLock(slotID))
9097 return false;
9098
9099 return true;
9100 }
9101
9102 bool IsCombineAll(ItemBase other_item, bool use_stack_max = false)
9103 {
9104 return ComputeQuantityUsed(other_item, use_stack_max) == other_item.GetQuantity();
9105 }
9106
9107 bool IsResultOfSplit()
9108 {
9109 return m_IsResultOfSplit;
9110 }
9111
9112 void SetResultOfSplit(bool value)
9113 {
9114 m_IsResultOfSplit = value;
9115 }
9116
9117 int ComputeQuantityUsed(ItemBase other_item, bool use_stack_max = true)
9118 {
9119 return ComputeQuantityUsedEx(other_item, use_stack_max);
9120 }
9121
9122 float ComputeQuantityUsedEx(ItemBase other_item, bool use_stack_max = true)
9123 {
9124 float other_item_quantity = other_item.GetQuantity();
9125 float this_free_space;
9126
9127 float stack_max = GetQuantityMax();
9128
9129 this_free_space = stack_max - GetQuantity();
9130
9131 if (other_item_quantity > this_free_space)
9132 {
9133 return this_free_space;
9134 }
9135 else
9136 {
9137 return other_item_quantity;
9138 }
9139 }
9140
9141 override void CombineItemsEx(EntityAI entity2, bool use_stack_max = true)
9142 {
9143 CombineItems(ItemBase.Cast(entity2),use_stack_max);
9144 }
9145
9146 void CombineItems(ItemBase other_item, bool use_stack_max = true)
9147 {
9148 if (!CanBeCombined(other_item, false))
9149 return;
9150
9151 if (!IsMagazine() && other_item)
9152 {
9153 float quantity_used = ComputeQuantityUsedEx(other_item,use_stack_max);
9154 if (quantity_used != 0)
9155 {
9156 float hp1 = GetHealth01("","");
9157 float hp2 = other_item.GetHealth01("","");
9158 float hpResult = ((hp1*GetQuantity()) + (hp2*quantity_used));
9159 hpResult = hpResult / (GetQuantity() + quantity_used);
9160
9161 hpResult *= GetMaxHealth();
9162 Math.Round(hpResult);
9163 SetHealth("", "Health", hpResult);
9164
9165 AddQuantity(quantity_used);
9166 other_item.AddQuantity(-quantity_used);
9167 }
9168 }
9169 OnCombine(other_item);
9170 }
9171
9172 void OnCombine(ItemBase other_item)
9173 {
9174 #ifdef SERVER
9175 if (!GetHierarchyRootPlayer() && GetHierarchyParent())
9176 GetHierarchyParent().IncreaseLifetimeUp();
9177 #endif
9178 };
9179
9180 void GetRecipesActions(Man player, out TSelectableActionInfoArray outputList)
9181 {
9182 PlayerBase p = PlayerBase.Cast(player);
9183
9184 array<int> recipesIds = p.m_Recipes;
9185 PluginRecipesManager moduleRecipesManager = PluginRecipesManager.Cast(GetPlugin(PluginRecipesManager));
9186 if (moduleRecipesManager)
9187 {
9188 EntityAI itemInHands = player.GetHumanInventory().GetEntityInHands();
9189 moduleRecipesManager.GetValidRecipes(ItemBase.Cast(this), ItemBase.Cast(itemInHands), recipesIds, p);
9190 }
9191
9192 for (int i = 0;i < recipesIds.Count(); i++)
9193 {
9194 int key = recipesIds.Get(i);
9195 string recipeName = moduleRecipesManager.GetRecipeName(key);
9196 outputList.Insert(new TSelectableActionInfo(SAT_CRAFTING, key, recipeName));
9197 }
9198 }
9199
9200 // -------------------------------------------------------------------------
9201 override void GetDebugActions(out TSelectableActionInfoArrayEx outputList)
9202 {
9203 super.GetDebugActions(outputList);
9204
9205 //quantity
9206 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.ADD_QUANTITY, "Quantity +20%", FadeColors.LIGHT_GREY));
9207 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.REMOVE_QUANTITY, "Quantity -20%", FadeColors.LIGHT_GREY));
9208 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SET_QUANTITY_0, "Set Quantity 0", FadeColors.LIGHT_GREY));
9209 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SET_MAX_QUANTITY, "Set Quantity Max", FadeColors.LIGHT_GREY));
9210 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SEPARATOR, "___________________________", FadeColors.RED));
9211
9212 //health
9213 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.ADD_HEALTH, "Health +20%", FadeColors.LIGHT_GREY));
9214 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.REMOVE_HEALTH, "Health -20%", FadeColors.LIGHT_GREY));
9215 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.DESTROY_HEALTH, "Health 0", FadeColors.LIGHT_GREY));
9216 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SEPARATOR, "___________________________", FadeColors.RED));
9217 //temperature
9218 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.ADD_TEMPERATURE, "Temperature +20", FadeColors.LIGHT_GREY));
9219 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.REMOVE_TEMPERATURE, "Temperature -20", FadeColors.LIGHT_GREY));
9220 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.FLIP_FROZEN, "Toggle Frozen", FadeColors.LIGHT_GREY));
9221 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SEPARATOR, "___________________________", FadeColors.RED));
9222
9223 //wet
9224 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.ADD_WETNESS, "Wetness +20", FadeColors.LIGHT_GREY));
9225 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.REMOVE_WETNESS, "Wetness -20", FadeColors.LIGHT_GREY));
9226 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SEPARATOR, "___________________________", FadeColors.RED));
9227
9228 //liquidtype
9229 if (IsLiquidContainer())
9230 {
9231 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.LIQUIDTYPE_UP, "LiquidType Next", FadeColors.LIGHT_GREY));
9232 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.LIQUIDTYPE_DOWN, "LiquidType Previous", FadeColors.LIGHT_GREY));
9233 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SEPARATOR, "___________________________", FadeColors.RED));
9234 }
9235
9236 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.MAKE_SPECIAL, "Make Special", FadeColors.LIGHT_GREY));
9237 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SEPARATOR, "___________________________", FadeColors.RED));
9238
9239 // watch
9240 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.WATCH_ITEM, "Watch (CTRL-Z)", FadeColors.LIGHT_GREY));
9241 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.WATCH_PLAYER, "Watch Player", FadeColors.LIGHT_GREY));
9242 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SEPARATOR, "___________________________", FadeColors.RED));
9243
9244 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.DELETE, "Delete", FadeColors.RED));
9245
9246 InventoryLocation loc = new InventoryLocation();
9247 GetInventory().GetCurrentInventoryLocation(loc);
9248 if (!loc || loc.GetType() == InventoryLocationType.GROUND)
9249 {
9250 if (Gizmo_IsSupported())
9251 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.GIZMO_OBJECT, "Gizmo Object", FadeColors.LIGHT_GREY));
9252 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.GIZMO_PHYSICS, "Gizmo Physics (SP Only)", FadeColors.LIGHT_GREY)); // intentionally allowed for testing physics desync
9253 }
9254
9255 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SEPARATOR, "___________________________", FadeColors.RED));
9256 }
9257
9258 // -------------------------------------------------------------------------
9259 // -------------------------------------------------------------------------
9260 // -------------------------------------------------------------------------
9261 override bool OnAction(int action_id, Man player, ParamsReadContext ctx)
9262 {
9263 super.OnAction(action_id, player, ctx);
9264
9265 if (GetGame().IsClient() || !GetGame().IsMultiplayer())
9266 {
9267 switch (action_id)
9268 {
9269 case EActions.GIZMO_OBJECT:
9270 GetGame().GizmoSelectObject(this);
9271 return true;
9272 case EActions.GIZMO_PHYSICS:
9273 GetGame().GizmoSelectPhysics(GetPhysics());
9274 return true;
9275 }
9276 }
9277
9278 if (GetGame().IsServer())
9279 {
9280 switch (action_id)
9281 {
9282 case EActions.DELETE:
9283 Delete();
9284 return true;
9285 }
9286 }
9287
9288 if (action_id >= EActions.RECIPES_RANGE_START && action_id < EActions.RECIPES_RANGE_END)
9289 {
9290 PluginRecipesManager plugin_recipes_manager = PluginRecipesManager.Cast(GetPlugin(PluginRecipesManager));
9291 int idWithoutOffset = action_id - EActions.RECIPES_RANGE_START;
9292 PlayerBase p = PlayerBase.Cast(player);
9293 if (EActions.RECIPES_RANGE_START < 1000)
9294 {
9295 float anim_length = plugin_recipes_manager.GetRecipeLengthInSecs(idWithoutOffset);
9296 float specialty_weight = plugin_recipes_manager.GetRecipeSpecialty(idWithoutOffset);
9297 }
9298 }
9299 #ifndef SERVER
9300 else if (action_id == EActions.WATCH_PLAYER)
9301 {
9302 PluginDeveloper.SetDeveloperItemClientEx(player);
9303 }
9304 #endif
9305 if (GetGame().IsServer())
9306 {
9307 if (action_id >= EActions.DEBUG_ITEM_WATCH_BUTTON_RANGE_START && action_id < EActions.DEBUG_ITEM_WATCH_BUTTON_RANGE_END)
9308 {
9309 int id = action_id - EActions.DEBUG_ITEM_WATCH_BUTTON_RANGE_START;
9310 OnDebugButtonPressServer(id + 1);
9311 }
9312
9313 else if (action_id >= EActions.DEBUG_AGENTS_RANGE_INJECT_START && action_id < EActions.DEBUG_AGENTS_RANGE_INJECT_END)
9314 {
9315 int agent_id = action_id - EActions.DEBUG_AGENTS_RANGE_INJECT_START;
9316 InsertAgent(agent_id,100);
9317 }
9318
9319 else if (action_id >= EActions.DEBUG_AGENTS_RANGE_REMOVE_START && action_id < EActions.DEBUG_AGENTS_RANGE_REMOVE_END)
9320 {
9321 int agent_id2 = action_id - EActions.DEBUG_AGENTS_RANGE_REMOVE_START;
9322 RemoveAgent(agent_id2);
9323 }
9324
9325 else if (action_id == EActions.ADD_QUANTITY)
9326 {
9327 if (IsMagazine())
9328 {
9329 Magazine mag = Magazine.Cast(this);
9330 mag.ServerSetAmmoCount(mag.GetAmmoCount() + mag.GetAmmoMax() * 0.2);
9331 }
9332 else
9333 {
9334 AddQuantity(GetQuantityMax() * 0.2);
9335 }
9336
9337 if (m_EM)
9338 {
9339 m_EM.AddEnergy(m_EM.GetEnergyMax() * 0.2);
9340 }
9341 //PrintVariables();
9342 }
9343
9344 else if (action_id == EActions.REMOVE_QUANTITY) //Quantity -20%
9345 {
9346 if (IsMagazine())
9347 {
9348 Magazine mag2 = Magazine.Cast(this);
9349 mag2.ServerSetAmmoCount(mag2.GetAmmoCount() - mag2.GetAmmoMax() * 0.2);
9350 }
9351 else
9352 {
9353 AddQuantity(- GetQuantityMax() * 0.2);
9354 }
9355 if (m_EM)
9356 {
9357 m_EM.AddEnergy(- m_EM.GetEnergyMax() * 0.2);
9358 }
9359 //PrintVariables();
9360 }
9361
9362 else if (action_id == EActions.SET_QUANTITY_0) //SetMaxQuantity
9363 {
9364 SetQuantity(0);
9365
9366 if (m_EM)
9367 {
9368 m_EM.SetEnergy(0);
9369 }
9370 }
9371
9372 else if (action_id == EActions.SET_MAX_QUANTITY) //SetMaxQuantity
9373 {
9375
9376 if (m_EM)
9377 {
9378 m_EM.SetEnergy(m_EM.GetEnergyMax());
9379 }
9380 }
9381
9382 else if (action_id == EActions.ADD_HEALTH)
9383 {
9384 AddHealth("","",GetMaxHealth("","Health")/5);
9385 }
9386 else if (action_id == EActions.REMOVE_HEALTH)
9387 {
9388 AddHealth("","",-GetMaxHealth("","Health")/5);
9389 }
9390 else if (action_id == EActions.DESTROY_HEALTH)
9391 {
9392 SetHealth01("","",0);
9393 }
9394 else if (action_id == EActions.WATCH_ITEM)
9395 {
9397 mid.RegisterDebugItem(ItemBase.Cast(this), PlayerBase.Cast(player));
9398 #ifdef DEVELOPER
9399 SetDebugDeveloper_item(this);
9400 #endif
9401 }
9402
9403 else if (action_id == EActions.ADD_TEMPERATURE)
9404 {
9405 AddTemperature(20);
9406 //PrintVariables();
9407 }
9408
9409 else if (action_id == EActions.REMOVE_TEMPERATURE)
9410 {
9411 AddTemperature(-20);
9412 //PrintVariables();
9413 }
9414
9415 else if (action_id == EActions.FLIP_FROZEN)
9416 {
9417 SetFrozen(!GetIsFrozen());
9418 //PrintVariables();
9419 }
9420
9421 else if (action_id == EActions.ADD_WETNESS)
9422 {
9423 AddWet(GetWetMax()/5);
9424 //PrintVariables();
9425 }
9426
9427 else if (action_id == EActions.REMOVE_WETNESS)
9428 {
9429 AddWet(-GetWetMax()/5);
9430 //PrintVariables();
9431 }
9432
9433 else if (action_id == EActions.LIQUIDTYPE_UP)
9434 {
9435 int curr_type = GetLiquidType();
9436 SetLiquidType(curr_type * 2);
9437 //AddWet(1);
9438 //PrintVariables();
9439 }
9440
9441 else if (action_id == EActions.LIQUIDTYPE_DOWN)
9442 {
9443 int curr_type2 = GetLiquidType();
9444 SetLiquidType(curr_type2 / 2);
9445 }
9446
9447 else if (action_id == EActions.MAKE_SPECIAL)
9448 {
9449 auto debugParams = DebugSpawnParams.WithPlayer(player);
9450 OnDebugSpawnEx(debugParams);
9451 }
9452
9453 }
9454
9455
9456 return false;
9457 }
9458
9459 // -------------------------------------------------------------------------
9460
9461
9464 void OnActivatedByTripWire();
9465
9467 void OnActivatedByItem(notnull ItemBase item);
9468
9469 //----------------------------------------------------------------
9470 //returns true if item is able to explode when put in fire
9471 bool CanExplodeInFire()
9472 {
9473 return false;
9474 }
9475
9476 //----------------------------------------------------------------
9477 bool CanEat()
9478 {
9479 return true;
9480 }
9481
9482 //----------------------------------------------------------------
9483 override bool IsIgnoredByConstruction()
9484 {
9485 return true;
9486 }
9487
9488 //----------------------------------------------------------------
9489 //has FoodStages in config?
9490 bool HasFoodStage()
9491 {
9492 string config_path = string.Format("CfgVehicles %1 Food FoodStages", GetType());
9493 return GetGame().ConfigIsExisting(config_path);
9494 }
9495
9497 FoodStage GetFoodStage()
9498 {
9499 return null;
9500 }
9501
9502 bool CanBeCooked()
9503 {
9504 return false;
9505 }
9506
9507 bool CanBeCookedOnStick()
9508 {
9509 return false;
9510 }
9511
9513 void RefreshAudioVisualsOnClient( CookingMethodType cooking_method, bool is_done, bool is_empty, bool is_burned );
9515
9516 //----------------------------------------------------------------
9517 bool CanRepair(ItemBase item_repair_kit)
9518 {
9519 PluginRepairing module_repairing = PluginRepairing.Cast(GetPlugin(PluginRepairing));
9520 return module_repairing.CanRepair(this, item_repair_kit);
9521 }
9522
9523 //----------------------------------------------------------------
9524 bool Repair(PlayerBase player, ItemBase item_repair_kit, float specialty_weight)
9525 {
9526 PluginRepairing module_repairing = PluginRepairing.Cast(GetPlugin(PluginRepairing));
9527 return module_repairing.Repair(player, this, item_repair_kit, specialty_weight);
9528 }
9529
9530 //----------------------------------------------------------------
9531 int GetItemSize()
9532 {
9533 /*
9534 vector v_size = this.ConfigGetVector("itemSize");
9535 int v_size_x = v_size[0];
9536 int v_size_y = v_size[1];
9537 int size = v_size_x * v_size_y;
9538 return size;
9539 */
9540
9541 return 1;
9542 }
9543
9544 //----------------------------------------------------------------
9545 //Override for allowing seemingly unallowed moves when two clients send a conflicting message simultaneously
9546 bool CanBeMovedOverride()
9547 {
9548 return m_CanBeMovedOverride;
9549 }
9550
9551 //----------------------------------------------------------------
9552 //Override for allowing seemingly unallowed moves when two clients send a conflicting message simultaneously
9553 void SetCanBeMovedOverride(bool setting)
9554 {
9555 m_CanBeMovedOverride = setting;
9556 }
9557
9558 //----------------------------------------------------------------
9566 void MessageToOwnerStatus(string text)
9567 {
9568 PlayerBase player = PlayerBase.Cast(this.GetHierarchyRootPlayer());
9569
9570 if (player)
9571 {
9572 player.MessageStatus(text);
9573 }
9574 }
9575
9576 //----------------------------------------------------------------
9584 void MessageToOwnerAction(string text)
9585 {
9586 PlayerBase player = PlayerBase.Cast(this.GetHierarchyRootPlayer());
9587
9588 if (player)
9589 {
9590 player.MessageAction(text);
9591 }
9592 }
9593
9594 //----------------------------------------------------------------
9602 void MessageToOwnerFriendly(string text)
9603 {
9604 PlayerBase player = PlayerBase.Cast(this.GetHierarchyRootPlayer());
9605
9606 if (player)
9607 {
9608 player.MessageFriendly(text);
9609 }
9610 }
9611
9612 //----------------------------------------------------------------
9620 void MessageToOwnerImportant(string text)
9621 {
9622 PlayerBase player = PlayerBase.Cast(this.GetHierarchyRootPlayer());
9623
9624 if (player)
9625 {
9626 player.MessageImportant(text);
9627 }
9628 }
9629
9630 override bool IsItemBase()
9631 {
9632 return true;
9633 }
9634
9635 // Checks if item is of questioned kind
9636 override bool KindOf(string tag)
9637 {
9638 bool found = false;
9639 string item_name = this.GetType();
9640 ref TStringArray item_tag_array = new TStringArray;
9641 GetGame().ConfigGetTextArray("cfgVehicles " + item_name + " itemInfo", item_tag_array);
9642
9643 int array_size = item_tag_array.Count();
9644 for (int i = 0; i < array_size; i++)
9645 {
9646 if (item_tag_array.Get(i) == tag)
9647 {
9648 found = true;
9649 break;
9650 }
9651 }
9652 return found;
9653 }
9654
9655
9656 override void OnRPC(PlayerIdentity sender, int rpc_type,ParamsReadContext ctx)
9657 {
9658 //Debug.Log("OnRPC called");
9659 super.OnRPC(sender, rpc_type,ctx);
9660
9661 //Play soundset for attachment locking (ActionLockAttachment.c)
9662 switch (rpc_type)
9663 {
9664 #ifndef SERVER
9665 case ERPCs.RPC_SOUND_LOCK_ATTACH:
9666 Param2<bool, string> p = new Param2<bool, string>(false, "");
9667
9668 if (!ctx.Read(p))
9669 return;
9670
9671 bool play = p.param1;
9672 string soundSet = p.param2;
9673
9674 if (play)
9675 {
9676 if (m_LockingSound)
9677 {
9679 {
9680 m_LockingSound = SEffectManager.PlaySound(soundSet, GetPosition(), 0, 0, true);
9681 }
9682 }
9683 else
9684 {
9685 m_LockingSound = SEffectManager.PlaySound(soundSet, GetPosition(), 0, 0, true);
9686 }
9687 }
9688 else
9689 {
9690 SEffectManager.DestroyEffect(m_LockingSound);
9691 }
9692
9693 break;
9694 #endif
9695
9696 }
9697
9698 if (GetWrittenNoteData())
9699 {
9700 GetWrittenNoteData().OnRPC(sender, rpc_type,ctx);
9701 }
9702 }
9703
9704 //-----------------------------
9705 // VARIABLE MANIPULATION SYSTEM
9706 //-----------------------------
9707 int NameToID(string name)
9708 {
9709 PluginVariables plugin = PluginVariables.Cast(GetPlugin(PluginVariables));
9710 return plugin.GetID(name);
9711 }
9712
9713 string IDToName(int id)
9714 {
9715 PluginVariables plugin = PluginVariables.Cast(GetPlugin(PluginVariables));
9716 return plugin.GetName(id);
9717 }
9718
9720 void OnSyncVariables(ParamsReadContext ctx)//with ID optimization
9721 {
9722 //Debug.Log("OnSyncVariables called for item: "+ ToString(this.GetType()),"varSync");
9723 //read the flags
9724 int varFlags;
9725 if (!ctx.Read(varFlags))
9726 return;
9727
9728 if (varFlags & ItemVariableFlags.FLOAT)
9729 {
9730 ReadVarsFromCTX(ctx);
9731 }
9732 }
9733
9734 override void SerializeNumericalVars(array<float> floats_out)
9735 {
9736 //some variables handled on EntityAI level already!
9737 super.SerializeNumericalVars(floats_out);
9738
9739 // the order of serialization must be the same as the order of de-serialization
9740 //--------------------------------------------
9741 if (IsVariableSet(VARIABLE_QUANTITY))
9742 {
9743 floats_out.Insert(m_VarQuantity);
9744 }
9745 //--------------------------------------------
9746 if (IsVariableSet(VARIABLE_WET))
9747 {
9748 floats_out.Insert(m_VarWet);
9749 }
9750 //--------------------------------------------
9751 if (IsVariableSet(VARIABLE_LIQUIDTYPE))
9752 {
9753 floats_out.Insert(m_VarLiquidType);
9754 }
9755 //--------------------------------------------
9756 if (IsVariableSet(VARIABLE_COLOR))
9757 {
9758 floats_out.Insert(m_ColorComponentR);
9759 floats_out.Insert(m_ColorComponentG);
9760 floats_out.Insert(m_ColorComponentB);
9761 floats_out.Insert(m_ColorComponentA);
9762 }
9763 //--------------------------------------------
9764 if (IsVariableSet(VARIABLE_CLEANNESS))
9765 {
9766 floats_out.Insert(m_Cleanness);
9767 }
9768 }
9769
9770 override void DeSerializeNumericalVars(array<float> floats)
9771 {
9772 //some variables handled on EntityAI level already!
9773 super.DeSerializeNumericalVars(floats);
9774
9775 // the order of serialization must be the same as the order of de-serialization
9776 int index = 0;
9777 int mask = Math.Round(floats.Get(index));
9778
9779 index++;
9780 //--------------------------------------------
9781 if (mask & VARIABLE_QUANTITY)
9782 {
9783 if (m_IsStoreLoad)
9784 {
9785 SetStoreLoadedQuantity(floats.Get(index));
9786 }
9787 else
9788 {
9789 float quantity = floats.Get(index);
9790 SetQuantity(quantity, true, false, false, false);
9791 }
9792 index++;
9793 }
9794 //--------------------------------------------
9795 if (mask & VARIABLE_WET)
9796 {
9797 float wet = floats.Get(index);
9798 SetWet(wet);
9799 index++;
9800 }
9801 //--------------------------------------------
9802 if (mask & VARIABLE_LIQUIDTYPE)
9803 {
9804 int liquidtype = Math.Round(floats.Get(index));
9805 SetLiquidType(liquidtype);
9806 index++;
9807 }
9808 //--------------------------------------------
9809 if (mask & VARIABLE_COLOR)
9810 {
9811 m_ColorComponentR = Math.Round(floats.Get(index));
9812 index++;
9813 m_ColorComponentG = Math.Round(floats.Get(index));
9814 index++;
9815 m_ColorComponentB = Math.Round(floats.Get(index));
9816 index++;
9817 m_ColorComponentA = Math.Round(floats.Get(index));
9818 index++;
9819 }
9820 //--------------------------------------------
9821 if (mask & VARIABLE_CLEANNESS)
9822 {
9823 int cleanness = Math.Round(floats.Get(index));
9824 SetCleanness(cleanness);
9825 index++;
9826 }
9827 }
9828
9829 override void WriteVarsToCTX(ParamsWriteContext ctx)
9830 {
9831 super.WriteVarsToCTX(ctx);
9832
9833 //--------------------------------------------
9834 if (IsVariableSet(VARIABLE_QUANTITY))
9835 {
9836 ctx.Write(GetQuantity());
9837 }
9838 //--------------------------------------------
9839 if (IsVariableSet(VARIABLE_WET))
9840 {
9841 ctx.Write(GetWet());
9842 }
9843 //--------------------------------------------
9844 if (IsVariableSet(VARIABLE_LIQUIDTYPE))
9845 {
9846 ctx.Write(GetLiquidType());
9847 }
9848 //--------------------------------------------
9849 if (IsVariableSet(VARIABLE_COLOR))
9850 {
9851 int r,g,b,a;
9852 GetColor(r,g,b,a);
9853 ctx.Write(r);
9854 ctx.Write(g);
9855 ctx.Write(b);
9856 ctx.Write(a);
9857 }
9858 //--------------------------------------------
9859 if (IsVariableSet(VARIABLE_CLEANNESS))
9860 {
9861 ctx.Write(GetCleanness());
9862 }
9863 }
9864
9865 override bool ReadVarsFromCTX(ParamsReadContext ctx, int version = -1)//with ID optimization
9866 {
9867 if (!super.ReadVarsFromCTX(ctx,version))
9868 return false;
9869
9870 int intValue;
9871 float value;
9872
9873 if (version < 140)
9874 {
9875 if (!ctx.Read(intValue))
9876 return false;
9877
9878 m_VariablesMask = intValue;
9879 }
9880
9881 if (m_VariablesMask & VARIABLE_QUANTITY)
9882 {
9883 if (!ctx.Read(value))
9884 return false;
9885
9886 if (IsStoreLoad())
9887 {
9889 }
9890 else
9891 {
9892 SetQuantity(value, true, false, false, false);
9893 }
9894 }
9895 //--------------------------------------------
9896 if (version < 140)
9897 {
9898 if (m_VariablesMask & VARIABLE_TEMPERATURE)
9899 {
9900 if (!ctx.Read(value))
9901 return false;
9902 SetTemperatureDirect(value);
9903 }
9904 }
9905 //--------------------------------------------
9906 if (m_VariablesMask & VARIABLE_WET)
9907 {
9908 if (!ctx.Read(value))
9909 return false;
9910 SetWet(value);
9911 }
9912 //--------------------------------------------
9913 if (m_VariablesMask & VARIABLE_LIQUIDTYPE)
9914 {
9915 if (!ctx.Read(intValue))
9916 return false;
9917 SetLiquidType(intValue);
9918 }
9919 //--------------------------------------------
9920 if (m_VariablesMask & VARIABLE_COLOR)
9921 {
9922 int r,g,b,a;
9923 if (!ctx.Read(r))
9924 return false;
9925 if (!ctx.Read(g))
9926 return false;
9927 if (!ctx.Read(b))
9928 return false;
9929 if (!ctx.Read(a))
9930 return false;
9931
9932 SetColor(r,g,b,a);
9933 }
9934 //--------------------------------------------
9935 if (m_VariablesMask & VARIABLE_CLEANNESS)
9936 {
9937 if (!ctx.Read(intValue))
9938 return false;
9939 SetCleanness(intValue);
9940 }
9941 //--------------------------------------------
9942 if (version >= 138 && version < 140)
9943 {
9944 if (m_VariablesMask & VARIABLE_TEMPERATURE)
9945 {
9946 if (!ctx.Read(intValue))
9947 return false;
9948 SetFrozen(intValue);
9949 }
9950 }
9951
9952 return true;
9953 }
9954
9955 //----------------------------------------------------------------
9956 override bool OnStoreLoad(ParamsReadContext ctx, int version)
9957 {
9958 m_IsStoreLoad = true;
9960 {
9961 m_FixDamageSystemInit = true;
9962 }
9963
9964 if (!super.OnStoreLoad(ctx, version))
9965 {
9966 m_IsStoreLoad = false;
9967 return false;
9968 }
9969
9970 if (version >= 114)
9971 {
9972 bool hasQuickBarIndexSaved;
9973
9974 if (!ctx.Read(hasQuickBarIndexSaved))
9975 {
9976 m_IsStoreLoad = false;
9977 return false;
9978 }
9979
9980 if (hasQuickBarIndexSaved)
9981 {
9982 int itmQBIndex;
9983
9984 //Load quickbar item bind
9985 if (!ctx.Read(itmQBIndex))
9986 {
9987 m_IsStoreLoad = false;
9988 return false;
9989 }
9990
9991 PlayerBase parentPlayer = PlayerBase.Cast(GetHierarchyRootPlayer());
9992 if (itmQBIndex != -1 && parentPlayer)
9993 parentPlayer.SetLoadedQuickBarItemBind(this, itmQBIndex);
9994 }
9995 }
9996 else
9997 {
9998 // Backup of how it used to be
9999 PlayerBase player;
10000 int itemQBIndex;
10001 if (version == int.MAX)
10002 {
10003 if (!ctx.Read(itemQBIndex))
10004 {
10005 m_IsStoreLoad = false;
10006 return false;
10007 }
10008 }
10009 else if (Class.CastTo(player, GetHierarchyRootPlayer()))
10010 {
10011 //Load quickbar item bind
10012 if (!ctx.Read(itemQBIndex))
10013 {
10014 m_IsStoreLoad = false;
10015 return false;
10016 }
10017 if (itemQBIndex != -1 && player)
10018 player.SetLoadedQuickBarItemBind(this,itemQBIndex);
10019 }
10020 }
10021
10022 if (version < 140)
10023 {
10024 // variable management system
10025 if (!LoadVariables(ctx, version))
10026 {
10027 m_IsStoreLoad = false;
10028 return false;
10029 }
10030 }
10031
10032 //agent trasmission system
10033 if (!LoadAgents(ctx, version))
10034 {
10035 m_IsStoreLoad = false;
10036 return false;
10037 }
10038 if (version >= 132)
10039 {
10040 RemotelyActivatedItemBehaviour raib = GetRemotelyActivatedItemBehaviour();
10041 if (raib)
10042 {
10043 if (!raib.OnStoreLoad(ctx,version))
10044 {
10045 m_IsStoreLoad = false;
10046 return false;
10047 }
10048 }
10049 }
10050
10051 m_IsStoreLoad = false;
10052 return true;
10053 }
10054
10055 //----------------------------------------------------------------
10056
10057 override void OnStoreSave(ParamsWriteContext ctx)
10058 {
10059 super.OnStoreSave(ctx);
10060
10061 PlayerBase player;
10062 if (PlayerBase.CastTo(player,GetHierarchyRootPlayer()))
10063 {
10064 ctx.Write(true); // Keep track of if we should actually read this in or not
10065 //Save quickbar item bind
10066 int itemQBIndex = -1;
10067 itemQBIndex = player.FindQuickBarEntityIndex(this);
10068 ctx.Write(itemQBIndex);
10069 }
10070 else
10071 {
10072 ctx.Write(false); // Keep track of if we should actually read this in or not
10073 }
10074
10075 SaveAgents(ctx);//agent trasmission system
10076
10077 RemotelyActivatedItemBehaviour raib = GetRemotelyActivatedItemBehaviour();
10078 if (raib)
10079 {
10080 raib.OnStoreSave(ctx);
10081 }
10082 }
10083 //----------------------------------------------------------------
10084
10085 override void AfterStoreLoad()
10086 {
10087 super.AfterStoreLoad();
10088
10090 {
10092 }
10093
10094 if (GetStoreLoadedQuantity() != float.LOWEST)
10095 {
10097 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
10098 }
10099 }
10100
10101 override void EEOnAfterLoad()
10102 {
10103 super.EEOnAfterLoad();
10104
10106 {
10107 m_FixDamageSystemInit = false;
10108 }
10109
10112 }
10113
10114 bool CanBeDisinfected()
10115 {
10116 return false;
10117 }
10118
10119
10120 //----------------------------------------------------------------
10121 override void OnVariablesSynchronized()
10122 {
10123 if (m_Initialized)
10124 {
10125 #ifdef PLATFORM_CONSOLE
10126 //bruteforce it is
10127 if (IsSplitable())
10128 {
10129 UIScriptedMenu menu = GetGame().GetUIManager().FindMenu(MENU_INVENTORY);
10130 if (menu)
10131 {
10132 menu.Refresh();
10133 }
10134 }
10135 #endif
10136 }
10137
10139 {
10140 PlayImpactSound(m_ConfigWeight, m_ImpactSpeed, m_ImpactSoundSurfaceHash);
10141 m_WantPlayImpactSound = false;
10142 }
10143
10145 {
10146 SetWeightDirty();
10148 }
10149 if (m_VarWet != m_VarWetPrev)
10150 {
10153 }
10154
10155 if (m_SoundSyncPlay != 0)
10156 {
10157 m_ItemSoundHandler.PlayItemSoundClient(m_SoundSyncPlay);
10158 m_SoundSyncPlay = 0;
10159 }
10160 if (m_SoundSyncStop != 0)
10161 {
10162 m_ItemSoundHandler.StopItemSoundClient(m_SoundSyncStop);
10163 m_SoundSyncStop = 0;
10164 }
10165
10166 super.OnVariablesSynchronized();
10167 }
10168
10169 //------------------------- Quantity
10170 //----------------------------------------------------------------
10172 override bool SetQuantity(float value, bool destroy_config = true, bool destroy_forced = false, bool allow_client = false, bool clamp_to_stack_max = true)
10173 {
10174 if (!IsServerCheck(allow_client))
10175 return false;
10176
10177 if (!HasQuantity())
10178 return false;
10179
10180 float min = GetQuantityMin();
10181 float max = GetQuantityMax();
10182
10183 if (value <= (min + 0.001))
10184 value = min;
10185
10186 if (value == min)
10187 {
10188 if (destroy_config)
10189 {
10190 bool dstr = ConfigGetBool("varQuantityDestroyOnMin");
10191 if (dstr)
10192 {
10193 m_VarQuantity = Math.Clamp(value, min, max);
10194 this.Delete();
10195 return true;
10196 }
10197 }
10198 else if (destroy_forced)
10199 {
10200 m_VarQuantity = Math.Clamp(value, min, max);
10201 this.Delete();
10202 return true;
10203 }
10204 // we get here if destroy_config IS true AND dstr(config destroy param) IS false;
10205 RemoveAllAgents();//we remove all agents when we got to the min value, but the item is not getting deleted
10206 }
10207
10208 float delta = m_VarQuantity;
10209 m_VarQuantity = Math.Clamp(value, min, max);
10210
10211 if (GetStoreLoadedQuantity() == float.LOWEST)//any other value means we are setting quantity from storage
10212 {
10213 delta = m_VarQuantity - delta;
10214
10215 if (delta)
10216 OnQuantityChanged(delta);
10217 }
10218
10219 SetVariableMask(VARIABLE_QUANTITY);
10220
10221 return false;
10222 }
10223
10224 //----------------------------------------------------------------
10226 bool AddQuantity(float value, bool destroy_config = true, bool destroy_forced = false)
10227 {
10228 return SetQuantity(GetQuantity() + value, destroy_config, destroy_forced);
10229 }
10230 //----------------------------------------------------------------
10231 void SetQuantityMax()
10232 {
10233 float max = GetQuantityMax();
10234 SetQuantity(max);
10235 }
10236
10237 override void SetQuantityToMinimum()
10238 {
10239 float min = GetQuantityMin();
10240 SetQuantity(min);
10241 }
10242 //----------------------------------------------------------------
10244 override void SetQuantityNormalized(float value, bool destroy_config = true, bool destroy_forced = false)
10245 {
10246 float value_clamped = Math.Clamp(value, 0, 1);//just to make sure
10247 int result = Math.Round(Math.Lerp(GetQuantityMin(), GetQuantityMax(), value_clamped));
10248 SetQuantity(result, destroy_config, destroy_forced);
10249 }
10250
10251 //----------------------------------------------------------------
10253 override float GetQuantityNormalized()
10254 {
10255 return Math.InverseLerp(GetQuantityMin(), GetQuantityMax(),m_VarQuantity);
10256 }
10257
10259 {
10260 return GetQuantityNormalized();
10261 }
10262
10263 /*void SetAmmoNormalized(float value)
10264 {
10265 float value_clamped = Math.Clamp(value, 0, 1);
10266 Magazine this_mag = Magazine.Cast(this);
10267 int max_rounds = this_mag.GetAmmoMax();
10268 int result = value * max_rounds;//can the rounded if higher precision is required
10269 this_mag.SetAmmoCount(result);
10270 }*/
10271 //----------------------------------------------------------------
10272 override int GetQuantityMax()
10273 {
10274 int slot = -1;
10275 if (GetInventory())
10276 {
10277 InventoryLocation il = new InventoryLocation;
10278 GetInventory().GetCurrentInventoryLocation(il);
10279 slot = il.GetSlot();
10280 }
10281
10282 return GetTargetQuantityMax(slot);
10283 }
10284
10285 override int GetTargetQuantityMax(int attSlotID = -1)
10286 {
10287 float quantity_max = 0;
10288
10289 if (IsSplitable()) //only stackable/splitable items can check for stack size
10290 {
10291 if (attSlotID != -1)
10292 quantity_max = InventorySlots.GetStackMaxForSlotId(attSlotID);
10293
10294 if (quantity_max <= 0)
10295 quantity_max = m_VarStackMax;
10296 }
10297
10298 if (quantity_max <= 0)
10299 quantity_max = m_VarQuantityMax;
10300
10301 return quantity_max;
10302 }
10303 //----------------------------------------------------------------
10304 override int GetQuantityMin()
10305 {
10306 return m_VarQuantityMin;
10307 }
10308 //----------------------------------------------------------------
10309 int GetQuantityInit()
10310 {
10311 return m_VarQuantityInit;
10312 }
10313
10314 //----------------------------------------------------------------
10315 override bool HasQuantity()
10316 {
10317 return !(GetQuantityMax() - GetQuantityMin() == 0);
10318 }
10319
10320 override float GetQuantity()
10321 {
10322 return m_VarQuantity;
10323 }
10324
10325 bool IsFullQuantity()
10326 {
10327 return GetQuantity() >= GetQuantityMax();
10328 }
10329
10330 //Calculates weight of single item without attachments and cargo
10331 override float GetSingleInventoryItemWeightEx()
10332 {
10333 //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
10334 float weightEx = GetWeightEx();//overall weight of the item
10335 float special = GetInventoryAndCargoWeight();//cargo and attachment weight
10336 return weightEx - special;
10337 }
10338
10339 // Obsolete, use GetSingleInventoryItemWeightEx() instead
10341 {
10343 }
10344
10345 override protected float GetWeightSpecialized(bool forceRecalc = false)
10346 {
10347 if (IsSplitable()) //quantity determines size of the stack
10348 {
10349 #ifdef DEVELOPER
10350 if (WeightDebug.m_VerbosityFlags & WeightDebugType.RECALC_FORCED)
10351 {
10352 WeightDebugData data1 = WeightDebug.GetWeightDebug(this);
10353 data1.SetCalcDetails("TIB1: " + GetConfigWeightModifiedDebugText() +" * " + GetQuantity()+"(quantity)");
10354 }
10355 #endif
10356
10357 return GetQuantity() * GetConfigWeightModified();
10358 }
10359 else if (HasEnergyManager())// items with energy manager
10360 {
10361 #ifdef DEVELOPER
10362 if (WeightDebug.m_VerbosityFlags & WeightDebugType.RECALC_FORCED)
10363 {
10364 WeightDebugData data2 = WeightDebug.GetWeightDebug(this);
10365 data2.SetCalcDetails("TIB2: "+super.GetWeightSpecialized(forceRecalc)+"(contents weight) + " + GetConfigWeightModifiedDebugText() +" + " + GetCompEM().GetEnergy()+"(energy) * " + ConfigGetFloat("weightPerQuantityUnit") +"(weightPerQuantityUnit)");
10366 }
10367 #endif
10368 return super.GetWeightSpecialized(forceRecalc) + (GetCompEM().GetEnergy() * ConfigGetFloat("weightPerQuantityUnit")) + GetConfigWeightModified();
10369 }
10370 else//everything else
10371 {
10372 #ifdef DEVELOPER
10373 if (WeightDebug.m_VerbosityFlags & WeightDebugType.RECALC_FORCED)
10374 {
10375 WeightDebugData data3 = WeightDebug.GetWeightDebug(this);
10376 data3.SetCalcDetails("TIB3: "+super.GetWeightSpecialized(forceRecalc)+"(contents weight) + " + GetConfigWeightModifiedDebugText() +" + " + GetQuantity()+"(quantity) * " + ConfigGetFloat("weightPerQuantityUnit") +"(weightPerQuantityUnit))");
10377 }
10378 #endif
10379 return super.GetWeightSpecialized(forceRecalc) + (GetQuantity() * ConfigGetFloat("weightPerQuantityUnit")) + GetConfigWeightModified();
10380 }
10381 }
10382
10384 int GetNumberOfItems()
10385 {
10386 int item_count = 0;
10387 ItemBase item;
10388
10389 if (GetInventory().GetCargo() != NULL)
10390 {
10391 item_count = GetInventory().GetCargo().GetItemCount();
10392 }
10393
10394 for (int i = 0; i < GetInventory().AttachmentCount(); i++)
10395 {
10396 Class.CastTo(item,GetInventory().GetAttachmentFromIndex(i));
10397 if (item)
10398 item_count += item.GetNumberOfItems();
10399 }
10400 return item_count;
10401 }
10402
10404 float GetUnitWeight(bool include_wetness = true)
10405 {
10406 float weight = 0;
10407 float wetness = 1;
10408 if (include_wetness)
10409 wetness += GetWet();
10410 if (IsSplitable()) //quantity determines size of the stack
10411 {
10412 weight = wetness * m_ConfigWeight;
10413 }
10414 else if (IsLiquidContainer()) //is a liquid container, default liquid weight is set to 1. May revisit later?
10415 {
10416 weight = 1;
10417 }
10418 return weight;
10419 }
10420
10421 //-----------------------------------------------------------------
10422
10423 override void ClearInventory()
10424 {
10425 if ((GetGame().IsServer() || !GetGame().IsMultiplayer()) && GetInventory())
10426 {
10427 GameInventory inv = GetInventory();
10428 array<EntityAI> items = new array<EntityAI>;
10429 inv.EnumerateInventory(InventoryTraversalType.INORDER, items);
10430 for (int i = 0; i < items.Count(); i++)
10431 {
10432 ItemBase item = ItemBase.Cast(items.Get(i));
10433 if (item)
10434 {
10435 GetGame().ObjectDelete(item);
10436 }
10437 }
10438 }
10439 }
10440
10441 //------------------------- Energy
10442
10443 //----------------------------------------------------------------
10444 float GetEnergy()
10445 {
10446 float energy = 0;
10447 if (HasEnergyManager())
10448 {
10449 energy = GetCompEM().GetEnergy();
10450 }
10451 return energy;
10452 }
10453
10454
10455 override void OnEnergyConsumed()
10456 {
10457 super.OnEnergyConsumed();
10458
10460 }
10461
10462 override void OnEnergyAdded()
10463 {
10464 super.OnEnergyAdded();
10465
10467 }
10468
10469 // Converts energy (from Energy Manager) to quantity, if enabled.
10471 {
10472 if (GetGame().IsServer() && HasEnergyManager() && GetCompEM().HasConversionOfEnergyToQuantity())
10473 {
10474 if (HasQuantity())
10475 {
10476 float energy_0to1 = GetCompEM().GetEnergy0To1();
10477 SetQuantityNormalized(energy_0to1);
10478 }
10479 }
10480 }
10481
10482 //----------------------------------------------------------------
10483 float GetHeatIsolationInit()
10484 {
10485 return ConfigGetFloat("heatIsolation");
10486 }
10487
10488 float GetHeatIsolation()
10489 {
10490 return m_HeatIsolation;
10491 }
10492
10493 float GetDryingIncrement(string pIncrementName)
10494 {
10495 string paramPath = string.Format("CfgVehicles %1 EnvironmentWetnessIncrements Drying %2", GetType(), pIncrementName);
10496 if (GetGame().ConfigIsExisting(paramPath))
10497 return GetGame().ConfigGetFloat(paramPath);
10498
10499 return 0.0;
10500 }
10501
10502 float GetSoakingIncrement(string pIncrementName)
10503 {
10504 string paramPath = string.Format("CfgVehicles %1 EnvironmentWetnessIncrements Soaking %2", GetType(), pIncrementName);
10505 if (GetGame().ConfigIsExisting(paramPath))
10506 return GetGame().ConfigGetFloat(paramPath);
10507
10508 return 0.0;
10509 }
10510 //----------------------------------------------------------------
10511 override void SetWet(float value, bool allow_client = false)
10512 {
10513 if (!IsServerCheck(allow_client))
10514 return;
10515
10516 float min = GetWetMin();
10517 float max = GetWetMax();
10518
10519 float previousValue = m_VarWet;
10520
10521 m_VarWet = Math.Clamp(value, min, max);
10522
10523 if (previousValue != m_VarWet)
10524 {
10525 SetVariableMask(VARIABLE_WET);
10526 OnWetChanged(m_VarWet, previousValue);
10527 }
10528 }
10529 //----------------------------------------------------------------
10530 override void AddWet(float value)
10531 {
10532 SetWet(GetWet() + value);
10533 }
10534 //----------------------------------------------------------------
10535 override void SetWetMax()
10536 {
10538 }
10539 //----------------------------------------------------------------
10540 override float GetWet()
10541 {
10542 return m_VarWet;
10543 }
10544 //----------------------------------------------------------------
10545 override float GetWetMax()
10546 {
10547 return m_VarWetMax;
10548 }
10549 //----------------------------------------------------------------
10550 override float GetWetMin()
10551 {
10552 return m_VarWetMin;
10553 }
10554 //----------------------------------------------------------------
10555 override float GetWetInit()
10556 {
10557 return m_VarWetInit;
10558 }
10559 //----------------------------------------------------------------
10560 override void OnWetChanged(float newVal, float oldVal)
10561 {
10562 EWetnessLevel newLevel = GetWetLevelInternal(newVal);
10563 EWetnessLevel oldLevel = GetWetLevelInternal(oldVal);
10564 if (newLevel != oldLevel)
10565 {
10566 OnWetLevelChanged(newLevel,oldLevel);
10567 }
10568 }
10569
10570 override void OnWetLevelChanged(EWetnessLevel newLevel, EWetnessLevel oldLevel)
10571 {
10572 SetWeightDirty();
10573 }
10574
10575 override EWetnessLevel GetWetLevel()
10576 {
10577 return GetWetLevelInternal(m_VarWet);
10578 }
10579
10580 //----------------------------------------------------------------
10581
10582 override void SetStoreLoad(bool value)
10583 {
10584 m_IsStoreLoad = value;
10585 }
10586
10587 override bool IsStoreLoad()
10588 {
10589 return m_IsStoreLoad;
10590 }
10591
10592 override void SetStoreLoadedQuantity(float value)
10593 {
10594 m_StoreLoadedQuantity = value;
10595 }
10596
10597 override float GetStoreLoadedQuantity()
10598 {
10599 return m_StoreLoadedQuantity;
10600 }
10601
10602 //----------------------------------------------------------------
10603
10604 float GetItemModelLength()
10605 {
10606 if (ConfigIsExisting("itemModelLength"))
10607 {
10608 return ConfigGetFloat("itemModelLength");
10609 }
10610 return 0;
10611 }
10612
10613 float GetItemAttachOffset()
10614 {
10615 if (ConfigIsExisting("itemAttachOffset"))
10616 {
10617 return ConfigGetFloat("itemAttachOffset");
10618 }
10619 return 0;
10620 }
10621
10622 override void SetCleanness(int value, bool allow_client = false)
10623 {
10624 if (!IsServerCheck(allow_client))
10625 return;
10626
10627 int previousValue = m_Cleanness;
10628
10629 m_Cleanness = Math.Clamp(value, m_CleannessMin, m_CleannessMax);
10630
10631 if (previousValue != m_Cleanness)
10632 SetVariableMask(VARIABLE_CLEANNESS);
10633 }
10634
10635 override int GetCleanness()
10636 {
10637 return m_Cleanness;
10638 }
10639
10641 {
10642 return true;
10643 }
10644
10645 //----------------------------------------------------------------
10646 // ATTACHMENT LOCKING
10647 // Getters relevant to generic ActionLockAttachment
10648 int GetLockType()
10649 {
10650 return m_LockType;
10651 }
10652
10653 string GetLockSoundSet()
10654 {
10655 return m_LockSoundSet;
10656 }
10657
10658 //----------------------------------------------------------------
10659 //------------------------- Color
10660 // sets items color variable given color components
10661 override void SetColor(int r, int g, int b, int a)
10662 {
10667 SetVariableMask(VARIABLE_COLOR);
10668 }
10670 override void GetColor(out int r,out int g,out int b,out int a)
10671 {
10676 }
10677
10678 bool IsColorSet()
10679 {
10680 return IsVariableSet(VARIABLE_COLOR);
10681 }
10682
10684 string GetColorString()
10685 {
10686 int r,g,b,a;
10687 GetColor(r,g,b,a);
10688 r = r/255;
10689 g = g/255;
10690 b = b/255;
10691 a = a/255;
10692 return MiscGameplayFunctions.GetColorString(r, g, b, a);
10693 }
10694 //----------------------------------------------------------------
10695 //------------------------- LiquidType
10696
10697 override void SetLiquidType(int value, bool allow_client = false)
10698 {
10699 if (!IsServerCheck(allow_client))
10700 return;
10701
10702 int old = m_VarLiquidType;
10703 m_VarLiquidType = value;
10704 OnLiquidTypeChanged(old,value);
10705 SetVariableMask(VARIABLE_LIQUIDTYPE);
10706 }
10707
10708 int GetLiquidTypeInit()
10709 {
10710 return ConfigGetInt("varLiquidTypeInit");
10711 }
10712
10713 override int GetLiquidType()
10714 {
10715 return m_VarLiquidType;
10716 }
10717
10718 protected void OnLiquidTypeChanged(int oldType, int newType)
10719 {
10720 if (newType == LIQUID_NONE && GetIsFrozen())
10721 SetFrozen(false);
10722 }
10723
10725 void UpdateQuickbarShortcutVisibility(PlayerBase player)
10726 {
10727 player.SetEnableQuickBarEntityShortcut(this,!GetHierarchyParent() || GetHierarchyParent().GetInventory().AreChildrenAccessible());
10728 }
10729
10730 // -------------------------------------------------------------------------
10732 void OnInventoryEnter(Man player)
10733 {
10734 PlayerBase nplayer;
10735 if (PlayerBase.CastTo(nplayer, player))
10736 {
10737 m_CanPlayImpactSound = true;
10738 //nplayer.OnItemInventoryEnter(this);
10739 nplayer.SetEnableQuickBarEntityShortcut(this,!GetHierarchyParent() || GetHierarchyParent().GetInventory().AreChildrenAccessible());
10740 }
10741 }
10742
10743 // -------------------------------------------------------------------------
10745 void OnInventoryExit(Man player)
10746 {
10747 PlayerBase nplayer;
10748 if (PlayerBase.CastTo(nplayer,player))
10749 {
10750 //nplayer.OnItemInventoryExit(this);
10751 nplayer.SetEnableQuickBarEntityShortcut(this,false);
10752
10753 }
10754
10755 //if (!GetGame().IsDedicatedServer())
10756 player.GetHumanInventory().ClearUserReservedLocationForContainer(this);
10757
10758
10759 if (HasEnergyManager())
10760 {
10761 GetCompEM().UpdatePlugState(); // Unplug the el. device if it's necesarry.
10762 }
10763 }
10764
10765 // ADVANCED PLACEMENT EVENTS
10766 override void OnPlacementStarted(Man player)
10767 {
10768 super.OnPlacementStarted(player);
10769
10770 SetTakeable(false);
10771 }
10772
10773 override void OnPlacementComplete(Man player, vector position = "0 0 0", vector orientation = "0 0 0")
10774 {
10775 if (m_AdminLog)
10776 {
10777 m_AdminLog.OnPlacementComplete(player, this);
10778 }
10779
10780 super.OnPlacementComplete(player, position, orientation);
10781 }
10782
10783 //-----------------------------
10784 // AGENT SYSTEM
10785 //-----------------------------
10786 //--------------------------------------------------------------------------
10787 bool ContainsAgent(int agent_id)
10788 {
10789 if (agent_id & m_AttachedAgents)
10790 {
10791 return true;
10792 }
10793 else
10794 {
10795 return false;
10796 }
10797 }
10798
10799 //--------------------------------------------------------------------------
10800 override void RemoveAgent(int agent_id)
10801 {
10802 if (ContainsAgent(agent_id))
10803 {
10804 m_AttachedAgents = ~agent_id & m_AttachedAgents;
10805 }
10806 }
10807
10808 //--------------------------------------------------------------------------
10809 override void RemoveAllAgents()
10810 {
10811 m_AttachedAgents = 0;
10812 }
10813 //--------------------------------------------------------------------------
10814 override void RemoveAllAgentsExcept(int agent_to_keep)
10815 {
10816 m_AttachedAgents = m_AttachedAgents & agent_to_keep;
10817 }
10818 // -------------------------------------------------------------------------
10819 override void InsertAgent(int agent, float count = 1)
10820 {
10821 if (count < 1)
10822 return;
10823 //Debug.Log("Inserting Agent on item: " + agent.ToString() +" count: " + count.ToString());
10825 }
10826
10828 void TransferAgents(int agents)
10829 {
10831 }
10832
10833 // -------------------------------------------------------------------------
10834 override int GetAgents()
10835 {
10836 return m_AttachedAgents;
10837 }
10838 //----------------------------------------------------------------------
10839
10840 /*int GetContaminationType()
10841 {
10842 int contamination_type;
10843
10844 const int CONTAMINATED_MASK = eAgents.CHOLERA | eAgents.INFLUENZA | eAgents.SALMONELLA | eAgents.BRAIN;
10845 const int POISONED_MASK = eAgents.FOOD_POISON | eAgents.CHEMICAL_POISON;
10846 const int NERVE_GAS_MASK = eAgents.CHEMICAL_POISON;
10847 const int DIRTY_MASK = eAgents.WOUND_AGENT;
10848
10849 Edible_Base edible = Edible_Base.Cast(this);
10850 int agents = GetAgents();
10851 if (edible)
10852 {
10853 NutritionalProfile profile = Edible_Base.GetNutritionalProfile(edible);
10854 if (profile)
10855 {
10856 agents = agents | profile.GetAgents();//merge item's agents with nutritional agents
10857 }
10858 }
10859 if (agents & CONTAMINATED_MASK)
10860 {
10861 contamination_type = contamination_type | EContaminationTypes.ITEM_BADGE_CONTAMINATED;
10862 }
10863 if (agents & POISONED_MASK)
10864 {
10865 contamination_type = contamination_type | EContaminationTypes.ITEM_BADGE_POISONED;
10866 }
10867 if (agents & NERVE_GAS_MASK)
10868 {
10869 contamination_type = contamination_type | EContaminationTypes.ITEM_BADGE_NERVE_GAS;
10870 }
10871 if (agents & DIRTY_MASK)
10872 {
10873 contamination_type = contamination_type | EContaminationTypes.ITEM_BADGE_DIRTY;
10874 }
10875
10876 return agents;
10877 }*/
10878
10879 // -------------------------------------------------------------------------
10880 bool LoadAgents(ParamsReadContext ctx, int version)
10881 {
10882 if (!ctx.Read(m_AttachedAgents))
10883 return false;
10884 return true;
10885 }
10886 // -------------------------------------------------------------------------
10888 {
10889
10891 }
10892 // -------------------------------------------------------------------------
10893
10895 override void CheckForRoofLimited(float timeTresholdMS = 3000)
10896 {
10897 super.CheckForRoofLimited(timeTresholdMS);
10898
10899 float time = GetGame().GetTime();
10900 if ((time - m_PreviousRoofTestTime) >= timeTresholdMS)
10901 {
10902 m_PreviousRoofTestTime = time;
10903 SetRoofAbove(MiscGameplayFunctions.IsUnderRoof(this));
10904 }
10905 }
10906
10907 // returns item's protection level against enviromental hazard, for masks with filters, returns the filters protection for valid filter, otherwise 0
10908 float GetProtectionLevel(int type, bool consider_filter = false, int system = 0)
10909 {
10910 if (IsDamageDestroyed() || (HasQuantity() && GetQuantity() <= 0))
10911 {
10912 return 0;
10913 }
10914
10915 if (GetInventory().GetAttachmentSlotsCount() != 0)//is it an item with attachable filter ?
10916 {
10917 ItemBase filter = ItemBase.Cast(FindAttachmentBySlotName("GasMaskFilter"));
10918 if (filter)
10919 return filter.GetProtectionLevel(type, false, system);//it's a valid filter, return the protection
10920 else
10921 return 0;//otherwise return 0 when no filter attached
10922 }
10923
10924 string subclassPath, entryName;
10925
10926 switch (type)
10927 {
10928 case DEF_BIOLOGICAL:
10929 entryName = "biological";
10930 break;
10931 case DEF_CHEMICAL:
10932 entryName = "chemical";
10933 break;
10934 default:
10935 entryName = "biological";
10936 break;
10937 }
10938
10939 subclassPath = "CfgVehicles " + this.GetType() + " Protection ";
10940
10941 return GetGame().ConfigGetFloat(subclassPath + entryName);
10942 }
10943
10944
10945
10947 override void EEOnCECreate()
10948 {
10949 if (!IsMagazine())
10951
10953 }
10954
10955
10956 //-------------------------
10957 // OPEN/CLOSE USER ACTIONS
10958 //-------------------------
10960 void Open();
10961 void Close();
10962 bool IsOpen()
10963 {
10964 return true;
10965 }
10966
10967 override bool CanDisplayCargo()
10968 {
10969 return IsOpen();
10970 }
10971
10972
10973 // ------------------------------------------------------------
10974 // CONDITIONS
10975 // ------------------------------------------------------------
10976 override bool CanPutInCargo(EntityAI parent)
10977 {
10978 if (parent)
10979 {
10980 if (parent.IsInherited(DayZInfected))
10981 return true;
10982
10983 if (!parent.IsRuined())
10984 return true;
10985 }
10986
10987 return true;
10988 }
10989
10990 override bool CanPutAsAttachment(EntityAI parent)
10991 {
10992 if (!super.CanPutAsAttachment(parent))
10993 {
10994 return false;
10995 }
10996
10997 if (!IsRuined() && !parent.IsRuined())
10998 {
10999 return true;
11000 }
11001
11002 return false;
11003 }
11004
11005 override bool CanReceiveItemIntoCargo(EntityAI item)
11006 {
11007 //removed 15.06. coz of loading from storage -> after load items in cargo was lost -> waiting for proper solution
11008 //if (GetHealthLevel() == GameConstants.STATE_RUINED)
11009 // return false;
11010
11011 return super.CanReceiveItemIntoCargo(item);
11012 }
11013
11014 override bool CanReceiveAttachment(EntityAI attachment, int slotId)
11015 {
11016 //removed 15.06. coz of loading from storage -> after load items in cargo was lost -> waiting for proper solution
11017 //if (GetHealthLevel() == GameConstants.STATE_RUINED)
11018 // return false;
11019
11020 GameInventory attachmentInv = attachment.GetInventory();
11021 if (attachmentInv && attachmentInv.GetCargo() && attachmentInv.GetCargo().GetItemCount() > 0)
11022 {
11023 if (GetHierarchyParent() && !GetHierarchyParent().IsInherited(PlayerBase))
11024 return false;
11025 }
11026
11027 InventoryLocation loc = new InventoryLocation();
11028 attachment.GetInventory().GetCurrentInventoryLocation(loc);
11029 if (loc && loc.IsValid() && !GetInventory().AreChildrenAccessible())
11030 return false;
11031
11032 return super.CanReceiveAttachment(attachment, slotId);
11033 }
11034
11035 override bool CanReleaseAttachment(EntityAI attachment)
11036 {
11037 if (!super.CanReleaseAttachment(attachment))
11038 return false;
11039
11040 return GetInventory().AreChildrenAccessible();
11041 }
11042
11043 /*override bool CanLoadAttachment(EntityAI attachment)
11044 {
11045 //removed 15.06. coz of loading from storage -> after load items in cargo was lost -> waiting for proper solution
11046 //if (GetHealthLevel() == GameConstants.STATE_RUINED)
11047 // return false;
11048
11049 GameInventory attachmentInv = attachment.GetInventory();
11050 if (attachmentInv && attachmentInv.GetCargo() && attachmentInv.GetCargo().GetItemCount() > 0)
11051 {
11052 bool boo = (GetHierarchyParent() && !GetHierarchyParent().IsInherited(PlayerBase));
11053 ErrorEx("CanLoadAttachment | this: " + this + " | attachment: " + attachment + " | boo: " + boo,ErrorExSeverity.INFO);
11054
11055 if (GetHierarchyParent() && !GetHierarchyParent().IsInherited(PlayerBase))
11056 return false;
11057 }
11058
11059 return super.CanLoadAttachment(attachment);
11060 }*/
11061
11062 // Plays muzzle flash particle effects
11063 static void PlayFireParticles(ItemBase weapon, int muzzle_index, string ammoType, ItemBase muzzle_owner, ItemBase suppressor, string config_to_search)
11064 {
11065 int id = muzzle_owner.GetMuzzleID();
11066 array<ref WeaponParticlesOnFire> WPOF_array = m_OnFireEffect.Get(id);
11067
11068 if (WPOF_array)
11069 {
11070 for (int i = 0; i < WPOF_array.Count(); i++)
11071 {
11072 WeaponParticlesOnFire WPOF = WPOF_array.Get(i);
11073
11074 if (WPOF)
11075 {
11076 WPOF.OnActivate(weapon, muzzle_index, ammoType, muzzle_owner, suppressor, config_to_search);
11077 }
11078 }
11079 }
11080 }
11081
11082 // Plays bullet eject particle effects (usually just smoke, the bullet itself is a 3D model and is not part of this function)
11083 static void PlayBulletCasingEjectParticles(ItemBase weapon, string ammoType, ItemBase muzzle_owner, ItemBase suppressor, string config_to_search)
11084 {
11085 int id = muzzle_owner.GetMuzzleID();
11086 array<ref WeaponParticlesOnBulletCasingEject> WPOBE_array = m_OnBulletCasingEjectEffect.Get(id);
11087
11088 if (WPOBE_array)
11089 {
11090 for (int i = 0; i < WPOBE_array.Count(); i++)
11091 {
11092 WeaponParticlesOnBulletCasingEject WPOBE = WPOBE_array.Get(i);
11093
11094 if (WPOBE)
11095 {
11096 WPOBE.OnActivate(weapon, 0, ammoType, muzzle_owner, suppressor, config_to_search);
11097 }
11098 }
11099 }
11100 }
11101
11102 // Plays all weapon overheating particles
11103 static void PlayOverheatingParticles(ItemBase weapon, string ammoType, ItemBase muzzle_owner, ItemBase suppressor, string config_to_search)
11104 {
11105 int id = muzzle_owner.GetMuzzleID();
11106 array<ref WeaponParticlesOnOverheating> WPOOH_array = weapon.m_OnOverheatingEffect.Get(id);
11107
11108 if (WPOOH_array)
11109 {
11110 for (int i = 0; i < WPOOH_array.Count(); i++)
11111 {
11112 WeaponParticlesOnOverheating WPOOH = WPOOH_array.Get(i);
11113
11114 if (WPOOH)
11115 {
11116 WPOOH.OnActivate(weapon, 0, ammoType, muzzle_owner, suppressor, config_to_search);
11117 }
11118 }
11119 }
11120 }
11121
11122 // Updates all weapon overheating particles
11123 static void UpdateOverheatingParticles(ItemBase weapon, string ammoType, ItemBase muzzle_owner, ItemBase suppressor, string config_to_search)
11124 {
11125 int id = muzzle_owner.GetMuzzleID();
11126 array<ref WeaponParticlesOnOverheating> WPOOH_array = weapon.m_OnOverheatingEffect.Get(id);
11127
11128 if (WPOOH_array)
11129 {
11130 for (int i = 0; i < WPOOH_array.Count(); i++)
11131 {
11132 WeaponParticlesOnOverheating WPOOH = WPOOH_array.Get(i);
11133
11134 if (WPOOH)
11135 {
11136 WPOOH.OnUpdate(weapon, ammoType, muzzle_owner, suppressor, config_to_search);
11137 }
11138 }
11139 }
11140 }
11141
11142 // Stops overheating particles
11143 static void StopOverheatingParticles(ItemBase weapon, string ammoType, ItemBase muzzle_owner, ItemBase suppressor, string config_to_search)
11144 {
11145 int id = muzzle_owner.GetMuzzleID();
11146 array<ref WeaponParticlesOnOverheating> WPOOH_array = weapon.m_OnOverheatingEffect.Get(id);
11147
11148 if (WPOOH_array)
11149 {
11150 for (int i = 0; i < WPOOH_array.Count(); i++)
11151 {
11152 WeaponParticlesOnOverheating WPOOH = WPOOH_array.Get(i);
11153
11154 if (WPOOH)
11155 {
11156 WPOOH.OnDeactivate(weapon, ammoType, muzzle_owner, suppressor, config_to_search);
11157 }
11158 }
11159 }
11160 }
11161
11162 //----------------------------------------------------------------
11163 //Item Behaviour - unified approach
11164 override bool IsHeavyBehaviour()
11165 {
11166 if (m_ItemBehaviour == 0)
11167 {
11168 return true;
11169 }
11170
11171 return false;
11172 }
11173
11174 override bool IsOneHandedBehaviour()
11175 {
11176 if (m_ItemBehaviour == 1)
11177 {
11178 return true;
11179 }
11180
11181 return false;
11182 }
11183
11184 override bool IsTwoHandedBehaviour()
11185 {
11186 if (m_ItemBehaviour == 2)
11187 {
11188 return true;
11189 }
11190
11191 return false;
11192 }
11193
11194 bool IsDeployable()
11195 {
11196 return false;
11197 }
11198
11200 float GetDeployTime()
11201 {
11202 return UATimeSpent.DEFAULT_DEPLOY;
11203 }
11204
11205
11206 //----------------------------------------------------------------
11207 // Item Targeting (User Actions)
11208 override void SetTakeable(bool pState)
11209 {
11210 m_IsTakeable = pState;
11211 SetSynchDirty();
11212 }
11213
11214 override bool IsTakeable()
11215 {
11216 return m_IsTakeable;
11217 }
11218
11219 // For cases where we want to show object widget which cant be taken to hands
11221 {
11222 return false;
11223 }
11224
11226 protected void PreLoadSoundAttachmentType()
11227 {
11228 string att_type = "None";
11229
11230 if (ConfigIsExisting("soundAttType"))
11231 {
11232 att_type = ConfigGetString("soundAttType");
11233 }
11234
11235 m_SoundAttType = att_type;
11236 }
11237
11238 override string GetAttachmentSoundType()
11239 {
11240 return m_SoundAttType;
11241 }
11242
11243 //----------------------------------------------------------------
11244 //SOUNDS - ItemSoundHandler
11245 //----------------------------------------------------------------
11246
11247 string GetPlaceSoundset(); // played when deploy starts
11248 string GetLoopDeploySoundset(); // played when deploy starts and stopped when it finishes
11249 string GetDeploySoundset(); // played when deploy sucessfully finishes
11250 string GetLoopFoldSoundset(); // played when fold starts and stopped when it finishes
11251 string GetFoldSoundset(); // played when fold sucessfully finishes
11252
11254 {
11255 if (!m_ItemSoundHandler)
11257
11258 return m_ItemSoundHandler;
11259 }
11260
11261 // override to initialize sounds
11262 protected void InitItemSounds()
11263 {
11264 if (GetPlaceSoundset() == string.Empty && GetDeploySoundset() == string.Empty && GetLoopDeploySoundset() == string.Empty)
11265 return;
11266
11268
11269 if (GetPlaceSoundset() != string.Empty)
11270 handler.AddSound(SoundConstants.ITEM_PLACE, GetPlaceSoundset());
11271
11272 if (GetDeploySoundset() != string.Empty)
11273 handler.AddSound(SoundConstants.ITEM_DEPLOY, GetDeploySoundset());
11274
11275 SoundParameters params = new SoundParameters();
11276 params.m_Loop = true;
11277 if (GetLoopDeploySoundset() != string.Empty)
11278 handler.AddSound(SoundConstants.ITEM_DEPLOY_LOOP, GetLoopDeploySoundset(), params);
11279 }
11280
11281 // Start sound using ItemSoundHandler
11282 void StartItemSoundServer(int id)
11283 {
11284 if (!GetGame().IsServer())
11285 return;
11286
11287 m_SoundSyncPlay = id;
11288 SetSynchDirty();
11289
11290 GetGame().GetCallQueue(CALL_CATEGORY_SYSTEM).Remove(ClearStartItemSoundServer); // in case one is queued already
11292 }
11293
11294 // Stop sound using ItemSoundHandler
11295 void StopItemSoundServer(int id)
11296 {
11297 if (!GetGame().IsServer())
11298 return;
11299
11300 m_SoundSyncStop = id;
11301 SetSynchDirty();
11302
11303 GetGame().GetCallQueue(CALL_CATEGORY_SYSTEM).Remove(ClearStopItemSoundServer); // in case one is queued already
11305 }
11306
11307 protected void ClearStartItemSoundServer()
11308 {
11309 m_SoundSyncPlay = 0;
11310 }
11311
11312 protected void ClearStopItemSoundServer()
11313 {
11314 m_SoundSyncStop = 0;
11315 }
11316
11318 void PlayAttachSound(string slot_type)
11319 {
11320 if (!GetGame().IsDedicatedServer())
11321 {
11322 if (ConfigIsExisting("attachSoundSet"))
11323 {
11324 string cfg_path = "";
11325 string soundset = "";
11326 string type_name = GetType();
11327
11328 TStringArray cfg_soundset_array = new TStringArray;
11329 TStringArray cfg_slot_array = new TStringArray;
11330 ConfigGetTextArray("attachSoundSet",cfg_soundset_array);
11331 ConfigGetTextArray("attachSoundSlot",cfg_slot_array);
11332
11333 if (cfg_soundset_array.Count() > 0 && cfg_soundset_array.Count() == cfg_slot_array.Count())
11334 {
11335 for (int i = 0; i < cfg_soundset_array.Count(); i++)
11336 {
11337 if (cfg_slot_array[i] == slot_type)
11338 {
11339 soundset = cfg_soundset_array[i];
11340 break;
11341 }
11342 }
11343 }
11344
11345 if (soundset != "")
11346 {
11347 EffectSound sound = SEffectManager.PlaySound(soundset, GetPosition());
11348 sound.SetAutodestroy(true);
11349 }
11350 }
11351 }
11352 }
11353
11354 void PlayDetachSound(string slot_type)
11355 {
11356 //TODO - evaluate if needed and devise universal config structure if so
11357 }
11358
11359 void OnApply(PlayerBase player);
11360
11362 {
11363 return 1.0;
11364 };
11365 //returns applicable selection
11366 array<string> GetHeadHidingSelection()
11367 {
11369 }
11370
11372 {
11374 }
11375
11376 WrittenNoteData GetWrittenNoteData() {};
11377
11379 {
11380 SetDynamicPhysicsLifeTime(0.01);
11381 m_ItemBeingDroppedPhys = false;
11382 }
11383
11385 {
11386 array<string> zone_names = new array<string>;
11387 GetDamageZones(zone_names);
11388 for (int i = 0; i < zone_names.Count(); i++)
11389 {
11390 SetHealthMax(zone_names.Get(i),"Health");
11391 }
11392 SetHealthMax("","Health");
11393 }
11394
11396 void SetZoneDamageCEInit()
11397 {
11398 float global_health = GetHealth01("","Health");
11399 array<string> zones = new array<string>;
11400 GetDamageZones(zones);
11401 //set damage of all zones to match global health level
11402 for (int i = 0; i < zones.Count(); i++)
11403 {
11404 SetHealth01(zones.Get(i),"Health",global_health);
11405 }
11406 }
11407
11409 bool IsCoverFaceForShave(string slot_name)
11410 {
11411 return IsExclusionFlagPresent(PlayerBase.GetFaceCoverageShaveValues());
11412 }
11413
11414 void ProcessItemWetness(float delta, bool hasParent, bool hasRootAsPlayer, ItemBase refParentIB)
11415 {
11416 if (!hasRootAsPlayer)
11417 {
11418 if (refParentIB)
11419 {
11420 // parent is wet
11421 if ((refParentIB.GetWet() >= GameConstants.STATE_SOAKING_WET) && (m_VarWet < m_VarWetMax))
11422 AddWet(delta * GameConstants.WETNESS_RATE_WETTING_INSIDE);
11423 // parent has liquid inside
11424 else if ((refParentIB.GetLiquidType() != 0) && (refParentIB.GetQuantity() > 0) && (m_VarWet < m_VarWetMax))
11425 AddWet(delta * GameConstants.WETNESS_RATE_WETTING_LIQUID);
11426 // drying
11427 else if (m_VarWet > m_VarWetMin)
11428 AddWet(-1 * delta * GetDryingIncrement("ground") * 2);
11429 }
11430 else
11431 {
11432 // drying on ground or inside non-itembase (car, ...)
11433 if (m_VarWet > m_VarWetMin)
11434 AddWet(-1 * delta * GetDryingIncrement("ground"));
11435 }
11436 }
11437 }
11438
11439 void ProcessItemTemperature(float delta, bool hasParent, bool hasRootAsPlayer, ItemBase refParentIB)
11440 {
11442 {
11443 float target = g_Game.GetMission().GetWorldData().GetBaseEnvTemperatureAtObject(this);
11444 if (GetTemperature() != target || !IsFreezeThawProgressFinished())
11445 {
11446 float heatPermCoef = 1.0;
11447 EntityAI ent = this;
11448 while (ent)
11449 {
11450 heatPermCoef *= ent.GetHeatPermeabilityCoef();
11451 ent = ent.GetHierarchyParent();
11452 }
11453
11454 SetTemperatureEx(new TemperatureDataInterpolated(target,ETemperatureAccessTypes.ACCESS_WORLD,delta,GameConstants.TEMP_COEF_WORLD,heatPermCoef));
11455 }
11456 }
11457 }
11458
11459 void HierarchyCheck(out bool hasParent, out bool hasRootAsPlayer, out ItemBase refParentIB)
11460 {
11461 // hierarchy check for an item to decide whether it has some parent and it is in some player inventory
11462 EntityAI parent = GetHierarchyParent();
11463 if (!parent)
11464 {
11465 hasParent = false;
11466 hasRootAsPlayer = false;
11467 }
11468 else
11469 {
11470 hasParent = true;
11471 hasRootAsPlayer = (GetHierarchyRootPlayer() != null);
11472 refParentIB = ItemBase.Cast(parent);
11473 }
11474 }
11475
11476 protected void ProcessDecay(float delta, bool hasRootAsPlayer)
11477 {
11478 // this is stub, implemented on Edible_Base
11479 }
11480
11481 bool CanDecay()
11482 {
11483 // return true used on selected food clases so they can decay
11484 return false;
11485 }
11486
11487 protected bool CanProcessDecay()
11488 {
11489 // this is stub, implemented on Edible_Base class
11490 // used to determine whether it is still necessary for the food to decay
11491 return false;
11492 }
11493
11494 protected bool CanHaveWetness()
11495 {
11496 // return true used on selected items that have a wetness effect
11497 return false;
11498 }
11499
11501 bool CanBeConsumed(ConsumeConditionData data = null)
11502 {
11503 return !GetIsFrozen() && IsOpen();
11504 }
11505
11506 override void ProcessVariables()
11507 {
11508 bool hasParent = false, hasRootAsPlayer = false;
11509 ItemBase refParentIB;
11510
11511 bool wwtu = g_Game.IsWorldWetTempUpdateEnabled();
11512 bool foodDecay = g_Game.IsFoodDecayEnabled();
11513
11514 if (wwtu || foodDecay)
11515 {
11516 bool processWetness = wwtu && CanHaveWetness();
11517 bool processTemperature = wwtu && CanHaveTemperature();
11518 bool processDecay = foodDecay && CanDecay() && CanProcessDecay();
11519
11520 if (processWetness || processTemperature || processDecay)
11521 {
11522 HierarchyCheck(hasParent, hasRootAsPlayer, refParentIB);
11523
11524 if (processWetness)
11525 ProcessItemWetness(m_ElapsedSinceLastUpdate, hasParent, hasRootAsPlayer, refParentIB);
11526
11527 if (processTemperature)
11528 ProcessItemTemperature(m_ElapsedSinceLastUpdate, hasParent, hasRootAsPlayer, refParentIB);
11529
11530 if (processDecay)
11531 ProcessDecay(m_ElapsedSinceLastUpdate, hasRootAsPlayer);
11532 }
11533 }
11534 }
11535
11538 {
11539 return m_TemperaturePerQuantityWeight * GameConstants.ITEM_TEMPERATURE_QUANTITY_WEIGHT_MULTIPLIER;
11540 }
11541
11542 override float GetTemperatureFreezeThreshold()
11543 {
11545 return Liquid.GetFreezeThreshold(GetLiquidType());
11546
11547 return super.GetTemperatureFreezeThreshold();
11548 }
11549
11550 override float GetTemperatureThawThreshold()
11551 {
11553 return Liquid.GetThawThreshold(GetLiquidType());
11554
11555 return super.GetTemperatureThawThreshold();
11556 }
11557
11558 override float GetItemOverheatThreshold()
11559 {
11561 return Liquid.GetBoilThreshold(GetLiquidType());
11562
11563 return super.GetItemOverheatThreshold();
11564 }
11565
11566 override float GetTemperatureFreezeTime()
11567 {
11568 if (HasQuantity())
11569 return Math.Lerp(GameConstants.TEMPERATURE_TIME_FREEZE_MIN,Math.Max(GameConstants.TEMPERATURE_TIME_FREEZE_MIN,super.GetTemperatureFreezeTime()),GetQuantityNormalized());
11570
11571 return super.GetTemperatureFreezeTime();
11572 }
11573
11574 override float GetTemperatureThawTime()
11575 {
11576 if (HasQuantity())
11577 return Math.Lerp(GameConstants.TEMPERATURE_TIME_THAW_MIN,Math.Max(GameConstants.TEMPERATURE_TIME_FREEZE_MIN,super.GetTemperatureThawTime()),GetQuantityNormalized());
11578
11579 return super.GetTemperatureThawTime();
11580 }
11581
11583 void AffectLiquidContainerOnFill(int liquid_type, float amount);
11585 void AffectLiquidContainerOnTransfer(int liquidType, float amount, float sourceLiquidTemperature);
11586
11587 bool IsCargoException4x3(EntityAI item)
11588 {
11589 return (item.IsKindOf("Cauldron") || item.IsKindOf("Pot") || item.IsKindOf("FryingPan") || item.IsKindOf("SmallProtectorCase") || (item.IsKindOf("PortableGasStove") && item.FindAttachmentBySlotName("CookingEquipment")));
11590 }
11591
11593 {
11594 MiscGameplayFunctions.TransferItemProperties(oldItem, this);
11595 }
11596
11598 void AddLightSourceItem(ItemBase lightsource)
11599 {
11600 m_LightSourceItem = lightsource;
11601 }
11602
11604 {
11605 m_LightSourceItem = null;
11606 }
11607
11609 {
11610 return m_LightSourceItem;
11611 }
11612
11614 array<int> GetValidFinishers()
11615 {
11616 return null;
11617 }
11618
11620 bool GetActionWidgetOverride(out typename name)
11621 {
11622 return false;
11623 }
11624
11625 bool PairWithDevice(notnull ItemBase otherDevice)
11626 {
11627 if (GetGame().IsServer())
11628 {
11629 ItemBase explosive = otherDevice;
11631 if (!trg)
11632 {
11633 trg = RemoteDetonatorTrigger.Cast(otherDevice);
11634 explosive = this;
11635 }
11636
11637 explosive.PairRemote(trg);
11638 trg.SetControlledDevice(explosive);
11639
11640 int persistentID = RemotelyActivatedItemBehaviour.GeneratePersistentID();
11641 trg.SetPersistentPairID(persistentID);
11642 explosive.SetPersistentPairID(persistentID);
11643
11644 return true;
11645 }
11646 return false;
11647 }
11648
11650 float GetBaitEffectivity()
11651 {
11652 float ret = 1.0;
11653 if (HasQuantity())
11654 ret *= GetQuantityNormalized();
11655 ret *= GetHealth01();
11656
11657 return ret;
11658 }
11659
11660 #ifdef DEVELOPER
11661 override void SetDebugItem()
11662 {
11663 super.SetDebugItem();
11664 _itemBase = this;
11665 }
11666
11667 override string GetDebugText()
11668 {
11669 string text = super.GetDebugText();
11670
11671 text += string.Format("Heat isolation(raw): %1\n", GetHeatIsolation());
11672 text += string.Format("Heat isolation(modified): %1\n", MiscGameplayFunctions.GetCurrentItemHeatIsolation(this));
11673
11674 return text;
11675 }
11676 #endif
11677
11678 bool CanBeUsedForSuicide()
11679 {
11680 return true;
11681 }
11682
11684 //DEPRECATED BELOW
11686 // Backwards compatibility
11687 void ProcessItemWetnessAndTemperature(float delta, bool hasParent, bool hasRootAsPlayer, ItemBase refParentIB)
11688 {
11689 ProcessItemWetness(delta, hasParent, hasRootAsPlayer, refParentIB);
11690 ProcessItemTemperature(delta, hasParent, hasRootAsPlayer, refParentIB);
11691 }
11692
11693 // replaced by ItemSoundHandler
11694 protected EffectSound m_SoundDeployFinish;
11695 protected EffectSound m_SoundPlace;
11696 protected EffectSound m_DeployLoopSoundEx;
11697 protected EffectSound m_SoundDeploy;
11698 bool m_IsPlaceSound;
11699 bool m_IsDeploySound;
11701
11702 string GetDeployFinishSoundset();
11703 void PlayDeploySound();
11704 void PlayDeployFinishSound();
11705 void PlayPlaceSound();
11706 void PlayDeployLoopSoundEx();
11707 void StopDeployLoopSoundEx();
11708 void SoundSynchRemoteReset();
11709 void SoundSynchRemote();
11710 bool UsesGlobalDeploy(){return false;}
11711 bool CanPlayDeployLoopSound(){return false;}
11713 bool IsPlaceSound(){return m_IsPlaceSound;}
11714 bool IsDeploySound(){return m_IsDeploySound;}
11715 void SetIsPlaceSound(bool is_place_sound);
11716 void SetIsDeploySound(bool is_deploy_sound);
11717}
11718
11719EntityAI SpawnItemOnLocation(string object_name, notnull InventoryLocation loc, bool full_quantity)
11720{
11721 EntityAI entity = SpawnEntity(object_name, loc, ECE_IN_INVENTORY, RF_DEFAULT);
11722 if (entity)
11723 {
11724 bool is_item = entity.IsInherited(ItemBase);
11725 if (is_item && full_quantity)
11726 {
11727 ItemBase item = ItemBase.Cast(entity);
11728 item.SetQuantity(item.GetQuantityInit());
11729 }
11730 }
11731 else
11732 {
11733 ErrorEx("Cannot spawn entity: " + object_name,ErrorExSeverity.INFO);
11734 return NULL;
11735 }
11736 return entity;
11737}
11738
11739void SetupSpawnedItem(ItemBase item, float health, float quantity)
11740{
11741 if (item)
11742 {
11743 if (health > 0)
11744 item.SetHealth("", "", health);
11745
11746 if (item.CanHaveTemperature())
11747 {
11748 item.SetTemperatureDirect(GameConstants.ITEM_TEMPERATURE_NEUTRAL_ZONE_MIDDLE);
11749 if (item.CanFreeze())
11750 item.SetFrozen(false);
11751 }
11752
11753 if (item.HasEnergyManager())
11754 {
11755 if (quantity >= 0)
11756 {
11757 item.GetCompEM().SetEnergy0To1(quantity);
11758 }
11759 else
11760 {
11761 item.GetCompEM().SetEnergy(Math.AbsFloat(quantity));
11762 }
11763 }
11764 else if (item.IsMagazine())
11765 {
11766 Magazine mag = Magazine.Cast(item);
11767 if (quantity >= 0)
11768 {
11769 mag.ServerSetAmmoCount(mag.GetAmmoMax() * quantity);
11770 }
11771 else
11772 {
11773 mag.ServerSetAmmoCount(Math.AbsFloat(quantity));
11774 }
11775
11776 }
11777 else
11778 {
11779 if (quantity >= 0)
11780 {
11781 item.SetQuantityNormalized(quantity, false);
11782 }
11783 else
11784 {
11785 item.SetQuantity(Math.AbsFloat(quantity));
11786 }
11787
11788 }
11789 }
11790}
11791
11792#ifdef DEVELOPER
11793ItemBase _itemBase;//watched item goes here(LCTRL+RMB->Watch)
11794#endif
Param4< int, int, string, int > TSelectableActionInfoWithColor
Определения 3_Game/Entities/EntityAI.c:97
Param3 TSelectableActionInfo
EWetnessLevel
Определения 3_Game/Entities/EntityAI.c:2
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:14
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
int GetLiquidType()
Определения CCTWaterSurface.c:129
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:3868
DayZGame GetDayZGame()
Определения DayZGame.c:3870
EActions
Определения EActions.c:2
ERPCs
Определения ERPCs.c:2
PluginAdminLog m_AdminLog
Определения EmoteManager.c:142
const int MAX
Определения EnConvert.c:27
float GetTemperature()
Определения Environment.c:497
override bool IsExplosive()
Определения ExplosivesBase.c:59
override bool CanHaveTemperature()
Определения FireplaceBase.c:559
class GP5GasMask extends MaskBase ItemBase
Empty
Определения Hand_States.c:14
FindInventoryLocationType
flags for searching locations in inventory
Определения InventoryLocation.c:17
InventoryLocationType
types of Inventory Location
Определения InventoryLocation.c:4
class BoxCollidingParams component
ComponentInfo for BoxCollidingResult.
bool DamageItemInCargo(float damage)
Определения ItemBase.c:6380
static bool HasDebugActionsMask(int mask)
Определения ItemBase.c:5620
bool HidesSelectionBySlot()
Определения ItemBase.c:9347
float m_VarWetMin
Определения ItemBase.c:4881
void SplitItem(PlayerBase player)
Определения ItemBase.c:6831
void CopyScriptPropertiesFrom(EntityAI oldItem)
Определения ItemBase.c:9568
override void InsertAgent(int agent, float count=1)
Определения ItemBase.c:8795
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:8229
static void SetDebugActionsMask(int mask)
Определения ItemBase.c:5625
void SetIsDeploySound(bool is_deploy_sound)
bool IsOpen()
Определения ItemBase.c:8938
void SplitItemToInventoryLocation(notnull InventoryLocation dst)
Определения ItemBase.c:6798
override bool IsHeavyBehaviour()
Определения ItemBase.c:9140
override void SetWetMax()
Определения ItemBase.c:8511
bool IsCoverFaceForShave(string slot_name)
DEPRECATED in use, but returns correct values nontheless. Check performed elsewhere.
Определения ItemBase.c:9385
void ClearStartItemSoundServer()
Определения ItemBase.c:9283
float m_VarWet
Определения ItemBase.c:4878
void ProcessItemTemperature(float delta, bool hasParent, bool hasRootAsPlayer, ItemBase refParentIB)
Определения ItemBase.c:9415
map< typename, ref ActionOverrideData > TActionAnimOverrideMap
Определения ItemBase.c:2
override void RemoveAllAgentsExcept(int agent_to_keep)
Определения ItemBase.c:8790
static ref map< int, ref array< ref WeaponParticlesOnBulletCasingEject > > m_OnBulletCasingEjectEffect
Определения ItemBase.c:4941
bool CanBeMovedOverride()
Определения ItemBase.c:7522
override void SetWet(float value, bool allow_client=false)
Определения ItemBase.c:8487
ref TIntArray m_SingleUseActions
Определения ItemBase.c:4927
override void ProcessVariables()
Определения ItemBase.c:9482
ref TStringArray m_HeadHidingSelections
Определения ItemBase.c:4955
float GetWeightSpecialized(bool forceRecalc=false)
Определения ItemBase.c:8321
bool LoadAgents(ParamsReadContext ctx, int version)
Определения ItemBase.c:8856
void UpdateQuickbarShortcutVisibility(PlayerBase player)
To be called on moving item within character's inventory; 'player' should never be null.
Определения ItemBase.c:8701
void OverrideActionAnimation(typename action, int commandUID, int stanceMask=-1, int commandUIDProne=-1)
Определения ItemBase.c:5211
ref array< ref OverheatingParticle > m_OverheatingParticles
Определения ItemBase.c:4953
override float GetTemperatureFreezeThreshold()
Определения ItemBase.c:9518
bool m_IsSoundSynchRemote
Определения ItemBase.c:9676
float m_OverheatingShots
Определения ItemBase.c:4948
void StopItemSoundServer(int id)
Определения ItemBase.c:9271
static void ToggleDebugActionsMask(int mask)
Определения ItemBase.c:5640
void IncreaseOverheating(ItemBase weapon, string ammoType, ItemBase muzzle_owner, ItemBase suppressor, string config_to_search)
Определения ItemBase.c:5364
override float GetTemperatureFreezeTime()
Определения ItemBase.c:9542
ref array< int > m_CompatibleLocks
Определения ItemBase.c:4965
bool CanBeCooked()
Определения ItemBase.c:7478
override void CombineItemsClient(EntityAI entity2, bool use_stack_max=true)
Определения ItemBase.c:5707
float m_TemperaturePerQuantityWeight
Определения ItemBase.c:4977
bool m_RecipesInitialized
Определения ItemBase.c:4863
void SplitIntoStackMax(EntityAI destination_entity, int slot_id, PlayerBase player)
Определения ItemBase.c:6471
override float GetTemperatureThawThreshold()
Определения ItemBase.c:9526
override void OnEnergyConsumed()
Определения ItemBase.c:8431
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:8360
override EWetnessLevel GetWetLevel()
Определения ItemBase.c:8551
float GetSingleInventoryItemWeight()
Определения ItemBase.c:8316
ref TIntArray m_InteractActions
Определения ItemBase.c:4929
void MessageToOwnerStatus(string text)
Send message to owner player in grey color.
Определения ItemBase.c:7542
float m_VarQuantity
Определения ItemBase.c:4869
bool CanPlayDeployLoopSound()
Определения ItemBase.c:9687
override float GetWetMax()
Определения ItemBase.c:8521
bool CanBeUsedForSuicide()
Определения ItemBase.c:9654
override void CombineItemsEx(EntityAI entity2, bool use_stack_max=true)
Определения ItemBase.c:7117
void OnItemInHandsPlayerSwimStart(PlayerBase player)
void SetIsHologram(bool is_hologram)
Определения ItemBase.c:5845
void OnSyncVariables(ParamsReadContext ctx)
DEPRECATED (most likely)
Определения ItemBase.c:7696
void StartItemSoundServer(int id)
Определения ItemBase.c:9258
void DoAmmoExplosion()
Определения ItemBase.c:6315
static ref map< int, ref array< ref WeaponParticlesOnFire > > m_OnFireEffect
Определения ItemBase.c:4940
void SplitIntoStackMaxCargoClient(EntityAI destination_entity, int idx, int row, int col)
Определения ItemBase.c:6655
int GetItemSize()
Определения ItemBase.c:7507
bool m_CanBeMovedOverride
Определения ItemBase.c:4906
override string ChangeIntoOnAttach(string slot)
Определения ItemBase.c:6239
void UpdateOverheating(ItemBase weapon=null, string ammoType="", ItemBase muzzle_owner=null, ItemBase suppressor=null, string config_to_search="")
Определения ItemBase.c:5432
bool CanDecay()
Определения ItemBase.c:9457
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:8202
void SetQuantityMax()
Определения ItemBase.c:8207
override float GetQuantity()
Определения ItemBase.c:8296
int m_ColorComponentR
Определения ItemBase.c:4918
int m_ShotsToStartOverheating
Определения ItemBase.c:4950
override void OnWetChanged(float newVal, float oldVal)
Определения ItemBase.c:8536
void StopOverheating(ItemBase weapon=null, string ammoType="", ItemBase muzzle_owner=null, ItemBase suppressor=null, string config_to_search="")
Определения ItemBase.c:5439
static void PlayFireParticles(ItemBase weapon, int muzzle_index, string ammoType, ItemBase muzzle_owner, ItemBase suppressor, string config_to_search)
Определения ItemBase.c:9039
void OnOverheatingDecay()
Определения ItemBase.c:5402
float GetDryingIncrement(string pIncrementName)
Определения ItemBase.c:8469
void SoundSynchRemoteReset()
int m_Cleanness
Определения ItemBase.c:4884
bool HasMuzzle()
Returns true if this item has a muzzle (weapons, suppressors)
Определения ItemBase.c:5540
bool UsesGlobalDeploy()
Определения ItemBase.c:9686
int m_ItemBehaviour
Определения ItemBase.c:4899
override bool CanReleaseAttachment(EntityAI attachment)
Определения ItemBase.c:9011
float m_HeatIsolation
Определения ItemBase.c:4894
float m_VarWetInit
Определения ItemBase.c:4880
override void OnMovedInsideCargo(EntityAI container)
Определения ItemBase.c:5885
void SetCEBasedQuantity()
Определения ItemBase.c:5653
bool m_CanPlayImpactSound
Определения ItemBase.c:4890
override string GetAttachmentSoundType()
Определения ItemBase.c:9214
float GetOverheatingCoef()
Определения ItemBase.c:5459
array< string > GetHeadHidingSelection()
Определения ItemBase.c:9342
void PlayAttachSound(string slot_type)
Plays sound on item attach. Be advised, the config structure may slightly change in 1....
Определения ItemBase.c:9294
override bool IsStoreLoad()
Определения ItemBase.c:8563
int ComputeQuantityUsed(ItemBase other_item, bool use_stack_max=true)
Определения ItemBase.c:7093
bool IsLightSource()
Определения ItemBase.c:5781
bool m_HasQuantityBar
Определения ItemBase.c:4912
void SetResultOfSplit(bool value)
Определения ItemBase.c:7088
void SplitIntoStackMaxCargo(EntityAI destination_entity, int idx, int row, int col)
Определения ItemBase.c:6719
void OnAttachmentQuantityChanged(ItemBase item)
Called on server side when some attachment's quantity is changed. Call super.OnAttachmentQuantityChan...
Определения ItemBase.c:6889
void UpdateAllOverheatingParticles()
Определения ItemBase.c:5467
float GetSoakingIncrement(string pIncrementName)
Определения ItemBase.c:8478
static void StopOverheatingParticles(ItemBase weapon, string ammoType, ItemBase muzzle_owner, ItemBase suppressor, string config_to_search)
Определения ItemBase.c:9119
override float GetStoreLoadedQuantity()
Определения ItemBase.c:8573
int m_LockType
Определения ItemBase.c:4966
const int ITEM_SOUNDS_MAX
Определения ItemBase.c:4971
bool m_CanBeDigged
Определения ItemBase.c:4913
float m_ItemAttachOffset
Определения ItemBase.c:4896
float GetItemModelLength()
Определения ItemBase.c:8580
bool m_ThrowItemOnDrop
Определения ItemBase.c:4904
override bool ReadVarsFromCTX(ParamsReadContext ctx, int version=-1)
Определения ItemBase.c:7841
override void CheckForRoofLimited(float timeTresholdMS=3000)
Roof check for entity, limited by time (anti-spam solution)
Определения ItemBase.c:8871
void Close()
float GetHeatIsolation()
Определения ItemBase.c:8464
void CombineItems(ItemBase other_item, bool use_stack_max=true)
Определения ItemBase.c:7122
void TransferModifiers(PlayerBase reciever)
appears to be deprecated, legacy code
float GetTemperaturePerQuantityWeight()
Used in heat comfort calculations only!
Определения ItemBase.c:9513
bool CanHaveWetness()
Определения ItemBase.c:9470
int m_CleannessMin
Определения ItemBase.c:4886
void TransferAgents(int agents)
transfer agents from another item
Определения ItemBase.c:8804
string IDToName(int id)
Определения ItemBase.c:7689
bool CanBeConsumed(ConsumeConditionData data=null)
Items cannot be consumed if frozen by default. Override for exceptions.
Определения ItemBase.c:9477
float GetHeatIsolationInit()
Определения ItemBase.c:8459
void PlayPlaceSound()
void SetCanBeMovedOverride(bool setting)
Определения ItemBase.c:7529
override bool HasQuantity()
Определения ItemBase.c:8291
float m_VarWetPrev
Определения ItemBase.c:4879
int m_SoundSyncStop
Определения ItemBase.c:4973
bool IsCargoException4x3(EntityAI item)
Определения ItemBase.c:9563
ref TIntArray m_ContinuousActions
Определения ItemBase.c:4928
int GetMuzzleID()
Returns global muzzle ID. If not found, then it gets automatically registered.
Определения ItemBase.c:5549
void LoadParticleConfigOnFire(int id)
Определения ItemBase.c:5234
int m_VarLiquidType
Определения ItemBase.c:4898
int m_QuickBarBonus
Определения ItemBase.c:4900
void PreLoadSoundAttachmentType()
Attachment Sound Type getting from config file.
Определения ItemBase.c:9202
override float GetWetInit()
Определения ItemBase.c:8531
int m_ImpactSoundSurfaceHash
Определения ItemBase.c:4892
int m_SoundSyncPlay
Определения ItemBase.c:4972
int m_MaxOverheatingValue
Определения ItemBase.c:4951
void SetupSpawnedItem(ItemBase item, float health, float quantity)
Определения ItemBase.c:4875
bool m_IsTakeable
Определения ItemBase.c:4903
bool ShouldSplitQuantity(float quantity)
Определения ItemBase.c:6428
static ref map< string, int > m_WeaponTypeToID
Определения ItemBase.c:4943
string GetLockSoundSet()
Определения ItemBase.c:8629
string GetColorString()
Returns item's PROCEDURAL color as formated string, i.e. "#(argb,8,8,3)color(0.15,...
Определения ItemBase.c:8660
array< int > GetValidFinishers()
returns an array of possible finishers
Определения ItemBase.c:9590
void OnAttachmentQuantityChangedEx(ItemBase item, float delta)
Called on server side when some attachment's quantity is changed. Call super.OnAttachmentQuantityChan...
Определения ItemBase.c:6895
class ItemBase extends InventoryItem SpawnItemOnLocation(string object_name, notnull InventoryLocation loc, bool full_quantity)
Определения ItemBase.c:4855
ItemSoundHandler GetItemSoundHandler()
Определения ItemBase.c:9229
override int GetQuantityMin()
Определения ItemBase.c:8280
void SplitIntoStackMaxToInventoryLocationClient(notnull InventoryLocation dst)
Определения ItemBase.c:6634
override int GetQuickBarBonus()
Определения ItemBase.c:5119
override void SetTakeable(bool pState)
Определения ItemBase.c:9184
float m_OverheatingDecayInterval
Определения ItemBase.c:4952
void SetIsPlaceSound(bool is_place_sound)
override void SplitIntoStackMaxClient(EntityAI destination_entity, int slot_id)
Определения ItemBase.c:6448
void HierarchyCheck(out bool hasParent, out bool hasRootAsPlayer, out ItemBase refParentIB)
Определения ItemBase.c:9435
bool CanProcessDecay()
Определения ItemBase.c:9463
void RemoveAudioVisualsOnClient()
Определения Bottle_Base.c:151
void SoundSynchRemote()
static void AddDebugActionsMask(int mask)
Определения ItemBase.c:5630
void PlayDeployLoopSoundEx()
void RemoveLightSourceItem()
Определения ItemBase.c:9579
bool CanRepair(ItemBase item_repair_kit)
Определения ItemBase.c:7493
bool can_this_be_combined
Определения ItemBase.c:4908
EffectSound m_SoundDeploy
Определения ItemBase.c:9673
int m_Count
Определения ItemBase.c:4874
float GetBaitEffectivity()
generic effectivity as a bait for animal catching
Определения ItemBase.c:9626
float GetDeployTime()
how long it takes to deploy this item in seconds
Определения ItemBase.c:9176
override bool IsSplitable()
Определения ItemBase.c:6415
bool DamageItemAttachments(float damage)
Определения ItemBase.c:6399
override void WriteVarsToCTX(ParamsWriteContext ctx)
Определения ItemBase.c:7805
void ConvertEnergyToQuantity()
Определения ItemBase.c:8446
override void RemoveAllAgents()
Определения ItemBase.c:8785
override void SetQuantityToMinimum()
Определения ItemBase.c:8213
bool m_WantPlayImpactSound
Определения ItemBase.c:4889
override float GetTemperatureThawTime()
Определения ItemBase.c:9550
ref map< int, ref array< ref WeaponParticlesOnOverheating > > m_OnOverheatingEffect
Определения ItemBase.c:4942
int m_ColorComponentG
Определения ItemBase.c:4919
float m_StoreLoadedQuantity
Определения ItemBase.c:4876
void MessageToOwnerAction(string text)
Send message to owner player in yellow color.
Определения ItemBase.c:7560
int m_ColorComponentA
Определения ItemBase.c:4921
int m_VarQuantityInit
Определения ItemBase.c:4871
float GetFilterDamageRatio()
Определения ItemBase.c:5534
override void SetLiquidType(int value, bool allow_client=false)
Определения ItemBase.c:8673
void OnQuantityChanged(float delta)
Called on server side when this item's quantity is changed. Call super.OnQuantityChanged(); first whe...
Определения ItemBase.c:6865
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:8220
bool m_HideSelectionsBySlot
Определения ItemBase.c:4956
bool IsOverheatingEffectActive()
Определения ItemBase.c:5397
void SetIsBeingPlaced(bool is_being_placed)
Определения ItemBase.c:5814
int GetLiquidContainerMask()
Определения ItemBase.c:5751
void SetInventoryLocationToVicinityOrCurrent(EntityAI root, inout InventoryLocation dst)
Определения ItemBase.c:7002
ref Timer m_CheckOverheating
Определения ItemBase.c:4949
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:5445
float GetEnergy()
Определения ItemBase.c:8420
bool CanBeDigged()
Определения ItemBase.c:5830
bool GetActionWidgetOverride(out typename name)
If we need a different (handheld)item action widget displayed, the logic goes in here.
Определения ItemBase.c:9596
bool IsNVG()
Определения ItemBase.c:5762
float GetUnitWeight(bool include_wetness=true)
Obsolete, use GetWeightEx instead.
Определения ItemBase.c:8380
void SetZoneDamageCEInit()
Sets zone damages to match randomized global health set by CE (CE spawn only)
Определения ItemBase.c:9372
bool m_IsDeploySound
Определения ItemBase.c:9675
bool CanEat()
Определения ItemBase.c:7453
static void PlayOverheatingParticles(ItemBase weapon, string ammoType, ItemBase muzzle_owner, ItemBase suppressor, string config_to_search)
Определения ItemBase.c:9079
override bool IsOneHandedBehaviour()
Определения ItemBase.c:9150
void AddLightSourceItem(ItemBase lightsource)
Adds a light source child.
Определения ItemBase.c:9574
bool IsLiquidContainer()
Определения ItemBase.c:5746
FoodStage GetFoodStage()
overridden on Edible_Base; so we don't have to parse configs all the time
Определения ItemBase.c:7473
override float GetSingleInventoryItemWeightEx()
Определения ItemBase.c:8307
void SaveAgents(ParamsWriteContext ctx)
Определения ItemBase.c:8863
override int GetTargetQuantityMax(int attSlotID=-1)
Определения ItemBase.c:8261
int m_CleannessInit
Определения ItemBase.c:4885
float GetDisinfectQuantity(int system=0, Param param1=null)
Определения ItemBase.c:5529
override int GetAgents()
Определения ItemBase.c:8810
int m_VarQuantityMax
Определения ItemBase.c:4873
override bool IsHologram()
Определения ItemBase.c:5825
float GetItemAttachOffset()
Определения ItemBase.c:8589
bool IsPlaceSound()
Определения ItemBase.c:9689
static int GetDebugActionsMask()
Определения ItemBase.c:5615
void ProcessDecay(float delta, bool hasRootAsPlayer)
Определения ItemBase.c:9452
override bool IsItemBase()
Определения ItemBase.c:7606
void PlayDeploySound()
override bool IsTwoHandedBehaviour()
Определения ItemBase.c:9160
void ExplodeAmmo()
Определения ItemBase.c:6302
bool IsCombineAll(ItemBase other_item, bool use_stack_max=false)
Определения ItemBase.c:7078
float GetProtectionLevel(int type, bool consider_filter=false, int system=0)
Определения ItemBase.c:8884
static void PlayBulletCasingEjectParticles(ItemBase weapon, string ammoType, ItemBase muzzle_owner, ItemBase suppressor, string config_to_search)
Определения ItemBase.c:9059
override void OnEnergyAdded()
Определения ItemBase.c:8438
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:5774
EffectSound m_DeployLoopSoundEx
Определения ItemBase.c:9672
override void DeSerializeNumericalVars(array< float > floats)
Определения ItemBase.c:7746
void StopItemDynamicPhysics()
Определения ItemBase.c:9354
bool HasFoodStage()
Определения ItemBase.c:7466
override void SetStoreLoad(bool value)
Определения ItemBase.c:8558
float GetOverheatingValue()
Определения ItemBase.c:5359
bool ContainsAgent(int agent_id)
Определения ItemBase.c:8763
override void AddWet(float value)
Определения ItemBase.c:8506
bool IsLiquidPresent()
Определения ItemBase.c:5741
bool IsFullQuantity()
Определения ItemBase.c:8301
override void EOnContact(IEntity other, Contact extra)
Определения ItemBase.c:6015
void SplitIntoStackMaxHands(PlayerBase player)
Определения ItemBase.c:6770
void SplitIntoStackMaxHandsClient(PlayerBase player)
Определения ItemBase.c:6746
int m_CleannessMax
Определения ItemBase.c:4887
float m_VarStackMax
Определения ItemBase.c:4875
ref Timer m_PhysDropTimer
Определения ItemBase.c:4962
void MessageToOwnerFriendly(string text)
Send message to owner player in green color.
Определения ItemBase.c:7578
override void SetStoreLoadedQuantity(float value)
Определения ItemBase.c:8568
bool m_IsResultOfSplit string m_SoundAttType
distinguish if item has been created as new or it came from splitting (server only flag)
Определения ItemBase.c:4916
void CheckOverheating(ItemBase weapon=null, string ammoType="", ItemBase muzzle_owner=null, ItemBase suppressor=null, string config_to_search="")
Определения ItemBase.c:5380
void UnlockFromParent()
Unlocks this item from its attachment slot of its parent.
Определения ItemBase.c:5695
bool Repair(PlayerBase player, ItemBase item_repair_kit, float specialty_weight)
Определения ItemBase.c:7500
void OnLiquidTypeChanged(int oldType, int newType)
Определения ItemBase.c:8694
void StartOverheating(ItemBase weapon=null, string ammoType="", ItemBase muzzle_owner=null, ItemBase suppressor=null, string config_to_search="")
Определения ItemBase.c:5426
void PlayDeployFinishSound()
bool AllowFoodConsumption()
Определения ItemBase.c:8616
bool m_IsOverheatingEffectActive
Определения ItemBase.c:4947
int m_LiquidContainerMask
Определения ItemBase.c:4897
void ProcessItemWetness(float delta, bool hasParent, bool hasRootAsPlayer, ItemBase refParentIB)
Определения ItemBase.c:9390
override int GetCleanness()
Определения ItemBase.c:8611
bool PairWithDevice(notnull ItemBase otherDevice)
Определения ItemBase.c:9601
bool IsDeploySound()
Определения ItemBase.c:9690
static void RemoveDebugActionsMask(int mask)
Определения ItemBase.c:5635
static void UpdateOverheatingParticles(ItemBase weapon, string ammoType, ItemBase muzzle_owner, ItemBase suppressor, string config_to_search)
Определения ItemBase.c:9099
int m_VarQuantityMin
Определения ItemBase.c:4872
void PerformDamageSystemReinit()
Определения ItemBase.c:9360
override void ClearInventory()
Определения ItemBase.c:8399
static int m_LastRegisteredWeaponID
Определения ItemBase.c:4944
ItemBase GetLightSourceItem()
Определения ItemBase.c:9584
void MessageToOwnerImportant(string text)
Send message to owner player in red color.
Определения ItemBase.c:7596
override float GetItemOverheatThreshold()
Определения ItemBase.c:9534
void StopDeployLoopSoundEx()
bool m_CanThisBeSplit
Определения ItemBase.c:4909
override void SerializeNumericalVars(array< float > floats_out)
Определения ItemBase.c:7710
ItemBase SplitIntoStackMaxToInventoryLocationEx(notnull InventoryLocation dst)
Определения ItemBase.c:6685
float m_ItemModelLength
Определения ItemBase.c:4895
bool m_IsHologram
Определения ItemBase.c:4902
static int m_DebugActionsMask
Определения ItemBase.c:4862
void KillAllOverheatingParticles()
Определения ItemBase.c:5495
bool CanBeCookedOnStick()
Определения ItemBase.c:7483
override int GetQuantityMax()
Определения ItemBase.c:8248
void GetRecipesActions(Man player, out TSelectableActionInfoArray outputList)
Определения ItemBase.c:7156
void OnActivatedByTripWire()
bool IsColorSet()
Определения ItemBase.c:8654
override void RemoveAgent(int agent_id)
Определения ItemBase.c:8776
bool m_ItemBeingDroppedPhys
Определения ItemBase.c:4905
override bool CanPutAsAttachment(EntityAI parent)
Определения ItemBase.c:8966
void PlayDetachSound(string slot_type)
Определения ItemBase.c:9330
static ref map< typename, ref TInputActionMap > m_ItemTypeActionsMap
Определения ItemBase.c:4856
void ProcessItemWetnessAndTemperature(float delta, bool hasParent, bool hasRootAsPlayer, ItemBase refParentIB)
Определения ItemBase.c:9663
override bool IsBeingPlaced()
Определения ItemBase.c:5809
int GetQuantityInit()
Определения ItemBase.c:8285
float ComputeQuantityUsedEx(ItemBase other_item, bool use_stack_max=true)
Определения ItemBase.c:7098
bool IsResultOfSplit()
Определения ItemBase.c:7083
bool m_FixDamageSystemInit
Определения ItemBase.c:4907
float m_ImpactSpeed
Определения ItemBase.c:4891
bool m_IsStoreLoad
Определения ItemBase.c:4910
int GetLiquidTypeInit()
Определения ItemBase.c:8684
string GetDeployFinishSoundset()
ItemBase m_LightSourceItem
Определения ItemBase.c:4925
void LockToParent()
Locks this item in it's current attachment slot of its parent. This makes the "locked" icon visible i...
Определения ItemBase.c:5682
override void SplitIntoStackMaxEx(EntityAI destination_entity, int slot_id)
Определения ItemBase.c:6557
int m_AttachedAgents
Определения ItemBase.c:4933
string m_LockSoundSet
Определения ItemBase.c:4968
void LoadParticleConfigOnOverheating(int id)
Определения ItemBase.c:5303
float m_VarQuantityPrev
Определения ItemBase.c:4870
bool IsSoundSynchRemote()
Определения ItemBase.c:9688
bool m_CanShowQuantity
Определения ItemBase.c:4911
override void OnRightClick()
Определения ItemBase.c:6938
int m_ColorComponentB
Определения ItemBase.c:4920
static ref map< typename, ref TActionAnimOverrideMap > m_ItemActionOverrides
Определения ItemBase.c:4858
bool IsActionTargetVisible()
Определения ItemBase.c:9196
override void OnItemAttachmentSlotChanged(notnull InventoryLocation oldLoc, notnull InventoryLocation newLoc)
Определения ItemBase.c:6050
override void EEHitBy(TotalDamageResult damageResult, int damageType, EntityAI source, int component, string dmgZone, string ammo, vector modelPos, float speedCoef)
Определения ItemBase.c:6339
bool m_IsBeingPlaced
Определения ItemBase.c:4901
int NameToID(string name)
Определения ItemBase.c:7683
void ~ItemBase()
Определения ItemBase.c:5580
override void OnWetLevelChanged(EWetnessLevel newLevel, EWetnessLevel oldLevel)
Определения ItemBase.c:8546
void ClearStopItemSoundServer()
Определения ItemBase.c:9288
override string ChangeIntoOnDetach()
Определения ItemBase.c:6263
float m_VarWetMax
Определения ItemBase.c:4882
void SplitIntoStackMaxToInventoryLocation(notnull InventoryLocation dst)
Определения ItemBase.c:6680
int GetLockType()
Определения ItemBase.c:8624
EffectSound m_SoundDeployFinish
Определения ItemBase.c:9670
override float GetWet()
Определения ItemBase.c:8516
EffectSound m_SoundPlace
Определения ItemBase.c:9671
float GetQuantityNormalizedScripted()
Определения ItemBase.c:8234
override void SetCleanness(int value, bool allow_client=false)
Определения ItemBase.c:8598
bool m_IsPlaceSound
Определения ItemBase.c:9674
override float GetWetMin()
Определения ItemBase.c:8526
ref ItemSoundHandler m_ItemSoundHandler
Определения ItemBase.c:4974
override bool KindOf(string tag)
Определения ItemBase.c:7612
void ItemSoundHandler(ItemBase parent)
Определения ItemSoundHandler.c:31
string Type
Определения JsonDataContaminatedArea.c:11
EffectSound m_LockingSound
Определения Land_Underground_Entrance.c:321
string GetDebugText()
Определения ModifierBase.c:71
PlayerBase GetPlayer()
Определения ModifierBase.c:51
@ LOWEST
Определения PPEConstants.c:54
void PluginItemDiagnostic()
Определения PluginItemDiagnostic.c:74
PluginBase GetPlugin(typename plugin_type)
Определения PluginManager.c:316
EntityAI GetItem()
Определения RadialQuickbarMenu.c:37
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
void Debug()
Определения UniversalTemperatureSource.c:349
int GetID()
Определения ActionBase.c:1360
void OnItemLocationChanged(ItemBase item)
Определения ActionBase.c:998
GetInputType()
Определения ActionBase.c:215
int m_StanceMask
Определения ActionBase.c:25
int m_CommandUIDProne
Определения ActionBase.c:24
int m_CommandUID
Определения ActionBase.c:23
void OnItemAttachedAtPlayer(EntityAI item, string slot_name)
Определения AnalyticsManagerClient.c:77
proto native UIManager GetUIManager()
proto bool ConfigGetChildName(string path, int index, out string name)
Get name of subclass in config class on path.
proto native float ConfigGetFloat(string path)
Get float value from config on path.
override ScriptCallQueue GetCallQueue(int call_category)
Определения DayZGame.c:1187
proto native void GizmoSelectObject(Object object)
proto native bool ConfigIsExisting(string path)
proto native void ConfigGetTextArray(string path, out TStringArray values)
Get array of strings from config on path.
proto native DayZPlayer GetPlayer()
proto native void GizmoSelectPhysics(Physics physics)
proto int GetTime()
returns mission time in milliseconds
proto native int ConfigGetType(string path)
Returns type of config value.
AnalyticsManagerClient GetAnalyticsClient()
Определения Global/game.c:1568
proto native int ConfigGetChildrenCount(string path)
Get count of subclasses in config class on path.
proto native SoundOnVehicle CreateSoundOnObject(Object source, string sound_name, float distance, bool looped, bool create_local=false)
proto native void ObjectDelete(Object obj)
proto native int GetItemCount()
proto native EntityAI GetItem(int index)
float GetEnergyAtSpawn()
Определения ComponentEnergyManager.c:1280
void SetEnergy0To1(float energy01)
Energy manager: Sets stored energy for this device between 0 and MAX based on relative input value be...
Определения ComponentEnergyManager.c:541
float GetEnergyMaxPristine()
Energy manager: Returns the maximum amount of energy this device can store. It's damage is NOT taken ...
Определения ComponentEnergyManager.c:1275
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/Entities/Man.c:44
proto native bool EnumerateInventory(InventoryTraversalType tt, out array< EntityAI > items)
enumerate inventory using traversal type and filling items array
proto native CargoBase GetCargo()
cargo
Определения ItemBase.c:15
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:469
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:29
override bool CanDisplayCargo()
Определения UndergroundStash.c:24
override void OnInventoryEnter(Man player)
Определения BarbedWire.c:203
override string GetFoldSoundset()
Определения BaseBuildingBase.c:108
override bool CanPutAsAttachment(EntityAI parent)
Определения ItemBase.c:6
override bool CanReceiveItemIntoCargo(EntityAI item)
Определения TentBase.c:913
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 void SetActions()
override string GetLoopFoldSoundset()
Определения BaseBuildingBase.c:113
override bool CanMakeGardenplot()
Определения FieldShovel.c:3
override void GetDebugActions(out TSelectableActionInfoArrayEx outputList)
Определения PowerGenerator.c:412
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:424
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 IsClothing()
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
Определения 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 void Remove(func fn)
remove specific call from queue
proto void CallLater(func fn, int delay=0, bool repeat=false, 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)
adds call into the queue with given parameters and arguments (arguments are held in memory until the ...
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:64
proto native float GetDamage(string zoneName, string healthType)
UIScriptedMenu FindMenu(int id)
Returns menu with specific ID if it is open (see MenuID)
Определения UIManager.c:160
override void Refresh()
Определения ChatInputMenu.c:70
void SetCalcDetails(string details)
Определения 3_Game/tools/Debug.c:816
void OnRPC(PlayerIdentity sender, int rpc_type, ParamsReadContext ctx)
Определения WrittenNoteData.c:13
const float LOWEST
Определения EnConvert.c:100
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
proto native CGame GetGame()
Serializer ParamsWriteContext
Определения gameplay.c:16
const int DEF_BIOLOGICAL
Определения 3_Game/constants.c:512
const int DEF_CHEMICAL
Определения 3_Game/constants.c:513
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:709
array< int > TIntArray
Определения EnScript.c:711
EntityEvent
Entity events for event-mask, or throwing event from code.
Определения EnEntity.c:45
static const float ITEM_TEMPERATURE_NEUTRAL_ZONE_MIDDLE
Определения 3_Game/constants.c:808
const int VARIABLE_LIQUIDTYPE
Определения 3_Game/constants.c:632
const int VARIABLE_CLEANNESS
Определения 3_Game/constants.c:635
const int VARIABLE_COLOR
Определения 3_Game/constants.c:634
const int VARIABLE_TEMPERATURE
Определения 3_Game/constants.c:630
const int VARIABLE_QUANTITY
Определения 3_Game/constants.c:628
const int VARIABLE_WET
Определения 3_Game/constants.c:631
const int LIQUID_NONE
Определения 3_Game/constants.c:529
static proto float AbsFloat(float f)
Returns absolute value.
const int MENU_INVENTORY
Определения 3_Game/constants.c:180
proto native bool dBodyIsDynamic(notnull IEntity ent)
const int SAT_CRAFTING
Определения 3_Game/constants.c:453
const int SAT_DEBUG_ACTION
Определения 3_Game/constants.c:454
class JsonUndergroundAreaTriggerData GetPosition
Определения UndergroundAreaLoader.c:9
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/tools/tools.c:10
const int CALL_CATEGORY_SYSTEM
Определения 3_Game/tools/tools.c:8
proto native int GetColor()

Используется в InventoryItem::SetQuantity().