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

◆ UpdateOverheating()

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

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

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