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

◆ EEKilled()

override void SpawnItemOnLocation::EEKilled ( Object killer)
private

item is able to explode in fire

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

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