DayZ 1.29
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 строка 5486

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

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