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

◆ OnWasDetached()

override void SpawnItemOnLocation::OnWasDetached ( EntityAI parent,
int slot_id )
private

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

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