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

◆ CanObstruct()

override bool SpawnItemOnLocation::CanObstruct ( )
private

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

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