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

◆ EEHitBy()

override void SpawnItemOnLocation::EEHitBy ( TotalDamageResult damageResult,
int damageType,
EntityAI source,
int component,
string dmgZone,
string ammo,
vector modelPos,
float speedCoef )
private

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

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