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

◆ GetQuickBarBonus()

override int SpawnItemOnLocation::GetQuickBarBonus ( )
private

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

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