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

◆ AddAction()

void SpawnItemOnLocation::AddAction ( typename actionName )
private

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

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