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

◆ EEHealthLevelChanged()

override void SpawnItemOnLocation::EEHealthLevelChanged ( int oldLevel,
int newLevel,
string zone )
protected

drops content of container when ruined in fireplace

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

6981{
6982 override bool CanPutAsAttachment(EntityAI parent)
6983 {
6984 return true;
6985 }
6986};
6987
6989{
6990
6991};
6992
6993//const bool QUANTITY_DEBUG_REMOVE_ME = false;
6994
6995class ItemBase extends InventoryItem
6996{
7000
7002
7003 static int m_DebugActionsMask;
7005 // ============================================
7006 // Variable Manipulation System
7007 // ============================================
7008 // Quantity
7009
7010 float m_VarQuantity;
7011 float m_VarQuantityPrev;//for client to know quantity changed during synchronization
7013 int m_VarQuantityMin;
7014 int m_VarQuantityMax;
7015 int m_Count;
7016 float m_VarStackMax;
7017 float m_StoreLoadedQuantity = float.LOWEST;
7018 // Wet
7019 float m_VarWet;
7020 float m_VarWetPrev;//for client to know wetness changed during synchronization
7021 float m_VarWetInit;
7022 float m_VarWetMin;
7023 float m_VarWetMax;
7024 // Cleanness
7025 int m_Cleanness;
7026 int m_CleannessInit;
7027 int m_CleannessMin;
7028 int m_CleannessMax;
7029 // impact sounds
7031 bool m_CanPlayImpactSound = true;
7032 float m_ImpactSpeed;
7034 //
7035 float m_HeatIsolation;
7036 float m_ItemModelLength;
7037 float m_ItemAttachOffset; // Offset length for when the item is attached e.g. to weapon
7039 int m_VarLiquidType;
7040 int m_ItemBehaviour; // -1 = not specified; 0 = heavy item; 1= onehanded item; 2 = twohanded item
7041 int m_QuickBarBonus;
7042 bool m_IsBeingPlaced;
7043 bool m_IsHologram;
7044 bool m_IsTakeable;
7045 bool m_ThrowItemOnDrop;
7048 bool m_FixDamageSystemInit = false; //can be changed on storage version check
7049 bool can_this_be_combined; //Check if item can be combined
7050 bool m_CanThisBeSplit; //Check if item can be split
7051 bool m_IsStoreLoad = false;
7052 bool m_CanShowQuantity;
7053 bool m_HasQuantityBar;
7054 protected bool m_CanBeDigged;
7055 protected bool m_IsResultOfSplit
7056
7057 string m_SoundAttType;
7058 // items color variables
7063 //-------------------------------------------------------
7064
7065 // light source managing
7067
7071
7072 //==============================================
7073 // agent system
7074 private int m_AttachedAgents;
7075
7077 void TransferModifiers(PlayerBase reciever);
7078
7079
7080 // Weapons & suppressors particle effects
7084 ref static map<string, int> m_WeaponTypeToID;
7085 static int m_LastRegisteredWeaponID = 0;
7086
7087 // Overheating effects
7089 float m_OverheatingShots;
7090 ref Timer m_CheckOverheating;
7091 int m_ShotsToStartOverheating = 0; // After these many shots, the overheating effect begins
7092 int m_MaxOverheatingValue = 0; // Limits the number of shots that will be tracked
7093 float m_OverheatingDecayInterval = 1; // Timer's interval for decrementing overheat effect's lifespan
7094 ref array <ref OverheatingParticle> m_OverheatingParticles;
7095
7097 protected bool m_HideSelectionsBySlot;
7098
7099 // Admin Log
7100 PluginAdminLog m_AdminLog;
7101
7102 // misc
7103 ref Timer m_PhysDropTimer;
7104
7105 // Attachment Locking variables
7106 ref array<int> m_CompatibleLocks;
7107 protected int m_LockType;
7108 protected ref EffectSound m_LockingSound;
7109 protected string m_LockSoundSet;
7110
7111 // ItemSoundHandler variables
7112 protected const int ITEM_SOUNDS_MAX = 63; // optimize network synch
7113 protected int m_SoundSyncPlay; // id for sound to play
7114 protected int m_SoundSyncStop; // id for sound to stop
7115 protected int m_SoundSyncSlotID = InventorySlots.INVALID; // slot id for attach/detach sound based on slot
7116
7118
7119 //temperature
7120 private float m_TemperaturePerQuantityWeight;
7121
7122 // -------------------------------------------------------------------------
7123 void ItemBase()
7124 {
7125 SetEventMask(EntityEvent.INIT); // Enable EOnInit event
7129
7130 if (!g_Game.IsDedicatedServer())
7131 {
7132 if (HasMuzzle())
7133 {
7135
7137 {
7139 }
7140 }
7141
7143 m_ActionsInitialize = false;
7144 }
7145
7146 m_OldLocation = null;
7147
7148 if (g_Game.IsServer())
7149 {
7150 m_AdminLog = PluginAdminLog.Cast(GetPlugin(PluginAdminLog));
7151 }
7152
7153 if (ConfigIsExisting("headSelectionsToHide"))
7154 {
7156 ConfigGetTextArray("headSelectionsToHide",m_HeadHidingSelections);
7157 }
7158
7159 m_HideSelectionsBySlot = false;
7160 if (ConfigIsExisting("hideSelectionsByinventorySlot"))
7161 {
7162 m_HideSelectionsBySlot = ConfigGetBool("hideSelectionsByinventorySlot");
7163 }
7164
7165 m_QuickBarBonus = Math.Max(0, ConfigGetInt("quickBarBonus"));
7166
7167 m_IsResultOfSplit = false;
7168
7170 }
7171
7172 override void InitItemVariables()
7173 {
7174 super.InitItemVariables();
7175
7176 m_VarQuantityInit = ConfigGetInt("varQuantityInit");
7177 m_VarQuantity = m_VarQuantityInit;//should be by the CE, this is just a precaution
7178 m_VarQuantityMin = ConfigGetInt("varQuantityMin");
7179 m_VarQuantityMax = ConfigGetInt("varQuantityMax");
7180 m_VarStackMax = ConfigGetFloat("varStackMax");
7181 m_Count = ConfigGetInt("count");
7182
7183 m_CanShowQuantity = ConfigGetBool("quantityShow");
7184 m_HasQuantityBar = ConfigGetBool("quantityBar");
7185
7186 m_CleannessInit = ConfigGetInt("varCleannessInit");
7188 m_CleannessMin = ConfigGetInt("varCleannessMin");
7189 m_CleannessMax = ConfigGetInt("varCleannessMax");
7190
7191 m_WantPlayImpactSound = false;
7192 m_ImpactSpeed = 0.0;
7193
7194 m_VarWetInit = ConfigGetFloat("varWetInit");
7196 m_VarWetMin = ConfigGetFloat("varWetMin");
7197 m_VarWetMax = ConfigGetFloat("varWetMax");
7198
7199 m_LiquidContainerMask = ConfigGetInt("liquidContainerType");
7200 if (IsLiquidContainer() && GetQuantity() != 0)
7202 m_IsBeingPlaced = false;
7203 m_IsHologram = false;
7204 m_IsTakeable = true;
7205 m_CanBeMovedOverride = false;
7209 m_CanBeDigged = ConfigGetBool("canBeDigged");
7210
7211 m_CompatibleLocks = new array<int>();
7212 ConfigGetIntArray("compatibleLocks", m_CompatibleLocks);
7213 m_LockType = ConfigGetInt("lockType");
7214
7215 //Define if item can be split and set ability to be combined accordingly
7216 m_CanThisBeSplit = false;
7217 can_this_be_combined = false;
7218 if (ConfigIsExisting("canBeSplit"))
7219 {
7220 can_this_be_combined = ConfigGetBool("canBeSplit");
7222 }
7223
7224 m_ItemBehaviour = -1;
7225 if (ConfigIsExisting("itemBehaviour"))
7226 m_ItemBehaviour = ConfigGetInt("itemBehaviour");
7227
7228 //RegisterNetSyncVariableInt("m_VariablesMask");
7229 if (HasQuantity()) RegisterNetSyncVariableFloat("m_VarQuantity", GetQuantityMin(), m_VarQuantityMax);
7230 RegisterNetSyncVariableFloat("m_VarWet", GetWetMin(), GetWetMax(), 2);
7231 RegisterNetSyncVariableInt("m_VarLiquidType");
7232 RegisterNetSyncVariableInt("m_Cleanness",0,1);
7233
7234 RegisterNetSyncVariableBoolSignal("m_WantPlayImpactSound");
7235 RegisterNetSyncVariableFloat("m_ImpactSpeed");
7236 RegisterNetSyncVariableInt("m_ImpactSoundSurfaceHash");
7237
7238 RegisterNetSyncVariableInt("m_ColorComponentR", 0, 255);
7239 RegisterNetSyncVariableInt("m_ColorComponentG", 0, 255);
7240 RegisterNetSyncVariableInt("m_ColorComponentB", 0, 255);
7241 RegisterNetSyncVariableInt("m_ColorComponentA", 0, 255);
7242
7243 RegisterNetSyncVariableBool("m_IsBeingPlaced");
7244 RegisterNetSyncVariableBool("m_IsTakeable");
7245 RegisterNetSyncVariableBool("m_IsHologram");
7246
7249 {
7250 RegisterNetSyncVariableInt("m_SoundSyncPlay", 0, ITEM_SOUNDS_MAX);
7251 RegisterNetSyncVariableInt("m_SoundSyncStop", 0, ITEM_SOUNDS_MAX);
7252 RegisterNetSyncVariableInt("m_SoundSyncSlotID", int.MIN, int.MAX);
7253 }
7254
7255 m_LockSoundSet = ConfigGetString("lockSoundSet");
7256
7258 if (ConfigIsExisting("temperaturePerQuantityWeight"))
7259 m_TemperaturePerQuantityWeight = ConfigGetFloat("temperaturePerQuantityWeight");
7260
7261 m_SoundSyncSlotID = -1;
7262 }
7263
7264 override int GetQuickBarBonus()
7265 {
7266 return m_QuickBarBonus;
7267 }
7268
7269 void InitializeActions()
7270 {
7272 if (!m_InputActionMap)
7273 {
7275 m_InputActionMap = iam;
7276 SetActions();
7278 }
7279 }
7280
7281 override void GetActions(typename action_input_type, out array<ActionBase_Basic> actions)
7282 {
7284 {
7285 m_ActionsInitialize = true;
7287 }
7288
7289 actions = m_InputActionMap.Get(action_input_type);
7290 }
7291
7292 void SetActions()
7293 {
7294 AddAction(ActionTakeItem);
7295 AddAction(ActionTakeItemToHands);
7296 AddAction(ActionWorldCraft);
7298 AddAction(ActionAttachWithSwitch);
7299 }
7300
7301 void SetActionAnimOverrides(); // Override action animation for specific item
7302
7303 void AddAction(typename actionName)
7304 {
7305 ActionBase action = ActionManagerBase.GetAction(actionName);
7306
7307 if (!action)
7308 {
7309 Debug.LogError("Action " + actionName + " dosn't exist!");
7310 return;
7311 }
7312
7313 typename ai = action.GetInputType();
7314 if (!ai)
7315 {
7316 m_ActionsInitialize = false;
7317 return;
7318 }
7319
7320 array<ActionBase_Basic> action_array = m_InputActionMap.Get(ai);
7321 if (!action_array)
7322 {
7323 action_array = new array<ActionBase_Basic>;
7324 m_InputActionMap.Insert(ai, action_array);
7325 }
7326 if (LogManager.IsActionLogEnable())
7327 {
7328 Debug.ActionLog(action.ToString() + " -> " + ai, this.ToString() , "n/a", "Add action");
7329 }
7330
7331 if (action_array.Find(action) != -1)
7332 {
7333 Debug.Log("Action " + action.Type() + " already added to " + this + ", skipping!");
7334 }
7335 else
7336 {
7337 action_array.Insert(action);
7338 }
7339 }
7340
7341 void RemoveAction(typename actionName)
7342 {
7343 PlayerBase player = PlayerBase.Cast(g_Game.GetPlayer());
7344 ActionBase action = player.GetActionManager().GetAction(actionName);
7345 typename ai = action.GetInputType();
7346 array<ActionBase_Basic> action_array = m_InputActionMap.Get(ai);
7347
7348 if (action_array)
7349 {
7350 action_array.RemoveItem(action);
7351 }
7352 }
7353
7354 // Allows override of default action command per item, defined in the SetActionAnimOverrides() of the item's class
7355 // Set -1 for params which should stay in default state
7356 void OverrideActionAnimation(typename action, int commandUID, int stanceMask = -1, int commandUIDProne = -1)
7357 {
7358 ActionOverrideData overrideData = new ActionOverrideData();
7359 overrideData.m_CommandUID = commandUID;
7360 overrideData.m_CommandUIDProne = commandUIDProne;
7361 overrideData.m_StanceMask = stanceMask;
7362
7363 TActionAnimOverrideMap actionMap = m_ItemActionOverrides.Get(action);
7364 if (!actionMap) // create new map of action > overidables map
7365 {
7366 actionMap = new TActionAnimOverrideMap();
7367 m_ItemActionOverrides.Insert(action, actionMap);
7368 }
7369
7370 actionMap.Insert(this.Type(), overrideData); // insert item -> overrides
7371
7372 }
7373
7374 void OnItemInHandsPlayerSwimStart(PlayerBase player);
7375
7376 ScriptedLightBase GetLight();
7377
7378 // Loads muzzle flash particle configuration from config and saves it to a map for faster access
7379 void LoadParticleConfigOnFire(int id)
7380 {
7381 if (!m_OnFireEffect)
7383
7386
7387 string config_to_search = "CfgVehicles";
7388 string muzzle_owner_config;
7389
7390 if (!m_OnFireEffect.Contains(id))
7391 {
7392 if (IsInherited(Weapon))
7393 config_to_search = "CfgWeapons";
7394
7395 muzzle_owner_config = config_to_search + " " + GetType() + " ";
7396
7397 string config_OnFire_class = muzzle_owner_config + "Particles " + "OnFire ";
7398
7399 int config_OnFire_subclass_count = g_Game.ConfigGetChildrenCount(config_OnFire_class);
7400
7401 if (config_OnFire_subclass_count > 0)
7402 {
7403 array<ref WeaponParticlesOnFire> WPOF_array = new array<ref WeaponParticlesOnFire>;
7404
7405 for (int i = 0; i < config_OnFire_subclass_count; i++)
7406 {
7407 string particle_class = "";
7408 g_Game.ConfigGetChildName(config_OnFire_class, i, particle_class);
7409 string config_OnFire_entry = config_OnFire_class + particle_class;
7410 WeaponParticlesOnFire WPOF = new WeaponParticlesOnFire(this, config_OnFire_entry);
7411 WPOF_array.Insert(WPOF);
7412 }
7413
7414
7415 m_OnFireEffect.Insert(id, WPOF_array);
7416 }
7417 }
7418
7419 if (!m_OnBulletCasingEjectEffect.Contains(id))
7420 {
7421 config_to_search = "CfgWeapons"; // Bullet Eject efect is supported on weapons only.
7422 muzzle_owner_config = config_to_search + " " + GetType() + " ";
7423
7424 string config_OnBulletCasingEject_class = muzzle_owner_config + "Particles " + "OnBulletCasingEject ";
7425
7426 int config_OnBulletCasingEject_count = g_Game.ConfigGetChildrenCount(config_OnBulletCasingEject_class);
7427
7428 if (config_OnBulletCasingEject_count > 0 && IsInherited(Weapon))
7429 {
7430 array<ref WeaponParticlesOnBulletCasingEject> WPOBE_array = new array<ref WeaponParticlesOnBulletCasingEject>;
7431
7432 for (i = 0; i < config_OnBulletCasingEject_count; i++)
7433 {
7434 string particle_class2 = "";
7435 g_Game.ConfigGetChildName(config_OnBulletCasingEject_class, i, particle_class2);
7436 string config_OnBulletCasingEject_entry = config_OnBulletCasingEject_class + particle_class2;
7437 WeaponParticlesOnBulletCasingEject WPOBE = new WeaponParticlesOnBulletCasingEject(this, config_OnBulletCasingEject_entry);
7438 WPOBE_array.Insert(WPOBE);
7439 }
7440
7441
7442 m_OnBulletCasingEjectEffect.Insert(id, WPOBE_array);
7443 }
7444 }
7445 }
7446
7447 // Loads muzzle flash particle configuration from config and saves it to a map for faster access
7449 {
7452
7453 if (!m_OnOverheatingEffect.Contains(id))
7454 {
7455 string config_to_search = "CfgVehicles";
7456
7457 if (IsInherited(Weapon))
7458 config_to_search = "CfgWeapons";
7459
7460 string muzzle_owner_config = config_to_search + " " + GetType() + " ";
7461 string config_OnOverheating_class = muzzle_owner_config + "Particles " + "OnOverheating ";
7462
7463 if (g_Game.ConfigIsExisting(config_OnOverheating_class))
7464 {
7465
7466 m_ShotsToStartOverheating = g_Game.ConfigGetFloat(config_OnOverheating_class + "shotsToStartOverheating");
7467
7469 {
7470 m_ShotsToStartOverheating = -1; // This prevents futher readings from config for future creations of this item
7471 string error = "Error reading config " + GetType() + ">Particles>OnOverheating - Parameter shotsToStartOverheating is configured wrong or is missing! Its value must be 1 or higher!";
7472 Error(error);
7473 return;
7474 }
7475
7476 m_OverheatingDecayInterval = g_Game.ConfigGetFloat(config_OnOverheating_class + "overheatingDecayInterval");
7477 m_MaxOverheatingValue = g_Game.ConfigGetFloat(config_OnOverheating_class + "maxOverheatingValue");
7478
7479
7480
7481 int config_OnOverheating_subclass_count = g_Game.ConfigGetChildrenCount(config_OnOverheating_class);
7482 array<ref WeaponParticlesOnOverheating> WPOOH_array = new array<ref WeaponParticlesOnOverheating>;
7483
7484 for (int i = 0; i < config_OnOverheating_subclass_count; i++)
7485 {
7486 string particle_class = "";
7487 g_Game.ConfigGetChildName(config_OnOverheating_class, i, particle_class);
7488 string config_OnOverheating_entry = config_OnOverheating_class + particle_class;
7489 int entry_type = g_Game.ConfigGetType(config_OnOverheating_entry);
7490
7491 if (entry_type == CT_CLASS)
7492 {
7493 WeaponParticlesOnOverheating WPOF = new WeaponParticlesOnOverheating(this, config_OnOverheating_entry);
7494 WPOOH_array.Insert(WPOF);
7495 }
7496 }
7497
7498
7499 m_OnOverheatingEffect.Insert(id, WPOOH_array);
7500 }
7501 }
7502 }
7503
7504 float GetOverheatingValue()
7505 {
7506 return m_OverheatingShots;
7507 }
7508
7509 void IncreaseOverheating(ItemBase weapon, string ammoType, ItemBase muzzle_owner, ItemBase suppressor, string config_to_search)
7510 {
7511 if (m_MaxOverheatingValue > 0)
7512 {
7514
7515 if (!m_CheckOverheating)
7517
7519 m_CheckOverheating.Run(m_OverheatingDecayInterval, this, "OnOverheatingDecay");
7520
7521 CheckOverheating(weapon, ammoType, muzzle_owner, suppressor, config_to_search);
7522 }
7523 }
7524
7525 void CheckOverheating(ItemBase weapon = null, string ammoType = "", ItemBase muzzle_owner = null, ItemBase suppressor = null, string config_to_search = "")
7526 {
7528 UpdateOverheating(weapon, ammoType, muzzle_owner, suppressor, config_to_search);
7529
7531 StartOverheating(weapon, ammoType, muzzle_owner, suppressor, config_to_search);
7532
7534 StopOverheating(weapon, ammoType, muzzle_owner, suppressor, config_to_search);
7535
7537 {
7539 }
7540 }
7541
7543 {
7545 }
7546
7547 void OnOverheatingDecay()
7548 {
7549 if (m_MaxOverheatingValue > 0)
7550 m_OverheatingShots -= 1 + m_OverheatingShots / m_MaxOverheatingValue; // The hotter a barrel is, the faster it needs to cool down.
7551 else
7553
7554 if (m_OverheatingShots <= 0)
7555 {
7558 }
7559 else
7560 {
7561 if (!m_CheckOverheating)
7563
7565 m_CheckOverheating.Run(m_OverheatingDecayInterval, this, "OnOverheatingDecay");
7566 }
7567
7568 CheckOverheating(this, "", this);
7569 }
7570
7571 void StartOverheating(ItemBase weapon = null, string ammoType = "", ItemBase muzzle_owner = null, ItemBase suppressor = null, string config_to_search = "")
7572 {
7574 ItemBase.PlayOverheatingParticles(this, ammoType, this, suppressor, "CfgWeapons");
7575 }
7576
7577 void UpdateOverheating(ItemBase weapon = null, string ammoType = "", ItemBase muzzle_owner = null, ItemBase suppressor = null, string config_to_search = "")
7578 {
7580 ItemBase.UpdateOverheatingParticles(this, ammoType, this, suppressor, "CfgWeapons");
7582 }
7583
7584 void StopOverheating(ItemBase weapon = null, string ammoType = "", ItemBase muzzle_owner = null, ItemBase suppressor = null, string config_to_search = "")
7585 {
7587 ItemBase.StopOverheatingParticles(weapon, ammoType, muzzle_owner, suppressor, config_to_search);
7588 }
7589
7590 void RegisterOverheatingParticle(Particle p, float min_heat_coef, float max_heat_coef, int particle_id, Object parent, vector local_pos, vector local_ori)
7591 {
7593 m_OverheatingParticles = new array<ref OverheatingParticle>;
7594
7595 OverheatingParticle OP = new OverheatingParticle();
7596 OP.RegisterParticle(p);
7597 OP.SetOverheatingLimitMin(min_heat_coef);
7598 OP.SetOverheatingLimitMax(max_heat_coef);
7599 OP.SetParticleParams(particle_id, parent, local_pos, local_ori);
7600
7601 m_OverheatingParticles.Insert(OP);
7602 }
7603
7604 float GetOverheatingCoef()
7605 {
7606 if (m_MaxOverheatingValue > 0)
7608
7609 return -1;
7610 }
7611
7613 {
7615 {
7616 float overheat_coef = GetOverheatingCoef();
7617 int count = m_OverheatingParticles.Count();
7618
7619 for (int i = count; i > 0; --i)
7620 {
7621 int id = i - 1;
7622 OverheatingParticle OP = m_OverheatingParticles.Get(id);
7623 Particle p = OP.GetParticle();
7624
7625 float overheat_min = OP.GetOverheatingLimitMin();
7626 float overheat_max = OP.GetOverheatingLimitMax();
7627
7628 if (overheat_coef < overheat_min && overheat_coef >= overheat_max)
7629 {
7630 if (p)
7631 {
7632 p.Stop();
7633 OP.RegisterParticle(null);
7634 }
7635 }
7636 }
7637 }
7638 }
7639
7641 {
7643 {
7644 for (int i = m_OverheatingParticles.Count(); i > 0; i--)
7645 {
7646 int id = i - 1;
7647 OverheatingParticle OP = m_OverheatingParticles.Get(id);
7648
7649 if (OP)
7650 {
7651 Particle p = OP.GetParticle();
7652
7653 if (p)
7654 {
7655 p.Stop();
7656 }
7657
7658 delete OP;
7659 }
7660 }
7661
7662 m_OverheatingParticles.Clear();
7664 }
7665 }
7666
7668 float GetInfectionChance(int system = 0, Param param = null)
7669 {
7670 return 0.0;
7671 }
7672
7673
7674 float GetDisinfectQuantity(int system = 0, Param param1 = null)
7675 {
7676 return 250;//default value
7677 }
7678
7679 float GetFilterDamageRatio()
7680 {
7681 return 0;
7682 }
7683
7685 bool HasMuzzle()
7686 {
7687 if (IsInherited(Weapon) || IsInherited(SuppressorBase))
7688 return true;
7689
7690 return false;
7691 }
7692
7694 int GetMuzzleID()
7695 {
7696 if (!m_WeaponTypeToID)
7697 m_WeaponTypeToID = new map<string, int>;
7698
7699 if (m_WeaponTypeToID.Contains(GetType()))
7700 {
7701 return m_WeaponTypeToID.Get(GetType());
7702 }
7703 else
7704 {
7705 // Register new weapon ID
7707 }
7708
7710 }
7711
7718 {
7719 return -1;
7720 }
7721
7722
7723
7724 // -------------------------------------------------------------------------
7725 void ~ItemBase()
7726 {
7727 if (g_Game && g_Game.GetPlayer() && (!g_Game.IsDedicatedServer()))
7728 {
7729 PlayerBase player = PlayerBase.Cast(g_Game.GetPlayer());
7730 int r_index = player.GetHumanInventory().FindUserReservedLocationIndex(this);
7731
7732 if (r_index >= 0)
7733 {
7734 InventoryLocation r_il = new InventoryLocation;
7735 player.GetHumanInventory().GetUserReservedLocation(r_index,r_il);
7736
7737 player.GetHumanInventory().ClearUserReservedLocationAtIndex(r_index);
7738 int r_type = r_il.GetType();
7739 if (r_type == InventoryLocationType.CARGO || r_type == InventoryLocationType.PROXYCARGO)
7740 {
7741 r_il.GetParent().GetOnReleaseLock().Invoke(this);
7742 }
7743 else if (r_type == InventoryLocationType.ATTACHMENT)
7744 {
7745 r_il.GetParent().GetOnAttachmentReleaseLock().Invoke(this, r_il.GetSlot());
7746 }
7747
7748 }
7749
7750 player.GetHumanInventory().ClearUserReservedLocation(this);
7751 }
7752
7753 if (m_LockingSound)
7754 SEffectManager.DestroyEffect(m_LockingSound);
7755 }
7756
7757
7758
7759 // -------------------------------------------------------------------------
7760 static int GetDebugActionsMask()
7761 {
7762 return ItemBase.m_DebugActionsMask;
7763 }
7764
7765 static bool HasDebugActionsMask(int mask)
7766 {
7767 return ItemBase.m_DebugActionsMask & mask;
7768 }
7769
7770 static void SetDebugActionsMask(int mask)
7771 {
7772 ItemBase.m_DebugActionsMask = mask;
7773 }
7774
7775 static void AddDebugActionsMask(int mask)
7776 {
7777 ItemBase.m_DebugActionsMask |= mask;
7778 }
7779
7780 static void RemoveDebugActionsMask(int mask)
7781 {
7782 ItemBase.m_DebugActionsMask &= ~mask;
7783 }
7784
7785 static void ToggleDebugActionsMask(int mask)
7786 {
7787 if (HasDebugActionsMask(mask))
7788 {
7790 }
7791 else
7792 {
7793 AddDebugActionsMask(mask);
7794 }
7795 }
7796
7797 // -------------------------------------------------------------------------
7798 void SetCEBasedQuantity()
7799 {
7800 if (GetEconomyProfile())
7801 {
7802 float q_max = GetEconomyProfile().GetQuantityMax();
7803 if (q_max > 0)
7804 {
7805 float q_min = GetEconomyProfile().GetQuantityMin();
7806 float quantity_randomized = Math.RandomFloatInclusive(q_min, q_max);
7807
7808 if (HasComponent(COMP_TYPE_ENERGY_MANAGER))//more direct access for speed
7809 {
7810 ComponentEnergyManager comp = GetCompEM();
7811 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
7812 {
7813 comp.SetEnergy0To1(quantity_randomized);
7814 }
7815 }
7816 else if (HasQuantity())
7817 {
7818 SetQuantityNormalized(quantity_randomized, false);
7819 //PrintString("<==> Normalized quantity for item: "+ GetType()+", qmin:"+q_min.ToString()+"; qmax:"+q_max.ToString()+";quantity:" +quantity_randomized.ToString());
7820 }
7821
7822 }
7823 }
7824 }
7825
7827 void LockToParent()
7828 {
7829 EntityAI parent = GetHierarchyParent();
7830
7831 if (parent)
7832 {
7833 InventoryLocation inventory_location_to_lock = new InventoryLocation;
7834 GetInventory().GetCurrentInventoryLocation(inventory_location_to_lock);
7835 parent.GetInventory().SetSlotLock(inventory_location_to_lock.GetSlot(), true);
7836 }
7837 }
7838
7840 void UnlockFromParent()
7841 {
7842 EntityAI parent = GetHierarchyParent();
7843
7844 if (parent)
7845 {
7846 InventoryLocation inventory_location_to_unlock = new InventoryLocation;
7847 GetInventory().GetCurrentInventoryLocation(inventory_location_to_unlock);
7848 parent.GetInventory().SetSlotLock(inventory_location_to_unlock.GetSlot(), false);
7849 }
7850 }
7851
7852 override void CombineItemsClient(EntityAI entity2, bool use_stack_max = true)
7853 {
7854 /*
7855 ref Param1<EntityAI> item = new Param1<EntityAI>(entity2);
7856 RPCSingleParam(ERPCs.RPC_ITEM_COMBINE, item, g_Game.GetPlayer());
7857 */
7858 ItemBase item2 = ItemBase.Cast(entity2);
7859
7860 if (g_Game.IsClient())
7861 {
7862 if (ScriptInputUserData.CanStoreInputUserData())
7863 {
7864 ScriptInputUserData ctx = new ScriptInputUserData;
7866 ctx.Write(-1);
7867 ItemBase i1 = this; // @NOTE: workaround for correct serialization
7868 ctx.Write(i1);
7869 ctx.Write(item2);
7870 ctx.Write(use_stack_max);
7871 ctx.Write(-1);
7872 ctx.Send();
7873
7874 if (IsCombineAll(item2, use_stack_max))
7875 {
7876 g_Game.GetPlayer().GetInventory().AddInventoryReservationEx(item2,null,GameInventory.c_InventoryReservationTimeoutShortMS);
7877 }
7878 }
7879 }
7880 else if (!g_Game.IsMultiplayer())
7881 {
7882 CombineItems(item2, use_stack_max);
7883 }
7884 }
7885
7886 bool IsLiquidPresent()
7887 {
7888 return (GetLiquidType() != 0 && HasQuantity());
7889 }
7890
7891 bool IsLiquidContainer()
7892 {
7893 return m_LiquidContainerMask != 0;
7894 }
7895
7897 {
7898 return m_LiquidContainerMask;
7899 }
7900
7901 bool IsBloodContainer()
7902 {
7903 //m_LiquidContainerMask & GROUP_LIQUID_BLOOD ???
7904 return false;
7905 }
7906
7907 bool IsNVG()
7908 {
7909 return false;
7910 }
7911
7914 bool IsExplosive()
7915 {
7916 return false;
7917 }
7918
7920 {
7921 return "";
7922 }
7923
7925
7926 bool IsLightSource()
7927 {
7928 return false;
7929 }
7930
7932 {
7933 return true;
7934 }
7935
7936 //--- ACTION CONDITIONS
7937 //direction
7938 bool IsFacingPlayer(PlayerBase player, string selection)
7939 {
7940 return true;
7941 }
7942
7943 bool IsPlayerInside(PlayerBase player, string selection)
7944 {
7945 return true;
7946 }
7947
7948 override bool CanObstruct()
7949 {
7950 PlayerBase player = PlayerBase.Cast(g_Game.GetPlayer());
7951 return !player || !IsPlayerInside(player, "");
7952 }
7953
7954 override bool IsBeingPlaced()
7955 {
7956 return m_IsBeingPlaced;
7957 }
7958
7959 void SetIsBeingPlaced(bool is_being_placed)
7960 {
7961 m_IsBeingPlaced = is_being_placed;
7962 if (!is_being_placed)
7964 SetSynchDirty();
7965 }
7966
7967 //server-side
7968 void OnEndPlacement() {}
7969
7970 override bool IsHologram()
7971 {
7972 return m_IsHologram;
7973 }
7974
7975 bool CanBeDigged()
7976 {
7977 return m_CanBeDigged;
7978 }
7979
7981 {
7982 return 1;
7983 }
7984
7985 bool CanMakeGardenplot()
7986 {
7987 return false;
7988 }
7989
7990 void SetIsHologram(bool is_hologram)
7991 {
7992 m_IsHologram = is_hologram;
7993 SetSynchDirty();
7994 }
7995 /*
7996 protected float GetNutritionalEnergy()
7997 {
7998 Edible_Base edible = Edible_Base.Cast(this);
7999 return edible.GetFoodEnergy();
8000 }
8001
8002 protected float GetNutritionalWaterContent()
8003 {
8004 Edible_Base edible = Edible_Base.Cast(this);
8005 return edible.GetFoodWater();
8006 }
8007
8008 protected float GetNutritionalIndex()
8009 {
8010 Edible_Base edible = Edible_Base.Cast(this);
8011 return edible.GetFoodNutritionalIndex();
8012 }
8013
8014 protected float GetNutritionalFullnessIndex()
8015 {
8016 Edible_Base edible = Edible_Base.Cast(this);
8017 return edible.GetFoodTotalVolume();
8018 }
8019
8020 protected float GetNutritionalToxicity()
8021 {
8022 Edible_Base edible = Edible_Base.Cast(this);
8023 return edible.GetFoodToxicity();
8024
8025 }
8026 */
8027
8028
8029 // -------------------------------------------------------------------------
8030 override void OnMovedInsideCargo(EntityAI container)
8031 {
8032 super.OnMovedInsideCargo(container);
8033
8034 MiscGameplayFunctions.RemoveAllAttachedChildrenByTypename(this, {Bolt_Base});
8035 }
8036
8037 override void EEItemLocationChanged(notnull InventoryLocation oldLoc, notnull InventoryLocation newLoc)
8038 {
8039 super.EEItemLocationChanged(oldLoc, newLoc);
8040
8041 PlayerBase newPlayer = null;
8042 PlayerBase oldPlayer = null;
8043
8044 if (newLoc.GetParent())
8045 newPlayer = PlayerBase.Cast(newLoc.GetParent().GetHierarchyRootPlayer());
8046
8047 if (oldLoc.GetParent())
8048 oldPlayer = PlayerBase.Cast(oldLoc.GetParent().GetHierarchyRootPlayer());
8049
8050 if (oldPlayer && oldLoc.GetType() == InventoryLocationType.HANDS)
8051 {
8052 int rIndex = oldPlayer.GetHumanInventory().FindUserReservedLocationIndex(this);
8053
8054 if (rIndex >= 0)
8055 {
8056 InventoryLocation rIl = new InventoryLocation;
8057 oldPlayer.GetHumanInventory().GetUserReservedLocation(rIndex, rIl);
8058
8059 oldPlayer.GetHumanInventory().ClearUserReservedLocationAtIndex(rIndex);
8060 int rType = rIl.GetType();
8061 if (rType == InventoryLocationType.CARGO || rType == InventoryLocationType.PROXYCARGO)
8062 {
8063 rIl.GetParent().GetOnReleaseLock().Invoke(this);
8064 }
8065 else if (rType == InventoryLocationType.ATTACHMENT)
8066 {
8067 rIl.GetParent().GetOnAttachmentReleaseLock().Invoke(this, rIl.GetSlot());
8068 }
8069
8070 }
8071 }
8072
8073 if (newLoc.GetType() == InventoryLocationType.HANDS && oldLoc.GetType() != InventoryLocationType.TEMP)
8074 {
8075 if (newPlayer)
8076 newPlayer.ForceStandUpForHeavyItems(newLoc.GetItem());
8077
8078 if (newPlayer == oldPlayer)
8079 {
8080 if (oldLoc.GetParent() && newPlayer.GetHumanInventory().LocationGetEntity(oldLoc) == NULL)
8081 {
8082 if (oldLoc.GetType() == InventoryLocationType.CARGO)
8083 {
8084 if (oldLoc.GetParent().GetInventory().TestAddEntityInCargoExLoc(oldLoc, false, false, false, true, false, false))
8085 {
8086 newPlayer.GetHumanInventory().SetUserReservedLocation(this,oldLoc);
8087 }
8088 }
8089 else
8090 {
8091 newPlayer.GetHumanInventory().SetUserReservedLocation(this,oldLoc);
8092 }
8093 }
8094
8095 if (newPlayer.GetHumanInventory().FindUserReservedLocationIndex(this) >= 0)
8096 {
8097 int type = oldLoc.GetType();
8098 if (type == InventoryLocationType.CARGO || type == InventoryLocationType.PROXYCARGO)
8099 {
8100 oldLoc.GetParent().GetOnSetLock().Invoke(this);
8101 }
8102 else if (type == InventoryLocationType.ATTACHMENT)
8103 {
8104 oldLoc.GetParent().GetOnAttachmentSetLock().Invoke(this, oldLoc.GetSlot());
8105 }
8106 }
8107 if (!m_OldLocation)
8108 {
8109 m_OldLocation = new InventoryLocation;
8110 }
8111 m_OldLocation.Copy(oldLoc);
8112 }
8113 else
8114 {
8115 if (m_OldLocation)
8116 {
8117 m_OldLocation.Reset();
8118 }
8119 }
8120
8121 g_Game.GetAnalyticsClient().OnItemAttachedAtPlayer(this,"Hands");
8122 }
8123 else
8124 {
8125 if (newPlayer)
8126 {
8127 int resIndex = newPlayer.GetHumanInventory().FindCollidingUserReservedLocationIndex(this, newLoc);
8128 if (resIndex >= 0)
8129 {
8130 InventoryLocation il = new InventoryLocation;
8131 newPlayer.GetHumanInventory().GetUserReservedLocation(resIndex, il);
8132 ItemBase it = ItemBase.Cast(il.GetItem());
8133 newPlayer.GetHumanInventory().ClearUserReservedLocationAtIndex(resIndex);
8134 int rel_type = il.GetType();
8135 if (rel_type == InventoryLocationType.CARGO || rel_type == InventoryLocationType.PROXYCARGO)
8136 {
8137 il.GetParent().GetOnReleaseLock().Invoke(it);
8138 }
8139 else if (rel_type == InventoryLocationType.ATTACHMENT)
8140 {
8141 il.GetParent().GetOnAttachmentReleaseLock().Invoke(it, il.GetSlot());
8142 }
8143 //it.GetOnReleaseLock().Invoke(it);
8144 }
8145 }
8146 else if (oldPlayer && newLoc.GetType() == InventoryLocationType.GROUND && m_ThrowItemOnDrop)
8147 {
8148 //ThrowPhysically(oldPlayer, vector.Zero);
8149 m_ThrowItemOnDrop = false;
8150 }
8151
8152 if (m_OldLocation)
8153 {
8154 m_OldLocation.Reset();
8155 }
8156 }
8157
8158 if (oldLoc.GetType() == InventoryLocationType.TEMP)
8159 {
8160 PluginInventoryRepair.Cast(GetPlugin(PluginInventoryRepair)).Remove(oldLoc.GetItem());
8161 }
8162
8163 if (newLoc.GetType() == InventoryLocationType.TEMP)
8164 {
8165 PluginInventoryRepair.Cast(GetPlugin(PluginInventoryRepair)).Add(oldLoc.GetItem());
8166 }
8167 }
8168
8169 override void EOnContact(IEntity other, Contact extra)
8170 {
8172 {
8173 int liquidType = -1;
8174 float impactSpeed = ProcessImpactSoundEx(other, extra, m_ConfigWeight, m_ImpactSoundSurfaceHash, liquidType);
8175 if (impactSpeed > 0.0)
8176 {
8177 m_ImpactSpeed = impactSpeed;
8178 #ifndef SERVER
8179 PlayImpactSound(m_ConfigWeight, m_ImpactSpeed, m_ImpactSoundSurfaceHash);
8180 #else
8181 m_WantPlayImpactSound = true;
8182 SetSynchDirty();
8183 #endif
8184 m_CanPlayImpactSound = (liquidType == -1);// prevents further playing of the sound when the surface is a liquid type
8185 }
8186 }
8187
8188 #ifdef SERVER
8189 if (GetCompEM() && GetCompEM().IsPlugged())
8190 {
8191 if (GetCompEM().GetCordLength() < vector.Distance(GetPosition(), GetCompEM().GetEnergySource().GetPosition()))
8192 GetCompEM().UnplugThis();
8193 }
8194 #endif
8195 }
8196
8197 void RefreshPhysics();
8198
8199 override void OnCreatePhysics()
8200 {
8202 }
8203
8204 override void OnItemAttachmentSlotChanged(notnull InventoryLocation oldLoc, notnull InventoryLocation newLoc)
8205 {
8206
8207 }
8208 // -------------------------------------------------------------------------
8209 override void OnItemLocationChanged(EntityAI old_owner, EntityAI new_owner)
8210 {
8211 super.OnItemLocationChanged(old_owner, new_owner);
8212
8213 PlayerBase relatedPlayer = PlayerBase.Cast(old_owner);
8214 PlayerBase playerNew = PlayerBase.Cast(new_owner);
8215
8216 if (!relatedPlayer && playerNew)
8217 relatedPlayer = playerNew;
8218
8219 if (relatedPlayer && relatedPlayer.GetPerformedActionID() != -1)
8220 {
8221 ActionManagerBase actionMgr = relatedPlayer.GetActionManager();
8222 if (actionMgr)
8223 {
8224 ActionBase currentAction = actionMgr.GetRunningAction();
8225 if (currentAction)
8226 currentAction.OnItemLocationChanged(this);
8227 }
8228 }
8229
8230 Man ownerPlayerOld = null;
8231 Man ownerPlayerNew = null;
8232
8233 if (old_owner)
8234 {
8235 if (old_owner.IsMan())
8236 {
8237 ownerPlayerOld = Man.Cast(old_owner);
8238 }
8239 else
8240 {
8241 ownerPlayerOld = Man.Cast(old_owner.GetHierarchyRootPlayer());
8242 }
8243 }
8244 else
8245 {
8246 if (new_owner && IsElectricAppliance() && GetCompEM() && GetCompEM().IsPlugged())
8247 {
8248 ActionBase action = ActionManagerBase.GetAction(ActionRepositionPluggedItem);
8249
8250 if (!action || !playerNew || playerNew.GetPerformedActionID() != action.GetID())
8251 {
8252 GetCompEM().UnplugThis();
8253 }
8254 }
8255 }
8256
8257 if (new_owner)
8258 {
8259 if (new_owner.IsMan())
8260 {
8261 ownerPlayerNew = Man.Cast(new_owner);
8262 }
8263 else
8264 {
8265 ownerPlayerNew = Man.Cast(new_owner.GetHierarchyRootPlayer());
8266 }
8267 }
8268
8269 if (ownerPlayerOld != ownerPlayerNew)
8270 {
8271 if (ownerPlayerOld)
8272 {
8273 array<EntityAI> subItemsExit = new array<EntityAI>;
8274 GetInventory().EnumerateInventory(InventoryTraversalType.PREORDER,subItemsExit);
8275 for (int i = 0; i < subItemsExit.Count(); i++)
8276 {
8277 ItemBase itemExit = ItemBase.Cast(subItemsExit.Get(i));
8278 itemExit.OnInventoryExit(ownerPlayerOld);
8279 }
8280 }
8281
8282 if (ownerPlayerNew)
8283 {
8284 array<EntityAI> subItemsEnter = new array<EntityAI>;
8285 GetInventory().EnumerateInventory(InventoryTraversalType.PREORDER,subItemsEnter);
8286 for (int j = 0; j < subItemsEnter.Count(); j++)
8287 {
8288 ItemBase itemEnter = ItemBase.Cast(subItemsEnter.Get(j));
8289 itemEnter.OnInventoryEnter(ownerPlayerNew);
8290 }
8291 }
8292 }
8293 else if (ownerPlayerNew != null)
8294 {
8295 PlayerBase nplayer;
8296 if (PlayerBase.CastTo(nplayer, ownerPlayerNew))
8297 {
8298 array<EntityAI> subItemsUpdate = new array<EntityAI>;
8299 GetInventory().EnumerateInventory(InventoryTraversalType.PREORDER,subItemsUpdate);
8300 for (int k = 0; k < subItemsUpdate.Count(); k++)
8301 {
8302 ItemBase itemUpdate = ItemBase.Cast(subItemsUpdate.Get(k));
8303 itemUpdate.UpdateQuickbarShortcutVisibility(nplayer);
8304 }
8305 }
8306 }
8307
8308 if (old_owner)
8309 old_owner.OnChildItemRemoved(this);
8310 if (new_owner)
8311 new_owner.OnChildItemReceived(this);
8312 }
8313
8314 // -------------------------------------------------------------------------------
8315 override void EEDelete(EntityAI parent)
8316 {
8317 super.EEDelete(parent);
8318 PlayerBase player = PlayerBase.Cast(GetHierarchyRootPlayer());
8319 if (player)
8320 {
8321 OnInventoryExit(player);
8322
8323 if (player.IsAlive())
8324 {
8325 int r_index = player.GetHumanInventory().FindUserReservedLocationIndex(this);
8326 if (r_index >= 0)
8327 {
8328 InventoryLocation r_il = new InventoryLocation;
8329 player.GetHumanInventory().GetUserReservedLocation(r_index,r_il);
8330
8331 player.GetHumanInventory().ClearUserReservedLocationAtIndex(r_index);
8332 int r_type = r_il.GetType();
8333 if (r_type == InventoryLocationType.CARGO || r_type == InventoryLocationType.PROXYCARGO)
8334 {
8335 r_il.GetParent().GetOnReleaseLock().Invoke(this);
8336 }
8337 else if (r_type == InventoryLocationType.ATTACHMENT)
8338 {
8339 r_il.GetParent().GetOnAttachmentReleaseLock().Invoke(this, r_il.GetSlot());
8340 }
8341
8342 }
8343
8344 player.RemoveQuickBarEntityShortcut(this);
8345 }
8346 }
8347 }
8348 // -------------------------------------------------------------------------------
8349 override void EEKilled(Object killer)
8350 {
8351 super.EEKilled(killer);
8352
8354 if (killer && killer.IsFireplace() && CanExplodeInFire())
8355 {
8356 if (GetTemperature() >= GameConstants.ITEM_TEMPERATURE_TO_EXPLODE_MIN)
8357 {
8358 if (IsMagazine())
8359 {
8360 if (Magazine.Cast(this).GetAmmoCount() > 0)
8361 {
8362 ExplodeAmmo();
8363 }
8364 }
8365 else
8366 {
8367 Explode(DamageType.EXPLOSION);
8368 }
8369 }
8370 }
8371 }
8372
8373 override void OnWasAttached(EntityAI parent, int slot_id)
8374 {
8375 MiscGameplayFunctions.RemoveAllAttachedChildrenByTypename(this, {Bolt_Base});
8376
8377 super.OnWasAttached(parent, slot_id);
8378
8379 if (HasQuantity())
8380 UpdateNetSyncVariableFloat("m_VarQuantity", GetQuantityMin(), m_VarQuantityMax);
8381
8382 if (g_Game.IsServer() || !g_Game.IsMultiplayer()) // single player or server side multiplayer
8383 StartItemSoundServer(SoundConstants.ITEM_ATTACH, slot_id);
8384 }
8385
8386 override void OnWasDetached(EntityAI parent, int slot_id)
8387 {
8388 super.OnWasDetached(parent, slot_id);
8389
8390 if (HasQuantity())
8391 UpdateNetSyncVariableFloat("m_VarQuantity", GetQuantityMin(), m_VarQuantityMax);
8392
8393 if (g_Game.IsServer() || !g_Game.IsMultiplayer()) // single player or server side multiplayer
8394 StartItemSoundServer(SoundConstants.ITEM_DETACH, slot_id);
8395 }
8396
8397 override string ChangeIntoOnAttach(string slot)
8398 {
8399 int idx;
8400 TStringArray inventory_slots = new TStringArray;
8401 TStringArray attach_types = new TStringArray;
8402
8403 ConfigGetTextArray("ChangeInventorySlot",inventory_slots);
8404 if (inventory_slots.Count() < 1) //is string
8405 {
8406 inventory_slots.Insert(ConfigGetString("ChangeInventorySlot"));
8407 attach_types.Insert(ConfigGetString("ChangeIntoOnAttach"));
8408 }
8409 else //is array
8410 {
8411 ConfigGetTextArray("ChangeIntoOnAttach",attach_types);
8412 }
8413
8414 idx = inventory_slots.Find(slot);
8415 if (idx < 0)
8416 return "";
8417
8418 return attach_types.Get(idx);
8419 }
8420
8421 override string ChangeIntoOnDetach()
8422 {
8423 int idx = -1;
8424 string slot;
8425
8426 TStringArray inventory_slots = new TStringArray;
8427 TStringArray detach_types = new TStringArray;
8428
8429 this.ConfigGetTextArray("ChangeInventorySlot",inventory_slots);
8430 if (inventory_slots.Count() < 1) //is string
8431 {
8432 inventory_slots.Insert(this.ConfigGetString("ChangeInventorySlot"));
8433 detach_types.Insert(this.ConfigGetString("ChangeIntoOnDetach"));
8434 }
8435 else //is array
8436 {
8437 this.ConfigGetTextArray("ChangeIntoOnDetach",detach_types);
8438 if (detach_types.Count() < 1)
8439 detach_types.Insert(this.ConfigGetString("ChangeIntoOnDetach"));
8440 }
8441
8442 for (int i = 0; i < inventory_slots.Count(); i++)
8443 {
8444 slot = inventory_slots.Get(i);
8445 }
8446
8447 if (slot != "")
8448 {
8449 if (detach_types.Count() == 1)
8450 idx = 0;
8451 else
8452 idx = inventory_slots.Find(slot);
8453 }
8454 if (idx < 0)
8455 return "";
8456
8457 return detach_types.Get(idx);
8458 }
8459
8460 void ExplodeAmmo()
8461 {
8462 //timer
8463 ref Timer explode_timer = new Timer(CALL_CATEGORY_SYSTEM);
8464
8465 //min/max time
8466 float min_time = 1;
8467 float max_time = 3;
8468 float delay = Math.RandomFloat(min_time, max_time);
8469
8470 explode_timer.Run(delay, this, "DoAmmoExplosion");
8471 }
8472
8473 void DoAmmoExplosion()
8474 {
8475 Magazine magazine = Magazine.Cast(this);
8476 int pop_sounds_count = 6;
8477 string pop_sounds[ 6 ] = { "ammopops_1","ammopops_2","ammopops_3","ammopops_4","ammopops_5","ammopops_6" };
8478
8479 //play sound
8480 int sound_idx = Math.RandomInt(0, pop_sounds_count - 1);
8481 string sound_name = pop_sounds[ sound_idx ];
8482 g_Game.CreateSoundOnObject(this, sound_name, 20, false);
8483
8484 //remove ammo count
8485 magazine.ServerAddAmmoCount(-1);
8486
8487 //if condition then repeat -> ExplodeAmmo
8488 float min_temp_to_explode = 100; //min temperature for item to explode
8489
8490 if (magazine.GetAmmoCount() > 0 && GetTemperature() >= min_temp_to_explode) //TODO ? add check for parent -> fireplace
8491 {
8492 ExplodeAmmo();
8493 }
8494 }
8495
8496 // -------------------------------------------------------------------------------
8497 override void EEHitBy(TotalDamageResult damageResult, int damageType, EntityAI source, int component, string dmgZone, string ammo, vector modelPos, float speedCoef)
8498 {
8499 super.EEHitBy(damageResult, damageType, source, component, dmgZone, ammo, modelPos, speedCoef);
8500
8501 const int CHANCE_DAMAGE_CARGO = 4;
8502 const int CHANCE_DAMAGE_ATTACHMENT = 1;
8503 const int CHANCE_DAMAGE_NOTHING = 2;
8504
8505 if (IsClothing() || IsContainer() || IsItemTent())
8506 {
8507 float dmg = damageResult.GetDamage("","Health") * -0.5;
8508 int chances;
8509 int rnd;
8510
8511 if (GetInventory().GetCargo())
8512 {
8513 chances = CHANCE_DAMAGE_CARGO + CHANCE_DAMAGE_ATTACHMENT + CHANCE_DAMAGE_NOTHING;
8514 rnd = Math.RandomInt(0,chances);
8515
8516 if (rnd < CHANCE_DAMAGE_CARGO)
8517 {
8518 DamageItemInCargo(dmg);
8519 }
8520 else if (rnd < (chances - CHANCE_DAMAGE_NOTHING))
8521 {
8523 }
8524 }
8525 else
8526 {
8527 chances = CHANCE_DAMAGE_ATTACHMENT + CHANCE_DAMAGE_NOTHING;
8528 rnd = Math.RandomInt(0,chances);
8529
8530 if (rnd < CHANCE_DAMAGE_ATTACHMENT)
8531 {
8533 }
8534 }
8535 }
8536 }
8537
8538 bool DamageItemInCargo(float damage)
8539 {
8540 CargoBase cargo = GetInventory().GetCargo();
8541 if (cargo)
8542 {
8543 int item_count = cargo.GetItemCount();
8544 if (item_count > 0)
8545 {
8546 int random_pick = Math.RandomInt(0, item_count);
8547 ItemBase item = ItemBase.Cast(cargo.GetItem(random_pick));
8548 if (!item.IsExplosive())
8549 {
8550 item.AddHealth("","",damage);
8551 return true;
8552 }
8553 }
8554 }
8555 return false;
8556 }
8557
8558 bool DamageItemAttachments(float damage)
8559 {
8560 GameInventory inventory = GetInventory();
8561 int attachment_count = inventory.AttachmentCount();
8562 if (attachment_count > 0)
8563 {
8564 int random_pick = Math.RandomInt(0, attachment_count);
8565 ItemBase attachment = ItemBase.Cast(inventory.GetAttachmentFromIndex(random_pick));
8566 if (!attachment.IsExplosive())
8567 {
8568 attachment.AddHealth("","",damage);
8569 return true;
8570 }
8571 }
8572 return false;
8573 }
8574
8575 override bool IsSplitable()
8576 {
8577 return m_CanThisBeSplit;
8578 }
8579 //----------------
8580 override bool CanBeSplit()
8581 {
8582 if (IsSplitable() && (GetQuantity() > 1))
8583 return GetInventory().CanRemoveEntity();
8584
8585 return false;
8586 }
8587
8588 protected bool ShouldSplitQuantity(float quantity)
8589 {
8590 // don't call 'CanBeSplit' here, too strict and will introduce a freeze-crash when dismantling fence with a fireplace nearby
8591 if (!IsSplitable())
8592 return false;
8593
8594 // nothing to split?
8595 if (GetQuantity() <= 1)
8596 return false;
8597
8598 // check if we should re-use the item instead of creating a new copy?
8599 // implicit cast to int, if 'IsSplitable' returns true, these values are assumed ints
8600 int delta = GetQuantity() - quantity;
8601 if (delta == 0)
8602 return false;
8603
8604 // valid to split
8605 return true;
8606 }
8607
8608 override void SplitIntoStackMaxClient(EntityAI destination_entity, int slot_id )
8609 {
8610 if (g_Game.IsClient())
8611 {
8612 if (ScriptInputUserData.CanStoreInputUserData())
8613 {
8614 ScriptInputUserData ctx = new ScriptInputUserData;
8616 ctx.Write(1);
8617 ItemBase i1 = this; // @NOTE: workaround for correct serialization
8618 ctx.Write(i1);
8619 ctx.Write(destination_entity);
8620 ctx.Write(true);
8621 ctx.Write(slot_id);
8622 ctx.Send();
8623 }
8624 }
8625 else if (!g_Game.IsMultiplayer())
8626 {
8627 SplitIntoStackMax(destination_entity, slot_id, PlayerBase.Cast(g_Game.GetPlayer()));
8628 }
8629 }
8630
8631 void SplitIntoStackMax(EntityAI destination_entity, int slot_id, PlayerBase player)
8632 {
8633 float split_quantity_new;
8634 ItemBase new_item;
8635 float quantity = GetQuantity();
8636 float stack_max = GetTargetQuantityMax(slot_id);
8637 InventoryLocation loc = new InventoryLocation;
8638
8639 if (destination_entity && slot_id != -1 && InventorySlots.IsSlotIdValid(slot_id))
8640 {
8641 if (stack_max <= GetQuantity())
8642 split_quantity_new = stack_max;
8643 else
8644 split_quantity_new = GetQuantity();
8645
8646 if (ShouldSplitQuantity(split_quantity_new))
8647 {
8648 new_item = ItemBase.Cast(destination_entity.GetInventory().CreateAttachmentEx(this.GetType(), slot_id));
8649 if (new_item)
8650 {
8651 new_item.SetResultOfSplit(true);
8652 MiscGameplayFunctions.TransferItemProperties(this, new_item);
8653 AddQuantity(-split_quantity_new, false, true);
8654 new_item.SetQuantity(split_quantity_new, false, true);
8655 }
8656 }
8657 }
8658 else if (destination_entity && slot_id == -1)
8659 {
8660 if (quantity > stack_max)
8661 split_quantity_new = stack_max;
8662 else
8663 split_quantity_new = quantity;
8664
8665 if (ShouldSplitQuantity(split_quantity_new))
8666 {
8667 GameInventory destinationInventory = destination_entity.GetInventory();
8668 if (destinationInventory.FindFreeLocationFor(this, FindInventoryLocationType.ANY, loc))
8669 {
8670 Object o = destinationInventory.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 (!g_Game.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(g_Game.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 GameInventory destinationInventory = destination_entity.GetInventory();
8755 if (destinationInventory.FindFreeLocationFor(this, FindInventoryLocationType.ANY, loc))
8756 {
8757 Object o = destinationInventory.LocationCreateEntity(loc, GetType(), ECE_IN_INVENTORY, RF_DEFAULT);
8758 new_item = ItemBase.Cast(o);
8759 }
8760
8761 if (new_item)
8762 {
8763 new_item.SetResultOfSplit(true);
8764 MiscGameplayFunctions.TransferItemProperties(this, new_item);
8765 AddQuantity(-split_quantity_new, false, true);
8766 new_item.SetQuantity(split_quantity_new, false, true);
8767 }
8768 }
8769 }
8770 else
8771 {
8772 if (stack_max != 0)
8773 {
8774 if (stack_max < GetQuantity())
8775 {
8776 split_quantity_new = GetQuantity() - stack_max;
8777 }
8778
8779 if (ShouldSplitQuantity(split_quantity_new))
8780 {
8781 new_item = ItemBase.Cast(g_Game.CreateObjectEx(GetType(),GetWorldPosition(), ECE_PLACE_ON_SURFACE));
8782
8783 if (new_item)
8784 {
8785 new_item.SetResultOfSplit(true);
8786 MiscGameplayFunctions.TransferItemProperties(this, new_item);
8787 SetQuantity(split_quantity_new, false, true);
8788 new_item.SetQuantity(stack_max, false, true);
8789 new_item.PlaceOnSurface();
8790 }
8791 }
8792 }
8793 }
8794 }
8795
8796 void SplitIntoStackMaxToInventoryLocationClient(notnull InventoryLocation dst)
8797 {
8798 if (g_Game.IsClient())
8799 {
8800 if (ScriptInputUserData.CanStoreInputUserData())
8801 {
8802 ScriptInputUserData ctx = new ScriptInputUserData;
8804 ctx.Write(4);
8805 ItemBase thiz = this; // @NOTE: workaround for correct serialization
8806 ctx.Write(thiz);
8807 dst.WriteToContext(ctx);
8808 ctx.Send();
8809 }
8810 }
8811 else if (!g_Game.IsMultiplayer())
8812 {
8814 }
8815 }
8816
8817 void SplitIntoStackMaxCargoClient(EntityAI destination_entity, int idx, int row, int col)
8818 {
8819 if (g_Game.IsClient())
8820 {
8821 if (ScriptInputUserData.CanStoreInputUserData())
8822 {
8823 ScriptInputUserData ctx = new ScriptInputUserData;
8825 ctx.Write(2);
8826 ItemBase dummy = this; // @NOTE: workaround for correct serialization
8827 ctx.Write(dummy);
8828 ctx.Write(destination_entity);
8829 ctx.Write(true);
8830 ctx.Write(idx);
8831 ctx.Write(row);
8832 ctx.Write(col);
8833 ctx.Send();
8834 }
8835 }
8836 else if (!g_Game.IsMultiplayer())
8837 {
8838 SplitIntoStackMaxCargo(destination_entity, idx, row, col);
8839 }
8840 }
8841
8842 void SplitIntoStackMaxToInventoryLocation(notnull InventoryLocation dst)
8843 {
8845 }
8846
8847 ItemBase SplitIntoStackMaxToInventoryLocationEx(notnull InventoryLocation dst)
8848 {
8849 float quantity = GetQuantity();
8850 float split_quantity_new;
8851 ItemBase new_item;
8852 if (dst.IsValid())
8853 {
8854 int slot_id = dst.GetSlot();
8855 float stack_max = GetTargetQuantityMax(slot_id);
8856
8857 if (quantity > stack_max)
8858 split_quantity_new = stack_max;
8859 else
8860 split_quantity_new = quantity;
8861
8862 if (ShouldSplitQuantity(split_quantity_new))
8863 {
8864 new_item = ItemBase.Cast(GameInventory.LocationCreateEntity(dst, this.GetType(), ECE_IN_INVENTORY, RF_DEFAULT));
8865
8866 if (new_item)
8867 {
8868 new_item.SetResultOfSplit(true);
8869 MiscGameplayFunctions.TransferItemProperties(this,new_item);
8870 AddQuantity(-split_quantity_new, false, true);
8871 new_item.SetQuantity(split_quantity_new, false, true);
8872 }
8873
8874 return new_item;
8875 }
8876 }
8877
8878 return null;
8879 }
8880
8881 void SplitIntoStackMaxCargo(EntityAI destination_entity, int idx, int row, int col)
8882 {
8883 float quantity = GetQuantity();
8884 float split_quantity_new;
8885 ItemBase new_item;
8886 if (destination_entity)
8887 {
8888 float stackable = GetTargetQuantityMax();
8889 if (quantity > stackable)
8890 split_quantity_new = stackable;
8891 else
8892 split_quantity_new = quantity;
8893
8894 if (ShouldSplitQuantity(split_quantity_new))
8895 {
8896 new_item = ItemBase.Cast(destination_entity.GetInventory().CreateEntityInCargoEx(this.GetType(), idx, row, col, false));
8897 if (new_item)
8898 {
8899 new_item.SetResultOfSplit(true);
8900 MiscGameplayFunctions.TransferItemProperties(this,new_item);
8901 AddQuantity(-split_quantity_new, false, true);
8902 new_item.SetQuantity(split_quantity_new, false, true);
8903 }
8904 }
8905 }
8906 }
8907
8908 void SplitIntoStackMaxHandsClient(PlayerBase player)
8909 {
8910 if (g_Game.IsClient())
8911 {
8912 if (ScriptInputUserData.CanStoreInputUserData())
8913 {
8914 ScriptInputUserData ctx = new ScriptInputUserData;
8916 ctx.Write(3);
8917 ItemBase i1 = this; // @NOTE: workaround for correct serialization
8918 ctx.Write(i1);
8919 ItemBase destination_entity = this;
8920 ctx.Write(destination_entity);
8921 ctx.Write(true);
8922 ctx.Write(0);
8923 ctx.Send();
8924 }
8925 }
8926 else if (!g_Game.IsMultiplayer())
8927 {
8928 SplitIntoStackMaxHands(player);
8929 }
8930 }
8931
8932 void SplitIntoStackMaxHands(PlayerBase player)
8933 {
8934 float quantity = GetQuantity();
8935 float split_quantity_new;
8936 ref ItemBase new_item;
8937 if (player)
8938 {
8939 float stackable = GetTargetQuantityMax();
8940 if (quantity > stackable)
8941 split_quantity_new = stackable;
8942 else
8943 split_quantity_new = quantity;
8944
8945 if (ShouldSplitQuantity(split_quantity_new))
8946 {
8947 EntityAI in_hands = player.GetHumanInventory().CreateInHands(this.GetType());
8948 new_item = ItemBase.Cast(in_hands);
8949 if (new_item)
8950 {
8951 new_item.SetResultOfSplit(true);
8952 MiscGameplayFunctions.TransferItemProperties(this,new_item);
8953 AddQuantity(-split_quantity_new, false, true);
8954 new_item.SetQuantity(split_quantity_new, false, true);
8955 }
8956 }
8957 }
8958 }
8959
8960 void SplitItemToInventoryLocation(notnull InventoryLocation dst)
8961 {
8962 float quantity = GetQuantity();
8963 float split_quantity_new = Math.Floor(quantity * 0.5);
8964
8965 if (!ShouldSplitQuantity(split_quantity_new))
8966 return;
8967
8968 ItemBase new_item = ItemBase.Cast(GameInventory.LocationCreateEntity(dst, GetType(), ECE_IN_INVENTORY, RF_DEFAULT));
8969
8970 if (new_item)
8971 {
8972 if (new_item.GetQuantityMax() < split_quantity_new)
8973 {
8974 split_quantity_new = new_item.GetQuantityMax();
8975 }
8976
8977 new_item.SetResultOfSplit(true);
8978 MiscGameplayFunctions.TransferItemProperties(this, new_item);
8979
8980 if (dst.IsValid() && dst.GetType() == InventoryLocationType.ATTACHMENT && split_quantity_new > 1)
8981 {
8982 AddQuantity(-1, false, true);
8983 new_item.SetQuantity(1, false, true);
8984 }
8985 else
8986 {
8987 AddQuantity(-split_quantity_new, false, true);
8988 new_item.SetQuantity(split_quantity_new, false, true);
8989 }
8990 }
8991 }
8992
8993 void SplitItem(PlayerBase player)
8994 {
8995 float quantity = GetQuantity();
8996 float split_quantity_new = Math.Floor(quantity / 2);
8997
8998 if (!ShouldSplitQuantity(split_quantity_new))
8999 return;
9000
9001 InventoryLocation invloc = new InventoryLocation;
9002 bool found = player.GetInventory().FindFirstFreeLocationForNewEntity(GetType(), FindInventoryLocationType.ATTACHMENT, invloc);
9003
9004 ItemBase new_item;
9005 new_item = player.CreateCopyOfItemInInventoryOrGroundEx(this, true);
9006
9007 if (new_item)
9008 {
9009 if (new_item.GetQuantityMax() < split_quantity_new)
9010 {
9011 split_quantity_new = new_item.GetQuantityMax();
9012 }
9013 if (found && invloc.IsValid() && invloc.GetType() == InventoryLocationType.ATTACHMENT && split_quantity_new > 1)
9014 {
9015 AddQuantity(-1, false, true);
9016 new_item.SetQuantity(1, false, true);
9017 }
9018 else if (split_quantity_new > 1)
9019 {
9020 AddQuantity(-split_quantity_new, false, true);
9021 new_item.SetQuantity(split_quantity_new, false, true);
9022 }
9023 }
9024 }
9025
9027 void OnQuantityChanged(float delta)
9028 {
9029 SetWeightDirty();
9030 ItemBase parent = ItemBase.Cast(GetHierarchyParent());
9031
9032 if (parent)
9033 parent.OnAttachmentQuantityChangedEx(this, delta);
9034
9035 if (IsLiquidContainer())
9036 {
9037 if (GetQuantityNormalized() <= 0.0)
9038 {
9040 }
9041 else if (GetLiquidType() == LIQUID_NONE)
9042 {
9043 ErrorEx("Undefined liquid type quantity changed, please define liquid type first! Using init value.",ErrorExSeverity.INFO);
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 (g_Game.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() && !g_Game.GetPlayer().GetInventory().HasInventoryReservation(this,null))
9104 {
9105 if (g_Game.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(g_Game.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 (g_Game.GetPlayer().GetInventory().HasInventoryReservation(this, dst))
9135 {
9137 }
9138 else
9139 {
9140 g_Game.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 (!g_Game.IsMultiplayer())
9157 {
9158 SplitItem(PlayerBase.Cast(g_Game.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.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 (g_Game.IsClient() || !g_Game.IsMultiplayer())
9403 {
9404 switch (action_id)
9405 {
9406 case EActions.GIZMO_OBJECT:
9407 if (GetGizmoApi())
9408 GetGizmoApi().SelectObject(this);
9409 return true;
9410 case EActions.GIZMO_PHYSICS:
9411 if (GetGizmoApi())
9412 GetGizmoApi().SelectPhysics(GetPhysics());
9413 return true;
9414 }
9415 }
9416
9417 if (g_Game.IsServer())
9418 {
9419 switch (action_id)
9420 {
9421 case EActions.DELETE:
9422 Delete();
9423 return true;
9424 }
9425 }
9426
9427 if (action_id >= EActions.RECIPES_RANGE_START && action_id < EActions.RECIPES_RANGE_END)
9428 {
9429 PluginRecipesManager plugin_recipes_manager = PluginRecipesManager.Cast(GetPlugin(PluginRecipesManager));
9430 int idWithoutOffset = action_id - EActions.RECIPES_RANGE_START;
9431 PlayerBase p = PlayerBase.Cast(player);
9432 if (EActions.RECIPES_RANGE_START < 1000)
9433 {
9434 float anim_length = plugin_recipes_manager.GetRecipeLengthInSecs(idWithoutOffset);
9435 float specialty_weight = plugin_recipes_manager.GetRecipeSpecialty(idWithoutOffset);
9436 }
9437 }
9438 #ifndef SERVER
9439 else if (action_id == EActions.WATCH_PLAYER)
9440 {
9441 PluginDeveloper.SetDeveloperItemClientEx(player);
9442 }
9443 #endif
9444 if (g_Game.IsServer())
9445 {
9446 if (action_id >= EActions.DEBUG_ITEM_WATCH_BUTTON_RANGE_START && action_id < EActions.DEBUG_ITEM_WATCH_BUTTON_RANGE_END)
9447 {
9448 int id = action_id - EActions.DEBUG_ITEM_WATCH_BUTTON_RANGE_START;
9449 OnDebugButtonPressServer(id + 1);
9450 }
9451
9452 else if (action_id >= EActions.DEBUG_AGENTS_RANGE_INJECT_START && action_id < EActions.DEBUG_AGENTS_RANGE_INJECT_END)
9453 {
9454 int agent_id = action_id - EActions.DEBUG_AGENTS_RANGE_INJECT_START;
9455 InsertAgent(agent_id,100);
9456 }
9457
9458 else if (action_id >= EActions.DEBUG_AGENTS_RANGE_REMOVE_START && action_id < EActions.DEBUG_AGENTS_RANGE_REMOVE_END)
9459 {
9460 int agent_id2 = action_id - EActions.DEBUG_AGENTS_RANGE_REMOVE_START;
9461 RemoveAgent(agent_id2);
9462 }
9463
9464 else if (action_id == EActions.ADD_QUANTITY)
9465 {
9466 if (IsMagazine())
9467 {
9468 Magazine mag = Magazine.Cast(this);
9469 mag.ServerSetAmmoCount(mag.GetAmmoCount() + mag.GetAmmoMax() * 0.2);
9470 }
9471 else
9472 {
9473 AddQuantity(GetQuantityMax() * 0.2);
9474 }
9475
9476 if (m_EM)
9477 {
9478 m_EM.AddEnergy(m_EM.GetEnergyMax() * 0.2);
9479 }
9480 //PrintVariables();
9481 }
9482
9483 else if (action_id == EActions.REMOVE_QUANTITY) //Quantity -20%
9484 {
9485 if (IsMagazine())
9486 {
9487 Magazine mag2 = Magazine.Cast(this);
9488 mag2.ServerSetAmmoCount(mag2.GetAmmoCount() - mag2.GetAmmoMax() * 0.2);
9489 }
9490 else
9491 {
9492 AddQuantity(- GetQuantityMax() * 0.2);
9493 }
9494 if (m_EM)
9495 {
9496 m_EM.AddEnergy(- m_EM.GetEnergyMax() * 0.2);
9497 }
9498 //PrintVariables();
9499 }
9500
9501 else if (action_id == EActions.SET_QUANTITY_0) //SetMaxQuantity
9502 {
9503 SetQuantity(0);
9504
9505 if (m_EM)
9506 {
9507 m_EM.SetEnergy(0);
9508 }
9509 }
9510
9511 else if (action_id == EActions.SET_MAX_QUANTITY) //SetMaxQuantity
9512 {
9514
9515 if (m_EM)
9516 {
9517 m_EM.SetEnergy(m_EM.GetEnergyMax());
9518 }
9519 }
9520
9521 else if (action_id == EActions.ADD_HEALTH)
9522 {
9523 AddHealth("","",GetMaxHealth("","Health")/5);
9524 }
9525 else if (action_id == EActions.REMOVE_HEALTH)
9526 {
9527 AddHealth("","",-GetMaxHealth("","Health")/5);
9528 }
9529 else if (action_id == EActions.DESTROY_HEALTH)
9530 {
9531 SetHealth01("","",0);
9532 }
9533 else if (action_id == EActions.WATCH_ITEM)
9534 {
9536 mid.RegisterDebugItem(ItemBase.Cast(this), PlayerBase.Cast(player));
9537 #ifdef DEVELOPER
9538 SetDebugDeveloper_item(this);
9539 #endif
9540 }
9541
9542 else if (action_id == EActions.ADD_TEMPERATURE)
9543 {
9544 AddTemperature(20);
9545 //PrintVariables();
9546 }
9547
9548 else if (action_id == EActions.REMOVE_TEMPERATURE)
9549 {
9550 AddTemperature(-20);
9551 //PrintVariables();
9552 }
9553
9554 else if (action_id == EActions.FLIP_FROZEN)
9555 {
9556 SetFrozen(!GetIsFrozen());
9557 //PrintVariables();
9558 }
9559
9560 else if (action_id == EActions.ADD_WETNESS)
9561 {
9562 AddWet(GetWetMax()/5);
9563 //PrintVariables();
9564 }
9565
9566 else if (action_id == EActions.REMOVE_WETNESS)
9567 {
9568 AddWet(-GetWetMax()/5);
9569 //PrintVariables();
9570 }
9571
9572 else if (action_id == EActions.LIQUIDTYPE_UP)
9573 {
9574 int curr_type = GetLiquidType();
9575 SetLiquidType(curr_type * 2);
9576 //AddWet(1);
9577 //PrintVariables();
9578 }
9579
9580 else if (action_id == EActions.LIQUIDTYPE_DOWN)
9581 {
9582 int curr_type2 = GetLiquidType();
9583 SetLiquidType(curr_type2 / 2);
9584 }
9585
9586 else if (action_id == EActions.MAKE_SPECIAL)
9587 {
9588 auto debugParams = DebugSpawnParams.WithPlayer(player);
9589 OnDebugSpawnEx(debugParams);
9590 }
9591
9592 }
9593
9594
9595 return false;
9596 }
9597
9598 // -------------------------------------------------------------------------
9599
9600
9603 void OnActivatedByTripWire();
9604
9606 void OnActivatedByItem(notnull ItemBase item);
9607
9608 //----------------------------------------------------------------
9609 //returns true if item is able to explode when put in fire
9610 bool CanExplodeInFire()
9611 {
9612 return false;
9613 }
9614
9615 //----------------------------------------------------------------
9616 bool CanEat()
9617 {
9618 return true;
9619 }
9620
9621 //----------------------------------------------------------------
9622 override bool IsIgnoredByConstruction()
9623 {
9624 return true;
9625 }
9626
9627 //----------------------------------------------------------------
9628 //has FoodStages in config?
9629 bool HasFoodStage()
9630 {
9631 string config_path = string.Format("CfgVehicles %1 Food FoodStages", GetType());
9632 return g_Game.ConfigIsExisting(config_path);
9633 }
9634
9636 FoodStage GetFoodStage()
9637 {
9638 return null;
9639 }
9640
9641 bool CanBeCooked()
9642 {
9643 return false;
9644 }
9645
9646 bool CanBeCookedOnStick()
9647 {
9648 return false;
9649 }
9650
9652 void RefreshAudioVisualsOnClient( CookingMethodType cooking_method, bool is_done, bool is_empty, bool is_burned );
9654
9655 //----------------------------------------------------------------
9656 bool CanRepair(ItemBase item_repair_kit)
9657 {
9658 PluginRepairing module_repairing = PluginRepairing.Cast(GetPlugin(PluginRepairing));
9659 return module_repairing.CanRepair(this, item_repair_kit);
9660 }
9661
9662 //----------------------------------------------------------------
9663 bool Repair(PlayerBase player, ItemBase item_repair_kit, float specialty_weight)
9664 {
9665 PluginRepairing module_repairing = PluginRepairing.Cast(GetPlugin(PluginRepairing));
9666 return module_repairing.Repair(player, this, item_repair_kit, specialty_weight);
9667 }
9668
9669 //----------------------------------------------------------------
9670 int GetItemSize()
9671 {
9672 /*
9673 vector v_size = this.ConfigGetVector("itemSize");
9674 int v_size_x = v_size[0];
9675 int v_size_y = v_size[1];
9676 int size = v_size_x * v_size_y;
9677 return size;
9678 */
9679
9680 return 1;
9681 }
9682
9683 //----------------------------------------------------------------
9684 //Override for allowing seemingly unallowed moves when two clients send a conflicting message simultaneously
9685 bool CanBeMovedOverride()
9686 {
9687 return m_CanBeMovedOverride;
9688 }
9689
9690 //----------------------------------------------------------------
9691 //Override for allowing seemingly unallowed moves when two clients send a conflicting message simultaneously
9692 void SetCanBeMovedOverride(bool setting)
9693 {
9694 m_CanBeMovedOverride = setting;
9695 }
9696
9697 //----------------------------------------------------------------
9705 void MessageToOwnerStatus(string text)
9706 {
9707 PlayerBase player = PlayerBase.Cast(this.GetHierarchyRootPlayer());
9708
9709 if (player)
9710 {
9711 player.MessageStatus(text);
9712 }
9713 }
9714
9715 //----------------------------------------------------------------
9723 void MessageToOwnerAction(string text)
9724 {
9725 PlayerBase player = PlayerBase.Cast(this.GetHierarchyRootPlayer());
9726
9727 if (player)
9728 {
9729 player.MessageAction(text);
9730 }
9731 }
9732
9733 //----------------------------------------------------------------
9741 void MessageToOwnerFriendly(string text)
9742 {
9743 PlayerBase player = PlayerBase.Cast(this.GetHierarchyRootPlayer());
9744
9745 if (player)
9746 {
9747 player.MessageFriendly(text);
9748 }
9749 }
9750
9751 //----------------------------------------------------------------
9759 void MessageToOwnerImportant(string text)
9760 {
9761 PlayerBase player = PlayerBase.Cast(this.GetHierarchyRootPlayer());
9762
9763 if (player)
9764 {
9765 player.MessageImportant(text);
9766 }
9767 }
9768
9769 override bool IsItemBase()
9770 {
9771 return true;
9772 }
9773
9774 // Checks if item is of questioned kind
9775 override bool KindOf(string tag)
9776 {
9777 bool found = false;
9778 string item_name = this.GetType();
9779 ref TStringArray item_tag_array = new TStringArray;
9780 g_Game.ConfigGetTextArray("cfgVehicles " + item_name + " itemInfo", item_tag_array);
9781
9782 int array_size = item_tag_array.Count();
9783 for (int i = 0; i < array_size; i++)
9784 {
9785 if (item_tag_array.Get(i) == tag)
9786 {
9787 found = true;
9788 break;
9789 }
9790 }
9791 return found;
9792 }
9793
9794
9795 override void OnRPC(PlayerIdentity sender, int rpc_type,ParamsReadContext ctx)
9796 {
9797 //Debug.Log("OnRPC called");
9798 super.OnRPC(sender, rpc_type,ctx);
9799
9800 //Play soundset for attachment locking (ActionLockAttachment.c)
9801 switch (rpc_type)
9802 {
9803 #ifndef SERVER
9804 case ERPCs.RPC_SOUND_LOCK_ATTACH:
9805 Param2<bool, string> p = new Param2<bool, string>(false, "");
9806
9807 if (!ctx.Read(p))
9808 return;
9809
9810 bool play = p.param1;
9811 string soundSet = p.param2;
9812
9813 if (play)
9814 {
9815 if (m_LockingSound)
9816 {
9818 {
9819 m_LockingSound = SEffectManager.PlaySound(soundSet, GetPosition(), 0, 0, true);
9820 }
9821 }
9822 else
9823 {
9824 m_LockingSound = SEffectManager.PlaySound(soundSet, GetPosition(), 0, 0, true);
9825 }
9826 }
9827 else
9828 {
9829 SEffectManager.DestroyEffect(m_LockingSound);
9830 }
9831
9832 break;
9833 #endif
9834
9835 }
9836
9837 if (GetWrittenNoteData())
9838 {
9839 GetWrittenNoteData().OnRPC(sender, rpc_type,ctx);
9840 }
9841 }
9842
9843 //-----------------------------
9844 // VARIABLE MANIPULATION SYSTEM
9845 //-----------------------------
9846 int NameToID(string name)
9847 {
9848 PluginVariables plugin = PluginVariables.Cast(GetPlugin(PluginVariables));
9849 return plugin.GetID(name);
9850 }
9851
9852 string IDToName(int id)
9853 {
9854 PluginVariables plugin = PluginVariables.Cast(GetPlugin(PluginVariables));
9855 return plugin.GetName(id);
9856 }
9857
9859 void OnSyncVariables(ParamsReadContext ctx)//with ID optimization
9860 {
9861 //Debug.Log("OnSyncVariables called for item: "+ ToString(this.GetType()),"varSync");
9862 //read the flags
9863 int varFlags;
9864 if (!ctx.Read(varFlags))
9865 return;
9866
9867 if (varFlags & ItemVariableFlags.FLOAT)
9868 {
9869 ReadVarsFromCTX(ctx);
9870 }
9871 }
9872
9873 override void SerializeNumericalVars(array<float> floats_out)
9874 {
9875 //some variables handled on EntityAI level already!
9876 super.SerializeNumericalVars(floats_out);
9877
9878 // the order of serialization must be the same as the order of de-serialization
9879 //--------------------------------------------
9880 if (IsVariableSet(VARIABLE_QUANTITY))
9881 {
9882 floats_out.Insert(m_VarQuantity);
9883 }
9884 //--------------------------------------------
9885 if (IsVariableSet(VARIABLE_WET))
9886 {
9887 floats_out.Insert(m_VarWet);
9888 }
9889 //--------------------------------------------
9890 if (IsVariableSet(VARIABLE_LIQUIDTYPE))
9891 {
9892 floats_out.Insert(m_VarLiquidType);
9893 }
9894 //--------------------------------------------
9895 if (IsVariableSet(VARIABLE_COLOR))
9896 {
9897 floats_out.Insert(m_ColorComponentR);
9898 floats_out.Insert(m_ColorComponentG);
9899 floats_out.Insert(m_ColorComponentB);
9900 floats_out.Insert(m_ColorComponentA);
9901 }
9902 //--------------------------------------------
9903 if (IsVariableSet(VARIABLE_CLEANNESS))
9904 {
9905 floats_out.Insert(m_Cleanness);
9906 }
9907 }
9908
9909 override void DeSerializeNumericalVars(array<float> floats)
9910 {
9911 //some variables handled on EntityAI level already!
9912 super.DeSerializeNumericalVars(floats);
9913
9914 // the order of serialization must be the same as the order of de-serialization
9915 int index = 0;
9916 int mask = Math.Round(floats.Get(index));
9917
9918 index++;
9919 //--------------------------------------------
9920 if (mask & VARIABLE_QUANTITY)
9921 {
9922 if (m_IsStoreLoad)
9923 {
9924 SetStoreLoadedQuantity(floats.Get(index));
9925 }
9926 else
9927 {
9928 float quantity = floats.Get(index);
9929 SetQuantity(quantity, true, false, false, false);
9930 }
9931 index++;
9932 }
9933 //--------------------------------------------
9934 if (mask & VARIABLE_WET)
9935 {
9936 float wet = floats.Get(index);
9937 SetWet(wet);
9938 index++;
9939 }
9940 //--------------------------------------------
9941 if (mask & VARIABLE_LIQUIDTYPE)
9942 {
9943 int liquidtype = Math.Round(floats.Get(index));
9944 SetLiquidType(liquidtype);
9945 index++;
9946 }
9947 //--------------------------------------------
9948 if (mask & VARIABLE_COLOR)
9949 {
9950 m_ColorComponentR = Math.Round(floats.Get(index));
9951 index++;
9952 m_ColorComponentG = Math.Round(floats.Get(index));
9953 index++;
9954 m_ColorComponentB = Math.Round(floats.Get(index));
9955 index++;
9956 m_ColorComponentA = Math.Round(floats.Get(index));
9957 index++;
9958 }
9959 //--------------------------------------------
9960 if (mask & VARIABLE_CLEANNESS)
9961 {
9962 int cleanness = Math.Round(floats.Get(index));
9963 SetCleanness(cleanness);
9964 index++;
9965 }
9966 }
9967
9968 override void WriteVarsToCTX(ParamsWriteContext ctx)
9969 {
9970 super.WriteVarsToCTX(ctx);
9971
9972 //--------------------------------------------
9973 if (IsVariableSet(VARIABLE_QUANTITY))
9974 {
9975 ctx.Write(GetQuantity());
9976 }
9977 //--------------------------------------------
9978 if (IsVariableSet(VARIABLE_WET))
9979 {
9980 ctx.Write(GetWet());
9981 }
9982 //--------------------------------------------
9983 if (IsVariableSet(VARIABLE_LIQUIDTYPE))
9984 {
9985 ctx.Write(GetLiquidType());
9986 }
9987 //--------------------------------------------
9988 if (IsVariableSet(VARIABLE_COLOR))
9989 {
9990 int r,g,b,a;
9991 GetColor(r,g,b,a);
9992 ctx.Write(r);
9993 ctx.Write(g);
9994 ctx.Write(b);
9995 ctx.Write(a);
9996 }
9997 //--------------------------------------------
9998 if (IsVariableSet(VARIABLE_CLEANNESS))
9999 {
10000 ctx.Write(GetCleanness());
10001 }
10002 }
10003
10004 override bool ReadVarsFromCTX(ParamsReadContext ctx, int version = -1)//with ID optimization
10005 {
10006 if (!super.ReadVarsFromCTX(ctx,version))
10007 return false;
10008
10009 int intValue;
10010 float value;
10011
10012 if (version < 140)
10013 {
10014 if (!ctx.Read(intValue))
10015 return false;
10016
10017 m_VariablesMask = intValue;
10018 }
10019
10020 if (m_VariablesMask & VARIABLE_QUANTITY)
10021 {
10022 if (!ctx.Read(value))
10023 return false;
10024
10025 if (IsStoreLoad())
10026 {
10028 }
10029 else
10030 {
10031 SetQuantity(value, true, false, false, false);
10032 }
10033 }
10034 //--------------------------------------------
10035 if (version < 140)
10036 {
10037 if (m_VariablesMask & VARIABLE_TEMPERATURE)
10038 {
10039 if (!ctx.Read(value))
10040 return false;
10041 SetTemperatureDirect(value);
10042 }
10043 }
10044 //--------------------------------------------
10045 if (m_VariablesMask & VARIABLE_WET)
10046 {
10047 if (!ctx.Read(value))
10048 return false;
10049 SetWet(value);
10050 }
10051 //--------------------------------------------
10052 if (m_VariablesMask & VARIABLE_LIQUIDTYPE)
10053 {
10054 if (!ctx.Read(intValue))
10055 return false;
10056 SetLiquidType(intValue);
10057 }
10058 //--------------------------------------------
10059 if (m_VariablesMask & VARIABLE_COLOR)
10060 {
10061 int r,g,b,a;
10062 if (!ctx.Read(r))
10063 return false;
10064 if (!ctx.Read(g))
10065 return false;
10066 if (!ctx.Read(b))
10067 return false;
10068 if (!ctx.Read(a))
10069 return false;
10070
10071 SetColor(r,g,b,a);
10072 }
10073 //--------------------------------------------
10074 if (m_VariablesMask & VARIABLE_CLEANNESS)
10075 {
10076 if (!ctx.Read(intValue))
10077 return false;
10078 SetCleanness(intValue);
10079 }
10080 //--------------------------------------------
10081 if (version >= 138 && version < 140)
10082 {
10083 if (m_VariablesMask & VARIABLE_TEMPERATURE)
10084 {
10085 if (!ctx.Read(intValue))
10086 return false;
10087 SetFrozen(intValue);
10088 }
10089 }
10090
10091 return true;
10092 }
10093
10094 //----------------------------------------------------------------
10095 override bool OnStoreLoad(ParamsReadContext ctx, int version)
10096 {
10097 m_IsStoreLoad = true;
10099 {
10100 m_FixDamageSystemInit = true;
10101 }
10102
10103 if (!super.OnStoreLoad(ctx, version))
10104 {
10105 m_IsStoreLoad = false;
10106 return false;
10107 }
10108
10109 if (version >= 114)
10110 {
10111 bool hasQuickBarIndexSaved;
10112
10113 if (!ctx.Read(hasQuickBarIndexSaved))
10114 {
10115 m_IsStoreLoad = false;
10116 return false;
10117 }
10118
10119 if (hasQuickBarIndexSaved)
10120 {
10121 int itmQBIndex;
10122
10123 //Load quickbar item bind
10124 if (!ctx.Read(itmQBIndex))
10125 {
10126 m_IsStoreLoad = false;
10127 return false;
10128 }
10129
10130 PlayerBase parentPlayer = PlayerBase.Cast(GetHierarchyRootPlayer());
10131 if (itmQBIndex != -1 && parentPlayer)
10132 parentPlayer.SetLoadedQuickBarItemBind(this, itmQBIndex);
10133 }
10134 }
10135 else
10136 {
10137 // Backup of how it used to be
10138 PlayerBase player;
10139 int itemQBIndex;
10140 if (version == int.MAX)
10141 {
10142 if (!ctx.Read(itemQBIndex))
10143 {
10144 m_IsStoreLoad = false;
10145 return false;
10146 }
10147 }
10148 else if (Class.CastTo(player, GetHierarchyRootPlayer()))
10149 {
10150 //Load quickbar item bind
10151 if (!ctx.Read(itemQBIndex))
10152 {
10153 m_IsStoreLoad = false;
10154 return false;
10155 }
10156 if (itemQBIndex != -1 && player)
10157 player.SetLoadedQuickBarItemBind(this,itemQBIndex);
10158 }
10159 }
10160
10161 if (version < 140)
10162 {
10163 // variable management system
10164 if (!LoadVariables(ctx, version))
10165 {
10166 m_IsStoreLoad = false;
10167 return false;
10168 }
10169 }
10170
10171 //agent trasmission system
10172 if (!LoadAgents(ctx, version))
10173 {
10174 m_IsStoreLoad = false;
10175 return false;
10176 }
10177 if (version >= 132)
10178 {
10179 RemotelyActivatedItemBehaviour raib = GetRemotelyActivatedItemBehaviour();
10180 if (raib)
10181 {
10182 if (!raib.OnStoreLoad(ctx,version))
10183 {
10184 m_IsStoreLoad = false;
10185 return false;
10186 }
10187 }
10188 }
10189
10190 m_IsStoreLoad = false;
10191 return true;
10192 }
10193
10194 //----------------------------------------------------------------
10195
10196 override void OnStoreSave(ParamsWriteContext ctx)
10197 {
10198 super.OnStoreSave(ctx);
10199
10200 PlayerBase player;
10201 if (PlayerBase.CastTo(player,GetHierarchyRootPlayer()))
10202 {
10203 ctx.Write(true); // Keep track of if we should actually read this in or not
10204 //Save quickbar item bind
10205 int itemQBIndex = -1;
10206 itemQBIndex = player.FindQuickBarEntityIndex(this);
10207 ctx.Write(itemQBIndex);
10208 }
10209 else
10210 {
10211 ctx.Write(false); // Keep track of if we should actually read this in or not
10212 }
10213
10214 SaveAgents(ctx);//agent trasmission system
10215
10216 RemotelyActivatedItemBehaviour raib = GetRemotelyActivatedItemBehaviour();
10217 if (raib)
10218 {
10219 raib.OnStoreSave(ctx);
10220 }
10221 }
10222 //----------------------------------------------------------------
10223
10224 override void AfterStoreLoad()
10225 {
10226 super.AfterStoreLoad();
10227
10229 {
10231 }
10232
10233 if (GetStoreLoadedQuantity() != float.LOWEST)
10234 {
10236 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
10237 }
10238 }
10239
10240 override void EEOnAfterLoad()
10241 {
10242 super.EEOnAfterLoad();
10243
10245 {
10246 m_FixDamageSystemInit = false;
10247 }
10248
10251 }
10252
10253 bool CanBeDisinfected()
10254 {
10255 return false;
10256 }
10257
10258
10259 //----------------------------------------------------------------
10260 override void OnVariablesSynchronized()
10261 {
10262 if (m_Initialized)
10263 {
10264 #ifdef PLATFORM_CONSOLE
10265 //bruteforce it is
10266 if (IsSplitable())
10267 {
10268 UIScriptedMenu menu = g_Game.GetUIManager().FindMenu(MENU_INVENTORY);
10269 if (menu)
10270 {
10271 menu.Refresh();
10272 }
10273 }
10274 #endif
10275 }
10276
10278 {
10279 PlayImpactSound(m_ConfigWeight, m_ImpactSpeed, m_ImpactSoundSurfaceHash);
10280 m_WantPlayImpactSound = false;
10281 }
10282
10284 {
10285 SetWeightDirty();
10287 }
10288 if (m_VarWet != m_VarWetPrev)
10289 {
10292 }
10293
10294 if (m_SoundSyncPlay != 0)
10295 {
10298
10299 m_SoundSyncPlay = 0;
10300 m_SoundSyncSlotID = -1;
10301 }
10302 if (m_SoundSyncStop != 0)
10303 {
10305 m_ItemSoundHandler.StopItemSoundClient(m_SoundSyncStop);
10306 m_SoundSyncStop = 0;
10307 }
10308
10309 super.OnVariablesSynchronized();
10310 }
10311
10312 //------------------------- Quantity
10313 //----------------------------------------------------------------
10315 override bool SetQuantity(float value, bool destroy_config = true, bool destroy_forced = false, bool allow_client = false, bool clamp_to_stack_max = true)
10316 {
10317 if (!IsServerCheck(allow_client))
10318 return false;
10319
10320 if (!HasQuantity())
10321 return false;
10322
10323 float min = GetQuantityMin();
10324 float max = GetQuantityMax();
10325
10326 if (value <= (min + 0.001))
10327 value = min;
10328
10329 if (value == min)
10330 {
10331 if (destroy_config)
10332 {
10333 bool dstr = ConfigGetBool("varQuantityDestroyOnMin");
10334 if (dstr)
10335 {
10336 m_VarQuantity = Math.Clamp(value, min, max);
10337 this.Delete();
10338 return true;
10339 }
10340 }
10341 else if (destroy_forced)
10342 {
10343 m_VarQuantity = Math.Clamp(value, min, max);
10344 this.Delete();
10345 return true;
10346 }
10347 // we get here if destroy_config IS true AND dstr(config destroy param) IS false;
10348 RemoveAllAgents();//we remove all agents when we got to the min value, but the item is not getting deleted
10349 }
10350
10351 float delta = m_VarQuantity;
10352 m_VarQuantity = Math.Clamp(value, min, max);
10353
10354 if (g_Game.IsServer() || !g_Game.IsMultiplayer()) // single player or server side multiplayer
10355 {
10356 EntityAI parent = GetHierarchyRoot();
10357 InventoryLocation iLoc = new InventoryLocation();
10358 GetInventory().GetCurrentInventoryLocation(iLoc);
10359 if (iLoc && iLoc.IsValid() && delta != m_VarQuantity)
10360 {
10361 int iLocSlot = iLoc.GetSlot();
10362 if (delta < m_VarQuantity && iLoc.GetType() != InventoryLocationType.GROUND)
10363 {
10364 StartItemSoundServer(SoundConstants.ITEM_ATTACH, iLocSlot);
10365 }
10366 if (delta > m_VarQuantity && m_VarQuantity != 0 && !IsPrepareToDelete() && iLoc.GetType() == InventoryLocationType.ATTACHMENT)
10367 {
10368 StartItemSoundServer(SoundConstants.ITEM_DETACH, iLocSlot);
10369 }
10370 }
10371 }
10372
10373 if (GetStoreLoadedQuantity() == float.LOWEST)//any other value means we are setting quantity from storage
10374 {
10375 delta = m_VarQuantity - delta;
10376
10377 if (delta)
10378 OnQuantityChanged(delta);
10379 }
10380
10381 SetVariableMask(VARIABLE_QUANTITY);
10382
10383 return false;
10384 }
10385
10386 //----------------------------------------------------------------
10388 bool AddQuantity(float value, bool destroy_config = true, bool destroy_forced = false)
10389 {
10390 return SetQuantity(GetQuantity() + value, destroy_config, destroy_forced);
10391 }
10392 //----------------------------------------------------------------
10393 void SetQuantityMax()
10394 {
10395 float max = GetQuantityMax();
10396 SetQuantity(max);
10397 }
10398
10399 override void SetQuantityToMinimum()
10400 {
10401 float min = GetQuantityMin();
10402 SetQuantity(min);
10403 }
10404 //----------------------------------------------------------------
10406 override void SetQuantityNormalized(float value, bool destroy_config = true, bool destroy_forced = false)
10407 {
10408 float value_clamped = Math.Clamp(value, 0, 1);//just to make sure
10409 int result = Math.Round(Math.Lerp(GetQuantityMin(), GetQuantityMax(), value_clamped));
10410 SetQuantity(result, destroy_config, destroy_forced);
10411 }
10412
10413 //----------------------------------------------------------------
10415 override float GetQuantityNormalized()
10416 {
10417 return Math.InverseLerp(GetQuantityMin(), GetQuantityMax(),m_VarQuantity);
10418 }
10419
10421 {
10422 return GetQuantityNormalized();
10423 }
10424
10425 /*void SetAmmoNormalized(float value)
10426 {
10427 float value_clamped = Math.Clamp(value, 0, 1);
10428 Magazine this_mag = Magazine.Cast(this);
10429 int max_rounds = this_mag.GetAmmoMax();
10430 int result = value * max_rounds;//can the rounded if higher precision is required
10431 this_mag.SetAmmoCount(result);
10432 }*/
10433 //----------------------------------------------------------------
10434 override int GetQuantityMax()
10435 {
10436 int slot = -1;
10437 GameInventory inventory = GetInventory();
10438 if (inventory)
10439 {
10440 InventoryLocation il = new InventoryLocation;
10441 inventory.GetCurrentInventoryLocation(il);
10442 slot = il.GetSlot();
10443 }
10444
10445 return GetTargetQuantityMax(slot);
10446 }
10447
10448 override int GetTargetQuantityMax(int attSlotID = -1)
10449 {
10450 float quantity_max = 0;
10451
10452 if (IsSplitable()) //only stackable/splitable items can check for stack size
10453 {
10454 if (attSlotID != -1)
10455 quantity_max = InventorySlots.GetStackMaxForSlotId(attSlotID);
10456
10457 if (quantity_max <= 0)
10458 quantity_max = m_VarStackMax;
10459 }
10460
10461 if (quantity_max <= 0)
10462 quantity_max = m_VarQuantityMax;
10463
10464 return quantity_max;
10465 }
10466 //----------------------------------------------------------------
10467 override int GetQuantityMin()
10468 {
10469 return m_VarQuantityMin;
10470 }
10471 //----------------------------------------------------------------
10472 int GetQuantityInit()
10473 {
10474 return m_VarQuantityInit;
10475 }
10476
10477 //----------------------------------------------------------------
10478 override bool HasQuantity()
10479 {
10480 return !(GetQuantityMax() - GetQuantityMin() == 0);
10481 }
10482
10483 override float GetQuantity()
10484 {
10485 return m_VarQuantity;
10486 }
10487
10488 bool IsFullQuantity()
10489 {
10490 return GetQuantity() >= GetQuantityMax();
10491 }
10492
10493 //Calculates weight of single item without attachments and cargo
10494 override float GetSingleInventoryItemWeightEx()
10495 {
10496 //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
10497 float weightEx = GetWeightEx();//overall weight of the item
10498 float special = GetInventoryAndCargoWeight();//cargo and attachment weight
10499 return weightEx - special;
10500 }
10501
10502 // Obsolete, use GetSingleInventoryItemWeightEx() instead
10504 {
10506 }
10507
10508 override protected float GetWeightSpecialized(bool forceRecalc = false)
10509 {
10510 if (IsSplitable()) //quantity determines size of the stack
10511 {
10512 #ifdef DEVELOPER
10513 if (WeightDebug.m_VerbosityFlags & WeightDebugType.RECALC_FORCED)
10514 {
10515 WeightDebugData data1 = WeightDebug.GetWeightDebug(this);
10516 data1.SetCalcDetails("TIB1: " + GetConfigWeightModifiedDebugText() +" * " + GetQuantity()+"(quantity)");
10517 }
10518 #endif
10519
10520 return GetQuantity() * GetConfigWeightModified();
10521 }
10522 else if (HasEnergyManager())// items with energy manager
10523 {
10524 #ifdef DEVELOPER
10525 if (WeightDebug.m_VerbosityFlags & WeightDebugType.RECALC_FORCED)
10526 {
10527 WeightDebugData data2 = WeightDebug.GetWeightDebug(this);
10528 data2.SetCalcDetails("TIB2: "+super.GetWeightSpecialized(forceRecalc)+"(contents weight) + " + GetConfigWeightModifiedDebugText() +" + " + GetCompEM().GetEnergy()+"(energy) * " + ConfigGetFloat("weightPerQuantityUnit") +"(weightPerQuantityUnit)");
10529 }
10530 #endif
10531 return super.GetWeightSpecialized(forceRecalc) + (GetCompEM().GetEnergy() * ConfigGetFloat("weightPerQuantityUnit")) + GetConfigWeightModified();
10532 }
10533 else//everything else
10534 {
10535 #ifdef DEVELOPER
10536 if (WeightDebug.m_VerbosityFlags & WeightDebugType.RECALC_FORCED)
10537 {
10538 WeightDebugData data3 = WeightDebug.GetWeightDebug(this);
10539 data3.SetCalcDetails("TIB3: "+super.GetWeightSpecialized(forceRecalc)+"(contents weight) + " + GetConfigWeightModifiedDebugText() +" + " + GetQuantity()+"(quantity) * " + ConfigGetFloat("weightPerQuantityUnit") +"(weightPerQuantityUnit))");
10540 }
10541 #endif
10542 return super.GetWeightSpecialized(forceRecalc) + (GetQuantity() * ConfigGetFloat("weightPerQuantityUnit")) + GetConfigWeightModified();
10543 }
10544 }
10545
10547 int GetNumberOfItems()
10548 {
10549 int item_count = 0;
10550 ItemBase item;
10551
10552 GameInventory inventory = GetInventory();
10553 CargoBase cargo = inventory.GetCargo();
10554 if (cargo != NULL)
10555 {
10556 item_count = cargo.GetItemCount();
10557 }
10558
10559 int nAttachments = inventory.AttachmentCount();
10560 for (int i = 0; i < nAttachments; ++i)
10561 {
10562 Class.CastTo(item, inventory.GetAttachmentFromIndex(i));
10563 if (item)
10564 item_count += item.GetNumberOfItems();
10565 }
10566 return item_count;
10567 }
10568
10570 float GetUnitWeight(bool include_wetness = true)
10571 {
10572 float weight = 0;
10573 float wetness = 1;
10574 if (include_wetness)
10575 wetness += GetWet();
10576 if (IsSplitable()) //quantity determines size of the stack
10577 {
10578 weight = wetness * m_ConfigWeight;
10579 }
10580 else if (IsLiquidContainer()) //is a liquid container, default liquid weight is set to 1. May revisit later?
10581 {
10582 weight = 1;
10583 }
10584 return weight;
10585 }
10586
10587 //-----------------------------------------------------------------
10588
10589 override void ClearInventory()
10590 {
10591 GameInventory inventory = GetInventory();
10592 if ((g_Game.IsServer() || !g_Game.IsMultiplayer()) && inventory)
10593 {
10594 array<EntityAI> items = new array<EntityAI>;
10595 inventory.EnumerateInventory(InventoryTraversalType.INORDER, items);
10596 for (int i = 0; i < items.Count(); ++i)
10597 {
10598 ItemBase item = ItemBase.Cast(items.Get(i));
10599 if (item)
10600 {
10601 g_Game.ObjectDelete(item);
10602 }
10603 }
10604 }
10605 }
10606
10607 //------------------------- Energy
10608
10609 //----------------------------------------------------------------
10610 float GetEnergy()
10611 {
10612 float energy = 0;
10613 if (HasEnergyManager())
10614 {
10615 energy = GetCompEM().GetEnergy();
10616 }
10617 return energy;
10618 }
10619
10620
10621 override void OnEnergyConsumed()
10622 {
10623 super.OnEnergyConsumed();
10624
10626 }
10627
10628 override void OnEnergyAdded()
10629 {
10630 super.OnEnergyAdded();
10631
10633 }
10634
10635 // Converts energy (from Energy Manager) to quantity, if enabled.
10637 {
10638 if (g_Game.IsServer() && HasEnergyManager() && GetCompEM().HasConversionOfEnergyToQuantity())
10639 {
10640 if (HasQuantity())
10641 {
10642 float energy_0to1 = GetCompEM().GetEnergy0To1();
10643 SetQuantityNormalized(energy_0to1);
10644 }
10645 }
10646 }
10647
10648 //----------------------------------------------------------------
10649 float GetHeatIsolationInit()
10650 {
10651 return ConfigGetFloat("heatIsolation");
10652 }
10653
10654 float GetHeatIsolation()
10655 {
10656 return m_HeatIsolation;
10657 }
10658
10659 float GetDryingIncrement(string pIncrementName)
10660 {
10661 string paramPath = string.Format("CfgVehicles %1 EnvironmentWetnessIncrements Drying %2", GetType(), pIncrementName);
10662 if (g_Game.ConfigIsExisting(paramPath))
10663 return g_Game.ConfigGetFloat(paramPath);
10664
10665 return 0.0;
10666 }
10667
10668 float GetSoakingIncrement(string pIncrementName)
10669 {
10670 string paramPath = string.Format("CfgVehicles %1 EnvironmentWetnessIncrements Soaking %2", GetType(), pIncrementName);
10671 if (g_Game.ConfigIsExisting(paramPath))
10672 return g_Game.ConfigGetFloat(paramPath);
10673
10674 return 0.0;
10675 }
10676 //----------------------------------------------------------------
10677 override void SetWet(float value, bool allow_client = false)
10678 {
10679 if (!IsServerCheck(allow_client))
10680 return;
10681
10682 float min = GetWetMin();
10683 float max = GetWetMax();
10684
10685 float previousValue = m_VarWet;
10686
10687 m_VarWet = Math.Clamp(value, min, max);
10688
10689 if (previousValue != m_VarWet)
10690 {
10691 SetVariableMask(VARIABLE_WET);
10692 OnWetChanged(m_VarWet, previousValue);
10693 }
10694 }
10695 //----------------------------------------------------------------
10696 override void AddWet(float value)
10697 {
10698 SetWet(GetWet() + value);
10699 }
10700 //----------------------------------------------------------------
10701 override void SetWetMax()
10702 {
10704 }
10705 //----------------------------------------------------------------
10706 override float GetWet()
10707 {
10708 return m_VarWet;
10709 }
10710 //----------------------------------------------------------------
10711 override float GetWetMax()
10712 {
10713 return m_VarWetMax;
10714 }
10715 //----------------------------------------------------------------
10716 override float GetWetMin()
10717 {
10718 return m_VarWetMin;
10719 }
10720 //----------------------------------------------------------------
10721 override float GetWetInit()
10722 {
10723 return m_VarWetInit;
10724 }
10725 //----------------------------------------------------------------
10726 override void OnWetChanged(float newVal, float oldVal)
10727 {
10728 EWetnessLevel newLevel = GetWetLevelInternal(newVal);
10729 EWetnessLevel oldLevel = GetWetLevelInternal(oldVal);
10730 if (newLevel != oldLevel)
10731 {
10732 OnWetLevelChanged(newLevel,oldLevel);
10733 }
10734 }
10735
10736 override void OnWetLevelChanged(EWetnessLevel newLevel, EWetnessLevel oldLevel)
10737 {
10738 SetWeightDirty();
10739 }
10740
10741 override EWetnessLevel GetWetLevel()
10742 {
10743 return GetWetLevelInternal(m_VarWet);
10744 }
10745
10746 //----------------------------------------------------------------
10747
10748 override void SetStoreLoad(bool value)
10749 {
10750 m_IsStoreLoad = value;
10751 }
10752
10753 override bool IsStoreLoad()
10754 {
10755 return m_IsStoreLoad;
10756 }
10757
10758 override void SetStoreLoadedQuantity(float value)
10759 {
10760 m_StoreLoadedQuantity = value;
10761 }
10762
10763 override float GetStoreLoadedQuantity()
10764 {
10765 return m_StoreLoadedQuantity;
10766 }
10767
10768 //----------------------------------------------------------------
10769
10770 float GetItemModelLength()
10771 {
10772 if (ConfigIsExisting("itemModelLength"))
10773 {
10774 return ConfigGetFloat("itemModelLength");
10775 }
10776 return 0;
10777 }
10778
10779 float GetItemAttachOffset()
10780 {
10781 if (ConfigIsExisting("itemAttachOffset"))
10782 {
10783 return ConfigGetFloat("itemAttachOffset");
10784 }
10785 return 0;
10786 }
10787
10788 override void SetCleanness(int value, bool allow_client = false)
10789 {
10790 if (!IsServerCheck(allow_client))
10791 return;
10792
10793 int previousValue = m_Cleanness;
10794
10795 m_Cleanness = Math.Clamp(value, m_CleannessMin, m_CleannessMax);
10796
10797 if (previousValue != m_Cleanness)
10798 SetVariableMask(VARIABLE_CLEANNESS);
10799 }
10800
10801 override int GetCleanness()
10802 {
10803 return m_Cleanness;
10804 }
10805
10807 {
10808 return true;
10809 }
10810
10811 //----------------------------------------------------------------
10812 // ATTACHMENT LOCKING
10813 // Getters relevant to generic ActionLockAttachment
10814 int GetLockType()
10815 {
10816 return m_LockType;
10817 }
10818
10819 string GetLockSoundSet()
10820 {
10821 return m_LockSoundSet;
10822 }
10823
10824 //----------------------------------------------------------------
10825 //------------------------- Color
10826 // sets items color variable given color components
10827 override void SetColor(int r, int g, int b, int a)
10828 {
10833 SetVariableMask(VARIABLE_COLOR);
10834 }
10836 override void GetColor(out int r,out int g,out int b,out int a)
10837 {
10842 }
10843
10844 bool IsColorSet()
10845 {
10846 return IsVariableSet(VARIABLE_COLOR);
10847 }
10848
10850 string GetColorString()
10851 {
10852 int r,g,b,a;
10853 GetColor(r,g,b,a);
10854 r = r/255;
10855 g = g/255;
10856 b = b/255;
10857 a = a/255;
10858 return MiscGameplayFunctions.GetColorString(r, g, b, a);
10859 }
10860 //----------------------------------------------------------------
10861 //------------------------- LiquidType
10862
10863 override void SetLiquidType(int value, bool allow_client = false)
10864 {
10865 if (!IsServerCheck(allow_client))
10866 return;
10867
10868 int old = m_VarLiquidType;
10869 m_VarLiquidType = value;
10870 OnLiquidTypeChanged(old,value);
10871 SetVariableMask(VARIABLE_LIQUIDTYPE);
10872 }
10873
10874 int GetLiquidTypeInit()
10875 {
10876 return ConfigGetInt("varLiquidTypeInit");
10877 }
10878
10879 override int GetLiquidType()
10880 {
10881 return m_VarLiquidType;
10882 }
10883
10884 protected void OnLiquidTypeChanged(int oldType, int newType)
10885 {
10886 if (newType == LIQUID_NONE && GetIsFrozen())
10887 SetFrozen(false);
10888 }
10889
10891 void UpdateQuickbarShortcutVisibility(PlayerBase player)
10892 {
10893 player.SetEnableQuickBarEntityShortcut(this,!GetHierarchyParent() || GetHierarchyParent().GetInventory().AreChildrenAccessible());
10894 }
10895
10896 // -------------------------------------------------------------------------
10898 void OnInventoryEnter(Man player)
10899 {
10900 PlayerBase nplayer;
10901 if (PlayerBase.CastTo(nplayer, player))
10902 {
10903 m_CanPlayImpactSound = true;
10904 nplayer.SetEnableQuickBarEntityShortcut(this,!GetHierarchyParent() || GetHierarchyParent().GetInventory().AreChildrenAccessible());
10905 }
10906 }
10907
10908 // -------------------------------------------------------------------------
10910 void OnInventoryExit(Man player)
10911 {
10912 PlayerBase nplayer;
10913 if (PlayerBase.CastTo(nplayer,player))
10914 {
10915 nplayer.SetEnableQuickBarEntityShortcut(this, false);
10916 }
10917
10918 player.GetHumanInventory().ClearUserReservedLocationForContainer(this);
10919
10920 if (HasEnergyManager())
10921 {
10922 GetCompEM().UpdatePlugState(); // Unplug the el. device if it's necesarry.
10923 }
10924 }
10925
10926 // ADVANCED PLACEMENT EVENTS
10927 override void OnPlacementStarted(Man player)
10928 {
10929 super.OnPlacementStarted(player);
10930
10931 SetTakeable(false);
10932 }
10933
10934 override void OnPlacementComplete(Man player, vector position = "0 0 0", vector orientation = "0 0 0")
10935 {
10936 if (m_AdminLog)
10937 {
10938 m_AdminLog.OnPlacementComplete(player, this);
10939 }
10940
10941 super.OnPlacementComplete(player, position, orientation);
10942 }
10943
10944 //-----------------------------
10945 // AGENT SYSTEM
10946 //-----------------------------
10947 //--------------------------------------------------------------------------
10948 bool ContainsAgent(int agent_id)
10949 {
10950 if (agent_id & m_AttachedAgents)
10951 {
10952 return true;
10953 }
10954 else
10955 {
10956 return false;
10957 }
10958 }
10959
10960 //--------------------------------------------------------------------------
10961 override void RemoveAgent(int agent_id)
10962 {
10963 if (ContainsAgent(agent_id))
10964 {
10965 m_AttachedAgents = ~agent_id & m_AttachedAgents;
10966 }
10967 }
10968
10969 //--------------------------------------------------------------------------
10970 override void RemoveAllAgents()
10971 {
10972 m_AttachedAgents = 0;
10973 }
10974 //--------------------------------------------------------------------------
10975 override void RemoveAllAgentsExcept(int agent_to_keep)
10976 {
10977 m_AttachedAgents = m_AttachedAgents & agent_to_keep;
10978 }
10979 // -------------------------------------------------------------------------
10980 override void InsertAgent(int agent, float count = 1)
10981 {
10982 if (count < 1)
10983 return;
10984 //Debug.Log("Inserting Agent on item: " + agent.ToString() +" count: " + count.ToString());
10986 }
10987
10989 void TransferAgents(int agents)
10990 {
10992 }
10993
10994 // -------------------------------------------------------------------------
10995 override int GetAgents()
10996 {
10997 return m_AttachedAgents;
10998 }
10999 //----------------------------------------------------------------------
11000
11001 /*int GetContaminationType()
11002 {
11003 int contamination_type;
11004
11005 const int CONTAMINATED_MASK = eAgents.CHOLERA | eAgents.INFLUENZA | eAgents.SALMONELLA | eAgents.BRAIN;
11006 const int POISONED_MASK = eAgents.FOOD_POISON | eAgents.CHEMICAL_POISON;
11007 const int NERVE_GAS_MASK = eAgents.CHEMICAL_POISON;
11008 const int DIRTY_MASK = eAgents.WOUND_AGENT;
11009
11010 Edible_Base edible = Edible_Base.Cast(this);
11011 int agents = GetAgents();
11012 if (edible)
11013 {
11014 NutritionalProfile profile = Edible_Base.GetNutritionalProfile(edible);
11015 if (profile)
11016 {
11017 agents = agents | profile.GetAgents();//merge item's agents with nutritional agents
11018 }
11019 }
11020 if (agents & CONTAMINATED_MASK)
11021 {
11022 contamination_type = contamination_type | EContaminationTypes.ITEM_BADGE_CONTAMINATED;
11023 }
11024 if (agents & POISONED_MASK)
11025 {
11026 contamination_type = contamination_type | EContaminationTypes.ITEM_BADGE_POISONED;
11027 }
11028 if (agents & NERVE_GAS_MASK)
11029 {
11030 contamination_type = contamination_type | EContaminationTypes.ITEM_BADGE_NERVE_GAS;
11031 }
11032 if (agents & DIRTY_MASK)
11033 {
11034 contamination_type = contamination_type | EContaminationTypes.ITEM_BADGE_DIRTY;
11035 }
11036
11037 return agents;
11038 }*/
11039
11040 // -------------------------------------------------------------------------
11041 bool LoadAgents(ParamsReadContext ctx, int version)
11042 {
11043 if (!ctx.Read(m_AttachedAgents))
11044 return false;
11045 return true;
11046 }
11047 // -------------------------------------------------------------------------
11049 {
11050
11052 }
11053 // -------------------------------------------------------------------------
11054
11056 override void CheckForRoofLimited(float timeTresholdMS = 3000)
11057 {
11058 super.CheckForRoofLimited(timeTresholdMS);
11059
11060 float time = g_Game.GetTime();
11061 if ((time - m_PreviousRoofTestTime) >= timeTresholdMS)
11062 {
11063 m_PreviousRoofTestTime = time;
11064 SetRoofAbove(MiscGameplayFunctions.IsUnderRoof(this));
11065 }
11066 }
11067
11068 // returns item's protection level against enviromental hazard, for masks with filters, returns the filters protection for valid filter, otherwise 0
11069 float GetProtectionLevel(int type, bool consider_filter = false, int system = 0)
11070 {
11071 if (IsDamageDestroyed() || (HasQuantity() && GetQuantity() <= 0))
11072 {
11073 return 0;
11074 }
11075
11076 if (GetInventory().GetAttachmentSlotsCount() != 0)//is it an item with attachable filter ?
11077 {
11078 ItemBase filter = ItemBase.Cast(FindAttachmentBySlotName("GasMaskFilter"));
11079 if (filter)
11080 return filter.GetProtectionLevel(type, false, system);//it's a valid filter, return the protection
11081 else
11082 return 0;//otherwise return 0 when no filter attached
11083 }
11084
11085 string subclassPath, entryName;
11086
11087 switch (type)
11088 {
11089 case DEF_BIOLOGICAL:
11090 entryName = "biological";
11091 break;
11092 case DEF_CHEMICAL:
11093 entryName = "chemical";
11094 break;
11095 default:
11096 entryName = "biological";
11097 break;
11098 }
11099
11100 subclassPath = "CfgVehicles " + this.GetType() + " Protection ";
11101
11102 return g_Game.ConfigGetFloat(subclassPath + entryName);
11103 }
11104
11105
11106
11108 override void EEOnCECreate()
11109 {
11110 if (!IsMagazine())
11112
11114 }
11115
11116
11117 //-------------------------
11118 // OPEN/CLOSE USER ACTIONS
11119 //-------------------------
11121 void Open();
11122 void Close();
11123 bool IsOpen()
11124 {
11125 return true;
11126 }
11127
11128 override bool CanDisplayCargo()
11129 {
11130 return IsOpen();
11131 }
11132
11133
11134 // ------------------------------------------------------------
11135 // CONDITIONS
11136 // ------------------------------------------------------------
11137 override bool CanPutInCargo(EntityAI parent)
11138 {
11139 if (parent)
11140 {
11141 if (parent.IsInherited(DayZInfected))
11142 return true;
11143
11144 if (!parent.IsRuined())
11145 return true;
11146 }
11147
11148 return true;
11149 }
11150
11151 override bool CanPutAsAttachment(EntityAI parent)
11152 {
11153 if (!super.CanPutAsAttachment(parent))
11154 {
11155 return false;
11156 }
11157
11158 if (!IsRuined() && !parent.IsRuined())
11159 {
11160 return true;
11161 }
11162
11163 return false;
11164 }
11165
11166 override bool CanReceiveItemIntoCargo(EntityAI item)
11167 {
11168 //removed 15.06. coz of loading from storage -> after load items in cargo was lost -> waiting for proper solution
11169 //if (GetHealthLevel() == GameConstants.STATE_RUINED)
11170 // return false;
11171
11172 return super.CanReceiveItemIntoCargo(item);
11173 }
11174
11175 override bool CanReceiveAttachment(EntityAI attachment, int slotId)
11176 {
11177 //removed 15.06. coz of loading from storage -> after load items in cargo was lost -> waiting for proper solution
11178 //if (GetHealthLevel() == GameConstants.STATE_RUINED)
11179 // return false;
11180
11181 GameInventory attachmentInv = attachment.GetInventory();
11182 if (attachmentInv && attachmentInv.GetCargo() && attachmentInv.GetCargo().GetItemCount() > 0)
11183 {
11184 if (GetHierarchyParent() && !GetHierarchyParent().IsInherited(PlayerBase))
11185 return false;
11186 }
11187
11188 InventoryLocation loc = new InventoryLocation();
11189 attachment.GetInventory().GetCurrentInventoryLocation(loc);
11190 if (loc && loc.IsValid() && !GetInventory().AreChildrenAccessible())
11191 return false;
11192
11193 return super.CanReceiveAttachment(attachment, slotId);
11194 }
11195
11196 override bool CanReleaseAttachment(EntityAI attachment)
11197 {
11198 if (!super.CanReleaseAttachment(attachment))
11199 return false;
11200
11201 return GetInventory().AreChildrenAccessible();
11202 }
11203
11204 /*override bool CanLoadAttachment(EntityAI attachment)
11205 {
11206 //removed 15.06. coz of loading from storage -> after load items in cargo was lost -> waiting for proper solution
11207 //if (GetHealthLevel() == GameConstants.STATE_RUINED)
11208 // return false;
11209
11210 GameInventory attachmentInv = attachment.GetInventory();
11211 if (attachmentInv && attachmentInv.GetCargo() && attachmentInv.GetCargo().GetItemCount() > 0)
11212 {
11213 bool boo = (GetHierarchyParent() && !GetHierarchyParent().IsInherited(PlayerBase));
11214 ErrorEx("CanLoadAttachment | this: " + this + " | attachment: " + attachment + " | boo: " + boo,ErrorExSeverity.INFO);
11215
11216 if (GetHierarchyParent() && !GetHierarchyParent().IsInherited(PlayerBase))
11217 return false;
11218 }
11219
11220 return super.CanLoadAttachment(attachment);
11221 }*/
11222
11223 // Plays muzzle flash particle effects
11224 static void PlayFireParticles(ItemBase weapon, int muzzle_index, string ammoType, ItemBase muzzle_owner, ItemBase suppressor, string config_to_search)
11225 {
11226 int id = muzzle_owner.GetMuzzleID();
11227 array<ref WeaponParticlesOnFire> WPOF_array = m_OnFireEffect.Get(id);
11228
11229 if (WPOF_array)
11230 {
11231 for (int i = 0; i < WPOF_array.Count(); i++)
11232 {
11233 WeaponParticlesOnFire WPOF = WPOF_array.Get(i);
11234
11235 if (WPOF)
11236 {
11237 WPOF.OnActivate(weapon, muzzle_index, ammoType, muzzle_owner, suppressor, config_to_search);
11238 }
11239 }
11240 }
11241 }
11242
11243 // Plays bullet eject particle effects (usually just smoke, the bullet itself is a 3D model and is not part of this function)
11244 static void PlayBulletCasingEjectParticles(ItemBase weapon, string ammoType, ItemBase muzzle_owner, ItemBase suppressor, string config_to_search)
11245 {
11246 int id = muzzle_owner.GetMuzzleID();
11247 array<ref WeaponParticlesOnBulletCasingEject> WPOBE_array = m_OnBulletCasingEjectEffect.Get(id);
11248
11249 if (WPOBE_array)
11250 {
11251 for (int i = 0; i < WPOBE_array.Count(); i++)
11252 {
11253 WeaponParticlesOnBulletCasingEject WPOBE = WPOBE_array.Get(i);
11254
11255 if (WPOBE)
11256 {
11257 WPOBE.OnActivate(weapon, 0, ammoType, muzzle_owner, suppressor, config_to_search);
11258 }
11259 }
11260 }
11261 }
11262
11263 // Plays all weapon overheating particles
11264 static void PlayOverheatingParticles(ItemBase weapon, string ammoType, ItemBase muzzle_owner, ItemBase suppressor, string config_to_search)
11265 {
11266 int id = muzzle_owner.GetMuzzleID();
11267 array<ref WeaponParticlesOnOverheating> WPOOH_array = weapon.m_OnOverheatingEffect.Get(id);
11268
11269 if (WPOOH_array)
11270 {
11271 for (int i = 0; i < WPOOH_array.Count(); i++)
11272 {
11273 WeaponParticlesOnOverheating WPOOH = WPOOH_array.Get(i);
11274
11275 if (WPOOH)
11276 {
11277 WPOOH.OnActivate(weapon, 0, ammoType, muzzle_owner, suppressor, config_to_search);
11278 }
11279 }
11280 }
11281 }
11282
11283 // Updates all weapon overheating particles
11284 static void UpdateOverheatingParticles(ItemBase weapon, string ammoType, ItemBase muzzle_owner, ItemBase suppressor, string config_to_search)
11285 {
11286 int id = muzzle_owner.GetMuzzleID();
11287 array<ref WeaponParticlesOnOverheating> WPOOH_array = weapon.m_OnOverheatingEffect.Get(id);
11288
11289 if (WPOOH_array)
11290 {
11291 for (int i = 0; i < WPOOH_array.Count(); i++)
11292 {
11293 WeaponParticlesOnOverheating WPOOH = WPOOH_array.Get(i);
11294
11295 if (WPOOH)
11296 {
11297 WPOOH.OnUpdate(weapon, ammoType, muzzle_owner, suppressor, config_to_search);
11298 }
11299 }
11300 }
11301 }
11302
11303 // Stops overheating particles
11304 static void StopOverheatingParticles(ItemBase weapon, string ammoType, ItemBase muzzle_owner, ItemBase suppressor, string config_to_search)
11305 {
11306 int id = muzzle_owner.GetMuzzleID();
11307 array<ref WeaponParticlesOnOverheating> WPOOH_array = weapon.m_OnOverheatingEffect.Get(id);
11308
11309 if (WPOOH_array)
11310 {
11311 for (int i = 0; i < WPOOH_array.Count(); i++)
11312 {
11313 WeaponParticlesOnOverheating WPOOH = WPOOH_array.Get(i);
11314
11315 if (WPOOH)
11316 {
11317 WPOOH.OnDeactivate(weapon, ammoType, muzzle_owner, suppressor, config_to_search);
11318 }
11319 }
11320 }
11321 }
11322
11323 //----------------------------------------------------------------
11324 //Item Behaviour - unified approach
11325 override bool IsHeavyBehaviour()
11326 {
11327 if (m_ItemBehaviour == 0)
11328 {
11329 return true;
11330 }
11331
11332 return false;
11333 }
11334
11335 override bool IsOneHandedBehaviour()
11336 {
11337 if (m_ItemBehaviour == 1)
11338 {
11339 return true;
11340 }
11341
11342 return false;
11343 }
11344
11345 override bool IsTwoHandedBehaviour()
11346 {
11347 if (m_ItemBehaviour == 2)
11348 {
11349 return true;
11350 }
11351
11352 return false;
11353 }
11354
11355 bool IsDeployable()
11356 {
11357 return false;
11358 }
11359
11361 float GetDeployTime()
11362 {
11363 return UATimeSpent.DEFAULT_DEPLOY;
11364 }
11365
11366
11367 //----------------------------------------------------------------
11368 // Item Targeting (User Actions)
11369 override void SetTakeable(bool pState)
11370 {
11371 m_IsTakeable = pState;
11372 SetSynchDirty();
11373 }
11374
11375 override bool IsTakeable()
11376 {
11377 return m_IsTakeable;
11378 }
11379
11380 // For cases where we want to show object widget which cant be taken to hands
11382 {
11383 return false;
11384 }
11385
11387 protected void PreLoadSoundAttachmentType()
11388 {
11389 string att_type = "None";
11390
11391 if (ConfigIsExisting("soundAttType"))
11392 {
11393 att_type = ConfigGetString("soundAttType");
11394 }
11395
11396 m_SoundAttType = att_type;
11397 }
11398
11399 override string GetAttachmentSoundType()
11400 {
11401 return m_SoundAttType;
11402 }
11403
11404 //----------------------------------------------------------------
11405 //SOUNDS - ItemSoundHandler
11406 //----------------------------------------------------------------
11407
11408 string GetPlaceSoundset(); // played when deploy starts
11409 string GetLoopDeploySoundset(); // played when deploy starts and stopped when it finishes
11410 string GetDeploySoundset(); // played when deploy sucessfully finishes
11411 string GetLoopFoldSoundset(); // played when fold starts and stopped when it finishes
11412 string GetFoldSoundset(); // played when fold sucessfully finishes
11413
11415 {
11416 if (!m_ItemSoundHandler)
11418
11419 return m_ItemSoundHandler;
11420 }
11421
11422 // override to initialize sounds
11423 protected void InitItemSounds()
11424 {
11425 if (GetPlaceSoundset() == string.Empty && GetDeploySoundset() == string.Empty && GetLoopDeploySoundset() == string.Empty && !GetInventoryItemType().SetDetachSoundEvent() && !GetInventoryItemType().SetAttachSoundEvent())
11426 return;
11427
11429
11430 if (GetPlaceSoundset() != string.Empty)
11431 handler.AddSound(SoundConstants.ITEM_PLACE, GetPlaceSoundset());
11432
11433 if (GetDeploySoundset() != string.Empty)
11434 handler.AddSound(SoundConstants.ITEM_DEPLOY, GetDeploySoundset());
11435
11436 SoundParameters params = new SoundParameters();
11437 params.m_Loop = true;
11438 if (GetLoopDeploySoundset() != string.Empty)
11439 handler.AddSound(SoundConstants.ITEM_DEPLOY_LOOP, GetLoopDeploySoundset(), params);
11440 }
11441
11442 // Start sound using ItemSoundHandler
11443 void StartItemSoundServer(int id, int slotId)
11444 {
11445 if (g_Game.IsServer() || !g_Game.IsMultiplayer()) // single player or server side multiplayer
11446 {
11447 m_SoundSyncSlotID = slotId;
11448 m_SoundSyncPlay = id;
11449
11450 SetSynchDirty();
11451
11452 g_Game.GetCallQueue(CALL_CATEGORY_SYSTEM).Remove(ClearStartItemSoundServer); // in case one is queued already
11453 g_Game.GetCallQueue(CALL_CATEGORY_SYSTEM).CallLater(ClearStartItemSoundServer, 100);
11454 }
11455 }
11456
11457 void StartItemSoundServer(int id)
11458 {
11459 StartItemSoundServer(id, InventorySlots.INVALID);
11460 }
11461
11462 // Stop sound using ItemSoundHandler
11463 void StopItemSoundServer(int id)
11464 {
11465 if (!g_Game.IsServer())
11466 return;
11467
11468 m_SoundSyncStop = id;
11469 SetSynchDirty();
11470
11471 g_Game.GetCallQueue(CALL_CATEGORY_SYSTEM).Remove(ClearStopItemSoundServer); // in case one is queued already
11472 g_Game.GetCallQueue(CALL_CATEGORY_SYSTEM).CallLater(ClearStopItemSoundServer, 100);
11473 }
11474
11475 protected void ClearStartItemSoundServer()
11476 {
11477 m_SoundSyncPlay = 0;
11478 m_SoundSyncSlotID = InventorySlots.INVALID;
11479 }
11480
11481 protected void ClearStopItemSoundServer()
11482 {
11483 m_SoundSyncStop = 0;
11484 }
11485
11486 void OnApply(PlayerBase player);
11487
11489 {
11490 return 1.0;
11491 };
11492 //returns applicable selection
11493 array<string> GetHeadHidingSelection()
11494 {
11496 }
11497
11499 {
11501 }
11502
11503 WrittenNoteData GetWrittenNoteData() {};
11504
11506 {
11507 SetDynamicPhysicsLifeTime(0.01);
11508 m_ItemBeingDroppedPhys = false;
11509 }
11510
11512 {
11513 array<string> zone_names = new array<string>;
11514 GetDamageZones(zone_names);
11515 for (int i = 0; i < zone_names.Count(); i++)
11516 {
11517 SetHealthMax(zone_names.Get(i),"Health");
11518 }
11519 SetHealthMax("","Health");
11520 }
11521
11523 void SetZoneDamageCEInit()
11524 {
11525 float global_health = GetHealth01("","Health");
11526 array<string> zones = new array<string>;
11527 GetDamageZones(zones);
11528 //set damage of all zones to match global health level
11529 for (int i = 0; i < zones.Count(); i++)
11530 {
11531 SetHealth01(zones.Get(i),"Health",global_health);
11532 }
11533 }
11534
11536 bool IsCoverFaceForShave(string slot_name)
11537 {
11538 return IsExclusionFlagPresent(PlayerBase.GetFaceCoverageShaveValues());
11539 }
11540
11541 void ProcessItemWetness(float delta, bool hasParent, bool hasRootAsPlayer, ItemBase refParentIB)
11542 {
11543 if (!hasRootAsPlayer)
11544 {
11545 if (refParentIB)
11546 {
11547 // parent is wet
11548 if ((refParentIB.GetWet() >= GameConstants.STATE_SOAKING_WET) && (m_VarWet < m_VarWetMax))
11549 AddWet(delta * GameConstants.WETNESS_RATE_WETTING_INSIDE);
11550 // parent has liquid inside
11551 else if ((refParentIB.GetLiquidType() != 0) && (refParentIB.GetQuantity() > 0) && (m_VarWet < m_VarWetMax))
11552 AddWet(delta * GameConstants.WETNESS_RATE_WETTING_LIQUID);
11553 // drying
11554 else if (m_VarWet > m_VarWetMin)
11555 AddWet(-1 * delta * GetDryingIncrement("ground") * 2);
11556 }
11557 else
11558 {
11559 // drying on ground or inside non-itembase (car, ...)
11560 if (m_VarWet > m_VarWetMin)
11561 AddWet(-1 * delta * GetDryingIncrement("ground"));
11562 }
11563 }
11564 }
11565
11566 void ProcessItemTemperature(float delta, bool hasParent, bool hasRootAsPlayer, ItemBase refParentIB)
11567 {
11569 {
11570 float target = g_Game.GetMission().GetWorldData().GetBaseEnvTemperatureAtObject(this);
11571 if (GetTemperature() != target || !IsFreezeThawProgressFinished())
11572 {
11573 float heatPermCoef = 1.0;
11574 EntityAI ent = this;
11575 while (ent)
11576 {
11577 heatPermCoef *= ent.GetHeatPermeabilityCoef();
11578 ent = ent.GetHierarchyParent();
11579 }
11580
11581 SetTemperatureEx(new TemperatureDataInterpolated(target,ETemperatureAccessTypes.ACCESS_WORLD,delta,GameConstants.TEMP_COEF_WORLD,heatPermCoef));
11582 }
11583 }
11584 }
11585
11586 void HierarchyCheck(out bool hasParent, out bool hasRootAsPlayer, out ItemBase refParentIB)
11587 {
11588 // hierarchy check for an item to decide whether it has some parent and it is in some player inventory
11589 EntityAI parent = GetHierarchyParent();
11590 if (!parent)
11591 {
11592 hasParent = false;
11593 hasRootAsPlayer = false;
11594 }
11595 else
11596 {
11597 hasParent = true;
11598 hasRootAsPlayer = (GetHierarchyRootPlayer() != null);
11599 refParentIB = ItemBase.Cast(parent);
11600 }
11601 }
11602
11603 protected void ProcessDecay(float delta, bool hasRootAsPlayer)
11604 {
11605 // this is stub, implemented on Edible_Base
11606 }
11607
11608 bool CanDecay()
11609 {
11610 // return true used on selected food clases so they can decay
11611 return false;
11612 }
11613
11614 protected bool CanProcessDecay()
11615 {
11616 // this is stub, implemented on Edible_Base class
11617 // used to determine whether it is still necessary for the food to decay
11618 return false;
11619 }
11620
11621 protected bool CanHaveWetness()
11622 {
11623 // return true used on selected items that have a wetness effect
11624 return false;
11625 }
11626
11628 bool CanBeConsumed(ConsumeConditionData data = null)
11629 {
11630 return !GetIsFrozen() && IsOpen();
11631 }
11632
11633 override void ProcessVariables()
11634 {
11635 bool hasParent = false, hasRootAsPlayer = false;
11636 ItemBase refParentIB;
11637
11638 bool wwtu = g_Game.IsWorldWetTempUpdateEnabled();
11639 bool foodDecay = g_Game.IsFoodDecayEnabled();
11640
11641 if (wwtu || foodDecay)
11642 {
11643 bool processWetness = wwtu && CanHaveWetness();
11644 bool processTemperature = wwtu && CanHaveTemperature();
11645 bool processDecay = foodDecay && CanDecay() && CanProcessDecay();
11646
11647 if (processWetness || processTemperature || processDecay)
11648 {
11649 HierarchyCheck(hasParent, hasRootAsPlayer, refParentIB);
11650
11651 if (processWetness)
11652 ProcessItemWetness(m_ElapsedSinceLastUpdate, hasParent, hasRootAsPlayer, refParentIB);
11653
11654 if (processTemperature)
11655 ProcessItemTemperature(m_ElapsedSinceLastUpdate, hasParent, hasRootAsPlayer, refParentIB);
11656
11657 if (processDecay)
11658 ProcessDecay(m_ElapsedSinceLastUpdate, hasRootAsPlayer);
11659 }
11660 }
11661 }
11662
11665 {
11666 return m_TemperaturePerQuantityWeight * GameConstants.ITEM_TEMPERATURE_QUANTITY_WEIGHT_MULTIPLIER;
11667 }
11668
11669 override float GetTemperatureFreezeThreshold()
11670 {
11672 return Liquid.GetFreezeThreshold(GetLiquidType());
11673
11674 return super.GetTemperatureFreezeThreshold();
11675 }
11676
11677 override float GetTemperatureThawThreshold()
11678 {
11680 return Liquid.GetThawThreshold(GetLiquidType());
11681
11682 return super.GetTemperatureThawThreshold();
11683 }
11684
11685 override float GetItemOverheatThreshold()
11686 {
11688 return Liquid.GetBoilThreshold(GetLiquidType());
11689
11690 return super.GetItemOverheatThreshold();
11691 }
11692
11693 override float GetTemperatureFreezeTime()
11694 {
11695 if (HasQuantity())
11696 return Math.Lerp(GameConstants.TEMPERATURE_TIME_FREEZE_MIN,Math.Max(GameConstants.TEMPERATURE_TIME_FREEZE_MIN,super.GetTemperatureFreezeTime()),GetQuantityNormalized());
11697
11698 return super.GetTemperatureFreezeTime();
11699 }
11700
11701 override float GetTemperatureThawTime()
11702 {
11703 if (HasQuantity())
11704 return Math.Lerp(GameConstants.TEMPERATURE_TIME_THAW_MIN,Math.Max(GameConstants.TEMPERATURE_TIME_FREEZE_MIN,super.GetTemperatureThawTime()),GetQuantityNormalized());
11705
11706 return super.GetTemperatureThawTime();
11707 }
11708
11710 void AffectLiquidContainerOnFill(int liquid_type, float amount);
11712 void AffectLiquidContainerOnTransfer(int liquidType, float amount, float sourceLiquidTemperature);
11713
11714 bool IsCargoException4x3(EntityAI item)
11715 {
11716 return (item.IsKindOf("Cauldron") || item.IsKindOf("Pot") || item.IsKindOf("FryingPan") || item.IsKindOf("SmallProtectorCase") || (item.IsKindOf("PortableGasStove") && item.FindAttachmentBySlotName("CookingEquipment")));
11717 }
11718
11720 {
11721 MiscGameplayFunctions.TransferItemProperties(oldItem, this);
11722 }
11723
11725 void AddLightSourceItem(ItemBase lightsource)
11726 {
11727 m_LightSourceItem = lightsource;
11728 }
11729
11731 {
11732 m_LightSourceItem = null;
11733 }
11734
11736 {
11737 return m_LightSourceItem;
11738 }
11739
11741 array<int> GetValidFinishers()
11742 {
11743 return null;
11744 }
11745
11747 bool GetActionWidgetOverride(out typename name)
11748 {
11749 return false;
11750 }
11751
11752 bool PairWithDevice(notnull ItemBase otherDevice)
11753 {
11754 if (g_Game.IsServer())
11755 {
11756 ItemBase explosive = otherDevice;
11758 if (!trg)
11759 {
11760 trg = RemoteDetonatorTrigger.Cast(otherDevice);
11761 explosive = this;
11762 }
11763
11764 explosive.PairRemote(trg);
11765 trg.SetControlledDevice(explosive);
11766
11767 int persistentID = RemotelyActivatedItemBehaviour.GeneratePersistentID();
11768 trg.SetPersistentPairID(persistentID);
11769 explosive.SetPersistentPairID(persistentID);
11770
11771 return true;
11772 }
11773 return false;
11774 }
11775
11777 float GetBaitEffectivity()
11778 {
11779 float ret = 1.0;
11780 if (HasQuantity())
11781 ret *= GetQuantityNormalized();
11782 ret *= GetHealth01();
11783
11784 return ret;
11785 }
11786
11787 #ifdef DEVELOPER
11788 override void SetDebugItem()
11789 {
11790 super.SetDebugItem();
11791 _itemBase = this;
11792 }
11793
11794 override string GetDebugText()
11795 {
11796 string text = super.GetDebugText();
11797
11798 text += string.Format("Heat isolation(raw): %1\n", GetHeatIsolation());
11799 text += string.Format("Heat isolation(modified): %1\n", MiscGameplayFunctions.GetCurrentItemHeatIsolation(this));
11800
11801 return text;
11802 }
11803 #endif
11804
11805 bool CanBeUsedForSuicide()
11806 {
11807 return true;
11808 }
11809
11811 //DEPRECATED BELOW
11813 // Backwards compatibility
11814 void ProcessItemWetnessAndTemperature(float delta, bool hasParent, bool hasRootAsPlayer, ItemBase refParentIB)
11815 {
11816 ProcessItemWetness(delta, hasParent, hasRootAsPlayer, refParentIB);
11817 ProcessItemTemperature(delta, hasParent, hasRootAsPlayer, refParentIB);
11818 }
11819
11820 // replaced by ItemSoundHandler
11821 protected EffectSound m_SoundDeployFinish;
11822 protected EffectSound m_SoundPlace;
11823 protected EffectSound m_DeployLoopSoundEx;
11824 protected EffectSound m_SoundDeploy;
11825 bool m_IsPlaceSound;
11826 bool m_IsDeploySound;
11828
11829 string GetDeployFinishSoundset();
11830 void PlayDeploySound();
11831 void PlayDeployFinishSound();
11832 void PlayPlaceSound();
11833 void PlayDeployLoopSoundEx();
11834 void StopDeployLoopSoundEx();
11835 void SoundSynchRemoteReset();
11836 void SoundSynchRemote();
11837 bool UsesGlobalDeploy(){return false;}
11838 bool CanPlayDeployLoopSound(){return false;}
11840 bool IsPlaceSound(){return m_IsPlaceSound;}
11841 bool IsDeploySound(){return m_IsDeploySound;}
11842 void SetIsPlaceSound(bool is_place_sound);
11843 void SetIsDeploySound(bool is_deploy_sound);
11844
11845 [Obsolete("Use ItemSoundHandler instead")]
11847 void PlayAttachSound(string slot_type)
11848 {
11849 if (!g_Game.IsDedicatedServer())
11850 {
11851 if (ConfigIsExisting("attachSoundSet"))
11852 {
11853 string cfg_path = "";
11854 string soundset = "";
11855 string type_name = GetType();
11856
11857 TStringArray cfg_soundset_array = new TStringArray;
11858 TStringArray cfg_slot_array = new TStringArray;
11859 ConfigGetTextArray("attachSoundSet",cfg_soundset_array);
11860 ConfigGetTextArray("attachSoundSlot",cfg_slot_array);
11861
11862 if (cfg_soundset_array.Count() > 0 && cfg_soundset_array.Count() == cfg_slot_array.Count())
11863 {
11864 for (int i = 0; i < cfg_soundset_array.Count(); i++)
11865 {
11866 if (cfg_slot_array[i] == slot_type)
11867 {
11868 soundset = cfg_soundset_array[i];
11869 break;
11870 }
11871 }
11872 }
11873
11874 if (soundset != "")
11875 {
11876 EffectSound sound = SEffectManager.PlaySound(soundset, GetPosition());
11877 sound.SetAutodestroy(true);
11878 }
11879 }
11880 }
11881 }
11882
11883 void PlayDetachSound(string slot_type) {}
11884}
11885
11886EntityAI SpawnItemOnLocation(string object_name, notnull InventoryLocation loc, bool full_quantity)
11887{
11888 EntityAI entity = SpawnEntity(object_name, loc, ECE_IN_INVENTORY, RF_DEFAULT);
11889 if (entity)
11890 {
11891 bool is_item = entity.IsInherited(ItemBase);
11892 if (is_item && full_quantity)
11893 {
11894 ItemBase item = ItemBase.Cast(entity);
11895 item.SetQuantity(item.GetQuantityInit());
11896 }
11897 }
11898 else
11899 {
11900 ErrorEx("Cannot spawn entity: " + object_name,ErrorExSeverity.INFO);
11901 return NULL;
11902 }
11903 return entity;
11904}
11905
11906void SetupSpawnedItem(ItemBase item, float health, float quantity)
11907{
11908 if (item)
11909 {
11910 if (health > 0)
11911 item.SetHealth("", "", health);
11912
11913 if (item.CanHaveTemperature())
11914 {
11915 item.SetTemperatureDirect(GameConstants.ITEM_TEMPERATURE_NEUTRAL_ZONE_MIDDLE);
11916 if (item.CanFreeze())
11917 item.SetFrozen(false);
11918 }
11919
11920 if (item.HasEnergyManager())
11921 {
11922 if (quantity >= 0)
11923 {
11924 item.GetCompEM().SetEnergy0To1(quantity);
11925 }
11926 else
11927 {
11928 item.GetCompEM().SetEnergy(Math.AbsFloat(quantity));
11929 }
11930 }
11931 else if (item.IsMagazine())
11932 {
11933 Magazine mag = Magazine.Cast(item);
11934 if (quantity >= 0)
11935 {
11936 mag.ServerSetAmmoCount(mag.GetAmmoMax() * quantity);
11937 }
11938 else
11939 {
11940 mag.ServerSetAmmoCount(Math.AbsFloat(quantity));
11941 }
11942
11943 }
11944 else
11945 {
11946 if (quantity >= 0)
11947 {
11948 item.SetQuantityNormalized(quantity, false);
11949 }
11950 else
11951 {
11952 item.SetQuantity(Math.AbsFloat(quantity));
11953 }
11954
11955 }
11956 }
11957}
11958
11959#ifdef DEVELOPER
11960ItemBase _itemBase;//watched item goes here(LCTRL+RMB->Watch)
11961#endif
Param4< int, int, string, int > TSelectableActionInfoWithColor
Param3 TSelectableActionInfo
EWetnessLevel
Определения 3_Game/DayZ/Entities/EntityAI.c:2
bool SetAttachSoundEvent()
void InventoryItemType()
bool SetDetachSoundEvent()
InventoryMode
NOTE: PREDICTIVE is not to be used at all in multiplayer.
const int INPUT_UDT_ITEM_MANIPULATION
class LogManager EntityAI
eBleedingSourceType GetType()
ItemSuppressor SuppressorBase
void ActionDropItem()
Определения ActionDropItem.c:34
void ActionManagerBase(PlayerBase player)
Определения ActionManagerBase.c:63
map< typename, ref array< ActionBase_Basic > > TInputActionMap
Определения ActionManagerClient.c:1
void AddAction(typename actionName)
Определения AdvancedCommunication.c:220
void RemoveAction(typename actionName)
Определения AdvancedCommunication.c:252
TInputActionMap m_InputActionMap
Определения AdvancedCommunication.c:137
bool m_ActionsInitialize
Определения AdvancedCommunication.c:138
override void GetActions(typename action_input_type, out array< ActionBase_Basic > actions)
Определения AdvancedCommunication.c:202
void InitializeActions()
Определения AdvancedCommunication.c:190
string Debug()
Определения CachedEquipmentStorageBase.c:29
const int ECE_PLACE_ON_SURFACE
Определения CentralEconomy.c:37
proto native void SpawnEntity(string sClassName, vector vPos, float fRange, int iCount)
Spawn an entity through CE.
const int ECE_IN_INVENTORY
Определения CentralEconomy.c:36
const int RF_DEFAULT
Определения CentralEconomy.c:65
PlayerSpawnPresetDiscreteItemSetSlotData name
one set for cargo
PlayerSpawnPreset slotName
Open
Implementations only.
override void EEOnCECreate()
Определения ContaminatedArea_Dynamic.c:42
map
Определения ControlsXboxNew.c:4
CookingMethodType
Определения Cooking.c:2
DamageType
exposed from C++ (do not change)
Определения DamageSystem.c:11
DayZGame g_Game
Определения DayZGame.c:3942
DayZGame GetDayZGame()
Определения DayZGame.c:3944
EActions
Определения EActions.c:2
ERPCs
Определения ERPCs.c:2
PluginAdminLog m_AdminLog
Определения EmoteManager.c:159
const int MIN
Определения EnConvert.c:28
const int MAX
Определения EnConvert.c:27
float GetTemperature()
Определения Environment.c:500
override bool IsExplosive()
Определения ExplosivesBase.c:59
override bool IsPrepareToDelete()
Определения FireplaceBase.c:643
override bool CanHaveTemperature()
Определения FireplaceBase.c:561
class GP5GasMask extends MaskBase ItemBase
proto GizmoApi GetGizmoApi()
Empty
Определения Hand_States.c:14
FindInventoryLocationType
flags for searching locations in inventory
Определения InventoryLocation.c:18
InventoryLocationType
types of Inventory Location
Определения InventoryLocation.c:4
class BoxCollidingParams component
ComponentInfo for BoxCollidingResult.
bool DamageItemInCargo(float damage)
Определения ItemBase.c:6453
static bool HasDebugActionsMask(int mask)
Определения ItemBase.c:5680
bool HidesSelectionBySlot()
Определения ItemBase.c:9413
float m_VarWetMin
Определения ItemBase.c:4937
void SplitItem(PlayerBase player)
Определения ItemBase.c:6908
void CopyScriptPropertiesFrom(EntityAI oldItem)
Определения ItemBase.c:9634
override void InsertAgent(int agent, float count=1)
Определения ItemBase.c:8895
override float GetQuantityNormalized()
Gets quantity in normalized 0..1 form between the item's Min a Max values as defined by item's config...
Определения ItemBase.c:8330
static void SetDebugActionsMask(int mask)
Определения ItemBase.c:5685
void SetIsDeploySound(bool is_deploy_sound)
bool IsOpen()
Определения ItemBase.c:9038
void SplitItemToInventoryLocation(notnull InventoryLocation dst)
Определения ItemBase.c:6875
override bool IsHeavyBehaviour()
Определения ItemBase.c:9240
override void SetWetMax()
Определения ItemBase.c:8616
bool IsCoverFaceForShave(string slot_name)
DEPRECATED in use, but returns correct values nontheless. Check performed elsewhere.
Определения ItemBase.c:9451
void ClearStartItemSoundServer()
Определения ItemBase.c:9390
float m_VarWet
Определения ItemBase.c:4934
void ProcessItemTemperature(float delta, bool hasParent, bool hasRootAsPlayer, ItemBase refParentIB)
Определения ItemBase.c:9481
map< typename, ref ActionOverrideData > TActionAnimOverrideMap
Определения ItemBase.c:3
override void RemoveAllAgentsExcept(int agent_to_keep)
Определения ItemBase.c:8890
static ref map< int, ref array< ref WeaponParticlesOnBulletCasingEject > > m_OnBulletCasingEjectEffect
Определения ItemBase.c:4997
bool CanBeMovedOverride()
Определения ItemBase.c:7600
override void SetWet(float value, bool allow_client=false)
Определения ItemBase.c:8592
ref TIntArray m_SingleUseActions
Определения ItemBase.c:4983
void StartItemSoundServer(int id, int slotId)
Определения ItemBase.c:9358
override void ProcessVariables()
Определения ItemBase.c:9548
ref TStringArray m_HeadHidingSelections
Определения ItemBase.c:5011
float GetWeightSpecialized(bool forceRecalc=false)
Определения ItemBase.c:8423
bool LoadAgents(ParamsReadContext ctx, int version)
Определения ItemBase.c:8956
void UpdateQuickbarShortcutVisibility(PlayerBase player)
To be called on moving item within character's inventory; 'player' should never be null.
Определения ItemBase.c:8806
void OverrideActionAnimation(typename action, int commandUID, int stanceMask=-1, int commandUIDProne=-1)
Определения ItemBase.c:5271
ref array< ref OverheatingParticle > m_OverheatingParticles
Определения ItemBase.c:5009
override float GetTemperatureFreezeThreshold()
Определения ItemBase.c:9584
bool m_IsSoundSynchRemote
Определения ItemBase.c:9742
float m_OverheatingShots
Определения ItemBase.c:5004
void StopItemSoundServer(int id)
Определения ItemBase.c:9378
static void ToggleDebugActionsMask(int mask)
Определения ItemBase.c:5700
void IncreaseOverheating(ItemBase weapon, string ammoType, ItemBase muzzle_owner, ItemBase suppressor, string config_to_search)
Определения ItemBase.c:5424
override float GetTemperatureFreezeTime()
Определения ItemBase.c:9608
ref array< int > m_CompatibleLocks
Определения ItemBase.c:5021
bool CanBeCooked()
Определения ItemBase.c:7556
override void CombineItemsClient(EntityAI entity2, bool use_stack_max=true)
Определения ItemBase.c:5767
float m_TemperaturePerQuantityWeight
Определения ItemBase.c:5035
bool m_RecipesInitialized
Определения ItemBase.c:4919
void SplitIntoStackMax(EntityAI destination_entity, int slot_id, PlayerBase player)
Определения ItemBase.c:6546
override float GetTemperatureThawThreshold()
Определения ItemBase.c:9592
override void OnEnergyConsumed()
Определения ItemBase.c:8536
void RefreshAudioVisualsOnClient(CookingMethodType cooking_method, bool is_done, bool is_empty, bool is_burned)
cooking-related effect methods
Определения Bottle_Base.c:158
int GetNumberOfItems()
Returns the number of items in cargo, otherwise returns 0(non-cargo objects). Recursive.
Определения ItemBase.c:8462
override EWetnessLevel GetWetLevel()
Определения ItemBase.c:8656
float GetSingleInventoryItemWeight()
Определения ItemBase.c:8418
ref TIntArray m_InteractActions
Определения ItemBase.c:4985
void MessageToOwnerStatus(string text)
Send message to owner player in grey color.
Определения ItemBase.c:7620
float m_VarQuantity
Определения ItemBase.c:4925
bool CanPlayDeployLoopSound()
Определения ItemBase.c:9753
override float GetWetMax()
Определения ItemBase.c:8626
bool CanBeUsedForSuicide()
Определения ItemBase.c:9720
override void CombineItemsEx(EntityAI entity2, bool use_stack_max=true)
Определения ItemBase.c:7193
void OnItemInHandsPlayerSwimStart(PlayerBase player)
void SetIsHologram(bool is_hologram)
Определения ItemBase.c:5905
void OnSyncVariables(ParamsReadContext ctx)
DEPRECATED (most likely)
Определения ItemBase.c:7774
void DoAmmoExplosion()
Определения ItemBase.c:6388
static ref map< int, ref array< ref WeaponParticlesOnFire > > m_OnFireEffect
Определения ItemBase.c:4996
void SplitIntoStackMaxCargoClient(EntityAI destination_entity, int idx, int row, int col)
Определения ItemBase.c:6732
int GetItemSize()
Определения ItemBase.c:7585
bool m_CanBeMovedOverride
Определения ItemBase.c:4962
override string ChangeIntoOnAttach(string slot)
Определения ItemBase.c:6312
void UpdateOverheating(ItemBase weapon=null, string ammoType="", ItemBase muzzle_owner=null, ItemBase suppressor=null, string config_to_search="")
Определения ItemBase.c:5492
bool CanDecay()
Определения ItemBase.c:9523
ScriptedLightBase GetLight()
string GetPlaceSoundset()
bool AddQuantity(float value, bool destroy_config=true, bool destroy_forced=false)
add item quantity[related to varQuantity... config entry], destroy_config = true > if the quantity re...
Определения ItemBase.c:8303
void SetQuantityMax()
Определения ItemBase.c:8308
override float GetQuantity()
Определения ItemBase.c:8398
int m_ColorComponentR
Определения ItemBase.c:4974
int m_ShotsToStartOverheating
Определения ItemBase.c:5006
override void OnWetChanged(float newVal, float oldVal)
Определения ItemBase.c:8641
void StopOverheating(ItemBase weapon=null, string ammoType="", ItemBase muzzle_owner=null, ItemBase suppressor=null, string config_to_search="")
Определения ItemBase.c:5499
static void PlayFireParticles(ItemBase weapon, int muzzle_index, string ammoType, ItemBase muzzle_owner, ItemBase suppressor, string config_to_search)
Определения ItemBase.c:9139
void OnOverheatingDecay()
Определения ItemBase.c:5462
float GetDryingIncrement(string pIncrementName)
Определения ItemBase.c:8574
void SoundSynchRemoteReset()
int m_Cleanness
Определения ItemBase.c:4940
bool HasMuzzle()
Returns true if this item has a muzzle (weapons, suppressors)
Определения ItemBase.c:5600
bool UsesGlobalDeploy()
Определения ItemBase.c:9752
int m_ItemBehaviour
Определения ItemBase.c:4955
override bool CanReleaseAttachment(EntityAI attachment)
Определения ItemBase.c:9111
float m_HeatIsolation
Определения ItemBase.c:4950
float m_VarWetInit
Определения ItemBase.c:4936
override void OnMovedInsideCargo(EntityAI container)
Определения ItemBase.c:5945
void SetCEBasedQuantity()
Определения ItemBase.c:5713
bool m_CanPlayImpactSound
Определения ItemBase.c:4946
override string GetAttachmentSoundType()
Определения ItemBase.c:9314
float GetOverheatingCoef()
Определения ItemBase.c:5519
array< string > GetHeadHidingSelection()
Определения ItemBase.c:9408
void PlayAttachSound(string slot_type)
Plays sound on item attach. Be advised, the config structure may slightly change in 1....
Определения ItemBase.c:9762
override bool IsStoreLoad()
Определения ItemBase.c:8668
int ComputeQuantityUsed(ItemBase other_item, bool use_stack_max=true)
Определения ItemBase.c:7169
bool IsLightSource()
Определения ItemBase.c:5841
bool m_HasQuantityBar
Определения ItemBase.c:4968
void SetResultOfSplit(bool value)
Определения ItemBase.c:7164
void SplitIntoStackMaxCargo(EntityAI destination_entity, int idx, int row, int col)
Определения ItemBase.c:6796
void OnAttachmentQuantityChanged(ItemBase item)
Called on server side when some attachment's quantity is changed. Call super.OnAttachmentQuantityChan...
Определения ItemBase.c:6965
void UpdateAllOverheatingParticles()
Определения ItemBase.c:5527
float GetSoakingIncrement(string pIncrementName)
Определения ItemBase.c:8583
static void StopOverheatingParticles(ItemBase weapon, string ammoType, ItemBase muzzle_owner, ItemBase suppressor, string config_to_search)
Определения ItemBase.c:9219
override float GetStoreLoadedQuantity()
Определения ItemBase.c:8678
int m_LockType
Определения ItemBase.c:5022
const int ITEM_SOUNDS_MAX
Определения ItemBase.c:5027
bool m_CanBeDigged
Определения ItemBase.c:4969
float m_ItemAttachOffset
Определения ItemBase.c:4952
float GetItemModelLength()
Определения ItemBase.c:8685
bool m_ThrowItemOnDrop
Определения ItemBase.c:4960
override bool ReadVarsFromCTX(ParamsReadContext ctx, int version=-1)
Определения ItemBase.c:7919
override void CheckForRoofLimited(float timeTresholdMS=3000)
Roof check for entity, limited by time (anti-spam solution)
Определения ItemBase.c:8971
void Close()
float GetHeatIsolation()
Определения ItemBase.c:8569
void CombineItems(ItemBase other_item, bool use_stack_max=true)
Определения ItemBase.c:7198
void TransferModifiers(PlayerBase reciever)
appears to be deprecated, legacy code
float GetTemperaturePerQuantityWeight()
Used in heat comfort calculations only!
Определения ItemBase.c:9579
bool CanHaveWetness()
Определения ItemBase.c:9536
int m_CleannessMin
Определения ItemBase.c:4942
void TransferAgents(int agents)
transfer agents from another item
Определения ItemBase.c:8904
string IDToName(int id)
Определения ItemBase.c:7767
bool CanBeConsumed(ConsumeConditionData data=null)
Items cannot be consumed if frozen by default. Override for exceptions.
Определения ItemBase.c:9543
float GetHeatIsolationInit()
Определения ItemBase.c:8564
void PlayPlaceSound()
void SetCanBeMovedOverride(bool setting)
Определения ItemBase.c:7607
override bool HasQuantity()
Определения ItemBase.c:8393
float m_VarWetPrev
Определения ItemBase.c:4935
int m_SoundSyncStop
Определения ItemBase.c:5029
bool IsCargoException4x3(EntityAI item)
Определения ItemBase.c:9629
ref TIntArray m_ContinuousActions
Определения ItemBase.c:4984
int GetMuzzleID()
Returns global muzzle ID. If not found, then it gets automatically registered.
Определения ItemBase.c:5609
void LoadParticleConfigOnFire(int id)
Определения ItemBase.c:5294
int m_VarLiquidType
Определения ItemBase.c:4954
int m_QuickBarBonus
Определения ItemBase.c:4956
void PreLoadSoundAttachmentType()
Attachment Sound Type getting from config file.
Определения ItemBase.c:9302
override float GetWetInit()
Определения ItemBase.c:8636
int m_ImpactSoundSurfaceHash
Определения ItemBase.c:4948
int m_SoundSyncPlay
Определения ItemBase.c:5028
int m_MaxOverheatingValue
Определения ItemBase.c:5007
void SetupSpawnedItem(ItemBase item, float health, float quantity)
Определения ItemBase.c:4931
bool m_IsTakeable
Определения ItemBase.c:4959
bool ShouldSplitQuantity(float quantity)
Определения ItemBase.c:6503
static ref map< string, int > m_WeaponTypeToID
Определения ItemBase.c:4999
string GetLockSoundSet()
Определения ItemBase.c:8734
string GetColorString()
Returns item's PROCEDURAL color as formated string, i.e. "#(argb,8,8,3)color(0.15,...
Определения ItemBase.c:8765
array< int > GetValidFinishers()
returns an array of possible finishers
Определения ItemBase.c:9656
void OnAttachmentQuantityChangedEx(ItemBase item, float delta)
Called on server side when some attachment's quantity is changed. Call super.OnAttachmentQuantityChan...
Определения ItemBase.c:6971
class ItemBase extends InventoryItem SpawnItemOnLocation(string object_name, notnull InventoryLocation loc, bool full_quantity)
Определения ItemBase.c:4911
ItemSoundHandler GetItemSoundHandler()
Определения ItemBase.c:9329
override int GetQuantityMin()
Определения ItemBase.c:8382
void SplitIntoStackMaxToInventoryLocationClient(notnull InventoryLocation dst)
Определения ItemBase.c:6711
override int GetQuickBarBonus()
Определения ItemBase.c:5179
override void SetTakeable(bool pState)
Определения ItemBase.c:9284
float m_OverheatingDecayInterval
Определения ItemBase.c:5008
void SetIsPlaceSound(bool is_place_sound)
override void SplitIntoStackMaxClient(EntityAI destination_entity, int slot_id)
Определения ItemBase.c:6523
void HierarchyCheck(out bool hasParent, out bool hasRootAsPlayer, out ItemBase refParentIB)
Определения ItemBase.c:9501
bool CanProcessDecay()
Определения ItemBase.c:9529
void RemoveAudioVisualsOnClient()
Определения Bottle_Base.c:151
void SoundSynchRemote()
static void AddDebugActionsMask(int mask)
Определения ItemBase.c:5690
void PlayDeployLoopSoundEx()
void RemoveLightSourceItem()
Определения ItemBase.c:9645
bool CanRepair(ItemBase item_repair_kit)
Определения ItemBase.c:7571
bool can_this_be_combined
Определения ItemBase.c:4964
EffectSound m_SoundDeploy
Определения ItemBase.c:9739
int m_SoundSyncSlotID
Определения ItemBase.c:5030
int m_Count
Определения ItemBase.c:4930
float GetBaitEffectivity()
generic effectivity as a bait for animal catching
Определения ItemBase.c:9692
float GetDeployTime()
how long it takes to deploy this item in seconds
Определения ItemBase.c:9276
override bool IsSplitable()
Определения ItemBase.c:6490
bool DamageItemAttachments(float damage)
Определения ItemBase.c:6473
override void WriteVarsToCTX(ParamsWriteContext ctx)
Определения ItemBase.c:7883
void ConvertEnergyToQuantity()
Определения ItemBase.c:8551
override void RemoveAllAgents()
Определения ItemBase.c:8885
override void SetQuantityToMinimum()
Определения ItemBase.c:8314
bool m_WantPlayImpactSound
Определения ItemBase.c:4945
override float GetTemperatureThawTime()
Определения ItemBase.c:9616
ref map< int, ref array< ref WeaponParticlesOnOverheating > > m_OnOverheatingEffect
Определения ItemBase.c:4998
int m_ColorComponentG
Определения ItemBase.c:4975
float m_StoreLoadedQuantity
Определения ItemBase.c:4932
void MessageToOwnerAction(string text)
Send message to owner player in yellow color.
Определения ItemBase.c:7638
int m_ColorComponentA
Определения ItemBase.c:4977
int m_VarQuantityInit
Определения ItemBase.c:4927
float GetFilterDamageRatio()
Определения ItemBase.c:5594
override void SetLiquidType(int value, bool allow_client=false)
Определения ItemBase.c:8778
void OnQuantityChanged(float delta)
Called on server side when this item's quantity is changed. Call super.OnQuantityChanged(); first whe...
Определения ItemBase.c:6942
void OnApply(PlayerBase player)
override void SetQuantityNormalized(float value, bool destroy_config=true, bool destroy_forced=false)
Sets quantity in normalized 0..1 form between the item's Min a Max values as defined by item's config...
Определения ItemBase.c:8321
bool m_HideSelectionsBySlot
Определения ItemBase.c:5012
bool IsOverheatingEffectActive()
Определения ItemBase.c:5457
void SetIsBeingPlaced(bool is_being_placed)
Определения ItemBase.c:5874
int GetLiquidContainerMask()
Определения ItemBase.c:5811
void SetInventoryLocationToVicinityOrCurrent(EntityAI root, inout InventoryLocation dst)
Определения ItemBase.c:7078
ref Timer m_CheckOverheating
Определения ItemBase.c:5005
void RegisterOverheatingParticle(Particle p, float min_heat_coef, float max_heat_coef, int particle_id, Object parent, vector local_pos, vector local_ori)
Определения ItemBase.c:5505
float GetEnergy()
Определения ItemBase.c:8525
bool CanBeDigged()
Определения ItemBase.c:5890
bool GetActionWidgetOverride(out typename name)
If we need a different (handheld)item action widget displayed, the logic goes in here.
Определения ItemBase.c:9662
bool IsNVG()
Определения ItemBase.c:5822
float GetUnitWeight(bool include_wetness=true)
Obsolete, use GetWeightEx instead.
Определения ItemBase.c:8485
void SetZoneDamageCEInit()
Sets zone damages to match randomized global health set by CE (CE spawn only)
Определения ItemBase.c:9438
bool m_IsDeploySound
Определения ItemBase.c:9741
bool CanEat()
Определения ItemBase.c:7531
static void PlayOverheatingParticles(ItemBase weapon, string ammoType, ItemBase muzzle_owner, ItemBase suppressor, string config_to_search)
Определения ItemBase.c:9179
override bool IsOneHandedBehaviour()
Определения ItemBase.c:9250
void AddLightSourceItem(ItemBase lightsource)
Adds a light source child.
Определения ItemBase.c:9640
bool IsLiquidContainer()
Определения ItemBase.c:5806
FoodStage GetFoodStage()
overridden on Edible_Base; so we don't have to parse configs all the time
Определения ItemBase.c:7551
override float GetSingleInventoryItemWeightEx()
Определения ItemBase.c:8409
void SaveAgents(ParamsWriteContext ctx)
Определения ItemBase.c:8963
override int GetTargetQuantityMax(int attSlotID=-1)
Определения ItemBase.c:8363
int m_CleannessInit
Определения ItemBase.c:4941
float GetDisinfectQuantity(int system=0, Param param1=null)
Определения ItemBase.c:5589
override int GetAgents()
Определения ItemBase.c:8910
int m_VarQuantityMax
Определения ItemBase.c:4929
override bool IsHologram()
Определения ItemBase.c:5885
float GetItemAttachOffset()
Определения ItemBase.c:8694
bool IsPlaceSound()
Определения ItemBase.c:9755
static int GetDebugActionsMask()
Определения ItemBase.c:5675
override int GetLiquidType()
Определения ItemBase.c:8794
void ProcessDecay(float delta, bool hasRootAsPlayer)
Определения ItemBase.c:9518
override bool IsItemBase()
Определения ItemBase.c:7684
void PlayDeploySound()
override bool IsTwoHandedBehaviour()
Определения ItemBase.c:9260
void ExplodeAmmo()
Определения ItemBase.c:6375
bool IsCombineAll(ItemBase other_item, bool use_stack_max=false)
Определения ItemBase.c:7154
float GetProtectionLevel(int type, bool consider_filter=false, int system=0)
Определения ItemBase.c:8984
static void PlayBulletCasingEjectParticles(ItemBase weapon, string ammoType, ItemBase muzzle_owner, ItemBase suppressor, string config_to_search)
Определения ItemBase.c:9159
override void OnEnergyAdded()
Определения ItemBase.c:8543
void AffectLiquidContainerOnFill(int liquid_type, float amount)
from enviro source
void AffectLiquidContainerOnTransfer(int liquidType, float amount, float sourceLiquidTemperature)
from other liquid container source
string GetExplosiveTriggerSlotName()
Определения ItemBase.c:5834
EffectSound m_DeployLoopSoundEx
Определения ItemBase.c:9738
override void DeSerializeNumericalVars(array< float > floats)
Определения ItemBase.c:7824
void StopItemDynamicPhysics()
Определения ItemBase.c:9420
bool HasFoodStage()
Определения ItemBase.c:7544
override void SetStoreLoad(bool value)
Определения ItemBase.c:8663
float GetOverheatingValue()
Определения ItemBase.c:5419
bool ContainsAgent(int agent_id)
Определения ItemBase.c:8863
override void AddWet(float value)
Определения ItemBase.c:8611
bool IsLiquidPresent()
Определения ItemBase.c:5801
bool IsFullQuantity()
Определения ItemBase.c:8403
override void EOnContact(IEntity other, Contact extra)
Определения ItemBase.c:6084
void SplitIntoStackMaxHands(PlayerBase player)
Определения ItemBase.c:6847
void SplitIntoStackMaxHandsClient(PlayerBase player)
Определения ItemBase.c:6823
int m_CleannessMax
Определения ItemBase.c:4943
float m_VarStackMax
Определения ItemBase.c:4931
ref Timer m_PhysDropTimer
Определения ItemBase.c:5018
void MessageToOwnerFriendly(string text)
Send message to owner player in green color.
Определения ItemBase.c:7656
override void SetStoreLoadedQuantity(float value)
Определения ItemBase.c:8673
bool m_IsResultOfSplit string m_SoundAttType
distinguish if item has been created as new or it came from splitting (server only flag)
Определения ItemBase.c:4972
void CheckOverheating(ItemBase weapon=null, string ammoType="", ItemBase muzzle_owner=null, ItemBase suppressor=null, string config_to_search="")
Определения ItemBase.c:5440
void UnlockFromParent()
Unlocks this item from its attachment slot of its parent.
Определения ItemBase.c:5755
bool Repair(PlayerBase player, ItemBase item_repair_kit, float specialty_weight)
Определения ItemBase.c:7578
void OnLiquidTypeChanged(int oldType, int newType)
Определения ItemBase.c:8799
void StartOverheating(ItemBase weapon=null, string ammoType="", ItemBase muzzle_owner=null, ItemBase suppressor=null, string config_to_search="")
Определения ItemBase.c:5486
void PlayDeployFinishSound()
bool AllowFoodConsumption()
Определения ItemBase.c:8721
bool m_IsOverheatingEffectActive
Определения ItemBase.c:5003
int m_LiquidContainerMask
Определения ItemBase.c:4953
void ProcessItemWetness(float delta, bool hasParent, bool hasRootAsPlayer, ItemBase refParentIB)
Определения ItemBase.c:9456
override int GetCleanness()
Определения ItemBase.c:8716
bool PairWithDevice(notnull ItemBase otherDevice)
Определения ItemBase.c:9667
bool IsDeploySound()
Определения ItemBase.c:9756
static void RemoveDebugActionsMask(int mask)
Определения ItemBase.c:5695
static void UpdateOverheatingParticles(ItemBase weapon, string ammoType, ItemBase muzzle_owner, ItemBase suppressor, string config_to_search)
Определения ItemBase.c:9199
int m_VarQuantityMin
Определения ItemBase.c:4928
void PerformDamageSystemReinit()
Определения ItemBase.c:9426
override void ClearInventory()
Определения ItemBase.c:8504
static int m_LastRegisteredWeaponID
Определения ItemBase.c:5000
ItemBase GetLightSourceItem()
Определения ItemBase.c:9650
void MessageToOwnerImportant(string text)
Send message to owner player in red color.
Определения ItemBase.c:7674
override float GetItemOverheatThreshold()
Определения ItemBase.c:9600
void StopDeployLoopSoundEx()
bool m_CanThisBeSplit
Определения ItemBase.c:4965
override void SerializeNumericalVars(array< float > floats_out)
Определения ItemBase.c:7788
ItemBase SplitIntoStackMaxToInventoryLocationEx(notnull InventoryLocation dst)
Определения ItemBase.c:6762
float m_ItemModelLength
Определения ItemBase.c:4951
bool m_IsHologram
Определения ItemBase.c:4958
static int m_DebugActionsMask
Определения ItemBase.c:4918
void KillAllOverheatingParticles()
Определения ItemBase.c:5555
bool CanBeCookedOnStick()
Определения ItemBase.c:7561
override int GetQuantityMax()
Определения ItemBase.c:8349
void GetRecipesActions(Man player, out TSelectableActionInfoArray outputList)
Определения ItemBase.c:7232
void OnActivatedByTripWire()
bool IsColorSet()
Определения ItemBase.c:8759
override void RemoveAgent(int agent_id)
Определения ItemBase.c:8876
bool m_ItemBeingDroppedPhys
Определения ItemBase.c:4961
override bool CanPutAsAttachment(EntityAI parent)
Определения ItemBase.c:9066
void PlayDetachSound(string slot_type)
Определения ItemBase.c:9798
static ref map< typename, ref TInputActionMap > m_ItemTypeActionsMap
Определения ItemBase.c:4912
void ProcessItemWetnessAndTemperature(float delta, bool hasParent, bool hasRootAsPlayer, ItemBase refParentIB)
Определения ItemBase.c:9729
override bool IsBeingPlaced()
Определения ItemBase.c:5869
int GetQuantityInit()
Определения ItemBase.c:8387
float ComputeQuantityUsedEx(ItemBase other_item, bool use_stack_max=true)
Определения ItemBase.c:7174
bool IsResultOfSplit()
Определения ItemBase.c:7159
bool m_FixDamageSystemInit
Определения ItemBase.c:4963
float m_ImpactSpeed
Определения ItemBase.c:4947
bool m_IsStoreLoad
Определения ItemBase.c:4966
int GetLiquidTypeInit()
Определения ItemBase.c:8789
string GetDeployFinishSoundset()
ItemBase m_LightSourceItem
Определения ItemBase.c:4981
void LockToParent()
Locks this item in it's current attachment slot of its parent. This makes the "locked" icon visible i...
Определения ItemBase.c:5742
override void SplitIntoStackMaxEx(EntityAI destination_entity, int slot_id)
Определения ItemBase.c:6633
int m_AttachedAgents
Определения ItemBase.c:4989
string m_LockSoundSet
Определения ItemBase.c:5024
void LoadParticleConfigOnOverheating(int id)
Определения ItemBase.c:5363
float m_VarQuantityPrev
Определения ItemBase.c:4926
bool IsSoundSynchRemote()
Определения ItemBase.c:9754
bool m_CanShowQuantity
Определения ItemBase.c:4967
override void OnRightClick()
Определения ItemBase.c:7014
int m_ColorComponentB
Определения ItemBase.c:4976
static ref map< typename, ref TActionAnimOverrideMap > m_ItemActionOverrides
Определения ItemBase.c:4914
bool IsActionTargetVisible()
Определения ItemBase.c:9296
override void OnItemAttachmentSlotChanged(notnull InventoryLocation oldLoc, notnull InventoryLocation newLoc)
Определения ItemBase.c:6119
override void EEHitBy(TotalDamageResult damageResult, int damageType, EntityAI source, int component, string dmgZone, string ammo, vector modelPos, float speedCoef)
Определения ItemBase.c:6412
bool m_IsBeingPlaced
Определения ItemBase.c:4957
int NameToID(string name)
Определения ItemBase.c:7761
void ~ItemBase()
Определения ItemBase.c:5640
override void OnWetLevelChanged(EWetnessLevel newLevel, EWetnessLevel oldLevel)
Определения ItemBase.c:8651
void ClearStopItemSoundServer()
Определения ItemBase.c:9396
override string ChangeIntoOnDetach()
Определения ItemBase.c:6336
float m_VarWetMax
Определения ItemBase.c:4938
void SplitIntoStackMaxToInventoryLocation(notnull InventoryLocation dst)
Определения ItemBase.c:6757
int GetLockType()
Определения ItemBase.c:8729
EffectSound m_SoundDeployFinish
Определения ItemBase.c:9736
override float GetWet()
Определения ItemBase.c:8621
EffectSound m_SoundPlace
Определения ItemBase.c:9737
float GetQuantityNormalizedScripted()
Определения ItemBase.c:8335
override void SetCleanness(int value, bool allow_client=false)
Определения ItemBase.c:8703
bool m_IsPlaceSound
Определения ItemBase.c:9740
override float GetWetMin()
Определения ItemBase.c:8631
ref ItemSoundHandler m_ItemSoundHandler
Определения ItemBase.c:5032
override bool KindOf(string tag)
Определения ItemBase.c:7690
void ItemSoundHandler(ItemBase parent)
Определения ItemSoundHandler.c:31
string Type
Определения JsonDataContaminatedArea.c:11
EffectSound m_LockingSound
Определения Land_Underground_Entrance.c:336
string GetDebugText()
Определения ModifierBase.c:71
@ LOWEST
Определения PPEConstants.c:54
void PluginItemDiagnostic()
Определения PluginItemDiagnostic.c:74
PluginBase GetPlugin(typename plugin_type)
Определения PluginManager.c:325
override RemotelyActivatedItemBehaviour GetRemotelyActivatedItemBehaviour()
Определения RemoteDetonator.c:272
void RemoteDetonatorTrigger()
Определения RemoteDetonator.c:233
override void OnActivatedByItem(notnull ItemBase item)
Called when this item is activated by other.
Определения RemoteDetonator.c:305
int particle_id
Определения SmokeSimulation.c:28
ETemperatureAccessTypes
Определения TemperatureAccessConstants.c:2
override void Explode(int damageType, string ammoType="")
Определения Trap_LandMine.c:220
bool m_Initialized
Определения UiHintPanel.c:317
int GetID()
Определения ActionBase.c:1335
void OnItemLocationChanged(ItemBase item)
Определения ActionBase.c:974
GetInputType()
Определения ActionBase.c:221
int m_StanceMask
Определения ActionBase.c:25
int m_CommandUIDProne
Определения ActionBase.c:24
int m_CommandUID
Определения ActionBase.c:23
proto native int GetItemCount()
proto native EntityAI GetItem(int index)
float GetEnergyAtSpawn()
Определения ComponentEnergyManager.c:1325
void SetEnergy0To1(float energy01)
Energy manager: Sets stored energy for this device between 0 and MAX based on relative input value be...
Определения ComponentEnergyManager.c:550
float GetEnergyMaxPristine()
Energy manager: Returns the maximum amount of energy this device can store. It's damage is NOT taken ...
Определения ComponentEnergyManager.c:1320
override void SetAutodestroy(bool auto_destroy)
Sets whether Effect automatically cleans up when it stops.
Определения EffectSound.c:603
bool IsSoundPlaying()
Get whether EffectSound is currently playing.
Определения EffectSound.c:274
override bool IsMan()
Определения 3_Game/DayZ/Entities/Man.c:48
proto native EntityAI GetAttachmentFromIndex(int index)
proto native bool GetCurrentInventoryLocation(out notnull InventoryLocation loc)
returns information about current item location
proto native bool EnumerateInventory(InventoryTraversalType tt, out array< EntityAI > items)
enumerate inventory using traversal type and filling items array
proto native CargoBase GetCargo()
cargo
static proto native EntityAI LocationCreateEntity(notnull InventoryLocation inv_loc, string type, int iSetupFlags, int iRotation)
creates new item directly at location
proto native int AttachmentCount()
Returns count of attachments attached to this item.
proto native bool FindFreeLocationFor(notnull EntityAI item, FindInventoryLocationType flags, out notnull InventoryLocation loc)
FindFreeLocationFor.
proto void SelectObject(Object object)
proto void SelectPhysics(Physics physics)
Определения ItemBase.c:21
proto native bool IsValid()
verify current set inventory location
proto native EntityAI GetParent()
returns parent of current inventory location
proto native int GetSlot()
returns slot id if current type is Attachment
proto native int GetCol()
returns column of cargo if current type is Cargo / ProxyCargo
proto native int GetRow()
returns row of cargo if current type is Cargo / ProxyCargo
bool WriteToContext(ParamsWriteContext ctx)
Определения InventoryLocation.c:507
proto native int GetType()
returns type of InventoryLocation
proto native int GetIdx()
returns index of cargo if current type is Cargo / ProxyCargo
proto native void SetCargo(notnull EntityAI parent, EntityAI e, int idx, int row, int col, bool flip)
sets current inventory location type to Cargo with coordinates (idx, row, col)
proto native bool GetFlip()
returns flip status of cargo
proto native EntityAI GetItem()
returns item of current inventory location
InventoryLocation.
Определения InventoryLocation.c:30
override bool CanDisplayCargo()
Определения TentBase.c:91
override void OnInventoryEnter(Man player)
Определения BarbedWire.c:203
override string GetFoldSoundset()
Определения BaseBuildingBase.c:108
override bool CanPutAsAttachment(EntityAI parent)
Определения ItemBase.c:7
override bool CanReceiveItemIntoCargo(EntityAI item)
Определения TentBase.c:934
override bool OnStoreLoad(ParamsReadContext ctx, int version)
Определения GardenBase.c:199
override void OnWasDetached(EntityAI parent, int slot_id)
override void EEOnAfterLoad()
Определения GardenBase.c:242
override void EEDelete(EntityAI parent)
Определения BaseBuildingBase.c:68
override bool CanBeRepairedByCrafting()
Определения TentBase.c:86
override void OnPlacementStarted(Man player)
Определения BatteryCharger.c:376
override void OnItemLocationChanged(EntityAI old_owner, EntityAI new_owner)
Определения BarbedWire.c:357
override bool IsElectricAppliance()
Определения BatteryCharger.c:43
override bool IsItemTent()
Определения TentBase.c:81
override string GetLoopFoldSoundset()
Определения BaseBuildingBase.c:113
override bool CanMakeGardenplot()
Определения FieldShovel.c:3
override void GetDebugActions(out TSelectableActionInfoArrayEx outputList)
Определения PowerGenerator.c:397
override void EEItemLocationChanged(notnull InventoryLocation oldLoc, notnull InventoryLocation newLoc)
Определения HandcuffsLocked.c:12
override WrittenNoteData GetWrittenNoteData()
Определения Paper.c:30
override int GetDamageSystemVersionChange()
Определения BaseBuildingBase.c:1238
override bool SetQuantity(float value, bool destroy_config=true, bool destroy_forced=false, bool allow_client=false, bool clamp_to_stack_max=true)
Определения PileOfWoodenPlanks.c:88
override void InitItemVariables()
Определения Matchbox.c:3
override void SetActionAnimOverrides()
Определения PickAxe.c:28
override void OnCreatePhysics()
Определения BaseBuildingBase.c:489
override string GetDeploySoundset()
Определения BarbedWire.c:392
override float GetBandagingEffectivity()
Определения BandageDressing.c:49
override bool OnAction(int action_id, Man player, ParamsReadContext ctx)
Определения PowerGenerator.c:409
override void EEHealthLevelChanged(int oldLevel, int newLevel, string zone)
Определения BaseBuildingBase.c:496
override void OnStoreSave(ParamsWriteContext ctx)
Определения GardenBase.c:266
override void AfterStoreLoad()
Определения BarbedWire.c:155
override int GetOnDigWormsAmount()
Определения FieldShovel.c:27
override bool IsSelfAdjustingTemperature()
Определения PortableGasStove.c:287
override bool IsPlayerInside(PlayerBase player, string selection)
Определения BaseBuildingBase.c:1037
override void OnVariablesSynchronized()
Определения GardenBase.c:97
override void RefreshPhysics()
Определения BatteryCharger.c:359
override bool CanObstruct()
Определения BaseBuildingBase.c:84
override void OnWasAttached(EntityAI parent, int slot_id)
override bool CanReceiveAttachment(EntityAI attachment, int slotId)
Определения BaseBuildingBase.c:982
override bool CanPutInCargo(EntityAI parent)
Определения GardenBase.c:331
override string GetLoopDeploySoundset()
Определения BarbedWire.c:397
override void OnPlacementComplete(Man player, vector position="0 0 0", vector orientation="0 0 0")
Определения BarbedWire.c:372
override void OnInventoryExit(Man player)
Определения BatteryCharger.c:341
override bool IsTakeable()
Определения BaseBuildingBase.c:1008
override bool IsIgnoredByConstruction()
Определения BaseBuildingBase.c:1170
override void InitItemSounds()
Определения BaseBuildingBase.c:94
override void EEKilled(Object killer)
Определения HandcuffsLocked.c:70
override void OnCombine(ItemBase other_item)
Определения BandageDressing.c:71
override bool CanExplodeInFire()
Определения LargeGasCannister.c:3
override bool IsFacingPlayer(PlayerBase player, string selection)
Определения BaseBuildingBase.c:1032
override bool CanBeCombined(EntityAI other_item, bool reservation_check=true, bool stack_max_limit=false)
Определения Rag.c:61
override bool IsBloodContainer()
Определения BloodContainerBase.c:10
override bool CanBeSplit()
Определения Rag.c:34
override bool IsDeployable()
Определения BaseBuildingBase.c:365
override void OnRPC(PlayerIdentity sender, int rpc_type, ParamsReadContext ctx)
Определения ToolBase.c:24
override bool CanBeDisinfected()
Определения BandageDressing.c:54
override float GetInfectionChance(int system=0, Param param=null)
Определения BandageDressing.c:59
override void OnEndPlacement()
Определения KitBase.c:65
Определения ItemBase.c:14
Определения EnMath.c:7
float GetOverheatingLimitMax()
Определения WeaponParticles.c:417
void SetOverheatingLimitMax(float max)
Определения WeaponParticles.c:407
void SetParticleParams(int particle_id, Object parent, vector local_pos, vector local_ori)
Определения WeaponParticles.c:422
float GetOverheatingLimitMin()
Определения WeaponParticles.c:412
Particle GetParticle()
Определения WeaponParticles.c:397
void SetOverheatingLimitMin(float min)
Определения WeaponParticles.c:402
void RegisterParticle(Particle p)
Определения WeaponParticles.c:392
void Stop()
Legacy function for backwards compatibility with 1.14 and below.
Определения Particle.c:266
void SetControlledDevice(EntityAI pDevice)
Определения RemoteDetonator.c:140
bool OnStoreLoad(ParamsReadContext ctx, int version)
void OnStoreSave(ParamsWriteContext ctx)
proto native void Send()
proto bool Write(void value_out)
proto bool Read(void value_in)
bool m_Loop
Определения ItemSoundHandler.c:5
override void Stop()
Определения DayZPlayerImplement.c:40
proto native float GetDamage(string zoneName, string healthType)
override void Refresh()
Определения ChatInputMenu.c:70
void SetCalcDetails(string details)
Определения 3_Game/DayZ/tools/Debug.c:916
void OnRPC(PlayerIdentity sender, int rpc_type, ParamsReadContext ctx)
Определения WrittenNoteData.c:13
const float LOWEST
Определения EnConvert.c:113
Serializer ParamsReadContext
Определения gameplay.c:15
class LOD Object
InventoryTraversalType
tree traversal type, for more see http://en.wikipedia.org/wiki/Tree_traversal
Определения gameplay.c:6
Serializer ParamsWriteContext
Определения gameplay.c:16
const int DEF_BIOLOGICAL
Определения 3_Game/DayZ/constants.c:515
const int DEF_CHEMICAL
Определения 3_Game/DayZ/constants.c:516
const int COMP_TYPE_ENERGY_MANAGER
Определения Component.c:9
ErrorExSeverity
Определения EnDebug.c:62
void Error(string err)
Messagebox with error message.
Определения EnDebug.c:90
enum ShapeType ErrorEx
proto native void SetColor(int color)
array< string > TStringArray
Определения EnScript.c:712
array< int > TIntArray
Определения EnScript.c:714
void Obsolete(string msg="")
Определения EnScript.c:371
EntityEvent
Entity events for event-mask, or throwing event from code.
Определения EnEntity.c:45
static const float ITEM_TEMPERATURE_NEUTRAL_ZONE_MIDDLE
Определения 3_Game/DayZ/constants.c:811
const int VARIABLE_LIQUIDTYPE
Определения 3_Game/DayZ/constants.c:635
const int VARIABLE_CLEANNESS
Определения 3_Game/DayZ/constants.c:638
const int VARIABLE_COLOR
Определения 3_Game/DayZ/constants.c:637
const int VARIABLE_TEMPERATURE
Определения 3_Game/DayZ/constants.c:633
const int VARIABLE_QUANTITY
Определения 3_Game/DayZ/constants.c:631
const int VARIABLE_WET
Определения 3_Game/DayZ/constants.c:634
const int LIQUID_NONE
Определения 3_Game/DayZ/constants.c:532
static proto float AbsFloat(float f)
Returns absolute value.
const int MENU_INVENTORY
Определения 3_Game/DayZ/constants.c:180
proto native bool dBodyIsDynamic(notnull IEntity ent)
const int SAT_CRAFTING
Определения 3_Game/DayZ/constants.c:456
const int SAT_DEBUG_ACTION
Определения 3_Game/DayZ/constants.c:457
vector GetPosition()
Get the world position of the Effect.
Определения Effect.c:473
static proto string Format(string fmt, void param1=NULL, void param2=NULL, void param3=NULL, void param4=NULL, void param5=NULL, void param6=NULL, void param7=NULL, void param8=NULL, void param9=NULL)
Gets n-th character from string.
const int CALL_CATEGORY_GAMEPLAY
Определения 3_Game/DayZ/tools/tools.c:10
const int CALL_CATEGORY_SYSTEM
Определения 3_Game/DayZ/tools/tools.c:8
proto native int GetColor()