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

◆ OnWasAttached()

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

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

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

Используется в Entity::EEItemLocationChanged().