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

◆ ExplodeAmmo()

void SpawnItemOnLocation::ExplodeAmmo ( )
private

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

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

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