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

◆ InitItemVariables()

override void SpawnItemOnLocation::InitItemVariables ( )
private

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

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

Используется в Entity::EntityAI().