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

◆ EEHitBy()

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

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

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