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

◆ CheckOverheating()

void SpawnItemOnLocation::CheckOverheating ( ItemBase weapon = null,
string ammoType = "",
ItemBase muzzle_owner = null,
ItemBase suppressor = null,
string config_to_search = "" )
private

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

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

Используется в InventoryItem::IncreaseOverheating() и InventoryItem::OnOverheatingDecay().