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

◆ InitializeActions()

void SpawnItemOnLocation::InitializeActions ( )
private

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

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