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

◆ ExplodeAmmo()

void SpawnItemOnLocation::ExplodeAmmo ( )
private

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

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

Используется в InventoryItem::DoAmmoExplosion() и InventoryItem::EEKilled().