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

◆ InitItemVariables()

override void SpawnItemOnLocation::InitItemVariables ( )
private

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

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

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