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

◆ StartOverheating()

void SpawnItemOnLocation::StartOverheating ( ItemBase weapon = null,
string ammoType = "",
ItemBase muzzle_owner = null,
ItemBase suppressor = null,
string config_to_search = "" )
private

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

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

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