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

◆ RemoveAction()

void SpawnItemOnLocation::RemoveAction ( typename actionName )
private

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

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