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

◆ GetDebugActionsMask()

static int SpawnItemOnLocation::GetDebugActionsMask ( )
staticprivate

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

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