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

◆ GetQuickBarBonus()

override int SpawnItemOnLocation::GetQuickBarBonus ( )
private

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

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