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

◆ ChangeIntoOnDetach()

override string SpawnItemOnLocation::ChangeIntoOnDetach ( )
private

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

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