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

◆ ItemBase()

void SpawnItemOnLocation::ItemBase ( )
private

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

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