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

◆ DoAmmoExplosion()

void SpawnItemOnLocation::DoAmmoExplosion ( )
private

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

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