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

◆ ChangeIntoOnAttach()

override string SpawnItemOnLocation::ChangeIntoOnAttach ( string slot)
private

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

6317{
6318 override bool CanPutAsAttachment(EntityAI parent)
6319 {
6320 return true;
6321 }
6322};
6323
6325{
6326
6327};
6328
6329//const bool QUANTITY_DEBUG_REMOVE_ME = false;
6330
6331class ItemBase extends InventoryItem
6332{
6336
6338
6339 static int m_DebugActionsMask;
6341 // ============================================
6342 // Variable Manipulation System
6343 // ============================================
6344 // Quantity
6345
6346 float m_VarQuantity;
6347 float m_VarQuantityPrev;//for client to know quantity changed during synchronization
6349 int m_VarQuantityMin;
6350 int m_VarQuantityMax;
6351 int m_Count;
6352 float m_VarStackMax;
6353 float m_StoreLoadedQuantity = float.LOWEST;
6354 // Wet
6355 float m_VarWet;
6356 float m_VarWetPrev;//for client to know wetness changed during synchronization
6357 float m_VarWetInit;
6358 float m_VarWetMin;
6359 float m_VarWetMax;
6360 // Cleanness
6361 int m_Cleanness;
6362 int m_CleannessInit;
6363 int m_CleannessMin;
6364 int m_CleannessMax;
6365 // impact sounds
6367 bool m_CanPlayImpactSound = true;
6368 float m_ImpactSpeed;
6370 //
6371 float m_HeatIsolation;
6372 float m_ItemModelLength;
6373 float m_ItemAttachOffset; // Offset length for when the item is attached e.g. to weapon
6375 int m_VarLiquidType;
6376 int m_ItemBehaviour; // -1 = not specified; 0 = heavy item; 1= onehanded item; 2 = twohanded item
6377 int m_QuickBarBonus;
6378 bool m_IsBeingPlaced;
6379 bool m_IsHologram;
6380 bool m_IsTakeable;
6381 bool m_ThrowItemOnDrop;
6384 bool m_FixDamageSystemInit = false; //can be changed on storage version check
6385 bool can_this_be_combined; //Check if item can be combined
6386 bool m_CanThisBeSplit; //Check if item can be split
6387 bool m_IsStoreLoad = false;
6388 bool m_CanShowQuantity;
6389 bool m_HasQuantityBar;
6390 protected bool m_CanBeDigged;
6391 protected bool m_IsResultOfSplit
6392
6393 string m_SoundAttType;
6394 // items color variables
6399 //-------------------------------------------------------
6400
6401 // light source managing
6403
6407
6408 //==============================================
6409 // agent system
6410 private int m_AttachedAgents;
6411
6413 void TransferModifiers(PlayerBase reciever);
6414
6415
6416 // Weapons & suppressors particle effects
6420 ref static map<string, int> m_WeaponTypeToID;
6421 static int m_LastRegisteredWeaponID = 0;
6422
6423 // Overheating effects
6425 float m_OverheatingShots;
6426 ref Timer m_CheckOverheating;
6427 int m_ShotsToStartOverheating = 0; // After these many shots, the overheating effect begins
6428 int m_MaxOverheatingValue = 0; // Limits the number of shots that will be tracked
6429 float m_OverheatingDecayInterval = 1; // Timer's interval for decrementing overheat effect's lifespan
6430 ref array <ref OverheatingParticle> m_OverheatingParticles;
6431
6433 protected bool m_HideSelectionsBySlot;
6434
6435 // Admin Log
6436 PluginAdminLog m_AdminLog;
6437
6438 // misc
6439 ref Timer m_PhysDropTimer;
6440
6441 // Attachment Locking variables
6442 ref array<int> m_CompatibleLocks;
6443 protected int m_LockType;
6444 protected ref EffectSound m_LockingSound;
6445 protected string m_LockSoundSet;
6446
6447 // ItemSoundHandler variables
6448 protected const int ITEM_SOUNDS_MAX = 63; // optimize network synch
6449 protected int m_SoundSyncPlay; // id for sound to play
6450 protected int m_SoundSyncStop; // id for sound to stop
6451 protected int m_SoundSyncSlotID = InventorySlots.INVALID; // slot id for attach/detach sound based on slot
6452
6454
6455 //temperature
6456 private float m_TemperaturePerQuantityWeight;
6457
6458 // -------------------------------------------------------------------------
6459 void ItemBase()
6460 {
6461 SetEventMask(EntityEvent.INIT); // Enable EOnInit event
6465
6466 if (!g_Game.IsDedicatedServer())
6467 {
6468 if (HasMuzzle())
6469 {
6471
6473 {
6475 }
6476 }
6477
6479 m_ActionsInitialize = false;
6480 }
6481
6482 m_OldLocation = null;
6483
6484 if (g_Game.IsServer())
6485 {
6486 m_AdminLog = PluginAdminLog.Cast(GetPlugin(PluginAdminLog));
6487 }
6488
6489 if (ConfigIsExisting("headSelectionsToHide"))
6490 {
6492 ConfigGetTextArray("headSelectionsToHide",m_HeadHidingSelections);
6493 }
6494
6495 m_HideSelectionsBySlot = false;
6496 if (ConfigIsExisting("hideSelectionsByinventorySlot"))
6497 {
6498 m_HideSelectionsBySlot = ConfigGetBool("hideSelectionsByinventorySlot");
6499 }
6500
6501 m_QuickBarBonus = Math.Max(0, ConfigGetInt("quickBarBonus"));
6502
6503 m_IsResultOfSplit = false;
6504
6506 }
6507
6508 override void InitItemVariables()
6509 {
6510 super.InitItemVariables();
6511
6512 m_VarQuantityInit = ConfigGetInt("varQuantityInit");
6513 m_VarQuantity = m_VarQuantityInit;//should be by the CE, this is just a precaution
6514 m_VarQuantityMin = ConfigGetInt("varQuantityMin");
6515 m_VarQuantityMax = ConfigGetInt("varQuantityMax");
6516 m_VarStackMax = ConfigGetFloat("varStackMax");
6517 m_Count = ConfigGetInt("count");
6518
6519 m_CanShowQuantity = ConfigGetBool("quantityShow");
6520 m_HasQuantityBar = ConfigGetBool("quantityBar");
6521
6522 m_CleannessInit = ConfigGetInt("varCleannessInit");
6524 m_CleannessMin = ConfigGetInt("varCleannessMin");
6525 m_CleannessMax = ConfigGetInt("varCleannessMax");
6526
6527 m_WantPlayImpactSound = false;
6528 m_ImpactSpeed = 0.0;
6529
6530 m_VarWetInit = ConfigGetFloat("varWetInit");
6532 m_VarWetMin = ConfigGetFloat("varWetMin");
6533 m_VarWetMax = ConfigGetFloat("varWetMax");
6534
6535 m_LiquidContainerMask = ConfigGetInt("liquidContainerType");
6536 if (IsLiquidContainer() && GetQuantity() != 0)
6538 m_IsBeingPlaced = false;
6539 m_IsHologram = false;
6540 m_IsTakeable = true;
6541 m_CanBeMovedOverride = false;
6545 m_CanBeDigged = ConfigGetBool("canBeDigged");
6546
6547 m_CompatibleLocks = new array<int>();
6548 ConfigGetIntArray("compatibleLocks", m_CompatibleLocks);
6549 m_LockType = ConfigGetInt("lockType");
6550
6551 //Define if item can be split and set ability to be combined accordingly
6552 m_CanThisBeSplit = false;
6553 can_this_be_combined = false;
6554 if (ConfigIsExisting("canBeSplit"))
6555 {
6556 can_this_be_combined = ConfigGetBool("canBeSplit");
6558 }
6559
6560 m_ItemBehaviour = -1;
6561 if (ConfigIsExisting("itemBehaviour"))
6562 m_ItemBehaviour = ConfigGetInt("itemBehaviour");
6563
6564 //RegisterNetSyncVariableInt("m_VariablesMask");
6565 if (HasQuantity()) RegisterNetSyncVariableFloat("m_VarQuantity", GetQuantityMin(), m_VarQuantityMax);
6566 RegisterNetSyncVariableFloat("m_VarWet", GetWetMin(), GetWetMax(), 2);
6567 RegisterNetSyncVariableInt("m_VarLiquidType");
6568 RegisterNetSyncVariableInt("m_Cleanness",0,1);
6569
6570 RegisterNetSyncVariableBoolSignal("m_WantPlayImpactSound");
6571 RegisterNetSyncVariableFloat("m_ImpactSpeed");
6572 RegisterNetSyncVariableInt("m_ImpactSoundSurfaceHash");
6573
6574 RegisterNetSyncVariableInt("m_ColorComponentR", 0, 255);
6575 RegisterNetSyncVariableInt("m_ColorComponentG", 0, 255);
6576 RegisterNetSyncVariableInt("m_ColorComponentB", 0, 255);
6577 RegisterNetSyncVariableInt("m_ColorComponentA", 0, 255);
6578
6579 RegisterNetSyncVariableBool("m_IsBeingPlaced");
6580 RegisterNetSyncVariableBool("m_IsTakeable");
6581 RegisterNetSyncVariableBool("m_IsHologram");
6582
6585 {
6586 RegisterNetSyncVariableInt("m_SoundSyncPlay", 0, ITEM_SOUNDS_MAX);
6587 RegisterNetSyncVariableInt("m_SoundSyncStop", 0, ITEM_SOUNDS_MAX);
6588 RegisterNetSyncVariableInt("m_SoundSyncSlotID", int.MIN, int.MAX);
6589 }
6590
6591 m_LockSoundSet = ConfigGetString("lockSoundSet");
6592
6594 if (ConfigIsExisting("temperaturePerQuantityWeight"))
6595 m_TemperaturePerQuantityWeight = ConfigGetFloat("temperaturePerQuantityWeight");
6596
6597 m_SoundSyncSlotID = -1;
6598 }
6599
6600 override int GetQuickBarBonus()
6601 {
6602 return m_QuickBarBonus;
6603 }
6604
6605 void InitializeActions()
6606 {
6608 if (!m_InputActionMap)
6609 {
6611 m_InputActionMap = iam;
6612 SetActions();
6614 }
6615 }
6616
6617 override void GetActions(typename action_input_type, out array<ActionBase_Basic> actions)
6618 {
6620 {
6621 m_ActionsInitialize = true;
6623 }
6624
6625 actions = m_InputActionMap.Get(action_input_type);
6626 }
6627
6628 void SetActions()
6629 {
6630 AddAction(ActionTakeItem);
6631 AddAction(ActionTakeItemToHands);
6632 AddAction(ActionWorldCraft);
6634 AddAction(ActionAttachWithSwitch);
6635 }
6636
6637 void SetActionAnimOverrides(); // Override action animation for specific item
6638
6639 void AddAction(typename actionName)
6640 {
6641 ActionBase action = ActionManagerBase.GetAction(actionName);
6642
6643 if (!action)
6644 {
6645 Debug.LogError("Action " + actionName + " dosn't exist!");
6646 return;
6647 }
6648
6649 typename ai = action.GetInputType();
6650 if (!ai)
6651 {
6652 m_ActionsInitialize = false;
6653 return;
6654 }
6655
6656 array<ActionBase_Basic> action_array = m_InputActionMap.Get(ai);
6657 if (!action_array)
6658 {
6659 action_array = new array<ActionBase_Basic>;
6660 m_InputActionMap.Insert(ai, action_array);
6661 }
6662 if (LogManager.IsActionLogEnable())
6663 {
6664 Debug.ActionLog(action.ToString() + " -> " + ai, this.ToString() , "n/a", "Add action");
6665 }
6666
6667 if (action_array.Find(action) != -1)
6668 {
6669 Debug.Log("Action " + action.Type() + " already added to " + this + ", skipping!");
6670 }
6671 else
6672 {
6673 action_array.Insert(action);
6674 }
6675 }
6676
6677 void RemoveAction(typename actionName)
6678 {
6679 PlayerBase player = PlayerBase.Cast(g_Game.GetPlayer());
6680 ActionBase action = player.GetActionManager().GetAction(actionName);
6681 typename ai = action.GetInputType();
6682 array<ActionBase_Basic> action_array = m_InputActionMap.Get(ai);
6683
6684 if (action_array)
6685 {
6686 action_array.RemoveItem(action);
6687 }
6688 }
6689
6690 // Allows override of default action command per item, defined in the SetActionAnimOverrides() of the item's class
6691 // Set -1 for params which should stay in default state
6692 void OverrideActionAnimation(typename action, int commandUID, int stanceMask = -1, int commandUIDProne = -1)
6693 {
6694 ActionOverrideData overrideData = new ActionOverrideData();
6695 overrideData.m_CommandUID = commandUID;
6696 overrideData.m_CommandUIDProne = commandUIDProne;
6697 overrideData.m_StanceMask = stanceMask;
6698
6699 TActionAnimOverrideMap actionMap = m_ItemActionOverrides.Get(action);
6700 if (!actionMap) // create new map of action > overidables map
6701 {
6702 actionMap = new TActionAnimOverrideMap();
6703 m_ItemActionOverrides.Insert(action, actionMap);
6704 }
6705
6706 actionMap.Insert(this.Type(), overrideData); // insert item -> overrides
6707
6708 }
6709
6710 void OnItemInHandsPlayerSwimStart(PlayerBase player);
6711
6712 ScriptedLightBase GetLight();
6713
6714 // Loads muzzle flash particle configuration from config and saves it to a map for faster access
6715 void LoadParticleConfigOnFire(int id)
6716 {
6717 if (!m_OnFireEffect)
6719
6722
6723 string config_to_search = "CfgVehicles";
6724 string muzzle_owner_config;
6725
6726 if (!m_OnFireEffect.Contains(id))
6727 {
6728 if (IsInherited(Weapon))
6729 config_to_search = "CfgWeapons";
6730
6731 muzzle_owner_config = config_to_search + " " + GetType() + " ";
6732
6733 string config_OnFire_class = muzzle_owner_config + "Particles " + "OnFire ";
6734
6735 int config_OnFire_subclass_count = g_Game.ConfigGetChildrenCount(config_OnFire_class);
6736
6737 if (config_OnFire_subclass_count > 0)
6738 {
6739 array<ref WeaponParticlesOnFire> WPOF_array = new array<ref WeaponParticlesOnFire>;
6740
6741 for (int i = 0; i < config_OnFire_subclass_count; i++)
6742 {
6743 string particle_class = "";
6744 g_Game.ConfigGetChildName(config_OnFire_class, i, particle_class);
6745 string config_OnFire_entry = config_OnFire_class + particle_class;
6746 WeaponParticlesOnFire WPOF = new WeaponParticlesOnFire(this, config_OnFire_entry);
6747 WPOF_array.Insert(WPOF);
6748 }
6749
6750
6751 m_OnFireEffect.Insert(id, WPOF_array);
6752 }
6753 }
6754
6755 if (!m_OnBulletCasingEjectEffect.Contains(id))
6756 {
6757 config_to_search = "CfgWeapons"; // Bullet Eject efect is supported on weapons only.
6758 muzzle_owner_config = config_to_search + " " + GetType() + " ";
6759
6760 string config_OnBulletCasingEject_class = muzzle_owner_config + "Particles " + "OnBulletCasingEject ";
6761
6762 int config_OnBulletCasingEject_count = g_Game.ConfigGetChildrenCount(config_OnBulletCasingEject_class);
6763
6764 if (config_OnBulletCasingEject_count > 0 && IsInherited(Weapon))
6765 {
6766 array<ref WeaponParticlesOnBulletCasingEject> WPOBE_array = new array<ref WeaponParticlesOnBulletCasingEject>;
6767
6768 for (i = 0; i < config_OnBulletCasingEject_count; i++)
6769 {
6770 string particle_class2 = "";
6771 g_Game.ConfigGetChildName(config_OnBulletCasingEject_class, i, particle_class2);
6772 string config_OnBulletCasingEject_entry = config_OnBulletCasingEject_class + particle_class2;
6773 WeaponParticlesOnBulletCasingEject WPOBE = new WeaponParticlesOnBulletCasingEject(this, config_OnBulletCasingEject_entry);
6774 WPOBE_array.Insert(WPOBE);
6775 }
6776
6777
6778 m_OnBulletCasingEjectEffect.Insert(id, WPOBE_array);
6779 }
6780 }
6781 }
6782
6783 // Loads muzzle flash particle configuration from config and saves it to a map for faster access
6785 {
6788
6789 if (!m_OnOverheatingEffect.Contains(id))
6790 {
6791 string config_to_search = "CfgVehicles";
6792
6793 if (IsInherited(Weapon))
6794 config_to_search = "CfgWeapons";
6795
6796 string muzzle_owner_config = config_to_search + " " + GetType() + " ";
6797 string config_OnOverheating_class = muzzle_owner_config + "Particles " + "OnOverheating ";
6798
6799 if (g_Game.ConfigIsExisting(config_OnOverheating_class))
6800 {
6801
6802 m_ShotsToStartOverheating = g_Game.ConfigGetFloat(config_OnOverheating_class + "shotsToStartOverheating");
6803
6805 {
6806 m_ShotsToStartOverheating = -1; // This prevents futher readings from config for future creations of this item
6807 string error = "Error reading config " + GetType() + ">Particles>OnOverheating - Parameter shotsToStartOverheating is configured wrong or is missing! Its value must be 1 or higher!";
6808 Error(error);
6809 return;
6810 }
6811
6812 m_OverheatingDecayInterval = g_Game.ConfigGetFloat(config_OnOverheating_class + "overheatingDecayInterval");
6813 m_MaxOverheatingValue = g_Game.ConfigGetFloat(config_OnOverheating_class + "maxOverheatingValue");
6814
6815
6816
6817 int config_OnOverheating_subclass_count = g_Game.ConfigGetChildrenCount(config_OnOverheating_class);
6818 array<ref WeaponParticlesOnOverheating> WPOOH_array = new array<ref WeaponParticlesOnOverheating>;
6819
6820 for (int i = 0; i < config_OnOverheating_subclass_count; i++)
6821 {
6822 string particle_class = "";
6823 g_Game.ConfigGetChildName(config_OnOverheating_class, i, particle_class);
6824 string config_OnOverheating_entry = config_OnOverheating_class + particle_class;
6825 int entry_type = g_Game.ConfigGetType(config_OnOverheating_entry);
6826
6827 if (entry_type == CT_CLASS)
6828 {
6829 WeaponParticlesOnOverheating WPOF = new WeaponParticlesOnOverheating(this, config_OnOverheating_entry);
6830 WPOOH_array.Insert(WPOF);
6831 }
6832 }
6833
6834
6835 m_OnOverheatingEffect.Insert(id, WPOOH_array);
6836 }
6837 }
6838 }
6839
6840 float GetOverheatingValue()
6841 {
6842 return m_OverheatingShots;
6843 }
6844
6845 void IncreaseOverheating(ItemBase weapon, string ammoType, ItemBase muzzle_owner, ItemBase suppressor, string config_to_search)
6846 {
6847 if (m_MaxOverheatingValue > 0)
6848 {
6850
6851 if (!m_CheckOverheating)
6853
6855 m_CheckOverheating.Run(m_OverheatingDecayInterval, this, "OnOverheatingDecay");
6856
6857 CheckOverheating(weapon, ammoType, muzzle_owner, suppressor, config_to_search);
6858 }
6859 }
6860
6861 void CheckOverheating(ItemBase weapon = null, string ammoType = "", ItemBase muzzle_owner = null, ItemBase suppressor = null, string config_to_search = "")
6862 {
6864 UpdateOverheating(weapon, ammoType, muzzle_owner, suppressor, config_to_search);
6865
6867 StartOverheating(weapon, ammoType, muzzle_owner, suppressor, config_to_search);
6868
6870 StopOverheating(weapon, ammoType, muzzle_owner, suppressor, config_to_search);
6871
6873 {
6875 }
6876 }
6877
6879 {
6881 }
6882
6883 void OnOverheatingDecay()
6884 {
6885 if (m_MaxOverheatingValue > 0)
6886 m_OverheatingShots -= 1 + m_OverheatingShots / m_MaxOverheatingValue; // The hotter a barrel is, the faster it needs to cool down.
6887 else
6889
6890 if (m_OverheatingShots <= 0)
6891 {
6894 }
6895 else
6896 {
6897 if (!m_CheckOverheating)
6899
6901 m_CheckOverheating.Run(m_OverheatingDecayInterval, this, "OnOverheatingDecay");
6902 }
6903
6904 CheckOverheating(this, "", this);
6905 }
6906
6907 void StartOverheating(ItemBase weapon = null, string ammoType = "", ItemBase muzzle_owner = null, ItemBase suppressor = null, string config_to_search = "")
6908 {
6910 ItemBase.PlayOverheatingParticles(this, ammoType, this, suppressor, "CfgWeapons");
6911 }
6912
6913 void UpdateOverheating(ItemBase weapon = null, string ammoType = "", ItemBase muzzle_owner = null, ItemBase suppressor = null, string config_to_search = "")
6914 {
6916 ItemBase.UpdateOverheatingParticles(this, ammoType, this, suppressor, "CfgWeapons");
6918 }
6919
6920 void StopOverheating(ItemBase weapon = null, string ammoType = "", ItemBase muzzle_owner = null, ItemBase suppressor = null, string config_to_search = "")
6921 {
6923 ItemBase.StopOverheatingParticles(weapon, ammoType, muzzle_owner, suppressor, config_to_search);
6924 }
6925
6926 void RegisterOverheatingParticle(Particle p, float min_heat_coef, float max_heat_coef, int particle_id, Object parent, vector local_pos, vector local_ori)
6927 {
6929 m_OverheatingParticles = new array<ref OverheatingParticle>;
6930
6931 OverheatingParticle OP = new OverheatingParticle();
6932 OP.RegisterParticle(p);
6933 OP.SetOverheatingLimitMin(min_heat_coef);
6934 OP.SetOverheatingLimitMax(max_heat_coef);
6935 OP.SetParticleParams(particle_id, parent, local_pos, local_ori);
6936
6937 m_OverheatingParticles.Insert(OP);
6938 }
6939
6940 float GetOverheatingCoef()
6941 {
6942 if (m_MaxOverheatingValue > 0)
6944
6945 return -1;
6946 }
6947
6949 {
6951 {
6952 float overheat_coef = GetOverheatingCoef();
6953 int count = m_OverheatingParticles.Count();
6954
6955 for (int i = count; i > 0; --i)
6956 {
6957 int id = i - 1;
6958 OverheatingParticle OP = m_OverheatingParticles.Get(id);
6959 Particle p = OP.GetParticle();
6960
6961 float overheat_min = OP.GetOverheatingLimitMin();
6962 float overheat_max = OP.GetOverheatingLimitMax();
6963
6964 if (overheat_coef < overheat_min && overheat_coef >= overheat_max)
6965 {
6966 if (p)
6967 {
6968 p.Stop();
6969 OP.RegisterParticle(null);
6970 }
6971 }
6972 }
6973 }
6974 }
6975
6977 {
6979 {
6980 for (int i = m_OverheatingParticles.Count(); i > 0; i--)
6981 {
6982 int id = i - 1;
6983 OverheatingParticle OP = m_OverheatingParticles.Get(id);
6984
6985 if (OP)
6986 {
6987 Particle p = OP.GetParticle();
6988
6989 if (p)
6990 {
6991 p.Stop();
6992 }
6993
6994 delete OP;
6995 }
6996 }
6997
6998 m_OverheatingParticles.Clear();
7000 }
7001 }
7002
7004 float GetInfectionChance(int system = 0, Param param = null)
7005 {
7006 return 0.0;
7007 }
7008
7009
7010 float GetDisinfectQuantity(int system = 0, Param param1 = null)
7011 {
7012 return 250;//default value
7013 }
7014
7015 float GetFilterDamageRatio()
7016 {
7017 return 0;
7018 }
7019
7021 bool HasMuzzle()
7022 {
7023 if (IsInherited(Weapon) || IsInherited(SuppressorBase))
7024 return true;
7025
7026 return false;
7027 }
7028
7030 int GetMuzzleID()
7031 {
7032 if (!m_WeaponTypeToID)
7033 m_WeaponTypeToID = new map<string, int>;
7034
7035 if (m_WeaponTypeToID.Contains(GetType()))
7036 {
7037 return m_WeaponTypeToID.Get(GetType());
7038 }
7039 else
7040 {
7041 // Register new weapon ID
7043 }
7044
7046 }
7047
7054 {
7055 return -1;
7056 }
7057
7058
7059
7060 // -------------------------------------------------------------------------
7061 void ~ItemBase()
7062 {
7063 if (g_Game && g_Game.GetPlayer() && (!g_Game.IsDedicatedServer()))
7064 {
7065 PlayerBase player = PlayerBase.Cast(g_Game.GetPlayer());
7066 int r_index = player.GetHumanInventory().FindUserReservedLocationIndex(this);
7067
7068 if (r_index >= 0)
7069 {
7070 InventoryLocation r_il = new InventoryLocation;
7071 player.GetHumanInventory().GetUserReservedLocation(r_index,r_il);
7072
7073 player.GetHumanInventory().ClearUserReservedLocationAtIndex(r_index);
7074 int r_type = r_il.GetType();
7075 if (r_type == InventoryLocationType.CARGO || r_type == InventoryLocationType.PROXYCARGO)
7076 {
7077 r_il.GetParent().GetOnReleaseLock().Invoke(this);
7078 }
7079 else if (r_type == InventoryLocationType.ATTACHMENT)
7080 {
7081 r_il.GetParent().GetOnAttachmentReleaseLock().Invoke(this, r_il.GetSlot());
7082 }
7083
7084 }
7085
7086 player.GetHumanInventory().ClearUserReservedLocation(this);
7087 }
7088
7089 if (m_LockingSound)
7090 SEffectManager.DestroyEffect(m_LockingSound);
7091 }
7092
7093
7094
7095 // -------------------------------------------------------------------------
7096 static int GetDebugActionsMask()
7097 {
7098 return ItemBase.m_DebugActionsMask;
7099 }
7100
7101 static bool HasDebugActionsMask(int mask)
7102 {
7103 return ItemBase.m_DebugActionsMask & mask;
7104 }
7105
7106 static void SetDebugActionsMask(int mask)
7107 {
7108 ItemBase.m_DebugActionsMask = mask;
7109 }
7110
7111 static void AddDebugActionsMask(int mask)
7112 {
7113 ItemBase.m_DebugActionsMask |= mask;
7114 }
7115
7116 static void RemoveDebugActionsMask(int mask)
7117 {
7118 ItemBase.m_DebugActionsMask &= ~mask;
7119 }
7120
7121 static void ToggleDebugActionsMask(int mask)
7122 {
7123 if (HasDebugActionsMask(mask))
7124 {
7126 }
7127 else
7128 {
7129 AddDebugActionsMask(mask);
7130 }
7131 }
7132
7133 // -------------------------------------------------------------------------
7134 void SetCEBasedQuantity()
7135 {
7136 if (GetEconomyProfile())
7137 {
7138 float q_max = GetEconomyProfile().GetQuantityMax();
7139 if (q_max > 0)
7140 {
7141 float q_min = GetEconomyProfile().GetQuantityMin();
7142 float quantity_randomized = Math.RandomFloatInclusive(q_min, q_max);
7143
7144 if (HasComponent(COMP_TYPE_ENERGY_MANAGER))//more direct access for speed
7145 {
7146 ComponentEnergyManager comp = GetCompEM();
7147 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
7148 {
7149 comp.SetEnergy0To1(quantity_randomized);
7150 }
7151 }
7152 else if (HasQuantity())
7153 {
7154 SetQuantityNormalized(quantity_randomized, false);
7155 //PrintString("<==> Normalized quantity for item: "+ GetType()+", qmin:"+q_min.ToString()+"; qmax:"+q_max.ToString()+";quantity:" +quantity_randomized.ToString());
7156 }
7157
7158 }
7159 }
7160 }
7161
7163 void LockToParent()
7164 {
7165 EntityAI parent = GetHierarchyParent();
7166
7167 if (parent)
7168 {
7169 InventoryLocation inventory_location_to_lock = new InventoryLocation;
7170 GetInventory().GetCurrentInventoryLocation(inventory_location_to_lock);
7171 parent.GetInventory().SetSlotLock(inventory_location_to_lock.GetSlot(), true);
7172 }
7173 }
7174
7176 void UnlockFromParent()
7177 {
7178 EntityAI parent = GetHierarchyParent();
7179
7180 if (parent)
7181 {
7182 InventoryLocation inventory_location_to_unlock = new InventoryLocation;
7183 GetInventory().GetCurrentInventoryLocation(inventory_location_to_unlock);
7184 parent.GetInventory().SetSlotLock(inventory_location_to_unlock.GetSlot(), false);
7185 }
7186 }
7187
7188 override void CombineItemsClient(EntityAI entity2, bool use_stack_max = true)
7189 {
7190 /*
7191 ref Param1<EntityAI> item = new Param1<EntityAI>(entity2);
7192 RPCSingleParam(ERPCs.RPC_ITEM_COMBINE, item, g_Game.GetPlayer());
7193 */
7194 ItemBase item2 = ItemBase.Cast(entity2);
7195
7196 if (g_Game.IsClient())
7197 {
7198 if (ScriptInputUserData.CanStoreInputUserData())
7199 {
7200 ScriptInputUserData ctx = new ScriptInputUserData;
7202 ctx.Write(-1);
7203 ItemBase i1 = this; // @NOTE: workaround for correct serialization
7204 ctx.Write(i1);
7205 ctx.Write(item2);
7206 ctx.Write(use_stack_max);
7207 ctx.Write(-1);
7208 ctx.Send();
7209
7210 if (IsCombineAll(item2, use_stack_max))
7211 {
7212 g_Game.GetPlayer().GetInventory().AddInventoryReservationEx(item2,null,GameInventory.c_InventoryReservationTimeoutShortMS);
7213 }
7214 }
7215 }
7216 else if (!g_Game.IsMultiplayer())
7217 {
7218 CombineItems(item2, use_stack_max);
7219 }
7220 }
7221
7222 bool IsLiquidPresent()
7223 {
7224 return (GetLiquidType() != 0 && HasQuantity());
7225 }
7226
7227 bool IsLiquidContainer()
7228 {
7229 return m_LiquidContainerMask != 0;
7230 }
7231
7233 {
7234 return m_LiquidContainerMask;
7235 }
7236
7237 bool IsBloodContainer()
7238 {
7239 //m_LiquidContainerMask & GROUP_LIQUID_BLOOD ???
7240 return false;
7241 }
7242
7243 bool IsNVG()
7244 {
7245 return false;
7246 }
7247
7250 bool IsExplosive()
7251 {
7252 return false;
7253 }
7254
7256 {
7257 return "";
7258 }
7259
7261
7262 bool IsLightSource()
7263 {
7264 return false;
7265 }
7266
7268 {
7269 return true;
7270 }
7271
7272 //--- ACTION CONDITIONS
7273 //direction
7274 bool IsFacingPlayer(PlayerBase player, string selection)
7275 {
7276 return true;
7277 }
7278
7279 bool IsPlayerInside(PlayerBase player, string selection)
7280 {
7281 return true;
7282 }
7283
7284 override bool CanObstruct()
7285 {
7286 PlayerBase player = PlayerBase.Cast(g_Game.GetPlayer());
7287 return !player || !IsPlayerInside(player, "");
7288 }
7289
7290 override bool IsBeingPlaced()
7291 {
7292 return m_IsBeingPlaced;
7293 }
7294
7295 void SetIsBeingPlaced(bool is_being_placed)
7296 {
7297 m_IsBeingPlaced = is_being_placed;
7298 if (!is_being_placed)
7300 SetSynchDirty();
7301 }
7302
7303 //server-side
7304 void OnEndPlacement() {}
7305
7306 override bool IsHologram()
7307 {
7308 return m_IsHologram;
7309 }
7310
7311 bool CanBeDigged()
7312 {
7313 return m_CanBeDigged;
7314 }
7315
7317 {
7318 return 1;
7319 }
7320
7321 bool CanMakeGardenplot()
7322 {
7323 return false;
7324 }
7325
7326 void SetIsHologram(bool is_hologram)
7327 {
7328 m_IsHologram = is_hologram;
7329 SetSynchDirty();
7330 }
7331 /*
7332 protected float GetNutritionalEnergy()
7333 {
7334 Edible_Base edible = Edible_Base.Cast(this);
7335 return edible.GetFoodEnergy();
7336 }
7337
7338 protected float GetNutritionalWaterContent()
7339 {
7340 Edible_Base edible = Edible_Base.Cast(this);
7341 return edible.GetFoodWater();
7342 }
7343
7344 protected float GetNutritionalIndex()
7345 {
7346 Edible_Base edible = Edible_Base.Cast(this);
7347 return edible.GetFoodNutritionalIndex();
7348 }
7349
7350 protected float GetNutritionalFullnessIndex()
7351 {
7352 Edible_Base edible = Edible_Base.Cast(this);
7353 return edible.GetFoodTotalVolume();
7354 }
7355
7356 protected float GetNutritionalToxicity()
7357 {
7358 Edible_Base edible = Edible_Base.Cast(this);
7359 return edible.GetFoodToxicity();
7360
7361 }
7362 */
7363
7364
7365 // -------------------------------------------------------------------------
7366 override void OnMovedInsideCargo(EntityAI container)
7367 {
7368 super.OnMovedInsideCargo(container);
7369
7370 MiscGameplayFunctions.RemoveAllAttachedChildrenByTypename(this, {Bolt_Base});
7371 }
7372
7373 override void EEItemLocationChanged(notnull InventoryLocation oldLoc, notnull InventoryLocation newLoc)
7374 {
7375 super.EEItemLocationChanged(oldLoc, newLoc);
7376
7377 PlayerBase newPlayer = null;
7378 PlayerBase oldPlayer = null;
7379
7380 if (newLoc.GetParent())
7381 newPlayer = PlayerBase.Cast(newLoc.GetParent().GetHierarchyRootPlayer());
7382
7383 if (oldLoc.GetParent())
7384 oldPlayer = PlayerBase.Cast(oldLoc.GetParent().GetHierarchyRootPlayer());
7385
7386 if (oldPlayer && oldLoc.GetType() == InventoryLocationType.HANDS)
7387 {
7388 int rIndex = oldPlayer.GetHumanInventory().FindUserReservedLocationIndex(this);
7389
7390 if (rIndex >= 0)
7391 {
7392 InventoryLocation rIl = new InventoryLocation;
7393 oldPlayer.GetHumanInventory().GetUserReservedLocation(rIndex, rIl);
7394
7395 oldPlayer.GetHumanInventory().ClearUserReservedLocationAtIndex(rIndex);
7396 int rType = rIl.GetType();
7397 if (rType == InventoryLocationType.CARGO || rType == InventoryLocationType.PROXYCARGO)
7398 {
7399 rIl.GetParent().GetOnReleaseLock().Invoke(this);
7400 }
7401 else if (rType == InventoryLocationType.ATTACHMENT)
7402 {
7403 rIl.GetParent().GetOnAttachmentReleaseLock().Invoke(this, rIl.GetSlot());
7404 }
7405
7406 }
7407 }
7408
7409 if (newLoc.GetType() == InventoryLocationType.HANDS && oldLoc.GetType() != InventoryLocationType.TEMP)
7410 {
7411 if (newPlayer)
7412 newPlayer.ForceStandUpForHeavyItems(newLoc.GetItem());
7413
7414 if (newPlayer == oldPlayer)
7415 {
7416 if (oldLoc.GetParent() && newPlayer.GetHumanInventory().LocationGetEntity(oldLoc) == NULL)
7417 {
7418 if (oldLoc.GetType() == InventoryLocationType.CARGO)
7419 {
7420 if (oldLoc.GetParent().GetInventory().TestAddEntityInCargoExLoc(oldLoc, false, false, false, true, false, false))
7421 {
7422 newPlayer.GetHumanInventory().SetUserReservedLocation(this,oldLoc);
7423 }
7424 }
7425 else
7426 {
7427 newPlayer.GetHumanInventory().SetUserReservedLocation(this,oldLoc);
7428 }
7429 }
7430
7431 if (newPlayer.GetHumanInventory().FindUserReservedLocationIndex(this) >= 0)
7432 {
7433 int type = oldLoc.GetType();
7434 if (type == InventoryLocationType.CARGO || type == InventoryLocationType.PROXYCARGO)
7435 {
7436 oldLoc.GetParent().GetOnSetLock().Invoke(this);
7437 }
7438 else if (type == InventoryLocationType.ATTACHMENT)
7439 {
7440 oldLoc.GetParent().GetOnAttachmentSetLock().Invoke(this, oldLoc.GetSlot());
7441 }
7442 }
7443 if (!m_OldLocation)
7444 {
7445 m_OldLocation = new InventoryLocation;
7446 }
7447 m_OldLocation.Copy(oldLoc);
7448 }
7449 else
7450 {
7451 if (m_OldLocation)
7452 {
7453 m_OldLocation.Reset();
7454 }
7455 }
7456
7457 g_Game.GetAnalyticsClient().OnItemAttachedAtPlayer(this,"Hands");
7458 }
7459 else
7460 {
7461 if (newPlayer)
7462 {
7463 int resIndex = newPlayer.GetHumanInventory().FindCollidingUserReservedLocationIndex(this, newLoc);
7464 if (resIndex >= 0)
7465 {
7466 InventoryLocation il = new InventoryLocation;
7467 newPlayer.GetHumanInventory().GetUserReservedLocation(resIndex, il);
7468 ItemBase it = ItemBase.Cast(il.GetItem());
7469 newPlayer.GetHumanInventory().ClearUserReservedLocationAtIndex(resIndex);
7470 int rel_type = il.GetType();
7471 if (rel_type == InventoryLocationType.CARGO || rel_type == InventoryLocationType.PROXYCARGO)
7472 {
7473 il.GetParent().GetOnReleaseLock().Invoke(it);
7474 }
7475 else if (rel_type == InventoryLocationType.ATTACHMENT)
7476 {
7477 il.GetParent().GetOnAttachmentReleaseLock().Invoke(it, il.GetSlot());
7478 }
7479 //it.GetOnReleaseLock().Invoke(it);
7480 }
7481 }
7482 else if (oldPlayer && newLoc.GetType() == InventoryLocationType.GROUND && m_ThrowItemOnDrop)
7483 {
7484 //ThrowPhysically(oldPlayer, vector.Zero);
7485 m_ThrowItemOnDrop = false;
7486 }
7487
7488 if (m_OldLocation)
7489 {
7490 m_OldLocation.Reset();
7491 }
7492 }
7493
7494 if (oldLoc.GetType() == InventoryLocationType.TEMP)
7495 {
7496 PluginInventoryRepair.Cast(GetPlugin(PluginInventoryRepair)).Remove(oldLoc.GetItem());
7497 }
7498
7499 if (newLoc.GetType() == InventoryLocationType.TEMP)
7500 {
7501 PluginInventoryRepair.Cast(GetPlugin(PluginInventoryRepair)).Add(oldLoc.GetItem());
7502 }
7503 }
7504
7505 override void EOnContact(IEntity other, Contact extra)
7506 {
7508 {
7509 int liquidType = -1;
7510 float impactSpeed = ProcessImpactSoundEx(other, extra, m_ConfigWeight, m_ImpactSoundSurfaceHash, liquidType);
7511 if (impactSpeed > 0.0)
7512 {
7513 m_ImpactSpeed = impactSpeed;
7514 #ifndef SERVER
7515 PlayImpactSound(m_ConfigWeight, m_ImpactSpeed, m_ImpactSoundSurfaceHash);
7516 #else
7517 m_WantPlayImpactSound = true;
7518 SetSynchDirty();
7519 #endif
7520 m_CanPlayImpactSound = (liquidType == -1);// prevents further playing of the sound when the surface is a liquid type
7521 }
7522 }
7523
7524 #ifdef SERVER
7525 if (GetCompEM() && GetCompEM().IsPlugged())
7526 {
7527 if (GetCompEM().GetCordLength() < vector.Distance(GetPosition(), GetCompEM().GetEnergySource().GetPosition()))
7528 GetCompEM().UnplugThis();
7529 }
7530 #endif
7531 }
7532
7533 void RefreshPhysics();
7534
7535 override void OnCreatePhysics()
7536 {
7538 }
7539
7540 override void OnItemAttachmentSlotChanged(notnull InventoryLocation oldLoc, notnull InventoryLocation newLoc)
7541 {
7542
7543 }
7544 // -------------------------------------------------------------------------
7545 override void OnItemLocationChanged(EntityAI old_owner, EntityAI new_owner)
7546 {
7547 super.OnItemLocationChanged(old_owner, new_owner);
7548
7549 PlayerBase relatedPlayer = PlayerBase.Cast(old_owner);
7550 PlayerBase playerNew = PlayerBase.Cast(new_owner);
7551
7552 if (!relatedPlayer && playerNew)
7553 relatedPlayer = playerNew;
7554
7555 if (relatedPlayer && relatedPlayer.GetPerformedActionID() != -1)
7556 {
7557 ActionManagerBase actionMgr = relatedPlayer.GetActionManager();
7558 if (actionMgr)
7559 {
7560 ActionBase currentAction = actionMgr.GetRunningAction();
7561 if (currentAction)
7562 currentAction.OnItemLocationChanged(this);
7563 }
7564 }
7565
7566 Man ownerPlayerOld = null;
7567 Man ownerPlayerNew = null;
7568
7569 if (old_owner)
7570 {
7571 if (old_owner.IsMan())
7572 {
7573 ownerPlayerOld = Man.Cast(old_owner);
7574 }
7575 else
7576 {
7577 ownerPlayerOld = Man.Cast(old_owner.GetHierarchyRootPlayer());
7578 }
7579 }
7580 else
7581 {
7582 if (new_owner && IsElectricAppliance() && GetCompEM() && GetCompEM().IsPlugged())
7583 {
7584 ActionBase action = ActionManagerBase.GetAction(ActionRepositionPluggedItem);
7585
7586 if (!action || !playerNew || playerNew.GetPerformedActionID() != action.GetID())
7587 {
7588 GetCompEM().UnplugThis();
7589 }
7590 }
7591 }
7592
7593 if (new_owner)
7594 {
7595 if (new_owner.IsMan())
7596 {
7597 ownerPlayerNew = Man.Cast(new_owner);
7598 }
7599 else
7600 {
7601 ownerPlayerNew = Man.Cast(new_owner.GetHierarchyRootPlayer());
7602 }
7603 }
7604
7605 if (ownerPlayerOld != ownerPlayerNew)
7606 {
7607 if (ownerPlayerOld)
7608 {
7609 array<EntityAI> subItemsExit = new array<EntityAI>;
7610 GetInventory().EnumerateInventory(InventoryTraversalType.PREORDER,subItemsExit);
7611 for (int i = 0; i < subItemsExit.Count(); i++)
7612 {
7613 ItemBase itemExit = ItemBase.Cast(subItemsExit.Get(i));
7614 itemExit.OnInventoryExit(ownerPlayerOld);
7615 }
7616 }
7617
7618 if (ownerPlayerNew)
7619 {
7620 array<EntityAI> subItemsEnter = new array<EntityAI>;
7621 GetInventory().EnumerateInventory(InventoryTraversalType.PREORDER,subItemsEnter);
7622 for (int j = 0; j < subItemsEnter.Count(); j++)
7623 {
7624 ItemBase itemEnter = ItemBase.Cast(subItemsEnter.Get(j));
7625 itemEnter.OnInventoryEnter(ownerPlayerNew);
7626 }
7627 }
7628 }
7629 else if (ownerPlayerNew != null)
7630 {
7631 PlayerBase nplayer;
7632 if (PlayerBase.CastTo(nplayer, ownerPlayerNew))
7633 {
7634 array<EntityAI> subItemsUpdate = new array<EntityAI>;
7635 GetInventory().EnumerateInventory(InventoryTraversalType.PREORDER,subItemsUpdate);
7636 for (int k = 0; k < subItemsUpdate.Count(); k++)
7637 {
7638 ItemBase itemUpdate = ItemBase.Cast(subItemsUpdate.Get(k));
7639 itemUpdate.UpdateQuickbarShortcutVisibility(nplayer);
7640 }
7641 }
7642 }
7643
7644 if (old_owner)
7645 old_owner.OnChildItemRemoved(this);
7646 if (new_owner)
7647 new_owner.OnChildItemReceived(this);
7648 }
7649
7650 // -------------------------------------------------------------------------------
7651 override void EEDelete(EntityAI parent)
7652 {
7653 super.EEDelete(parent);
7654 PlayerBase player = PlayerBase.Cast(GetHierarchyRootPlayer());
7655 if (player)
7656 {
7657 OnInventoryExit(player);
7658
7659 if (player.IsAlive())
7660 {
7661 int r_index = player.GetHumanInventory().FindUserReservedLocationIndex(this);
7662 if (r_index >= 0)
7663 {
7664 InventoryLocation r_il = new InventoryLocation;
7665 player.GetHumanInventory().GetUserReservedLocation(r_index,r_il);
7666
7667 player.GetHumanInventory().ClearUserReservedLocationAtIndex(r_index);
7668 int r_type = r_il.GetType();
7669 if (r_type == InventoryLocationType.CARGO || r_type == InventoryLocationType.PROXYCARGO)
7670 {
7671 r_il.GetParent().GetOnReleaseLock().Invoke(this);
7672 }
7673 else if (r_type == InventoryLocationType.ATTACHMENT)
7674 {
7675 r_il.GetParent().GetOnAttachmentReleaseLock().Invoke(this, r_il.GetSlot());
7676 }
7677
7678 }
7679
7680 player.RemoveQuickBarEntityShortcut(this);
7681 }
7682 }
7683 }
7684 // -------------------------------------------------------------------------------
7685 override void EEKilled(Object killer)
7686 {
7687 super.EEKilled(killer);
7688
7690 if (killer && killer.IsFireplace() && CanExplodeInFire())
7691 {
7692 if (GetTemperature() >= GameConstants.ITEM_TEMPERATURE_TO_EXPLODE_MIN)
7693 {
7694 if (IsMagazine())
7695 {
7696 if (Magazine.Cast(this).GetAmmoCount() > 0)
7697 {
7698 ExplodeAmmo();
7699 }
7700 }
7701 else
7702 {
7703 Explode(DamageType.EXPLOSION);
7704 }
7705 }
7706 }
7707 }
7708
7709 override void OnWasAttached(EntityAI parent, int slot_id)
7710 {
7711 MiscGameplayFunctions.RemoveAllAttachedChildrenByTypename(this, {Bolt_Base});
7712
7713 super.OnWasAttached(parent, slot_id);
7714
7715 if (HasQuantity())
7716 UpdateNetSyncVariableFloat("m_VarQuantity", GetQuantityMin(), m_VarQuantityMax);
7717
7718 if (g_Game.IsServer() || !g_Game.IsMultiplayer()) // single player or server side multiplayer
7719 StartItemSoundServer(SoundConstants.ITEM_ATTACH, slot_id);
7720 }
7721
7722 override void OnWasDetached(EntityAI parent, int slot_id)
7723 {
7724 super.OnWasDetached(parent, slot_id);
7725
7726 if (HasQuantity())
7727 UpdateNetSyncVariableFloat("m_VarQuantity", GetQuantityMin(), m_VarQuantityMax);
7728
7729 if (g_Game.IsServer() || !g_Game.IsMultiplayer()) // single player or server side multiplayer
7730 StartItemSoundServer(SoundConstants.ITEM_DETACH, slot_id);
7731 }
7732
7733 override string ChangeIntoOnAttach(string slot)
7734 {
7735 int idx;
7736 TStringArray inventory_slots = new TStringArray;
7737 TStringArray attach_types = new TStringArray;
7738
7739 ConfigGetTextArray("ChangeInventorySlot",inventory_slots);
7740 if (inventory_slots.Count() < 1) //is string
7741 {
7742 inventory_slots.Insert(ConfigGetString("ChangeInventorySlot"));
7743 attach_types.Insert(ConfigGetString("ChangeIntoOnAttach"));
7744 }
7745 else //is array
7746 {
7747 ConfigGetTextArray("ChangeIntoOnAttach",attach_types);
7748 }
7749
7750 idx = inventory_slots.Find(slot);
7751 if (idx < 0)
7752 return "";
7753
7754 return attach_types.Get(idx);
7755 }
7756
7757 override string ChangeIntoOnDetach()
7758 {
7759 int idx = -1;
7760 string slot;
7761
7762 TStringArray inventory_slots = new TStringArray;
7763 TStringArray detach_types = new TStringArray;
7764
7765 this.ConfigGetTextArray("ChangeInventorySlot",inventory_slots);
7766 if (inventory_slots.Count() < 1) //is string
7767 {
7768 inventory_slots.Insert(this.ConfigGetString("ChangeInventorySlot"));
7769 detach_types.Insert(this.ConfigGetString("ChangeIntoOnDetach"));
7770 }
7771 else //is array
7772 {
7773 this.ConfigGetTextArray("ChangeIntoOnDetach",detach_types);
7774 if (detach_types.Count() < 1)
7775 detach_types.Insert(this.ConfigGetString("ChangeIntoOnDetach"));
7776 }
7777
7778 for (int i = 0; i < inventory_slots.Count(); i++)
7779 {
7780 slot = inventory_slots.Get(i);
7781 }
7782
7783 if (slot != "")
7784 {
7785 if (detach_types.Count() == 1)
7786 idx = 0;
7787 else
7788 idx = inventory_slots.Find(slot);
7789 }
7790 if (idx < 0)
7791 return "";
7792
7793 return detach_types.Get(idx);
7794 }
7795
7796 void ExplodeAmmo()
7797 {
7798 //timer
7799 ref Timer explode_timer = new Timer(CALL_CATEGORY_SYSTEM);
7800
7801 //min/max time
7802 float min_time = 1;
7803 float max_time = 3;
7804 float delay = Math.RandomFloat(min_time, max_time);
7805
7806 explode_timer.Run(delay, this, "DoAmmoExplosion");
7807 }
7808
7809 void DoAmmoExplosion()
7810 {
7811 Magazine magazine = Magazine.Cast(this);
7812 int pop_sounds_count = 6;
7813 string pop_sounds[ 6 ] = { "ammopops_1","ammopops_2","ammopops_3","ammopops_4","ammopops_5","ammopops_6" };
7814
7815 //play sound
7816 int sound_idx = Math.RandomInt(0, pop_sounds_count - 1);
7817 string sound_name = pop_sounds[ sound_idx ];
7818 g_Game.CreateSoundOnObject(this, sound_name, 20, false);
7819
7820 //remove ammo count
7821 magazine.ServerAddAmmoCount(-1);
7822
7823 //if condition then repeat -> ExplodeAmmo
7824 float min_temp_to_explode = 100; //min temperature for item to explode
7825
7826 if (magazine.GetAmmoCount() > 0 && GetTemperature() >= min_temp_to_explode) //TODO ? add check for parent -> fireplace
7827 {
7828 ExplodeAmmo();
7829 }
7830 }
7831
7832 // -------------------------------------------------------------------------------
7833 override void EEHitBy(TotalDamageResult damageResult, int damageType, EntityAI source, int component, string dmgZone, string ammo, vector modelPos, float speedCoef)
7834 {
7835 super.EEHitBy(damageResult, damageType, source, component, dmgZone, ammo, modelPos, speedCoef);
7836
7837 const int CHANCE_DAMAGE_CARGO = 4;
7838 const int CHANCE_DAMAGE_ATTACHMENT = 1;
7839 const int CHANCE_DAMAGE_NOTHING = 2;
7840
7841 if (IsClothing() || IsContainer() || IsItemTent())
7842 {
7843 float dmg = damageResult.GetDamage("","Health") * -0.5;
7844 int chances;
7845 int rnd;
7846
7847 if (GetInventory().GetCargo())
7848 {
7849 chances = CHANCE_DAMAGE_CARGO + CHANCE_DAMAGE_ATTACHMENT + CHANCE_DAMAGE_NOTHING;
7850 rnd = Math.RandomInt(0,chances);
7851
7852 if (rnd < CHANCE_DAMAGE_CARGO)
7853 {
7854 DamageItemInCargo(dmg);
7855 }
7856 else if (rnd < (chances - CHANCE_DAMAGE_NOTHING))
7857 {
7859 }
7860 }
7861 else
7862 {
7863 chances = CHANCE_DAMAGE_ATTACHMENT + CHANCE_DAMAGE_NOTHING;
7864 rnd = Math.RandomInt(0,chances);
7865
7866 if (rnd < CHANCE_DAMAGE_ATTACHMENT)
7867 {
7869 }
7870 }
7871 }
7872 }
7873
7874 bool DamageItemInCargo(float damage)
7875 {
7876 CargoBase cargo = GetInventory().GetCargo();
7877 if (cargo)
7878 {
7879 int item_count = cargo.GetItemCount();
7880 if (item_count > 0)
7881 {
7882 int random_pick = Math.RandomInt(0, item_count);
7883 ItemBase item = ItemBase.Cast(cargo.GetItem(random_pick));
7884 if (!item.IsExplosive())
7885 {
7886 item.AddHealth("","",damage);
7887 return true;
7888 }
7889 }
7890 }
7891 return false;
7892 }
7893
7894 bool DamageItemAttachments(float damage)
7895 {
7896 GameInventory inventory = GetInventory();
7897 int attachment_count = inventory.AttachmentCount();
7898 if (attachment_count > 0)
7899 {
7900 int random_pick = Math.RandomInt(0, attachment_count);
7901 ItemBase attachment = ItemBase.Cast(inventory.GetAttachmentFromIndex(random_pick));
7902 if (!attachment.IsExplosive())
7903 {
7904 attachment.AddHealth("","",damage);
7905 return true;
7906 }
7907 }
7908 return false;
7909 }
7910
7911 override bool IsSplitable()
7912 {
7913 return m_CanThisBeSplit;
7914 }
7915 //----------------
7916 override bool CanBeSplit()
7917 {
7918 if (IsSplitable() && (GetQuantity() > 1))
7919 return GetInventory().CanRemoveEntity();
7920
7921 return false;
7922 }
7923
7924 protected bool ShouldSplitQuantity(float quantity)
7925 {
7926 // don't call 'CanBeSplit' here, too strict and will introduce a freeze-crash when dismantling fence with a fireplace nearby
7927 if (!IsSplitable())
7928 return false;
7929
7930 // nothing to split?
7931 if (GetQuantity() <= 1)
7932 return false;
7933
7934 // check if we should re-use the item instead of creating a new copy?
7935 // implicit cast to int, if 'IsSplitable' returns true, these values are assumed ints
7936 int delta = GetQuantity() - quantity;
7937 if (delta == 0)
7938 return false;
7939
7940 // valid to split
7941 return true;
7942 }
7943
7944 override void SplitIntoStackMaxClient(EntityAI destination_entity, int slot_id )
7945 {
7946 if (g_Game.IsClient())
7947 {
7948 if (ScriptInputUserData.CanStoreInputUserData())
7949 {
7950 ScriptInputUserData ctx = new ScriptInputUserData;
7952 ctx.Write(1);
7953 ItemBase i1 = this; // @NOTE: workaround for correct serialization
7954 ctx.Write(i1);
7955 ctx.Write(destination_entity);
7956 ctx.Write(true);
7957 ctx.Write(slot_id);
7958 ctx.Send();
7959 }
7960 }
7961 else if (!g_Game.IsMultiplayer())
7962 {
7963 SplitIntoStackMax(destination_entity, slot_id, PlayerBase.Cast(g_Game.GetPlayer()));
7964 }
7965 }
7966
7967 void SplitIntoStackMax(EntityAI destination_entity, int slot_id, PlayerBase player)
7968 {
7969 float split_quantity_new;
7970 ItemBase new_item;
7971 float quantity = GetQuantity();
7972 float stack_max = GetTargetQuantityMax(slot_id);
7973 InventoryLocation loc = new InventoryLocation;
7974
7975 if (destination_entity && slot_id != -1 && InventorySlots.IsSlotIdValid(slot_id))
7976 {
7977 if (stack_max <= GetQuantity())
7978 split_quantity_new = stack_max;
7979 else
7980 split_quantity_new = GetQuantity();
7981
7982 if (ShouldSplitQuantity(split_quantity_new))
7983 {
7984 new_item = ItemBase.Cast(destination_entity.GetInventory().CreateAttachmentEx(this.GetType(), slot_id));
7985 if (new_item)
7986 {
7987 new_item.SetResultOfSplit(true);
7988 MiscGameplayFunctions.TransferItemProperties(this, new_item);
7989 AddQuantity(-split_quantity_new, false, true);
7990 new_item.SetQuantity(split_quantity_new, false, true);
7991 }
7992 }
7993 }
7994 else if (destination_entity && slot_id == -1)
7995 {
7996 if (quantity > stack_max)
7997 split_quantity_new = stack_max;
7998 else
7999 split_quantity_new = quantity;
8000
8001 if (ShouldSplitQuantity(split_quantity_new))
8002 {
8003 GameInventory destinationInventory = destination_entity.GetInventory();
8004 if (destinationInventory.FindFreeLocationFor(this, FindInventoryLocationType.ANY, loc))
8005 {
8006 Object o = destinationInventory.LocationCreateEntity(loc, GetType(), ECE_IN_INVENTORY, RF_DEFAULT);
8007 new_item = ItemBase.Cast(o);
8008 }
8009
8010 if (new_item)
8011 {
8012 new_item.SetResultOfSplit(true);
8013 MiscGameplayFunctions.TransferItemProperties(this, new_item);
8014 AddQuantity(-split_quantity_new, false, true);
8015 new_item.SetQuantity(split_quantity_new, false, true);
8016 }
8017 }
8018 }
8019 else
8020 {
8021 if (stack_max != 0)
8022 {
8023 if (stack_max < GetQuantity())
8024 {
8025 split_quantity_new = GetQuantity() - stack_max;
8026 }
8027
8028 if (split_quantity_new == 0)
8029 {
8030 if (!g_Game.IsMultiplayer())
8031 player.PhysicalPredictiveDropItem(this);
8032 else
8033 player.ServerDropEntity(this);
8034 return;
8035 }
8036
8037 if (ShouldSplitQuantity(split_quantity_new))
8038 {
8039 new_item = ItemBase.Cast(g_Game.CreateObjectEx(GetType(), player.GetWorldPosition(), ECE_PLACE_ON_SURFACE));
8040
8041 if (new_item)
8042 {
8043 new_item.SetResultOfSplit(true);
8044 MiscGameplayFunctions.TransferItemProperties(this, new_item);
8045 SetQuantity(split_quantity_new, false, true);
8046 new_item.SetQuantity(stack_max, false, true);
8047 new_item.PlaceOnSurface();
8048 }
8049 }
8050 }
8051 }
8052 }
8053
8054 override void SplitIntoStackMaxEx(EntityAI destination_entity, int slot_id)
8055 {
8056 float split_quantity_new;
8057 ItemBase new_item;
8058 float quantity = GetQuantity();
8059 float stack_max = GetTargetQuantityMax(slot_id);
8060 InventoryLocation loc = new InventoryLocation;
8061
8062 if (destination_entity && slot_id != -1 && InventorySlots.IsSlotIdValid(slot_id))
8063 {
8064 if (stack_max <= GetQuantity())
8065 split_quantity_new = stack_max;
8066 else
8067 split_quantity_new = GetQuantity();
8068
8069 if (ShouldSplitQuantity(split_quantity_new))
8070 {
8071 new_item = ItemBase.Cast(destination_entity.GetInventory().CreateAttachmentEx(this.GetType(), slot_id));
8072 if (new_item)
8073 {
8074 new_item.SetResultOfSplit(true);
8075 MiscGameplayFunctions.TransferItemProperties(this, new_item);
8076 AddQuantity(-split_quantity_new, false, true);
8077 new_item.SetQuantity(split_quantity_new, false, true);
8078 }
8079 }
8080 }
8081 else if (destination_entity && slot_id == -1)
8082 {
8083 if (quantity > stack_max)
8084 split_quantity_new = stack_max;
8085 else
8086 split_quantity_new = quantity;
8087
8088 if (ShouldSplitQuantity(split_quantity_new))
8089 {
8090 GameInventory destinationInventory = destination_entity.GetInventory();
8091 if (destinationInventory.FindFreeLocationFor(this, FindInventoryLocationType.ANY, loc))
8092 {
8093 Object o = destinationInventory.LocationCreateEntity(loc, GetType(), ECE_IN_INVENTORY, RF_DEFAULT);
8094 new_item = ItemBase.Cast(o);
8095 }
8096
8097 if (new_item)
8098 {
8099 new_item.SetResultOfSplit(true);
8100 MiscGameplayFunctions.TransferItemProperties(this, new_item);
8101 AddQuantity(-split_quantity_new, false, true);
8102 new_item.SetQuantity(split_quantity_new, false, true);
8103 }
8104 }
8105 }
8106 else
8107 {
8108 if (stack_max != 0)
8109 {
8110 if (stack_max < GetQuantity())
8111 {
8112 split_quantity_new = GetQuantity() - stack_max;
8113 }
8114
8115 if (ShouldSplitQuantity(split_quantity_new))
8116 {
8117 new_item = ItemBase.Cast(g_Game.CreateObjectEx(GetType(),GetWorldPosition(), ECE_PLACE_ON_SURFACE));
8118
8119 if (new_item)
8120 {
8121 new_item.SetResultOfSplit(true);
8122 MiscGameplayFunctions.TransferItemProperties(this, new_item);
8123 SetQuantity(split_quantity_new, false, true);
8124 new_item.SetQuantity(stack_max, false, true);
8125 new_item.PlaceOnSurface();
8126 }
8127 }
8128 }
8129 }
8130 }
8131
8132 void SplitIntoStackMaxToInventoryLocationClient(notnull InventoryLocation dst)
8133 {
8134 if (g_Game.IsClient())
8135 {
8136 if (ScriptInputUserData.CanStoreInputUserData())
8137 {
8138 ScriptInputUserData ctx = new ScriptInputUserData;
8140 ctx.Write(4);
8141 ItemBase thiz = this; // @NOTE: workaround for correct serialization
8142 ctx.Write(thiz);
8143 dst.WriteToContext(ctx);
8144 ctx.Send();
8145 }
8146 }
8147 else if (!g_Game.IsMultiplayer())
8148 {
8150 }
8151 }
8152
8153 void SplitIntoStackMaxCargoClient(EntityAI destination_entity, int idx, int row, int col)
8154 {
8155 if (g_Game.IsClient())
8156 {
8157 if (ScriptInputUserData.CanStoreInputUserData())
8158 {
8159 ScriptInputUserData ctx = new ScriptInputUserData;
8161 ctx.Write(2);
8162 ItemBase dummy = this; // @NOTE: workaround for correct serialization
8163 ctx.Write(dummy);
8164 ctx.Write(destination_entity);
8165 ctx.Write(true);
8166 ctx.Write(idx);
8167 ctx.Write(row);
8168 ctx.Write(col);
8169 ctx.Send();
8170 }
8171 }
8172 else if (!g_Game.IsMultiplayer())
8173 {
8174 SplitIntoStackMaxCargo(destination_entity, idx, row, col);
8175 }
8176 }
8177
8178 void SplitIntoStackMaxToInventoryLocation(notnull InventoryLocation dst)
8179 {
8181 }
8182
8183 ItemBase SplitIntoStackMaxToInventoryLocationEx(notnull InventoryLocation dst)
8184 {
8185 float quantity = GetQuantity();
8186 float split_quantity_new;
8187 ItemBase new_item;
8188 if (dst.IsValid())
8189 {
8190 int slot_id = dst.GetSlot();
8191 float stack_max = GetTargetQuantityMax(slot_id);
8192
8193 if (quantity > stack_max)
8194 split_quantity_new = stack_max;
8195 else
8196 split_quantity_new = quantity;
8197
8198 if (ShouldSplitQuantity(split_quantity_new))
8199 {
8200 new_item = ItemBase.Cast(GameInventory.LocationCreateEntity(dst, this.GetType(), ECE_IN_INVENTORY, RF_DEFAULT));
8201
8202 if (new_item)
8203 {
8204 new_item.SetResultOfSplit(true);
8205 MiscGameplayFunctions.TransferItemProperties(this,new_item);
8206 AddQuantity(-split_quantity_new, false, true);
8207 new_item.SetQuantity(split_quantity_new, false, true);
8208 }
8209
8210 return new_item;
8211 }
8212 }
8213
8214 return null;
8215 }
8216
8217 void SplitIntoStackMaxCargo(EntityAI destination_entity, int idx, int row, int col)
8218 {
8219 float quantity = GetQuantity();
8220 float split_quantity_new;
8221 ItemBase new_item;
8222 if (destination_entity)
8223 {
8224 float stackable = GetTargetQuantityMax();
8225 if (quantity > stackable)
8226 split_quantity_new = stackable;
8227 else
8228 split_quantity_new = quantity;
8229
8230 if (ShouldSplitQuantity(split_quantity_new))
8231 {
8232 new_item = ItemBase.Cast(destination_entity.GetInventory().CreateEntityInCargoEx(this.GetType(), idx, row, col, false));
8233 if (new_item)
8234 {
8235 new_item.SetResultOfSplit(true);
8236 MiscGameplayFunctions.TransferItemProperties(this,new_item);
8237 AddQuantity(-split_quantity_new, false, true);
8238 new_item.SetQuantity(split_quantity_new, false, true);
8239 }
8240 }
8241 }
8242 }
8243
8244 void SplitIntoStackMaxHandsClient(PlayerBase player)
8245 {
8246 if (g_Game.IsClient())
8247 {
8248 if (ScriptInputUserData.CanStoreInputUserData())
8249 {
8250 ScriptInputUserData ctx = new ScriptInputUserData;
8252 ctx.Write(3);
8253 ItemBase i1 = this; // @NOTE: workaround for correct serialization
8254 ctx.Write(i1);
8255 ItemBase destination_entity = this;
8256 ctx.Write(destination_entity);
8257 ctx.Write(true);
8258 ctx.Write(0);
8259 ctx.Send();
8260 }
8261 }
8262 else if (!g_Game.IsMultiplayer())
8263 {
8264 SplitIntoStackMaxHands(player);
8265 }
8266 }
8267
8268 void SplitIntoStackMaxHands(PlayerBase player)
8269 {
8270 float quantity = GetQuantity();
8271 float split_quantity_new;
8272 ref ItemBase new_item;
8273 if (player)
8274 {
8275 float stackable = GetTargetQuantityMax();
8276 if (quantity > stackable)
8277 split_quantity_new = stackable;
8278 else
8279 split_quantity_new = quantity;
8280
8281 if (ShouldSplitQuantity(split_quantity_new))
8282 {
8283 EntityAI in_hands = player.GetHumanInventory().CreateInHands(this.GetType());
8284 new_item = ItemBase.Cast(in_hands);
8285 if (new_item)
8286 {
8287 new_item.SetResultOfSplit(true);
8288 MiscGameplayFunctions.TransferItemProperties(this,new_item);
8289 AddQuantity(-split_quantity_new, false, true);
8290 new_item.SetQuantity(split_quantity_new, false, true);
8291 }
8292 }
8293 }
8294 }
8295
8296 void SplitItemToInventoryLocation(notnull InventoryLocation dst)
8297 {
8298 float quantity = GetQuantity();
8299 float split_quantity_new = Math.Floor(quantity * 0.5);
8300
8301 if (!ShouldSplitQuantity(split_quantity_new))
8302 return;
8303
8304 ItemBase new_item = ItemBase.Cast(GameInventory.LocationCreateEntity(dst, GetType(), ECE_IN_INVENTORY, RF_DEFAULT));
8305
8306 if (new_item)
8307 {
8308 if (new_item.GetQuantityMax() < split_quantity_new)
8309 {
8310 split_quantity_new = new_item.GetQuantityMax();
8311 }
8312
8313 new_item.SetResultOfSplit(true);
8314 MiscGameplayFunctions.TransferItemProperties(this, new_item);
8315
8316 if (dst.IsValid() && dst.GetType() == InventoryLocationType.ATTACHMENT && split_quantity_new > 1)
8317 {
8318 AddQuantity(-1, false, true);
8319 new_item.SetQuantity(1, false, true);
8320 }
8321 else
8322 {
8323 AddQuantity(-split_quantity_new, false, true);
8324 new_item.SetQuantity(split_quantity_new, false, true);
8325 }
8326 }
8327 }
8328
8329 void SplitItem(PlayerBase player)
8330 {
8331 float quantity = GetQuantity();
8332 float split_quantity_new = Math.Floor(quantity / 2);
8333
8334 if (!ShouldSplitQuantity(split_quantity_new))
8335 return;
8336
8337 InventoryLocation invloc = new InventoryLocation;
8338 bool found = player.GetInventory().FindFirstFreeLocationForNewEntity(GetType(), FindInventoryLocationType.ATTACHMENT, invloc);
8339
8340 ItemBase new_item;
8341 new_item = player.CreateCopyOfItemInInventoryOrGroundEx(this, true);
8342
8343 if (new_item)
8344 {
8345 if (new_item.GetQuantityMax() < split_quantity_new)
8346 {
8347 split_quantity_new = new_item.GetQuantityMax();
8348 }
8349 if (found && invloc.IsValid() && invloc.GetType() == InventoryLocationType.ATTACHMENT && split_quantity_new > 1)
8350 {
8351 AddQuantity(-1, false, true);
8352 new_item.SetQuantity(1, false, true);
8353 }
8354 else if (split_quantity_new > 1)
8355 {
8356 AddQuantity(-split_quantity_new, false, true);
8357 new_item.SetQuantity(split_quantity_new, false, true);
8358 }
8359 }
8360 }
8361
8363 void OnQuantityChanged(float delta)
8364 {
8365 SetWeightDirty();
8366 ItemBase parent = ItemBase.Cast(GetHierarchyParent());
8367
8368 if (parent)
8369 parent.OnAttachmentQuantityChangedEx(this, delta);
8370
8371 if (IsLiquidContainer())
8372 {
8373 if (GetQuantityNormalized() <= 0.0)
8374 {
8376 }
8377 else if (GetLiquidType() == LIQUID_NONE)
8378 {
8379 ErrorEx("Undefined liquid type quantity changed, please define liquid type first! Using init value.",ErrorExSeverity.INFO);
8381 }
8382 }
8383 }
8384
8387 {
8388 // insert code here
8389 }
8390
8392 void OnAttachmentQuantityChangedEx(ItemBase item , float delta)
8393 {
8395 }
8396
8397 override void EEHealthLevelChanged(int oldLevel, int newLevel, string zone)
8398 {
8399 super.EEHealthLevelChanged(oldLevel,newLevel,zone);
8400
8401 if (g_Game.IsServer())
8402 {
8403 if (newLevel == GameConstants.STATE_RUINED)
8404 {
8406 EntityAI parent = GetHierarchyParent();
8407 if (parent && parent.IsFireplace())
8408 {
8409 CargoBase cargo = GetInventory().GetCargo();
8410 if (cargo)
8411 {
8412 for (int i = 0; i < cargo.GetItemCount(); ++i)
8413 {
8414 parent.GetInventory().TakeEntityToInventory(InventoryMode.SERVER, FindInventoryLocationType.CARGO, cargo.GetItem(i));
8415 }
8416 }
8417 }
8418 }
8419
8420 if (IsResultOfSplit())
8421 {
8422 // reset the splitting result flag, return to normal item behavior
8423 SetResultOfSplit(false);
8424 return;
8425 }
8426
8427 if (m_Cleanness != 0 && oldLevel < newLevel && newLevel != 0)
8428 {
8429 SetCleanness(0);//unclean the item upon damage dealt
8430 }
8431 }
8432 }
8433
8434 // just the split? TODO: verify
8435 override void OnRightClick()
8436 {
8437 super.OnRightClick();
8438
8439 if (CanBeSplit() && !GetDayZGame().IsLeftCtrlDown() && !g_Game.GetPlayer().GetInventory().HasInventoryReservation(this,null))
8440 {
8441 if (g_Game.IsClient())
8442 {
8443 if (ScriptInputUserData.CanStoreInputUserData())
8444 {
8445 EntityAI root = GetHierarchyRoot();
8446 Man playerOwner = GetHierarchyRootPlayer();
8447 InventoryLocation dst = new InventoryLocation;
8448
8449 // 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
8450 if (!playerOwner && root && root == this)
8451 {
8453 }
8454 else
8455 {
8456 // 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
8457 GetInventory().GetCurrentInventoryLocation(dst);
8458 if (!dst.GetParent() || dst.GetParent() && !dst.GetParent().GetInventory().FindFreeLocationFor(this, FindInventoryLocationType.CARGO, dst))
8459 {
8460 PlayerBase player = PlayerBase.Cast(g_Game.GetPlayer());
8461 if (!player.GetInventory().FindFreeLocationFor(this, FindInventoryLocationType.CARGO, dst) || !playerOwner)
8462 {
8464 }
8465 else
8466 {
8467 dst.SetCargo(dst.GetParent(), this, dst.GetIdx(), dst.GetRow(), dst.GetCol(), dst.GetFlip());
8468 /* hacky solution to check reservation of "this" item instead of null since the gamecode is checking null against null and returning reservation=true incorrectly
8469 this shouldnt cause issues within this scope*/
8470 if (g_Game.GetPlayer().GetInventory().HasInventoryReservation(this, dst))
8471 {
8473 }
8474 else
8475 {
8476 g_Game.GetPlayer().GetInventory().AddInventoryReservationEx(null, dst, GameInventory.c_InventoryReservationTimeoutShortMS);
8477 }
8478 }
8479 }
8480 }
8481
8482 ScriptInputUserData ctx = new ScriptInputUserData;
8484 ctx.Write(4);
8485 ItemBase thiz = this; // @NOTE: workaround for correct serialization
8486 ctx.Write(thiz);
8487 dst.WriteToContext(ctx);
8488 ctx.Write(true); // dummy
8489 ctx.Send();
8490 }
8491 }
8492 else if (!g_Game.IsMultiplayer())
8493 {
8494 SplitItem(PlayerBase.Cast(g_Game.GetPlayer()));
8495 }
8496 }
8497 }
8498
8499 protected void SetInventoryLocationToVicinityOrCurrent(EntityAI root, inout InventoryLocation dst)
8500 {
8501 if (root)
8502 {
8503 vector m4[4];
8504 root.GetTransform(m4);
8505 dst.SetGround(this, m4);
8506 }
8507 else
8508 {
8509 GetInventory().GetCurrentInventoryLocation(dst);
8510 }
8511 }
8512
8513 override bool CanBeCombined(EntityAI other_item, bool reservation_check = true, bool stack_max_limit = false)
8514 {
8515 //TODO: delete check zero quantity check after fix double posts hands fsm events
8516 if (!other_item || GetType() != other_item.GetType() || (IsFullQuantity() && other_item.GetQuantity() > 0) || other_item == this)
8517 return false;
8518
8519 if (GetHealthLevel() == GameConstants.STATE_RUINED || other_item.GetHealthLevel() == GameConstants.STATE_RUINED)
8520 return false;
8521
8522 //can_this_be_combined = ConfigGetBool("canBeSplit");
8524 return false;
8525
8526
8527 Magazine mag = Magazine.Cast(this);
8528 if (mag)
8529 {
8530 if (mag.GetAmmoCount() >= mag.GetAmmoMax())
8531 return false;
8532
8533 if (stack_max_limit)
8534 {
8535 Magazine other_mag = Magazine.Cast(other_item);
8536 if (other_item)
8537 {
8538 if (mag.GetAmmoCount() + other_mag.GetAmmoCount() > mag.GetAmmoMax())
8539 return false;
8540 }
8541
8542 }
8543 }
8544 else
8545 {
8546 //TODO: delete check zero quantity check after fix double posts hands fsm events
8547 if (GetQuantity() >= GetQuantityMax() && other_item.GetQuantity() > 0 )
8548 return false;
8549
8550 if (stack_max_limit && (GetQuantity() + other_item.GetQuantity() > GetQuantityMax()))
8551 return false;
8552 }
8553
8554 PlayerBase player = null;
8555 if (CastTo(player, GetHierarchyRootPlayer())) //false when attached to player's attachment slot
8556 {
8557 if (player.GetInventory().HasAttachment(this))
8558 return false;
8559
8560 if (player.IsItemsToDelete())
8561 return false;
8562 }
8563
8564 if (reservation_check && (GetInventory().HasInventoryReservation(this, null) || other_item.GetInventory().HasInventoryReservation(other_item, null)))
8565 return false;
8566
8567 int slotID;
8568 string slotName;
8569 if (GetInventory().GetCurrentAttachmentSlotInfo(slotID,slotName) && GetHierarchyParent().GetInventory().GetSlotLock(slotID))
8570 return false;
8571
8572 return true;
8573 }
8574
8575 bool IsCombineAll(ItemBase other_item, bool use_stack_max = false)
8576 {
8577 return ComputeQuantityUsed(other_item, use_stack_max) == other_item.GetQuantity();
8578 }
8579
8580 bool IsResultOfSplit()
8581 {
8582 return m_IsResultOfSplit;
8583 }
8584
8585 void SetResultOfSplit(bool value)
8586 {
8587 m_IsResultOfSplit = value;
8588 }
8589
8590 int ComputeQuantityUsed(ItemBase other_item, bool use_stack_max = true)
8591 {
8592 return ComputeQuantityUsedEx(other_item, use_stack_max);
8593 }
8594
8595 float ComputeQuantityUsedEx(ItemBase other_item, bool use_stack_max = true)
8596 {
8597 float other_item_quantity = other_item.GetQuantity();
8598 float this_free_space;
8599
8600 float stack_max = GetQuantityMax();
8601
8602 this_free_space = stack_max - GetQuantity();
8603
8604 if (other_item_quantity > this_free_space)
8605 {
8606 return this_free_space;
8607 }
8608 else
8609 {
8610 return other_item_quantity;
8611 }
8612 }
8613
8614 override void CombineItemsEx(EntityAI entity2, bool use_stack_max = true)
8615 {
8616 CombineItems(ItemBase.Cast(entity2),use_stack_max);
8617 }
8618
8619 void CombineItems(ItemBase other_item, bool use_stack_max = true)
8620 {
8621 if (!CanBeCombined(other_item, false))
8622 return;
8623
8624 if (!IsMagazine() && other_item)
8625 {
8626 float quantity_used = ComputeQuantityUsedEx(other_item,use_stack_max);
8627 if (quantity_used != 0)
8628 {
8629 float hp1 = GetHealth01("","");
8630 float hp2 = other_item.GetHealth01("","");
8631 float hpResult = ((hp1*GetQuantity()) + (hp2*quantity_used));
8632 hpResult = hpResult / (GetQuantity() + quantity_used);
8633
8634 hpResult *= GetMaxHealth();
8635 Math.Round(hpResult);
8636 SetHealth("", "Health", hpResult);
8637
8638 AddQuantity(quantity_used);
8639 other_item.AddQuantity(-quantity_used);
8640 }
8641 }
8642 OnCombine(other_item);
8643 }
8644
8645 void OnCombine(ItemBase other_item)
8646 {
8647 #ifdef SERVER
8648 if (!GetHierarchyRootPlayer() && GetHierarchyParent())
8649 GetHierarchyParent().IncreaseLifetimeUp();
8650 #endif
8651 };
8652
8653 void GetRecipesActions(Man player, out TSelectableActionInfoArray outputList)
8654 {
8655 PlayerBase p = PlayerBase.Cast(player);
8656
8657 array<int> recipesIds = p.m_Recipes;
8658 PluginRecipesManager moduleRecipesManager = PluginRecipesManager.Cast(GetPlugin(PluginRecipesManager));
8659 if (moduleRecipesManager)
8660 {
8661 EntityAI itemInHands = player.GetEntityInHands();
8662 moduleRecipesManager.GetValidRecipes(ItemBase.Cast(this), ItemBase.Cast(itemInHands), recipesIds, p);
8663 }
8664
8665 for (int i = 0;i < recipesIds.Count(); i++)
8666 {
8667 int key = recipesIds.Get(i);
8668 string recipeName = moduleRecipesManager.GetRecipeName(key);
8669 outputList.Insert(new TSelectableActionInfo(SAT_CRAFTING, key, recipeName));
8670 }
8671 }
8672
8673 // -------------------------------------------------------------------------
8674 override void GetDebugActions(out TSelectableActionInfoArrayEx outputList)
8675 {
8676 super.GetDebugActions(outputList);
8677
8678 //quantity
8679 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.ADD_QUANTITY, "Quantity +20%", FadeColors.LIGHT_GREY));
8680 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.REMOVE_QUANTITY, "Quantity -20%", FadeColors.LIGHT_GREY));
8681 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SET_QUANTITY_0, "Set Quantity 0", FadeColors.LIGHT_GREY));
8682 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SET_MAX_QUANTITY, "Set Quantity Max", FadeColors.LIGHT_GREY));
8683 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SEPARATOR, "___________________________", FadeColors.RED));
8684
8685 //health
8686 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.ADD_HEALTH, "Health +20%", FadeColors.LIGHT_GREY));
8687 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.REMOVE_HEALTH, "Health -20%", FadeColors.LIGHT_GREY));
8688 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.DESTROY_HEALTH, "Health 0", FadeColors.LIGHT_GREY));
8689 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SEPARATOR, "___________________________", FadeColors.RED));
8690 //temperature
8691 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.ADD_TEMPERATURE, "Temperature +20", FadeColors.LIGHT_GREY));
8692 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.REMOVE_TEMPERATURE, "Temperature -20", FadeColors.LIGHT_GREY));
8693 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.FLIP_FROZEN, "Toggle Frozen", FadeColors.LIGHT_GREY));
8694 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SEPARATOR, "___________________________", FadeColors.RED));
8695
8696 //wet
8697 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.ADD_WETNESS, "Wetness +20", FadeColors.LIGHT_GREY));
8698 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.REMOVE_WETNESS, "Wetness -20", FadeColors.LIGHT_GREY));
8699 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SEPARATOR, "___________________________", FadeColors.RED));
8700
8701 //liquidtype
8702 if (IsLiquidContainer())
8703 {
8704 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.LIQUIDTYPE_UP, "LiquidType Next", FadeColors.LIGHT_GREY));
8705 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.LIQUIDTYPE_DOWN, "LiquidType Previous", FadeColors.LIGHT_GREY));
8706 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SEPARATOR, "___________________________", FadeColors.RED));
8707 }
8708
8709 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.MAKE_SPECIAL, "Make Special", FadeColors.LIGHT_GREY));
8710 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SEPARATOR, "___________________________", FadeColors.RED));
8711
8712 // watch
8713 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.WATCH_ITEM, "Watch (CTRL-Z)", FadeColors.LIGHT_GREY));
8714 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.WATCH_PLAYER, "Watch Player", FadeColors.LIGHT_GREY));
8715 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SEPARATOR, "___________________________", FadeColors.RED));
8716
8717 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.DELETE, "Delete", FadeColors.RED));
8718
8719 InventoryLocation loc = new InventoryLocation();
8720 GetInventory().GetCurrentInventoryLocation(loc);
8721 if (!loc || loc.GetType() == InventoryLocationType.GROUND)
8722 {
8723 if (Gizmo_IsSupported())
8724 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.GIZMO_OBJECT, "Gizmo Object", FadeColors.LIGHT_GREY));
8725 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.GIZMO_PHYSICS, "Gizmo Physics (SP Only)", FadeColors.LIGHT_GREY)); // intentionally allowed for testing physics desync
8726 }
8727
8728 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SEPARATOR, "___________________________", FadeColors.RED));
8729 }
8730
8731 // -------------------------------------------------------------------------
8732 // -------------------------------------------------------------------------
8733 // -------------------------------------------------------------------------
8734 override bool OnAction(int action_id, Man player, ParamsReadContext ctx)
8735 {
8736 super.OnAction(action_id, player, ctx);
8737
8738 if (g_Game.IsClient() || !g_Game.IsMultiplayer())
8739 {
8740 switch (action_id)
8741 {
8742 case EActions.GIZMO_OBJECT:
8743 if (GetGizmoApi())
8744 GetGizmoApi().SelectObject(this);
8745 return true;
8746 case EActions.GIZMO_PHYSICS:
8747 if (GetGizmoApi())
8748 GetGizmoApi().SelectPhysics(GetPhysics());
8749 return true;
8750 }
8751 }
8752
8753 if (g_Game.IsServer())
8754 {
8755 switch (action_id)
8756 {
8757 case EActions.DELETE:
8758 Delete();
8759 return true;
8760 }
8761 }
8762
8763 if (action_id >= EActions.RECIPES_RANGE_START && action_id < EActions.RECIPES_RANGE_END)
8764 {
8765 PluginRecipesManager plugin_recipes_manager = PluginRecipesManager.Cast(GetPlugin(PluginRecipesManager));
8766 int idWithoutOffset = action_id - EActions.RECIPES_RANGE_START;
8767 PlayerBase p = PlayerBase.Cast(player);
8768 if (EActions.RECIPES_RANGE_START < 1000)
8769 {
8770 float anim_length = plugin_recipes_manager.GetRecipeLengthInSecs(idWithoutOffset);
8771 float specialty_weight = plugin_recipes_manager.GetRecipeSpecialty(idWithoutOffset);
8772 }
8773 }
8774 #ifndef SERVER
8775 else if (action_id == EActions.WATCH_PLAYER)
8776 {
8777 PluginDeveloper.SetDeveloperItemClientEx(player);
8778 }
8779 #endif
8780 if (g_Game.IsServer())
8781 {
8782 if (action_id >= EActions.DEBUG_ITEM_WATCH_BUTTON_RANGE_START && action_id < EActions.DEBUG_ITEM_WATCH_BUTTON_RANGE_END)
8783 {
8784 int id = action_id - EActions.DEBUG_ITEM_WATCH_BUTTON_RANGE_START;
8785 OnDebugButtonPressServer(id + 1);
8786 }
8787
8788 else if (action_id >= EActions.DEBUG_AGENTS_RANGE_INJECT_START && action_id < EActions.DEBUG_AGENTS_RANGE_INJECT_END)
8789 {
8790 int agent_id = action_id - EActions.DEBUG_AGENTS_RANGE_INJECT_START;
8791 InsertAgent(agent_id,100);
8792 }
8793
8794 else if (action_id >= EActions.DEBUG_AGENTS_RANGE_REMOVE_START && action_id < EActions.DEBUG_AGENTS_RANGE_REMOVE_END)
8795 {
8796 int agent_id2 = action_id - EActions.DEBUG_AGENTS_RANGE_REMOVE_START;
8797 RemoveAgent(agent_id2);
8798 }
8799
8800 else if (action_id == EActions.ADD_QUANTITY)
8801 {
8802 if (IsMagazine())
8803 {
8804 Magazine mag = Magazine.Cast(this);
8805 mag.ServerSetAmmoCount(mag.GetAmmoCount() + mag.GetAmmoMax() * 0.2);
8806 }
8807 else
8808 {
8809 AddQuantity(GetQuantityMax() * 0.2);
8810 }
8811
8812 if (m_EM)
8813 {
8814 m_EM.AddEnergy(m_EM.GetEnergyMax() * 0.2);
8815 }
8816 //PrintVariables();
8817 }
8818
8819 else if (action_id == EActions.REMOVE_QUANTITY) //Quantity -20%
8820 {
8821 if (IsMagazine())
8822 {
8823 Magazine mag2 = Magazine.Cast(this);
8824 mag2.ServerSetAmmoCount(mag2.GetAmmoCount() - mag2.GetAmmoMax() * 0.2);
8825 }
8826 else
8827 {
8828 AddQuantity(- GetQuantityMax() * 0.2);
8829 }
8830 if (m_EM)
8831 {
8832 m_EM.AddEnergy(- m_EM.GetEnergyMax() * 0.2);
8833 }
8834 //PrintVariables();
8835 }
8836
8837 else if (action_id == EActions.SET_QUANTITY_0) //SetMaxQuantity
8838 {
8839 SetQuantity(0);
8840
8841 if (m_EM)
8842 {
8843 m_EM.SetEnergy(0);
8844 }
8845 }
8846
8847 else if (action_id == EActions.SET_MAX_QUANTITY) //SetMaxQuantity
8848 {
8850
8851 if (m_EM)
8852 {
8853 m_EM.SetEnergy(m_EM.GetEnergyMax());
8854 }
8855 }
8856
8857 else if (action_id == EActions.ADD_HEALTH)
8858 {
8859 AddHealth("","",GetMaxHealth("","Health")/5);
8860 }
8861 else if (action_id == EActions.REMOVE_HEALTH)
8862 {
8863 AddHealth("","",-GetMaxHealth("","Health")/5);
8864 }
8865 else if (action_id == EActions.DESTROY_HEALTH)
8866 {
8867 SetHealth01("","",0);
8868 }
8869 else if (action_id == EActions.WATCH_ITEM)
8870 {
8872 mid.RegisterDebugItem(ItemBase.Cast(this), PlayerBase.Cast(player));
8873 #ifdef DEVELOPER
8874 SetDebugDeveloper_item(this);
8875 #endif
8876 }
8877
8878 else if (action_id == EActions.ADD_TEMPERATURE)
8879 {
8880 AddTemperature(20);
8881 //PrintVariables();
8882 }
8883
8884 else if (action_id == EActions.REMOVE_TEMPERATURE)
8885 {
8886 AddTemperature(-20);
8887 //PrintVariables();
8888 }
8889
8890 else if (action_id == EActions.FLIP_FROZEN)
8891 {
8892 SetFrozen(!GetIsFrozen());
8893 //PrintVariables();
8894 }
8895
8896 else if (action_id == EActions.ADD_WETNESS)
8897 {
8898 AddWet(GetWetMax()/5);
8899 //PrintVariables();
8900 }
8901
8902 else if (action_id == EActions.REMOVE_WETNESS)
8903 {
8904 AddWet(-GetWetMax()/5);
8905 //PrintVariables();
8906 }
8907
8908 else if (action_id == EActions.LIQUIDTYPE_UP)
8909 {
8910 int curr_type = GetLiquidType();
8911 SetLiquidType(curr_type * 2);
8912 //AddWet(1);
8913 //PrintVariables();
8914 }
8915
8916 else if (action_id == EActions.LIQUIDTYPE_DOWN)
8917 {
8918 int curr_type2 = GetLiquidType();
8919 SetLiquidType(curr_type2 / 2);
8920 }
8921
8922 else if (action_id == EActions.MAKE_SPECIAL)
8923 {
8924 auto debugParams = DebugSpawnParams.WithPlayer(player);
8925 OnDebugSpawnEx(debugParams);
8926 }
8927
8928 }
8929
8930
8931 return false;
8932 }
8933
8934 // -------------------------------------------------------------------------
8935
8936
8939 void OnActivatedByTripWire();
8940
8942 void OnActivatedByItem(notnull ItemBase item);
8943
8944 //----------------------------------------------------------------
8945 //returns true if item is able to explode when put in fire
8946 bool CanExplodeInFire()
8947 {
8948 return false;
8949 }
8950
8951 //----------------------------------------------------------------
8952 bool CanEat()
8953 {
8954 return true;
8955 }
8956
8957 //----------------------------------------------------------------
8958 override bool IsIgnoredByConstruction()
8959 {
8960 return true;
8961 }
8962
8963 //----------------------------------------------------------------
8964 //has FoodStages in config?
8965 bool HasFoodStage()
8966 {
8967 string config_path = string.Format("CfgVehicles %1 Food FoodStages", GetType());
8968 return g_Game.ConfigIsExisting(config_path);
8969 }
8970
8972 FoodStage GetFoodStage()
8973 {
8974 return null;
8975 }
8976
8977 bool CanBeCooked()
8978 {
8979 return false;
8980 }
8981
8982 bool CanBeCookedOnStick()
8983 {
8984 return false;
8985 }
8986
8988 void RefreshAudioVisualsOnClient( CookingMethodType cooking_method, bool is_done, bool is_empty, bool is_burned );
8990
8991 //----------------------------------------------------------------
8992 bool CanRepair(ItemBase item_repair_kit)
8993 {
8994 PluginRepairing module_repairing = PluginRepairing.Cast(GetPlugin(PluginRepairing));
8995 return module_repairing.CanRepair(this, item_repair_kit);
8996 }
8997
8998 //----------------------------------------------------------------
8999 bool Repair(PlayerBase player, ItemBase item_repair_kit, float specialty_weight)
9000 {
9001 PluginRepairing module_repairing = PluginRepairing.Cast(GetPlugin(PluginRepairing));
9002 return module_repairing.Repair(player, this, item_repair_kit, specialty_weight);
9003 }
9004
9005 //----------------------------------------------------------------
9006 int GetItemSize()
9007 {
9008 /*
9009 vector v_size = this.ConfigGetVector("itemSize");
9010 int v_size_x = v_size[0];
9011 int v_size_y = v_size[1];
9012 int size = v_size_x * v_size_y;
9013 return size;
9014 */
9015
9016 return 1;
9017 }
9018
9019 //----------------------------------------------------------------
9020 //Override for allowing seemingly unallowed moves when two clients send a conflicting message simultaneously
9021 bool CanBeMovedOverride()
9022 {
9023 return m_CanBeMovedOverride;
9024 }
9025
9026 //----------------------------------------------------------------
9027 //Override for allowing seemingly unallowed moves when two clients send a conflicting message simultaneously
9028 void SetCanBeMovedOverride(bool setting)
9029 {
9030 m_CanBeMovedOverride = setting;
9031 }
9032
9033 //----------------------------------------------------------------
9041 void MessageToOwnerStatus(string text)
9042 {
9043 PlayerBase player = PlayerBase.Cast(this.GetHierarchyRootPlayer());
9044
9045 if (player)
9046 {
9047 player.MessageStatus(text);
9048 }
9049 }
9050
9051 //----------------------------------------------------------------
9059 void MessageToOwnerAction(string text)
9060 {
9061 PlayerBase player = PlayerBase.Cast(this.GetHierarchyRootPlayer());
9062
9063 if (player)
9064 {
9065 player.MessageAction(text);
9066 }
9067 }
9068
9069 //----------------------------------------------------------------
9077 void MessageToOwnerFriendly(string text)
9078 {
9079 PlayerBase player = PlayerBase.Cast(this.GetHierarchyRootPlayer());
9080
9081 if (player)
9082 {
9083 player.MessageFriendly(text);
9084 }
9085 }
9086
9087 //----------------------------------------------------------------
9095 void MessageToOwnerImportant(string text)
9096 {
9097 PlayerBase player = PlayerBase.Cast(this.GetHierarchyRootPlayer());
9098
9099 if (player)
9100 {
9101 player.MessageImportant(text);
9102 }
9103 }
9104
9105 override bool IsItemBase()
9106 {
9107 return true;
9108 }
9109
9110 // Checks if item is of questioned kind
9111 override bool KindOf(string tag)
9112 {
9113 bool found = false;
9114 string item_name = this.GetType();
9115 ref TStringArray item_tag_array = new TStringArray;
9116 g_Game.ConfigGetTextArray("cfgVehicles " + item_name + " itemInfo", item_tag_array);
9117
9118 int array_size = item_tag_array.Count();
9119 for (int i = 0; i < array_size; i++)
9120 {
9121 if (item_tag_array.Get(i) == tag)
9122 {
9123 found = true;
9124 break;
9125 }
9126 }
9127 return found;
9128 }
9129
9130
9131 override void OnRPC(PlayerIdentity sender, int rpc_type,ParamsReadContext ctx)
9132 {
9133 //Debug.Log("OnRPC called");
9134 super.OnRPC(sender, rpc_type,ctx);
9135
9136 //Play soundset for attachment locking (ActionLockAttachment.c)
9137 switch (rpc_type)
9138 {
9139 #ifndef SERVER
9140 case ERPCs.RPC_SOUND_LOCK_ATTACH:
9141 Param2<bool, string> p = new Param2<bool, string>(false, "");
9142
9143 if (!ctx.Read(p))
9144 return;
9145
9146 bool play = p.param1;
9147 string soundSet = p.param2;
9148
9149 if (play)
9150 {
9151 if (m_LockingSound)
9152 {
9154 {
9155 m_LockingSound = SEffectManager.PlaySound(soundSet, GetPosition(), 0, 0, true);
9156 }
9157 }
9158 else
9159 {
9160 m_LockingSound = SEffectManager.PlaySound(soundSet, GetPosition(), 0, 0, true);
9161 }
9162 }
9163 else
9164 {
9165 SEffectManager.DestroyEffect(m_LockingSound);
9166 }
9167
9168 break;
9169 #endif
9170
9171 }
9172
9173 if (GetWrittenNoteData())
9174 {
9175 GetWrittenNoteData().OnRPC(sender, rpc_type,ctx);
9176 }
9177 }
9178
9179 //-----------------------------
9180 // VARIABLE MANIPULATION SYSTEM
9181 //-----------------------------
9182 int NameToID(string name)
9183 {
9184 PluginVariables plugin = PluginVariables.Cast(GetPlugin(PluginVariables));
9185 return plugin.GetID(name);
9186 }
9187
9188 string IDToName(int id)
9189 {
9190 PluginVariables plugin = PluginVariables.Cast(GetPlugin(PluginVariables));
9191 return plugin.GetName(id);
9192 }
9193
9195 void OnSyncVariables(ParamsReadContext ctx)//with ID optimization
9196 {
9197 //Debug.Log("OnSyncVariables called for item: "+ ToString(this.GetType()),"varSync");
9198 //read the flags
9199 int varFlags;
9200 if (!ctx.Read(varFlags))
9201 return;
9202
9203 if (varFlags & ItemVariableFlags.FLOAT)
9204 {
9205 ReadVarsFromCTX(ctx);
9206 }
9207 }
9208
9209 override void SerializeNumericalVars(array<float> floats_out)
9210 {
9211 //some variables handled on EntityAI level already!
9212 super.SerializeNumericalVars(floats_out);
9213
9214 // the order of serialization must be the same as the order of de-serialization
9215 //--------------------------------------------
9216 if (IsVariableSet(VARIABLE_QUANTITY))
9217 {
9218 floats_out.Insert(m_VarQuantity);
9219 }
9220 //--------------------------------------------
9221 if (IsVariableSet(VARIABLE_WET))
9222 {
9223 floats_out.Insert(m_VarWet);
9224 }
9225 //--------------------------------------------
9226 if (IsVariableSet(VARIABLE_LIQUIDTYPE))
9227 {
9228 floats_out.Insert(m_VarLiquidType);
9229 }
9230 //--------------------------------------------
9231 if (IsVariableSet(VARIABLE_COLOR))
9232 {
9233 floats_out.Insert(m_ColorComponentR);
9234 floats_out.Insert(m_ColorComponentG);
9235 floats_out.Insert(m_ColorComponentB);
9236 floats_out.Insert(m_ColorComponentA);
9237 }
9238 //--------------------------------------------
9239 if (IsVariableSet(VARIABLE_CLEANNESS))
9240 {
9241 floats_out.Insert(m_Cleanness);
9242 }
9243 }
9244
9245 override void DeSerializeNumericalVars(array<float> floats)
9246 {
9247 //some variables handled on EntityAI level already!
9248 super.DeSerializeNumericalVars(floats);
9249
9250 // the order of serialization must be the same as the order of de-serialization
9251 int index = 0;
9252 int mask = Math.Round(floats.Get(index));
9253
9254 index++;
9255 //--------------------------------------------
9256 if (mask & VARIABLE_QUANTITY)
9257 {
9258 if (m_IsStoreLoad)
9259 {
9260 SetStoreLoadedQuantity(floats.Get(index));
9261 }
9262 else
9263 {
9264 float quantity = floats.Get(index);
9265 SetQuantity(quantity, true, false, false, false);
9266 }
9267 index++;
9268 }
9269 //--------------------------------------------
9270 if (mask & VARIABLE_WET)
9271 {
9272 float wet = floats.Get(index);
9273 SetWet(wet);
9274 index++;
9275 }
9276 //--------------------------------------------
9277 if (mask & VARIABLE_LIQUIDTYPE)
9278 {
9279 int liquidtype = Math.Round(floats.Get(index));
9280 SetLiquidType(liquidtype);
9281 index++;
9282 }
9283 //--------------------------------------------
9284 if (mask & VARIABLE_COLOR)
9285 {
9286 m_ColorComponentR = Math.Round(floats.Get(index));
9287 index++;
9288 m_ColorComponentG = Math.Round(floats.Get(index));
9289 index++;
9290 m_ColorComponentB = Math.Round(floats.Get(index));
9291 index++;
9292 m_ColorComponentA = Math.Round(floats.Get(index));
9293 index++;
9294 }
9295 //--------------------------------------------
9296 if (mask & VARIABLE_CLEANNESS)
9297 {
9298 int cleanness = Math.Round(floats.Get(index));
9299 SetCleanness(cleanness);
9300 index++;
9301 }
9302 }
9303
9304 override void WriteVarsToCTX(ParamsWriteContext ctx)
9305 {
9306 super.WriteVarsToCTX(ctx);
9307
9308 //--------------------------------------------
9309 if (IsVariableSet(VARIABLE_QUANTITY))
9310 {
9311 ctx.Write(GetQuantity());
9312 }
9313 //--------------------------------------------
9314 if (IsVariableSet(VARIABLE_WET))
9315 {
9316 ctx.Write(GetWet());
9317 }
9318 //--------------------------------------------
9319 if (IsVariableSet(VARIABLE_LIQUIDTYPE))
9320 {
9321 ctx.Write(GetLiquidType());
9322 }
9323 //--------------------------------------------
9324 if (IsVariableSet(VARIABLE_COLOR))
9325 {
9326 int r,g,b,a;
9327 GetColor(r,g,b,a);
9328 ctx.Write(r);
9329 ctx.Write(g);
9330 ctx.Write(b);
9331 ctx.Write(a);
9332 }
9333 //--------------------------------------------
9334 if (IsVariableSet(VARIABLE_CLEANNESS))
9335 {
9336 ctx.Write(GetCleanness());
9337 }
9338 }
9339
9340 override bool ReadVarsFromCTX(ParamsReadContext ctx, int version = -1)//with ID optimization
9341 {
9342 if (!super.ReadVarsFromCTX(ctx,version))
9343 return false;
9344
9345 int intValue;
9346 float value;
9347
9348 if (version < 140)
9349 {
9350 if (!ctx.Read(intValue))
9351 return false;
9352
9353 m_VariablesMask = intValue;
9354 }
9355
9356 if (m_VariablesMask & VARIABLE_QUANTITY)
9357 {
9358 if (!ctx.Read(value))
9359 return false;
9360
9361 if (IsStoreLoad())
9362 {
9364 }
9365 else
9366 {
9367 SetQuantity(value, true, false, false, false);
9368 }
9369 }
9370 //--------------------------------------------
9371 if (version < 140)
9372 {
9373 if (m_VariablesMask & VARIABLE_TEMPERATURE)
9374 {
9375 if (!ctx.Read(value))
9376 return false;
9377 SetTemperatureDirect(value);
9378 }
9379 }
9380 //--------------------------------------------
9381 if (m_VariablesMask & VARIABLE_WET)
9382 {
9383 if (!ctx.Read(value))
9384 return false;
9385 SetWet(value);
9386 }
9387 //--------------------------------------------
9388 if (m_VariablesMask & VARIABLE_LIQUIDTYPE)
9389 {
9390 if (!ctx.Read(intValue))
9391 return false;
9392 SetLiquidType(intValue);
9393 }
9394 //--------------------------------------------
9395 if (m_VariablesMask & VARIABLE_COLOR)
9396 {
9397 int r,g,b,a;
9398 if (!ctx.Read(r))
9399 return false;
9400 if (!ctx.Read(g))
9401 return false;
9402 if (!ctx.Read(b))
9403 return false;
9404 if (!ctx.Read(a))
9405 return false;
9406
9407 SetColor(r,g,b,a);
9408 }
9409 //--------------------------------------------
9410 if (m_VariablesMask & VARIABLE_CLEANNESS)
9411 {
9412 if (!ctx.Read(intValue))
9413 return false;
9414 SetCleanness(intValue);
9415 }
9416 //--------------------------------------------
9417 if (version >= 138 && version < 140)
9418 {
9419 if (m_VariablesMask & VARIABLE_TEMPERATURE)
9420 {
9421 if (!ctx.Read(intValue))
9422 return false;
9423 SetFrozen(intValue);
9424 }
9425 }
9426
9427 return true;
9428 }
9429
9430 //----------------------------------------------------------------
9431 override bool OnStoreLoad(ParamsReadContext ctx, int version)
9432 {
9433 m_IsStoreLoad = true;
9435 {
9436 m_FixDamageSystemInit = true;
9437 }
9438
9439 if (!super.OnStoreLoad(ctx, version))
9440 {
9441 m_IsStoreLoad = false;
9442 return false;
9443 }
9444
9445 if (version >= 114)
9446 {
9447 bool hasQuickBarIndexSaved;
9448
9449 if (!ctx.Read(hasQuickBarIndexSaved))
9450 {
9451 m_IsStoreLoad = false;
9452 return false;
9453 }
9454
9455 if (hasQuickBarIndexSaved)
9456 {
9457 int itmQBIndex;
9458
9459 //Load quickbar item bind
9460 if (!ctx.Read(itmQBIndex))
9461 {
9462 m_IsStoreLoad = false;
9463 return false;
9464 }
9465
9466 PlayerBase parentPlayer = PlayerBase.Cast(GetHierarchyRootPlayer());
9467 if (itmQBIndex != -1 && parentPlayer)
9468 parentPlayer.SetLoadedQuickBarItemBind(this, itmQBIndex);
9469 }
9470 }
9471 else
9472 {
9473 // Backup of how it used to be
9474 PlayerBase player;
9475 int itemQBIndex;
9476 if (version == int.MAX)
9477 {
9478 if (!ctx.Read(itemQBIndex))
9479 {
9480 m_IsStoreLoad = false;
9481 return false;
9482 }
9483 }
9484 else if (Class.CastTo(player, GetHierarchyRootPlayer()))
9485 {
9486 //Load quickbar item bind
9487 if (!ctx.Read(itemQBIndex))
9488 {
9489 m_IsStoreLoad = false;
9490 return false;
9491 }
9492 if (itemQBIndex != -1 && player)
9493 player.SetLoadedQuickBarItemBind(this,itemQBIndex);
9494 }
9495 }
9496
9497 if (version < 140)
9498 {
9499 // variable management system
9500 if (!LoadVariables(ctx, version))
9501 {
9502 m_IsStoreLoad = false;
9503 return false;
9504 }
9505 }
9506
9507 //agent trasmission system
9508 if (!LoadAgents(ctx, version))
9509 {
9510 m_IsStoreLoad = false;
9511 return false;
9512 }
9513 if (version >= 132)
9514 {
9515 RemotelyActivatedItemBehaviour raib = GetRemotelyActivatedItemBehaviour();
9516 if (raib)
9517 {
9518 if (!raib.OnStoreLoad(ctx,version))
9519 {
9520 m_IsStoreLoad = false;
9521 return false;
9522 }
9523 }
9524 }
9525
9526 m_IsStoreLoad = false;
9527 return true;
9528 }
9529
9530 //----------------------------------------------------------------
9531
9532 override void OnStoreSave(ParamsWriteContext ctx)
9533 {
9534 super.OnStoreSave(ctx);
9535
9536 PlayerBase player;
9537 if (PlayerBase.CastTo(player,GetHierarchyRootPlayer()))
9538 {
9539 ctx.Write(true); // Keep track of if we should actually read this in or not
9540 //Save quickbar item bind
9541 int itemQBIndex = -1;
9542 itemQBIndex = player.FindQuickBarEntityIndex(this);
9543 ctx.Write(itemQBIndex);
9544 }
9545 else
9546 {
9547 ctx.Write(false); // Keep track of if we should actually read this in or not
9548 }
9549
9550 SaveAgents(ctx);//agent trasmission system
9551
9552 RemotelyActivatedItemBehaviour raib = GetRemotelyActivatedItemBehaviour();
9553 if (raib)
9554 {
9555 raib.OnStoreSave(ctx);
9556 }
9557 }
9558 //----------------------------------------------------------------
9559
9560 override void AfterStoreLoad()
9561 {
9562 super.AfterStoreLoad();
9563
9565 {
9567 }
9568
9569 if (GetStoreLoadedQuantity() != float.LOWEST)
9570 {
9572 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
9573 }
9574 }
9575
9576 override void EEOnAfterLoad()
9577 {
9578 super.EEOnAfterLoad();
9579
9581 {
9582 m_FixDamageSystemInit = false;
9583 }
9584
9587 }
9588
9589 bool CanBeDisinfected()
9590 {
9591 return false;
9592 }
9593
9594
9595 //----------------------------------------------------------------
9596 override void OnVariablesSynchronized()
9597 {
9598 if (m_Initialized)
9599 {
9600 #ifdef PLATFORM_CONSOLE
9601 //bruteforce it is
9602 if (IsSplitable())
9603 {
9604 UIScriptedMenu menu = g_Game.GetUIManager().FindMenu(MENU_INVENTORY);
9605 if (menu)
9606 {
9607 menu.Refresh();
9608 }
9609 }
9610 #endif
9611 }
9612
9614 {
9615 PlayImpactSound(m_ConfigWeight, m_ImpactSpeed, m_ImpactSoundSurfaceHash);
9616 m_WantPlayImpactSound = false;
9617 }
9618
9620 {
9621 SetWeightDirty();
9623 }
9624 if (m_VarWet != m_VarWetPrev)
9625 {
9628 }
9629
9630 if (m_SoundSyncPlay != 0)
9631 {
9634
9635 m_SoundSyncPlay = 0;
9636 m_SoundSyncSlotID = -1;
9637 }
9638 if (m_SoundSyncStop != 0)
9639 {
9641 m_ItemSoundHandler.StopItemSoundClient(m_SoundSyncStop);
9642 m_SoundSyncStop = 0;
9643 }
9644
9645 super.OnVariablesSynchronized();
9646 }
9647
9648 //------------------------- Quantity
9649 //----------------------------------------------------------------
9651 override bool SetQuantity(float value, bool destroy_config = true, bool destroy_forced = false, bool allow_client = false, bool clamp_to_stack_max = true)
9652 {
9653 if (!IsServerCheck(allow_client))
9654 return false;
9655
9656 if (!HasQuantity())
9657 return false;
9658
9659 float min = GetQuantityMin();
9660 float max = GetQuantityMax();
9661
9662 if (value <= (min + 0.001))
9663 value = min;
9664
9665 if (value == min)
9666 {
9667 if (destroy_config)
9668 {
9669 bool dstr = ConfigGetBool("varQuantityDestroyOnMin");
9670 if (dstr)
9671 {
9672 m_VarQuantity = Math.Clamp(value, min, max);
9673 this.Delete();
9674 return true;
9675 }
9676 }
9677 else if (destroy_forced)
9678 {
9679 m_VarQuantity = Math.Clamp(value, min, max);
9680 this.Delete();
9681 return true;
9682 }
9683 // we get here if destroy_config IS true AND dstr(config destroy param) IS false;
9684 RemoveAllAgents();//we remove all agents when we got to the min value, but the item is not getting deleted
9685 }
9686
9687 float delta = m_VarQuantity;
9688 m_VarQuantity = Math.Clamp(value, min, max);
9689
9690 if (g_Game.IsServer() || !g_Game.IsMultiplayer()) // single player or server side multiplayer
9691 {
9692 EntityAI parent = GetHierarchyRoot();
9693 InventoryLocation iLoc = new InventoryLocation();
9694 GetInventory().GetCurrentInventoryLocation(iLoc);
9695 if (iLoc && iLoc.IsValid() && delta != m_VarQuantity)
9696 {
9697 int iLocSlot = iLoc.GetSlot();
9698 if (delta < m_VarQuantity && iLoc.GetType() != InventoryLocationType.GROUND)
9699 {
9700 StartItemSoundServer(SoundConstants.ITEM_ATTACH, iLocSlot);
9701 }
9702 if (delta > m_VarQuantity && m_VarQuantity != 0 && !IsPrepareToDelete() && iLoc.GetType() == InventoryLocationType.ATTACHMENT)
9703 {
9704 StartItemSoundServer(SoundConstants.ITEM_DETACH, iLocSlot);
9705 }
9706 }
9707 }
9708
9709 if (GetStoreLoadedQuantity() == float.LOWEST)//any other value means we are setting quantity from storage
9710 {
9711 delta = m_VarQuantity - delta;
9712
9713 if (delta)
9714 OnQuantityChanged(delta);
9715 }
9716
9717 SetVariableMask(VARIABLE_QUANTITY);
9718
9719 return false;
9720 }
9721
9722 //----------------------------------------------------------------
9724 bool AddQuantity(float value, bool destroy_config = true, bool destroy_forced = false)
9725 {
9726 return SetQuantity(GetQuantity() + value, destroy_config, destroy_forced);
9727 }
9728 //----------------------------------------------------------------
9729 void SetQuantityMax()
9730 {
9731 float max = GetQuantityMax();
9732 SetQuantity(max);
9733 }
9734
9735 override void SetQuantityToMinimum()
9736 {
9737 float min = GetQuantityMin();
9738 SetQuantity(min);
9739 }
9740 //----------------------------------------------------------------
9742 override void SetQuantityNormalized(float value, bool destroy_config = true, bool destroy_forced = false)
9743 {
9744 float value_clamped = Math.Clamp(value, 0, 1);//just to make sure
9745 int result = Math.Round(Math.Lerp(GetQuantityMin(), GetQuantityMax(), value_clamped));
9746 SetQuantity(result, destroy_config, destroy_forced);
9747 }
9748
9749 //----------------------------------------------------------------
9751 override float GetQuantityNormalized()
9752 {
9753 return Math.InverseLerp(GetQuantityMin(), GetQuantityMax(),m_VarQuantity);
9754 }
9755
9757 {
9758 return GetQuantityNormalized();
9759 }
9760
9761 /*void SetAmmoNormalized(float value)
9762 {
9763 float value_clamped = Math.Clamp(value, 0, 1);
9764 Magazine this_mag = Magazine.Cast(this);
9765 int max_rounds = this_mag.GetAmmoMax();
9766 int result = value * max_rounds;//can the rounded if higher precision is required
9767 this_mag.SetAmmoCount(result);
9768 }*/
9769 //----------------------------------------------------------------
9770 override int GetQuantityMax()
9771 {
9772 int slot = -1;
9773 GameInventory inventory = GetInventory();
9774 if (inventory)
9775 {
9776 InventoryLocation il = new InventoryLocation;
9777 inventory.GetCurrentInventoryLocation(il);
9778 slot = il.GetSlot();
9779 }
9780
9781 return GetTargetQuantityMax(slot);
9782 }
9783
9784 override int GetTargetQuantityMax(int attSlotID = -1)
9785 {
9786 float quantity_max = 0;
9787
9788 if (IsSplitable()) //only stackable/splitable items can check for stack size
9789 {
9790 if (attSlotID != -1)
9791 quantity_max = InventorySlots.GetStackMaxForSlotId(attSlotID);
9792
9793 if (quantity_max <= 0)
9794 quantity_max = m_VarStackMax;
9795 }
9796
9797 if (quantity_max <= 0)
9798 quantity_max = m_VarQuantityMax;
9799
9800 return quantity_max;
9801 }
9802 //----------------------------------------------------------------
9803 override int GetQuantityMin()
9804 {
9805 return m_VarQuantityMin;
9806 }
9807 //----------------------------------------------------------------
9808 int GetQuantityInit()
9809 {
9810 return m_VarQuantityInit;
9811 }
9812
9813 //----------------------------------------------------------------
9814 override bool HasQuantity()
9815 {
9816 return !(GetQuantityMax() - GetQuantityMin() == 0);
9817 }
9818
9819 override float GetQuantity()
9820 {
9821 return m_VarQuantity;
9822 }
9823
9824 bool IsFullQuantity()
9825 {
9826 return GetQuantity() >= GetQuantityMax();
9827 }
9828
9829 //Calculates weight of single item without attachments and cargo
9830 override float GetSingleInventoryItemWeightEx()
9831 {
9832 //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
9833 float weightEx = GetWeightEx();//overall weight of the item
9834 float special = GetInventoryAndCargoWeight();//cargo and attachment weight
9835 return weightEx - special;
9836 }
9837
9838 // Obsolete, use GetSingleInventoryItemWeightEx() instead
9840 {
9842 }
9843
9844 override protected float GetWeightSpecialized(bool forceRecalc = false)
9845 {
9846 if (IsSplitable()) //quantity determines size of the stack
9847 {
9848 #ifdef DEVELOPER
9849 if (WeightDebug.m_VerbosityFlags & WeightDebugType.RECALC_FORCED)
9850 {
9851 WeightDebugData data1 = WeightDebug.GetWeightDebug(this);
9852 data1.SetCalcDetails("TIB1: " + GetConfigWeightModifiedDebugText() +" * " + GetQuantity()+"(quantity)");
9853 }
9854 #endif
9855
9856 return GetQuantity() * GetConfigWeightModified();
9857 }
9858 else if (HasEnergyManager())// items with energy manager
9859 {
9860 #ifdef DEVELOPER
9861 if (WeightDebug.m_VerbosityFlags & WeightDebugType.RECALC_FORCED)
9862 {
9863 WeightDebugData data2 = WeightDebug.GetWeightDebug(this);
9864 data2.SetCalcDetails("TIB2: "+super.GetWeightSpecialized(forceRecalc)+"(contents weight) + " + GetConfigWeightModifiedDebugText() +" + " + GetCompEM().GetEnergy()+"(energy) * " + ConfigGetFloat("weightPerQuantityUnit") +"(weightPerQuantityUnit)");
9865 }
9866 #endif
9867 return super.GetWeightSpecialized(forceRecalc) + (GetCompEM().GetEnergy() * ConfigGetFloat("weightPerQuantityUnit")) + GetConfigWeightModified();
9868 }
9869 else//everything else
9870 {
9871 #ifdef DEVELOPER
9872 if (WeightDebug.m_VerbosityFlags & WeightDebugType.RECALC_FORCED)
9873 {
9874 WeightDebugData data3 = WeightDebug.GetWeightDebug(this);
9875 data3.SetCalcDetails("TIB3: "+super.GetWeightSpecialized(forceRecalc)+"(contents weight) + " + GetConfigWeightModifiedDebugText() +" + " + GetQuantity()+"(quantity) * " + ConfigGetFloat("weightPerQuantityUnit") +"(weightPerQuantityUnit))");
9876 }
9877 #endif
9878 return super.GetWeightSpecialized(forceRecalc) + (GetQuantity() * ConfigGetFloat("weightPerQuantityUnit")) + GetConfigWeightModified();
9879 }
9880 }
9881
9883 int GetNumberOfItems()
9884 {
9885 int item_count = 0;
9886 ItemBase item;
9887
9888 GameInventory inventory = GetInventory();
9889 CargoBase cargo = inventory.GetCargo();
9890 if (cargo != NULL)
9891 {
9892 item_count = cargo.GetItemCount();
9893 }
9894
9895 int nAttachments = inventory.AttachmentCount();
9896 for (int i = 0; i < nAttachments; ++i)
9897 {
9898 Class.CastTo(item, inventory.GetAttachmentFromIndex(i));
9899 if (item)
9900 item_count += item.GetNumberOfItems();
9901 }
9902 return item_count;
9903 }
9904
9906 float GetUnitWeight(bool include_wetness = true)
9907 {
9908 float weight = 0;
9909 float wetness = 1;
9910 if (include_wetness)
9911 wetness += GetWet();
9912 if (IsSplitable()) //quantity determines size of the stack
9913 {
9914 weight = wetness * m_ConfigWeight;
9915 }
9916 else if (IsLiquidContainer()) //is a liquid container, default liquid weight is set to 1. May revisit later?
9917 {
9918 weight = 1;
9919 }
9920 return weight;
9921 }
9922
9923 //-----------------------------------------------------------------
9924
9925 override void ClearInventory()
9926 {
9927 GameInventory inventory = GetInventory();
9928 if ((g_Game.IsServer() || !g_Game.IsMultiplayer()) && inventory)
9929 {
9930 array<EntityAI> items = new array<EntityAI>;
9931 inventory.EnumerateInventory(InventoryTraversalType.INORDER, items);
9932 for (int i = 0; i < items.Count(); ++i)
9933 {
9934 ItemBase item = ItemBase.Cast(items.Get(i));
9935 if (item)
9936 {
9937 g_Game.ObjectDelete(item);
9938 }
9939 }
9940 }
9941 }
9942
9943 //------------------------- Energy
9944
9945 //----------------------------------------------------------------
9946 float GetEnergy()
9947 {
9948 float energy = 0;
9949 if (HasEnergyManager())
9950 {
9951 energy = GetCompEM().GetEnergy();
9952 }
9953 return energy;
9954 }
9955
9956
9957 override void OnEnergyConsumed()
9958 {
9959 super.OnEnergyConsumed();
9960
9962 }
9963
9964 override void OnEnergyAdded()
9965 {
9966 super.OnEnergyAdded();
9967
9969 }
9970
9971 // Converts energy (from Energy Manager) to quantity, if enabled.
9973 {
9974 if (g_Game.IsServer() && HasEnergyManager() && GetCompEM().HasConversionOfEnergyToQuantity())
9975 {
9976 if (HasQuantity())
9977 {
9978 float energy_0to1 = GetCompEM().GetEnergy0To1();
9979 SetQuantityNormalized(energy_0to1);
9980 }
9981 }
9982 }
9983
9984 //----------------------------------------------------------------
9985 float GetHeatIsolationInit()
9986 {
9987 return ConfigGetFloat("heatIsolation");
9988 }
9989
9990 float GetHeatIsolation()
9991 {
9992 return m_HeatIsolation;
9993 }
9994
9995 float GetDryingIncrement(string pIncrementName)
9996 {
9997 string paramPath = string.Format("CfgVehicles %1 EnvironmentWetnessIncrements Drying %2", GetType(), pIncrementName);
9998 if (g_Game.ConfigIsExisting(paramPath))
9999 return g_Game.ConfigGetFloat(paramPath);
10000
10001 return 0.0;
10002 }
10003
10004 float GetSoakingIncrement(string pIncrementName)
10005 {
10006 string paramPath = string.Format("CfgVehicles %1 EnvironmentWetnessIncrements Soaking %2", GetType(), pIncrementName);
10007 if (g_Game.ConfigIsExisting(paramPath))
10008 return g_Game.ConfigGetFloat(paramPath);
10009
10010 return 0.0;
10011 }
10012 //----------------------------------------------------------------
10013 override void SetWet(float value, bool allow_client = false)
10014 {
10015 if (!IsServerCheck(allow_client))
10016 return;
10017
10018 float min = GetWetMin();
10019 float max = GetWetMax();
10020
10021 float previousValue = m_VarWet;
10022
10023 m_VarWet = Math.Clamp(value, min, max);
10024
10025 if (previousValue != m_VarWet)
10026 {
10027 SetVariableMask(VARIABLE_WET);
10028 OnWetChanged(m_VarWet, previousValue);
10029 }
10030 }
10031 //----------------------------------------------------------------
10032 override void AddWet(float value)
10033 {
10034 SetWet(GetWet() + value);
10035 }
10036 //----------------------------------------------------------------
10037 override void SetWetMax()
10038 {
10040 }
10041 //----------------------------------------------------------------
10042 override float GetWet()
10043 {
10044 return m_VarWet;
10045 }
10046 //----------------------------------------------------------------
10047 override float GetWetMax()
10048 {
10049 return m_VarWetMax;
10050 }
10051 //----------------------------------------------------------------
10052 override float GetWetMin()
10053 {
10054 return m_VarWetMin;
10055 }
10056 //----------------------------------------------------------------
10057 override float GetWetInit()
10058 {
10059 return m_VarWetInit;
10060 }
10061 //----------------------------------------------------------------
10062 override void OnWetChanged(float newVal, float oldVal)
10063 {
10064 EWetnessLevel newLevel = GetWetLevelInternal(newVal);
10065 EWetnessLevel oldLevel = GetWetLevelInternal(oldVal);
10066 if (newLevel != oldLevel)
10067 {
10068 OnWetLevelChanged(newLevel,oldLevel);
10069 }
10070 }
10071
10072 override void OnWetLevelChanged(EWetnessLevel newLevel, EWetnessLevel oldLevel)
10073 {
10074 SetWeightDirty();
10075 }
10076
10077 override EWetnessLevel GetWetLevel()
10078 {
10079 return GetWetLevelInternal(m_VarWet);
10080 }
10081
10082 //----------------------------------------------------------------
10083
10084 override void SetStoreLoad(bool value)
10085 {
10086 m_IsStoreLoad = value;
10087 }
10088
10089 override bool IsStoreLoad()
10090 {
10091 return m_IsStoreLoad;
10092 }
10093
10094 override void SetStoreLoadedQuantity(float value)
10095 {
10096 m_StoreLoadedQuantity = value;
10097 }
10098
10099 override float GetStoreLoadedQuantity()
10100 {
10101 return m_StoreLoadedQuantity;
10102 }
10103
10104 //----------------------------------------------------------------
10105
10106 float GetItemModelLength()
10107 {
10108 if (ConfigIsExisting("itemModelLength"))
10109 {
10110 return ConfigGetFloat("itemModelLength");
10111 }
10112 return 0;
10113 }
10114
10115 float GetItemAttachOffset()
10116 {
10117 if (ConfigIsExisting("itemAttachOffset"))
10118 {
10119 return ConfigGetFloat("itemAttachOffset");
10120 }
10121 return 0;
10122 }
10123
10124 override void SetCleanness(int value, bool allow_client = false)
10125 {
10126 if (!IsServerCheck(allow_client))
10127 return;
10128
10129 int previousValue = m_Cleanness;
10130
10131 m_Cleanness = Math.Clamp(value, m_CleannessMin, m_CleannessMax);
10132
10133 if (previousValue != m_Cleanness)
10134 SetVariableMask(VARIABLE_CLEANNESS);
10135 }
10136
10137 override int GetCleanness()
10138 {
10139 return m_Cleanness;
10140 }
10141
10143 {
10144 return true;
10145 }
10146
10147 //----------------------------------------------------------------
10148 // ATTACHMENT LOCKING
10149 // Getters relevant to generic ActionLockAttachment
10150 int GetLockType()
10151 {
10152 return m_LockType;
10153 }
10154
10155 string GetLockSoundSet()
10156 {
10157 return m_LockSoundSet;
10158 }
10159
10160 //----------------------------------------------------------------
10161 //------------------------- Color
10162 // sets items color variable given color components
10163 override void SetColor(int r, int g, int b, int a)
10164 {
10169 SetVariableMask(VARIABLE_COLOR);
10170 }
10172 override void GetColor(out int r,out int g,out int b,out int a)
10173 {
10178 }
10179
10180 bool IsColorSet()
10181 {
10182 return IsVariableSet(VARIABLE_COLOR);
10183 }
10184
10186 string GetColorString()
10187 {
10188 int r,g,b,a;
10189 GetColor(r,g,b,a);
10190 r = r/255;
10191 g = g/255;
10192 b = b/255;
10193 a = a/255;
10194 return MiscGameplayFunctions.GetColorString(r, g, b, a);
10195 }
10196 //----------------------------------------------------------------
10197 //------------------------- LiquidType
10198
10199 override void SetLiquidType(int value, bool allow_client = false)
10200 {
10201 if (!IsServerCheck(allow_client))
10202 return;
10203
10204 int old = m_VarLiquidType;
10205 m_VarLiquidType = value;
10206 OnLiquidTypeChanged(old,value);
10207 SetVariableMask(VARIABLE_LIQUIDTYPE);
10208 }
10209
10210 int GetLiquidTypeInit()
10211 {
10212 return ConfigGetInt("varLiquidTypeInit");
10213 }
10214
10215 override int GetLiquidType()
10216 {
10217 return m_VarLiquidType;
10218 }
10219
10220 protected void OnLiquidTypeChanged(int oldType, int newType)
10221 {
10222 if (newType == LIQUID_NONE && GetIsFrozen())
10223 SetFrozen(false);
10224 }
10225
10227 void UpdateQuickbarShortcutVisibility(PlayerBase player)
10228 {
10229 player.SetEnableQuickBarEntityShortcut(this,!GetHierarchyParent() || GetHierarchyParent().GetInventory().AreChildrenAccessible());
10230 }
10231
10232 // -------------------------------------------------------------------------
10234 void OnInventoryEnter(Man player)
10235 {
10236 PlayerBase nplayer;
10237 if (PlayerBase.CastTo(nplayer, player))
10238 {
10239 m_CanPlayImpactSound = true;
10240 nplayer.SetEnableQuickBarEntityShortcut(this,!GetHierarchyParent() || GetHierarchyParent().GetInventory().AreChildrenAccessible());
10241 }
10242 }
10243
10244 // -------------------------------------------------------------------------
10246 void OnInventoryExit(Man player)
10247 {
10248 PlayerBase nplayer;
10249 if (PlayerBase.CastTo(nplayer,player))
10250 {
10251 nplayer.SetEnableQuickBarEntityShortcut(this, false);
10252 }
10253
10254 player.GetHumanInventory().ClearUserReservedLocationForContainer(this);
10255
10256 if (HasEnergyManager())
10257 {
10258 GetCompEM().UpdatePlugState(); // Unplug the el. device if it's necesarry.
10259 }
10260 }
10261
10262 // ADVANCED PLACEMENT EVENTS
10263 override void OnPlacementStarted(Man player)
10264 {
10265 super.OnPlacementStarted(player);
10266
10267 SetTakeable(false);
10268 }
10269
10270 override void OnPlacementComplete(Man player, vector position = "0 0 0", vector orientation = "0 0 0")
10271 {
10272 if (m_AdminLog)
10273 {
10274 m_AdminLog.OnPlacementComplete(player, this);
10275 }
10276
10277 super.OnPlacementComplete(player, position, orientation);
10278 }
10279
10280 //-----------------------------
10281 // AGENT SYSTEM
10282 //-----------------------------
10283 //--------------------------------------------------------------------------
10284 bool ContainsAgent(int agent_id)
10285 {
10286 if (agent_id & m_AttachedAgents)
10287 {
10288 return true;
10289 }
10290 else
10291 {
10292 return false;
10293 }
10294 }
10295
10296 //--------------------------------------------------------------------------
10297 override void RemoveAgent(int agent_id)
10298 {
10299 if (ContainsAgent(agent_id))
10300 {
10301 m_AttachedAgents = ~agent_id & m_AttachedAgents;
10302 }
10303 }
10304
10305 //--------------------------------------------------------------------------
10306 override void RemoveAllAgents()
10307 {
10308 m_AttachedAgents = 0;
10309 }
10310 //--------------------------------------------------------------------------
10311 override void RemoveAllAgentsExcept(int agent_to_keep)
10312 {
10313 m_AttachedAgents = m_AttachedAgents & agent_to_keep;
10314 }
10315 // -------------------------------------------------------------------------
10316 override void InsertAgent(int agent, float count = 1)
10317 {
10318 if (count < 1)
10319 return;
10320 //Debug.Log("Inserting Agent on item: " + agent.ToString() +" count: " + count.ToString());
10322 }
10323
10325 void TransferAgents(int agents)
10326 {
10328 }
10329
10330 // -------------------------------------------------------------------------
10331 override int GetAgents()
10332 {
10333 return m_AttachedAgents;
10334 }
10335 //----------------------------------------------------------------------
10336
10337 /*int GetContaminationType()
10338 {
10339 int contamination_type;
10340
10341 const int CONTAMINATED_MASK = eAgents.CHOLERA | eAgents.INFLUENZA | eAgents.SALMONELLA | eAgents.BRAIN;
10342 const int POISONED_MASK = eAgents.FOOD_POISON | eAgents.CHEMICAL_POISON;
10343 const int NERVE_GAS_MASK = eAgents.CHEMICAL_POISON;
10344 const int DIRTY_MASK = eAgents.WOUND_AGENT;
10345
10346 Edible_Base edible = Edible_Base.Cast(this);
10347 int agents = GetAgents();
10348 if (edible)
10349 {
10350 NutritionalProfile profile = Edible_Base.GetNutritionalProfile(edible);
10351 if (profile)
10352 {
10353 agents = agents | profile.GetAgents();//merge item's agents with nutritional agents
10354 }
10355 }
10356 if (agents & CONTAMINATED_MASK)
10357 {
10358 contamination_type = contamination_type | EContaminationTypes.ITEM_BADGE_CONTAMINATED;
10359 }
10360 if (agents & POISONED_MASK)
10361 {
10362 contamination_type = contamination_type | EContaminationTypes.ITEM_BADGE_POISONED;
10363 }
10364 if (agents & NERVE_GAS_MASK)
10365 {
10366 contamination_type = contamination_type | EContaminationTypes.ITEM_BADGE_NERVE_GAS;
10367 }
10368 if (agents & DIRTY_MASK)
10369 {
10370 contamination_type = contamination_type | EContaminationTypes.ITEM_BADGE_DIRTY;
10371 }
10372
10373 return agents;
10374 }*/
10375
10376 // -------------------------------------------------------------------------
10377 bool LoadAgents(ParamsReadContext ctx, int version)
10378 {
10379 if (!ctx.Read(m_AttachedAgents))
10380 return false;
10381 return true;
10382 }
10383 // -------------------------------------------------------------------------
10385 {
10386
10388 }
10389 // -------------------------------------------------------------------------
10390
10392 override void CheckForRoofLimited(float timeTresholdMS = 3000)
10393 {
10394 super.CheckForRoofLimited(timeTresholdMS);
10395
10396 float time = g_Game.GetTime();
10397 if ((time - m_PreviousRoofTestTime) >= timeTresholdMS)
10398 {
10399 m_PreviousRoofTestTime = time;
10400 SetRoofAbove(MiscGameplayFunctions.IsUnderRoof(this));
10401 }
10402 }
10403
10404 // returns item's protection level against enviromental hazard, for masks with filters, returns the filters protection for valid filter, otherwise 0
10405 float GetProtectionLevel(int type, bool consider_filter = false, int system = 0)
10406 {
10407 if (IsDamageDestroyed() || (HasQuantity() && GetQuantity() <= 0))
10408 {
10409 return 0;
10410 }
10411
10412 if (GetInventory().GetAttachmentSlotsCount() != 0)//is it an item with attachable filter ?
10413 {
10414 ItemBase filter = ItemBase.Cast(FindAttachmentBySlotName("GasMaskFilter"));
10415 if (filter)
10416 return filter.GetProtectionLevel(type, false, system);//it's a valid filter, return the protection
10417 else
10418 return 0;//otherwise return 0 when no filter attached
10419 }
10420
10421 string subclassPath, entryName;
10422
10423 switch (type)
10424 {
10425 case DEF_BIOLOGICAL:
10426 entryName = "biological";
10427 break;
10428 case DEF_CHEMICAL:
10429 entryName = "chemical";
10430 break;
10431 default:
10432 entryName = "biological";
10433 break;
10434 }
10435
10436 subclassPath = "CfgVehicles " + this.GetType() + " Protection ";
10437
10438 return g_Game.ConfigGetFloat(subclassPath + entryName);
10439 }
10440
10441
10442
10444 override void EEOnCECreate()
10445 {
10446 if (!IsMagazine())
10448
10450 }
10451
10452
10453 //-------------------------
10454 // OPEN/CLOSE USER ACTIONS
10455 //-------------------------
10457 void Open();
10458 void Close();
10459 bool IsOpen()
10460 {
10461 return true;
10462 }
10463
10464 override bool CanDisplayCargo()
10465 {
10466 return IsOpen();
10467 }
10468
10469
10470 // ------------------------------------------------------------
10471 // CONDITIONS
10472 // ------------------------------------------------------------
10473 override bool CanPutInCargo(EntityAI parent)
10474 {
10475 if (parent)
10476 {
10477 if (parent.IsInherited(DayZInfected))
10478 return true;
10479
10480 if (!parent.IsRuined())
10481 return true;
10482 }
10483
10484 return true;
10485 }
10486
10487 override bool CanPutAsAttachment(EntityAI parent)
10488 {
10489 if (!super.CanPutAsAttachment(parent))
10490 {
10491 return false;
10492 }
10493
10494 if (!IsRuined() && !parent.IsRuined())
10495 {
10496 return true;
10497 }
10498
10499 return false;
10500 }
10501
10502 override bool CanReceiveItemIntoCargo(EntityAI item)
10503 {
10504 //removed 15.06. coz of loading from storage -> after load items in cargo was lost -> waiting for proper solution
10505 //if (GetHealthLevel() == GameConstants.STATE_RUINED)
10506 // return false;
10507
10508 return super.CanReceiveItemIntoCargo(item);
10509 }
10510
10511 override bool CanReceiveAttachment(EntityAI attachment, int slotId)
10512 {
10513 //removed 15.06. coz of loading from storage -> after load items in cargo was lost -> waiting for proper solution
10514 //if (GetHealthLevel() == GameConstants.STATE_RUINED)
10515 // return false;
10516
10517 GameInventory attachmentInv = attachment.GetInventory();
10518 if (attachmentInv && attachmentInv.GetCargo() && attachmentInv.GetCargo().GetItemCount() > 0)
10519 {
10520 if (GetHierarchyParent() && !GetHierarchyParent().IsInherited(PlayerBase))
10521 return false;
10522 }
10523
10524 InventoryLocation loc = new InventoryLocation();
10525 attachment.GetInventory().GetCurrentInventoryLocation(loc);
10526 if (loc && loc.IsValid() && !GetInventory().AreChildrenAccessible())
10527 return false;
10528
10529 return super.CanReceiveAttachment(attachment, slotId);
10530 }
10531
10532 override bool CanReleaseAttachment(EntityAI attachment)
10533 {
10534 if (!super.CanReleaseAttachment(attachment))
10535 return false;
10536
10537 return GetInventory().AreChildrenAccessible();
10538 }
10539
10540 /*override bool CanLoadAttachment(EntityAI attachment)
10541 {
10542 //removed 15.06. coz of loading from storage -> after load items in cargo was lost -> waiting for proper solution
10543 //if (GetHealthLevel() == GameConstants.STATE_RUINED)
10544 // return false;
10545
10546 GameInventory attachmentInv = attachment.GetInventory();
10547 if (attachmentInv && attachmentInv.GetCargo() && attachmentInv.GetCargo().GetItemCount() > 0)
10548 {
10549 bool boo = (GetHierarchyParent() && !GetHierarchyParent().IsInherited(PlayerBase));
10550 ErrorEx("CanLoadAttachment | this: " + this + " | attachment: " + attachment + " | boo: " + boo,ErrorExSeverity.INFO);
10551
10552 if (GetHierarchyParent() && !GetHierarchyParent().IsInherited(PlayerBase))
10553 return false;
10554 }
10555
10556 return super.CanLoadAttachment(attachment);
10557 }*/
10558
10559 // Plays muzzle flash particle effects
10560 static void PlayFireParticles(ItemBase weapon, int muzzle_index, string ammoType, ItemBase muzzle_owner, ItemBase suppressor, string config_to_search)
10561 {
10562 int id = muzzle_owner.GetMuzzleID();
10563 array<ref WeaponParticlesOnFire> WPOF_array = m_OnFireEffect.Get(id);
10564
10565 if (WPOF_array)
10566 {
10567 for (int i = 0; i < WPOF_array.Count(); i++)
10568 {
10569 WeaponParticlesOnFire WPOF = WPOF_array.Get(i);
10570
10571 if (WPOF)
10572 {
10573 WPOF.OnActivate(weapon, muzzle_index, ammoType, muzzle_owner, suppressor, config_to_search);
10574 }
10575 }
10576 }
10577 }
10578
10579 // Plays bullet eject particle effects (usually just smoke, the bullet itself is a 3D model and is not part of this function)
10580 static void PlayBulletCasingEjectParticles(ItemBase weapon, string ammoType, ItemBase muzzle_owner, ItemBase suppressor, string config_to_search)
10581 {
10582 int id = muzzle_owner.GetMuzzleID();
10583 array<ref WeaponParticlesOnBulletCasingEject> WPOBE_array = m_OnBulletCasingEjectEffect.Get(id);
10584
10585 if (WPOBE_array)
10586 {
10587 for (int i = 0; i < WPOBE_array.Count(); i++)
10588 {
10589 WeaponParticlesOnBulletCasingEject WPOBE = WPOBE_array.Get(i);
10590
10591 if (WPOBE)
10592 {
10593 WPOBE.OnActivate(weapon, 0, ammoType, muzzle_owner, suppressor, config_to_search);
10594 }
10595 }
10596 }
10597 }
10598
10599 // Plays all weapon overheating particles
10600 static void PlayOverheatingParticles(ItemBase weapon, string ammoType, ItemBase muzzle_owner, ItemBase suppressor, string config_to_search)
10601 {
10602 int id = muzzle_owner.GetMuzzleID();
10603 array<ref WeaponParticlesOnOverheating> WPOOH_array = weapon.m_OnOverheatingEffect.Get(id);
10604
10605 if (WPOOH_array)
10606 {
10607 for (int i = 0; i < WPOOH_array.Count(); i++)
10608 {
10609 WeaponParticlesOnOverheating WPOOH = WPOOH_array.Get(i);
10610
10611 if (WPOOH)
10612 {
10613 WPOOH.OnActivate(weapon, 0, ammoType, muzzle_owner, suppressor, config_to_search);
10614 }
10615 }
10616 }
10617 }
10618
10619 // Updates all weapon overheating particles
10620 static void UpdateOverheatingParticles(ItemBase weapon, string ammoType, ItemBase muzzle_owner, ItemBase suppressor, string config_to_search)
10621 {
10622 int id = muzzle_owner.GetMuzzleID();
10623 array<ref WeaponParticlesOnOverheating> WPOOH_array = weapon.m_OnOverheatingEffect.Get(id);
10624
10625 if (WPOOH_array)
10626 {
10627 for (int i = 0; i < WPOOH_array.Count(); i++)
10628 {
10629 WeaponParticlesOnOverheating WPOOH = WPOOH_array.Get(i);
10630
10631 if (WPOOH)
10632 {
10633 WPOOH.OnUpdate(weapon, ammoType, muzzle_owner, suppressor, config_to_search);
10634 }
10635 }
10636 }
10637 }
10638
10639 // Stops overheating particles
10640 static void StopOverheatingParticles(ItemBase weapon, string ammoType, ItemBase muzzle_owner, ItemBase suppressor, string config_to_search)
10641 {
10642 int id = muzzle_owner.GetMuzzleID();
10643 array<ref WeaponParticlesOnOverheating> WPOOH_array = weapon.m_OnOverheatingEffect.Get(id);
10644
10645 if (WPOOH_array)
10646 {
10647 for (int i = 0; i < WPOOH_array.Count(); i++)
10648 {
10649 WeaponParticlesOnOverheating WPOOH = WPOOH_array.Get(i);
10650
10651 if (WPOOH)
10652 {
10653 WPOOH.OnDeactivate(weapon, ammoType, muzzle_owner, suppressor, config_to_search);
10654 }
10655 }
10656 }
10657 }
10658
10659 //----------------------------------------------------------------
10660 //Item Behaviour - unified approach
10661 override bool IsHeavyBehaviour()
10662 {
10663 if (m_ItemBehaviour == 0)
10664 {
10665 return true;
10666 }
10667
10668 return false;
10669 }
10670
10671 override bool IsOneHandedBehaviour()
10672 {
10673 if (m_ItemBehaviour == 1)
10674 {
10675 return true;
10676 }
10677
10678 return false;
10679 }
10680
10681 override bool IsTwoHandedBehaviour()
10682 {
10683 if (m_ItemBehaviour == 2)
10684 {
10685 return true;
10686 }
10687
10688 return false;
10689 }
10690
10691 bool IsDeployable()
10692 {
10693 return false;
10694 }
10695
10697 float GetDeployTime()
10698 {
10699 return UATimeSpent.DEFAULT_DEPLOY;
10700 }
10701
10702
10703 //----------------------------------------------------------------
10704 // Item Targeting (User Actions)
10705 override void SetTakeable(bool pState)
10706 {
10707 m_IsTakeable = pState;
10708 SetSynchDirty();
10709 }
10710
10711 override bool IsTakeable()
10712 {
10713 return m_IsTakeable;
10714 }
10715
10716 // For cases where we want to show object widget which cant be taken to hands
10718 {
10719 return false;
10720 }
10721
10723 protected void PreLoadSoundAttachmentType()
10724 {
10725 string att_type = "None";
10726
10727 if (ConfigIsExisting("soundAttType"))
10728 {
10729 att_type = ConfigGetString("soundAttType");
10730 }
10731
10732 m_SoundAttType = att_type;
10733 }
10734
10735 override string GetAttachmentSoundType()
10736 {
10737 return m_SoundAttType;
10738 }
10739
10740 //----------------------------------------------------------------
10741 //SOUNDS - ItemSoundHandler
10742 //----------------------------------------------------------------
10743
10744 string GetPlaceSoundset(); // played when deploy starts
10745 string GetLoopDeploySoundset(); // played when deploy starts and stopped when it finishes
10746 string GetDeploySoundset(); // played when deploy sucessfully finishes
10747 string GetLoopFoldSoundset(); // played when fold starts and stopped when it finishes
10748 string GetFoldSoundset(); // played when fold sucessfully finishes
10749
10751 {
10752 if (!m_ItemSoundHandler)
10754
10755 return m_ItemSoundHandler;
10756 }
10757
10758 // override to initialize sounds
10759 protected void InitItemSounds()
10760 {
10761 if (GetPlaceSoundset() == string.Empty && GetDeploySoundset() == string.Empty && GetLoopDeploySoundset() == string.Empty && !GetInventoryItemType().SetDetachSoundEvent() && !GetInventoryItemType().SetAttachSoundEvent())
10762 return;
10763
10765
10766 if (GetPlaceSoundset() != string.Empty)
10767 handler.AddSound(SoundConstants.ITEM_PLACE, GetPlaceSoundset());
10768
10769 if (GetDeploySoundset() != string.Empty)
10770 handler.AddSound(SoundConstants.ITEM_DEPLOY, GetDeploySoundset());
10771
10772 SoundParameters params = new SoundParameters();
10773 params.m_Loop = true;
10774 if (GetLoopDeploySoundset() != string.Empty)
10775 handler.AddSound(SoundConstants.ITEM_DEPLOY_LOOP, GetLoopDeploySoundset(), params);
10776 }
10777
10778 // Start sound using ItemSoundHandler
10779 void StartItemSoundServer(int id, int slotId)
10780 {
10781 if (g_Game.IsServer() || !g_Game.IsMultiplayer()) // single player or server side multiplayer
10782 {
10783 m_SoundSyncSlotID = slotId;
10784 m_SoundSyncPlay = id;
10785
10786 SetSynchDirty();
10787
10788 g_Game.GetCallQueue(CALL_CATEGORY_SYSTEM).Remove(ClearStartItemSoundServer); // in case one is queued already
10789 g_Game.GetCallQueue(CALL_CATEGORY_SYSTEM).CallLater(ClearStartItemSoundServer, 100);
10790 }
10791 }
10792
10793 void StartItemSoundServer(int id)
10794 {
10795 StartItemSoundServer(id, InventorySlots.INVALID);
10796 }
10797
10798 // Stop sound using ItemSoundHandler
10799 void StopItemSoundServer(int id)
10800 {
10801 if (!g_Game.IsServer())
10802 return;
10803
10804 m_SoundSyncStop = id;
10805 SetSynchDirty();
10806
10807 g_Game.GetCallQueue(CALL_CATEGORY_SYSTEM).Remove(ClearStopItemSoundServer); // in case one is queued already
10808 g_Game.GetCallQueue(CALL_CATEGORY_SYSTEM).CallLater(ClearStopItemSoundServer, 100);
10809 }
10810
10811 protected void ClearStartItemSoundServer()
10812 {
10813 m_SoundSyncPlay = 0;
10814 m_SoundSyncSlotID = InventorySlots.INVALID;
10815 }
10816
10817 protected void ClearStopItemSoundServer()
10818 {
10819 m_SoundSyncStop = 0;
10820 }
10821
10822 void OnApply(PlayerBase player);
10823
10825 {
10826 return 1.0;
10827 };
10828 //returns applicable selection
10829 array<string> GetHeadHidingSelection()
10830 {
10832 }
10833
10835 {
10837 }
10838
10839 WrittenNoteData GetWrittenNoteData() {};
10840
10842 {
10843 SetDynamicPhysicsLifeTime(0.01);
10844 m_ItemBeingDroppedPhys = false;
10845 }
10846
10848 {
10849 array<string> zone_names = new array<string>;
10850 GetDamageZones(zone_names);
10851 for (int i = 0; i < zone_names.Count(); i++)
10852 {
10853 SetHealthMax(zone_names.Get(i),"Health");
10854 }
10855 SetHealthMax("","Health");
10856 }
10857
10859 void SetZoneDamageCEInit()
10860 {
10861 float global_health = GetHealth01("","Health");
10862 array<string> zones = new array<string>;
10863 GetDamageZones(zones);
10864 //set damage of all zones to match global health level
10865 for (int i = 0; i < zones.Count(); i++)
10866 {
10867 SetHealth01(zones.Get(i),"Health",global_health);
10868 }
10869 }
10870
10872 bool IsCoverFaceForShave(string slot_name)
10873 {
10874 return IsExclusionFlagPresent(PlayerBase.GetFaceCoverageShaveValues());
10875 }
10876
10877 void ProcessItemWetness(float delta, bool hasParent, bool hasRootAsPlayer, ItemBase refParentIB)
10878 {
10879 if (!hasRootAsPlayer)
10880 {
10881 if (refParentIB)
10882 {
10883 // parent is wet
10884 if ((refParentIB.GetWet() >= GameConstants.STATE_SOAKING_WET) && (m_VarWet < m_VarWetMax))
10885 AddWet(delta * GameConstants.WETNESS_RATE_WETTING_INSIDE);
10886 // parent has liquid inside
10887 else if ((refParentIB.GetLiquidType() != 0) && (refParentIB.GetQuantity() > 0) && (m_VarWet < m_VarWetMax))
10888 AddWet(delta * GameConstants.WETNESS_RATE_WETTING_LIQUID);
10889 // drying
10890 else if (m_VarWet > m_VarWetMin)
10891 AddWet(-1 * delta * GetDryingIncrement("ground") * 2);
10892 }
10893 else
10894 {
10895 // drying on ground or inside non-itembase (car, ...)
10896 if (m_VarWet > m_VarWetMin)
10897 AddWet(-1 * delta * GetDryingIncrement("ground"));
10898 }
10899 }
10900 }
10901
10902 void ProcessItemTemperature(float delta, bool hasParent, bool hasRootAsPlayer, ItemBase refParentIB)
10903 {
10905 {
10906 float target = g_Game.GetMission().GetWorldData().GetBaseEnvTemperatureAtObject(this);
10907 if (GetTemperature() != target || !IsFreezeThawProgressFinished())
10908 {
10909 float heatPermCoef = 1.0;
10910 EntityAI ent = this;
10911 while (ent)
10912 {
10913 heatPermCoef *= ent.GetHeatPermeabilityCoef();
10914 ent = ent.GetHierarchyParent();
10915 }
10916
10917 SetTemperatureEx(new TemperatureDataInterpolated(target,ETemperatureAccessTypes.ACCESS_WORLD,delta,GameConstants.TEMP_COEF_WORLD,heatPermCoef));
10918 }
10919 }
10920 }
10921
10922 void HierarchyCheck(out bool hasParent, out bool hasRootAsPlayer, out ItemBase refParentIB)
10923 {
10924 // hierarchy check for an item to decide whether it has some parent and it is in some player inventory
10925 EntityAI parent = GetHierarchyParent();
10926 if (!parent)
10927 {
10928 hasParent = false;
10929 hasRootAsPlayer = false;
10930 }
10931 else
10932 {
10933 hasParent = true;
10934 hasRootAsPlayer = (GetHierarchyRootPlayer() != null);
10935 refParentIB = ItemBase.Cast(parent);
10936 }
10937 }
10938
10939 protected void ProcessDecay(float delta, bool hasRootAsPlayer)
10940 {
10941 // this is stub, implemented on Edible_Base
10942 }
10943
10944 bool CanDecay()
10945 {
10946 // return true used on selected food clases so they can decay
10947 return false;
10948 }
10949
10950 protected bool CanProcessDecay()
10951 {
10952 // this is stub, implemented on Edible_Base class
10953 // used to determine whether it is still necessary for the food to decay
10954 return false;
10955 }
10956
10957 protected bool CanHaveWetness()
10958 {
10959 // return true used on selected items that have a wetness effect
10960 return false;
10961 }
10962
10964 bool CanBeConsumed(ConsumeConditionData data = null)
10965 {
10966 return !GetIsFrozen() && IsOpen();
10967 }
10968
10969 override void ProcessVariables()
10970 {
10971 bool hasParent = false, hasRootAsPlayer = false;
10972 ItemBase refParentIB;
10973
10974 bool wwtu = g_Game.IsWorldWetTempUpdateEnabled();
10975 bool foodDecay = g_Game.IsFoodDecayEnabled();
10976
10977 if (wwtu || foodDecay)
10978 {
10979 bool processWetness = wwtu && CanHaveWetness();
10980 bool processTemperature = wwtu && CanHaveTemperature();
10981 bool processDecay = foodDecay && CanDecay() && CanProcessDecay();
10982
10983 if (processWetness || processTemperature || processDecay)
10984 {
10985 HierarchyCheck(hasParent, hasRootAsPlayer, refParentIB);
10986
10987 if (processWetness)
10988 ProcessItemWetness(m_ElapsedSinceLastUpdate, hasParent, hasRootAsPlayer, refParentIB);
10989
10990 if (processTemperature)
10991 ProcessItemTemperature(m_ElapsedSinceLastUpdate, hasParent, hasRootAsPlayer, refParentIB);
10992
10993 if (processDecay)
10994 ProcessDecay(m_ElapsedSinceLastUpdate, hasRootAsPlayer);
10995 }
10996 }
10997 }
10998
11001 {
11002 return m_TemperaturePerQuantityWeight * GameConstants.ITEM_TEMPERATURE_QUANTITY_WEIGHT_MULTIPLIER;
11003 }
11004
11005 override float GetTemperatureFreezeThreshold()
11006 {
11008 return Liquid.GetFreezeThreshold(GetLiquidType());
11009
11010 return super.GetTemperatureFreezeThreshold();
11011 }
11012
11013 override float GetTemperatureThawThreshold()
11014 {
11016 return Liquid.GetThawThreshold(GetLiquidType());
11017
11018 return super.GetTemperatureThawThreshold();
11019 }
11020
11021 override float GetItemOverheatThreshold()
11022 {
11024 return Liquid.GetBoilThreshold(GetLiquidType());
11025
11026 return super.GetItemOverheatThreshold();
11027 }
11028
11029 override float GetTemperatureFreezeTime()
11030 {
11031 if (HasQuantity())
11032 return Math.Lerp(GameConstants.TEMPERATURE_TIME_FREEZE_MIN,Math.Max(GameConstants.TEMPERATURE_TIME_FREEZE_MIN,super.GetTemperatureFreezeTime()),GetQuantityNormalized());
11033
11034 return super.GetTemperatureFreezeTime();
11035 }
11036
11037 override float GetTemperatureThawTime()
11038 {
11039 if (HasQuantity())
11040 return Math.Lerp(GameConstants.TEMPERATURE_TIME_THAW_MIN,Math.Max(GameConstants.TEMPERATURE_TIME_FREEZE_MIN,super.GetTemperatureThawTime()),GetQuantityNormalized());
11041
11042 return super.GetTemperatureThawTime();
11043 }
11044
11046 void AffectLiquidContainerOnFill(int liquid_type, float amount);
11048 void AffectLiquidContainerOnTransfer(int liquidType, float amount, float sourceLiquidTemperature);
11049
11050 bool IsCargoException4x3(EntityAI item)
11051 {
11052 return (item.IsKindOf("Cauldron") || item.IsKindOf("Pot") || item.IsKindOf("FryingPan") || item.IsKindOf("SmallProtectorCase") || (item.IsKindOf("PortableGasStove") && item.FindAttachmentBySlotName("CookingEquipment")));
11053 }
11054
11056 {
11057 MiscGameplayFunctions.TransferItemProperties(oldItem, this);
11058 }
11059
11061 void AddLightSourceItem(ItemBase lightsource)
11062 {
11063 m_LightSourceItem = lightsource;
11064 }
11065
11067 {
11068 m_LightSourceItem = null;
11069 }
11070
11072 {
11073 return m_LightSourceItem;
11074 }
11075
11077 array<int> GetValidFinishers()
11078 {
11079 return null;
11080 }
11081
11083 bool GetActionWidgetOverride(out typename name)
11084 {
11085 return false;
11086 }
11087
11088 bool PairWithDevice(notnull ItemBase otherDevice)
11089 {
11090 if (g_Game.IsServer())
11091 {
11092 ItemBase explosive = otherDevice;
11094 if (!trg)
11095 {
11096 trg = RemoteDetonatorTrigger.Cast(otherDevice);
11097 explosive = this;
11098 }
11099
11100 explosive.PairRemote(trg);
11101 trg.SetControlledDevice(explosive);
11102
11103 int persistentID = RemotelyActivatedItemBehaviour.GeneratePersistentID();
11104 trg.SetPersistentPairID(persistentID);
11105 explosive.SetPersistentPairID(persistentID);
11106
11107 return true;
11108 }
11109 return false;
11110 }
11111
11113 float GetBaitEffectivity()
11114 {
11115 float ret = 1.0;
11116 if (HasQuantity())
11117 ret *= GetQuantityNormalized();
11118 ret *= GetHealth01();
11119
11120 return ret;
11121 }
11122
11123 #ifdef DEVELOPER
11124 override void SetDebugItem()
11125 {
11126 super.SetDebugItem();
11127 _itemBase = this;
11128 }
11129
11130 override string GetDebugText()
11131 {
11132 string text = super.GetDebugText();
11133
11134 text += string.Format("Heat isolation(raw): %1\n", GetHeatIsolation());
11135 text += string.Format("Heat isolation(modified): %1\n", MiscGameplayFunctions.GetCurrentItemHeatIsolation(this));
11136
11137 return text;
11138 }
11139 #endif
11140
11141 bool CanBeUsedForSuicide()
11142 {
11143 return true;
11144 }
11145
11147 //DEPRECATED BELOW
11149 // Backwards compatibility
11150 void ProcessItemWetnessAndTemperature(float delta, bool hasParent, bool hasRootAsPlayer, ItemBase refParentIB)
11151 {
11152 ProcessItemWetness(delta, hasParent, hasRootAsPlayer, refParentIB);
11153 ProcessItemTemperature(delta, hasParent, hasRootAsPlayer, refParentIB);
11154 }
11155
11156 // replaced by ItemSoundHandler
11157 protected EffectSound m_SoundDeployFinish;
11158 protected EffectSound m_SoundPlace;
11159 protected EffectSound m_DeployLoopSoundEx;
11160 protected EffectSound m_SoundDeploy;
11161 bool m_IsPlaceSound;
11162 bool m_IsDeploySound;
11164
11165 string GetDeployFinishSoundset();
11166 void PlayDeploySound();
11167 void PlayDeployFinishSound();
11168 void PlayPlaceSound();
11169 void PlayDeployLoopSoundEx();
11170 void StopDeployLoopSoundEx();
11171 void SoundSynchRemoteReset();
11172 void SoundSynchRemote();
11173 bool UsesGlobalDeploy(){return false;}
11174 bool CanPlayDeployLoopSound(){return false;}
11176 bool IsPlaceSound(){return m_IsPlaceSound;}
11177 bool IsDeploySound(){return m_IsDeploySound;}
11178 void SetIsPlaceSound(bool is_place_sound);
11179 void SetIsDeploySound(bool is_deploy_sound);
11180
11181 [Obsolete("Use ItemSoundHandler instead")]
11183 void PlayAttachSound(string slot_type)
11184 {
11185 if (!g_Game.IsDedicatedServer())
11186 {
11187 if (ConfigIsExisting("attachSoundSet"))
11188 {
11189 string cfg_path = "";
11190 string soundset = "";
11191 string type_name = GetType();
11192
11193 TStringArray cfg_soundset_array = new TStringArray;
11194 TStringArray cfg_slot_array = new TStringArray;
11195 ConfigGetTextArray("attachSoundSet",cfg_soundset_array);
11196 ConfigGetTextArray("attachSoundSlot",cfg_slot_array);
11197
11198 if (cfg_soundset_array.Count() > 0 && cfg_soundset_array.Count() == cfg_slot_array.Count())
11199 {
11200 for (int i = 0; i < cfg_soundset_array.Count(); i++)
11201 {
11202 if (cfg_slot_array[i] == slot_type)
11203 {
11204 soundset = cfg_soundset_array[i];
11205 break;
11206 }
11207 }
11208 }
11209
11210 if (soundset != "")
11211 {
11212 EffectSound sound = SEffectManager.PlaySound(soundset, GetPosition());
11213 sound.SetAutodestroy(true);
11214 }
11215 }
11216 }
11217 }
11218
11219 void PlayDetachSound(string slot_type) {}
11220}
11221
11222EntityAI SpawnItemOnLocation(string object_name, notnull InventoryLocation loc, bool full_quantity)
11223{
11224 EntityAI entity = SpawnEntity(object_name, loc, ECE_IN_INVENTORY, RF_DEFAULT);
11225 if (entity)
11226 {
11227 bool is_item = entity.IsInherited(ItemBase);
11228 if (is_item && full_quantity)
11229 {
11230 ItemBase item = ItemBase.Cast(entity);
11231 item.SetQuantity(item.GetQuantityInit());
11232 }
11233 }
11234 else
11235 {
11236 ErrorEx("Cannot spawn entity: " + object_name,ErrorExSeverity.INFO);
11237 return NULL;
11238 }
11239 return entity;
11240}
11241
11242void SetupSpawnedItem(ItemBase item, float health, float quantity)
11243{
11244 if (item)
11245 {
11246 if (health > 0)
11247 item.SetHealth("", "", health);
11248
11249 if (item.CanHaveTemperature())
11250 {
11251 item.SetTemperatureDirect(GameConstants.ITEM_TEMPERATURE_NEUTRAL_ZONE_MIDDLE);
11252 if (item.CanFreeze())
11253 item.SetFrozen(false);
11254 }
11255
11256 if (item.HasEnergyManager())
11257 {
11258 if (quantity >= 0)
11259 {
11260 item.GetCompEM().SetEnergy0To1(quantity);
11261 }
11262 else
11263 {
11264 item.GetCompEM().SetEnergy(Math.AbsFloat(quantity));
11265 }
11266 }
11267 else if (item.IsMagazine())
11268 {
11269 Magazine mag = Magazine.Cast(item);
11270 if (quantity >= 0)
11271 {
11272 mag.ServerSetAmmoCount(mag.GetAmmoMax() * quantity);
11273 }
11274 else
11275 {
11276 mag.ServerSetAmmoCount(Math.AbsFloat(quantity));
11277 }
11278
11279 }
11280 else
11281 {
11282 if (quantity >= 0)
11283 {
11284 item.SetQuantityNormalized(quantity, false);
11285 }
11286 else
11287 {
11288 item.SetQuantity(Math.AbsFloat(quantity));
11289 }
11290
11291 }
11292 }
11293}
11294
11295#ifdef DEVELOPER
11296ItemBase _itemBase;//watched item goes here(LCTRL+RMB->Watch)
11297#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()