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

◆ CanBeSplit()

override bool SpawnItemOnLocation::CanBeSplit ( )
private

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

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