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

◆ ChangeIntoOnDetach()

override string SpawnItemOnLocation::ChangeIntoOnDetach ( )
private

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

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