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

◆ InitializeActions()

void SpawnItemOnLocation::InitializeActions ( )
private

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

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