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

◆ SetInventoryLocationToVicinityOrCurrent()

void SpawnItemOnLocation::SetInventoryLocationToVicinityOrCurrent ( EntityAI root,
inout InventoryLocation dst )
protected

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

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