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

◆ GetActions()

override void SpawnItemOnLocation::GetActions ( typename action_input_type ,
out array< ActionBase_Basic > actions )
private

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

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