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

◆ EEHitBy()

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

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

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