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

◆ OnRightClick()

override void SpawnItemOnLocation::OnRightClick ( )
protected

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

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