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

◆ IncreaseOverheating()

void SpawnItemOnLocation::IncreaseOverheating ( ItemBase weapon,
string ammoType,
ItemBase muzzle_owner,
ItemBase suppressor,
string config_to_search )
private

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

5368{
5369 override bool CanPutAsAttachment(EntityAI parent)
5370 {
5371 return true;
5372 }
5373};
5374
5375//const bool QUANTITY_DEBUG_REMOVE_ME = false;
5376
5377class ItemBase extends InventoryItem
5378{
5382
5384
5385 static int m_DebugActionsMask;
5387 // ============================================
5388 // Variable Manipulation System
5389 // ============================================
5390 // Quantity
5391
5392 float m_VarQuantity;
5393 float m_VarQuantityPrev;//for client to know quantity changed during synchronization
5395 int m_VarQuantityMin;
5396 int m_VarQuantityMax;
5397 int m_Count;
5398 float m_VarStackMax;
5399 float m_StoreLoadedQuantity = float.LOWEST;
5400 // Wet
5401 float m_VarWet;
5402 float m_VarWetPrev;//for client to know wetness changed during synchronization
5403 float m_VarWetInit;
5404 float m_VarWetMin;
5405 float m_VarWetMax;
5406 // Cleanness
5407 int m_Cleanness;
5408 int m_CleannessInit;
5409 int m_CleannessMin;
5410 int m_CleannessMax;
5411 // impact sounds
5413 bool m_CanPlayImpactSound = true;
5414 float m_ImpactSpeed;
5416 //
5417 float m_HeatIsolation;
5418 float m_ItemModelLength;
5419 float m_ItemAttachOffset; // Offset length for when the item is attached e.g. to weapon
5421 int m_VarLiquidType;
5422 int m_ItemBehaviour; // -1 = not specified; 0 = heavy item; 1= onehanded item; 2 = twohanded item
5423 int m_QuickBarBonus;
5424 bool m_IsBeingPlaced;
5425 bool m_IsHologram;
5426 bool m_IsTakeable;
5427 bool m_ThrowItemOnDrop;
5430 bool m_FixDamageSystemInit = false; //can be changed on storage version check
5431 bool can_this_be_combined; //Check if item can be combined
5432 bool m_CanThisBeSplit; //Check if item can be split
5433 bool m_IsStoreLoad = false;
5434 bool m_CanShowQuantity;
5435 bool m_HasQuantityBar;
5436 protected bool m_CanBeDigged;
5437 protected bool m_IsResultOfSplit
5438
5439 string m_SoundAttType;
5440 // items color variables
5445 //-------------------------------------------------------
5446
5447 // light source managing
5449
5453
5454 //==============================================
5455 // agent system
5456 private int m_AttachedAgents;
5457
5459 void TransferModifiers(PlayerBase reciever);
5460
5461
5462 // Weapons & suppressors particle effects
5467 static int m_LastRegisteredWeaponID = 0;
5468
5469 // Overheating effects
5471 float m_OverheatingShots;
5472 ref Timer m_CheckOverheating;
5473 int m_ShotsToStartOverheating = 0; // After these many shots, the overheating effect begins
5474 int m_MaxOverheatingValue = 0; // Limits the number of shots that will be tracked
5475 float m_OverheatingDecayInterval = 1; // Timer's interval for decrementing overheat effect's lifespan
5476 ref array <ref OverheatingParticle> m_OverheatingParticles;
5477
5479 protected bool m_HideSelectionsBySlot;
5480
5481 // Admin Log
5482 PluginAdminLog m_AdminLog;
5483
5484 // misc
5485 ref Timer m_PhysDropTimer;
5486
5487 // Attachment Locking variables
5488 ref array<int> m_CompatibleLocks;
5489 protected int m_LockType;
5490 protected ref EffectSound m_LockingSound;
5491 protected string m_LockSoundSet;
5492
5493 // ItemSoundHandler
5494 protected const int ITEM_SOUNDS_MAX = 63; // optimize network synch
5495 protected int m_SoundSyncPlay; // id for sound to play
5496 protected int m_SoundSyncStop; // id for sound to stop
5498
5499 //temperature
5500 private float m_TemperaturePerQuantityWeight;
5501
5502 // -------------------------------------------------------------------------
5503 void ItemBase()
5504 {
5505 SetEventMask(EntityEvent.INIT); // Enable EOnInit event
5509
5510 if (!GetGame().IsDedicatedServer())
5511 {
5512 if (HasMuzzle())
5513 {
5515
5517 {
5519 }
5520 }
5521
5523 m_ActionsInitialize = false;
5524 }
5525
5526 m_OldLocation = null;
5527
5528 if (GetGame().IsServer())
5529 {
5530 m_AdminLog = PluginAdminLog.Cast(GetPlugin(PluginAdminLog));
5531 }
5532
5533 if (ConfigIsExisting("headSelectionsToHide"))
5534 {
5536 ConfigGetTextArray("headSelectionsToHide",m_HeadHidingSelections);
5537 }
5538
5539 m_HideSelectionsBySlot = false;
5540 if (ConfigIsExisting("hideSelectionsByinventorySlot"))
5541 {
5542 m_HideSelectionsBySlot = ConfigGetBool("hideSelectionsByinventorySlot");
5543 }
5544
5545 m_QuickBarBonus = Math.Max(0, ConfigGetInt("quickBarBonus"));
5546
5547 m_IsResultOfSplit = false;
5548
5550 }
5551
5552 override void InitItemVariables()
5553 {
5554 super.InitItemVariables();
5555
5556 m_VarQuantityInit = ConfigGetInt("varQuantityInit");
5557 m_VarQuantity = m_VarQuantityInit;//should be by the CE, this is just a precaution
5558 m_VarQuantityMin = ConfigGetInt("varQuantityMin");
5559 m_VarQuantityMax = ConfigGetInt("varQuantityMax");
5560 m_VarStackMax = ConfigGetFloat("varStackMax");
5561 m_Count = ConfigGetInt("count");
5562
5563 m_CanShowQuantity = ConfigGetBool("quantityShow");
5564 m_HasQuantityBar = ConfigGetBool("quantityBar");
5565
5566 m_CleannessInit = ConfigGetInt("varCleannessInit");
5568 m_CleannessMin = ConfigGetInt("varCleannessMin");
5569 m_CleannessMax = ConfigGetInt("varCleannessMax");
5570
5571 m_WantPlayImpactSound = false;
5572 m_ImpactSpeed = 0.0;
5573
5574 m_VarWetInit = ConfigGetFloat("varWetInit");
5576 m_VarWetMin = ConfigGetFloat("varWetMin");
5577 m_VarWetMax = ConfigGetFloat("varWetMax");
5578
5579 m_LiquidContainerMask = ConfigGetInt("liquidContainerType");
5580 if (IsLiquidContainer() && GetQuantity() != 0)
5582 m_IsBeingPlaced = false;
5583 m_IsHologram = false;
5584 m_IsTakeable = true;
5585 m_CanBeMovedOverride = false;
5589 m_CanBeDigged = ConfigGetBool("canBeDigged");
5590
5591 m_CompatibleLocks = new array<int>();
5592 ConfigGetIntArray("compatibleLocks", m_CompatibleLocks);
5593 m_LockType = ConfigGetInt("lockType");
5594
5595 //Define if item can be split and set ability to be combined accordingly
5596 m_CanThisBeSplit = false;
5597 can_this_be_combined = false;
5598 if (ConfigIsExisting("canBeSplit"))
5599 {
5600 can_this_be_combined = ConfigGetBool("canBeSplit");
5602 }
5603
5604 m_ItemBehaviour = -1;
5605 if (ConfigIsExisting("itemBehaviour"))
5606 m_ItemBehaviour = ConfigGetInt("itemBehaviour");
5607
5608 //RegisterNetSyncVariableInt("m_VariablesMask");
5609 if (HasQuantity()) RegisterNetSyncVariableFloat("m_VarQuantity", GetQuantityMin(), m_VarQuantityMax);
5610 RegisterNetSyncVariableFloat("m_VarWet", GetWetMin(), GetWetMax(), 2);
5611 RegisterNetSyncVariableInt("m_VarLiquidType");
5612 RegisterNetSyncVariableInt("m_Cleanness",0,1);
5613
5614 RegisterNetSyncVariableBoolSignal("m_WantPlayImpactSound");
5615 RegisterNetSyncVariableFloat("m_ImpactSpeed");
5616 RegisterNetSyncVariableInt("m_ImpactSoundSurfaceHash");
5617
5618 RegisterNetSyncVariableInt("m_ColorComponentR", 0, 255);
5619 RegisterNetSyncVariableInt("m_ColorComponentG", 0, 255);
5620 RegisterNetSyncVariableInt("m_ColorComponentB", 0, 255);
5621 RegisterNetSyncVariableInt("m_ColorComponentA", 0, 255);
5622
5623 RegisterNetSyncVariableBool("m_IsBeingPlaced");
5624 RegisterNetSyncVariableBool("m_IsTakeable");
5625 RegisterNetSyncVariableBool("m_IsHologram");
5626
5627 InitItemSounds();
5629 {
5630 RegisterNetSyncVariableInt("m_SoundSyncPlay", 0, ITEM_SOUNDS_MAX);
5631 RegisterNetSyncVariableInt("m_SoundSyncStop", 0, ITEM_SOUNDS_MAX);
5632 }
5633
5634 m_LockSoundSet = ConfigGetString("lockSoundSet");
5635
5637 if (ConfigIsExisting("temperaturePerQuantityWeight"))
5638 m_TemperaturePerQuantityWeight = ConfigGetFloat("temperaturePerQuantityWeight");
5639
5640 }
5641
5642 override int GetQuickBarBonus()
5643 {
5644 return m_QuickBarBonus;
5645 }
5646
5647 void InitializeActions()
5648 {
5650 if (!m_InputActionMap)
5651 {
5653 m_InputActionMap = iam;
5654 SetActions();
5656 }
5657 }
5658
5659 override void GetActions(typename action_input_type, out array<ActionBase_Basic> actions)
5660 {
5662 {
5663 m_ActionsInitialize = true;
5665 }
5666
5667 actions = m_InputActionMap.Get(action_input_type);
5668 }
5669
5670 void SetActions()
5671 {
5672 AddAction(ActionTakeItem);
5673 AddAction(ActionTakeItemToHands);
5674 AddAction(ActionWorldCraft);
5676 AddAction(ActionAttachWithSwitch);
5677 }
5678
5679 void SetActionAnimOverrides(); // Override action animation for specific item
5680
5681 void AddAction(typename actionName)
5682 {
5683 ActionBase action = ActionManagerBase.GetAction(actionName);
5684
5685 if (!action)
5686 {
5687 Debug.LogError("Action " + actionName + " dosn't exist!");
5688 return;
5689 }
5690
5691 typename ai = action.GetInputType();
5692 if (!ai)
5693 {
5694 m_ActionsInitialize = false;
5695 return;
5696 }
5697
5698 array<ActionBase_Basic> action_array = m_InputActionMap.Get(ai);
5699 if (!action_array)
5700 {
5701 action_array = new array<ActionBase_Basic>;
5702 m_InputActionMap.Insert(ai, action_array);
5703 }
5704 if (LogManager.IsActionLogEnable())
5705 {
5706 Debug.ActionLog(action.ToString() + " -> " + ai, this.ToString() , "n/a", "Add action");
5707 }
5708
5709 if (action_array.Find(action) != -1)
5710 {
5711 Debug.Log("Action " + action.Type() + " already added to " + this + ", skipping!");
5712 }
5713 else
5714 {
5715 action_array.Insert(action);
5716 }
5717 }
5718
5719 void RemoveAction(typename actionName)
5720 {
5721 PlayerBase player = PlayerBase.Cast(GetGame().GetPlayer());
5722 ActionBase action = player.GetActionManager().GetAction(actionName);
5723 typename ai = action.GetInputType();
5724 array<ActionBase_Basic> action_array = m_InputActionMap.Get(ai);
5725
5726 if (action_array)
5727 {
5728 action_array.RemoveItem(action);
5729 }
5730 }
5731
5732 // Allows override of default action command per item, defined in the SetActionAnimOverrides() of the item's class
5733 // Set -1 for params which should stay in default state
5734 void OverrideActionAnimation(typename action, int commandUID, int stanceMask = -1, int commandUIDProne = -1)
5735 {
5736 ActionOverrideData overrideData = new ActionOverrideData();
5737 overrideData.m_CommandUID = commandUID;
5738 overrideData.m_CommandUIDProne = commandUIDProne;
5739 overrideData.m_StanceMask = stanceMask;
5740
5741 TActionAnimOverrideMap actionMap = m_ItemActionOverrides.Get(action);
5742 if (!actionMap) // create new map of action > overidables map
5743 {
5744 actionMap = new TActionAnimOverrideMap();
5745 m_ItemActionOverrides.Insert(action, actionMap);
5746 }
5747
5748 actionMap.Insert(this.Type(), overrideData); // insert item -> overrides
5749
5750 }
5751
5752 void OnItemInHandsPlayerSwimStart(PlayerBase player);
5753
5754 ScriptedLightBase GetLight();
5755
5756 // Loads muzzle flash particle configuration from config and saves it to a map for faster access
5757 void LoadParticleConfigOnFire(int id)
5758 {
5759 if (!m_OnFireEffect)
5761
5764
5765 string config_to_search = "CfgVehicles";
5766 string muzzle_owner_config;
5767
5768 if (!m_OnFireEffect.Contains(id))
5769 {
5770 if (IsInherited(Weapon))
5771 config_to_search = "CfgWeapons";
5772
5773 muzzle_owner_config = config_to_search + " " + GetType() + " ";
5774
5775 string config_OnFire_class = muzzle_owner_config + "Particles " + "OnFire ";
5776
5777 int config_OnFire_subclass_count = GetGame().ConfigGetChildrenCount(config_OnFire_class);
5778
5779 if (config_OnFire_subclass_count > 0)
5780 {
5781 array<ref WeaponParticlesOnFire> WPOF_array = new array<ref WeaponParticlesOnFire>;
5782
5783 for (int i = 0; i < config_OnFire_subclass_count; i++)
5784 {
5785 string particle_class = "";
5786 GetGame().ConfigGetChildName(config_OnFire_class, i, particle_class);
5787 string config_OnFire_entry = config_OnFire_class + particle_class;
5788 WeaponParticlesOnFire WPOF = new WeaponParticlesOnFire(this, config_OnFire_entry);
5789 WPOF_array.Insert(WPOF);
5790 }
5791
5792
5793 m_OnFireEffect.Insert(id, WPOF_array);
5794 }
5795 }
5796
5797 if (!m_OnBulletCasingEjectEffect.Contains(id))
5798 {
5799 config_to_search = "CfgWeapons"; // Bullet Eject efect is supported on weapons only.
5800 muzzle_owner_config = config_to_search + " " + GetType() + " ";
5801
5802 string config_OnBulletCasingEject_class = muzzle_owner_config + "Particles " + "OnBulletCasingEject ";
5803
5804 int config_OnBulletCasingEject_count = GetGame().ConfigGetChildrenCount(config_OnBulletCasingEject_class);
5805
5806 if (config_OnBulletCasingEject_count > 0 && IsInherited(Weapon))
5807 {
5808 array<ref WeaponParticlesOnBulletCasingEject> WPOBE_array = new array<ref WeaponParticlesOnBulletCasingEject>;
5809
5810 for (i = 0; i < config_OnBulletCasingEject_count; i++)
5811 {
5812 string particle_class2 = "";
5813 GetGame().ConfigGetChildName(config_OnBulletCasingEject_class, i, particle_class2);
5814 string config_OnBulletCasingEject_entry = config_OnBulletCasingEject_class + particle_class2;
5815 WeaponParticlesOnBulletCasingEject WPOBE = new WeaponParticlesOnBulletCasingEject(this, config_OnBulletCasingEject_entry);
5816 WPOBE_array.Insert(WPOBE);
5817 }
5818
5819
5820 m_OnBulletCasingEjectEffect.Insert(id, WPOBE_array);
5821 }
5822 }
5823 }
5824
5825 // Loads muzzle flash particle configuration from config and saves it to a map for faster access
5827 {
5830
5831 if (!m_OnOverheatingEffect.Contains(id))
5832 {
5833 string config_to_search = "CfgVehicles";
5834
5835 if (IsInherited(Weapon))
5836 config_to_search = "CfgWeapons";
5837
5838 string muzzle_owner_config = config_to_search + " " + GetType() + " ";
5839 string config_OnOverheating_class = muzzle_owner_config + "Particles " + "OnOverheating ";
5840
5841 if (GetGame().ConfigIsExisting(config_OnOverheating_class))
5842 {
5843
5844 m_ShotsToStartOverheating = GetGame().ConfigGetFloat(config_OnOverheating_class + "shotsToStartOverheating");
5845
5847 {
5848 m_ShotsToStartOverheating = -1; // This prevents futher readings from config for future creations of this item
5849 string error = "Error reading config " + GetType() + ">Particles>OnOverheating - Parameter shotsToStartOverheating is configured wrong or is missing! Its value must be 1 or higher!";
5850 Error(error);
5851 return;
5852 }
5853
5854 m_OverheatingDecayInterval = GetGame().ConfigGetFloat(config_OnOverheating_class + "overheatingDecayInterval");
5855 m_MaxOverheatingValue = GetGame().ConfigGetFloat(config_OnOverheating_class + "maxOverheatingValue");
5856
5857
5858
5859 int config_OnOverheating_subclass_count = GetGame().ConfigGetChildrenCount(config_OnOverheating_class);
5860 array<ref WeaponParticlesOnOverheating> WPOOH_array = new array<ref WeaponParticlesOnOverheating>;
5861
5862 for (int i = 0; i < config_OnOverheating_subclass_count; i++)
5863 {
5864 string particle_class = "";
5865 GetGame().ConfigGetChildName(config_OnOverheating_class, i, particle_class);
5866 string config_OnOverheating_entry = config_OnOverheating_class + particle_class;
5867 int entry_type = GetGame().ConfigGetType(config_OnOverheating_entry);
5868
5869 if (entry_type == CT_CLASS)
5870 {
5871 WeaponParticlesOnOverheating WPOF = new WeaponParticlesOnOverheating(this, config_OnOverheating_entry);
5872 WPOOH_array.Insert(WPOF);
5873 }
5874 }
5875
5876
5877 m_OnOverheatingEffect.Insert(id, WPOOH_array);
5878 }
5879 }
5880 }
5881
5882 float GetOverheatingValue()
5883 {
5884 return m_OverheatingShots;
5885 }
5886
5887 void IncreaseOverheating(ItemBase weapon, string ammoType, ItemBase muzzle_owner, ItemBase suppressor, string config_to_search)
5888 {
5889 if (m_MaxOverheatingValue > 0)
5890 {
5892
5893 if (!m_CheckOverheating)
5895
5897 m_CheckOverheating.Run(m_OverheatingDecayInterval, this, "OnOverheatingDecay");
5898
5899 CheckOverheating(weapon, ammoType, muzzle_owner, suppressor, config_to_search);
5900 }
5901 }
5902
5903 void CheckOverheating(ItemBase weapon = null, string ammoType = "", ItemBase muzzle_owner = null, ItemBase suppressor = null, string config_to_search = "")
5904 {
5906 UpdateOverheating(weapon, ammoType, muzzle_owner, suppressor, config_to_search);
5907
5909 StartOverheating(weapon, ammoType, muzzle_owner, suppressor, config_to_search);
5910
5912 StopOverheating(weapon, ammoType, muzzle_owner, suppressor, config_to_search);
5913
5915 {
5917 }
5918 }
5919
5921 {
5923 }
5924
5925 void OnOverheatingDecay()
5926 {
5927 if (m_MaxOverheatingValue > 0)
5928 m_OverheatingShots -= 1 + m_OverheatingShots / m_MaxOverheatingValue; // The hotter a barrel is, the faster it needs to cool down.
5929 else
5931
5932 if (m_OverheatingShots <= 0)
5933 {
5936 }
5937 else
5938 {
5939 if (!m_CheckOverheating)
5941
5943 m_CheckOverheating.Run(m_OverheatingDecayInterval, this, "OnOverheatingDecay");
5944 }
5945
5946 CheckOverheating(this, "", this);
5947 }
5948
5949 void StartOverheating(ItemBase weapon = null, string ammoType = "", ItemBase muzzle_owner = null, ItemBase suppressor = null, string config_to_search = "")
5950 {
5952 ItemBase.PlayOverheatingParticles(this, ammoType, this, suppressor, "CfgWeapons");
5953 }
5954
5955 void UpdateOverheating(ItemBase weapon = null, string ammoType = "", ItemBase muzzle_owner = null, ItemBase suppressor = null, string config_to_search = "")
5956 {
5958 ItemBase.UpdateOverheatingParticles(this, ammoType, this, suppressor, "CfgWeapons");
5960 }
5961
5962 void StopOverheating(ItemBase weapon = null, string ammoType = "", ItemBase muzzle_owner = null, ItemBase suppressor = null, string config_to_search = "")
5963 {
5965 ItemBase.StopOverheatingParticles(weapon, ammoType, muzzle_owner, suppressor, config_to_search);
5966 }
5967
5968 void RegisterOverheatingParticle(Particle p, float min_heat_coef, float max_heat_coef, int particle_id, Object parent, vector local_pos, vector local_ori)
5969 {
5971 m_OverheatingParticles = new array<ref OverheatingParticle>;
5972
5973 OverheatingParticle OP = new OverheatingParticle();
5974 OP.RegisterParticle(p);
5975 OP.SetOverheatingLimitMin(min_heat_coef);
5976 OP.SetOverheatingLimitMax(max_heat_coef);
5977 OP.SetParticleParams(particle_id, parent, local_pos, local_ori);
5978
5979 m_OverheatingParticles.Insert(OP);
5980 }
5981
5982 float GetOverheatingCoef()
5983 {
5984 if (m_MaxOverheatingValue > 0)
5986
5987 return -1;
5988 }
5989
5991 {
5993 {
5994 float overheat_coef = GetOverheatingCoef();
5995 int count = m_OverheatingParticles.Count();
5996
5997 for (int i = count; i > 0; --i)
5998 {
5999 int id = i - 1;
6000 OverheatingParticle OP = m_OverheatingParticles.Get(id);
6001 Particle p = OP.GetParticle();
6002
6003 float overheat_min = OP.GetOverheatingLimitMin();
6004 float overheat_max = OP.GetOverheatingLimitMax();
6005
6006 if (overheat_coef < overheat_min && overheat_coef >= overheat_max)
6007 {
6008 if (p)
6009 {
6010 p.Stop();
6011 OP.RegisterParticle(null);
6012 }
6013 }
6014 }
6015 }
6016 }
6017
6019 {
6021 {
6022 for (int i = m_OverheatingParticles.Count(); i > 0; i--)
6023 {
6024 int id = i - 1;
6025 OverheatingParticle OP = m_OverheatingParticles.Get(id);
6026
6027 if (OP)
6028 {
6029 Particle p = OP.GetParticle();
6030
6031 if (p)
6032 {
6033 p.Stop();
6034 }
6035
6036 delete OP;
6037 }
6038 }
6039
6040 m_OverheatingParticles.Clear();
6042 }
6043 }
6044
6046 float GetInfectionChance(int system = 0, Param param = null)
6047 {
6048 return 0.0;
6049 }
6050
6051
6052 float GetDisinfectQuantity(int system = 0, Param param1 = null)
6053 {
6054 return 250;//default value
6055 }
6056
6057 float GetFilterDamageRatio()
6058 {
6059 return 0;
6060 }
6061
6063 bool HasMuzzle()
6064 {
6065 if (IsInherited(Weapon) || IsInherited(SuppressorBase))
6066 return true;
6067
6068 return false;
6069 }
6070
6072 int GetMuzzleID()
6073 {
6074 if (!m_WeaponTypeToID)
6076
6077 if (m_WeaponTypeToID.Contains(GetType()))
6078 {
6079 return m_WeaponTypeToID.Get(GetType());
6080 }
6081 else
6082 {
6083 // Register new weapon ID
6085 }
6086
6088 }
6089
6096 {
6097 return -1;
6098 }
6099
6100
6101
6102 // -------------------------------------------------------------------------
6103 void ~ItemBase()
6104 {
6105 if (GetGame() && GetGame().GetPlayer() && (!GetGame().IsDedicatedServer()))
6106 {
6107 PlayerBase player = PlayerBase.Cast(GetGame().GetPlayer());
6108 int r_index = player.GetHumanInventory().FindUserReservedLocationIndex(this);
6109
6110 if (r_index >= 0)
6111 {
6112 InventoryLocation r_il = new InventoryLocation;
6113 player.GetHumanInventory().GetUserReservedLocation(r_index,r_il);
6114
6115 player.GetHumanInventory().ClearUserReservedLocationAtIndex(r_index);
6116 int r_type = r_il.GetType();
6117 if (r_type == InventoryLocationType.CARGO || r_type == InventoryLocationType.PROXYCARGO)
6118 {
6119 r_il.GetParent().GetOnReleaseLock().Invoke(this);
6120 }
6121 else if (r_type == InventoryLocationType.ATTACHMENT)
6122 {
6123 r_il.GetParent().GetOnAttachmentReleaseLock().Invoke(this, r_il.GetSlot());
6124 }
6125
6126 }
6127
6128 player.GetHumanInventory().ClearUserReservedLocation(this);
6129 }
6130
6131 if (m_LockingSound)
6132 SEffectManager.DestroyEffect(m_LockingSound);
6133 }
6134
6135
6136
6137 // -------------------------------------------------------------------------
6138 static int GetDebugActionsMask()
6139 {
6140 return ItemBase.m_DebugActionsMask;
6141 }
6142
6143 static bool HasDebugActionsMask(int mask)
6144 {
6145 return ItemBase.m_DebugActionsMask & mask;
6146 }
6147
6148 static void SetDebugActionsMask(int mask)
6149 {
6150 ItemBase.m_DebugActionsMask = mask;
6151 }
6152
6153 static void AddDebugActionsMask(int mask)
6154 {
6155 ItemBase.m_DebugActionsMask |= mask;
6156 }
6157
6158 static void RemoveDebugActionsMask(int mask)
6159 {
6160 ItemBase.m_DebugActionsMask &= ~mask;
6161 }
6162
6163 static void ToggleDebugActionsMask(int mask)
6164 {
6165 if (HasDebugActionsMask(mask))
6166 {
6168 }
6169 else
6170 {
6171 AddDebugActionsMask(mask);
6172 }
6173 }
6174
6175 // -------------------------------------------------------------------------
6176 void SetCEBasedQuantity()
6177 {
6178 if (GetEconomyProfile())
6179 {
6180 float q_max = GetEconomyProfile().GetQuantityMax();
6181 if (q_max > 0)
6182 {
6183 float q_min = GetEconomyProfile().GetQuantityMin();
6184 float quantity_randomized = Math.RandomFloatInclusive(q_min, q_max);
6185
6186 if (HasComponent(COMP_TYPE_ENERGY_MANAGER))//more direct access for speed
6187 {
6188 ComponentEnergyManager comp = GetCompEM();
6189 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
6190 {
6191 comp.SetEnergy0To1(quantity_randomized);
6192 }
6193 }
6194 else if (HasQuantity())
6195 {
6196 SetQuantityNormalized(quantity_randomized, false);
6197 //PrintString("<==> Normalized quantity for item: "+ GetType()+", qmin:"+q_min.ToString()+"; qmax:"+q_max.ToString()+";quantity:" +quantity_randomized.ToString());
6198 }
6199
6200 }
6201 }
6202 }
6203
6205 void LockToParent()
6206 {
6207 EntityAI parent = GetHierarchyParent();
6208
6209 if (parent)
6210 {
6211 InventoryLocation inventory_location_to_lock = new InventoryLocation;
6212 GetInventory().GetCurrentInventoryLocation(inventory_location_to_lock);
6213 parent.GetInventory().SetSlotLock(inventory_location_to_lock.GetSlot(), true);
6214 }
6215 }
6216
6218 void UnlockFromParent()
6219 {
6220 EntityAI parent = GetHierarchyParent();
6221
6222 if (parent)
6223 {
6224 InventoryLocation inventory_location_to_unlock = new InventoryLocation;
6225 GetInventory().GetCurrentInventoryLocation(inventory_location_to_unlock);
6226 parent.GetInventory().SetSlotLock(inventory_location_to_unlock.GetSlot(), false);
6227 }
6228 }
6229
6230 override void CombineItemsClient(EntityAI entity2, bool use_stack_max = true)
6231 {
6232 /*
6233 ref Param1<EntityAI> item = new Param1<EntityAI>(entity2);
6234 RPCSingleParam(ERPCs.RPC_ITEM_COMBINE, item, GetGame().GetPlayer());
6235 */
6236 ItemBase item2 = ItemBase.Cast(entity2);
6237
6238 if (GetGame().IsClient())
6239 {
6240 if (ScriptInputUserData.CanStoreInputUserData())
6241 {
6242 ScriptInputUserData ctx = new ScriptInputUserData;
6244 ctx.Write(-1);
6245 ItemBase i1 = this; // @NOTE: workaround for correct serialization
6246 ctx.Write(i1);
6247 ctx.Write(item2);
6248 ctx.Write(use_stack_max);
6249 ctx.Write(-1);
6250 ctx.Send();
6251
6252 if (IsCombineAll(item2, use_stack_max))
6253 {
6254 GetGame().GetPlayer().GetInventory().AddInventoryReservationEx(item2,null,GameInventory.c_InventoryReservationTimeoutShortMS);
6255 }
6256 }
6257 }
6258 else if (!GetGame().IsMultiplayer())
6259 {
6260 CombineItems(item2, use_stack_max);
6261 }
6262 }
6263
6264 bool IsLiquidPresent()
6265 {
6266 return (GetLiquidType() != 0 && HasQuantity());
6267 }
6268
6269 bool IsLiquidContainer()
6270 {
6271 return m_LiquidContainerMask != 0;
6272 }
6273
6275 {
6276 return m_LiquidContainerMask;
6277 }
6278
6279 bool IsBloodContainer()
6280 {
6281 //m_LiquidContainerMask & GROUP_LIQUID_BLOOD ???
6282 return false;
6283 }
6284
6285 bool IsNVG()
6286 {
6287 return false;
6288 }
6289
6292 bool IsExplosive()
6293 {
6294 return false;
6295 }
6296
6298 {
6299 return "";
6300 }
6301
6303
6304 bool IsLightSource()
6305 {
6306 return false;
6307 }
6308
6310 {
6311 return true;
6312 }
6313
6314 //--- ACTION CONDITIONS
6315 //direction
6316 bool IsFacingPlayer(PlayerBase player, string selection)
6317 {
6318 return true;
6319 }
6320
6321 bool IsPlayerInside(PlayerBase player, string selection)
6322 {
6323 return true;
6324 }
6325
6326 override bool CanObstruct()
6327 {
6328 PlayerBase player = PlayerBase.Cast(g_Game.GetPlayer());
6329 return !player || !IsPlayerInside(player, "");
6330 }
6331
6332 override bool IsBeingPlaced()
6333 {
6334 return m_IsBeingPlaced;
6335 }
6336
6337 void SetIsBeingPlaced(bool is_being_placed)
6338 {
6339 m_IsBeingPlaced = is_being_placed;
6340 if (!is_being_placed)
6342 SetSynchDirty();
6343 }
6344
6345 //server-side
6346 void OnEndPlacement() {}
6347
6348 override bool IsHologram()
6349 {
6350 return m_IsHologram;
6351 }
6352
6353 bool CanBeDigged()
6354 {
6355 return m_CanBeDigged;
6356 }
6357
6359 {
6360 return 1;
6361 }
6362
6363 bool CanMakeGardenplot()
6364 {
6365 return false;
6366 }
6367
6368 void SetIsHologram(bool is_hologram)
6369 {
6370 m_IsHologram = is_hologram;
6371 SetSynchDirty();
6372 }
6373 /*
6374 protected float GetNutritionalEnergy()
6375 {
6376 Edible_Base edible = Edible_Base.Cast(this);
6377 return edible.GetFoodEnergy();
6378 }
6379
6380 protected float GetNutritionalWaterContent()
6381 {
6382 Edible_Base edible = Edible_Base.Cast(this);
6383 return edible.GetFoodWater();
6384 }
6385
6386 protected float GetNutritionalIndex()
6387 {
6388 Edible_Base edible = Edible_Base.Cast(this);
6389 return edible.GetFoodNutritionalIndex();
6390 }
6391
6392 protected float GetNutritionalFullnessIndex()
6393 {
6394 Edible_Base edible = Edible_Base.Cast(this);
6395 return edible.GetFoodTotalVolume();
6396 }
6397
6398 protected float GetNutritionalToxicity()
6399 {
6400 Edible_Base edible = Edible_Base.Cast(this);
6401 return edible.GetFoodToxicity();
6402
6403 }
6404 */
6405
6406
6407 // -------------------------------------------------------------------------
6408 override void OnMovedInsideCargo(EntityAI container)
6409 {
6410 super.OnMovedInsideCargo(container);
6411
6412 MiscGameplayFunctions.RemoveAllAttachedChildrenByTypename(this, {Bolt_Base});
6413 }
6414
6415 override void EEItemLocationChanged(notnull InventoryLocation oldLoc, notnull InventoryLocation newLoc)
6416 {
6417 super.EEItemLocationChanged(oldLoc,newLoc);
6418
6419 PlayerBase new_player = null;
6420 PlayerBase old_player = null;
6421
6422 if (newLoc.GetParent())
6423 new_player = PlayerBase.Cast(newLoc.GetParent().GetHierarchyRootPlayer());
6424
6425 if (oldLoc.GetParent())
6426 old_player = PlayerBase.Cast(oldLoc.GetParent().GetHierarchyRootPlayer());
6427
6428 if (old_player && oldLoc.GetType() == InventoryLocationType.HANDS)
6429 {
6430 int r_index = old_player.GetHumanInventory().FindUserReservedLocationIndex(this);
6431
6432 if (r_index >= 0)
6433 {
6434 InventoryLocation r_il = new InventoryLocation;
6435 old_player.GetHumanInventory().GetUserReservedLocation(r_index,r_il);
6436
6437 old_player.GetHumanInventory().ClearUserReservedLocationAtIndex(r_index);
6438 int r_type = r_il.GetType();
6439 if (r_type == InventoryLocationType.CARGO || r_type == InventoryLocationType.PROXYCARGO)
6440 {
6441 r_il.GetParent().GetOnReleaseLock().Invoke(this);
6442 }
6443 else if (r_type == InventoryLocationType.ATTACHMENT)
6444 {
6445 r_il.GetParent().GetOnAttachmentReleaseLock().Invoke(this, r_il.GetSlot());
6446 }
6447
6448 }
6449 }
6450
6451 if (newLoc.GetType() == InventoryLocationType.HANDS)
6452 {
6453 if (new_player)
6454 new_player.ForceStandUpForHeavyItems(newLoc.GetItem());
6455
6456 if (new_player == old_player)
6457 {
6458
6459 if (oldLoc.GetParent() && new_player.GetHumanInventory().LocationGetEntity(oldLoc) == NULL)
6460 {
6461 if (oldLoc.GetType() == InventoryLocationType.CARGO)
6462 {
6463 if (oldLoc.GetParent().GetInventory().TestAddEntityInCargoExLoc(oldLoc, false, false, false, true, false, false))
6464 {
6465 new_player.GetHumanInventory().SetUserReservedLocation(this,oldLoc);
6466 }
6467 }
6468 else
6469 {
6470 new_player.GetHumanInventory().SetUserReservedLocation(this,oldLoc);
6471 }
6472 }
6473
6474 if (new_player.GetHumanInventory().FindUserReservedLocationIndex(this) >= 0)
6475 {
6476 int type = oldLoc.GetType();
6477 if (type == InventoryLocationType.CARGO || type == InventoryLocationType.PROXYCARGO)
6478 {
6479 oldLoc.GetParent().GetOnSetLock().Invoke(this);
6480 }
6481 else if (type == InventoryLocationType.ATTACHMENT)
6482 {
6483 oldLoc.GetParent().GetOnAttachmentSetLock().Invoke(this, oldLoc.GetSlot());
6484 }
6485 }
6486 if (!m_OldLocation)
6487 {
6488 m_OldLocation = new InventoryLocation;
6489 }
6490 m_OldLocation.Copy(oldLoc);
6491 }
6492 else
6493 {
6494 if (m_OldLocation)
6495 {
6496 m_OldLocation.Reset();
6497 }
6498 }
6499
6501 }
6502 else
6503 {
6504 if (new_player)
6505 {
6506 int res_index = new_player.GetHumanInventory().FindCollidingUserReservedLocationIndex(this, newLoc);
6507 if (res_index >= 0)
6508 {
6509 InventoryLocation il = new InventoryLocation;
6510 new_player.GetHumanInventory().GetUserReservedLocation(res_index,il);
6511 ItemBase it = ItemBase.Cast(il.GetItem());
6512 new_player.GetHumanInventory().ClearUserReservedLocationAtIndex(res_index);
6513 int rel_type = il.GetType();
6514 if (rel_type == InventoryLocationType.CARGO || rel_type == InventoryLocationType.PROXYCARGO)
6515 {
6516 il.GetParent().GetOnReleaseLock().Invoke(it);
6517 }
6518 else if (rel_type == InventoryLocationType.ATTACHMENT)
6519 {
6520 il.GetParent().GetOnAttachmentReleaseLock().Invoke(it, il.GetSlot());
6521 }
6522 //it.GetOnReleaseLock().Invoke(it);
6523 }
6524 }
6525 else if (old_player && newLoc.GetType() == InventoryLocationType.GROUND && m_ThrowItemOnDrop)
6526 {
6527 //ThrowPhysically(old_player, vector.Zero);
6528 m_ThrowItemOnDrop = false;
6529 }
6530
6531 if (m_OldLocation)
6532 {
6533 m_OldLocation.Reset();
6534 }
6535 }
6536 }
6537
6538 override void EOnContact(IEntity other, Contact extra)
6539 {
6541 {
6542 int liquidType = -1;
6543 float impactSpeed = ProcessImpactSoundEx(other, extra, m_ConfigWeight, m_ImpactSoundSurfaceHash, liquidType);
6544 if (impactSpeed > 0.0)
6545 {
6546 m_ImpactSpeed = impactSpeed;
6547 #ifndef SERVER
6548 PlayImpactSound(m_ConfigWeight, m_ImpactSpeed, m_ImpactSoundSurfaceHash);
6549 #else
6550 m_WantPlayImpactSound = true;
6551 SetSynchDirty();
6552 #endif
6553 m_CanPlayImpactSound = (liquidType == -1);// prevents further playing of the sound when the surface is a liquid type
6554 }
6555 }
6556
6557 #ifdef SERVER
6558 if (GetCompEM() && GetCompEM().IsPlugged())
6559 {
6560 if (GetCompEM().GetCordLength() < vector.Distance(GetPosition(), GetCompEM().GetEnergySource().GetPosition()))
6561 GetCompEM().UnplugThis();
6562 }
6563 #endif
6564 }
6565
6566 void RefreshPhysics();
6567
6568 override void OnCreatePhysics()
6569 {
6571 }
6572
6573 override void OnItemAttachmentSlotChanged(notnull InventoryLocation oldLoc, notnull InventoryLocation newLoc)
6574 {
6575
6576 }
6577 // -------------------------------------------------------------------------
6578 override void OnItemLocationChanged(EntityAI old_owner, EntityAI new_owner)
6579 {
6580 super.OnItemLocationChanged(old_owner, new_owner);
6581
6582 PlayerBase relatedPlayer = PlayerBase.Cast(old_owner);
6583 PlayerBase playerNew = PlayerBase.Cast(new_owner);
6584
6585 if (!relatedPlayer && playerNew)
6586 relatedPlayer = playerNew;
6587
6588 if (relatedPlayer && relatedPlayer.GetPerformedActionID() != -1)
6589 {
6590 ActionManagerBase actionMgr = relatedPlayer.GetActionManager();
6591 if (actionMgr)
6592 {
6593 ActionBase currentAction = actionMgr.GetRunningAction();
6594 if (currentAction)
6595 currentAction.OnItemLocationChanged(this);
6596 }
6597 }
6598
6599 Man ownerPlayerOld = null;
6600 Man ownerPlayerNew = null;
6601
6602 if (old_owner)
6603 {
6604 if (old_owner.IsMan())
6605 {
6606 ownerPlayerOld = Man.Cast(old_owner);
6607 }
6608 else
6609 {
6610 ownerPlayerOld = Man.Cast(old_owner.GetHierarchyRootPlayer());
6611 }
6612 }
6613 else
6614 {
6615 if (new_owner && IsElectricAppliance() && GetCompEM() && GetCompEM().IsPlugged())
6616 {
6617 ActionBase action = ActionManagerBase.GetAction(ActionRepositionPluggedItem);
6618
6619 if (!action || !playerNew || playerNew.GetPerformedActionID() != action.GetID())
6620 {
6621 GetCompEM().UnplugThis();
6622 }
6623 }
6624 }
6625
6626 if (new_owner)
6627 {
6628 if (new_owner.IsMan())
6629 {
6630 ownerPlayerNew = Man.Cast(new_owner);
6631 }
6632 else
6633 {
6634 ownerPlayerNew = Man.Cast(new_owner.GetHierarchyRootPlayer());
6635 }
6636 }
6637
6638 if (ownerPlayerOld != ownerPlayerNew)
6639 {
6640 if (ownerPlayerOld)
6641 {
6642 array<EntityAI> subItemsExit = new array<EntityAI>;
6643 GetInventory().EnumerateInventory(InventoryTraversalType.PREORDER,subItemsExit);
6644 for (int i = 0; i < subItemsExit.Count(); i++)
6645 {
6646 ItemBase itemExit = ItemBase.Cast(subItemsExit.Get(i));
6647 itemExit.OnInventoryExit(ownerPlayerOld);
6648 }
6649 }
6650
6651 if (ownerPlayerNew)
6652 {
6653 array<EntityAI> subItemsEnter = new array<EntityAI>;
6654 GetInventory().EnumerateInventory(InventoryTraversalType.PREORDER,subItemsEnter);
6655 for (int j = 0; j < subItemsEnter.Count(); j++)
6656 {
6657 ItemBase itemEnter = ItemBase.Cast(subItemsEnter.Get(j));
6658 itemEnter.OnInventoryEnter(ownerPlayerNew);
6659 }
6660 }
6661 }
6662 else if (ownerPlayerNew != null)
6663 {
6664 PlayerBase nplayer;
6665 if (PlayerBase.CastTo(nplayer, ownerPlayerNew))
6666 {
6667 array<EntityAI> subItemsUpdate = new array<EntityAI>;
6668 GetInventory().EnumerateInventory(InventoryTraversalType.PREORDER,subItemsUpdate);
6669 for (int k = 0; k < subItemsUpdate.Count(); k++)
6670 {
6671 ItemBase itemUpdate = ItemBase.Cast(subItemsUpdate.Get(k));
6672 itemUpdate.UpdateQuickbarShortcutVisibility(nplayer);
6673 }
6674 }
6675 }
6676
6677 if (old_owner)
6678 old_owner.OnChildItemRemoved(this);
6679 if (new_owner)
6680 new_owner.OnChildItemReceived(this);
6681 }
6682
6683 // -------------------------------------------------------------------------------
6684 override void EEDelete(EntityAI parent)
6685 {
6686 super.EEDelete(parent);
6687 PlayerBase player = PlayerBase.Cast(GetHierarchyRootPlayer());
6688 if (player)
6689 {
6690 OnInventoryExit(player);
6691
6692 if (player.IsAlive())
6693 {
6694 int r_index = player.GetHumanInventory().FindUserReservedLocationIndex(this);
6695 if (r_index >= 0)
6696 {
6697 InventoryLocation r_il = new InventoryLocation;
6698 player.GetHumanInventory().GetUserReservedLocation(r_index,r_il);
6699
6700 player.GetHumanInventory().ClearUserReservedLocationAtIndex(r_index);
6701 int r_type = r_il.GetType();
6702 if (r_type == InventoryLocationType.CARGO || r_type == InventoryLocationType.PROXYCARGO)
6703 {
6704 r_il.GetParent().GetOnReleaseLock().Invoke(this);
6705 }
6706 else if (r_type == InventoryLocationType.ATTACHMENT)
6707 {
6708 r_il.GetParent().GetOnAttachmentReleaseLock().Invoke(this, r_il.GetSlot());
6709 }
6710
6711 }
6712
6713 player.RemoveQuickBarEntityShortcut(this);
6714 }
6715 }
6716 }
6717 // -------------------------------------------------------------------------------
6718 override void EEKilled(Object killer)
6719 {
6720 super.EEKilled(killer);
6721
6723 if (killer && killer.IsFireplace() && CanExplodeInFire())
6724 {
6725 if (GetTemperature() >= GameConstants.ITEM_TEMPERATURE_TO_EXPLODE_MIN)
6726 {
6727 if (IsMagazine())
6728 {
6729 if (Magazine.Cast(this).GetAmmoCount() > 0)
6730 {
6731 ExplodeAmmo();
6732 }
6733 }
6734 else
6735 {
6736 Explode(DamageType.EXPLOSION);
6737 }
6738 }
6739 }
6740 }
6741
6742 override void OnWasAttached(EntityAI parent, int slot_id)
6743 {
6744 MiscGameplayFunctions.RemoveAllAttachedChildrenByTypename(this, {Bolt_Base});
6745
6746 super.OnWasAttached(parent, slot_id);
6747
6748 if (HasQuantity())
6749 UpdateNetSyncVariableFloat("m_VarQuantity", GetQuantityMin(), m_VarQuantityMax);
6750
6751 PlayAttachSound(InventorySlots.GetSlotName(slot_id));
6752 }
6753
6754 override void OnWasDetached(EntityAI parent, int slot_id)
6755 {
6756 super.OnWasDetached(parent, slot_id);
6757
6758 if (HasQuantity())
6759 UpdateNetSyncVariableFloat("m_VarQuantity", GetQuantityMin(), m_VarQuantityMax);
6760 }
6761
6762 override string ChangeIntoOnAttach(string slot)
6763 {
6764 int idx;
6765 TStringArray inventory_slots = new TStringArray;
6766 TStringArray attach_types = new TStringArray;
6767
6768 ConfigGetTextArray("ChangeInventorySlot",inventory_slots);
6769 if (inventory_slots.Count() < 1) //is string
6770 {
6771 inventory_slots.Insert(ConfigGetString("ChangeInventorySlot"));
6772 attach_types.Insert(ConfigGetString("ChangeIntoOnAttach"));
6773 }
6774 else //is array
6775 {
6776 ConfigGetTextArray("ChangeIntoOnAttach",attach_types);
6777 }
6778
6779 idx = inventory_slots.Find(slot);
6780 if (idx < 0)
6781 return "";
6782
6783 return attach_types.Get(idx);
6784 }
6785
6786 override string ChangeIntoOnDetach()
6787 {
6788 int idx = -1;
6789 string slot;
6790
6791 TStringArray inventory_slots = new TStringArray;
6792 TStringArray detach_types = new TStringArray;
6793
6794 this.ConfigGetTextArray("ChangeInventorySlot",inventory_slots);
6795 if (inventory_slots.Count() < 1) //is string
6796 {
6797 inventory_slots.Insert(this.ConfigGetString("ChangeInventorySlot"));
6798 detach_types.Insert(this.ConfigGetString("ChangeIntoOnDetach"));
6799 }
6800 else //is array
6801 {
6802 this.ConfigGetTextArray("ChangeIntoOnDetach",detach_types);
6803 if (detach_types.Count() < 1)
6804 detach_types.Insert(this.ConfigGetString("ChangeIntoOnDetach"));
6805 }
6806
6807 for (int i = 0; i < inventory_slots.Count(); i++)
6808 {
6809 slot = inventory_slots.Get(i);
6810 }
6811
6812 if (slot != "")
6813 {
6814 if (detach_types.Count() == 1)
6815 idx = 0;
6816 else
6817 idx = inventory_slots.Find(slot);
6818 }
6819 if (idx < 0)
6820 return "";
6821
6822 return detach_types.Get(idx);
6823 }
6824
6825 void ExplodeAmmo()
6826 {
6827 //timer
6828 ref Timer explode_timer = new Timer(CALL_CATEGORY_SYSTEM);
6829
6830 //min/max time
6831 float min_time = 1;
6832 float max_time = 3;
6833 float delay = Math.RandomFloat(min_time, max_time);
6834
6835 explode_timer.Run(delay, this, "DoAmmoExplosion");
6836 }
6837
6838 void DoAmmoExplosion()
6839 {
6840 Magazine magazine = Magazine.Cast(this);
6841 int pop_sounds_count = 6;
6842 string pop_sounds[ 6 ] = { "ammopops_1","ammopops_2","ammopops_3","ammopops_4","ammopops_5","ammopops_6" };
6843
6844 //play sound
6845 int sound_idx = Math.RandomInt(0, pop_sounds_count - 1);
6846 string sound_name = pop_sounds[ sound_idx ];
6847 GetGame().CreateSoundOnObject(this, sound_name, 20, false);
6848
6849 //remove ammo count
6850 magazine.ServerAddAmmoCount(-1);
6851
6852 //if condition then repeat -> ExplodeAmmo
6853 float min_temp_to_explode = 100; //min temperature for item to explode
6854
6855 if (magazine.GetAmmoCount() > 0 && GetTemperature() >= min_temp_to_explode) //TODO ? add check for parent -> fireplace
6856 {
6857 ExplodeAmmo();
6858 }
6859 }
6860
6861 // -------------------------------------------------------------------------------
6862 override void EEHitBy(TotalDamageResult damageResult, int damageType, EntityAI source, int component, string dmgZone, string ammo, vector modelPos, float speedCoef)
6863 {
6864 super.EEHitBy(damageResult, damageType, source, component, dmgZone, ammo, modelPos, speedCoef);
6865
6866 const int CHANCE_DAMAGE_CARGO = 4;
6867 const int CHANCE_DAMAGE_ATTACHMENT = 1;
6868 const int CHANCE_DAMAGE_NOTHING = 2;
6869
6870 if (IsClothing() || IsContainer() || IsItemTent())
6871 {
6872 float dmg = damageResult.GetDamage("","Health") * -0.5;
6873 int chances;
6874 int rnd;
6875
6876 if (GetInventory().GetCargo())
6877 {
6878 chances = CHANCE_DAMAGE_CARGO + CHANCE_DAMAGE_ATTACHMENT + CHANCE_DAMAGE_NOTHING;
6879 rnd = Math.RandomInt(0,chances);
6880
6881 if (rnd < CHANCE_DAMAGE_CARGO)
6882 {
6883 DamageItemInCargo(dmg);
6884 }
6885 else if (rnd < (chances - CHANCE_DAMAGE_NOTHING))
6886 {
6888 }
6889 }
6890 else
6891 {
6892 chances = CHANCE_DAMAGE_ATTACHMENT + CHANCE_DAMAGE_NOTHING;
6893 rnd = Math.RandomInt(0,chances);
6894
6895 if (rnd < CHANCE_DAMAGE_ATTACHMENT)
6896 {
6898 }
6899 }
6900 }
6901 }
6902
6903 bool DamageItemInCargo(float damage)
6904 {
6905 if (GetInventory().GetCargo())
6906 {
6907 int item_count = GetInventory().GetCargo().GetItemCount();
6908 if (item_count > 0)
6909 {
6910 int random_pick = Math.RandomInt(0, item_count);
6911 ItemBase item = ItemBase.Cast(GetInventory().GetCargo().GetItem(random_pick));
6912 if (!item.IsExplosive())
6913 {
6914 item.AddHealth("","",damage);
6915 return true;
6916 }
6917 }
6918 }
6919 return false;
6920 }
6921
6922 bool DamageItemAttachments(float damage)
6923 {
6924 int attachment_count = GetInventory().AttachmentCount();
6925 if (attachment_count > 0)
6926 {
6927 int random_pick = Math.RandomInt(0, attachment_count);
6928 ItemBase attachment = ItemBase.Cast(GetInventory().GetAttachmentFromIndex(random_pick));
6929 if (!attachment.IsExplosive())
6930 {
6931 attachment.AddHealth("","",damage);
6932 return true;
6933 }
6934 }
6935 return false;
6936 }
6937
6938 override bool IsSplitable()
6939 {
6940 return m_CanThisBeSplit;
6941 }
6942 //----------------
6943 override bool CanBeSplit()
6944 {
6945 if (IsSplitable() && (GetQuantity() > 1))
6946 return GetInventory().CanRemoveEntity();
6947
6948 return false;
6949 }
6950
6951 protected bool ShouldSplitQuantity(float quantity)
6952 {
6953 // don't call 'CanBeSplit' here, too strict and will introduce a freeze-crash when dismantling fence with a fireplace nearby
6954 if (!IsSplitable())
6955 return false;
6956
6957 // nothing to split?
6958 if (GetQuantity() <= 1)
6959 return false;
6960
6961 // check if we should re-use the item instead of creating a new copy?
6962 // implicit cast to int, if 'IsSplitable' returns true, these values are assumed ints
6963 int delta = GetQuantity() - quantity;
6964 if (delta == 0)
6965 return false;
6966
6967 // valid to split
6968 return true;
6969 }
6970
6971 override void SplitIntoStackMaxClient(EntityAI destination_entity, int slot_id )
6972 {
6973 if (GetGame().IsClient())
6974 {
6975 if (ScriptInputUserData.CanStoreInputUserData())
6976 {
6977 ScriptInputUserData ctx = new ScriptInputUserData;
6979 ctx.Write(1);
6980 ItemBase i1 = this; // @NOTE: workaround for correct serialization
6981 ctx.Write(i1);
6982 ctx.Write(destination_entity);
6983 ctx.Write(true);
6984 ctx.Write(slot_id);
6985 ctx.Send();
6986 }
6987 }
6988 else if (!GetGame().IsMultiplayer())
6989 {
6990 SplitIntoStackMax(destination_entity, slot_id, PlayerBase.Cast(GetGame().GetPlayer()));
6991 }
6992 }
6993
6994 void SplitIntoStackMax(EntityAI destination_entity, int slot_id, PlayerBase player)
6995 {
6996 float split_quantity_new;
6997 ItemBase new_item;
6998 float quantity = GetQuantity();
6999 float stack_max = GetTargetQuantityMax(slot_id);
7000 InventoryLocation loc = new InventoryLocation;
7001
7002 if (destination_entity && slot_id != -1 && InventorySlots.IsSlotIdValid(slot_id))
7003 {
7004 if (stack_max <= GetQuantity())
7005 split_quantity_new = stack_max;
7006 else
7007 split_quantity_new = GetQuantity();
7008
7009 if (ShouldSplitQuantity(split_quantity_new))
7010 {
7011 new_item = ItemBase.Cast(destination_entity.GetInventory().CreateAttachmentEx(this.GetType(), slot_id));
7012 if (new_item)
7013 {
7014 new_item.SetResultOfSplit(true);
7015 MiscGameplayFunctions.TransferItemProperties(this, new_item);
7016 AddQuantity(-split_quantity_new, false, true);
7017 new_item.SetQuantity(split_quantity_new, false, true);
7018 }
7019 }
7020 }
7021 else if (destination_entity && slot_id == -1)
7022 {
7023 if (quantity > stack_max)
7024 split_quantity_new = stack_max;
7025 else
7026 split_quantity_new = quantity;
7027
7028 if (ShouldSplitQuantity(split_quantity_new))
7029 {
7030 if (destination_entity.GetInventory().FindFreeLocationFor(this, FindInventoryLocationType.ANY, loc))
7031 {
7032 Object o = destination_entity.GetInventory().LocationCreateEntity(loc, GetType(), ECE_IN_INVENTORY, RF_DEFAULT);
7033 new_item = ItemBase.Cast(o);
7034 }
7035
7036 if (new_item)
7037 {
7038 new_item.SetResultOfSplit(true);
7039 MiscGameplayFunctions.TransferItemProperties(this, new_item);
7040 AddQuantity(-split_quantity_new, false, true);
7041 new_item.SetQuantity(split_quantity_new, false, true);
7042 }
7043 }
7044 }
7045 else
7046 {
7047 if (stack_max != 0)
7048 {
7049 if (stack_max < GetQuantity())
7050 {
7051 split_quantity_new = GetQuantity() - stack_max;
7052 }
7053
7054 if (split_quantity_new == 0)
7055 {
7056 if (!GetGame().IsMultiplayer())
7057 player.PhysicalPredictiveDropItem(this);
7058 else
7059 player.ServerDropEntity(this);
7060 return;
7061 }
7062
7063 if (ShouldSplitQuantity(split_quantity_new))
7064 {
7065 new_item = ItemBase.Cast(GetGame().CreateObjectEx(GetType(), player.GetWorldPosition(), ECE_PLACE_ON_SURFACE));
7066
7067 if (new_item)
7068 {
7069 new_item.SetResultOfSplit(true);
7070 MiscGameplayFunctions.TransferItemProperties(this, new_item);
7071 SetQuantity(split_quantity_new, false, true);
7072 new_item.SetQuantity(stack_max, false, true);
7073 new_item.PlaceOnSurface();
7074 }
7075 }
7076 }
7077 }
7078 }
7079
7080 override void SplitIntoStackMaxEx(EntityAI destination_entity, int slot_id)
7081 {
7082 float split_quantity_new;
7083 ItemBase new_item;
7084 float quantity = GetQuantity();
7085 float stack_max = GetTargetQuantityMax(slot_id);
7086 InventoryLocation loc = new InventoryLocation;
7087
7088 if (destination_entity && slot_id != -1 && InventorySlots.IsSlotIdValid(slot_id))
7089 {
7090 if (stack_max <= GetQuantity())
7091 split_quantity_new = stack_max;
7092 else
7093 split_quantity_new = GetQuantity();
7094
7095 if (ShouldSplitQuantity(split_quantity_new))
7096 {
7097 new_item = ItemBase.Cast(destination_entity.GetInventory().CreateAttachmentEx(this.GetType(), slot_id));
7098 if (new_item)
7099 {
7100 new_item.SetResultOfSplit(true);
7101 MiscGameplayFunctions.TransferItemProperties(this, new_item);
7102 AddQuantity(-split_quantity_new, false, true);
7103 new_item.SetQuantity(split_quantity_new, false, true);
7104 }
7105 }
7106 }
7107 else if (destination_entity && slot_id == -1)
7108 {
7109 if (quantity > stack_max)
7110 split_quantity_new = stack_max;
7111 else
7112 split_quantity_new = quantity;
7113
7114 if (ShouldSplitQuantity(split_quantity_new))
7115 {
7116 if (destination_entity.GetInventory().FindFreeLocationFor(this, FindInventoryLocationType.ANY, loc))
7117 {
7118 Object o = destination_entity.GetInventory().LocationCreateEntity(loc, GetType(), ECE_IN_INVENTORY, RF_DEFAULT);
7119 new_item = ItemBase.Cast(o);
7120 }
7121
7122 if (new_item)
7123 {
7124 new_item.SetResultOfSplit(true);
7125 MiscGameplayFunctions.TransferItemProperties(this, new_item);
7126 AddQuantity(-split_quantity_new, false, true);
7127 new_item.SetQuantity(split_quantity_new, false, true);
7128 }
7129 }
7130 }
7131 else
7132 {
7133 if (stack_max != 0)
7134 {
7135 if (stack_max < GetQuantity())
7136 {
7137 split_quantity_new = GetQuantity() - stack_max;
7138 }
7139
7140 if (ShouldSplitQuantity(split_quantity_new))
7141 {
7142 new_item = ItemBase.Cast(GetGame().CreateObjectEx(GetType(),GetWorldPosition(), ECE_PLACE_ON_SURFACE));
7143
7144 if (new_item)
7145 {
7146 new_item.SetResultOfSplit(true);
7147 MiscGameplayFunctions.TransferItemProperties(this, new_item);
7148 SetQuantity(split_quantity_new, false, true);
7149 new_item.SetQuantity(stack_max, false, true);
7150 new_item.PlaceOnSurface();
7151 }
7152 }
7153 }
7154 }
7155 }
7156
7157 void SplitIntoStackMaxToInventoryLocationClient(notnull InventoryLocation dst)
7158 {
7159 if (GetGame().IsClient())
7160 {
7161 if (ScriptInputUserData.CanStoreInputUserData())
7162 {
7163 ScriptInputUserData ctx = new ScriptInputUserData;
7165 ctx.Write(4);
7166 ItemBase thiz = this; // @NOTE: workaround for correct serialization
7167 ctx.Write(thiz);
7168 dst.WriteToContext(ctx);
7169 ctx.Send();
7170 }
7171 }
7172 else if (!GetGame().IsMultiplayer())
7173 {
7175 }
7176 }
7177
7178 void SplitIntoStackMaxCargoClient(EntityAI destination_entity, int idx, int row, int col)
7179 {
7180 if (GetGame().IsClient())
7181 {
7182 if (ScriptInputUserData.CanStoreInputUserData())
7183 {
7184 ScriptInputUserData ctx = new ScriptInputUserData;
7186 ctx.Write(2);
7187 ItemBase dummy = this; // @NOTE: workaround for correct serialization
7188 ctx.Write(dummy);
7189 ctx.Write(destination_entity);
7190 ctx.Write(true);
7191 ctx.Write(idx);
7192 ctx.Write(row);
7193 ctx.Write(col);
7194 ctx.Send();
7195 }
7196 }
7197 else if (!GetGame().IsMultiplayer())
7198 {
7199 SplitIntoStackMaxCargo(destination_entity, idx, row, col);
7200 }
7201 }
7202
7203 void SplitIntoStackMaxToInventoryLocation(notnull InventoryLocation dst)
7204 {
7206 }
7207
7208 ItemBase SplitIntoStackMaxToInventoryLocationEx(notnull InventoryLocation dst)
7209 {
7210 float quantity = GetQuantity();
7211 float split_quantity_new;
7212 ItemBase new_item;
7213 if (dst.IsValid())
7214 {
7215 int slot_id = dst.GetSlot();
7216 float stack_max = GetTargetQuantityMax(slot_id);
7217
7218 if (quantity > stack_max)
7219 split_quantity_new = stack_max;
7220 else
7221 split_quantity_new = quantity;
7222
7223 if (ShouldSplitQuantity(split_quantity_new))
7224 {
7225 new_item = ItemBase.Cast(GameInventory.LocationCreateEntity(dst, this.GetType(), ECE_IN_INVENTORY, RF_DEFAULT));
7226
7227 if (new_item)
7228 {
7229 new_item.SetResultOfSplit(true);
7230 MiscGameplayFunctions.TransferItemProperties(this,new_item);
7231 AddQuantity(-split_quantity_new, false, true);
7232 new_item.SetQuantity(split_quantity_new, false, true);
7233 }
7234
7235 return new_item;
7236 }
7237 }
7238
7239 return null;
7240 }
7241
7242 void SplitIntoStackMaxCargo(EntityAI destination_entity, int idx, int row, int col)
7243 {
7244 float quantity = GetQuantity();
7245 float split_quantity_new;
7246 ItemBase new_item;
7247 if (destination_entity)
7248 {
7249 float stackable = GetTargetQuantityMax();
7250 if (quantity > stackable)
7251 split_quantity_new = stackable;
7252 else
7253 split_quantity_new = quantity;
7254
7255 if (ShouldSplitQuantity(split_quantity_new))
7256 {
7257 new_item = ItemBase.Cast(destination_entity.GetInventory().CreateEntityInCargoEx(this.GetType(), idx, row, col, false));
7258 if (new_item)
7259 {
7260 new_item.SetResultOfSplit(true);
7261 MiscGameplayFunctions.TransferItemProperties(this,new_item);
7262 AddQuantity(-split_quantity_new, false, true);
7263 new_item.SetQuantity(split_quantity_new, false, true);
7264 }
7265 }
7266 }
7267 }
7268
7269 void SplitIntoStackMaxHandsClient(PlayerBase player)
7270 {
7271 if (GetGame().IsClient())
7272 {
7273 if (ScriptInputUserData.CanStoreInputUserData())
7274 {
7275 ScriptInputUserData ctx = new ScriptInputUserData;
7277 ctx.Write(3);
7278 ItemBase i1 = this; // @NOTE: workaround for correct serialization
7279 ctx.Write(i1);
7280 ItemBase destination_entity = this;
7281 ctx.Write(destination_entity);
7282 ctx.Write(true);
7283 ctx.Write(0);
7284 ctx.Send();
7285 }
7286 }
7287 else if (!GetGame().IsMultiplayer())
7288 {
7289 SplitIntoStackMaxHands(player);
7290 }
7291 }
7292
7293 void SplitIntoStackMaxHands(PlayerBase player)
7294 {
7295 float quantity = GetQuantity();
7296 float split_quantity_new;
7297 ref ItemBase new_item;
7298 if (player)
7299 {
7300 float stackable = GetTargetQuantityMax();
7301 if (quantity > stackable)
7302 split_quantity_new = stackable;
7303 else
7304 split_quantity_new = quantity;
7305
7306 if (ShouldSplitQuantity(split_quantity_new))
7307 {
7308 EntityAI in_hands = player.GetHumanInventory().CreateInHands(this.GetType());
7309 new_item = ItemBase.Cast(in_hands);
7310 if (new_item)
7311 {
7312 new_item.SetResultOfSplit(true);
7313 MiscGameplayFunctions.TransferItemProperties(this,new_item);
7314 AddQuantity(-split_quantity_new, false, true);
7315 new_item.SetQuantity(split_quantity_new, false, true);
7316 }
7317 }
7318 }
7319 }
7320
7321 void SplitItemToInventoryLocation(notnull InventoryLocation dst)
7322 {
7323 float quantity = GetQuantity();
7324 float split_quantity_new = Math.Floor(quantity * 0.5);
7325
7326 if (!ShouldSplitQuantity(split_quantity_new))
7327 return;
7328
7329 ItemBase new_item = ItemBase.Cast(GameInventory.LocationCreateEntity(dst, GetType(), ECE_IN_INVENTORY, RF_DEFAULT));
7330
7331 if (new_item)
7332 {
7333 if (new_item.GetQuantityMax() < split_quantity_new)
7334 {
7335 split_quantity_new = new_item.GetQuantityMax();
7336 }
7337
7338 new_item.SetResultOfSplit(true);
7339 MiscGameplayFunctions.TransferItemProperties(this, new_item);
7340
7341 if (dst.IsValid() && dst.GetType() == InventoryLocationType.ATTACHMENT && split_quantity_new > 1)
7342 {
7343 AddQuantity(-1, false, true);
7344 new_item.SetQuantity(1, false, true);
7345 }
7346 else
7347 {
7348 AddQuantity(-split_quantity_new, false, true);
7349 new_item.SetQuantity(split_quantity_new, false, true);
7350 }
7351 }
7352 }
7353
7354 void SplitItem(PlayerBase player)
7355 {
7356 float quantity = GetQuantity();
7357 float split_quantity_new = Math.Floor(quantity / 2);
7358
7359 if (!ShouldSplitQuantity(split_quantity_new))
7360 return;
7361
7362 InventoryLocation invloc = new InventoryLocation;
7363 bool found = player.GetInventory().FindFirstFreeLocationForNewEntity(GetType(), FindInventoryLocationType.ATTACHMENT, invloc);
7364
7365 ItemBase new_item;
7366 new_item = player.CreateCopyOfItemInInventoryOrGroundEx(this, true);
7367
7368 if (new_item)
7369 {
7370 if (new_item.GetQuantityMax() < split_quantity_new)
7371 {
7372 split_quantity_new = new_item.GetQuantityMax();
7373 }
7374 if (found && invloc.IsValid() && invloc.GetType() == InventoryLocationType.ATTACHMENT && split_quantity_new > 1)
7375 {
7376 AddQuantity(-1, false, true);
7377 new_item.SetQuantity(1, false, true);
7378 }
7379 else if (split_quantity_new > 1)
7380 {
7381 AddQuantity(-split_quantity_new, false, true);
7382 new_item.SetQuantity(split_quantity_new, false, true);
7383 }
7384 }
7385 }
7386
7388 void OnQuantityChanged(float delta)
7389 {
7390 SetWeightDirty();
7391 ItemBase parent = ItemBase.Cast(GetHierarchyParent());
7392
7393 if (parent)
7394 parent.OnAttachmentQuantityChangedEx(this, delta);
7395
7396 if (IsLiquidContainer())
7397 {
7398 if (GetQuantityNormalized() <= 0.0)
7399 {
7401 }
7402 else if (GetLiquidType() == LIQUID_NONE)
7403 {
7404 ErrorEx("Undefined liquid type quantity changed, please define liquid type first! Using init value.",ErrorExSeverity.INFO);
7406 }
7407 }
7408
7409 }
7410
7413 {
7414 // insert code here
7415 }
7416
7418 void OnAttachmentQuantityChangedEx(ItemBase item , float delta)
7419 {
7421 }
7422
7423 override void EEHealthLevelChanged(int oldLevel, int newLevel, string zone)
7424 {
7425 super.EEHealthLevelChanged(oldLevel,newLevel,zone);
7426
7427 if (GetGame().IsServer())
7428 {
7429 if (newLevel == GameConstants.STATE_RUINED)
7430 {
7432 EntityAI parent = GetHierarchyParent();
7433 if (parent && parent.IsFireplace())
7434 {
7435 CargoBase cargo = GetInventory().GetCargo();
7436 if (cargo)
7437 {
7438 for (int i = 0; i < cargo.GetItemCount(); ++i)
7439 {
7440 parent.GetInventory().TakeEntityToInventory(InventoryMode.SERVER, FindInventoryLocationType.CARGO, cargo.GetItem(i));
7441 }
7442 }
7443 }
7444 }
7445
7446 if (IsResultOfSplit())
7447 {
7448 // reset the splitting result flag, return to normal item behavior
7449 SetResultOfSplit(false);
7450 return;
7451 }
7452
7453 if (m_Cleanness != 0 && oldLevel < newLevel && newLevel != 0)
7454 {
7455 SetCleanness(0);//unclean the item upon damage dealt
7456 }
7457 }
7458 }
7459
7460 // just the split? TODO: verify
7461 override void OnRightClick()
7462 {
7463 super.OnRightClick();
7464
7465 if (CanBeSplit() && !GetDayZGame().IsLeftCtrlDown() && !GetGame().GetPlayer().GetInventory().HasInventoryReservation(this,null))
7466 {
7467 if (GetGame().IsClient())
7468 {
7469 if (ScriptInputUserData.CanStoreInputUserData())
7470 {
7471 EntityAI root = GetHierarchyRoot();
7472 Man playerOwner = GetHierarchyRootPlayer();
7473 InventoryLocation dst = new InventoryLocation;
7474
7475 // 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
7476 if (!playerOwner && root && root == this)
7477 {
7479 }
7480 else
7481 {
7482 // 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
7483 GetInventory().GetCurrentInventoryLocation(dst);
7484 if (!dst.GetParent() || dst.GetParent() && !dst.GetParent().GetInventory().FindFreeLocationFor(this, FindInventoryLocationType.CARGO, dst))
7485 {
7486 PlayerBase player = PlayerBase.Cast(GetGame().GetPlayer());
7487 if (!player.GetInventory().FindFreeLocationFor(this, FindInventoryLocationType.CARGO, dst) || !playerOwner)
7488 {
7490 }
7491 else
7492 {
7493 dst.SetCargo(dst.GetParent(), this, dst.GetIdx(), dst.GetRow(), dst.GetCol(), dst.GetFlip());
7494 /* hacky solution to check reservation of "this" item instead of null since the gamecode is checking null against null and returning reservation=true incorrectly
7495 this shouldnt cause issues within this scope*/
7496 if (GetGame().GetPlayer().GetInventory().HasInventoryReservation(this, dst))
7497 {
7499 }
7500 else
7501 {
7502 GetGame().GetPlayer().GetInventory().AddInventoryReservationEx(null, dst, GameInventory.c_InventoryReservationTimeoutShortMS);
7503 }
7504 }
7505 }
7506 }
7507
7508 ScriptInputUserData ctx = new ScriptInputUserData;
7510 ctx.Write(4);
7511 ItemBase thiz = this; // @NOTE: workaround for correct serialization
7512 ctx.Write(thiz);
7513 dst.WriteToContext(ctx);
7514 ctx.Write(true); // dummy
7515 ctx.Send();
7516 }
7517 }
7518 else if (!GetGame().IsMultiplayer())
7519 {
7520 SplitItem(PlayerBase.Cast(GetGame().GetPlayer()));
7521 }
7522 }
7523 }
7524
7525 protected void SetInventoryLocationToVicinityOrCurrent(EntityAI root, inout InventoryLocation dst)
7526 {
7527 if (root)
7528 {
7529 vector m4[4];
7530 root.GetTransform(m4);
7531 dst.SetGround(this, m4);
7532 }
7533 else
7534 {
7535 GetInventory().GetCurrentInventoryLocation(dst);
7536 }
7537 }
7538
7539 override bool CanBeCombined(EntityAI other_item, bool reservation_check = true, bool stack_max_limit = false)
7540 {
7541 //TODO: delete check zero quantity check after fix double posts hands fsm events
7542 if (!other_item || GetType() != other_item.GetType() || (IsFullQuantity() && other_item.GetQuantity() > 0) || other_item == this)
7543 return false;
7544
7545 if (GetHealthLevel() == GameConstants.STATE_RUINED || other_item.GetHealthLevel() == GameConstants.STATE_RUINED)
7546 return false;
7547
7548 //can_this_be_combined = ConfigGetBool("canBeSplit");
7550 return false;
7551
7552
7553 Magazine mag = Magazine.Cast(this);
7554 if (mag)
7555 {
7556 if (mag.GetAmmoCount() >= mag.GetAmmoMax())
7557 return false;
7558
7559 if (stack_max_limit)
7560 {
7561 Magazine other_mag = Magazine.Cast(other_item);
7562 if (other_item)
7563 {
7564 if (mag.GetAmmoCount() + other_mag.GetAmmoCount() > mag.GetAmmoMax())
7565 return false;
7566 }
7567
7568 }
7569 }
7570 else
7571 {
7572 //TODO: delete check zero quantity check after fix double posts hands fsm events
7573 if (GetQuantity() >= GetQuantityMax() && other_item.GetQuantity() > 0 )
7574 return false;
7575
7576 if (stack_max_limit && (GetQuantity() + other_item.GetQuantity() > GetQuantityMax()))
7577 return false;
7578 }
7579
7580 PlayerBase player = null;
7581 if (CastTo(player, GetHierarchyRootPlayer())) //false when attached to player's attachment slot
7582 {
7583 if (player.GetInventory().HasAttachment(this))
7584 return false;
7585
7586 if (player.IsItemsToDelete())
7587 return false;
7588 }
7589
7590 if (reservation_check && (GetInventory().HasInventoryReservation(this, null) || other_item.GetInventory().HasInventoryReservation(other_item, null)))
7591 return false;
7592
7593 int slotID;
7594 string slotName;
7595 if (GetInventory().GetCurrentAttachmentSlotInfo(slotID,slotName) && GetHierarchyParent().GetInventory().GetSlotLock(slotID))
7596 return false;
7597
7598 return true;
7599 }
7600
7601 bool IsCombineAll(ItemBase other_item, bool use_stack_max = false)
7602 {
7603 return ComputeQuantityUsed(other_item, use_stack_max) == other_item.GetQuantity();
7604 }
7605
7606 bool IsResultOfSplit()
7607 {
7608 return m_IsResultOfSplit;
7609 }
7610
7611 void SetResultOfSplit(bool value)
7612 {
7613 m_IsResultOfSplit = value;
7614 }
7615
7616 int ComputeQuantityUsed(ItemBase other_item, bool use_stack_max = true)
7617 {
7618 return ComputeQuantityUsedEx(other_item, use_stack_max);
7619 }
7620
7621 float ComputeQuantityUsedEx(ItemBase other_item, bool use_stack_max = true)
7622 {
7623 float other_item_quantity = other_item.GetQuantity();
7624 float this_free_space;
7625
7626 float stack_max = GetQuantityMax();
7627
7628 this_free_space = stack_max - GetQuantity();
7629
7630 if (other_item_quantity > this_free_space)
7631 {
7632 return this_free_space;
7633 }
7634 else
7635 {
7636 return other_item_quantity;
7637 }
7638 }
7639
7640 override void CombineItemsEx(EntityAI entity2, bool use_stack_max = true)
7641 {
7642 CombineItems(ItemBase.Cast(entity2),use_stack_max);
7643 }
7644
7645 void CombineItems(ItemBase other_item, bool use_stack_max = true)
7646 {
7647 if (!CanBeCombined(other_item, false))
7648 return;
7649
7650 if (!IsMagazine() && other_item)
7651 {
7652 float quantity_used = ComputeQuantityUsedEx(other_item,use_stack_max);
7653 if (quantity_used != 0)
7654 {
7655 float hp1 = GetHealth01("","");
7656 float hp2 = other_item.GetHealth01("","");
7657 float hpResult = ((hp1*GetQuantity()) + (hp2*quantity_used));
7658 hpResult = hpResult / (GetQuantity() + quantity_used);
7659
7660 hpResult *= GetMaxHealth();
7661 Math.Round(hpResult);
7662 SetHealth("", "Health", hpResult);
7663
7664 AddQuantity(quantity_used);
7665 other_item.AddQuantity(-quantity_used);
7666 }
7667 }
7668 OnCombine(other_item);
7669 }
7670
7671 void OnCombine(ItemBase other_item)
7672 {
7673 #ifdef SERVER
7674 if (!GetHierarchyRootPlayer() && GetHierarchyParent())
7675 GetHierarchyParent().IncreaseLifetimeUp();
7676 #endif
7677 };
7678
7679 void GetRecipesActions(Man player, out TSelectableActionInfoArray outputList)
7680 {
7681 PlayerBase p = PlayerBase.Cast(player);
7682
7683 array<int> recipesIds = p.m_Recipes;
7684 PluginRecipesManager moduleRecipesManager = PluginRecipesManager.Cast(GetPlugin(PluginRecipesManager));
7685 if (moduleRecipesManager)
7686 {
7687 EntityAI itemInHands = player.GetHumanInventory().GetEntityInHands();
7688 moduleRecipesManager.GetValidRecipes(ItemBase.Cast(this), ItemBase.Cast(itemInHands), recipesIds, p);
7689 }
7690
7691 for (int i = 0;i < recipesIds.Count(); i++)
7692 {
7693 int key = recipesIds.Get(i);
7694 string recipeName = moduleRecipesManager.GetRecipeName(key);
7695 outputList.Insert(new TSelectableActionInfo(SAT_CRAFTING, key, recipeName));
7696 }
7697 }
7698
7699 // -------------------------------------------------------------------------
7700 override void GetDebugActions(out TSelectableActionInfoArrayEx outputList)
7701 {
7702 super.GetDebugActions(outputList);
7703
7704 //quantity
7705 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.ADD_QUANTITY, "Quantity +20%", FadeColors.LIGHT_GREY));
7706 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.REMOVE_QUANTITY, "Quantity -20%", FadeColors.LIGHT_GREY));
7707 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SET_QUANTITY_0, "Set Quantity 0", FadeColors.LIGHT_GREY));
7708 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SET_MAX_QUANTITY, "Set Quantity Max", FadeColors.LIGHT_GREY));
7709 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SEPARATOR, "___________________________", FadeColors.RED));
7710
7711 //health
7712 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.ADD_HEALTH, "Health +20%", FadeColors.LIGHT_GREY));
7713 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.REMOVE_HEALTH, "Health -20%", FadeColors.LIGHT_GREY));
7714 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.DESTROY_HEALTH, "Health 0", FadeColors.LIGHT_GREY));
7715 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SEPARATOR, "___________________________", FadeColors.RED));
7716 //temperature
7717 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.ADD_TEMPERATURE, "Temperature +20", FadeColors.LIGHT_GREY));
7718 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.REMOVE_TEMPERATURE, "Temperature -20", FadeColors.LIGHT_GREY));
7719 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.FLIP_FROZEN, "Toggle Frozen", FadeColors.LIGHT_GREY));
7720 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SEPARATOR, "___________________________", FadeColors.RED));
7721
7722 //wet
7723 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.ADD_WETNESS, "Wetness +20", FadeColors.LIGHT_GREY));
7724 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.REMOVE_WETNESS, "Wetness -20", FadeColors.LIGHT_GREY));
7725 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SEPARATOR, "___________________________", FadeColors.RED));
7726
7727 //liquidtype
7728 if (IsLiquidContainer())
7729 {
7730 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.LIQUIDTYPE_UP, "LiquidType Next", FadeColors.LIGHT_GREY));
7731 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.LIQUIDTYPE_DOWN, "LiquidType Previous", FadeColors.LIGHT_GREY));
7732 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SEPARATOR, "___________________________", FadeColors.RED));
7733 }
7734
7735 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.MAKE_SPECIAL, "Make Special", FadeColors.LIGHT_GREY));
7736 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SEPARATOR, "___________________________", FadeColors.RED));
7737
7738 // watch
7739 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.WATCH_ITEM, "Watch (CTRL-Z)", FadeColors.LIGHT_GREY));
7740 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.WATCH_PLAYER, "Watch Player", FadeColors.LIGHT_GREY));
7741 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SEPARATOR, "___________________________", FadeColors.RED));
7742
7743 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.DELETE, "Delete", FadeColors.RED));
7744
7745 InventoryLocation loc = new InventoryLocation();
7746 GetInventory().GetCurrentInventoryLocation(loc);
7747 if (!loc || loc.GetType() == InventoryLocationType.GROUND)
7748 {
7749 if (Gizmo_IsSupported())
7750 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.GIZMO_OBJECT, "Gizmo Object", FadeColors.LIGHT_GREY));
7751 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.GIZMO_PHYSICS, "Gizmo Physics (SP Only)", FadeColors.LIGHT_GREY)); // intentionally allowed for testing physics desync
7752 }
7753
7754 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SEPARATOR, "___________________________", FadeColors.RED));
7755 }
7756
7757 // -------------------------------------------------------------------------
7758 // -------------------------------------------------------------------------
7759 // -------------------------------------------------------------------------
7760 override bool OnAction(int action_id, Man player, ParamsReadContext ctx)
7761 {
7762 super.OnAction(action_id, player, ctx);
7763
7764 if (GetGame().IsClient() || !GetGame().IsMultiplayer())
7765 {
7766 switch (action_id)
7767 {
7768 case EActions.GIZMO_OBJECT:
7769 GetGame().GizmoSelectObject(this);
7770 return true;
7771 case EActions.GIZMO_PHYSICS:
7772 GetGame().GizmoSelectPhysics(GetPhysics());
7773 return true;
7774 }
7775 }
7776
7777 if (GetGame().IsServer())
7778 {
7779 switch (action_id)
7780 {
7781 case EActions.DELETE:
7782 Delete();
7783 return true;
7784 }
7785 }
7786
7787 if (action_id >= EActions.RECIPES_RANGE_START && action_id < EActions.RECIPES_RANGE_END)
7788 {
7789 PluginRecipesManager plugin_recipes_manager = PluginRecipesManager.Cast(GetPlugin(PluginRecipesManager));
7790 int idWithoutOffset = action_id - EActions.RECIPES_RANGE_START;
7791 PlayerBase p = PlayerBase.Cast(player);
7792 if (EActions.RECIPES_RANGE_START < 1000)
7793 {
7794 float anim_length = plugin_recipes_manager.GetRecipeLengthInSecs(idWithoutOffset);
7795 float specialty_weight = plugin_recipes_manager.GetRecipeSpecialty(idWithoutOffset);
7796 }
7797 }
7798 #ifndef SERVER
7799 else if (action_id == EActions.WATCH_PLAYER)
7800 {
7801 PluginDeveloper.SetDeveloperItemClientEx(player);
7802 }
7803 #endif
7804 if (GetGame().IsServer())
7805 {
7806 if (action_id >= EActions.DEBUG_ITEM_WATCH_BUTTON_RANGE_START && action_id < EActions.DEBUG_ITEM_WATCH_BUTTON_RANGE_END)
7807 {
7808 int id = action_id - EActions.DEBUG_ITEM_WATCH_BUTTON_RANGE_START;
7809 OnDebugButtonPressServer(id + 1);
7810 }
7811
7812 else if (action_id >= EActions.DEBUG_AGENTS_RANGE_INJECT_START && action_id < EActions.DEBUG_AGENTS_RANGE_INJECT_END)
7813 {
7814 int agent_id = action_id - EActions.DEBUG_AGENTS_RANGE_INJECT_START;
7815 InsertAgent(agent_id,100);
7816 }
7817
7818 else if (action_id >= EActions.DEBUG_AGENTS_RANGE_REMOVE_START && action_id < EActions.DEBUG_AGENTS_RANGE_REMOVE_END)
7819 {
7820 int agent_id2 = action_id - EActions.DEBUG_AGENTS_RANGE_REMOVE_START;
7821 RemoveAgent(agent_id2);
7822 }
7823
7824 else if (action_id == EActions.ADD_QUANTITY)
7825 {
7826 if (IsMagazine())
7827 {
7828 Magazine mag = Magazine.Cast(this);
7829 mag.ServerSetAmmoCount(mag.GetAmmoCount() + mag.GetAmmoMax() * 0.2);
7830 }
7831 else
7832 {
7833 AddQuantity(GetQuantityMax() * 0.2);
7834 }
7835
7836 if (m_EM)
7837 {
7838 m_EM.AddEnergy(m_EM.GetEnergyMax() * 0.2);
7839 }
7840 //PrintVariables();
7841 }
7842
7843 else if (action_id == EActions.REMOVE_QUANTITY) //Quantity -20%
7844 {
7845 if (IsMagazine())
7846 {
7847 Magazine mag2 = Magazine.Cast(this);
7848 mag2.ServerSetAmmoCount(mag2.GetAmmoCount() - mag2.GetAmmoMax() * 0.2);
7849 }
7850 else
7851 {
7852 AddQuantity(- GetQuantityMax() * 0.2);
7853 }
7854 if (m_EM)
7855 {
7856 m_EM.AddEnergy(- m_EM.GetEnergyMax() * 0.2);
7857 }
7858 //PrintVariables();
7859 }
7860
7861 else if (action_id == EActions.SET_QUANTITY_0) //SetMaxQuantity
7862 {
7863 SetQuantity(0);
7864
7865 if (m_EM)
7866 {
7867 m_EM.SetEnergy(0);
7868 }
7869 }
7870
7871 else if (action_id == EActions.SET_MAX_QUANTITY) //SetMaxQuantity
7872 {
7874
7875 if (m_EM)
7876 {
7877 m_EM.SetEnergy(m_EM.GetEnergyMax());
7878 }
7879 }
7880
7881 else if (action_id == EActions.ADD_HEALTH)
7882 {
7883 AddHealth("","",GetMaxHealth("","Health")/5);
7884 }
7885 else if (action_id == EActions.REMOVE_HEALTH)
7886 {
7887 AddHealth("","",-GetMaxHealth("","Health")/5);
7888 }
7889 else if (action_id == EActions.DESTROY_HEALTH)
7890 {
7891 SetHealth01("","",0);
7892 }
7893 else if (action_id == EActions.WATCH_ITEM)
7894 {
7896 mid.RegisterDebugItem(ItemBase.Cast(this), PlayerBase.Cast(player));
7897 #ifdef DEVELOPER
7898 SetDebugDeveloper_item(this);
7899 #endif
7900 }
7901
7902 else if (action_id == EActions.ADD_TEMPERATURE)
7903 {
7904 AddTemperature(20);
7905 //PrintVariables();
7906 }
7907
7908 else if (action_id == EActions.REMOVE_TEMPERATURE)
7909 {
7910 AddTemperature(-20);
7911 //PrintVariables();
7912 }
7913
7914 else if (action_id == EActions.FLIP_FROZEN)
7915 {
7916 SetFrozen(!GetIsFrozen());
7917 //PrintVariables();
7918 }
7919
7920 else if (action_id == EActions.ADD_WETNESS)
7921 {
7922 AddWet(GetWetMax()/5);
7923 //PrintVariables();
7924 }
7925
7926 else if (action_id == EActions.REMOVE_WETNESS)
7927 {
7928 AddWet(-GetWetMax()/5);
7929 //PrintVariables();
7930 }
7931
7932 else if (action_id == EActions.LIQUIDTYPE_UP)
7933 {
7934 int curr_type = GetLiquidType();
7935 SetLiquidType(curr_type * 2);
7936 //AddWet(1);
7937 //PrintVariables();
7938 }
7939
7940 else if (action_id == EActions.LIQUIDTYPE_DOWN)
7941 {
7942 int curr_type2 = GetLiquidType();
7943 SetLiquidType(curr_type2 / 2);
7944 }
7945
7946 else if (action_id == EActions.MAKE_SPECIAL)
7947 {
7948 auto debugParams = DebugSpawnParams.WithPlayer(player);
7949 OnDebugSpawnEx(debugParams);
7950 }
7951
7952 }
7953
7954
7955 return false;
7956 }
7957
7958 // -------------------------------------------------------------------------
7959
7960
7963 void OnActivatedByTripWire();
7964
7966 void OnActivatedByItem(notnull ItemBase item);
7967
7968 //----------------------------------------------------------------
7969 //returns true if item is able to explode when put in fire
7970 bool CanExplodeInFire()
7971 {
7972 return false;
7973 }
7974
7975 //----------------------------------------------------------------
7976 bool CanEat()
7977 {
7978 return true;
7979 }
7980
7981 //----------------------------------------------------------------
7982 override bool IsIgnoredByConstruction()
7983 {
7984 return true;
7985 }
7986
7987 //----------------------------------------------------------------
7988 //has FoodStages in config?
7989 bool HasFoodStage()
7990 {
7991 string config_path = string.Format("CfgVehicles %1 Food FoodStages", GetType());
7992 return GetGame().ConfigIsExisting(config_path);
7993 }
7994
7996 FoodStage GetFoodStage()
7997 {
7998 return null;
7999 }
8000
8001 bool CanBeCooked()
8002 {
8003 return false;
8004 }
8005
8006 bool CanBeCookedOnStick()
8007 {
8008 return false;
8009 }
8010
8012 void RefreshAudioVisualsOnClient( CookingMethodType cooking_method, bool is_done, bool is_empty, bool is_burned );
8014
8015 //----------------------------------------------------------------
8016 bool CanRepair(ItemBase item_repair_kit)
8017 {
8018 PluginRepairing module_repairing = PluginRepairing.Cast(GetPlugin(PluginRepairing));
8019 return module_repairing.CanRepair(this, item_repair_kit);
8020 }
8021
8022 //----------------------------------------------------------------
8023 bool Repair(PlayerBase player, ItemBase item_repair_kit, float specialty_weight)
8024 {
8025 PluginRepairing module_repairing = PluginRepairing.Cast(GetPlugin(PluginRepairing));
8026 return module_repairing.Repair(player, this, item_repair_kit, specialty_weight);
8027 }
8028
8029 //----------------------------------------------------------------
8030 int GetItemSize()
8031 {
8032 /*
8033 vector v_size = this.ConfigGetVector("itemSize");
8034 int v_size_x = v_size[0];
8035 int v_size_y = v_size[1];
8036 int size = v_size_x * v_size_y;
8037 return size;
8038 */
8039
8040 return 1;
8041 }
8042
8043 //----------------------------------------------------------------
8044 //Override for allowing seemingly unallowed moves when two clients send a conflicting message simultaneously
8045 bool CanBeMovedOverride()
8046 {
8047 return m_CanBeMovedOverride;
8048 }
8049
8050 //----------------------------------------------------------------
8051 //Override for allowing seemingly unallowed moves when two clients send a conflicting message simultaneously
8052 void SetCanBeMovedOverride(bool setting)
8053 {
8054 m_CanBeMovedOverride = setting;
8055 }
8056
8057 //----------------------------------------------------------------
8065 void MessageToOwnerStatus(string text)
8066 {
8067 PlayerBase player = PlayerBase.Cast(this.GetHierarchyRootPlayer());
8068
8069 if (player)
8070 {
8071 player.MessageStatus(text);
8072 }
8073 }
8074
8075 //----------------------------------------------------------------
8083 void MessageToOwnerAction(string text)
8084 {
8085 PlayerBase player = PlayerBase.Cast(this.GetHierarchyRootPlayer());
8086
8087 if (player)
8088 {
8089 player.MessageAction(text);
8090 }
8091 }
8092
8093 //----------------------------------------------------------------
8101 void MessageToOwnerFriendly(string text)
8102 {
8103 PlayerBase player = PlayerBase.Cast(this.GetHierarchyRootPlayer());
8104
8105 if (player)
8106 {
8107 player.MessageFriendly(text);
8108 }
8109 }
8110
8111 //----------------------------------------------------------------
8119 void MessageToOwnerImportant(string text)
8120 {
8121 PlayerBase player = PlayerBase.Cast(this.GetHierarchyRootPlayer());
8122
8123 if (player)
8124 {
8125 player.MessageImportant(text);
8126 }
8127 }
8128
8129 override bool IsItemBase()
8130 {
8131 return true;
8132 }
8133
8134 // Checks if item is of questioned kind
8135 override bool KindOf(string tag)
8136 {
8137 bool found = false;
8138 string item_name = this.GetType();
8139 ref TStringArray item_tag_array = new TStringArray;
8140 GetGame().ConfigGetTextArray("cfgVehicles " + item_name + " itemInfo", item_tag_array);
8141
8142 int array_size = item_tag_array.Count();
8143 for (int i = 0; i < array_size; i++)
8144 {
8145 if (item_tag_array.Get(i) == tag)
8146 {
8147 found = true;
8148 break;
8149 }
8150 }
8151 return found;
8152 }
8153
8154
8155 override void OnRPC(PlayerIdentity sender, int rpc_type,ParamsReadContext ctx)
8156 {
8157 //Debug.Log("OnRPC called");
8158 super.OnRPC(sender, rpc_type,ctx);
8159
8160 //Play soundset for attachment locking (ActionLockAttachment.c)
8161 switch (rpc_type)
8162 {
8163 #ifndef SERVER
8164 case ERPCs.RPC_SOUND_LOCK_ATTACH:
8165 Param2<bool, string> p = new Param2<bool, string>(false, "");
8166
8167 if (!ctx.Read(p))
8168 return;
8169
8170 bool play = p.param1;
8171 string soundSet = p.param2;
8172
8173 if (play)
8174 {
8175 if (m_LockingSound)
8176 {
8178 {
8179 m_LockingSound = SEffectManager.PlaySound(soundSet, GetPosition(), 0, 0, true);
8180 }
8181 }
8182 else
8183 {
8184 m_LockingSound = SEffectManager.PlaySound(soundSet, GetPosition(), 0, 0, true);
8185 }
8186 }
8187 else
8188 {
8189 SEffectManager.DestroyEffect(m_LockingSound);
8190 }
8191
8192 break;
8193 #endif
8194
8195 }
8196
8197 if (GetWrittenNoteData())
8198 {
8199 GetWrittenNoteData().OnRPC(sender, rpc_type,ctx);
8200 }
8201 }
8202
8203 //-----------------------------
8204 // VARIABLE MANIPULATION SYSTEM
8205 //-----------------------------
8206 int NameToID(string name)
8207 {
8208 PluginVariables plugin = PluginVariables.Cast(GetPlugin(PluginVariables));
8209 return plugin.GetID(name);
8210 }
8211
8212 string IDToName(int id)
8213 {
8214 PluginVariables plugin = PluginVariables.Cast(GetPlugin(PluginVariables));
8215 return plugin.GetName(id);
8216 }
8217
8219 void OnSyncVariables(ParamsReadContext ctx)//with ID optimization
8220 {
8221 //Debug.Log("OnSyncVariables called for item: "+ ToString(this.GetType()),"varSync");
8222 //read the flags
8223 int varFlags;
8224 if (!ctx.Read(varFlags))
8225 return;
8226
8227 if (varFlags & ItemVariableFlags.FLOAT)
8228 {
8229 ReadVarsFromCTX(ctx);
8230 }
8231 }
8232
8233 override void SerializeNumericalVars(array<float> floats_out)
8234 {
8235 //some variables handled on EntityAI level already!
8236 super.SerializeNumericalVars(floats_out);
8237
8238 // the order of serialization must be the same as the order of de-serialization
8239 //--------------------------------------------
8240 if (IsVariableSet(VARIABLE_QUANTITY))
8241 {
8242 floats_out.Insert(m_VarQuantity);
8243 }
8244 //--------------------------------------------
8245 if (IsVariableSet(VARIABLE_WET))
8246 {
8247 floats_out.Insert(m_VarWet);
8248 }
8249 //--------------------------------------------
8250 if (IsVariableSet(VARIABLE_LIQUIDTYPE))
8251 {
8252 floats_out.Insert(m_VarLiquidType);
8253 }
8254 //--------------------------------------------
8255 if (IsVariableSet(VARIABLE_COLOR))
8256 {
8257 floats_out.Insert(m_ColorComponentR);
8258 floats_out.Insert(m_ColorComponentG);
8259 floats_out.Insert(m_ColorComponentB);
8260 floats_out.Insert(m_ColorComponentA);
8261 }
8262 //--------------------------------------------
8263 if (IsVariableSet(VARIABLE_CLEANNESS))
8264 {
8265 floats_out.Insert(m_Cleanness);
8266 }
8267 }
8268
8269 override void DeSerializeNumericalVars(array<float> floats)
8270 {
8271 //some variables handled on EntityAI level already!
8272 super.DeSerializeNumericalVars(floats);
8273
8274 // the order of serialization must be the same as the order of de-serialization
8275 int index = 0;
8276 int mask = Math.Round(floats.Get(index));
8277
8278 index++;
8279 //--------------------------------------------
8280 if (mask & VARIABLE_QUANTITY)
8281 {
8282 if (m_IsStoreLoad)
8283 {
8284 SetStoreLoadedQuantity(floats.Get(index));
8285 }
8286 else
8287 {
8288 float quantity = floats.Get(index);
8289 SetQuantity(quantity, true, false, false, false);
8290 }
8291 index++;
8292 }
8293 //--------------------------------------------
8294 if (mask & VARIABLE_WET)
8295 {
8296 float wet = floats.Get(index);
8297 SetWet(wet);
8298 index++;
8299 }
8300 //--------------------------------------------
8301 if (mask & VARIABLE_LIQUIDTYPE)
8302 {
8303 int liquidtype = Math.Round(floats.Get(index));
8304 SetLiquidType(liquidtype);
8305 index++;
8306 }
8307 //--------------------------------------------
8308 if (mask & VARIABLE_COLOR)
8309 {
8310 m_ColorComponentR = Math.Round(floats.Get(index));
8311 index++;
8312 m_ColorComponentG = Math.Round(floats.Get(index));
8313 index++;
8314 m_ColorComponentB = Math.Round(floats.Get(index));
8315 index++;
8316 m_ColorComponentA = Math.Round(floats.Get(index));
8317 index++;
8318 }
8319 //--------------------------------------------
8320 if (mask & VARIABLE_CLEANNESS)
8321 {
8322 int cleanness = Math.Round(floats.Get(index));
8323 SetCleanness(cleanness);
8324 index++;
8325 }
8326 }
8327
8328 override void WriteVarsToCTX(ParamsWriteContext ctx)
8329 {
8330 super.WriteVarsToCTX(ctx);
8331
8332 //--------------------------------------------
8333 if (IsVariableSet(VARIABLE_QUANTITY))
8334 {
8335 ctx.Write(GetQuantity());
8336 }
8337 //--------------------------------------------
8338 if (IsVariableSet(VARIABLE_WET))
8339 {
8340 ctx.Write(GetWet());
8341 }
8342 //--------------------------------------------
8343 if (IsVariableSet(VARIABLE_LIQUIDTYPE))
8344 {
8345 ctx.Write(GetLiquidType());
8346 }
8347 //--------------------------------------------
8348 if (IsVariableSet(VARIABLE_COLOR))
8349 {
8350 int r,g,b,a;
8351 GetColor(r,g,b,a);
8352 ctx.Write(r);
8353 ctx.Write(g);
8354 ctx.Write(b);
8355 ctx.Write(a);
8356 }
8357 //--------------------------------------------
8358 if (IsVariableSet(VARIABLE_CLEANNESS))
8359 {
8360 ctx.Write(GetCleanness());
8361 }
8362 }
8363
8364 override bool ReadVarsFromCTX(ParamsReadContext ctx, int version = -1)//with ID optimization
8365 {
8366 if (!super.ReadVarsFromCTX(ctx,version))
8367 return false;
8368
8369 int intValue;
8370 float value;
8371
8372 if (version < 140)
8373 {
8374 if (!ctx.Read(intValue))
8375 return false;
8376
8377 m_VariablesMask = intValue;
8378 }
8379
8380 if (m_VariablesMask & VARIABLE_QUANTITY)
8381 {
8382 if (!ctx.Read(value))
8383 return false;
8384
8385 if (IsStoreLoad())
8386 {
8388 }
8389 else
8390 {
8391 SetQuantity(value, true, false, false, false);
8392 }
8393 }
8394 //--------------------------------------------
8395 if (version < 140)
8396 {
8397 if (m_VariablesMask & VARIABLE_TEMPERATURE)
8398 {
8399 if (!ctx.Read(value))
8400 return false;
8401 SetTemperatureDirect(value);
8402 }
8403 }
8404 //--------------------------------------------
8405 if (m_VariablesMask & VARIABLE_WET)
8406 {
8407 if (!ctx.Read(value))
8408 return false;
8409 SetWet(value);
8410 }
8411 //--------------------------------------------
8412 if (m_VariablesMask & VARIABLE_LIQUIDTYPE)
8413 {
8414 if (!ctx.Read(intValue))
8415 return false;
8416 SetLiquidType(intValue);
8417 }
8418 //--------------------------------------------
8419 if (m_VariablesMask & VARIABLE_COLOR)
8420 {
8421 int r,g,b,a;
8422 if (!ctx.Read(r))
8423 return false;
8424 if (!ctx.Read(g))
8425 return false;
8426 if (!ctx.Read(b))
8427 return false;
8428 if (!ctx.Read(a))
8429 return false;
8430
8431 SetColor(r,g,b,a);
8432 }
8433 //--------------------------------------------
8434 if (m_VariablesMask & VARIABLE_CLEANNESS)
8435 {
8436 if (!ctx.Read(intValue))
8437 return false;
8438 SetCleanness(intValue);
8439 }
8440 //--------------------------------------------
8441 if (version >= 138 && version < 140)
8442 {
8443 if (m_VariablesMask & VARIABLE_TEMPERATURE)
8444 {
8445 if (!ctx.Read(intValue))
8446 return false;
8447 SetFrozen(intValue);
8448 }
8449 }
8450
8451 return true;
8452 }
8453
8454 //----------------------------------------------------------------
8455 override bool OnStoreLoad(ParamsReadContext ctx, int version)
8456 {
8457 m_IsStoreLoad = true;
8459 {
8460 m_FixDamageSystemInit = true;
8461 }
8462
8463 if (!super.OnStoreLoad(ctx, version))
8464 {
8465 m_IsStoreLoad = false;
8466 return false;
8467 }
8468
8469 if (version >= 114)
8470 {
8471 bool hasQuickBarIndexSaved;
8472
8473 if (!ctx.Read(hasQuickBarIndexSaved))
8474 {
8475 m_IsStoreLoad = false;
8476 return false;
8477 }
8478
8479 if (hasQuickBarIndexSaved)
8480 {
8481 int itmQBIndex;
8482
8483 //Load quickbar item bind
8484 if (!ctx.Read(itmQBIndex))
8485 {
8486 m_IsStoreLoad = false;
8487 return false;
8488 }
8489
8490 PlayerBase parentPlayer = PlayerBase.Cast(GetHierarchyRootPlayer());
8491 if (itmQBIndex != -1 && parentPlayer)
8492 parentPlayer.SetLoadedQuickBarItemBind(this, itmQBIndex);
8493 }
8494 }
8495 else
8496 {
8497 // Backup of how it used to be
8498 PlayerBase player;
8499 int itemQBIndex;
8500 if (version == int.MAX)
8501 {
8502 if (!ctx.Read(itemQBIndex))
8503 {
8504 m_IsStoreLoad = false;
8505 return false;
8506 }
8507 }
8508 else if (Class.CastTo(player, GetHierarchyRootPlayer()))
8509 {
8510 //Load quickbar item bind
8511 if (!ctx.Read(itemQBIndex))
8512 {
8513 m_IsStoreLoad = false;
8514 return false;
8515 }
8516 if (itemQBIndex != -1 && player)
8517 player.SetLoadedQuickBarItemBind(this,itemQBIndex);
8518 }
8519 }
8520
8521 if (version < 140)
8522 {
8523 // variable management system
8524 if (!LoadVariables(ctx, version))
8525 {
8526 m_IsStoreLoad = false;
8527 return false;
8528 }
8529 }
8530
8531 //agent trasmission system
8532 if (!LoadAgents(ctx, version))
8533 {
8534 m_IsStoreLoad = false;
8535 return false;
8536 }
8537 if (version >= 132)
8538 {
8539 RemotelyActivatedItemBehaviour raib = GetRemotelyActivatedItemBehaviour();
8540 if (raib)
8541 {
8542 if (!raib.OnStoreLoad(ctx,version))
8543 {
8544 m_IsStoreLoad = false;
8545 return false;
8546 }
8547 }
8548 }
8549
8550 m_IsStoreLoad = false;
8551 return true;
8552 }
8553
8554 //----------------------------------------------------------------
8555
8556 override void OnStoreSave(ParamsWriteContext ctx)
8557 {
8558 super.OnStoreSave(ctx);
8559
8560 PlayerBase player;
8561 if (PlayerBase.CastTo(player,GetHierarchyRootPlayer()))
8562 {
8563 ctx.Write(true); // Keep track of if we should actually read this in or not
8564 //Save quickbar item bind
8565 int itemQBIndex = -1;
8566 itemQBIndex = player.FindQuickBarEntityIndex(this);
8567 ctx.Write(itemQBIndex);
8568 }
8569 else
8570 {
8571 ctx.Write(false); // Keep track of if we should actually read this in or not
8572 }
8573
8574 SaveAgents(ctx);//agent trasmission system
8575
8576 RemotelyActivatedItemBehaviour raib = GetRemotelyActivatedItemBehaviour();
8577 if (raib)
8578 {
8579 raib.OnStoreSave(ctx);
8580 }
8581 }
8582 //----------------------------------------------------------------
8583
8584 override void AfterStoreLoad()
8585 {
8586 super.AfterStoreLoad();
8587
8589 {
8591 }
8592
8593 if (GetStoreLoadedQuantity() != float.LOWEST)
8594 {
8596 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
8597 }
8598 }
8599
8600 override void EEOnAfterLoad()
8601 {
8602 super.EEOnAfterLoad();
8603
8605 {
8606 m_FixDamageSystemInit = false;
8607 }
8608
8611 }
8612
8613 bool CanBeDisinfected()
8614 {
8615 return false;
8616 }
8617
8618
8619 //----------------------------------------------------------------
8620 override void OnVariablesSynchronized()
8621 {
8622 if (m_Initialized)
8623 {
8624 #ifdef PLATFORM_CONSOLE
8625 //bruteforce it is
8626 if (IsSplitable())
8627 {
8628 UIScriptedMenu menu = GetGame().GetUIManager().FindMenu(MENU_INVENTORY);
8629 if (menu)
8630 {
8631 menu.Refresh();
8632 }
8633 }
8634 #endif
8635 }
8636
8638 {
8639 PlayImpactSound(m_ConfigWeight, m_ImpactSpeed, m_ImpactSoundSurfaceHash);
8640 m_WantPlayImpactSound = false;
8641 }
8642
8644 {
8645 SetWeightDirty();
8647 }
8648 if (m_VarWet != m_VarWetPrev)
8649 {
8652 }
8653
8654 if (m_SoundSyncPlay != 0)
8655 {
8656 m_ItemSoundHandler.PlayItemSoundClient(m_SoundSyncPlay);
8657 m_SoundSyncPlay = 0;
8658 }
8659 if (m_SoundSyncStop != 0)
8660 {
8661 m_ItemSoundHandler.StopItemSoundClient(m_SoundSyncStop);
8662 m_SoundSyncStop = 0;
8663 }
8664
8665 super.OnVariablesSynchronized();
8666 }
8667
8668 //------------------------- Quantity
8669 //----------------------------------------------------------------
8671 override bool SetQuantity(float value, bool destroy_config = true, bool destroy_forced = false, bool allow_client = false, bool clamp_to_stack_max = true)
8672 {
8673 if (!IsServerCheck(allow_client))
8674 return false;
8675
8676 if (!HasQuantity())
8677 return false;
8678
8679 float min = GetQuantityMin();
8680 float max = GetQuantityMax();
8681
8682 if (value <= (min + 0.001))
8683 value = min;
8684
8685 if (value == min)
8686 {
8687 if (destroy_config)
8688 {
8689 bool dstr = ConfigGetBool("varQuantityDestroyOnMin");
8690 if (dstr)
8691 {
8692 m_VarQuantity = Math.Clamp(value, min, max);
8693 this.Delete();
8694 return true;
8695 }
8696 }
8697 else if (destroy_forced)
8698 {
8699 m_VarQuantity = Math.Clamp(value, min, max);
8700 this.Delete();
8701 return true;
8702 }
8703 // we get here if destroy_config IS true AND dstr(config destroy param) IS false;
8704 RemoveAllAgents();//we remove all agents when we got to the min value, but the item is not getting deleted
8705 }
8706
8707 float delta = m_VarQuantity;
8708 m_VarQuantity = Math.Clamp(value, min, max);
8709
8710 if (GetStoreLoadedQuantity() == float.LOWEST)//any other value means we are setting quantity from storage
8711 {
8712 delta = m_VarQuantity - delta;
8713
8714 if (delta)
8715 OnQuantityChanged(delta);
8716 }
8717
8718 SetVariableMask(VARIABLE_QUANTITY);
8719
8720 return false;
8721 }
8722
8723 //----------------------------------------------------------------
8725 bool AddQuantity(float value, bool destroy_config = true, bool destroy_forced = false)
8726 {
8727 return SetQuantity(GetQuantity() + value, destroy_config, destroy_forced);
8728 }
8729 //----------------------------------------------------------------
8730 void SetQuantityMax()
8731 {
8732 float max = GetQuantityMax();
8733 SetQuantity(max);
8734 }
8735
8736 override void SetQuantityToMinimum()
8737 {
8738 float min = GetQuantityMin();
8739 SetQuantity(min);
8740 }
8741 //----------------------------------------------------------------
8743 override void SetQuantityNormalized(float value, bool destroy_config = true, bool destroy_forced = false)
8744 {
8745 float value_clamped = Math.Clamp(value, 0, 1);//just to make sure
8746 int result = Math.Round(Math.Lerp(GetQuantityMin(), GetQuantityMax(), value_clamped));
8747 SetQuantity(result, destroy_config, destroy_forced);
8748 }
8749
8750 //----------------------------------------------------------------
8752 override float GetQuantityNormalized()
8753 {
8754 return Math.InverseLerp(GetQuantityMin(), GetQuantityMax(),m_VarQuantity);
8755 }
8756
8758 {
8759 return GetQuantityNormalized();
8760 }
8761
8762 /*void SetAmmoNormalized(float value)
8763 {
8764 float value_clamped = Math.Clamp(value, 0, 1);
8765 Magazine this_mag = Magazine.Cast(this);
8766 int max_rounds = this_mag.GetAmmoMax();
8767 int result = value * max_rounds;//can the rounded if higher precision is required
8768 this_mag.SetAmmoCount(result);
8769 }*/
8770 //----------------------------------------------------------------
8771 override int GetQuantityMax()
8772 {
8773 int slot = -1;
8774 if (GetInventory())
8775 {
8776 InventoryLocation il = new InventoryLocation;
8777 GetInventory().GetCurrentInventoryLocation(il);
8778 slot = il.GetSlot();
8779 }
8780
8781 return GetTargetQuantityMax(slot);
8782 }
8783
8784 override int GetTargetQuantityMax(int attSlotID = -1)
8785 {
8786 float quantity_max = 0;
8787
8788 if (IsSplitable()) //only stackable/splitable items can check for stack size
8789 {
8790 if (attSlotID != -1)
8791 quantity_max = InventorySlots.GetStackMaxForSlotId(attSlotID);
8792
8793 if (quantity_max <= 0)
8794 quantity_max = m_VarStackMax;
8795 }
8796
8797 if (quantity_max <= 0)
8798 quantity_max = m_VarQuantityMax;
8799
8800 return quantity_max;
8801 }
8802 //----------------------------------------------------------------
8803 override int GetQuantityMin()
8804 {
8805 return m_VarQuantityMin;
8806 }
8807 //----------------------------------------------------------------
8808 int GetQuantityInit()
8809 {
8810 return m_VarQuantityInit;
8811 }
8812
8813 //----------------------------------------------------------------
8814 override bool HasQuantity()
8815 {
8816 return !(GetQuantityMax() - GetQuantityMin() == 0);
8817 }
8818
8819 override float GetQuantity()
8820 {
8821 return m_VarQuantity;
8822 }
8823
8824 bool IsFullQuantity()
8825 {
8826 return GetQuantity() >= GetQuantityMax();
8827 }
8828
8829 //Calculates weight of single item without attachments and cargo
8830 override float GetSingleInventoryItemWeightEx()
8831 {
8832 //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
8833 float weightEx = GetWeightEx();//overall weight of the item
8834 float special = GetInventoryAndCargoWeight();//cargo and attachment weight
8835 return weightEx - special;
8836 }
8837
8838 // Obsolete, use GetSingleInventoryItemWeightEx() instead
8840 {
8842 }
8843
8844 override protected float GetWeightSpecialized(bool forceRecalc = false)
8845 {
8846 if (IsSplitable()) //quantity determines size of the stack
8847 {
8848 #ifdef DEVELOPER
8849 if (WeightDebug.m_VerbosityFlags & WeightDebugType.RECALC_FORCED)
8850 {
8851 WeightDebugData data1 = WeightDebug.GetWeightDebug(this);
8852 data1.SetCalcDetails("TIB1: " + GetConfigWeightModifiedDebugText() +" * " + GetQuantity()+"(quantity)");
8853 }
8854 #endif
8855
8856 return GetQuantity() * GetConfigWeightModified();
8857 }
8858 else if (HasEnergyManager())// items with energy manager
8859 {
8860 #ifdef DEVELOPER
8861 if (WeightDebug.m_VerbosityFlags & WeightDebugType.RECALC_FORCED)
8862 {
8863 WeightDebugData data2 = WeightDebug.GetWeightDebug(this);
8864 data2.SetCalcDetails("TIB2: "+super.GetWeightSpecialized(forceRecalc)+"(contents weight) + " + GetConfigWeightModifiedDebugText() +" + " + GetCompEM().GetEnergy()+"(energy) * " + ConfigGetFloat("weightPerQuantityUnit") +"(weightPerQuantityUnit)");
8865 }
8866 #endif
8867 return super.GetWeightSpecialized(forceRecalc) + (GetCompEM().GetEnergy() * ConfigGetFloat("weightPerQuantityUnit")) + GetConfigWeightModified();
8868 }
8869 else//everything else
8870 {
8871 #ifdef DEVELOPER
8872 if (WeightDebug.m_VerbosityFlags & WeightDebugType.RECALC_FORCED)
8873 {
8874 WeightDebugData data3 = WeightDebug.GetWeightDebug(this);
8875 data3.SetCalcDetails("TIB3: "+super.GetWeightSpecialized(forceRecalc)+"(contents weight) + " + GetConfigWeightModifiedDebugText() +" + " + GetQuantity()+"(quantity) * " + ConfigGetFloat("weightPerQuantityUnit") +"(weightPerQuantityUnit))");
8876 }
8877 #endif
8878 return super.GetWeightSpecialized(forceRecalc) + (GetQuantity() * ConfigGetFloat("weightPerQuantityUnit")) + GetConfigWeightModified();
8879 }
8880 }
8881
8883 int GetNumberOfItems()
8884 {
8885 int item_count = 0;
8886 ItemBase item;
8887
8888 if (GetInventory().GetCargo() != NULL)
8889 {
8890 item_count = GetInventory().GetCargo().GetItemCount();
8891 }
8892
8893 for (int i = 0; i < GetInventory().AttachmentCount(); i++)
8894 {
8895 Class.CastTo(item,GetInventory().GetAttachmentFromIndex(i));
8896 if (item)
8897 item_count += item.GetNumberOfItems();
8898 }
8899 return item_count;
8900 }
8901
8903 float GetUnitWeight(bool include_wetness = true)
8904 {
8905 float weight = 0;
8906 float wetness = 1;
8907 if (include_wetness)
8908 wetness += GetWet();
8909 if (IsSplitable()) //quantity determines size of the stack
8910 {
8911 weight = wetness * m_ConfigWeight;
8912 }
8913 else if (IsLiquidContainer()) //is a liquid container, default liquid weight is set to 1. May revisit later?
8914 {
8915 weight = 1;
8916 }
8917 return weight;
8918 }
8919
8920 //-----------------------------------------------------------------
8921
8922 override void ClearInventory()
8923 {
8924 if ((GetGame().IsServer() || !GetGame().IsMultiplayer()) && GetInventory())
8925 {
8926 GameInventory inv = GetInventory();
8927 array<EntityAI> items = new array<EntityAI>;
8928 inv.EnumerateInventory(InventoryTraversalType.INORDER, items);
8929 for (int i = 0; i < items.Count(); i++)
8930 {
8931 ItemBase item = ItemBase.Cast(items.Get(i));
8932 if (item)
8933 {
8934 GetGame().ObjectDelete(item);
8935 }
8936 }
8937 }
8938 }
8939
8940 //------------------------- Energy
8941
8942 //----------------------------------------------------------------
8943 float GetEnergy()
8944 {
8945 float energy = 0;
8946 if (HasEnergyManager())
8947 {
8948 energy = GetCompEM().GetEnergy();
8949 }
8950 return energy;
8951 }
8952
8953
8954 override void OnEnergyConsumed()
8955 {
8956 super.OnEnergyConsumed();
8957
8959 }
8960
8961 override void OnEnergyAdded()
8962 {
8963 super.OnEnergyAdded();
8964
8966 }
8967
8968 // Converts energy (from Energy Manager) to quantity, if enabled.
8970 {
8971 if (GetGame().IsServer() && HasEnergyManager() && GetCompEM().HasConversionOfEnergyToQuantity())
8972 {
8973 if (HasQuantity())
8974 {
8975 float energy_0to1 = GetCompEM().GetEnergy0To1();
8976 SetQuantityNormalized(energy_0to1);
8977 }
8978 }
8979 }
8980
8981 //----------------------------------------------------------------
8982 float GetHeatIsolationInit()
8983 {
8984 return ConfigGetFloat("heatIsolation");
8985 }
8986
8987 float GetHeatIsolation()
8988 {
8989 return m_HeatIsolation;
8990 }
8991
8992 float GetDryingIncrement(string pIncrementName)
8993 {
8994 string paramPath = string.Format("CfgVehicles %1 EnvironmentWetnessIncrements Drying %2", GetType(), pIncrementName);
8995 if (GetGame().ConfigIsExisting(paramPath))
8996 return GetGame().ConfigGetFloat(paramPath);
8997
8998 return 0.0;
8999 }
9000
9001 float GetSoakingIncrement(string pIncrementName)
9002 {
9003 string paramPath = string.Format("CfgVehicles %1 EnvironmentWetnessIncrements Soaking %2", GetType(), pIncrementName);
9004 if (GetGame().ConfigIsExisting(paramPath))
9005 return GetGame().ConfigGetFloat(paramPath);
9006
9007 return 0.0;
9008 }
9009 //----------------------------------------------------------------
9010 override void SetWet(float value, bool allow_client = false)
9011 {
9012 if (!IsServerCheck(allow_client))
9013 return;
9014
9015 float min = GetWetMin();
9016 float max = GetWetMax();
9017
9018 float previousValue = m_VarWet;
9019
9020 m_VarWet = Math.Clamp(value, min, max);
9021
9022 if (previousValue != m_VarWet)
9023 {
9024 SetVariableMask(VARIABLE_WET);
9025 OnWetChanged(m_VarWet, previousValue);
9026 }
9027 }
9028 //----------------------------------------------------------------
9029 override void AddWet(float value)
9030 {
9031 SetWet(GetWet() + value);
9032 }
9033 //----------------------------------------------------------------
9034 override void SetWetMax()
9035 {
9037 }
9038 //----------------------------------------------------------------
9039 override float GetWet()
9040 {
9041 return m_VarWet;
9042 }
9043 //----------------------------------------------------------------
9044 override float GetWetMax()
9045 {
9046 return m_VarWetMax;
9047 }
9048 //----------------------------------------------------------------
9049 override float GetWetMin()
9050 {
9051 return m_VarWetMin;
9052 }
9053 //----------------------------------------------------------------
9054 override float GetWetInit()
9055 {
9056 return m_VarWetInit;
9057 }
9058 //----------------------------------------------------------------
9059 override void OnWetChanged(float newVal, float oldVal)
9060 {
9061 EWetnessLevel newLevel = GetWetLevelInternal(newVal);
9062 EWetnessLevel oldLevel = GetWetLevelInternal(oldVal);
9063 if (newLevel != oldLevel)
9064 {
9065 OnWetLevelChanged(newLevel,oldLevel);
9066 }
9067 }
9068
9069 override void OnWetLevelChanged(EWetnessLevel newLevel, EWetnessLevel oldLevel)
9070 {
9071 SetWeightDirty();
9072 }
9073
9074 override EWetnessLevel GetWetLevel()
9075 {
9076 return GetWetLevelInternal(m_VarWet);
9077 }
9078
9079 //----------------------------------------------------------------
9080
9081 override void SetStoreLoad(bool value)
9082 {
9083 m_IsStoreLoad = value;
9084 }
9085
9086 override bool IsStoreLoad()
9087 {
9088 return m_IsStoreLoad;
9089 }
9090
9091 override void SetStoreLoadedQuantity(float value)
9092 {
9093 m_StoreLoadedQuantity = value;
9094 }
9095
9096 override float GetStoreLoadedQuantity()
9097 {
9098 return m_StoreLoadedQuantity;
9099 }
9100
9101 //----------------------------------------------------------------
9102
9103 float GetItemModelLength()
9104 {
9105 if (ConfigIsExisting("itemModelLength"))
9106 {
9107 return ConfigGetFloat("itemModelLength");
9108 }
9109 return 0;
9110 }
9111
9112 float GetItemAttachOffset()
9113 {
9114 if (ConfigIsExisting("itemAttachOffset"))
9115 {
9116 return ConfigGetFloat("itemAttachOffset");
9117 }
9118 return 0;
9119 }
9120
9121 override void SetCleanness(int value, bool allow_client = false)
9122 {
9123 if (!IsServerCheck(allow_client))
9124 return;
9125
9126 int previousValue = m_Cleanness;
9127
9128 m_Cleanness = Math.Clamp(value, m_CleannessMin, m_CleannessMax);
9129
9130 if (previousValue != m_Cleanness)
9131 SetVariableMask(VARIABLE_CLEANNESS);
9132 }
9133
9134 override int GetCleanness()
9135 {
9136 return m_Cleanness;
9137 }
9138
9140 {
9141 return true;
9142 }
9143
9144 //----------------------------------------------------------------
9145 // ATTACHMENT LOCKING
9146 // Getters relevant to generic ActionLockAttachment
9147 int GetLockType()
9148 {
9149 return m_LockType;
9150 }
9151
9152 string GetLockSoundSet()
9153 {
9154 return m_LockSoundSet;
9155 }
9156
9157 //----------------------------------------------------------------
9158 //------------------------- Color
9159 // sets items color variable given color components
9160 override void SetColor(int r, int g, int b, int a)
9161 {
9166 SetVariableMask(VARIABLE_COLOR);
9167 }
9169 override void GetColor(out int r,out int g,out int b,out int a)
9170 {
9175 }
9176
9177 bool IsColorSet()
9178 {
9179 return IsVariableSet(VARIABLE_COLOR);
9180 }
9181
9183 string GetColorString()
9184 {
9185 int r,g,b,a;
9186 GetColor(r,g,b,a);
9187 r = r/255;
9188 g = g/255;
9189 b = b/255;
9190 a = a/255;
9191 return MiscGameplayFunctions.GetColorString(r, g, b, a);
9192 }
9193 //----------------------------------------------------------------
9194 //------------------------- LiquidType
9195
9196 override void SetLiquidType(int value, bool allow_client = false)
9197 {
9198 if (!IsServerCheck(allow_client))
9199 return;
9200
9201 int old = m_VarLiquidType;
9202 m_VarLiquidType = value;
9203 OnLiquidTypeChanged(old,value);
9204 SetVariableMask(VARIABLE_LIQUIDTYPE);
9205 }
9206
9207 int GetLiquidTypeInit()
9208 {
9209 return ConfigGetInt("varLiquidTypeInit");
9210 }
9211
9212 override int GetLiquidType()
9213 {
9214 return m_VarLiquidType;
9215 }
9216
9217 protected void OnLiquidTypeChanged(int oldType, int newType)
9218 {
9219 if (newType == LIQUID_NONE && GetIsFrozen())
9220 SetFrozen(false);
9221 }
9222
9224 void UpdateQuickbarShortcutVisibility(PlayerBase player)
9225 {
9226 player.SetEnableQuickBarEntityShortcut(this,!GetHierarchyParent() || GetHierarchyParent().GetInventory().AreChildrenAccessible());
9227 }
9228
9229 // -------------------------------------------------------------------------
9231 void OnInventoryEnter(Man player)
9232 {
9233 PlayerBase nplayer;
9234 if (PlayerBase.CastTo(nplayer, player))
9235 {
9236 m_CanPlayImpactSound = true;
9237 //nplayer.OnItemInventoryEnter(this);
9238 nplayer.SetEnableQuickBarEntityShortcut(this,!GetHierarchyParent() || GetHierarchyParent().GetInventory().AreChildrenAccessible());
9239 }
9240 }
9241
9242 // -------------------------------------------------------------------------
9244 void OnInventoryExit(Man player)
9245 {
9246 PlayerBase nplayer;
9247 if (PlayerBase.CastTo(nplayer,player))
9248 {
9249 //nplayer.OnItemInventoryExit(this);
9250 nplayer.SetEnableQuickBarEntityShortcut(this,false);
9251
9252 }
9253
9254 //if (!GetGame().IsDedicatedServer())
9255 player.GetHumanInventory().ClearUserReservedLocationForContainer(this);
9256
9257
9258 if (HasEnergyManager())
9259 {
9260 GetCompEM().UpdatePlugState(); // Unplug the el. device if it's necesarry.
9261 }
9262 }
9263
9264 // ADVANCED PLACEMENT EVENTS
9265 override void OnPlacementStarted(Man player)
9266 {
9267 super.OnPlacementStarted(player);
9268
9269 SetTakeable(false);
9270 }
9271
9272 override void OnPlacementComplete(Man player, vector position = "0 0 0", vector orientation = "0 0 0")
9273 {
9274 if (m_AdminLog)
9275 {
9276 m_AdminLog.OnPlacementComplete(player, this);
9277 }
9278
9279 super.OnPlacementComplete(player, position, orientation);
9280 }
9281
9282 //-----------------------------
9283 // AGENT SYSTEM
9284 //-----------------------------
9285 //--------------------------------------------------------------------------
9286 bool ContainsAgent(int agent_id)
9287 {
9288 if (agent_id & m_AttachedAgents)
9289 {
9290 return true;
9291 }
9292 else
9293 {
9294 return false;
9295 }
9296 }
9297
9298 //--------------------------------------------------------------------------
9299 override void RemoveAgent(int agent_id)
9300 {
9301 if (ContainsAgent(agent_id))
9302 {
9303 m_AttachedAgents = ~agent_id & m_AttachedAgents;
9304 }
9305 }
9306
9307 //--------------------------------------------------------------------------
9308 override void RemoveAllAgents()
9309 {
9310 m_AttachedAgents = 0;
9311 }
9312 //--------------------------------------------------------------------------
9313 override void RemoveAllAgentsExcept(int agent_to_keep)
9314 {
9315 m_AttachedAgents = m_AttachedAgents & agent_to_keep;
9316 }
9317 // -------------------------------------------------------------------------
9318 override void InsertAgent(int agent, float count = 1)
9319 {
9320 if (count < 1)
9321 return;
9322 //Debug.Log("Inserting Agent on item: " + agent.ToString() +" count: " + count.ToString());
9324 }
9325
9327 void TransferAgents(int agents)
9328 {
9330 }
9331
9332 // -------------------------------------------------------------------------
9333 override int GetAgents()
9334 {
9335 return m_AttachedAgents;
9336 }
9337 //----------------------------------------------------------------------
9338
9339 /*int GetContaminationType()
9340 {
9341 int contamination_type;
9342
9343 const int CONTAMINATED_MASK = eAgents.CHOLERA | eAgents.INFLUENZA | eAgents.SALMONELLA | eAgents.BRAIN;
9344 const int POISONED_MASK = eAgents.FOOD_POISON | eAgents.CHEMICAL_POISON;
9345 const int NERVE_GAS_MASK = eAgents.CHEMICAL_POISON;
9346 const int DIRTY_MASK = eAgents.WOUND_AGENT;
9347
9348 Edible_Base edible = Edible_Base.Cast(this);
9349 int agents = GetAgents();
9350 if (edible)
9351 {
9352 NutritionalProfile profile = Edible_Base.GetNutritionalProfile(edible);
9353 if (profile)
9354 {
9355 agents = agents | profile.GetAgents();//merge item's agents with nutritional agents
9356 }
9357 }
9358 if (agents & CONTAMINATED_MASK)
9359 {
9360 contamination_type = contamination_type | EContaminationTypes.ITEM_BADGE_CONTAMINATED;
9361 }
9362 if (agents & POISONED_MASK)
9363 {
9364 contamination_type = contamination_type | EContaminationTypes.ITEM_BADGE_POISONED;
9365 }
9366 if (agents & NERVE_GAS_MASK)
9367 {
9368 contamination_type = contamination_type | EContaminationTypes.ITEM_BADGE_NERVE_GAS;
9369 }
9370 if (agents & DIRTY_MASK)
9371 {
9372 contamination_type = contamination_type | EContaminationTypes.ITEM_BADGE_DIRTY;
9373 }
9374
9375 return agents;
9376 }*/
9377
9378 // -------------------------------------------------------------------------
9379 bool LoadAgents(ParamsReadContext ctx, int version)
9380 {
9381 if (!ctx.Read(m_AttachedAgents))
9382 return false;
9383 return true;
9384 }
9385 // -------------------------------------------------------------------------
9387 {
9388
9390 }
9391 // -------------------------------------------------------------------------
9392
9394 override void CheckForRoofLimited(float timeTresholdMS = 3000)
9395 {
9396 super.CheckForRoofLimited(timeTresholdMS);
9397
9398 float time = GetGame().GetTime();
9399 if ((time - m_PreviousRoofTestTime) >= timeTresholdMS)
9400 {
9401 m_PreviousRoofTestTime = time;
9402 SetRoofAbove(MiscGameplayFunctions.IsUnderRoof(this));
9403 }
9404 }
9405
9406 // returns item's protection level against enviromental hazard, for masks with filters, returns the filters protection for valid filter, otherwise 0
9407 float GetProtectionLevel(int type, bool consider_filter = false, int system = 0)
9408 {
9409 if (IsDamageDestroyed() || (HasQuantity() && GetQuantity() <= 0))
9410 {
9411 return 0;
9412 }
9413
9414 if (GetInventory().GetAttachmentSlotsCount() != 0)//is it an item with attachable filter ?
9415 {
9416 ItemBase filter = ItemBase.Cast(FindAttachmentBySlotName("GasMaskFilter"));
9417 if (filter)
9418 return filter.GetProtectionLevel(type, false, system);//it's a valid filter, return the protection
9419 else
9420 return 0;//otherwise return 0 when no filter attached
9421 }
9422
9423 string subclassPath, entryName;
9424
9425 switch (type)
9426 {
9427 case DEF_BIOLOGICAL:
9428 entryName = "biological";
9429 break;
9430 case DEF_CHEMICAL:
9431 entryName = "chemical";
9432 break;
9433 default:
9434 entryName = "biological";
9435 break;
9436 }
9437
9438 subclassPath = "CfgVehicles " + this.GetType() + " Protection ";
9439
9440 return GetGame().ConfigGetFloat(subclassPath + entryName);
9441 }
9442
9443
9444
9446 override void EEOnCECreate()
9447 {
9448 if (!IsMagazine())
9450
9452 }
9453
9454
9455 //-------------------------
9456 // OPEN/CLOSE USER ACTIONS
9457 //-------------------------
9459 void Open();
9460 void Close();
9461 bool IsOpen()
9462 {
9463 return true;
9464 }
9465
9466 override bool CanDisplayCargo()
9467 {
9468 return IsOpen();
9469 }
9470
9471
9472 // ------------------------------------------------------------
9473 // CONDITIONS
9474 // ------------------------------------------------------------
9475 override bool CanPutInCargo(EntityAI parent)
9476 {
9477 if (parent)
9478 {
9479 if (parent.IsInherited(DayZInfected))
9480 return true;
9481
9482 if (!parent.IsRuined())
9483 return true;
9484 }
9485
9486 return true;
9487 }
9488
9489 override bool CanPutAsAttachment(EntityAI parent)
9490 {
9491 if (!super.CanPutAsAttachment(parent))
9492 {
9493 return false;
9494 }
9495
9496 if (!IsRuined() && !parent.IsRuined())
9497 {
9498 return true;
9499 }
9500
9501 return false;
9502 }
9503
9504 override bool CanReceiveItemIntoCargo(EntityAI item)
9505 {
9506 //removed 15.06. coz of loading from storage -> after load items in cargo was lost -> waiting for proper solution
9507 //if (GetHealthLevel() == GameConstants.STATE_RUINED)
9508 // return false;
9509
9510 return super.CanReceiveItemIntoCargo(item);
9511 }
9512
9513 override bool CanReceiveAttachment(EntityAI attachment, int slotId)
9514 {
9515 //removed 15.06. coz of loading from storage -> after load items in cargo was lost -> waiting for proper solution
9516 //if (GetHealthLevel() == GameConstants.STATE_RUINED)
9517 // return false;
9518
9519 GameInventory attachmentInv = attachment.GetInventory();
9520 if (attachmentInv && attachmentInv.GetCargo() && attachmentInv.GetCargo().GetItemCount() > 0)
9521 {
9522 if (GetHierarchyParent() && !GetHierarchyParent().IsInherited(PlayerBase))
9523 return false;
9524 }
9525
9526 InventoryLocation loc = new InventoryLocation();
9527 attachment.GetInventory().GetCurrentInventoryLocation(loc);
9528 if (loc && loc.IsValid() && !GetInventory().AreChildrenAccessible())
9529 return false;
9530
9531 return super.CanReceiveAttachment(attachment, slotId);
9532 }
9533
9534 override bool CanReleaseAttachment(EntityAI attachment)
9535 {
9536 if (!super.CanReleaseAttachment(attachment))
9537 return false;
9538
9539 return GetInventory().AreChildrenAccessible();
9540 }
9541
9542 /*override bool CanLoadAttachment(EntityAI attachment)
9543 {
9544 //removed 15.06. coz of loading from storage -> after load items in cargo was lost -> waiting for proper solution
9545 //if (GetHealthLevel() == GameConstants.STATE_RUINED)
9546 // return false;
9547
9548 GameInventory attachmentInv = attachment.GetInventory();
9549 if (attachmentInv && attachmentInv.GetCargo() && attachmentInv.GetCargo().GetItemCount() > 0)
9550 {
9551 bool boo = (GetHierarchyParent() && !GetHierarchyParent().IsInherited(PlayerBase));
9552 ErrorEx("CanLoadAttachment | this: " + this + " | attachment: " + attachment + " | boo: " + boo,ErrorExSeverity.INFO);
9553
9554 if (GetHierarchyParent() && !GetHierarchyParent().IsInherited(PlayerBase))
9555 return false;
9556 }
9557
9558 return super.CanLoadAttachment(attachment);
9559 }*/
9560
9561 // Plays muzzle flash particle effects
9562 static void PlayFireParticles(ItemBase weapon, int muzzle_index, string ammoType, ItemBase muzzle_owner, ItemBase suppressor, string config_to_search)
9563 {
9564 int id = muzzle_owner.GetMuzzleID();
9565 array<ref WeaponParticlesOnFire> WPOF_array = m_OnFireEffect.Get(id);
9566
9567 if (WPOF_array)
9568 {
9569 for (int i = 0; i < WPOF_array.Count(); i++)
9570 {
9571 WeaponParticlesOnFire WPOF = WPOF_array.Get(i);
9572
9573 if (WPOF)
9574 {
9575 WPOF.OnActivate(weapon, muzzle_index, ammoType, muzzle_owner, suppressor, config_to_search);
9576 }
9577 }
9578 }
9579 }
9580
9581 // Plays bullet eject particle effects (usually just smoke, the bullet itself is a 3D model and is not part of this function)
9582 static void PlayBulletCasingEjectParticles(ItemBase weapon, string ammoType, ItemBase muzzle_owner, ItemBase suppressor, string config_to_search)
9583 {
9584 int id = muzzle_owner.GetMuzzleID();
9585 array<ref WeaponParticlesOnBulletCasingEject> WPOBE_array = m_OnBulletCasingEjectEffect.Get(id);
9586
9587 if (WPOBE_array)
9588 {
9589 for (int i = 0; i < WPOBE_array.Count(); i++)
9590 {
9591 WeaponParticlesOnBulletCasingEject WPOBE = WPOBE_array.Get(i);
9592
9593 if (WPOBE)
9594 {
9595 WPOBE.OnActivate(weapon, 0, ammoType, muzzle_owner, suppressor, config_to_search);
9596 }
9597 }
9598 }
9599 }
9600
9601 // Plays all weapon overheating particles
9602 static void PlayOverheatingParticles(ItemBase weapon, string ammoType, ItemBase muzzle_owner, ItemBase suppressor, string config_to_search)
9603 {
9604 int id = muzzle_owner.GetMuzzleID();
9605 array<ref WeaponParticlesOnOverheating> WPOOH_array = weapon.m_OnOverheatingEffect.Get(id);
9606
9607 if (WPOOH_array)
9608 {
9609 for (int i = 0; i < WPOOH_array.Count(); i++)
9610 {
9611 WeaponParticlesOnOverheating WPOOH = WPOOH_array.Get(i);
9612
9613 if (WPOOH)
9614 {
9615 WPOOH.OnActivate(weapon, 0, ammoType, muzzle_owner, suppressor, config_to_search);
9616 }
9617 }
9618 }
9619 }
9620
9621 // Updates all weapon overheating particles
9622 static void UpdateOverheatingParticles(ItemBase weapon, string ammoType, ItemBase muzzle_owner, ItemBase suppressor, string config_to_search)
9623 {
9624 int id = muzzle_owner.GetMuzzleID();
9625 array<ref WeaponParticlesOnOverheating> WPOOH_array = weapon.m_OnOverheatingEffect.Get(id);
9626
9627 if (WPOOH_array)
9628 {
9629 for (int i = 0; i < WPOOH_array.Count(); i++)
9630 {
9631 WeaponParticlesOnOverheating WPOOH = WPOOH_array.Get(i);
9632
9633 if (WPOOH)
9634 {
9635 WPOOH.OnUpdate(weapon, ammoType, muzzle_owner, suppressor, config_to_search);
9636 }
9637 }
9638 }
9639 }
9640
9641 // Stops overheating particles
9642 static void StopOverheatingParticles(ItemBase weapon, string ammoType, ItemBase muzzle_owner, ItemBase suppressor, string config_to_search)
9643 {
9644 int id = muzzle_owner.GetMuzzleID();
9645 array<ref WeaponParticlesOnOverheating> WPOOH_array = weapon.m_OnOverheatingEffect.Get(id);
9646
9647 if (WPOOH_array)
9648 {
9649 for (int i = 0; i < WPOOH_array.Count(); i++)
9650 {
9651 WeaponParticlesOnOverheating WPOOH = WPOOH_array.Get(i);
9652
9653 if (WPOOH)
9654 {
9655 WPOOH.OnDeactivate(weapon, ammoType, muzzle_owner, suppressor, config_to_search);
9656 }
9657 }
9658 }
9659 }
9660
9661 //----------------------------------------------------------------
9662 //Item Behaviour - unified approach
9663 override bool IsHeavyBehaviour()
9664 {
9665 if (m_ItemBehaviour == 0)
9666 {
9667 return true;
9668 }
9669
9670 return false;
9671 }
9672
9673 override bool IsOneHandedBehaviour()
9674 {
9675 if (m_ItemBehaviour == 1)
9676 {
9677 return true;
9678 }
9679
9680 return false;
9681 }
9682
9683 override bool IsTwoHandedBehaviour()
9684 {
9685 if (m_ItemBehaviour == 2)
9686 {
9687 return true;
9688 }
9689
9690 return false;
9691 }
9692
9693 bool IsDeployable()
9694 {
9695 return false;
9696 }
9697
9699 float GetDeployTime()
9700 {
9701 return UATimeSpent.DEFAULT_DEPLOY;
9702 }
9703
9704
9705 //----------------------------------------------------------------
9706 // Item Targeting (User Actions)
9707 override void SetTakeable(bool pState)
9708 {
9709 m_IsTakeable = pState;
9710 SetSynchDirty();
9711 }
9712
9713 override bool IsTakeable()
9714 {
9715 return m_IsTakeable;
9716 }
9717
9718 // For cases where we want to show object widget which cant be taken to hands
9720 {
9721 return false;
9722 }
9723
9725 protected void PreLoadSoundAttachmentType()
9726 {
9727 string att_type = "None";
9728
9729 if (ConfigIsExisting("soundAttType"))
9730 {
9731 att_type = ConfigGetString("soundAttType");
9732 }
9733
9734 m_SoundAttType = att_type;
9735 }
9736
9737 override string GetAttachmentSoundType()
9738 {
9739 return m_SoundAttType;
9740 }
9741
9742 //----------------------------------------------------------------
9743 //SOUNDS - ItemSoundHandler
9744 //----------------------------------------------------------------
9745
9746 string GetPlaceSoundset(); // played when deploy starts
9747 string GetLoopDeploySoundset(); // played when deploy starts and stopped when it finishes
9748 string GetDeploySoundset(); // played when deploy sucessfully finishes
9749 string GetLoopFoldSoundset(); // played when fold starts and stopped when it finishes
9750 string GetFoldSoundset(); // played when fold sucessfully finishes
9751
9753 {
9754 if (!m_ItemSoundHandler)
9756
9757 return m_ItemSoundHandler;
9758 }
9759
9760 // override to initialize sounds
9761 protected void InitItemSounds()
9762 {
9763 if (GetPlaceSoundset() == string.Empty && GetDeploySoundset() == string.Empty && GetLoopDeploySoundset() == string.Empty)
9764 return;
9765
9767
9768 if (GetPlaceSoundset() != string.Empty)
9769 handler.AddSound(SoundConstants.ITEM_PLACE, GetPlaceSoundset());
9770
9771 if (GetDeploySoundset() != string.Empty)
9772 handler.AddSound(SoundConstants.ITEM_DEPLOY, GetDeploySoundset());
9773
9774 SoundParameters params = new SoundParameters();
9775 params.m_Loop = true;
9776 if (GetLoopDeploySoundset() != string.Empty)
9777 handler.AddSound(SoundConstants.ITEM_DEPLOY_LOOP, GetLoopDeploySoundset(), params);
9778 }
9779
9780 // Start sound using ItemSoundHandler
9781 void StartItemSoundServer(int id)
9782 {
9783 if (!GetGame().IsServer())
9784 return;
9785
9786 m_SoundSyncPlay = id;
9787 SetSynchDirty();
9788
9789 GetGame().GetCallQueue(CALL_CATEGORY_SYSTEM).Remove(ClearStartItemSoundServer); // in case one is queued already
9791 }
9792
9793 // Stop sound using ItemSoundHandler
9794 void StopItemSoundServer(int id)
9795 {
9796 if (!GetGame().IsServer())
9797 return;
9798
9799 m_SoundSyncStop = id;
9800 SetSynchDirty();
9801
9802 GetGame().GetCallQueue(CALL_CATEGORY_SYSTEM).Remove(ClearStopItemSoundServer); // in case one is queued already
9804 }
9805
9806 protected void ClearStartItemSoundServer()
9807 {
9808 m_SoundSyncPlay = 0;
9809 }
9810
9811 protected void ClearStopItemSoundServer()
9812 {
9813 m_SoundSyncStop = 0;
9814 }
9815
9817 void PlayAttachSound(string slot_type)
9818 {
9819 if (!GetGame().IsDedicatedServer())
9820 {
9821 if (ConfigIsExisting("attachSoundSet"))
9822 {
9823 string cfg_path = "";
9824 string soundset = "";
9825 string type_name = GetType();
9826
9827 TStringArray cfg_soundset_array = new TStringArray;
9828 TStringArray cfg_slot_array = new TStringArray;
9829 ConfigGetTextArray("attachSoundSet",cfg_soundset_array);
9830 ConfigGetTextArray("attachSoundSlot",cfg_slot_array);
9831
9832 if (cfg_soundset_array.Count() > 0 && cfg_soundset_array.Count() == cfg_slot_array.Count())
9833 {
9834 for (int i = 0; i < cfg_soundset_array.Count(); i++)
9835 {
9836 if (cfg_slot_array[i] == slot_type)
9837 {
9838 soundset = cfg_soundset_array[i];
9839 break;
9840 }
9841 }
9842 }
9843
9844 if (soundset != "")
9845 {
9846 EffectSound sound = SEffectManager.PlaySound(soundset, GetPosition());
9847 sound.SetAutodestroy(true);
9848 }
9849 }
9850 }
9851 }
9852
9853 void PlayDetachSound(string slot_type)
9854 {
9855 //TODO - evaluate if needed and devise universal config structure if so
9856 }
9857
9858 void OnApply(PlayerBase player);
9859
9861 {
9862 return 1.0;
9863 };
9864 //returns applicable selection
9865 array<string> GetHeadHidingSelection()
9866 {
9868 }
9869
9871 {
9873 }
9874
9875 WrittenNoteData GetWrittenNoteData() {};
9876
9878 {
9879 SetDynamicPhysicsLifeTime(0.01);
9880 m_ItemBeingDroppedPhys = false;
9881 }
9882
9884 {
9885 array<string> zone_names = new array<string>;
9886 GetDamageZones(zone_names);
9887 for (int i = 0; i < zone_names.Count(); i++)
9888 {
9889 SetHealthMax(zone_names.Get(i),"Health");
9890 }
9891 SetHealthMax("","Health");
9892 }
9893
9895 void SetZoneDamageCEInit()
9896 {
9897 float global_health = GetHealth01("","Health");
9898 array<string> zones = new array<string>;
9899 GetDamageZones(zones);
9900 //set damage of all zones to match global health level
9901 for (int i = 0; i < zones.Count(); i++)
9902 {
9903 SetHealth01(zones.Get(i),"Health",global_health);
9904 }
9905 }
9906
9908 bool IsCoverFaceForShave(string slot_name)
9909 {
9910 return IsExclusionFlagPresent(PlayerBase.GetFaceCoverageShaveValues());
9911 }
9912
9913 void ProcessItemWetness(float delta, bool hasParent, bool hasRootAsPlayer, ItemBase refParentIB)
9914 {
9915 if (!hasRootAsPlayer)
9916 {
9917 if (refParentIB)
9918 {
9919 // parent is wet
9920 if ((refParentIB.GetWet() >= GameConstants.STATE_SOAKING_WET) && (m_VarWet < m_VarWetMax))
9921 AddWet(delta * GameConstants.WETNESS_RATE_WETTING_INSIDE);
9922 // parent has liquid inside
9923 else if ((refParentIB.GetLiquidType() != 0) && (refParentIB.GetQuantity() > 0) && (m_VarWet < m_VarWetMax))
9924 AddWet(delta * GameConstants.WETNESS_RATE_WETTING_LIQUID);
9925 // drying
9926 else if (m_VarWet > m_VarWetMin)
9927 AddWet(-1 * delta * GetDryingIncrement("ground") * 2);
9928 }
9929 else
9930 {
9931 // drying on ground or inside non-itembase (car, ...)
9932 if (m_VarWet > m_VarWetMin)
9933 AddWet(-1 * delta * GetDryingIncrement("ground"));
9934 }
9935 }
9936 }
9937
9938 void ProcessItemTemperature(float delta, bool hasParent, bool hasRootAsPlayer, ItemBase refParentIB)
9939 {
9941 {
9942 float target = g_Game.GetMission().GetWorldData().GetBaseEnvTemperatureAtObject(this);
9943 if (GetTemperature() != target || !IsFreezeThawProgressFinished())
9944 {
9945 float heatPermCoef = 1.0;
9946 EntityAI ent = this;
9947 while (ent)
9948 {
9949 heatPermCoef *= ent.GetHeatPermeabilityCoef();
9950 ent = ent.GetHierarchyParent();
9951 }
9952
9953 SetTemperatureEx(new TemperatureDataInterpolated(target,ETemperatureAccessTypes.ACCESS_WORLD,delta,GameConstants.TEMP_COEF_WORLD,heatPermCoef));
9954 }
9955 }
9956 }
9957
9958 void HierarchyCheck(out bool hasParent, out bool hasRootAsPlayer, out ItemBase refParentIB)
9959 {
9960 // hierarchy check for an item to decide whether it has some parent and it is in some player inventory
9961 EntityAI parent = GetHierarchyParent();
9962 if (!parent)
9963 {
9964 hasParent = false;
9965 hasRootAsPlayer = false;
9966 }
9967 else
9968 {
9969 hasParent = true;
9970 hasRootAsPlayer = (GetHierarchyRootPlayer() != null);
9971 refParentIB = ItemBase.Cast(parent);
9972 }
9973 }
9974
9975 protected void ProcessDecay(float delta, bool hasRootAsPlayer)
9976 {
9977 // this is stub, implemented on Edible_Base
9978 }
9979
9980 bool CanDecay()
9981 {
9982 // return true used on selected food clases so they can decay
9983 return false;
9984 }
9985
9986 protected bool CanProcessDecay()
9987 {
9988 // this is stub, implemented on Edible_Base class
9989 // used to determine whether it is still necessary for the food to decay
9990 return false;
9991 }
9992
9993 protected bool CanHaveWetness()
9994 {
9995 // return true used on selected items that have a wetness effect
9996 return false;
9997 }
9998
10000 bool CanBeConsumed(ConsumeConditionData data = null)
10001 {
10002 return !GetIsFrozen() && IsOpen();
10003 }
10004
10005 override void ProcessVariables()
10006 {
10007 bool hasParent = false, hasRootAsPlayer = false;
10008 ItemBase refParentIB;
10009
10010 bool wwtu = g_Game.IsWorldWetTempUpdateEnabled();
10011 bool foodDecay = g_Game.IsFoodDecayEnabled();
10012
10013 if (wwtu || foodDecay)
10014 {
10015 bool processWetness = wwtu && CanHaveWetness();
10016 bool processTemperature = wwtu && CanHaveTemperature();
10017 bool processDecay = foodDecay && CanDecay() && CanProcessDecay();
10018
10019 if (processWetness || processTemperature || processDecay)
10020 {
10021 HierarchyCheck(hasParent, hasRootAsPlayer, refParentIB);
10022
10023 if (processWetness)
10024 ProcessItemWetness(m_ElapsedSinceLastUpdate, hasParent, hasRootAsPlayer, refParentIB);
10025
10026 if (processTemperature)
10027 ProcessItemTemperature(m_ElapsedSinceLastUpdate, hasParent, hasRootAsPlayer, refParentIB);
10028
10029 if (processDecay)
10030 ProcessDecay(m_ElapsedSinceLastUpdate, hasRootAsPlayer);
10031 }
10032 }
10033 }
10034
10037 {
10038 return m_TemperaturePerQuantityWeight * GameConstants.ITEM_TEMPERATURE_QUANTITY_WEIGHT_MULTIPLIER;
10039 }
10040
10041 override float GetTemperatureFreezeThreshold()
10042 {
10044 return Liquid.GetFreezeThreshold(GetLiquidType());
10045
10046 return super.GetTemperatureFreezeThreshold();
10047 }
10048
10049 override float GetTemperatureThawThreshold()
10050 {
10052 return Liquid.GetThawThreshold(GetLiquidType());
10053
10054 return super.GetTemperatureThawThreshold();
10055 }
10056
10057 override float GetItemOverheatThreshold()
10058 {
10060 return Liquid.GetBoilThreshold(GetLiquidType());
10061
10062 return super.GetItemOverheatThreshold();
10063 }
10064
10065 override float GetTemperatureFreezeTime()
10066 {
10067 if (HasQuantity())
10068 return Math.Lerp(GameConstants.TEMPERATURE_TIME_FREEZE_MIN,Math.Max(GameConstants.TEMPERATURE_TIME_FREEZE_MIN,super.GetTemperatureFreezeTime()),GetQuantityNormalized());
10069
10070 return super.GetTemperatureFreezeTime();
10071 }
10072
10073 override float GetTemperatureThawTime()
10074 {
10075 if (HasQuantity())
10076 return Math.Lerp(GameConstants.TEMPERATURE_TIME_THAW_MIN,Math.Max(GameConstants.TEMPERATURE_TIME_FREEZE_MIN,super.GetTemperatureThawTime()),GetQuantityNormalized());
10077
10078 return super.GetTemperatureThawTime();
10079 }
10080
10082 void AffectLiquidContainerOnFill(int liquid_type, float amount);
10084 void AffectLiquidContainerOnTransfer(int liquidType, float amount, float sourceLiquidTemperature);
10085
10086 bool IsCargoException4x3(EntityAI item)
10087 {
10088 return (item.IsKindOf("Cauldron") || item.IsKindOf("Pot") || item.IsKindOf("FryingPan") || item.IsKindOf("SmallProtectorCase") || (item.IsKindOf("PortableGasStove") && item.FindAttachmentBySlotName("CookingEquipment")));
10089 }
10090
10092 {
10093 MiscGameplayFunctions.TransferItemProperties(oldItem, this);
10094 }
10095
10097 void AddLightSourceItem(ItemBase lightsource)
10098 {
10099 m_LightSourceItem = lightsource;
10100 }
10101
10103 {
10104 m_LightSourceItem = null;
10105 }
10106
10108 {
10109 return m_LightSourceItem;
10110 }
10111
10113 array<int> GetValidFinishers()
10114 {
10115 return null;
10116 }
10117
10119 bool GetActionWidgetOverride(out typename name)
10120 {
10121 return false;
10122 }
10123
10124 bool PairWithDevice(notnull ItemBase otherDevice)
10125 {
10126 if (GetGame().IsServer())
10127 {
10128 ItemBase explosive = otherDevice;
10130 if (!trg)
10131 {
10132 trg = RemoteDetonatorTrigger.Cast(otherDevice);
10133 explosive = this;
10134 }
10135
10136 explosive.PairRemote(trg);
10137 trg.SetControlledDevice(explosive);
10138
10139 int persistentID = RemotelyActivatedItemBehaviour.GeneratePersistentID();
10140 trg.SetPersistentPairID(persistentID);
10141 explosive.SetPersistentPairID(persistentID);
10142
10143 return true;
10144 }
10145 return false;
10146 }
10147
10149 float GetBaitEffectivity()
10150 {
10151 float ret = 1.0;
10152 if (HasQuantity())
10153 ret *= GetQuantityNormalized();
10154 ret *= GetHealth01();
10155
10156 return ret;
10157 }
10158
10159 #ifdef DEVELOPER
10160 override void SetDebugItem()
10161 {
10162 super.SetDebugItem();
10163 _itemBase = this;
10164 }
10165
10166 override string GetDebugText()
10167 {
10168 string text = super.GetDebugText();
10169
10170 text += string.Format("Heat isolation(raw): %1\n", GetHeatIsolation());
10171 text += string.Format("Heat isolation(modified): %1\n", MiscGameplayFunctions.GetCurrentItemHeatIsolation(this));
10172
10173 return text;
10174 }
10175 #endif
10176
10177 bool CanBeUsedForSuicide()
10178 {
10179 return true;
10180 }
10181
10183 //DEPRECATED BELOW
10185 // Backwards compatibility
10186 void ProcessItemWetnessAndTemperature(float delta, bool hasParent, bool hasRootAsPlayer, ItemBase refParentIB)
10187 {
10188 ProcessItemWetness(delta, hasParent, hasRootAsPlayer, refParentIB);
10189 ProcessItemTemperature(delta, hasParent, hasRootAsPlayer, refParentIB);
10190 }
10191
10192 // replaced by ItemSoundHandler
10193 protected EffectSound m_SoundDeployFinish;
10194 protected EffectSound m_SoundPlace;
10195 protected EffectSound m_DeployLoopSoundEx;
10196 protected EffectSound m_SoundDeploy;
10197 bool m_IsPlaceSound;
10198 bool m_IsDeploySound;
10200
10201 string GetDeployFinishSoundset();
10202 void PlayDeploySound();
10203 void PlayDeployFinishSound();
10204 void PlayPlaceSound();
10205 void PlayDeployLoopSoundEx();
10206 void StopDeployLoopSoundEx();
10207 void SoundSynchRemoteReset();
10208 void SoundSynchRemote();
10209 bool UsesGlobalDeploy(){return false;}
10210 bool CanPlayDeployLoopSound(){return false;}
10212 bool IsPlaceSound(){return m_IsPlaceSound;}
10213 bool IsDeploySound(){return m_IsDeploySound;}
10214 void SetIsPlaceSound(bool is_place_sound);
10215 void SetIsDeploySound(bool is_deploy_sound);
10216}
10217
10218EntityAI SpawnItemOnLocation(string object_name, notnull InventoryLocation loc, bool full_quantity)
10219{
10220 EntityAI entity = SpawnEntity(object_name, loc, ECE_IN_INVENTORY, RF_DEFAULT);
10221 if (entity)
10222 {
10223 bool is_item = entity.IsInherited(ItemBase);
10224 if (is_item && full_quantity)
10225 {
10226 ItemBase item = ItemBase.Cast(entity);
10227 item.SetQuantity(item.GetQuantityInit());
10228 }
10229 }
10230 else
10231 {
10232 ErrorEx("Cannot spawn entity: " + object_name,ErrorExSeverity.INFO);
10233 return NULL;
10234 }
10235 return entity;
10236}
10237
10238void SetupSpawnedItem(ItemBase item, float health, float quantity)
10239{
10240 if (item)
10241 {
10242 if (health > 0)
10243 item.SetHealth("", "", health);
10244
10245 if (item.CanHaveTemperature())
10246 {
10247 item.SetTemperatureDirect(GameConstants.ITEM_TEMPERATURE_NEUTRAL_ZONE_MIDDLE);
10248 if (item.CanFreeze())
10249 item.SetFrozen(false);
10250 }
10251
10252 if (item.HasEnergyManager())
10253 {
10254 if (quantity >= 0)
10255 {
10256 item.GetCompEM().SetEnergy0To1(quantity);
10257 }
10258 else
10259 {
10260 item.GetCompEM().SetEnergy(Math.AbsFloat(quantity));
10261 }
10262 }
10263 else if (item.IsMagazine())
10264 {
10265 Magazine mag = Magazine.Cast(item);
10266 if (quantity >= 0)
10267 {
10268 mag.ServerSetAmmoCount(mag.GetAmmoMax() * quantity);
10269 }
10270 else
10271 {
10272 mag.ServerSetAmmoCount(Math.AbsFloat(quantity));
10273 }
10274
10275 }
10276 else
10277 {
10278 if (quantity >= 0)
10279 {
10280 item.SetQuantityNormalized(quantity, false);
10281 }
10282 else
10283 {
10284 item.SetQuantity(Math.AbsFloat(quantity));
10285 }
10286
10287 }
10288 }
10289}
10290
10291#ifdef DEVELOPER
10292ItemBase _itemBase;//watched item goes here(LCTRL+RMB->Watch)
10293#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()

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