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

◆ AddAction()

void SpawnItemOnLocation::AddAction ( typename actionName )
private

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

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