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

◆ ChangeIntoOnAttach()

override string SpawnItemOnLocation::ChangeIntoOnAttach ( string slot)
private

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

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