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

◆ OverrideActionAnimation()

void SpawnItemOnLocation::OverrideActionAnimation ( typename action ,
int commandUID,
int stanceMask = -1,
int commandUIDProne = -1 )
private

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

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

Используется в FarmingHoe::SetActionAnimOverrides() и ItemBase::SetActionAnimOverrides().