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

◆ SetActions()

void SpawnItemOnLocation::SetActions ( )
private

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

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