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

◆ IsCombineAll()

bool SpawnItemOnLocation::IsCombineAll ( ItemBase other_item,
bool use_stack_max = false )
protected

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

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

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