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

◆ AllowFoodConsumption()

bool SpawnItemOnLocation::AllowFoodConsumption ( )
protected

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

8620{
8621 override bool CanPutAsAttachment(EntityAI parent)
8622 {
8623 return true;
8624 }
8625};
8626
8627//const bool QUANTITY_DEBUG_REMOVE_ME = false;
8628
8629class ItemBase extends InventoryItem
8630{
8634
8636
8637 static int m_DebugActionsMask;
8639 // ============================================
8640 // Variable Manipulation System
8641 // ============================================
8642 // Quantity
8643
8644 float m_VarQuantity;
8645 float m_VarQuantityPrev;//for client to know quantity changed during synchronization
8647 int m_VarQuantityMin;
8648 int m_VarQuantityMax;
8649 int m_Count;
8650 float m_VarStackMax;
8651 float m_StoreLoadedQuantity = float.LOWEST;
8652 // Wet
8653 float m_VarWet;
8654 float m_VarWetPrev;//for client to know wetness changed during synchronization
8655 float m_VarWetInit;
8656 float m_VarWetMin;
8657 float m_VarWetMax;
8658 // Cleanness
8659 int m_Cleanness;
8660 int m_CleannessInit;
8661 int m_CleannessMin;
8662 int m_CleannessMax;
8663 // impact sounds
8665 bool m_CanPlayImpactSound = true;
8666 float m_ImpactSpeed;
8668 //
8669 float m_HeatIsolation;
8670 float m_ItemModelLength;
8671 float m_ItemAttachOffset; // Offset length for when the item is attached e.g. to weapon
8673 int m_VarLiquidType;
8674 int m_ItemBehaviour; // -1 = not specified; 0 = heavy item; 1= onehanded item; 2 = twohanded item
8675 int m_QuickBarBonus;
8676 bool m_IsBeingPlaced;
8677 bool m_IsHologram;
8678 bool m_IsTakeable;
8679 bool m_ThrowItemOnDrop;
8682 bool m_FixDamageSystemInit = false; //can be changed on storage version check
8683 bool can_this_be_combined; //Check if item can be combined
8684 bool m_CanThisBeSplit; //Check if item can be split
8685 bool m_IsStoreLoad = false;
8686 bool m_CanShowQuantity;
8687 bool m_HasQuantityBar;
8688 protected bool m_CanBeDigged;
8689 protected bool m_IsResultOfSplit
8690
8691 string m_SoundAttType;
8692 // items color variables
8697 //-------------------------------------------------------
8698
8699 // light source managing
8701
8705
8706 //==============================================
8707 // agent system
8708 private int m_AttachedAgents;
8709
8711 void TransferModifiers(PlayerBase reciever);
8712
8713
8714 // Weapons & suppressors particle effects
8719 static int m_LastRegisteredWeaponID = 0;
8720
8721 // Overheating effects
8723 float m_OverheatingShots;
8724 ref Timer m_CheckOverheating;
8725 int m_ShotsToStartOverheating = 0; // After these many shots, the overheating effect begins
8726 int m_MaxOverheatingValue = 0; // Limits the number of shots that will be tracked
8727 float m_OverheatingDecayInterval = 1; // Timer's interval for decrementing overheat effect's lifespan
8728 ref array <ref OverheatingParticle> m_OverheatingParticles;
8729
8731 protected bool m_HideSelectionsBySlot;
8732
8733 // Admin Log
8734 PluginAdminLog m_AdminLog;
8735
8736 // misc
8737 ref Timer m_PhysDropTimer;
8738
8739 // Attachment Locking variables
8740 ref array<int> m_CompatibleLocks;
8741 protected int m_LockType;
8742 protected ref EffectSound m_LockingSound;
8743 protected string m_LockSoundSet;
8744
8745 // ItemSoundHandler
8746 protected const int ITEM_SOUNDS_MAX = 63; // optimize network synch
8747 protected int m_SoundSyncPlay; // id for sound to play
8748 protected int m_SoundSyncStop; // id for sound to stop
8750
8751 //temperature
8752 private float m_TemperaturePerQuantityWeight;
8753
8754 // -------------------------------------------------------------------------
8755 void ItemBase()
8756 {
8757 SetEventMask(EntityEvent.INIT); // Enable EOnInit event
8761
8762 if (!GetGame().IsDedicatedServer())
8763 {
8764 if (HasMuzzle())
8765 {
8767
8769 {
8771 }
8772 }
8773
8775 m_ActionsInitialize = false;
8776 }
8777
8778 m_OldLocation = null;
8779
8780 if (GetGame().IsServer())
8781 {
8782 m_AdminLog = PluginAdminLog.Cast(GetPlugin(PluginAdminLog));
8783 }
8784
8785 if (ConfigIsExisting("headSelectionsToHide"))
8786 {
8788 ConfigGetTextArray("headSelectionsToHide",m_HeadHidingSelections);
8789 }
8790
8791 m_HideSelectionsBySlot = false;
8792 if (ConfigIsExisting("hideSelectionsByinventorySlot"))
8793 {
8794 m_HideSelectionsBySlot = ConfigGetBool("hideSelectionsByinventorySlot");
8795 }
8796
8797 m_QuickBarBonus = Math.Max(0, ConfigGetInt("quickBarBonus"));
8798
8799 m_IsResultOfSplit = false;
8800
8802 }
8803
8804 override void InitItemVariables()
8805 {
8806 super.InitItemVariables();
8807
8808 m_VarQuantityInit = ConfigGetInt("varQuantityInit");
8809 m_VarQuantity = m_VarQuantityInit;//should be by the CE, this is just a precaution
8810 m_VarQuantityMin = ConfigGetInt("varQuantityMin");
8811 m_VarQuantityMax = ConfigGetInt("varQuantityMax");
8812 m_VarStackMax = ConfigGetFloat("varStackMax");
8813 m_Count = ConfigGetInt("count");
8814
8815 m_CanShowQuantity = ConfigGetBool("quantityShow");
8816 m_HasQuantityBar = ConfigGetBool("quantityBar");
8817
8818 m_CleannessInit = ConfigGetInt("varCleannessInit");
8820 m_CleannessMin = ConfigGetInt("varCleannessMin");
8821 m_CleannessMax = ConfigGetInt("varCleannessMax");
8822
8823 m_WantPlayImpactSound = false;
8824 m_ImpactSpeed = 0.0;
8825
8826 m_VarWetInit = ConfigGetFloat("varWetInit");
8828 m_VarWetMin = ConfigGetFloat("varWetMin");
8829 m_VarWetMax = ConfigGetFloat("varWetMax");
8830
8831 m_LiquidContainerMask = ConfigGetInt("liquidContainerType");
8832 if (IsLiquidContainer() && GetQuantity() != 0)
8834 m_IsBeingPlaced = false;
8835 m_IsHologram = false;
8836 m_IsTakeable = true;
8837 m_CanBeMovedOverride = false;
8841 m_CanBeDigged = ConfigGetBool("canBeDigged");
8842
8843 m_CompatibleLocks = new array<int>();
8844 ConfigGetIntArray("compatibleLocks", m_CompatibleLocks);
8845 m_LockType = ConfigGetInt("lockType");
8846
8847 //Define if item can be split and set ability to be combined accordingly
8848 m_CanThisBeSplit = false;
8849 can_this_be_combined = false;
8850 if (ConfigIsExisting("canBeSplit"))
8851 {
8852 can_this_be_combined = ConfigGetBool("canBeSplit");
8854 }
8855
8856 m_ItemBehaviour = -1;
8857 if (ConfigIsExisting("itemBehaviour"))
8858 m_ItemBehaviour = ConfigGetInt("itemBehaviour");
8859
8860 //RegisterNetSyncVariableInt("m_VariablesMask");
8861 if (HasQuantity()) RegisterNetSyncVariableFloat("m_VarQuantity", GetQuantityMin(), m_VarQuantityMax);
8862 RegisterNetSyncVariableFloat("m_VarWet", GetWetMin(), GetWetMax(), 2);
8863 RegisterNetSyncVariableInt("m_VarLiquidType");
8864 RegisterNetSyncVariableInt("m_Cleanness",0,1);
8865
8866 RegisterNetSyncVariableBoolSignal("m_WantPlayImpactSound");
8867 RegisterNetSyncVariableFloat("m_ImpactSpeed");
8868 RegisterNetSyncVariableInt("m_ImpactSoundSurfaceHash");
8869
8870 RegisterNetSyncVariableInt("m_ColorComponentR", 0, 255);
8871 RegisterNetSyncVariableInt("m_ColorComponentG", 0, 255);
8872 RegisterNetSyncVariableInt("m_ColorComponentB", 0, 255);
8873 RegisterNetSyncVariableInt("m_ColorComponentA", 0, 255);
8874
8875 RegisterNetSyncVariableBool("m_IsBeingPlaced");
8876 RegisterNetSyncVariableBool("m_IsTakeable");
8877 RegisterNetSyncVariableBool("m_IsHologram");
8878
8879 InitItemSounds();
8881 {
8882 RegisterNetSyncVariableInt("m_SoundSyncPlay", 0, ITEM_SOUNDS_MAX);
8883 RegisterNetSyncVariableInt("m_SoundSyncStop", 0, ITEM_SOUNDS_MAX);
8884 }
8885
8886 m_LockSoundSet = ConfigGetString("lockSoundSet");
8887
8889 if (ConfigIsExisting("temperaturePerQuantityWeight"))
8890 m_TemperaturePerQuantityWeight = ConfigGetFloat("temperaturePerQuantityWeight");
8891
8892 }
8893
8894 override int GetQuickBarBonus()
8895 {
8896 return m_QuickBarBonus;
8897 }
8898
8899 void InitializeActions()
8900 {
8902 if (!m_InputActionMap)
8903 {
8905 m_InputActionMap = iam;
8906 SetActions();
8908 }
8909 }
8910
8911 override void GetActions(typename action_input_type, out array<ActionBase_Basic> actions)
8912 {
8914 {
8915 m_ActionsInitialize = true;
8917 }
8918
8919 actions = m_InputActionMap.Get(action_input_type);
8920 }
8921
8922 void SetActions()
8923 {
8924 AddAction(ActionTakeItem);
8925 AddAction(ActionTakeItemToHands);
8926 AddAction(ActionWorldCraft);
8928 AddAction(ActionAttachWithSwitch);
8929 }
8930
8931 void SetActionAnimOverrides(); // Override action animation for specific item
8932
8933 void AddAction(typename actionName)
8934 {
8935 ActionBase action = ActionManagerBase.GetAction(actionName);
8936
8937 if (!action)
8938 {
8939 Debug.LogError("Action " + actionName + " dosn't exist!");
8940 return;
8941 }
8942
8943 typename ai = action.GetInputType();
8944 if (!ai)
8945 {
8946 m_ActionsInitialize = false;
8947 return;
8948 }
8949
8950 array<ActionBase_Basic> action_array = m_InputActionMap.Get(ai);
8951 if (!action_array)
8952 {
8953 action_array = new array<ActionBase_Basic>;
8954 m_InputActionMap.Insert(ai, action_array);
8955 }
8956 if (LogManager.IsActionLogEnable())
8957 {
8958 Debug.ActionLog(action.ToString() + " -> " + ai, this.ToString() , "n/a", "Add action");
8959 }
8960
8961 if (action_array.Find(action) != -1)
8962 {
8963 Debug.Log("Action " + action.Type() + " already added to " + this + ", skipping!");
8964 }
8965 else
8966 {
8967 action_array.Insert(action);
8968 }
8969 }
8970
8971 void RemoveAction(typename actionName)
8972 {
8973 PlayerBase player = PlayerBase.Cast(GetGame().GetPlayer());
8974 ActionBase action = player.GetActionManager().GetAction(actionName);
8975 typename ai = action.GetInputType();
8976 array<ActionBase_Basic> action_array = m_InputActionMap.Get(ai);
8977
8978 if (action_array)
8979 {
8980 action_array.RemoveItem(action);
8981 }
8982 }
8983
8984 // Allows override of default action command per item, defined in the SetActionAnimOverrides() of the item's class
8985 // Set -1 for params which should stay in default state
8986 void OverrideActionAnimation(typename action, int commandUID, int stanceMask = -1, int commandUIDProne = -1)
8987 {
8988 ActionOverrideData overrideData = new ActionOverrideData();
8989 overrideData.m_CommandUID = commandUID;
8990 overrideData.m_CommandUIDProne = commandUIDProne;
8991 overrideData.m_StanceMask = stanceMask;
8992
8993 TActionAnimOverrideMap actionMap = m_ItemActionOverrides.Get(action);
8994 if (!actionMap) // create new map of action > overidables map
8995 {
8996 actionMap = new TActionAnimOverrideMap();
8997 m_ItemActionOverrides.Insert(action, actionMap);
8998 }
8999
9000 actionMap.Insert(this.Type(), overrideData); // insert item -> overrides
9001
9002 }
9003
9004 void OnItemInHandsPlayerSwimStart(PlayerBase player);
9005
9006 ScriptedLightBase GetLight();
9007
9008 // Loads muzzle flash particle configuration from config and saves it to a map for faster access
9009 void LoadParticleConfigOnFire(int id)
9010 {
9011 if (!m_OnFireEffect)
9013
9016
9017 string config_to_search = "CfgVehicles";
9018 string muzzle_owner_config;
9019
9020 if (!m_OnFireEffect.Contains(id))
9021 {
9022 if (IsInherited(Weapon))
9023 config_to_search = "CfgWeapons";
9024
9025 muzzle_owner_config = config_to_search + " " + GetType() + " ";
9026
9027 string config_OnFire_class = muzzle_owner_config + "Particles " + "OnFire ";
9028
9029 int config_OnFire_subclass_count = GetGame().ConfigGetChildrenCount(config_OnFire_class);
9030
9031 if (config_OnFire_subclass_count > 0)
9032 {
9033 array<ref WeaponParticlesOnFire> WPOF_array = new array<ref WeaponParticlesOnFire>;
9034
9035 for (int i = 0; i < config_OnFire_subclass_count; i++)
9036 {
9037 string particle_class = "";
9038 GetGame().ConfigGetChildName(config_OnFire_class, i, particle_class);
9039 string config_OnFire_entry = config_OnFire_class + particle_class;
9040 WeaponParticlesOnFire WPOF = new WeaponParticlesOnFire(this, config_OnFire_entry);
9041 WPOF_array.Insert(WPOF);
9042 }
9043
9044
9045 m_OnFireEffect.Insert(id, WPOF_array);
9046 }
9047 }
9048
9049 if (!m_OnBulletCasingEjectEffect.Contains(id))
9050 {
9051 config_to_search = "CfgWeapons"; // Bullet Eject efect is supported on weapons only.
9052 muzzle_owner_config = config_to_search + " " + GetType() + " ";
9053
9054 string config_OnBulletCasingEject_class = muzzle_owner_config + "Particles " + "OnBulletCasingEject ";
9055
9056 int config_OnBulletCasingEject_count = GetGame().ConfigGetChildrenCount(config_OnBulletCasingEject_class);
9057
9058 if (config_OnBulletCasingEject_count > 0 && IsInherited(Weapon))
9059 {
9060 array<ref WeaponParticlesOnBulletCasingEject> WPOBE_array = new array<ref WeaponParticlesOnBulletCasingEject>;
9061
9062 for (i = 0; i < config_OnBulletCasingEject_count; i++)
9063 {
9064 string particle_class2 = "";
9065 GetGame().ConfigGetChildName(config_OnBulletCasingEject_class, i, particle_class2);
9066 string config_OnBulletCasingEject_entry = config_OnBulletCasingEject_class + particle_class2;
9067 WeaponParticlesOnBulletCasingEject WPOBE = new WeaponParticlesOnBulletCasingEject(this, config_OnBulletCasingEject_entry);
9068 WPOBE_array.Insert(WPOBE);
9069 }
9070
9071
9072 m_OnBulletCasingEjectEffect.Insert(id, WPOBE_array);
9073 }
9074 }
9075 }
9076
9077 // Loads muzzle flash particle configuration from config and saves it to a map for faster access
9079 {
9082
9083 if (!m_OnOverheatingEffect.Contains(id))
9084 {
9085 string config_to_search = "CfgVehicles";
9086
9087 if (IsInherited(Weapon))
9088 config_to_search = "CfgWeapons";
9089
9090 string muzzle_owner_config = config_to_search + " " + GetType() + " ";
9091 string config_OnOverheating_class = muzzle_owner_config + "Particles " + "OnOverheating ";
9092
9093 if (GetGame().ConfigIsExisting(config_OnOverheating_class))
9094 {
9095
9096 m_ShotsToStartOverheating = GetGame().ConfigGetFloat(config_OnOverheating_class + "shotsToStartOverheating");
9097
9099 {
9100 m_ShotsToStartOverheating = -1; // This prevents futher readings from config for future creations of this item
9101 string error = "Error reading config " + GetType() + ">Particles>OnOverheating - Parameter shotsToStartOverheating is configured wrong or is missing! Its value must be 1 or higher!";
9102 Error(error);
9103 return;
9104 }
9105
9106 m_OverheatingDecayInterval = GetGame().ConfigGetFloat(config_OnOverheating_class + "overheatingDecayInterval");
9107 m_MaxOverheatingValue = GetGame().ConfigGetFloat(config_OnOverheating_class + "maxOverheatingValue");
9108
9109
9110
9111 int config_OnOverheating_subclass_count = GetGame().ConfigGetChildrenCount(config_OnOverheating_class);
9112 array<ref WeaponParticlesOnOverheating> WPOOH_array = new array<ref WeaponParticlesOnOverheating>;
9113
9114 for (int i = 0; i < config_OnOverheating_subclass_count; i++)
9115 {
9116 string particle_class = "";
9117 GetGame().ConfigGetChildName(config_OnOverheating_class, i, particle_class);
9118 string config_OnOverheating_entry = config_OnOverheating_class + particle_class;
9119 int entry_type = GetGame().ConfigGetType(config_OnOverheating_entry);
9120
9121 if (entry_type == CT_CLASS)
9122 {
9123 WeaponParticlesOnOverheating WPOF = new WeaponParticlesOnOverheating(this, config_OnOverheating_entry);
9124 WPOOH_array.Insert(WPOF);
9125 }
9126 }
9127
9128
9129 m_OnOverheatingEffect.Insert(id, WPOOH_array);
9130 }
9131 }
9132 }
9133
9134 float GetOverheatingValue()
9135 {
9136 return m_OverheatingShots;
9137 }
9138
9139 void IncreaseOverheating(ItemBase weapon, string ammoType, ItemBase muzzle_owner, ItemBase suppressor, string config_to_search)
9140 {
9141 if (m_MaxOverheatingValue > 0)
9142 {
9144
9145 if (!m_CheckOverheating)
9147
9149 m_CheckOverheating.Run(m_OverheatingDecayInterval, this, "OnOverheatingDecay");
9150
9151 CheckOverheating(weapon, ammoType, muzzle_owner, suppressor, config_to_search);
9152 }
9153 }
9154
9155 void CheckOverheating(ItemBase weapon = null, string ammoType = "", ItemBase muzzle_owner = null, ItemBase suppressor = null, string config_to_search = "")
9156 {
9158 UpdateOverheating(weapon, ammoType, muzzle_owner, suppressor, config_to_search);
9159
9161 StartOverheating(weapon, ammoType, muzzle_owner, suppressor, config_to_search);
9162
9164 StopOverheating(weapon, ammoType, muzzle_owner, suppressor, config_to_search);
9165
9167 {
9169 }
9170 }
9171
9173 {
9175 }
9176
9177 void OnOverheatingDecay()
9178 {
9179 if (m_MaxOverheatingValue > 0)
9180 m_OverheatingShots -= 1 + m_OverheatingShots / m_MaxOverheatingValue; // The hotter a barrel is, the faster it needs to cool down.
9181 else
9183
9184 if (m_OverheatingShots <= 0)
9185 {
9188 }
9189 else
9190 {
9191 if (!m_CheckOverheating)
9193
9195 m_CheckOverheating.Run(m_OverheatingDecayInterval, this, "OnOverheatingDecay");
9196 }
9197
9198 CheckOverheating(this, "", this);
9199 }
9200
9201 void StartOverheating(ItemBase weapon = null, string ammoType = "", ItemBase muzzle_owner = null, ItemBase suppressor = null, string config_to_search = "")
9202 {
9204 ItemBase.PlayOverheatingParticles(this, ammoType, this, suppressor, "CfgWeapons");
9205 }
9206
9207 void UpdateOverheating(ItemBase weapon = null, string ammoType = "", ItemBase muzzle_owner = null, ItemBase suppressor = null, string config_to_search = "")
9208 {
9210 ItemBase.UpdateOverheatingParticles(this, ammoType, this, suppressor, "CfgWeapons");
9212 }
9213
9214 void StopOverheating(ItemBase weapon = null, string ammoType = "", ItemBase muzzle_owner = null, ItemBase suppressor = null, string config_to_search = "")
9215 {
9217 ItemBase.StopOverheatingParticles(weapon, ammoType, muzzle_owner, suppressor, config_to_search);
9218 }
9219
9220 void RegisterOverheatingParticle(Particle p, float min_heat_coef, float max_heat_coef, int particle_id, Object parent, vector local_pos, vector local_ori)
9221 {
9223 m_OverheatingParticles = new array<ref OverheatingParticle>;
9224
9225 OverheatingParticle OP = new OverheatingParticle();
9226 OP.RegisterParticle(p);
9227 OP.SetOverheatingLimitMin(min_heat_coef);
9228 OP.SetOverheatingLimitMax(max_heat_coef);
9229 OP.SetParticleParams(particle_id, parent, local_pos, local_ori);
9230
9231 m_OverheatingParticles.Insert(OP);
9232 }
9233
9234 float GetOverheatingCoef()
9235 {
9236 if (m_MaxOverheatingValue > 0)
9238
9239 return -1;
9240 }
9241
9243 {
9245 {
9246 float overheat_coef = GetOverheatingCoef();
9247 int count = m_OverheatingParticles.Count();
9248
9249 for (int i = count; i > 0; --i)
9250 {
9251 int id = i - 1;
9252 OverheatingParticle OP = m_OverheatingParticles.Get(id);
9253 Particle p = OP.GetParticle();
9254
9255 float overheat_min = OP.GetOverheatingLimitMin();
9256 float overheat_max = OP.GetOverheatingLimitMax();
9257
9258 if (overheat_coef < overheat_min && overheat_coef >= overheat_max)
9259 {
9260 if (p)
9261 {
9262 p.Stop();
9263 OP.RegisterParticle(null);
9264 }
9265 }
9266 }
9267 }
9268 }
9269
9271 {
9273 {
9274 for (int i = m_OverheatingParticles.Count(); i > 0; i--)
9275 {
9276 int id = i - 1;
9277 OverheatingParticle OP = m_OverheatingParticles.Get(id);
9278
9279 if (OP)
9280 {
9281 Particle p = OP.GetParticle();
9282
9283 if (p)
9284 {
9285 p.Stop();
9286 }
9287
9288 delete OP;
9289 }
9290 }
9291
9292 m_OverheatingParticles.Clear();
9294 }
9295 }
9296
9298 float GetInfectionChance(int system = 0, Param param = null)
9299 {
9300 return 0.0;
9301 }
9302
9303
9304 float GetDisinfectQuantity(int system = 0, Param param1 = null)
9305 {
9306 return 250;//default value
9307 }
9308
9309 float GetFilterDamageRatio()
9310 {
9311 return 0;
9312 }
9313
9315 bool HasMuzzle()
9316 {
9317 if (IsInherited(Weapon) || IsInherited(SuppressorBase))
9318 return true;
9319
9320 return false;
9321 }
9322
9324 int GetMuzzleID()
9325 {
9326 if (!m_WeaponTypeToID)
9328
9329 if (m_WeaponTypeToID.Contains(GetType()))
9330 {
9331 return m_WeaponTypeToID.Get(GetType());
9332 }
9333 else
9334 {
9335 // Register new weapon ID
9337 }
9338
9340 }
9341
9348 {
9349 return -1;
9350 }
9351
9352
9353
9354 // -------------------------------------------------------------------------
9355 void ~ItemBase()
9356 {
9357 if (GetGame() && GetGame().GetPlayer() && (!GetGame().IsDedicatedServer()))
9358 {
9359 PlayerBase player = PlayerBase.Cast(GetGame().GetPlayer());
9360 int r_index = player.GetHumanInventory().FindUserReservedLocationIndex(this);
9361
9362 if (r_index >= 0)
9363 {
9364 InventoryLocation r_il = new InventoryLocation;
9365 player.GetHumanInventory().GetUserReservedLocation(r_index,r_il);
9366
9367 player.GetHumanInventory().ClearUserReservedLocationAtIndex(r_index);
9368 int r_type = r_il.GetType();
9369 if (r_type == InventoryLocationType.CARGO || r_type == InventoryLocationType.PROXYCARGO)
9370 {
9371 r_il.GetParent().GetOnReleaseLock().Invoke(this);
9372 }
9373 else if (r_type == InventoryLocationType.ATTACHMENT)
9374 {
9375 r_il.GetParent().GetOnAttachmentReleaseLock().Invoke(this, r_il.GetSlot());
9376 }
9377
9378 }
9379
9380 player.GetHumanInventory().ClearUserReservedLocation(this);
9381 }
9382
9383 if (m_LockingSound)
9384 SEffectManager.DestroyEffect(m_LockingSound);
9385 }
9386
9387
9388
9389 // -------------------------------------------------------------------------
9390 static int GetDebugActionsMask()
9391 {
9392 return ItemBase.m_DebugActionsMask;
9393 }
9394
9395 static bool HasDebugActionsMask(int mask)
9396 {
9397 return ItemBase.m_DebugActionsMask & mask;
9398 }
9399
9400 static void SetDebugActionsMask(int mask)
9401 {
9402 ItemBase.m_DebugActionsMask = mask;
9403 }
9404
9405 static void AddDebugActionsMask(int mask)
9406 {
9407 ItemBase.m_DebugActionsMask |= mask;
9408 }
9409
9410 static void RemoveDebugActionsMask(int mask)
9411 {
9412 ItemBase.m_DebugActionsMask &= ~mask;
9413 }
9414
9415 static void ToggleDebugActionsMask(int mask)
9416 {
9417 if (HasDebugActionsMask(mask))
9418 {
9420 }
9421 else
9422 {
9423 AddDebugActionsMask(mask);
9424 }
9425 }
9426
9427 // -------------------------------------------------------------------------
9428 void SetCEBasedQuantity()
9429 {
9430 if (GetEconomyProfile())
9431 {
9432 float q_max = GetEconomyProfile().GetQuantityMax();
9433 if (q_max > 0)
9434 {
9435 float q_min = GetEconomyProfile().GetQuantityMin();
9436 float quantity_randomized = Math.RandomFloatInclusive(q_min, q_max);
9437
9438 if (HasComponent(COMP_TYPE_ENERGY_MANAGER))//more direct access for speed
9439 {
9440 ComponentEnergyManager comp = GetCompEM();
9441 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
9442 {
9443 comp.SetEnergy0To1(quantity_randomized);
9444 }
9445 }
9446 else if (HasQuantity())
9447 {
9448 SetQuantityNormalized(quantity_randomized, false);
9449 //PrintString("<==> Normalized quantity for item: "+ GetType()+", qmin:"+q_min.ToString()+"; qmax:"+q_max.ToString()+";quantity:" +quantity_randomized.ToString());
9450 }
9451
9452 }
9453 }
9454 }
9455
9457 void LockToParent()
9458 {
9459 EntityAI parent = GetHierarchyParent();
9460
9461 if (parent)
9462 {
9463 InventoryLocation inventory_location_to_lock = new InventoryLocation;
9464 GetInventory().GetCurrentInventoryLocation(inventory_location_to_lock);
9465 parent.GetInventory().SetSlotLock(inventory_location_to_lock.GetSlot(), true);
9466 }
9467 }
9468
9470 void UnlockFromParent()
9471 {
9472 EntityAI parent = GetHierarchyParent();
9473
9474 if (parent)
9475 {
9476 InventoryLocation inventory_location_to_unlock = new InventoryLocation;
9477 GetInventory().GetCurrentInventoryLocation(inventory_location_to_unlock);
9478 parent.GetInventory().SetSlotLock(inventory_location_to_unlock.GetSlot(), false);
9479 }
9480 }
9481
9482 override void CombineItemsClient(EntityAI entity2, bool use_stack_max = true)
9483 {
9484 /*
9485 ref Param1<EntityAI> item = new Param1<EntityAI>(entity2);
9486 RPCSingleParam(ERPCs.RPC_ITEM_COMBINE, item, GetGame().GetPlayer());
9487 */
9488 ItemBase item2 = ItemBase.Cast(entity2);
9489
9490 if (GetGame().IsClient())
9491 {
9492 if (ScriptInputUserData.CanStoreInputUserData())
9493 {
9494 ScriptInputUserData ctx = new ScriptInputUserData;
9496 ctx.Write(-1);
9497 ItemBase i1 = this; // @NOTE: workaround for correct serialization
9498 ctx.Write(i1);
9499 ctx.Write(item2);
9500 ctx.Write(use_stack_max);
9501 ctx.Write(-1);
9502 ctx.Send();
9503
9504 if (IsCombineAll(item2, use_stack_max))
9505 {
9506 GetGame().GetPlayer().GetInventory().AddInventoryReservationEx(item2,null,GameInventory.c_InventoryReservationTimeoutShortMS);
9507 }
9508 }
9509 }
9510 else if (!GetGame().IsMultiplayer())
9511 {
9512 CombineItems(item2, use_stack_max);
9513 }
9514 }
9515
9516 bool IsLiquidPresent()
9517 {
9518 return (GetLiquidType() != 0 && HasQuantity());
9519 }
9520
9521 bool IsLiquidContainer()
9522 {
9523 return m_LiquidContainerMask != 0;
9524 }
9525
9527 {
9528 return m_LiquidContainerMask;
9529 }
9530
9531 bool IsBloodContainer()
9532 {
9533 //m_LiquidContainerMask & GROUP_LIQUID_BLOOD ???
9534 return false;
9535 }
9536
9537 bool IsNVG()
9538 {
9539 return false;
9540 }
9541
9544 bool IsExplosive()
9545 {
9546 return false;
9547 }
9548
9550 {
9551 return "";
9552 }
9553
9555
9556 bool IsLightSource()
9557 {
9558 return false;
9559 }
9560
9562 {
9563 return true;
9564 }
9565
9566 //--- ACTION CONDITIONS
9567 //direction
9568 bool IsFacingPlayer(PlayerBase player, string selection)
9569 {
9570 return true;
9571 }
9572
9573 bool IsPlayerInside(PlayerBase player, string selection)
9574 {
9575 return true;
9576 }
9577
9578 override bool CanObstruct()
9579 {
9580 PlayerBase player = PlayerBase.Cast(g_Game.GetPlayer());
9581 return !player || !IsPlayerInside(player, "");
9582 }
9583
9584 override bool IsBeingPlaced()
9585 {
9586 return m_IsBeingPlaced;
9587 }
9588
9589 void SetIsBeingPlaced(bool is_being_placed)
9590 {
9591 m_IsBeingPlaced = is_being_placed;
9592 if (!is_being_placed)
9594 SetSynchDirty();
9595 }
9596
9597 //server-side
9598 void OnEndPlacement() {}
9599
9600 override bool IsHologram()
9601 {
9602 return m_IsHologram;
9603 }
9604
9605 bool CanBeDigged()
9606 {
9607 return m_CanBeDigged;
9608 }
9609
9611 {
9612 return 1;
9613 }
9614
9615 bool CanMakeGardenplot()
9616 {
9617 return false;
9618 }
9619
9620 void SetIsHologram(bool is_hologram)
9621 {
9622 m_IsHologram = is_hologram;
9623 SetSynchDirty();
9624 }
9625 /*
9626 protected float GetNutritionalEnergy()
9627 {
9628 Edible_Base edible = Edible_Base.Cast(this);
9629 return edible.GetFoodEnergy();
9630 }
9631
9632 protected float GetNutritionalWaterContent()
9633 {
9634 Edible_Base edible = Edible_Base.Cast(this);
9635 return edible.GetFoodWater();
9636 }
9637
9638 protected float GetNutritionalIndex()
9639 {
9640 Edible_Base edible = Edible_Base.Cast(this);
9641 return edible.GetFoodNutritionalIndex();
9642 }
9643
9644 protected float GetNutritionalFullnessIndex()
9645 {
9646 Edible_Base edible = Edible_Base.Cast(this);
9647 return edible.GetFoodTotalVolume();
9648 }
9649
9650 protected float GetNutritionalToxicity()
9651 {
9652 Edible_Base edible = Edible_Base.Cast(this);
9653 return edible.GetFoodToxicity();
9654
9655 }
9656 */
9657
9658
9659 // -------------------------------------------------------------------------
9660 override void OnMovedInsideCargo(EntityAI container)
9661 {
9662 super.OnMovedInsideCargo(container);
9663
9664 MiscGameplayFunctions.RemoveAllAttachedChildrenByTypename(this, {Bolt_Base});
9665 }
9666
9667 override void EEItemLocationChanged(notnull InventoryLocation oldLoc, notnull InventoryLocation newLoc)
9668 {
9669 super.EEItemLocationChanged(oldLoc,newLoc);
9670
9671 PlayerBase new_player = null;
9672 PlayerBase old_player = null;
9673
9674 if (newLoc.GetParent())
9675 new_player = PlayerBase.Cast(newLoc.GetParent().GetHierarchyRootPlayer());
9676
9677 if (oldLoc.GetParent())
9678 old_player = PlayerBase.Cast(oldLoc.GetParent().GetHierarchyRootPlayer());
9679
9680 if (old_player && oldLoc.GetType() == InventoryLocationType.HANDS)
9681 {
9682 int r_index = old_player.GetHumanInventory().FindUserReservedLocationIndex(this);
9683
9684 if (r_index >= 0)
9685 {
9686 InventoryLocation r_il = new InventoryLocation;
9687 old_player.GetHumanInventory().GetUserReservedLocation(r_index,r_il);
9688
9689 old_player.GetHumanInventory().ClearUserReservedLocationAtIndex(r_index);
9690 int r_type = r_il.GetType();
9691 if (r_type == InventoryLocationType.CARGO || r_type == InventoryLocationType.PROXYCARGO)
9692 {
9693 r_il.GetParent().GetOnReleaseLock().Invoke(this);
9694 }
9695 else if (r_type == InventoryLocationType.ATTACHMENT)
9696 {
9697 r_il.GetParent().GetOnAttachmentReleaseLock().Invoke(this, r_il.GetSlot());
9698 }
9699
9700 }
9701 }
9702
9703 if (newLoc.GetType() == InventoryLocationType.HANDS)
9704 {
9705 if (new_player)
9706 new_player.ForceStandUpForHeavyItems(newLoc.GetItem());
9707
9708 if (new_player == old_player)
9709 {
9710
9711 if (oldLoc.GetParent() && new_player.GetHumanInventory().LocationGetEntity(oldLoc) == NULL)
9712 {
9713 if (oldLoc.GetType() == InventoryLocationType.CARGO)
9714 {
9715 if (oldLoc.GetParent().GetInventory().TestAddEntityInCargoExLoc(oldLoc, false, false, false, true, false, false))
9716 {
9717 new_player.GetHumanInventory().SetUserReservedLocation(this,oldLoc);
9718 }
9719 }
9720 else
9721 {
9722 new_player.GetHumanInventory().SetUserReservedLocation(this,oldLoc);
9723 }
9724 }
9725
9726 if (new_player.GetHumanInventory().FindUserReservedLocationIndex(this) >= 0)
9727 {
9728 int type = oldLoc.GetType();
9729 if (type == InventoryLocationType.CARGO || type == InventoryLocationType.PROXYCARGO)
9730 {
9731 oldLoc.GetParent().GetOnSetLock().Invoke(this);
9732 }
9733 else if (type == InventoryLocationType.ATTACHMENT)
9734 {
9735 oldLoc.GetParent().GetOnAttachmentSetLock().Invoke(this, oldLoc.GetSlot());
9736 }
9737 }
9738 if (!m_OldLocation)
9739 {
9740 m_OldLocation = new InventoryLocation;
9741 }
9742 m_OldLocation.Copy(oldLoc);
9743 }
9744 else
9745 {
9746 if (m_OldLocation)
9747 {
9748 m_OldLocation.Reset();
9749 }
9750 }
9751
9753 }
9754 else
9755 {
9756 if (new_player)
9757 {
9758 int res_index = new_player.GetHumanInventory().FindCollidingUserReservedLocationIndex(this, newLoc);
9759 if (res_index >= 0)
9760 {
9761 InventoryLocation il = new InventoryLocation;
9762 new_player.GetHumanInventory().GetUserReservedLocation(res_index,il);
9763 ItemBase it = ItemBase.Cast(il.GetItem());
9764 new_player.GetHumanInventory().ClearUserReservedLocationAtIndex(res_index);
9765 int rel_type = il.GetType();
9766 if (rel_type == InventoryLocationType.CARGO || rel_type == InventoryLocationType.PROXYCARGO)
9767 {
9768 il.GetParent().GetOnReleaseLock().Invoke(it);
9769 }
9770 else if (rel_type == InventoryLocationType.ATTACHMENT)
9771 {
9772 il.GetParent().GetOnAttachmentReleaseLock().Invoke(it, il.GetSlot());
9773 }
9774 //it.GetOnReleaseLock().Invoke(it);
9775 }
9776 }
9777 else if (old_player && newLoc.GetType() == InventoryLocationType.GROUND && m_ThrowItemOnDrop)
9778 {
9779 //ThrowPhysically(old_player, vector.Zero);
9780 m_ThrowItemOnDrop = false;
9781 }
9782
9783 if (m_OldLocation)
9784 {
9785 m_OldLocation.Reset();
9786 }
9787 }
9788 }
9789
9790 override void EOnContact(IEntity other, Contact extra)
9791 {
9793 {
9794 int liquidType = -1;
9795 float impactSpeed = ProcessImpactSoundEx(other, extra, m_ConfigWeight, m_ImpactSoundSurfaceHash, liquidType);
9796 if (impactSpeed > 0.0)
9797 {
9798 m_ImpactSpeed = impactSpeed;
9799 #ifndef SERVER
9800 PlayImpactSound(m_ConfigWeight, m_ImpactSpeed, m_ImpactSoundSurfaceHash);
9801 #else
9802 m_WantPlayImpactSound = true;
9803 SetSynchDirty();
9804 #endif
9805 m_CanPlayImpactSound = (liquidType == -1);// prevents further playing of the sound when the surface is a liquid type
9806 }
9807 }
9808
9809 #ifdef SERVER
9810 if (GetCompEM() && GetCompEM().IsPlugged())
9811 {
9812 if (GetCompEM().GetCordLength() < vector.Distance(GetPosition(), GetCompEM().GetEnergySource().GetPosition()))
9813 GetCompEM().UnplugThis();
9814 }
9815 #endif
9816 }
9817
9818 void RefreshPhysics();
9819
9820 override void OnCreatePhysics()
9821 {
9823 }
9824
9825 override void OnItemAttachmentSlotChanged(notnull InventoryLocation oldLoc, notnull InventoryLocation newLoc)
9826 {
9827
9828 }
9829 // -------------------------------------------------------------------------
9830 override void OnItemLocationChanged(EntityAI old_owner, EntityAI new_owner)
9831 {
9832 super.OnItemLocationChanged(old_owner, new_owner);
9833
9834 PlayerBase relatedPlayer = PlayerBase.Cast(old_owner);
9835 PlayerBase playerNew = PlayerBase.Cast(new_owner);
9836
9837 if (!relatedPlayer && playerNew)
9838 relatedPlayer = playerNew;
9839
9840 if (relatedPlayer && relatedPlayer.GetPerformedActionID() != -1)
9841 {
9842 ActionManagerBase actionMgr = relatedPlayer.GetActionManager();
9843 if (actionMgr)
9844 {
9845 ActionBase currentAction = actionMgr.GetRunningAction();
9846 if (currentAction)
9847 currentAction.OnItemLocationChanged(this);
9848 }
9849 }
9850
9851 Man ownerPlayerOld = null;
9852 Man ownerPlayerNew = null;
9853
9854 if (old_owner)
9855 {
9856 if (old_owner.IsMan())
9857 {
9858 ownerPlayerOld = Man.Cast(old_owner);
9859 }
9860 else
9861 {
9862 ownerPlayerOld = Man.Cast(old_owner.GetHierarchyRootPlayer());
9863 }
9864 }
9865 else
9866 {
9867 if (new_owner && IsElectricAppliance() && GetCompEM() && GetCompEM().IsPlugged())
9868 {
9869 ActionBase action = ActionManagerBase.GetAction(ActionRepositionPluggedItem);
9870
9871 if (!action || !playerNew || playerNew.GetPerformedActionID() != action.GetID())
9872 {
9873 GetCompEM().UnplugThis();
9874 }
9875 }
9876 }
9877
9878 if (new_owner)
9879 {
9880 if (new_owner.IsMan())
9881 {
9882 ownerPlayerNew = Man.Cast(new_owner);
9883 }
9884 else
9885 {
9886 ownerPlayerNew = Man.Cast(new_owner.GetHierarchyRootPlayer());
9887 }
9888 }
9889
9890 if (ownerPlayerOld != ownerPlayerNew)
9891 {
9892 if (ownerPlayerOld)
9893 {
9894 array<EntityAI> subItemsExit = new array<EntityAI>;
9895 GetInventory().EnumerateInventory(InventoryTraversalType.PREORDER,subItemsExit);
9896 for (int i = 0; i < subItemsExit.Count(); i++)
9897 {
9898 ItemBase itemExit = ItemBase.Cast(subItemsExit.Get(i));
9899 itemExit.OnInventoryExit(ownerPlayerOld);
9900 }
9901 }
9902
9903 if (ownerPlayerNew)
9904 {
9905 array<EntityAI> subItemsEnter = new array<EntityAI>;
9906 GetInventory().EnumerateInventory(InventoryTraversalType.PREORDER,subItemsEnter);
9907 for (int j = 0; j < subItemsEnter.Count(); j++)
9908 {
9909 ItemBase itemEnter = ItemBase.Cast(subItemsEnter.Get(j));
9910 itemEnter.OnInventoryEnter(ownerPlayerNew);
9911 }
9912 }
9913 }
9914 else if (ownerPlayerNew != null)
9915 {
9916 PlayerBase nplayer;
9917 if (PlayerBase.CastTo(nplayer, ownerPlayerNew))
9918 {
9919 array<EntityAI> subItemsUpdate = new array<EntityAI>;
9920 GetInventory().EnumerateInventory(InventoryTraversalType.PREORDER,subItemsUpdate);
9921 for (int k = 0; k < subItemsUpdate.Count(); k++)
9922 {
9923 ItemBase itemUpdate = ItemBase.Cast(subItemsUpdate.Get(k));
9924 itemUpdate.UpdateQuickbarShortcutVisibility(nplayer);
9925 }
9926 }
9927 }
9928
9929 if (old_owner)
9930 old_owner.OnChildItemRemoved(this);
9931 if (new_owner)
9932 new_owner.OnChildItemReceived(this);
9933 }
9934
9935 // -------------------------------------------------------------------------------
9936 override void EEDelete(EntityAI parent)
9937 {
9938 super.EEDelete(parent);
9939 PlayerBase player = PlayerBase.Cast(GetHierarchyRootPlayer());
9940 if (player)
9941 {
9942 OnInventoryExit(player);
9943
9944 if (player.IsAlive())
9945 {
9946 int r_index = player.GetHumanInventory().FindUserReservedLocationIndex(this);
9947 if (r_index >= 0)
9948 {
9949 InventoryLocation r_il = new InventoryLocation;
9950 player.GetHumanInventory().GetUserReservedLocation(r_index,r_il);
9951
9952 player.GetHumanInventory().ClearUserReservedLocationAtIndex(r_index);
9953 int r_type = r_il.GetType();
9954 if (r_type == InventoryLocationType.CARGO || r_type == InventoryLocationType.PROXYCARGO)
9955 {
9956 r_il.GetParent().GetOnReleaseLock().Invoke(this);
9957 }
9958 else if (r_type == InventoryLocationType.ATTACHMENT)
9959 {
9960 r_il.GetParent().GetOnAttachmentReleaseLock().Invoke(this, r_il.GetSlot());
9961 }
9962
9963 }
9964
9965 player.RemoveQuickBarEntityShortcut(this);
9966 }
9967 }
9968 }
9969 // -------------------------------------------------------------------------------
9970 override void EEKilled(Object killer)
9971 {
9972 super.EEKilled(killer);
9973
9975 if (killer && killer.IsFireplace() && CanExplodeInFire())
9976 {
9977 if (GetTemperature() >= GameConstants.ITEM_TEMPERATURE_TO_EXPLODE_MIN)
9978 {
9979 if (IsMagazine())
9980 {
9981 if (Magazine.Cast(this).GetAmmoCount() > 0)
9982 {
9983 ExplodeAmmo();
9984 }
9985 }
9986 else
9987 {
9988 Explode(DamageType.EXPLOSION);
9989 }
9990 }
9991 }
9992 }
9993
9994 override void OnWasAttached(EntityAI parent, int slot_id)
9995 {
9996 MiscGameplayFunctions.RemoveAllAttachedChildrenByTypename(this, {Bolt_Base});
9997
9998 super.OnWasAttached(parent, slot_id);
9999
10000 if (HasQuantity())
10001 UpdateNetSyncVariableFloat("m_VarQuantity", GetQuantityMin(), m_VarQuantityMax);
10002
10003 PlayAttachSound(InventorySlots.GetSlotName(slot_id));
10004 }
10005
10006 override void OnWasDetached(EntityAI parent, int slot_id)
10007 {
10008 super.OnWasDetached(parent, slot_id);
10009
10010 if (HasQuantity())
10011 UpdateNetSyncVariableFloat("m_VarQuantity", GetQuantityMin(), m_VarQuantityMax);
10012 }
10013
10014 override string ChangeIntoOnAttach(string slot)
10015 {
10016 int idx;
10017 TStringArray inventory_slots = new TStringArray;
10018 TStringArray attach_types = new TStringArray;
10019
10020 ConfigGetTextArray("ChangeInventorySlot",inventory_slots);
10021 if (inventory_slots.Count() < 1) //is string
10022 {
10023 inventory_slots.Insert(ConfigGetString("ChangeInventorySlot"));
10024 attach_types.Insert(ConfigGetString("ChangeIntoOnAttach"));
10025 }
10026 else //is array
10027 {
10028 ConfigGetTextArray("ChangeIntoOnAttach",attach_types);
10029 }
10030
10031 idx = inventory_slots.Find(slot);
10032 if (idx < 0)
10033 return "";
10034
10035 return attach_types.Get(idx);
10036 }
10037
10038 override string ChangeIntoOnDetach()
10039 {
10040 int idx = -1;
10041 string slot;
10042
10043 TStringArray inventory_slots = new TStringArray;
10044 TStringArray detach_types = new TStringArray;
10045
10046 this.ConfigGetTextArray("ChangeInventorySlot",inventory_slots);
10047 if (inventory_slots.Count() < 1) //is string
10048 {
10049 inventory_slots.Insert(this.ConfigGetString("ChangeInventorySlot"));
10050 detach_types.Insert(this.ConfigGetString("ChangeIntoOnDetach"));
10051 }
10052 else //is array
10053 {
10054 this.ConfigGetTextArray("ChangeIntoOnDetach",detach_types);
10055 if (detach_types.Count() < 1)
10056 detach_types.Insert(this.ConfigGetString("ChangeIntoOnDetach"));
10057 }
10058
10059 for (int i = 0; i < inventory_slots.Count(); i++)
10060 {
10061 slot = inventory_slots.Get(i);
10062 }
10063
10064 if (slot != "")
10065 {
10066 if (detach_types.Count() == 1)
10067 idx = 0;
10068 else
10069 idx = inventory_slots.Find(slot);
10070 }
10071 if (idx < 0)
10072 return "";
10073
10074 return detach_types.Get(idx);
10075 }
10076
10077 void ExplodeAmmo()
10078 {
10079 //timer
10080 ref Timer explode_timer = new Timer(CALL_CATEGORY_SYSTEM);
10081
10082 //min/max time
10083 float min_time = 1;
10084 float max_time = 3;
10085 float delay = Math.RandomFloat(min_time, max_time);
10086
10087 explode_timer.Run(delay, this, "DoAmmoExplosion");
10088 }
10089
10090 void DoAmmoExplosion()
10091 {
10092 Magazine magazine = Magazine.Cast(this);
10093 int pop_sounds_count = 6;
10094 string pop_sounds[ 6 ] = { "ammopops_1","ammopops_2","ammopops_3","ammopops_4","ammopops_5","ammopops_6" };
10095
10096 //play sound
10097 int sound_idx = Math.RandomInt(0, pop_sounds_count - 1);
10098 string sound_name = pop_sounds[ sound_idx ];
10099 GetGame().CreateSoundOnObject(this, sound_name, 20, false);
10100
10101 //remove ammo count
10102 magazine.ServerAddAmmoCount(-1);
10103
10104 //if condition then repeat -> ExplodeAmmo
10105 float min_temp_to_explode = 100; //min temperature for item to explode
10106
10107 if (magazine.GetAmmoCount() > 0 && GetTemperature() >= min_temp_to_explode) //TODO ? add check for parent -> fireplace
10108 {
10109 ExplodeAmmo();
10110 }
10111 }
10112
10113 // -------------------------------------------------------------------------------
10114 override void EEHitBy(TotalDamageResult damageResult, int damageType, EntityAI source, int component, string dmgZone, string ammo, vector modelPos, float speedCoef)
10115 {
10116 super.EEHitBy(damageResult, damageType, source, component, dmgZone, ammo, modelPos, speedCoef);
10117
10118 const int CHANCE_DAMAGE_CARGO = 4;
10119 const int CHANCE_DAMAGE_ATTACHMENT = 1;
10120 const int CHANCE_DAMAGE_NOTHING = 2;
10121
10122 if (IsClothing() || IsContainer() || IsItemTent())
10123 {
10124 float dmg = damageResult.GetDamage("","Health") * -0.5;
10125 int chances;
10126 int rnd;
10127
10128 if (GetInventory().GetCargo())
10129 {
10130 chances = CHANCE_DAMAGE_CARGO + CHANCE_DAMAGE_ATTACHMENT + CHANCE_DAMAGE_NOTHING;
10131 rnd = Math.RandomInt(0,chances);
10132
10133 if (rnd < CHANCE_DAMAGE_CARGO)
10134 {
10135 DamageItemInCargo(dmg);
10136 }
10137 else if (rnd < (chances - CHANCE_DAMAGE_NOTHING))
10138 {
10140 }
10141 }
10142 else
10143 {
10144 chances = CHANCE_DAMAGE_ATTACHMENT + CHANCE_DAMAGE_NOTHING;
10145 rnd = Math.RandomInt(0,chances);
10146
10147 if (rnd < CHANCE_DAMAGE_ATTACHMENT)
10148 {
10150 }
10151 }
10152 }
10153 }
10154
10155 bool DamageItemInCargo(float damage)
10156 {
10157 if (GetInventory().GetCargo())
10158 {
10159 int item_count = GetInventory().GetCargo().GetItemCount();
10160 if (item_count > 0)
10161 {
10162 int random_pick = Math.RandomInt(0, item_count);
10163 ItemBase item = ItemBase.Cast(GetInventory().GetCargo().GetItem(random_pick));
10164 if (!item.IsExplosive())
10165 {
10166 item.AddHealth("","",damage);
10167 return true;
10168 }
10169 }
10170 }
10171 return false;
10172 }
10173
10174 bool DamageItemAttachments(float damage)
10175 {
10176 int attachment_count = GetInventory().AttachmentCount();
10177 if (attachment_count > 0)
10178 {
10179 int random_pick = Math.RandomInt(0, attachment_count);
10180 ItemBase attachment = ItemBase.Cast(GetInventory().GetAttachmentFromIndex(random_pick));
10181 if (!attachment.IsExplosive())
10182 {
10183 attachment.AddHealth("","",damage);
10184 return true;
10185 }
10186 }
10187 return false;
10188 }
10189
10190 override bool IsSplitable()
10191 {
10192 return m_CanThisBeSplit;
10193 }
10194 //----------------
10195 override bool CanBeSplit()
10196 {
10197 if (IsSplitable() && (GetQuantity() > 1))
10198 return GetInventory().CanRemoveEntity();
10199
10200 return false;
10201 }
10202
10203 protected bool ShouldSplitQuantity(float quantity)
10204 {
10205 // don't call 'CanBeSplit' here, too strict and will introduce a freeze-crash when dismantling fence with a fireplace nearby
10206 if (!IsSplitable())
10207 return false;
10208
10209 // nothing to split?
10210 if (GetQuantity() <= 1)
10211 return false;
10212
10213 // check if we should re-use the item instead of creating a new copy?
10214 // implicit cast to int, if 'IsSplitable' returns true, these values are assumed ints
10215 int delta = GetQuantity() - quantity;
10216 if (delta == 0)
10217 return false;
10218
10219 // valid to split
10220 return true;
10221 }
10222
10223 override void SplitIntoStackMaxClient(EntityAI destination_entity, int slot_id )
10224 {
10225 if (GetGame().IsClient())
10226 {
10227 if (ScriptInputUserData.CanStoreInputUserData())
10228 {
10229 ScriptInputUserData ctx = new ScriptInputUserData;
10231 ctx.Write(1);
10232 ItemBase i1 = this; // @NOTE: workaround for correct serialization
10233 ctx.Write(i1);
10234 ctx.Write(destination_entity);
10235 ctx.Write(true);
10236 ctx.Write(slot_id);
10237 ctx.Send();
10238 }
10239 }
10240 else if (!GetGame().IsMultiplayer())
10241 {
10242 SplitIntoStackMax(destination_entity, slot_id, PlayerBase.Cast(GetGame().GetPlayer()));
10243 }
10244 }
10245
10246 void SplitIntoStackMax(EntityAI destination_entity, int slot_id, PlayerBase player)
10247 {
10248 float split_quantity_new;
10249 ItemBase new_item;
10250 float quantity = GetQuantity();
10251 float stack_max = GetTargetQuantityMax(slot_id);
10252 InventoryLocation loc = new InventoryLocation;
10253
10254 if (destination_entity && slot_id != -1 && InventorySlots.IsSlotIdValid(slot_id))
10255 {
10256 if (stack_max <= GetQuantity())
10257 split_quantity_new = stack_max;
10258 else
10259 split_quantity_new = GetQuantity();
10260
10261 if (ShouldSplitQuantity(split_quantity_new))
10262 {
10263 new_item = ItemBase.Cast(destination_entity.GetInventory().CreateAttachmentEx(this.GetType(), slot_id));
10264 if (new_item)
10265 {
10266 new_item.SetResultOfSplit(true);
10267 MiscGameplayFunctions.TransferItemProperties(this, new_item);
10268 AddQuantity(-split_quantity_new, false, true);
10269 new_item.SetQuantity(split_quantity_new, false, true);
10270 }
10271 }
10272 }
10273 else if (destination_entity && slot_id == -1)
10274 {
10275 if (quantity > stack_max)
10276 split_quantity_new = stack_max;
10277 else
10278 split_quantity_new = quantity;
10279
10280 if (ShouldSplitQuantity(split_quantity_new))
10281 {
10282 if (destination_entity.GetInventory().FindFreeLocationFor(this, FindInventoryLocationType.ANY, loc))
10283 {
10284 Object o = destination_entity.GetInventory().LocationCreateEntity(loc, GetType(), ECE_IN_INVENTORY, RF_DEFAULT);
10285 new_item = ItemBase.Cast(o);
10286 }
10287
10288 if (new_item)
10289 {
10290 new_item.SetResultOfSplit(true);
10291 MiscGameplayFunctions.TransferItemProperties(this, new_item);
10292 AddQuantity(-split_quantity_new, false, true);
10293 new_item.SetQuantity(split_quantity_new, false, true);
10294 }
10295 }
10296 }
10297 else
10298 {
10299 if (stack_max != 0)
10300 {
10301 if (stack_max < GetQuantity())
10302 {
10303 split_quantity_new = GetQuantity() - stack_max;
10304 }
10305
10306 if (split_quantity_new == 0)
10307 {
10308 if (!GetGame().IsMultiplayer())
10309 player.PhysicalPredictiveDropItem(this);
10310 else
10311 player.ServerDropEntity(this);
10312 return;
10313 }
10314
10315 if (ShouldSplitQuantity(split_quantity_new))
10316 {
10317 new_item = ItemBase.Cast(GetGame().CreateObjectEx(GetType(), player.GetWorldPosition(), ECE_PLACE_ON_SURFACE));
10318
10319 if (new_item)
10320 {
10321 new_item.SetResultOfSplit(true);
10322 MiscGameplayFunctions.TransferItemProperties(this, new_item);
10323 SetQuantity(split_quantity_new, false, true);
10324 new_item.SetQuantity(stack_max, false, true);
10325 new_item.PlaceOnSurface();
10326 }
10327 }
10328 }
10329 }
10330 }
10331
10332 override void SplitIntoStackMaxEx(EntityAI destination_entity, int slot_id)
10333 {
10334 float split_quantity_new;
10335 ItemBase new_item;
10336 float quantity = GetQuantity();
10337 float stack_max = GetTargetQuantityMax(slot_id);
10338 InventoryLocation loc = new InventoryLocation;
10339
10340 if (destination_entity && slot_id != -1 && InventorySlots.IsSlotIdValid(slot_id))
10341 {
10342 if (stack_max <= GetQuantity())
10343 split_quantity_new = stack_max;
10344 else
10345 split_quantity_new = GetQuantity();
10346
10347 if (ShouldSplitQuantity(split_quantity_new))
10348 {
10349 new_item = ItemBase.Cast(destination_entity.GetInventory().CreateAttachmentEx(this.GetType(), slot_id));
10350 if (new_item)
10351 {
10352 new_item.SetResultOfSplit(true);
10353 MiscGameplayFunctions.TransferItemProperties(this, new_item);
10354 AddQuantity(-split_quantity_new, false, true);
10355 new_item.SetQuantity(split_quantity_new, false, true);
10356 }
10357 }
10358 }
10359 else if (destination_entity && slot_id == -1)
10360 {
10361 if (quantity > stack_max)
10362 split_quantity_new = stack_max;
10363 else
10364 split_quantity_new = quantity;
10365
10366 if (ShouldSplitQuantity(split_quantity_new))
10367 {
10368 if (destination_entity.GetInventory().FindFreeLocationFor(this, FindInventoryLocationType.ANY, loc))
10369 {
10370 Object o = destination_entity.GetInventory().LocationCreateEntity(loc, GetType(), ECE_IN_INVENTORY, RF_DEFAULT);
10371 new_item = ItemBase.Cast(o);
10372 }
10373
10374 if (new_item)
10375 {
10376 new_item.SetResultOfSplit(true);
10377 MiscGameplayFunctions.TransferItemProperties(this, new_item);
10378 AddQuantity(-split_quantity_new, false, true);
10379 new_item.SetQuantity(split_quantity_new, false, true);
10380 }
10381 }
10382 }
10383 else
10384 {
10385 if (stack_max != 0)
10386 {
10387 if (stack_max < GetQuantity())
10388 {
10389 split_quantity_new = GetQuantity() - stack_max;
10390 }
10391
10392 if (ShouldSplitQuantity(split_quantity_new))
10393 {
10394 new_item = ItemBase.Cast(GetGame().CreateObjectEx(GetType(),GetWorldPosition(), ECE_PLACE_ON_SURFACE));
10395
10396 if (new_item)
10397 {
10398 new_item.SetResultOfSplit(true);
10399 MiscGameplayFunctions.TransferItemProperties(this, new_item);
10400 SetQuantity(split_quantity_new, false, true);
10401 new_item.SetQuantity(stack_max, false, true);
10402 new_item.PlaceOnSurface();
10403 }
10404 }
10405 }
10406 }
10407 }
10408
10409 void SplitIntoStackMaxToInventoryLocationClient(notnull InventoryLocation dst)
10410 {
10411 if (GetGame().IsClient())
10412 {
10413 if (ScriptInputUserData.CanStoreInputUserData())
10414 {
10415 ScriptInputUserData ctx = new ScriptInputUserData;
10417 ctx.Write(4);
10418 ItemBase thiz = this; // @NOTE: workaround for correct serialization
10419 ctx.Write(thiz);
10420 dst.WriteToContext(ctx);
10421 ctx.Send();
10422 }
10423 }
10424 else if (!GetGame().IsMultiplayer())
10425 {
10427 }
10428 }
10429
10430 void SplitIntoStackMaxCargoClient(EntityAI destination_entity, int idx, int row, int col)
10431 {
10432 if (GetGame().IsClient())
10433 {
10434 if (ScriptInputUserData.CanStoreInputUserData())
10435 {
10436 ScriptInputUserData ctx = new ScriptInputUserData;
10438 ctx.Write(2);
10439 ItemBase dummy = this; // @NOTE: workaround for correct serialization
10440 ctx.Write(dummy);
10441 ctx.Write(destination_entity);
10442 ctx.Write(true);
10443 ctx.Write(idx);
10444 ctx.Write(row);
10445 ctx.Write(col);
10446 ctx.Send();
10447 }
10448 }
10449 else if (!GetGame().IsMultiplayer())
10450 {
10451 SplitIntoStackMaxCargo(destination_entity, idx, row, col);
10452 }
10453 }
10454
10455 void SplitIntoStackMaxToInventoryLocation(notnull InventoryLocation dst)
10456 {
10458 }
10459
10460 ItemBase SplitIntoStackMaxToInventoryLocationEx(notnull InventoryLocation dst)
10461 {
10462 float quantity = GetQuantity();
10463 float split_quantity_new;
10464 ItemBase new_item;
10465 if (dst.IsValid())
10466 {
10467 int slot_id = dst.GetSlot();
10468 float stack_max = GetTargetQuantityMax(slot_id);
10469
10470 if (quantity > stack_max)
10471 split_quantity_new = stack_max;
10472 else
10473 split_quantity_new = quantity;
10474
10475 if (ShouldSplitQuantity(split_quantity_new))
10476 {
10477 new_item = ItemBase.Cast(GameInventory.LocationCreateEntity(dst, this.GetType(), ECE_IN_INVENTORY, RF_DEFAULT));
10478
10479 if (new_item)
10480 {
10481 new_item.SetResultOfSplit(true);
10482 MiscGameplayFunctions.TransferItemProperties(this,new_item);
10483 AddQuantity(-split_quantity_new, false, true);
10484 new_item.SetQuantity(split_quantity_new, false, true);
10485 }
10486
10487 return new_item;
10488 }
10489 }
10490
10491 return null;
10492 }
10493
10494 void SplitIntoStackMaxCargo(EntityAI destination_entity, int idx, int row, int col)
10495 {
10496 float quantity = GetQuantity();
10497 float split_quantity_new;
10498 ItemBase new_item;
10499 if (destination_entity)
10500 {
10501 float stackable = GetTargetQuantityMax();
10502 if (quantity > stackable)
10503 split_quantity_new = stackable;
10504 else
10505 split_quantity_new = quantity;
10506
10507 if (ShouldSplitQuantity(split_quantity_new))
10508 {
10509 new_item = ItemBase.Cast(destination_entity.GetInventory().CreateEntityInCargoEx(this.GetType(), idx, row, col, false));
10510 if (new_item)
10511 {
10512 new_item.SetResultOfSplit(true);
10513 MiscGameplayFunctions.TransferItemProperties(this,new_item);
10514 AddQuantity(-split_quantity_new, false, true);
10515 new_item.SetQuantity(split_quantity_new, false, true);
10516 }
10517 }
10518 }
10519 }
10520
10521 void SplitIntoStackMaxHandsClient(PlayerBase player)
10522 {
10523 if (GetGame().IsClient())
10524 {
10525 if (ScriptInputUserData.CanStoreInputUserData())
10526 {
10527 ScriptInputUserData ctx = new ScriptInputUserData;
10529 ctx.Write(3);
10530 ItemBase i1 = this; // @NOTE: workaround for correct serialization
10531 ctx.Write(i1);
10532 ItemBase destination_entity = this;
10533 ctx.Write(destination_entity);
10534 ctx.Write(true);
10535 ctx.Write(0);
10536 ctx.Send();
10537 }
10538 }
10539 else if (!GetGame().IsMultiplayer())
10540 {
10541 SplitIntoStackMaxHands(player);
10542 }
10543 }
10544
10545 void SplitIntoStackMaxHands(PlayerBase player)
10546 {
10547 float quantity = GetQuantity();
10548 float split_quantity_new;
10549 ref ItemBase new_item;
10550 if (player)
10551 {
10552 float stackable = GetTargetQuantityMax();
10553 if (quantity > stackable)
10554 split_quantity_new = stackable;
10555 else
10556 split_quantity_new = quantity;
10557
10558 if (ShouldSplitQuantity(split_quantity_new))
10559 {
10560 EntityAI in_hands = player.GetHumanInventory().CreateInHands(this.GetType());
10561 new_item = ItemBase.Cast(in_hands);
10562 if (new_item)
10563 {
10564 new_item.SetResultOfSplit(true);
10565 MiscGameplayFunctions.TransferItemProperties(this,new_item);
10566 AddQuantity(-split_quantity_new, false, true);
10567 new_item.SetQuantity(split_quantity_new, false, true);
10568 }
10569 }
10570 }
10571 }
10572
10573 void SplitItemToInventoryLocation(notnull InventoryLocation dst)
10574 {
10575 float quantity = GetQuantity();
10576 float split_quantity_new = Math.Floor(quantity * 0.5);
10577
10578 if (!ShouldSplitQuantity(split_quantity_new))
10579 return;
10580
10581 ItemBase new_item = ItemBase.Cast(GameInventory.LocationCreateEntity(dst, GetType(), ECE_IN_INVENTORY, RF_DEFAULT));
10582
10583 if (new_item)
10584 {
10585 if (new_item.GetQuantityMax() < split_quantity_new)
10586 {
10587 split_quantity_new = new_item.GetQuantityMax();
10588 }
10589
10590 new_item.SetResultOfSplit(true);
10591 MiscGameplayFunctions.TransferItemProperties(this, new_item);
10592
10593 if (dst.IsValid() && dst.GetType() == InventoryLocationType.ATTACHMENT && split_quantity_new > 1)
10594 {
10595 AddQuantity(-1, false, true);
10596 new_item.SetQuantity(1, false, true);
10597 }
10598 else
10599 {
10600 AddQuantity(-split_quantity_new, false, true);
10601 new_item.SetQuantity(split_quantity_new, false, true);
10602 }
10603 }
10604 }
10605
10606 void SplitItem(PlayerBase player)
10607 {
10608 float quantity = GetQuantity();
10609 float split_quantity_new = Math.Floor(quantity / 2);
10610
10611 if (!ShouldSplitQuantity(split_quantity_new))
10612 return;
10613
10614 InventoryLocation invloc = new InventoryLocation;
10615 bool found = player.GetInventory().FindFirstFreeLocationForNewEntity(GetType(), FindInventoryLocationType.ATTACHMENT, invloc);
10616
10617 ItemBase new_item;
10618 new_item = player.CreateCopyOfItemInInventoryOrGroundEx(this, true);
10619
10620 if (new_item)
10621 {
10622 if (new_item.GetQuantityMax() < split_quantity_new)
10623 {
10624 split_quantity_new = new_item.GetQuantityMax();
10625 }
10626 if (found && invloc.IsValid() && invloc.GetType() == InventoryLocationType.ATTACHMENT && split_quantity_new > 1)
10627 {
10628 AddQuantity(-1, false, true);
10629 new_item.SetQuantity(1, false, true);
10630 }
10631 else if (split_quantity_new > 1)
10632 {
10633 AddQuantity(-split_quantity_new, false, true);
10634 new_item.SetQuantity(split_quantity_new, false, true);
10635 }
10636 }
10637 }
10638
10640 void OnQuantityChanged(float delta)
10641 {
10642 SetWeightDirty();
10643 ItemBase parent = ItemBase.Cast(GetHierarchyParent());
10644
10645 if (parent)
10646 parent.OnAttachmentQuantityChangedEx(this, delta);
10647
10648 if (IsLiquidContainer())
10649 {
10650 if (GetQuantityNormalized() <= 0.0)
10651 {
10653 }
10654 else if (GetLiquidType() == LIQUID_NONE)
10655 {
10656 ErrorEx("Undefined liquid type quantity changed, please define liquid type first! Using init value.",ErrorExSeverity.INFO);
10658 }
10659 }
10660
10661 }
10662
10665 {
10666 // insert code here
10667 }
10668
10670 void OnAttachmentQuantityChangedEx(ItemBase item , float delta)
10671 {
10673 }
10674
10675 override void EEHealthLevelChanged(int oldLevel, int newLevel, string zone)
10676 {
10677 super.EEHealthLevelChanged(oldLevel,newLevel,zone);
10678
10679 if (GetGame().IsServer())
10680 {
10681 if (newLevel == GameConstants.STATE_RUINED)
10682 {
10684 EntityAI parent = GetHierarchyParent();
10685 if (parent && parent.IsFireplace())
10686 {
10687 CargoBase cargo = GetInventory().GetCargo();
10688 if (cargo)
10689 {
10690 for (int i = 0; i < cargo.GetItemCount(); ++i)
10691 {
10692 parent.GetInventory().TakeEntityToInventory(InventoryMode.SERVER, FindInventoryLocationType.CARGO, cargo.GetItem(i));
10693 }
10694 }
10695 }
10696 }
10697
10698 if (IsResultOfSplit())
10699 {
10700 // reset the splitting result flag, return to normal item behavior
10701 SetResultOfSplit(false);
10702 return;
10703 }
10704
10705 if (m_Cleanness != 0 && oldLevel < newLevel && newLevel != 0)
10706 {
10707 SetCleanness(0);//unclean the item upon damage dealt
10708 }
10709 }
10710 }
10711
10712 // just the split? TODO: verify
10713 override void OnRightClick()
10714 {
10715 super.OnRightClick();
10716
10717 if (CanBeSplit() && !GetDayZGame().IsLeftCtrlDown() && !GetGame().GetPlayer().GetInventory().HasInventoryReservation(this,null))
10718 {
10719 if (GetGame().IsClient())
10720 {
10721 if (ScriptInputUserData.CanStoreInputUserData())
10722 {
10723 EntityAI root = GetHierarchyRoot();
10724 Man playerOwner = GetHierarchyRootPlayer();
10725 InventoryLocation dst = new InventoryLocation;
10726
10727 // 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
10728 if (!playerOwner && root && root == this)
10729 {
10731 }
10732 else
10733 {
10734 // 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
10735 GetInventory().GetCurrentInventoryLocation(dst);
10736 if (!dst.GetParent() || dst.GetParent() && !dst.GetParent().GetInventory().FindFreeLocationFor(this, FindInventoryLocationType.CARGO, dst))
10737 {
10738 PlayerBase player = PlayerBase.Cast(GetGame().GetPlayer());
10739 if (!player.GetInventory().FindFreeLocationFor(this, FindInventoryLocationType.CARGO, dst) || !playerOwner)
10740 {
10742 }
10743 else
10744 {
10745 dst.SetCargo(dst.GetParent(), this, dst.GetIdx(), dst.GetRow(), dst.GetCol(), dst.GetFlip());
10746 /* hacky solution to check reservation of "this" item instead of null since the gamecode is checking null against null and returning reservation=true incorrectly
10747 this shouldnt cause issues within this scope*/
10748 if (GetGame().GetPlayer().GetInventory().HasInventoryReservation(this, dst))
10749 {
10751 }
10752 else
10753 {
10754 GetGame().GetPlayer().GetInventory().AddInventoryReservationEx(null, dst, GameInventory.c_InventoryReservationTimeoutShortMS);
10755 }
10756 }
10757 }
10758 }
10759
10760 ScriptInputUserData ctx = new ScriptInputUserData;
10762 ctx.Write(4);
10763 ItemBase thiz = this; // @NOTE: workaround for correct serialization
10764 ctx.Write(thiz);
10765 dst.WriteToContext(ctx);
10766 ctx.Write(true); // dummy
10767 ctx.Send();
10768 }
10769 }
10770 else if (!GetGame().IsMultiplayer())
10771 {
10772 SplitItem(PlayerBase.Cast(GetGame().GetPlayer()));
10773 }
10774 }
10775 }
10776
10777 protected void SetInventoryLocationToVicinityOrCurrent(EntityAI root, inout InventoryLocation dst)
10778 {
10779 if (root)
10780 {
10781 vector m4[4];
10782 root.GetTransform(m4);
10783 dst.SetGround(this, m4);
10784 }
10785 else
10786 {
10787 GetInventory().GetCurrentInventoryLocation(dst);
10788 }
10789 }
10790
10791 override bool CanBeCombined(EntityAI other_item, bool reservation_check = true, bool stack_max_limit = false)
10792 {
10793 //TODO: delete check zero quantity check after fix double posts hands fsm events
10794 if (!other_item || GetType() != other_item.GetType() || (IsFullQuantity() && other_item.GetQuantity() > 0) || other_item == this)
10795 return false;
10796
10797 if (GetHealthLevel() == GameConstants.STATE_RUINED || other_item.GetHealthLevel() == GameConstants.STATE_RUINED)
10798 return false;
10799
10800 //can_this_be_combined = ConfigGetBool("canBeSplit");
10802 return false;
10803
10804
10805 Magazine mag = Magazine.Cast(this);
10806 if (mag)
10807 {
10808 if (mag.GetAmmoCount() >= mag.GetAmmoMax())
10809 return false;
10810
10811 if (stack_max_limit)
10812 {
10813 Magazine other_mag = Magazine.Cast(other_item);
10814 if (other_item)
10815 {
10816 if (mag.GetAmmoCount() + other_mag.GetAmmoCount() > mag.GetAmmoMax())
10817 return false;
10818 }
10819
10820 }
10821 }
10822 else
10823 {
10824 //TODO: delete check zero quantity check after fix double posts hands fsm events
10825 if (GetQuantity() >= GetQuantityMax() && other_item.GetQuantity() > 0 )
10826 return false;
10827
10828 if (stack_max_limit && (GetQuantity() + other_item.GetQuantity() > GetQuantityMax()))
10829 return false;
10830 }
10831
10832 PlayerBase player = null;
10833 if (CastTo(player, GetHierarchyRootPlayer())) //false when attached to player's attachment slot
10834 {
10835 if (player.GetInventory().HasAttachment(this))
10836 return false;
10837
10838 if (player.IsItemsToDelete())
10839 return false;
10840 }
10841
10842 if (reservation_check && (GetInventory().HasInventoryReservation(this, null) || other_item.GetInventory().HasInventoryReservation(other_item, null)))
10843 return false;
10844
10845 int slotID;
10846 string slotName;
10847 if (GetInventory().GetCurrentAttachmentSlotInfo(slotID,slotName) && GetHierarchyParent().GetInventory().GetSlotLock(slotID))
10848 return false;
10849
10850 return true;
10851 }
10852
10853 bool IsCombineAll(ItemBase other_item, bool use_stack_max = false)
10854 {
10855 return ComputeQuantityUsed(other_item, use_stack_max) == other_item.GetQuantity();
10856 }
10857
10858 bool IsResultOfSplit()
10859 {
10860 return m_IsResultOfSplit;
10861 }
10862
10863 void SetResultOfSplit(bool value)
10864 {
10865 m_IsResultOfSplit = value;
10866 }
10867
10868 int ComputeQuantityUsed(ItemBase other_item, bool use_stack_max = true)
10869 {
10870 return ComputeQuantityUsedEx(other_item, use_stack_max);
10871 }
10872
10873 float ComputeQuantityUsedEx(ItemBase other_item, bool use_stack_max = true)
10874 {
10875 float other_item_quantity = other_item.GetQuantity();
10876 float this_free_space;
10877
10878 float stack_max = GetQuantityMax();
10879
10880 this_free_space = stack_max - GetQuantity();
10881
10882 if (other_item_quantity > this_free_space)
10883 {
10884 return this_free_space;
10885 }
10886 else
10887 {
10888 return other_item_quantity;
10889 }
10890 }
10891
10892 override void CombineItemsEx(EntityAI entity2, bool use_stack_max = true)
10893 {
10894 CombineItems(ItemBase.Cast(entity2),use_stack_max);
10895 }
10896
10897 void CombineItems(ItemBase other_item, bool use_stack_max = true)
10898 {
10899 if (!CanBeCombined(other_item, false))
10900 return;
10901
10902 if (!IsMagazine() && other_item)
10903 {
10904 float quantity_used = ComputeQuantityUsedEx(other_item,use_stack_max);
10905 if (quantity_used != 0)
10906 {
10907 float hp1 = GetHealth01("","");
10908 float hp2 = other_item.GetHealth01("","");
10909 float hpResult = ((hp1*GetQuantity()) + (hp2*quantity_used));
10910 hpResult = hpResult / (GetQuantity() + quantity_used);
10911
10912 hpResult *= GetMaxHealth();
10913 Math.Round(hpResult);
10914 SetHealth("", "Health", hpResult);
10915
10916 AddQuantity(quantity_used);
10917 other_item.AddQuantity(-quantity_used);
10918 }
10919 }
10920 OnCombine(other_item);
10921 }
10922
10923 void OnCombine(ItemBase other_item)
10924 {
10925 #ifdef SERVER
10926 if (!GetHierarchyRootPlayer() && GetHierarchyParent())
10927 GetHierarchyParent().IncreaseLifetimeUp();
10928 #endif
10929 };
10930
10931 void GetRecipesActions(Man player, out TSelectableActionInfoArray outputList)
10932 {
10933 PlayerBase p = PlayerBase.Cast(player);
10934
10935 array<int> recipesIds = p.m_Recipes;
10936 PluginRecipesManager moduleRecipesManager = PluginRecipesManager.Cast(GetPlugin(PluginRecipesManager));
10937 if (moduleRecipesManager)
10938 {
10939 EntityAI itemInHands = player.GetHumanInventory().GetEntityInHands();
10940 moduleRecipesManager.GetValidRecipes(ItemBase.Cast(this), ItemBase.Cast(itemInHands), recipesIds, p);
10941 }
10942
10943 for (int i = 0;i < recipesIds.Count(); i++)
10944 {
10945 int key = recipesIds.Get(i);
10946 string recipeName = moduleRecipesManager.GetRecipeName(key);
10947 outputList.Insert(new TSelectableActionInfo(SAT_CRAFTING, key, recipeName));
10948 }
10949 }
10950
10951 // -------------------------------------------------------------------------
10952 override void GetDebugActions(out TSelectableActionInfoArrayEx outputList)
10953 {
10954 super.GetDebugActions(outputList);
10955
10956 //quantity
10957 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.ADD_QUANTITY, "Quantity +20%", FadeColors.LIGHT_GREY));
10958 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.REMOVE_QUANTITY, "Quantity -20%", FadeColors.LIGHT_GREY));
10959 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SET_QUANTITY_0, "Set Quantity 0", FadeColors.LIGHT_GREY));
10960 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SET_MAX_QUANTITY, "Set Quantity Max", FadeColors.LIGHT_GREY));
10961 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SEPARATOR, "___________________________", FadeColors.RED));
10962
10963 //health
10964 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.ADD_HEALTH, "Health +20%", FadeColors.LIGHT_GREY));
10965 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.REMOVE_HEALTH, "Health -20%", FadeColors.LIGHT_GREY));
10966 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.DESTROY_HEALTH, "Health 0", FadeColors.LIGHT_GREY));
10967 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SEPARATOR, "___________________________", FadeColors.RED));
10968 //temperature
10969 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.ADD_TEMPERATURE, "Temperature +20", FadeColors.LIGHT_GREY));
10970 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.REMOVE_TEMPERATURE, "Temperature -20", FadeColors.LIGHT_GREY));
10971 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.FLIP_FROZEN, "Toggle Frozen", FadeColors.LIGHT_GREY));
10972 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SEPARATOR, "___________________________", FadeColors.RED));
10973
10974 //wet
10975 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.ADD_WETNESS, "Wetness +20", FadeColors.LIGHT_GREY));
10976 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.REMOVE_WETNESS, "Wetness -20", FadeColors.LIGHT_GREY));
10977 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SEPARATOR, "___________________________", FadeColors.RED));
10978
10979 //liquidtype
10980 if (IsLiquidContainer())
10981 {
10982 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.LIQUIDTYPE_UP, "LiquidType Next", FadeColors.LIGHT_GREY));
10983 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.LIQUIDTYPE_DOWN, "LiquidType Previous", FadeColors.LIGHT_GREY));
10984 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SEPARATOR, "___________________________", FadeColors.RED));
10985 }
10986
10987 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.MAKE_SPECIAL, "Make Special", FadeColors.LIGHT_GREY));
10988 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SEPARATOR, "___________________________", FadeColors.RED));
10989
10990 // watch
10991 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.WATCH_ITEM, "Watch (CTRL-Z)", FadeColors.LIGHT_GREY));
10992 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.WATCH_PLAYER, "Watch Player", FadeColors.LIGHT_GREY));
10993 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SEPARATOR, "___________________________", FadeColors.RED));
10994
10995 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.DELETE, "Delete", FadeColors.RED));
10996
10997 InventoryLocation loc = new InventoryLocation();
10998 GetInventory().GetCurrentInventoryLocation(loc);
10999 if (!loc || loc.GetType() == InventoryLocationType.GROUND)
11000 {
11001 if (Gizmo_IsSupported())
11002 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.GIZMO_OBJECT, "Gizmo Object", FadeColors.LIGHT_GREY));
11003 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.GIZMO_PHYSICS, "Gizmo Physics (SP Only)", FadeColors.LIGHT_GREY)); // intentionally allowed for testing physics desync
11004 }
11005
11006 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SEPARATOR, "___________________________", FadeColors.RED));
11007 }
11008
11009 // -------------------------------------------------------------------------
11010 // -------------------------------------------------------------------------
11011 // -------------------------------------------------------------------------
11012 override bool OnAction(int action_id, Man player, ParamsReadContext ctx)
11013 {
11014 super.OnAction(action_id, player, ctx);
11015
11016 if (GetGame().IsClient() || !GetGame().IsMultiplayer())
11017 {
11018 switch (action_id)
11019 {
11020 case EActions.GIZMO_OBJECT:
11021 GetGame().GizmoSelectObject(this);
11022 return true;
11023 case EActions.GIZMO_PHYSICS:
11024 GetGame().GizmoSelectPhysics(GetPhysics());
11025 return true;
11026 }
11027 }
11028
11029 if (GetGame().IsServer())
11030 {
11031 switch (action_id)
11032 {
11033 case EActions.DELETE:
11034 Delete();
11035 return true;
11036 }
11037 }
11038
11039 if (action_id >= EActions.RECIPES_RANGE_START && action_id < EActions.RECIPES_RANGE_END)
11040 {
11041 PluginRecipesManager plugin_recipes_manager = PluginRecipesManager.Cast(GetPlugin(PluginRecipesManager));
11042 int idWithoutOffset = action_id - EActions.RECIPES_RANGE_START;
11043 PlayerBase p = PlayerBase.Cast(player);
11044 if (EActions.RECIPES_RANGE_START < 1000)
11045 {
11046 float anim_length = plugin_recipes_manager.GetRecipeLengthInSecs(idWithoutOffset);
11047 float specialty_weight = plugin_recipes_manager.GetRecipeSpecialty(idWithoutOffset);
11048 }
11049 }
11050 #ifndef SERVER
11051 else if (action_id == EActions.WATCH_PLAYER)
11052 {
11053 PluginDeveloper.SetDeveloperItemClientEx(player);
11054 }
11055 #endif
11056 if (GetGame().IsServer())
11057 {
11058 if (action_id >= EActions.DEBUG_ITEM_WATCH_BUTTON_RANGE_START && action_id < EActions.DEBUG_ITEM_WATCH_BUTTON_RANGE_END)
11059 {
11060 int id = action_id - EActions.DEBUG_ITEM_WATCH_BUTTON_RANGE_START;
11061 OnDebugButtonPressServer(id + 1);
11062 }
11063
11064 else if (action_id >= EActions.DEBUG_AGENTS_RANGE_INJECT_START && action_id < EActions.DEBUG_AGENTS_RANGE_INJECT_END)
11065 {
11066 int agent_id = action_id - EActions.DEBUG_AGENTS_RANGE_INJECT_START;
11067 InsertAgent(agent_id,100);
11068 }
11069
11070 else if (action_id >= EActions.DEBUG_AGENTS_RANGE_REMOVE_START && action_id < EActions.DEBUG_AGENTS_RANGE_REMOVE_END)
11071 {
11072 int agent_id2 = action_id - EActions.DEBUG_AGENTS_RANGE_REMOVE_START;
11073 RemoveAgent(agent_id2);
11074 }
11075
11076 else if (action_id == EActions.ADD_QUANTITY)
11077 {
11078 if (IsMagazine())
11079 {
11080 Magazine mag = Magazine.Cast(this);
11081 mag.ServerSetAmmoCount(mag.GetAmmoCount() + mag.GetAmmoMax() * 0.2);
11082 }
11083 else
11084 {
11085 AddQuantity(GetQuantityMax() * 0.2);
11086 }
11087
11088 if (m_EM)
11089 {
11090 m_EM.AddEnergy(m_EM.GetEnergyMax() * 0.2);
11091 }
11092 //PrintVariables();
11093 }
11094
11095 else if (action_id == EActions.REMOVE_QUANTITY) //Quantity -20%
11096 {
11097 if (IsMagazine())
11098 {
11099 Magazine mag2 = Magazine.Cast(this);
11100 mag2.ServerSetAmmoCount(mag2.GetAmmoCount() - mag2.GetAmmoMax() * 0.2);
11101 }
11102 else
11103 {
11104 AddQuantity(- GetQuantityMax() * 0.2);
11105 }
11106 if (m_EM)
11107 {
11108 m_EM.AddEnergy(- m_EM.GetEnergyMax() * 0.2);
11109 }
11110 //PrintVariables();
11111 }
11112
11113 else if (action_id == EActions.SET_QUANTITY_0) //SetMaxQuantity
11114 {
11115 SetQuantity(0);
11116
11117 if (m_EM)
11118 {
11119 m_EM.SetEnergy(0);
11120 }
11121 }
11122
11123 else if (action_id == EActions.SET_MAX_QUANTITY) //SetMaxQuantity
11124 {
11126
11127 if (m_EM)
11128 {
11129 m_EM.SetEnergy(m_EM.GetEnergyMax());
11130 }
11131 }
11132
11133 else if (action_id == EActions.ADD_HEALTH)
11134 {
11135 AddHealth("","",GetMaxHealth("","Health")/5);
11136 }
11137 else if (action_id == EActions.REMOVE_HEALTH)
11138 {
11139 AddHealth("","",-GetMaxHealth("","Health")/5);
11140 }
11141 else if (action_id == EActions.DESTROY_HEALTH)
11142 {
11143 SetHealth01("","",0);
11144 }
11145 else if (action_id == EActions.WATCH_ITEM)
11146 {
11148 mid.RegisterDebugItem(ItemBase.Cast(this), PlayerBase.Cast(player));
11149 #ifdef DEVELOPER
11150 SetDebugDeveloper_item(this);
11151 #endif
11152 }
11153
11154 else if (action_id == EActions.ADD_TEMPERATURE)
11155 {
11156 AddTemperature(20);
11157 //PrintVariables();
11158 }
11159
11160 else if (action_id == EActions.REMOVE_TEMPERATURE)
11161 {
11162 AddTemperature(-20);
11163 //PrintVariables();
11164 }
11165
11166 else if (action_id == EActions.FLIP_FROZEN)
11167 {
11168 SetFrozen(!GetIsFrozen());
11169 //PrintVariables();
11170 }
11171
11172 else if (action_id == EActions.ADD_WETNESS)
11173 {
11174 AddWet(GetWetMax()/5);
11175 //PrintVariables();
11176 }
11177
11178 else if (action_id == EActions.REMOVE_WETNESS)
11179 {
11180 AddWet(-GetWetMax()/5);
11181 //PrintVariables();
11182 }
11183
11184 else if (action_id == EActions.LIQUIDTYPE_UP)
11185 {
11186 int curr_type = GetLiquidType();
11187 SetLiquidType(curr_type * 2);
11188 //AddWet(1);
11189 //PrintVariables();
11190 }
11191
11192 else if (action_id == EActions.LIQUIDTYPE_DOWN)
11193 {
11194 int curr_type2 = GetLiquidType();
11195 SetLiquidType(curr_type2 / 2);
11196 }
11197
11198 else if (action_id == EActions.MAKE_SPECIAL)
11199 {
11200 auto debugParams = DebugSpawnParams.WithPlayer(player);
11201 OnDebugSpawnEx(debugParams);
11202 }
11203
11204 }
11205
11206
11207 return false;
11208 }
11209
11210 // -------------------------------------------------------------------------
11211
11212
11215 void OnActivatedByTripWire();
11216
11218 void OnActivatedByItem(notnull ItemBase item);
11219
11220 //----------------------------------------------------------------
11221 //returns true if item is able to explode when put in fire
11222 bool CanExplodeInFire()
11223 {
11224 return false;
11225 }
11226
11227 //----------------------------------------------------------------
11228 bool CanEat()
11229 {
11230 return true;
11231 }
11232
11233 //----------------------------------------------------------------
11234 override bool IsIgnoredByConstruction()
11235 {
11236 return true;
11237 }
11238
11239 //----------------------------------------------------------------
11240 //has FoodStages in config?
11241 bool HasFoodStage()
11242 {
11243 string config_path = string.Format("CfgVehicles %1 Food FoodStages", GetType());
11244 return GetGame().ConfigIsExisting(config_path);
11245 }
11246
11248 FoodStage GetFoodStage()
11249 {
11250 return null;
11251 }
11252
11253 bool CanBeCooked()
11254 {
11255 return false;
11256 }
11257
11258 bool CanBeCookedOnStick()
11259 {
11260 return false;
11261 }
11262
11264 void RefreshAudioVisualsOnClient( CookingMethodType cooking_method, bool is_done, bool is_empty, bool is_burned );
11266
11267 //----------------------------------------------------------------
11268 bool CanRepair(ItemBase item_repair_kit)
11269 {
11270 PluginRepairing module_repairing = PluginRepairing.Cast(GetPlugin(PluginRepairing));
11271 return module_repairing.CanRepair(this, item_repair_kit);
11272 }
11273
11274 //----------------------------------------------------------------
11275 bool Repair(PlayerBase player, ItemBase item_repair_kit, float specialty_weight)
11276 {
11277 PluginRepairing module_repairing = PluginRepairing.Cast(GetPlugin(PluginRepairing));
11278 return module_repairing.Repair(player, this, item_repair_kit, specialty_weight);
11279 }
11280
11281 //----------------------------------------------------------------
11282 int GetItemSize()
11283 {
11284 /*
11285 vector v_size = this.ConfigGetVector("itemSize");
11286 int v_size_x = v_size[0];
11287 int v_size_y = v_size[1];
11288 int size = v_size_x * v_size_y;
11289 return size;
11290 */
11291
11292 return 1;
11293 }
11294
11295 //----------------------------------------------------------------
11296 //Override for allowing seemingly unallowed moves when two clients send a conflicting message simultaneously
11297 bool CanBeMovedOverride()
11298 {
11299 return m_CanBeMovedOverride;
11300 }
11301
11302 //----------------------------------------------------------------
11303 //Override for allowing seemingly unallowed moves when two clients send a conflicting message simultaneously
11304 void SetCanBeMovedOverride(bool setting)
11305 {
11306 m_CanBeMovedOverride = setting;
11307 }
11308
11309 //----------------------------------------------------------------
11317 void MessageToOwnerStatus(string text)
11318 {
11319 PlayerBase player = PlayerBase.Cast(this.GetHierarchyRootPlayer());
11320
11321 if (player)
11322 {
11323 player.MessageStatus(text);
11324 }
11325 }
11326
11327 //----------------------------------------------------------------
11335 void MessageToOwnerAction(string text)
11336 {
11337 PlayerBase player = PlayerBase.Cast(this.GetHierarchyRootPlayer());
11338
11339 if (player)
11340 {
11341 player.MessageAction(text);
11342 }
11343 }
11344
11345 //----------------------------------------------------------------
11353 void MessageToOwnerFriendly(string text)
11354 {
11355 PlayerBase player = PlayerBase.Cast(this.GetHierarchyRootPlayer());
11356
11357 if (player)
11358 {
11359 player.MessageFriendly(text);
11360 }
11361 }
11362
11363 //----------------------------------------------------------------
11371 void MessageToOwnerImportant(string text)
11372 {
11373 PlayerBase player = PlayerBase.Cast(this.GetHierarchyRootPlayer());
11374
11375 if (player)
11376 {
11377 player.MessageImportant(text);
11378 }
11379 }
11380
11381 override bool IsItemBase()
11382 {
11383 return true;
11384 }
11385
11386 // Checks if item is of questioned kind
11387 override bool KindOf(string tag)
11388 {
11389 bool found = false;
11390 string item_name = this.GetType();
11391 ref TStringArray item_tag_array = new TStringArray;
11392 GetGame().ConfigGetTextArray("cfgVehicles " + item_name + " itemInfo", item_tag_array);
11393
11394 int array_size = item_tag_array.Count();
11395 for (int i = 0; i < array_size; i++)
11396 {
11397 if (item_tag_array.Get(i) == tag)
11398 {
11399 found = true;
11400 break;
11401 }
11402 }
11403 return found;
11404 }
11405
11406
11407 override void OnRPC(PlayerIdentity sender, int rpc_type,ParamsReadContext ctx)
11408 {
11409 //Debug.Log("OnRPC called");
11410 super.OnRPC(sender, rpc_type,ctx);
11411
11412 //Play soundset for attachment locking (ActionLockAttachment.c)
11413 switch (rpc_type)
11414 {
11415 #ifndef SERVER
11416 case ERPCs.RPC_SOUND_LOCK_ATTACH:
11417 Param2<bool, string> p = new Param2<bool, string>(false, "");
11418
11419 if (!ctx.Read(p))
11420 return;
11421
11422 bool play = p.param1;
11423 string soundSet = p.param2;
11424
11425 if (play)
11426 {
11427 if (m_LockingSound)
11428 {
11430 {
11431 m_LockingSound = SEffectManager.PlaySound(soundSet, GetPosition(), 0, 0, true);
11432 }
11433 }
11434 else
11435 {
11436 m_LockingSound = SEffectManager.PlaySound(soundSet, GetPosition(), 0, 0, true);
11437 }
11438 }
11439 else
11440 {
11441 SEffectManager.DestroyEffect(m_LockingSound);
11442 }
11443
11444 break;
11445 #endif
11446
11447 }
11448
11449 if (GetWrittenNoteData())
11450 {
11451 GetWrittenNoteData().OnRPC(sender, rpc_type,ctx);
11452 }
11453 }
11454
11455 //-----------------------------
11456 // VARIABLE MANIPULATION SYSTEM
11457 //-----------------------------
11458 int NameToID(string name)
11459 {
11460 PluginVariables plugin = PluginVariables.Cast(GetPlugin(PluginVariables));
11461 return plugin.GetID(name);
11462 }
11463
11464 string IDToName(int id)
11465 {
11466 PluginVariables plugin = PluginVariables.Cast(GetPlugin(PluginVariables));
11467 return plugin.GetName(id);
11468 }
11469
11471 void OnSyncVariables(ParamsReadContext ctx)//with ID optimization
11472 {
11473 //Debug.Log("OnSyncVariables called for item: "+ ToString(this.GetType()),"varSync");
11474 //read the flags
11475 int varFlags;
11476 if (!ctx.Read(varFlags))
11477 return;
11478
11479 if (varFlags & ItemVariableFlags.FLOAT)
11480 {
11481 ReadVarsFromCTX(ctx);
11482 }
11483 }
11484
11485 override void SerializeNumericalVars(array<float> floats_out)
11486 {
11487 //some variables handled on EntityAI level already!
11488 super.SerializeNumericalVars(floats_out);
11489
11490 // the order of serialization must be the same as the order of de-serialization
11491 //--------------------------------------------
11492 if (IsVariableSet(VARIABLE_QUANTITY))
11493 {
11494 floats_out.Insert(m_VarQuantity);
11495 }
11496 //--------------------------------------------
11497 if (IsVariableSet(VARIABLE_WET))
11498 {
11499 floats_out.Insert(m_VarWet);
11500 }
11501 //--------------------------------------------
11502 if (IsVariableSet(VARIABLE_LIQUIDTYPE))
11503 {
11504 floats_out.Insert(m_VarLiquidType);
11505 }
11506 //--------------------------------------------
11507 if (IsVariableSet(VARIABLE_COLOR))
11508 {
11509 floats_out.Insert(m_ColorComponentR);
11510 floats_out.Insert(m_ColorComponentG);
11511 floats_out.Insert(m_ColorComponentB);
11512 floats_out.Insert(m_ColorComponentA);
11513 }
11514 //--------------------------------------------
11515 if (IsVariableSet(VARIABLE_CLEANNESS))
11516 {
11517 floats_out.Insert(m_Cleanness);
11518 }
11519 }
11520
11521 override void DeSerializeNumericalVars(array<float> floats)
11522 {
11523 //some variables handled on EntityAI level already!
11524 super.DeSerializeNumericalVars(floats);
11525
11526 // the order of serialization must be the same as the order of de-serialization
11527 int index = 0;
11528 int mask = Math.Round(floats.Get(index));
11529
11530 index++;
11531 //--------------------------------------------
11532 if (mask & VARIABLE_QUANTITY)
11533 {
11534 if (m_IsStoreLoad)
11535 {
11536 SetStoreLoadedQuantity(floats.Get(index));
11537 }
11538 else
11539 {
11540 float quantity = floats.Get(index);
11541 SetQuantity(quantity, true, false, false, false);
11542 }
11543 index++;
11544 }
11545 //--------------------------------------------
11546 if (mask & VARIABLE_WET)
11547 {
11548 float wet = floats.Get(index);
11549 SetWet(wet);
11550 index++;
11551 }
11552 //--------------------------------------------
11553 if (mask & VARIABLE_LIQUIDTYPE)
11554 {
11555 int liquidtype = Math.Round(floats.Get(index));
11556 SetLiquidType(liquidtype);
11557 index++;
11558 }
11559 //--------------------------------------------
11560 if (mask & VARIABLE_COLOR)
11561 {
11562 m_ColorComponentR = Math.Round(floats.Get(index));
11563 index++;
11564 m_ColorComponentG = Math.Round(floats.Get(index));
11565 index++;
11566 m_ColorComponentB = Math.Round(floats.Get(index));
11567 index++;
11568 m_ColorComponentA = Math.Round(floats.Get(index));
11569 index++;
11570 }
11571 //--------------------------------------------
11572 if (mask & VARIABLE_CLEANNESS)
11573 {
11574 int cleanness = Math.Round(floats.Get(index));
11575 SetCleanness(cleanness);
11576 index++;
11577 }
11578 }
11579
11580 override void WriteVarsToCTX(ParamsWriteContext ctx)
11581 {
11582 super.WriteVarsToCTX(ctx);
11583
11584 //--------------------------------------------
11585 if (IsVariableSet(VARIABLE_QUANTITY))
11586 {
11587 ctx.Write(GetQuantity());
11588 }
11589 //--------------------------------------------
11590 if (IsVariableSet(VARIABLE_WET))
11591 {
11592 ctx.Write(GetWet());
11593 }
11594 //--------------------------------------------
11595 if (IsVariableSet(VARIABLE_LIQUIDTYPE))
11596 {
11597 ctx.Write(GetLiquidType());
11598 }
11599 //--------------------------------------------
11600 if (IsVariableSet(VARIABLE_COLOR))
11601 {
11602 int r,g,b,a;
11603 GetColor(r,g,b,a);
11604 ctx.Write(r);
11605 ctx.Write(g);
11606 ctx.Write(b);
11607 ctx.Write(a);
11608 }
11609 //--------------------------------------------
11610 if (IsVariableSet(VARIABLE_CLEANNESS))
11611 {
11612 ctx.Write(GetCleanness());
11613 }
11614 }
11615
11616 override bool ReadVarsFromCTX(ParamsReadContext ctx, int version = -1)//with ID optimization
11617 {
11618 if (!super.ReadVarsFromCTX(ctx,version))
11619 return false;
11620
11621 int intValue;
11622 float value;
11623
11624 if (version < 140)
11625 {
11626 if (!ctx.Read(intValue))
11627 return false;
11628
11629 m_VariablesMask = intValue;
11630 }
11631
11632 if (m_VariablesMask & VARIABLE_QUANTITY)
11633 {
11634 if (!ctx.Read(value))
11635 return false;
11636
11637 if (IsStoreLoad())
11638 {
11640 }
11641 else
11642 {
11643 SetQuantity(value, true, false, false, false);
11644 }
11645 }
11646 //--------------------------------------------
11647 if (version < 140)
11648 {
11649 if (m_VariablesMask & VARIABLE_TEMPERATURE)
11650 {
11651 if (!ctx.Read(value))
11652 return false;
11653 SetTemperatureDirect(value);
11654 }
11655 }
11656 //--------------------------------------------
11657 if (m_VariablesMask & VARIABLE_WET)
11658 {
11659 if (!ctx.Read(value))
11660 return false;
11661 SetWet(value);
11662 }
11663 //--------------------------------------------
11664 if (m_VariablesMask & VARIABLE_LIQUIDTYPE)
11665 {
11666 if (!ctx.Read(intValue))
11667 return false;
11668 SetLiquidType(intValue);
11669 }
11670 //--------------------------------------------
11671 if (m_VariablesMask & VARIABLE_COLOR)
11672 {
11673 int r,g,b,a;
11674 if (!ctx.Read(r))
11675 return false;
11676 if (!ctx.Read(g))
11677 return false;
11678 if (!ctx.Read(b))
11679 return false;
11680 if (!ctx.Read(a))
11681 return false;
11682
11683 SetColor(r,g,b,a);
11684 }
11685 //--------------------------------------------
11686 if (m_VariablesMask & VARIABLE_CLEANNESS)
11687 {
11688 if (!ctx.Read(intValue))
11689 return false;
11690 SetCleanness(intValue);
11691 }
11692 //--------------------------------------------
11693 if (version >= 138 && version < 140)
11694 {
11695 if (m_VariablesMask & VARIABLE_TEMPERATURE)
11696 {
11697 if (!ctx.Read(intValue))
11698 return false;
11699 SetFrozen(intValue);
11700 }
11701 }
11702
11703 return true;
11704 }
11705
11706 //----------------------------------------------------------------
11707 override bool OnStoreLoad(ParamsReadContext ctx, int version)
11708 {
11709 m_IsStoreLoad = true;
11711 {
11712 m_FixDamageSystemInit = true;
11713 }
11714
11715 if (!super.OnStoreLoad(ctx, version))
11716 {
11717 m_IsStoreLoad = false;
11718 return false;
11719 }
11720
11721 if (version >= 114)
11722 {
11723 bool hasQuickBarIndexSaved;
11724
11725 if (!ctx.Read(hasQuickBarIndexSaved))
11726 {
11727 m_IsStoreLoad = false;
11728 return false;
11729 }
11730
11731 if (hasQuickBarIndexSaved)
11732 {
11733 int itmQBIndex;
11734
11735 //Load quickbar item bind
11736 if (!ctx.Read(itmQBIndex))
11737 {
11738 m_IsStoreLoad = false;
11739 return false;
11740 }
11741
11742 PlayerBase parentPlayer = PlayerBase.Cast(GetHierarchyRootPlayer());
11743 if (itmQBIndex != -1 && parentPlayer)
11744 parentPlayer.SetLoadedQuickBarItemBind(this, itmQBIndex);
11745 }
11746 }
11747 else
11748 {
11749 // Backup of how it used to be
11750 PlayerBase player;
11751 int itemQBIndex;
11752 if (version == int.MAX)
11753 {
11754 if (!ctx.Read(itemQBIndex))
11755 {
11756 m_IsStoreLoad = false;
11757 return false;
11758 }
11759 }
11760 else if (Class.CastTo(player, GetHierarchyRootPlayer()))
11761 {
11762 //Load quickbar item bind
11763 if (!ctx.Read(itemQBIndex))
11764 {
11765 m_IsStoreLoad = false;
11766 return false;
11767 }
11768 if (itemQBIndex != -1 && player)
11769 player.SetLoadedQuickBarItemBind(this,itemQBIndex);
11770 }
11771 }
11772
11773 if (version < 140)
11774 {
11775 // variable management system
11776 if (!LoadVariables(ctx, version))
11777 {
11778 m_IsStoreLoad = false;
11779 return false;
11780 }
11781 }
11782
11783 //agent trasmission system
11784 if (!LoadAgents(ctx, version))
11785 {
11786 m_IsStoreLoad = false;
11787 return false;
11788 }
11789 if (version >= 132)
11790 {
11791 RemotelyActivatedItemBehaviour raib = GetRemotelyActivatedItemBehaviour();
11792 if (raib)
11793 {
11794 if (!raib.OnStoreLoad(ctx,version))
11795 {
11796 m_IsStoreLoad = false;
11797 return false;
11798 }
11799 }
11800 }
11801
11802 m_IsStoreLoad = false;
11803 return true;
11804 }
11805
11806 //----------------------------------------------------------------
11807
11808 override void OnStoreSave(ParamsWriteContext ctx)
11809 {
11810 super.OnStoreSave(ctx);
11811
11812 PlayerBase player;
11813 if (PlayerBase.CastTo(player,GetHierarchyRootPlayer()))
11814 {
11815 ctx.Write(true); // Keep track of if we should actually read this in or not
11816 //Save quickbar item bind
11817 int itemQBIndex = -1;
11818 itemQBIndex = player.FindQuickBarEntityIndex(this);
11819 ctx.Write(itemQBIndex);
11820 }
11821 else
11822 {
11823 ctx.Write(false); // Keep track of if we should actually read this in or not
11824 }
11825
11826 SaveAgents(ctx);//agent trasmission system
11827
11828 RemotelyActivatedItemBehaviour raib = GetRemotelyActivatedItemBehaviour();
11829 if (raib)
11830 {
11831 raib.OnStoreSave(ctx);
11832 }
11833 }
11834 //----------------------------------------------------------------
11835
11836 override void AfterStoreLoad()
11837 {
11838 super.AfterStoreLoad();
11839
11841 {
11843 }
11844
11845 if (GetStoreLoadedQuantity() != float.LOWEST)
11846 {
11848 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
11849 }
11850 }
11851
11852 override void EEOnAfterLoad()
11853 {
11854 super.EEOnAfterLoad();
11855
11857 {
11858 m_FixDamageSystemInit = false;
11859 }
11860
11863 }
11864
11865 bool CanBeDisinfected()
11866 {
11867 return false;
11868 }
11869
11870
11871 //----------------------------------------------------------------
11872 override void OnVariablesSynchronized()
11873 {
11874 if (m_Initialized)
11875 {
11876 #ifdef PLATFORM_CONSOLE
11877 //bruteforce it is
11878 if (IsSplitable())
11879 {
11880 UIScriptedMenu menu = GetGame().GetUIManager().FindMenu(MENU_INVENTORY);
11881 if (menu)
11882 {
11883 menu.Refresh();
11884 }
11885 }
11886 #endif
11887 }
11888
11890 {
11891 PlayImpactSound(m_ConfigWeight, m_ImpactSpeed, m_ImpactSoundSurfaceHash);
11892 m_WantPlayImpactSound = false;
11893 }
11894
11896 {
11897 SetWeightDirty();
11899 }
11900 if (m_VarWet != m_VarWetPrev)
11901 {
11904 }
11905
11906 if (m_SoundSyncPlay != 0)
11907 {
11908 m_ItemSoundHandler.PlayItemSoundClient(m_SoundSyncPlay);
11909 m_SoundSyncPlay = 0;
11910 }
11911 if (m_SoundSyncStop != 0)
11912 {
11913 m_ItemSoundHandler.StopItemSoundClient(m_SoundSyncStop);
11914 m_SoundSyncStop = 0;
11915 }
11916
11917 super.OnVariablesSynchronized();
11918 }
11919
11920 //------------------------- Quantity
11921 //----------------------------------------------------------------
11923 override bool SetQuantity(float value, bool destroy_config = true, bool destroy_forced = false, bool allow_client = false, bool clamp_to_stack_max = true)
11924 {
11925 if (!IsServerCheck(allow_client))
11926 return false;
11927
11928 if (!HasQuantity())
11929 return false;
11930
11931 float min = GetQuantityMin();
11932 float max = GetQuantityMax();
11933
11934 if (value <= (min + 0.001))
11935 value = min;
11936
11937 if (value == min)
11938 {
11939 if (destroy_config)
11940 {
11941 bool dstr = ConfigGetBool("varQuantityDestroyOnMin");
11942 if (dstr)
11943 {
11944 m_VarQuantity = Math.Clamp(value, min, max);
11945 this.Delete();
11946 return true;
11947 }
11948 }
11949 else if (destroy_forced)
11950 {
11951 m_VarQuantity = Math.Clamp(value, min, max);
11952 this.Delete();
11953 return true;
11954 }
11955 // we get here if destroy_config IS true AND dstr(config destroy param) IS false;
11956 RemoveAllAgents();//we remove all agents when we got to the min value, but the item is not getting deleted
11957 }
11958
11959 float delta = m_VarQuantity;
11960 m_VarQuantity = Math.Clamp(value, min, max);
11961
11962 if (GetStoreLoadedQuantity() == float.LOWEST)//any other value means we are setting quantity from storage
11963 {
11964 delta = m_VarQuantity - delta;
11965
11966 if (delta)
11967 OnQuantityChanged(delta);
11968 }
11969
11970 SetVariableMask(VARIABLE_QUANTITY);
11971
11972 return false;
11973 }
11974
11975 //----------------------------------------------------------------
11977 bool AddQuantity(float value, bool destroy_config = true, bool destroy_forced = false)
11978 {
11979 return SetQuantity(GetQuantity() + value, destroy_config, destroy_forced);
11980 }
11981 //----------------------------------------------------------------
11982 void SetQuantityMax()
11983 {
11984 float max = GetQuantityMax();
11985 SetQuantity(max);
11986 }
11987
11988 override void SetQuantityToMinimum()
11989 {
11990 float min = GetQuantityMin();
11991 SetQuantity(min);
11992 }
11993 //----------------------------------------------------------------
11995 override void SetQuantityNormalized(float value, bool destroy_config = true, bool destroy_forced = false)
11996 {
11997 float value_clamped = Math.Clamp(value, 0, 1);//just to make sure
11998 int result = Math.Round(Math.Lerp(GetQuantityMin(), GetQuantityMax(), value_clamped));
11999 SetQuantity(result, destroy_config, destroy_forced);
12000 }
12001
12002 //----------------------------------------------------------------
12004 override float GetQuantityNormalized()
12005 {
12006 return Math.InverseLerp(GetQuantityMin(), GetQuantityMax(),m_VarQuantity);
12007 }
12008
12010 {
12011 return GetQuantityNormalized();
12012 }
12013
12014 /*void SetAmmoNormalized(float value)
12015 {
12016 float value_clamped = Math.Clamp(value, 0, 1);
12017 Magazine this_mag = Magazine.Cast(this);
12018 int max_rounds = this_mag.GetAmmoMax();
12019 int result = value * max_rounds;//can the rounded if higher precision is required
12020 this_mag.SetAmmoCount(result);
12021 }*/
12022 //----------------------------------------------------------------
12023 override int GetQuantityMax()
12024 {
12025 int slot = -1;
12026 if (GetInventory())
12027 {
12028 InventoryLocation il = new InventoryLocation;
12029 GetInventory().GetCurrentInventoryLocation(il);
12030 slot = il.GetSlot();
12031 }
12032
12033 return GetTargetQuantityMax(slot);
12034 }
12035
12036 override int GetTargetQuantityMax(int attSlotID = -1)
12037 {
12038 float quantity_max = 0;
12039
12040 if (IsSplitable()) //only stackable/splitable items can check for stack size
12041 {
12042 if (attSlotID != -1)
12043 quantity_max = InventorySlots.GetStackMaxForSlotId(attSlotID);
12044
12045 if (quantity_max <= 0)
12046 quantity_max = m_VarStackMax;
12047 }
12048
12049 if (quantity_max <= 0)
12050 quantity_max = m_VarQuantityMax;
12051
12052 return quantity_max;
12053 }
12054 //----------------------------------------------------------------
12055 override int GetQuantityMin()
12056 {
12057 return m_VarQuantityMin;
12058 }
12059 //----------------------------------------------------------------
12060 int GetQuantityInit()
12061 {
12062 return m_VarQuantityInit;
12063 }
12064
12065 //----------------------------------------------------------------
12066 override bool HasQuantity()
12067 {
12068 return !(GetQuantityMax() - GetQuantityMin() == 0);
12069 }
12070
12071 override float GetQuantity()
12072 {
12073 return m_VarQuantity;
12074 }
12075
12076 bool IsFullQuantity()
12077 {
12078 return GetQuantity() >= GetQuantityMax();
12079 }
12080
12081 //Calculates weight of single item without attachments and cargo
12082 override float GetSingleInventoryItemWeightEx()
12083 {
12084 //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
12085 float weightEx = GetWeightEx();//overall weight of the item
12086 float special = GetInventoryAndCargoWeight();//cargo and attachment weight
12087 return weightEx - special;
12088 }
12089
12090 // Obsolete, use GetSingleInventoryItemWeightEx() instead
12092 {
12094 }
12095
12096 override protected float GetWeightSpecialized(bool forceRecalc = false)
12097 {
12098 if (IsSplitable()) //quantity determines size of the stack
12099 {
12100 #ifdef DEVELOPER
12101 if (WeightDebug.m_VerbosityFlags & WeightDebugType.RECALC_FORCED)
12102 {
12103 WeightDebugData data1 = WeightDebug.GetWeightDebug(this);
12104 data1.SetCalcDetails("TIB1: " + GetConfigWeightModifiedDebugText() +" * " + GetQuantity()+"(quantity)");
12105 }
12106 #endif
12107
12108 return GetQuantity() * GetConfigWeightModified();
12109 }
12110 else if (HasEnergyManager())// items with energy manager
12111 {
12112 #ifdef DEVELOPER
12113 if (WeightDebug.m_VerbosityFlags & WeightDebugType.RECALC_FORCED)
12114 {
12115 WeightDebugData data2 = WeightDebug.GetWeightDebug(this);
12116 data2.SetCalcDetails("TIB2: "+super.GetWeightSpecialized(forceRecalc)+"(contents weight) + " + GetConfigWeightModifiedDebugText() +" + " + GetCompEM().GetEnergy()+"(energy) * " + ConfigGetFloat("weightPerQuantityUnit") +"(weightPerQuantityUnit)");
12117 }
12118 #endif
12119 return super.GetWeightSpecialized(forceRecalc) + (GetCompEM().GetEnergy() * ConfigGetFloat("weightPerQuantityUnit")) + GetConfigWeightModified();
12120 }
12121 else//everything else
12122 {
12123 #ifdef DEVELOPER
12124 if (WeightDebug.m_VerbosityFlags & WeightDebugType.RECALC_FORCED)
12125 {
12126 WeightDebugData data3 = WeightDebug.GetWeightDebug(this);
12127 data3.SetCalcDetails("TIB3: "+super.GetWeightSpecialized(forceRecalc)+"(contents weight) + " + GetConfigWeightModifiedDebugText() +" + " + GetQuantity()+"(quantity) * " + ConfigGetFloat("weightPerQuantityUnit") +"(weightPerQuantityUnit))");
12128 }
12129 #endif
12130 return super.GetWeightSpecialized(forceRecalc) + (GetQuantity() * ConfigGetFloat("weightPerQuantityUnit")) + GetConfigWeightModified();
12131 }
12132 }
12133
12135 int GetNumberOfItems()
12136 {
12137 int item_count = 0;
12138 ItemBase item;
12139
12140 if (GetInventory().GetCargo() != NULL)
12141 {
12142 item_count = GetInventory().GetCargo().GetItemCount();
12143 }
12144
12145 for (int i = 0; i < GetInventory().AttachmentCount(); i++)
12146 {
12147 Class.CastTo(item,GetInventory().GetAttachmentFromIndex(i));
12148 if (item)
12149 item_count += item.GetNumberOfItems();
12150 }
12151 return item_count;
12152 }
12153
12155 float GetUnitWeight(bool include_wetness = true)
12156 {
12157 float weight = 0;
12158 float wetness = 1;
12159 if (include_wetness)
12160 wetness += GetWet();
12161 if (IsSplitable()) //quantity determines size of the stack
12162 {
12163 weight = wetness * m_ConfigWeight;
12164 }
12165 else if (IsLiquidContainer()) //is a liquid container, default liquid weight is set to 1. May revisit later?
12166 {
12167 weight = 1;
12168 }
12169 return weight;
12170 }
12171
12172 //-----------------------------------------------------------------
12173
12174 override void ClearInventory()
12175 {
12176 if ((GetGame().IsServer() || !GetGame().IsMultiplayer()) && GetInventory())
12177 {
12178 GameInventory inv = GetInventory();
12179 array<EntityAI> items = new array<EntityAI>;
12180 inv.EnumerateInventory(InventoryTraversalType.INORDER, items);
12181 for (int i = 0; i < items.Count(); i++)
12182 {
12183 ItemBase item = ItemBase.Cast(items.Get(i));
12184 if (item)
12185 {
12186 GetGame().ObjectDelete(item);
12187 }
12188 }
12189 }
12190 }
12191
12192 //------------------------- Energy
12193
12194 //----------------------------------------------------------------
12195 float GetEnergy()
12196 {
12197 float energy = 0;
12198 if (HasEnergyManager())
12199 {
12200 energy = GetCompEM().GetEnergy();
12201 }
12202 return energy;
12203 }
12204
12205
12206 override void OnEnergyConsumed()
12207 {
12208 super.OnEnergyConsumed();
12209
12211 }
12212
12213 override void OnEnergyAdded()
12214 {
12215 super.OnEnergyAdded();
12216
12218 }
12219
12220 // Converts energy (from Energy Manager) to quantity, if enabled.
12222 {
12223 if (GetGame().IsServer() && HasEnergyManager() && GetCompEM().HasConversionOfEnergyToQuantity())
12224 {
12225 if (HasQuantity())
12226 {
12227 float energy_0to1 = GetCompEM().GetEnergy0To1();
12228 SetQuantityNormalized(energy_0to1);
12229 }
12230 }
12231 }
12232
12233 //----------------------------------------------------------------
12234 float GetHeatIsolationInit()
12235 {
12236 return ConfigGetFloat("heatIsolation");
12237 }
12238
12239 float GetHeatIsolation()
12240 {
12241 return m_HeatIsolation;
12242 }
12243
12244 float GetDryingIncrement(string pIncrementName)
12245 {
12246 string paramPath = string.Format("CfgVehicles %1 EnvironmentWetnessIncrements Drying %2", GetType(), pIncrementName);
12247 if (GetGame().ConfigIsExisting(paramPath))
12248 return GetGame().ConfigGetFloat(paramPath);
12249
12250 return 0.0;
12251 }
12252
12253 float GetSoakingIncrement(string pIncrementName)
12254 {
12255 string paramPath = string.Format("CfgVehicles %1 EnvironmentWetnessIncrements Soaking %2", GetType(), pIncrementName);
12256 if (GetGame().ConfigIsExisting(paramPath))
12257 return GetGame().ConfigGetFloat(paramPath);
12258
12259 return 0.0;
12260 }
12261 //----------------------------------------------------------------
12262 override void SetWet(float value, bool allow_client = false)
12263 {
12264 if (!IsServerCheck(allow_client))
12265 return;
12266
12267 float min = GetWetMin();
12268 float max = GetWetMax();
12269
12270 float previousValue = m_VarWet;
12271
12272 m_VarWet = Math.Clamp(value, min, max);
12273
12274 if (previousValue != m_VarWet)
12275 {
12276 SetVariableMask(VARIABLE_WET);
12277 OnWetChanged(m_VarWet, previousValue);
12278 }
12279 }
12280 //----------------------------------------------------------------
12281 override void AddWet(float value)
12282 {
12283 SetWet(GetWet() + value);
12284 }
12285 //----------------------------------------------------------------
12286 override void SetWetMax()
12287 {
12289 }
12290 //----------------------------------------------------------------
12291 override float GetWet()
12292 {
12293 return m_VarWet;
12294 }
12295 //----------------------------------------------------------------
12296 override float GetWetMax()
12297 {
12298 return m_VarWetMax;
12299 }
12300 //----------------------------------------------------------------
12301 override float GetWetMin()
12302 {
12303 return m_VarWetMin;
12304 }
12305 //----------------------------------------------------------------
12306 override float GetWetInit()
12307 {
12308 return m_VarWetInit;
12309 }
12310 //----------------------------------------------------------------
12311 override void OnWetChanged(float newVal, float oldVal)
12312 {
12313 EWetnessLevel newLevel = GetWetLevelInternal(newVal);
12314 EWetnessLevel oldLevel = GetWetLevelInternal(oldVal);
12315 if (newLevel != oldLevel)
12316 {
12317 OnWetLevelChanged(newLevel,oldLevel);
12318 }
12319 }
12320
12321 override void OnWetLevelChanged(EWetnessLevel newLevel, EWetnessLevel oldLevel)
12322 {
12323 SetWeightDirty();
12324 }
12325
12326 override EWetnessLevel GetWetLevel()
12327 {
12328 return GetWetLevelInternal(m_VarWet);
12329 }
12330
12331 //----------------------------------------------------------------
12332
12333 override void SetStoreLoad(bool value)
12334 {
12335 m_IsStoreLoad = value;
12336 }
12337
12338 override bool IsStoreLoad()
12339 {
12340 return m_IsStoreLoad;
12341 }
12342
12343 override void SetStoreLoadedQuantity(float value)
12344 {
12345 m_StoreLoadedQuantity = value;
12346 }
12347
12348 override float GetStoreLoadedQuantity()
12349 {
12350 return m_StoreLoadedQuantity;
12351 }
12352
12353 //----------------------------------------------------------------
12354
12355 float GetItemModelLength()
12356 {
12357 if (ConfigIsExisting("itemModelLength"))
12358 {
12359 return ConfigGetFloat("itemModelLength");
12360 }
12361 return 0;
12362 }
12363
12364 float GetItemAttachOffset()
12365 {
12366 if (ConfigIsExisting("itemAttachOffset"))
12367 {
12368 return ConfigGetFloat("itemAttachOffset");
12369 }
12370 return 0;
12371 }
12372
12373 override void SetCleanness(int value, bool allow_client = false)
12374 {
12375 if (!IsServerCheck(allow_client))
12376 return;
12377
12378 int previousValue = m_Cleanness;
12379
12380 m_Cleanness = Math.Clamp(value, m_CleannessMin, m_CleannessMax);
12381
12382 if (previousValue != m_Cleanness)
12383 SetVariableMask(VARIABLE_CLEANNESS);
12384 }
12385
12386 override int GetCleanness()
12387 {
12388 return m_Cleanness;
12389 }
12390
12392 {
12393 return true;
12394 }
12395
12396 //----------------------------------------------------------------
12397 // ATTACHMENT LOCKING
12398 // Getters relevant to generic ActionLockAttachment
12399 int GetLockType()
12400 {
12401 return m_LockType;
12402 }
12403
12404 string GetLockSoundSet()
12405 {
12406 return m_LockSoundSet;
12407 }
12408
12409 //----------------------------------------------------------------
12410 //------------------------- Color
12411 // sets items color variable given color components
12412 override void SetColor(int r, int g, int b, int a)
12413 {
12418 SetVariableMask(VARIABLE_COLOR);
12419 }
12421 override void GetColor(out int r,out int g,out int b,out int a)
12422 {
12427 }
12428
12429 bool IsColorSet()
12430 {
12431 return IsVariableSet(VARIABLE_COLOR);
12432 }
12433
12435 string GetColorString()
12436 {
12437 int r,g,b,a;
12438 GetColor(r,g,b,a);
12439 r = r/255;
12440 g = g/255;
12441 b = b/255;
12442 a = a/255;
12443 return MiscGameplayFunctions.GetColorString(r, g, b, a);
12444 }
12445 //----------------------------------------------------------------
12446 //------------------------- LiquidType
12447
12448 override void SetLiquidType(int value, bool allow_client = false)
12449 {
12450 if (!IsServerCheck(allow_client))
12451 return;
12452
12453 int old = m_VarLiquidType;
12454 m_VarLiquidType = value;
12455 OnLiquidTypeChanged(old,value);
12456 SetVariableMask(VARIABLE_LIQUIDTYPE);
12457 }
12458
12459 int GetLiquidTypeInit()
12460 {
12461 return ConfigGetInt("varLiquidTypeInit");
12462 }
12463
12464 override int GetLiquidType()
12465 {
12466 return m_VarLiquidType;
12467 }
12468
12469 protected void OnLiquidTypeChanged(int oldType, int newType)
12470 {
12471 if (newType == LIQUID_NONE && GetIsFrozen())
12472 SetFrozen(false);
12473 }
12474
12476 void UpdateQuickbarShortcutVisibility(PlayerBase player)
12477 {
12478 player.SetEnableQuickBarEntityShortcut(this,!GetHierarchyParent() || GetHierarchyParent().GetInventory().AreChildrenAccessible());
12479 }
12480
12481 // -------------------------------------------------------------------------
12483 void OnInventoryEnter(Man player)
12484 {
12485 PlayerBase nplayer;
12486 if (PlayerBase.CastTo(nplayer, player))
12487 {
12488 m_CanPlayImpactSound = true;
12489 //nplayer.OnItemInventoryEnter(this);
12490 nplayer.SetEnableQuickBarEntityShortcut(this,!GetHierarchyParent() || GetHierarchyParent().GetInventory().AreChildrenAccessible());
12491 }
12492 }
12493
12494 // -------------------------------------------------------------------------
12496 void OnInventoryExit(Man player)
12497 {
12498 PlayerBase nplayer;
12499 if (PlayerBase.CastTo(nplayer,player))
12500 {
12501 //nplayer.OnItemInventoryExit(this);
12502 nplayer.SetEnableQuickBarEntityShortcut(this,false);
12503
12504 }
12505
12506 //if (!GetGame().IsDedicatedServer())
12507 player.GetHumanInventory().ClearUserReservedLocationForContainer(this);
12508
12509
12510 if (HasEnergyManager())
12511 {
12512 GetCompEM().UpdatePlugState(); // Unplug the el. device if it's necesarry.
12513 }
12514 }
12515
12516 // ADVANCED PLACEMENT EVENTS
12517 override void OnPlacementStarted(Man player)
12518 {
12519 super.OnPlacementStarted(player);
12520
12521 SetTakeable(false);
12522 }
12523
12524 override void OnPlacementComplete(Man player, vector position = "0 0 0", vector orientation = "0 0 0")
12525 {
12526 if (m_AdminLog)
12527 {
12528 m_AdminLog.OnPlacementComplete(player, this);
12529 }
12530
12531 super.OnPlacementComplete(player, position, orientation);
12532 }
12533
12534 //-----------------------------
12535 // AGENT SYSTEM
12536 //-----------------------------
12537 //--------------------------------------------------------------------------
12538 bool ContainsAgent(int agent_id)
12539 {
12540 if (agent_id & m_AttachedAgents)
12541 {
12542 return true;
12543 }
12544 else
12545 {
12546 return false;
12547 }
12548 }
12549
12550 //--------------------------------------------------------------------------
12551 override void RemoveAgent(int agent_id)
12552 {
12553 if (ContainsAgent(agent_id))
12554 {
12555 m_AttachedAgents = ~agent_id & m_AttachedAgents;
12556 }
12557 }
12558
12559 //--------------------------------------------------------------------------
12560 override void RemoveAllAgents()
12561 {
12562 m_AttachedAgents = 0;
12563 }
12564 //--------------------------------------------------------------------------
12565 override void RemoveAllAgentsExcept(int agent_to_keep)
12566 {
12567 m_AttachedAgents = m_AttachedAgents & agent_to_keep;
12568 }
12569 // -------------------------------------------------------------------------
12570 override void InsertAgent(int agent, float count = 1)
12571 {
12572 if (count < 1)
12573 return;
12574 //Debug.Log("Inserting Agent on item: " + agent.ToString() +" count: " + count.ToString());
12576 }
12577
12579 void TransferAgents(int agents)
12580 {
12582 }
12583
12584 // -------------------------------------------------------------------------
12585 override int GetAgents()
12586 {
12587 return m_AttachedAgents;
12588 }
12589 //----------------------------------------------------------------------
12590
12591 /*int GetContaminationType()
12592 {
12593 int contamination_type;
12594
12595 const int CONTAMINATED_MASK = eAgents.CHOLERA | eAgents.INFLUENZA | eAgents.SALMONELLA | eAgents.BRAIN;
12596 const int POISONED_MASK = eAgents.FOOD_POISON | eAgents.CHEMICAL_POISON;
12597 const int NERVE_GAS_MASK = eAgents.CHEMICAL_POISON;
12598 const int DIRTY_MASK = eAgents.WOUND_AGENT;
12599
12600 Edible_Base edible = Edible_Base.Cast(this);
12601 int agents = GetAgents();
12602 if (edible)
12603 {
12604 NutritionalProfile profile = Edible_Base.GetNutritionalProfile(edible);
12605 if (profile)
12606 {
12607 agents = agents | profile.GetAgents();//merge item's agents with nutritional agents
12608 }
12609 }
12610 if (agents & CONTAMINATED_MASK)
12611 {
12612 contamination_type = contamination_type | EContaminationTypes.ITEM_BADGE_CONTAMINATED;
12613 }
12614 if (agents & POISONED_MASK)
12615 {
12616 contamination_type = contamination_type | EContaminationTypes.ITEM_BADGE_POISONED;
12617 }
12618 if (agents & NERVE_GAS_MASK)
12619 {
12620 contamination_type = contamination_type | EContaminationTypes.ITEM_BADGE_NERVE_GAS;
12621 }
12622 if (agents & DIRTY_MASK)
12623 {
12624 contamination_type = contamination_type | EContaminationTypes.ITEM_BADGE_DIRTY;
12625 }
12626
12627 return agents;
12628 }*/
12629
12630 // -------------------------------------------------------------------------
12631 bool LoadAgents(ParamsReadContext ctx, int version)
12632 {
12633 if (!ctx.Read(m_AttachedAgents))
12634 return false;
12635 return true;
12636 }
12637 // -------------------------------------------------------------------------
12639 {
12640
12642 }
12643 // -------------------------------------------------------------------------
12644
12646 override void CheckForRoofLimited(float timeTresholdMS = 3000)
12647 {
12648 super.CheckForRoofLimited(timeTresholdMS);
12649
12650 float time = GetGame().GetTime();
12651 if ((time - m_PreviousRoofTestTime) >= timeTresholdMS)
12652 {
12653 m_PreviousRoofTestTime = time;
12654 SetRoofAbove(MiscGameplayFunctions.IsUnderRoof(this));
12655 }
12656 }
12657
12658 // returns item's protection level against enviromental hazard, for masks with filters, returns the filters protection for valid filter, otherwise 0
12659 float GetProtectionLevel(int type, bool consider_filter = false, int system = 0)
12660 {
12661 if (IsDamageDestroyed() || (HasQuantity() && GetQuantity() <= 0))
12662 {
12663 return 0;
12664 }
12665
12666 if (GetInventory().GetAttachmentSlotsCount() != 0)//is it an item with attachable filter ?
12667 {
12668 ItemBase filter = ItemBase.Cast(FindAttachmentBySlotName("GasMaskFilter"));
12669 if (filter)
12670 return filter.GetProtectionLevel(type, false, system);//it's a valid filter, return the protection
12671 else
12672 return 0;//otherwise return 0 when no filter attached
12673 }
12674
12675 string subclassPath, entryName;
12676
12677 switch (type)
12678 {
12679 case DEF_BIOLOGICAL:
12680 entryName = "biological";
12681 break;
12682 case DEF_CHEMICAL:
12683 entryName = "chemical";
12684 break;
12685 default:
12686 entryName = "biological";
12687 break;
12688 }
12689
12690 subclassPath = "CfgVehicles " + this.GetType() + " Protection ";
12691
12692 return GetGame().ConfigGetFloat(subclassPath + entryName);
12693 }
12694
12695
12696
12698 override void EEOnCECreate()
12699 {
12700 if (!IsMagazine())
12702
12704 }
12705
12706
12707 //-------------------------
12708 // OPEN/CLOSE USER ACTIONS
12709 //-------------------------
12711 void Open();
12712 void Close();
12713 bool IsOpen()
12714 {
12715 return true;
12716 }
12717
12718 override bool CanDisplayCargo()
12719 {
12720 return IsOpen();
12721 }
12722
12723
12724 // ------------------------------------------------------------
12725 // CONDITIONS
12726 // ------------------------------------------------------------
12727 override bool CanPutInCargo(EntityAI parent)
12728 {
12729 if (parent)
12730 {
12731 if (parent.IsInherited(DayZInfected))
12732 return true;
12733
12734 if (!parent.IsRuined())
12735 return true;
12736 }
12737
12738 return true;
12739 }
12740
12741 override bool CanPutAsAttachment(EntityAI parent)
12742 {
12743 if (!super.CanPutAsAttachment(parent))
12744 {
12745 return false;
12746 }
12747
12748 if (!IsRuined() && !parent.IsRuined())
12749 {
12750 return true;
12751 }
12752
12753 return false;
12754 }
12755
12756 override bool CanReceiveItemIntoCargo(EntityAI item)
12757 {
12758 //removed 15.06. coz of loading from storage -> after load items in cargo was lost -> waiting for proper solution
12759 //if (GetHealthLevel() == GameConstants.STATE_RUINED)
12760 // return false;
12761
12762 return super.CanReceiveItemIntoCargo(item);
12763 }
12764
12765 override bool CanReceiveAttachment(EntityAI attachment, int slotId)
12766 {
12767 //removed 15.06. coz of loading from storage -> after load items in cargo was lost -> waiting for proper solution
12768 //if (GetHealthLevel() == GameConstants.STATE_RUINED)
12769 // return false;
12770
12771 GameInventory attachmentInv = attachment.GetInventory();
12772 if (attachmentInv && attachmentInv.GetCargo() && attachmentInv.GetCargo().GetItemCount() > 0)
12773 {
12774 if (GetHierarchyParent() && !GetHierarchyParent().IsInherited(PlayerBase))
12775 return false;
12776 }
12777
12778 InventoryLocation loc = new InventoryLocation();
12779 attachment.GetInventory().GetCurrentInventoryLocation(loc);
12780 if (loc && loc.IsValid() && !GetInventory().AreChildrenAccessible())
12781 return false;
12782
12783 return super.CanReceiveAttachment(attachment, slotId);
12784 }
12785
12786 override bool CanReleaseAttachment(EntityAI attachment)
12787 {
12788 if (!super.CanReleaseAttachment(attachment))
12789 return false;
12790
12791 return GetInventory().AreChildrenAccessible();
12792 }
12793
12794 /*override bool CanLoadAttachment(EntityAI attachment)
12795 {
12796 //removed 15.06. coz of loading from storage -> after load items in cargo was lost -> waiting for proper solution
12797 //if (GetHealthLevel() == GameConstants.STATE_RUINED)
12798 // return false;
12799
12800 GameInventory attachmentInv = attachment.GetInventory();
12801 if (attachmentInv && attachmentInv.GetCargo() && attachmentInv.GetCargo().GetItemCount() > 0)
12802 {
12803 bool boo = (GetHierarchyParent() && !GetHierarchyParent().IsInherited(PlayerBase));
12804 ErrorEx("CanLoadAttachment | this: " + this + " | attachment: " + attachment + " | boo: " + boo,ErrorExSeverity.INFO);
12805
12806 if (GetHierarchyParent() && !GetHierarchyParent().IsInherited(PlayerBase))
12807 return false;
12808 }
12809
12810 return super.CanLoadAttachment(attachment);
12811 }*/
12812
12813 // Plays muzzle flash particle effects
12814 static void PlayFireParticles(ItemBase weapon, int muzzle_index, string ammoType, ItemBase muzzle_owner, ItemBase suppressor, string config_to_search)
12815 {
12816 int id = muzzle_owner.GetMuzzleID();
12817 array<ref WeaponParticlesOnFire> WPOF_array = m_OnFireEffect.Get(id);
12818
12819 if (WPOF_array)
12820 {
12821 for (int i = 0; i < WPOF_array.Count(); i++)
12822 {
12823 WeaponParticlesOnFire WPOF = WPOF_array.Get(i);
12824
12825 if (WPOF)
12826 {
12827 WPOF.OnActivate(weapon, muzzle_index, ammoType, muzzle_owner, suppressor, config_to_search);
12828 }
12829 }
12830 }
12831 }
12832
12833 // Plays bullet eject particle effects (usually just smoke, the bullet itself is a 3D model and is not part of this function)
12834 static void PlayBulletCasingEjectParticles(ItemBase weapon, string ammoType, ItemBase muzzle_owner, ItemBase suppressor, string config_to_search)
12835 {
12836 int id = muzzle_owner.GetMuzzleID();
12837 array<ref WeaponParticlesOnBulletCasingEject> WPOBE_array = m_OnBulletCasingEjectEffect.Get(id);
12838
12839 if (WPOBE_array)
12840 {
12841 for (int i = 0; i < WPOBE_array.Count(); i++)
12842 {
12843 WeaponParticlesOnBulletCasingEject WPOBE = WPOBE_array.Get(i);
12844
12845 if (WPOBE)
12846 {
12847 WPOBE.OnActivate(weapon, 0, ammoType, muzzle_owner, suppressor, config_to_search);
12848 }
12849 }
12850 }
12851 }
12852
12853 // Plays all weapon overheating particles
12854 static void PlayOverheatingParticles(ItemBase weapon, string ammoType, ItemBase muzzle_owner, ItemBase suppressor, string config_to_search)
12855 {
12856 int id = muzzle_owner.GetMuzzleID();
12857 array<ref WeaponParticlesOnOverheating> WPOOH_array = weapon.m_OnOverheatingEffect.Get(id);
12858
12859 if (WPOOH_array)
12860 {
12861 for (int i = 0; i < WPOOH_array.Count(); i++)
12862 {
12863 WeaponParticlesOnOverheating WPOOH = WPOOH_array.Get(i);
12864
12865 if (WPOOH)
12866 {
12867 WPOOH.OnActivate(weapon, 0, ammoType, muzzle_owner, suppressor, config_to_search);
12868 }
12869 }
12870 }
12871 }
12872
12873 // Updates all weapon overheating particles
12874 static void UpdateOverheatingParticles(ItemBase weapon, string ammoType, ItemBase muzzle_owner, ItemBase suppressor, string config_to_search)
12875 {
12876 int id = muzzle_owner.GetMuzzleID();
12877 array<ref WeaponParticlesOnOverheating> WPOOH_array = weapon.m_OnOverheatingEffect.Get(id);
12878
12879 if (WPOOH_array)
12880 {
12881 for (int i = 0; i < WPOOH_array.Count(); i++)
12882 {
12883 WeaponParticlesOnOverheating WPOOH = WPOOH_array.Get(i);
12884
12885 if (WPOOH)
12886 {
12887 WPOOH.OnUpdate(weapon, ammoType, muzzle_owner, suppressor, config_to_search);
12888 }
12889 }
12890 }
12891 }
12892
12893 // Stops overheating particles
12894 static void StopOverheatingParticles(ItemBase weapon, string ammoType, ItemBase muzzle_owner, ItemBase suppressor, string config_to_search)
12895 {
12896 int id = muzzle_owner.GetMuzzleID();
12897 array<ref WeaponParticlesOnOverheating> WPOOH_array = weapon.m_OnOverheatingEffect.Get(id);
12898
12899 if (WPOOH_array)
12900 {
12901 for (int i = 0; i < WPOOH_array.Count(); i++)
12902 {
12903 WeaponParticlesOnOverheating WPOOH = WPOOH_array.Get(i);
12904
12905 if (WPOOH)
12906 {
12907 WPOOH.OnDeactivate(weapon, ammoType, muzzle_owner, suppressor, config_to_search);
12908 }
12909 }
12910 }
12911 }
12912
12913 //----------------------------------------------------------------
12914 //Item Behaviour - unified approach
12915 override bool IsHeavyBehaviour()
12916 {
12917 if (m_ItemBehaviour == 0)
12918 {
12919 return true;
12920 }
12921
12922 return false;
12923 }
12924
12925 override bool IsOneHandedBehaviour()
12926 {
12927 if (m_ItemBehaviour == 1)
12928 {
12929 return true;
12930 }
12931
12932 return false;
12933 }
12934
12935 override bool IsTwoHandedBehaviour()
12936 {
12937 if (m_ItemBehaviour == 2)
12938 {
12939 return true;
12940 }
12941
12942 return false;
12943 }
12944
12945 bool IsDeployable()
12946 {
12947 return false;
12948 }
12949
12951 float GetDeployTime()
12952 {
12953 return UATimeSpent.DEFAULT_DEPLOY;
12954 }
12955
12956
12957 //----------------------------------------------------------------
12958 // Item Targeting (User Actions)
12959 override void SetTakeable(bool pState)
12960 {
12961 m_IsTakeable = pState;
12962 SetSynchDirty();
12963 }
12964
12965 override bool IsTakeable()
12966 {
12967 return m_IsTakeable;
12968 }
12969
12970 // For cases where we want to show object widget which cant be taken to hands
12972 {
12973 return false;
12974 }
12975
12977 protected void PreLoadSoundAttachmentType()
12978 {
12979 string att_type = "None";
12980
12981 if (ConfigIsExisting("soundAttType"))
12982 {
12983 att_type = ConfigGetString("soundAttType");
12984 }
12985
12986 m_SoundAttType = att_type;
12987 }
12988
12989 override string GetAttachmentSoundType()
12990 {
12991 return m_SoundAttType;
12992 }
12993
12994 //----------------------------------------------------------------
12995 //SOUNDS - ItemSoundHandler
12996 //----------------------------------------------------------------
12997
12998 string GetPlaceSoundset(); // played when deploy starts
12999 string GetLoopDeploySoundset(); // played when deploy starts and stopped when it finishes
13000 string GetDeploySoundset(); // played when deploy sucessfully finishes
13001 string GetLoopFoldSoundset(); // played when fold starts and stopped when it finishes
13002 string GetFoldSoundset(); // played when fold sucessfully finishes
13003
13005 {
13006 if (!m_ItemSoundHandler)
13008
13009 return m_ItemSoundHandler;
13010 }
13011
13012 // override to initialize sounds
13013 protected void InitItemSounds()
13014 {
13015 if (GetPlaceSoundset() == string.Empty && GetDeploySoundset() == string.Empty && GetLoopDeploySoundset() == string.Empty)
13016 return;
13017
13019
13020 if (GetPlaceSoundset() != string.Empty)
13021 handler.AddSound(SoundConstants.ITEM_PLACE, GetPlaceSoundset());
13022
13023 if (GetDeploySoundset() != string.Empty)
13024 handler.AddSound(SoundConstants.ITEM_DEPLOY, GetDeploySoundset());
13025
13026 SoundParameters params = new SoundParameters();
13027 params.m_Loop = true;
13028 if (GetLoopDeploySoundset() != string.Empty)
13029 handler.AddSound(SoundConstants.ITEM_DEPLOY_LOOP, GetLoopDeploySoundset(), params);
13030 }
13031
13032 // Start sound using ItemSoundHandler
13033 void StartItemSoundServer(int id)
13034 {
13035 if (!GetGame().IsServer())
13036 return;
13037
13038 m_SoundSyncPlay = id;
13039 SetSynchDirty();
13040
13041 GetGame().GetCallQueue(CALL_CATEGORY_SYSTEM).Remove(ClearStartItemSoundServer); // in case one is queued already
13043 }
13044
13045 // Stop sound using ItemSoundHandler
13046 void StopItemSoundServer(int id)
13047 {
13048 if (!GetGame().IsServer())
13049 return;
13050
13051 m_SoundSyncStop = id;
13052 SetSynchDirty();
13053
13054 GetGame().GetCallQueue(CALL_CATEGORY_SYSTEM).Remove(ClearStopItemSoundServer); // in case one is queued already
13056 }
13057
13058 protected void ClearStartItemSoundServer()
13059 {
13060 m_SoundSyncPlay = 0;
13061 }
13062
13063 protected void ClearStopItemSoundServer()
13064 {
13065 m_SoundSyncStop = 0;
13066 }
13067
13069 void PlayAttachSound(string slot_type)
13070 {
13071 if (!GetGame().IsDedicatedServer())
13072 {
13073 if (ConfigIsExisting("attachSoundSet"))
13074 {
13075 string cfg_path = "";
13076 string soundset = "";
13077 string type_name = GetType();
13078
13079 TStringArray cfg_soundset_array = new TStringArray;
13080 TStringArray cfg_slot_array = new TStringArray;
13081 ConfigGetTextArray("attachSoundSet",cfg_soundset_array);
13082 ConfigGetTextArray("attachSoundSlot",cfg_slot_array);
13083
13084 if (cfg_soundset_array.Count() > 0 && cfg_soundset_array.Count() == cfg_slot_array.Count())
13085 {
13086 for (int i = 0; i < cfg_soundset_array.Count(); i++)
13087 {
13088 if (cfg_slot_array[i] == slot_type)
13089 {
13090 soundset = cfg_soundset_array[i];
13091 break;
13092 }
13093 }
13094 }
13095
13096 if (soundset != "")
13097 {
13098 EffectSound sound = SEffectManager.PlaySound(soundset, GetPosition());
13099 sound.SetAutodestroy(true);
13100 }
13101 }
13102 }
13103 }
13104
13105 void PlayDetachSound(string slot_type)
13106 {
13107 //TODO - evaluate if needed and devise universal config structure if so
13108 }
13109
13110 void OnApply(PlayerBase player);
13111
13113 {
13114 return 1.0;
13115 };
13116 //returns applicable selection
13117 array<string> GetHeadHidingSelection()
13118 {
13120 }
13121
13123 {
13125 }
13126
13127 WrittenNoteData GetWrittenNoteData() {};
13128
13130 {
13131 SetDynamicPhysicsLifeTime(0.01);
13132 m_ItemBeingDroppedPhys = false;
13133 }
13134
13136 {
13137 array<string> zone_names = new array<string>;
13138 GetDamageZones(zone_names);
13139 for (int i = 0; i < zone_names.Count(); i++)
13140 {
13141 SetHealthMax(zone_names.Get(i),"Health");
13142 }
13143 SetHealthMax("","Health");
13144 }
13145
13147 void SetZoneDamageCEInit()
13148 {
13149 float global_health = GetHealth01("","Health");
13150 array<string> zones = new array<string>;
13151 GetDamageZones(zones);
13152 //set damage of all zones to match global health level
13153 for (int i = 0; i < zones.Count(); i++)
13154 {
13155 SetHealth01(zones.Get(i),"Health",global_health);
13156 }
13157 }
13158
13160 bool IsCoverFaceForShave(string slot_name)
13161 {
13162 return IsExclusionFlagPresent(PlayerBase.GetFaceCoverageShaveValues());
13163 }
13164
13165 void ProcessItemWetness(float delta, bool hasParent, bool hasRootAsPlayer, ItemBase refParentIB)
13166 {
13167 if (!hasRootAsPlayer)
13168 {
13169 if (refParentIB)
13170 {
13171 // parent is wet
13172 if ((refParentIB.GetWet() >= GameConstants.STATE_SOAKING_WET) && (m_VarWet < m_VarWetMax))
13173 AddWet(delta * GameConstants.WETNESS_RATE_WETTING_INSIDE);
13174 // parent has liquid inside
13175 else if ((refParentIB.GetLiquidType() != 0) && (refParentIB.GetQuantity() > 0) && (m_VarWet < m_VarWetMax))
13176 AddWet(delta * GameConstants.WETNESS_RATE_WETTING_LIQUID);
13177 // drying
13178 else if (m_VarWet > m_VarWetMin)
13179 AddWet(-1 * delta * GetDryingIncrement("ground") * 2);
13180 }
13181 else
13182 {
13183 // drying on ground or inside non-itembase (car, ...)
13184 if (m_VarWet > m_VarWetMin)
13185 AddWet(-1 * delta * GetDryingIncrement("ground"));
13186 }
13187 }
13188 }
13189
13190 void ProcessItemTemperature(float delta, bool hasParent, bool hasRootAsPlayer, ItemBase refParentIB)
13191 {
13193 {
13194 float target = g_Game.GetMission().GetWorldData().GetBaseEnvTemperatureAtObject(this);
13195 if (GetTemperature() != target || !IsFreezeThawProgressFinished())
13196 {
13197 float heatPermCoef = 1.0;
13198 EntityAI ent = this;
13199 while (ent)
13200 {
13201 heatPermCoef *= ent.GetHeatPermeabilityCoef();
13202 ent = ent.GetHierarchyParent();
13203 }
13204
13205 SetTemperatureEx(new TemperatureDataInterpolated(target,ETemperatureAccessTypes.ACCESS_WORLD,delta,GameConstants.TEMP_COEF_WORLD,heatPermCoef));
13206 }
13207 }
13208 }
13209
13210 void HierarchyCheck(out bool hasParent, out bool hasRootAsPlayer, out ItemBase refParentIB)
13211 {
13212 // hierarchy check for an item to decide whether it has some parent and it is in some player inventory
13213 EntityAI parent = GetHierarchyParent();
13214 if (!parent)
13215 {
13216 hasParent = false;
13217 hasRootAsPlayer = false;
13218 }
13219 else
13220 {
13221 hasParent = true;
13222 hasRootAsPlayer = (GetHierarchyRootPlayer() != null);
13223 refParentIB = ItemBase.Cast(parent);
13224 }
13225 }
13226
13227 protected void ProcessDecay(float delta, bool hasRootAsPlayer)
13228 {
13229 // this is stub, implemented on Edible_Base
13230 }
13231
13232 bool CanDecay()
13233 {
13234 // return true used on selected food clases so they can decay
13235 return false;
13236 }
13237
13238 protected bool CanProcessDecay()
13239 {
13240 // this is stub, implemented on Edible_Base class
13241 // used to determine whether it is still necessary for the food to decay
13242 return false;
13243 }
13244
13245 protected bool CanHaveWetness()
13246 {
13247 // return true used on selected items that have a wetness effect
13248 return false;
13249 }
13250
13252 bool CanBeConsumed(ConsumeConditionData data = null)
13253 {
13254 return !GetIsFrozen() && IsOpen();
13255 }
13256
13257 override void ProcessVariables()
13258 {
13259 bool hasParent = false, hasRootAsPlayer = false;
13260 ItemBase refParentIB;
13261
13262 bool wwtu = g_Game.IsWorldWetTempUpdateEnabled();
13263 bool foodDecay = g_Game.IsFoodDecayEnabled();
13264
13265 if (wwtu || foodDecay)
13266 {
13267 bool processWetness = wwtu && CanHaveWetness();
13268 bool processTemperature = wwtu && CanHaveTemperature();
13269 bool processDecay = foodDecay && CanDecay() && CanProcessDecay();
13270
13271 if (processWetness || processTemperature || processDecay)
13272 {
13273 HierarchyCheck(hasParent, hasRootAsPlayer, refParentIB);
13274
13275 if (processWetness)
13276 ProcessItemWetness(m_ElapsedSinceLastUpdate, hasParent, hasRootAsPlayer, refParentIB);
13277
13278 if (processTemperature)
13279 ProcessItemTemperature(m_ElapsedSinceLastUpdate, hasParent, hasRootAsPlayer, refParentIB);
13280
13281 if (processDecay)
13282 ProcessDecay(m_ElapsedSinceLastUpdate, hasRootAsPlayer);
13283 }
13284 }
13285 }
13286
13289 {
13290 return m_TemperaturePerQuantityWeight * GameConstants.ITEM_TEMPERATURE_QUANTITY_WEIGHT_MULTIPLIER;
13291 }
13292
13293 override float GetTemperatureFreezeThreshold()
13294 {
13296 return Liquid.GetFreezeThreshold(GetLiquidType());
13297
13298 return super.GetTemperatureFreezeThreshold();
13299 }
13300
13301 override float GetTemperatureThawThreshold()
13302 {
13304 return Liquid.GetThawThreshold(GetLiquidType());
13305
13306 return super.GetTemperatureThawThreshold();
13307 }
13308
13309 override float GetItemOverheatThreshold()
13310 {
13312 return Liquid.GetBoilThreshold(GetLiquidType());
13313
13314 return super.GetItemOverheatThreshold();
13315 }
13316
13317 override float GetTemperatureFreezeTime()
13318 {
13319 if (HasQuantity())
13320 return Math.Lerp(GameConstants.TEMPERATURE_TIME_FREEZE_MIN,Math.Max(GameConstants.TEMPERATURE_TIME_FREEZE_MIN,super.GetTemperatureFreezeTime()),GetQuantityNormalized());
13321
13322 return super.GetTemperatureFreezeTime();
13323 }
13324
13325 override float GetTemperatureThawTime()
13326 {
13327 if (HasQuantity())
13328 return Math.Lerp(GameConstants.TEMPERATURE_TIME_THAW_MIN,Math.Max(GameConstants.TEMPERATURE_TIME_FREEZE_MIN,super.GetTemperatureThawTime()),GetQuantityNormalized());
13329
13330 return super.GetTemperatureThawTime();
13331 }
13332
13334 void AffectLiquidContainerOnFill(int liquid_type, float amount);
13336 void AffectLiquidContainerOnTransfer(int liquidType, float amount, float sourceLiquidTemperature);
13337
13338 bool IsCargoException4x3(EntityAI item)
13339 {
13340 return (item.IsKindOf("Cauldron") || item.IsKindOf("Pot") || item.IsKindOf("FryingPan") || item.IsKindOf("SmallProtectorCase") || (item.IsKindOf("PortableGasStove") && item.FindAttachmentBySlotName("CookingEquipment")));
13341 }
13342
13344 {
13345 MiscGameplayFunctions.TransferItemProperties(oldItem, this);
13346 }
13347
13349 void AddLightSourceItem(ItemBase lightsource)
13350 {
13351 m_LightSourceItem = lightsource;
13352 }
13353
13355 {
13356 m_LightSourceItem = null;
13357 }
13358
13360 {
13361 return m_LightSourceItem;
13362 }
13363
13365 array<int> GetValidFinishers()
13366 {
13367 return null;
13368 }
13369
13371 bool GetActionWidgetOverride(out typename name)
13372 {
13373 return false;
13374 }
13375
13376 bool PairWithDevice(notnull ItemBase otherDevice)
13377 {
13378 if (GetGame().IsServer())
13379 {
13380 ItemBase explosive = otherDevice;
13382 if (!trg)
13383 {
13384 trg = RemoteDetonatorTrigger.Cast(otherDevice);
13385 explosive = this;
13386 }
13387
13388 explosive.PairRemote(trg);
13389 trg.SetControlledDevice(explosive);
13390
13391 int persistentID = RemotelyActivatedItemBehaviour.GeneratePersistentID();
13392 trg.SetPersistentPairID(persistentID);
13393 explosive.SetPersistentPairID(persistentID);
13394
13395 return true;
13396 }
13397 return false;
13398 }
13399
13401 float GetBaitEffectivity()
13402 {
13403 float ret = 1.0;
13404 if (HasQuantity())
13405 ret *= GetQuantityNormalized();
13406 ret *= GetHealth01();
13407
13408 return ret;
13409 }
13410
13411 #ifdef DEVELOPER
13412 override void SetDebugItem()
13413 {
13414 super.SetDebugItem();
13415 _itemBase = this;
13416 }
13417
13418 override string GetDebugText()
13419 {
13420 string text = super.GetDebugText();
13421
13422 text += string.Format("Heat isolation(raw): %1\n", GetHeatIsolation());
13423 text += string.Format("Heat isolation(modified): %1\n", MiscGameplayFunctions.GetCurrentItemHeatIsolation(this));
13424
13425 return text;
13426 }
13427 #endif
13428
13429 bool CanBeUsedForSuicide()
13430 {
13431 return true;
13432 }
13433
13435 //DEPRECATED BELOW
13437 // Backwards compatibility
13438 void ProcessItemWetnessAndTemperature(float delta, bool hasParent, bool hasRootAsPlayer, ItemBase refParentIB)
13439 {
13440 ProcessItemWetness(delta, hasParent, hasRootAsPlayer, refParentIB);
13441 ProcessItemTemperature(delta, hasParent, hasRootAsPlayer, refParentIB);
13442 }
13443
13444 // replaced by ItemSoundHandler
13445 protected EffectSound m_SoundDeployFinish;
13446 protected EffectSound m_SoundPlace;
13447 protected EffectSound m_DeployLoopSoundEx;
13448 protected EffectSound m_SoundDeploy;
13449 bool m_IsPlaceSound;
13450 bool m_IsDeploySound;
13452
13453 string GetDeployFinishSoundset();
13454 void PlayDeploySound();
13455 void PlayDeployFinishSound();
13456 void PlayPlaceSound();
13457 void PlayDeployLoopSoundEx();
13458 void StopDeployLoopSoundEx();
13459 void SoundSynchRemoteReset();
13460 void SoundSynchRemote();
13461 bool UsesGlobalDeploy(){return false;}
13462 bool CanPlayDeployLoopSound(){return false;}
13464 bool IsPlaceSound(){return m_IsPlaceSound;}
13465 bool IsDeploySound(){return m_IsDeploySound;}
13466 void SetIsPlaceSound(bool is_place_sound);
13467 void SetIsDeploySound(bool is_deploy_sound);
13468}
13469
13470EntityAI SpawnItemOnLocation(string object_name, notnull InventoryLocation loc, bool full_quantity)
13471{
13472 EntityAI entity = SpawnEntity(object_name, loc, ECE_IN_INVENTORY, RF_DEFAULT);
13473 if (entity)
13474 {
13475 bool is_item = entity.IsInherited(ItemBase);
13476 if (is_item && full_quantity)
13477 {
13478 ItemBase item = ItemBase.Cast(entity);
13479 item.SetQuantity(item.GetQuantityInit());
13480 }
13481 }
13482 else
13483 {
13484 ErrorEx("Cannot spawn entity: " + object_name,ErrorExSeverity.INFO);
13485 return NULL;
13486 }
13487 return entity;
13488}
13489
13490void SetupSpawnedItem(ItemBase item, float health, float quantity)
13491{
13492 if (item)
13493 {
13494 if (health > 0)
13495 item.SetHealth("", "", health);
13496
13497 if (item.CanHaveTemperature())
13498 {
13499 item.SetTemperatureDirect(GameConstants.ITEM_TEMPERATURE_NEUTRAL_ZONE_MIDDLE);
13500 if (item.CanFreeze())
13501 item.SetFrozen(false);
13502 }
13503
13504 if (item.HasEnergyManager())
13505 {
13506 if (quantity >= 0)
13507 {
13508 item.GetCompEM().SetEnergy0To1(quantity);
13509 }
13510 else
13511 {
13512 item.GetCompEM().SetEnergy(Math.AbsFloat(quantity));
13513 }
13514 }
13515 else if (item.IsMagazine())
13516 {
13517 Magazine mag = Magazine.Cast(item);
13518 if (quantity >= 0)
13519 {
13520 mag.ServerSetAmmoCount(mag.GetAmmoMax() * quantity);
13521 }
13522 else
13523 {
13524 mag.ServerSetAmmoCount(Math.AbsFloat(quantity));
13525 }
13526
13527 }
13528 else
13529 {
13530 if (quantity >= 0)
13531 {
13532 item.SetQuantityNormalized(quantity, false);
13533 }
13534 else
13535 {
13536 item.SetQuantity(Math.AbsFloat(quantity));
13537 }
13538
13539 }
13540 }
13541}
13542
13543#ifdef DEVELOPER
13544ItemBase _itemBase;//watched item goes here(LCTRL+RMB->Watch)
13545#endif
Param4< int, int, string, int > TSelectableActionInfoWithColor
Определения 3_Game/Entities/EntityAI.c:97
Param3 TSelectableActionInfo
EWetnessLevel
Определения 3_Game/Entities/EntityAI.c:2
InventoryMode
NOTE: PREDICTIVE is not to be used at all in multiplayer.
const int INPUT_UDT_ITEM_MANIPULATION
class LogManager EntityAI
eBleedingSourceType GetType()
ItemSuppressor SuppressorBase
void ActionDropItem()
Определения ActionDropItem.c:14
void ActionManagerBase(PlayerBase player)
Определения ActionManagerBase.c:63
map< typename, ref array< ActionBase_Basic > > TInputActionMap
Определения ActionManagerClient.c:1
void AddAction(typename actionName)
Определения AdvancedCommunication.c:220
void RemoveAction(typename actionName)
Определения AdvancedCommunication.c:252
TInputActionMap m_InputActionMap
Определения AdvancedCommunication.c:137
bool m_ActionsInitialize
Определения AdvancedCommunication.c:138
override void GetActions(typename action_input_type, out array< ActionBase_Basic > actions)
Определения AdvancedCommunication.c:202
void InitializeActions()
Определения AdvancedCommunication.c:190
int GetLiquidType()
Определения CCTWaterSurface.c:129
const int ECE_PLACE_ON_SURFACE
Определения CentralEconomy.c:37
proto native void SpawnEntity(string sClassName, vector vPos, float fRange, int iCount)
Spawn an entity through CE.
const int ECE_IN_INVENTORY
Определения CentralEconomy.c:36
const int RF_DEFAULT
Определения CentralEconomy.c:65
PlayerSpawnPresetDiscreteItemSetSlotData name
one set for cargo
PlayerSpawnPreset slotName
Open
Implementations only.
override void EEOnCECreate()
Определения ContaminatedArea_Dynamic.c:42
map
Определения ControlsXboxNew.c:4
CookingMethodType
Определения Cooking.c:2
DamageType
exposed from C++ (do not change)
Определения DamageSystem.c:11
DayZGame g_Game
Определения DayZGame.c:3868
DayZGame GetDayZGame()
Определения DayZGame.c:3870
EActions
Определения EActions.c:2
ERPCs
Определения ERPCs.c:2
PluginAdminLog m_AdminLog
Определения EmoteManager.c:142
const int MAX
Определения EnConvert.c:27
float GetTemperature()
Определения Environment.c:497
override bool IsExplosive()
Определения ExplosivesBase.c:59
override bool CanHaveTemperature()
Определения FireplaceBase.c:559
class GP5GasMask extends MaskBase ItemBase
Empty
Определения Hand_States.c:14
FindInventoryLocationType
flags for searching locations in inventory
Определения InventoryLocation.c:17
InventoryLocationType
types of Inventory Location
Определения InventoryLocation.c:4
class BoxCollidingParams component
ComponentInfo for BoxCollidingResult.
bool DamageItemInCargo(float damage)
Определения ItemBase.c:6380
static bool HasDebugActionsMask(int mask)
Определения ItemBase.c:5620
bool HidesSelectionBySlot()
Определения ItemBase.c:9347
float m_VarWetMin
Определения ItemBase.c:4881
void SplitItem(PlayerBase player)
Определения ItemBase.c:6831
void CopyScriptPropertiesFrom(EntityAI oldItem)
Определения ItemBase.c:9568
override void InsertAgent(int agent, float count=1)
Определения ItemBase.c:8795
override float GetQuantityNormalized()
Gets quantity in normalized 0..1 form between the item's Min a Max values as defined by item's config...
Определения ItemBase.c:8229
static void SetDebugActionsMask(int mask)
Определения ItemBase.c:5625
void SetIsDeploySound(bool is_deploy_sound)
bool IsOpen()
Определения ItemBase.c:8938
void SplitItemToInventoryLocation(notnull InventoryLocation dst)
Определения ItemBase.c:6798
override bool IsHeavyBehaviour()
Определения ItemBase.c:9140
override void SetWetMax()
Определения ItemBase.c:8511
bool IsCoverFaceForShave(string slot_name)
DEPRECATED in use, but returns correct values nontheless. Check performed elsewhere.
Определения ItemBase.c:9385
void ClearStartItemSoundServer()
Определения ItemBase.c:9283
float m_VarWet
Определения ItemBase.c:4878
void ProcessItemTemperature(float delta, bool hasParent, bool hasRootAsPlayer, ItemBase refParentIB)
Определения ItemBase.c:9415
map< typename, ref ActionOverrideData > TActionAnimOverrideMap
Определения ItemBase.c:2
override void RemoveAllAgentsExcept(int agent_to_keep)
Определения ItemBase.c:8790
static ref map< int, ref array< ref WeaponParticlesOnBulletCasingEject > > m_OnBulletCasingEjectEffect
Определения ItemBase.c:4941
bool CanBeMovedOverride()
Определения ItemBase.c:7522
override void SetWet(float value, bool allow_client=false)
Определения ItemBase.c:8487
ref TIntArray m_SingleUseActions
Определения ItemBase.c:4927
override void ProcessVariables()
Определения ItemBase.c:9482
ref TStringArray m_HeadHidingSelections
Определения ItemBase.c:4955
float GetWeightSpecialized(bool forceRecalc=false)
Определения ItemBase.c:8321
bool LoadAgents(ParamsReadContext ctx, int version)
Определения ItemBase.c:8856
void UpdateQuickbarShortcutVisibility(PlayerBase player)
To be called on moving item within character's inventory; 'player' should never be null.
Определения ItemBase.c:8701
void OverrideActionAnimation(typename action, int commandUID, int stanceMask=-1, int commandUIDProne=-1)
Определения ItemBase.c:5211
ref array< ref OverheatingParticle > m_OverheatingParticles
Определения ItemBase.c:4953
override float GetTemperatureFreezeThreshold()
Определения ItemBase.c:9518
bool m_IsSoundSynchRemote
Определения ItemBase.c:9676
float m_OverheatingShots
Определения ItemBase.c:4948
void StopItemSoundServer(int id)
Определения ItemBase.c:9271
static void ToggleDebugActionsMask(int mask)
Определения ItemBase.c:5640
void IncreaseOverheating(ItemBase weapon, string ammoType, ItemBase muzzle_owner, ItemBase suppressor, string config_to_search)
Определения ItemBase.c:5364
override float GetTemperatureFreezeTime()
Определения ItemBase.c:9542
ref array< int > m_CompatibleLocks
Определения ItemBase.c:4965
bool CanBeCooked()
Определения ItemBase.c:7478
override void CombineItemsClient(EntityAI entity2, bool use_stack_max=true)
Определения ItemBase.c:5707
float m_TemperaturePerQuantityWeight
Определения ItemBase.c:4977
bool m_RecipesInitialized
Определения ItemBase.c:4863
void SplitIntoStackMax(EntityAI destination_entity, int slot_id, PlayerBase player)
Определения ItemBase.c:6471
override float GetTemperatureThawThreshold()
Определения ItemBase.c:9526
override void OnEnergyConsumed()
Определения ItemBase.c:8431
void RefreshAudioVisualsOnClient(CookingMethodType cooking_method, bool is_done, bool is_empty, bool is_burned)
cooking-related effect methods
Определения Bottle_Base.c:158
int GetNumberOfItems()
Returns the number of items in cargo, otherwise returns 0(non-cargo objects). Recursive.
Определения ItemBase.c:8360
override EWetnessLevel GetWetLevel()
Определения ItemBase.c:8551
float GetSingleInventoryItemWeight()
Определения ItemBase.c:8316
ref TIntArray m_InteractActions
Определения ItemBase.c:4929
void MessageToOwnerStatus(string text)
Send message to owner player in grey color.
Определения ItemBase.c:7542
float m_VarQuantity
Определения ItemBase.c:4869
bool CanPlayDeployLoopSound()
Определения ItemBase.c:9687
override float GetWetMax()
Определения ItemBase.c:8521
bool CanBeUsedForSuicide()
Определения ItemBase.c:9654
override void CombineItemsEx(EntityAI entity2, bool use_stack_max=true)
Определения ItemBase.c:7117
void OnItemInHandsPlayerSwimStart(PlayerBase player)
void SetIsHologram(bool is_hologram)
Определения ItemBase.c:5845
void OnSyncVariables(ParamsReadContext ctx)
DEPRECATED (most likely)
Определения ItemBase.c:7696
void StartItemSoundServer(int id)
Определения ItemBase.c:9258
void DoAmmoExplosion()
Определения ItemBase.c:6315
static ref map< int, ref array< ref WeaponParticlesOnFire > > m_OnFireEffect
Определения ItemBase.c:4940
void SplitIntoStackMaxCargoClient(EntityAI destination_entity, int idx, int row, int col)
Определения ItemBase.c:6655
int GetItemSize()
Определения ItemBase.c:7507
bool m_CanBeMovedOverride
Определения ItemBase.c:4906
override string ChangeIntoOnAttach(string slot)
Определения ItemBase.c:6239
void UpdateOverheating(ItemBase weapon=null, string ammoType="", ItemBase muzzle_owner=null, ItemBase suppressor=null, string config_to_search="")
Определения ItemBase.c:5432
bool CanDecay()
Определения ItemBase.c:9457
ScriptedLightBase GetLight()
string GetPlaceSoundset()
bool AddQuantity(float value, bool destroy_config=true, bool destroy_forced=false)
add item quantity[related to varQuantity... config entry], destroy_config = true > if the quantity re...
Определения ItemBase.c:8202
void SetQuantityMax()
Определения ItemBase.c:8207
override float GetQuantity()
Определения ItemBase.c:8296
int m_ColorComponentR
Определения ItemBase.c:4918
int m_ShotsToStartOverheating
Определения ItemBase.c:4950
override void OnWetChanged(float newVal, float oldVal)
Определения ItemBase.c:8536
void StopOverheating(ItemBase weapon=null, string ammoType="", ItemBase muzzle_owner=null, ItemBase suppressor=null, string config_to_search="")
Определения ItemBase.c:5439
static void PlayFireParticles(ItemBase weapon, int muzzle_index, string ammoType, ItemBase muzzle_owner, ItemBase suppressor, string config_to_search)
Определения ItemBase.c:9039
void OnOverheatingDecay()
Определения ItemBase.c:5402
float GetDryingIncrement(string pIncrementName)
Определения ItemBase.c:8469
void SoundSynchRemoteReset()
int m_Cleanness
Определения ItemBase.c:4884
bool HasMuzzle()
Returns true if this item has a muzzle (weapons, suppressors)
Определения ItemBase.c:5540
bool UsesGlobalDeploy()
Определения ItemBase.c:9686
int m_ItemBehaviour
Определения ItemBase.c:4899
override bool CanReleaseAttachment(EntityAI attachment)
Определения ItemBase.c:9011
float m_HeatIsolation
Определения ItemBase.c:4894
float m_VarWetInit
Определения ItemBase.c:4880
override void OnMovedInsideCargo(EntityAI container)
Определения ItemBase.c:5885
void SetCEBasedQuantity()
Определения ItemBase.c:5653
bool m_CanPlayImpactSound
Определения ItemBase.c:4890
override string GetAttachmentSoundType()
Определения ItemBase.c:9214
float GetOverheatingCoef()
Определения ItemBase.c:5459
array< string > GetHeadHidingSelection()
Определения ItemBase.c:9342
void PlayAttachSound(string slot_type)
Plays sound on item attach. Be advised, the config structure may slightly change in 1....
Определения ItemBase.c:9294
override bool IsStoreLoad()
Определения ItemBase.c:8563
int ComputeQuantityUsed(ItemBase other_item, bool use_stack_max=true)
Определения ItemBase.c:7093
bool IsLightSource()
Определения ItemBase.c:5781
bool m_HasQuantityBar
Определения ItemBase.c:4912
void SetResultOfSplit(bool value)
Определения ItemBase.c:7088
void SplitIntoStackMaxCargo(EntityAI destination_entity, int idx, int row, int col)
Определения ItemBase.c:6719
void OnAttachmentQuantityChanged(ItemBase item)
Called on server side when some attachment's quantity is changed. Call super.OnAttachmentQuantityChan...
Определения ItemBase.c:6889
void UpdateAllOverheatingParticles()
Определения ItemBase.c:5467
float GetSoakingIncrement(string pIncrementName)
Определения ItemBase.c:8478
static void StopOverheatingParticles(ItemBase weapon, string ammoType, ItemBase muzzle_owner, ItemBase suppressor, string config_to_search)
Определения ItemBase.c:9119
override float GetStoreLoadedQuantity()
Определения ItemBase.c:8573
int m_LockType
Определения ItemBase.c:4966
const int ITEM_SOUNDS_MAX
Определения ItemBase.c:4971
bool m_CanBeDigged
Определения ItemBase.c:4913
float m_ItemAttachOffset
Определения ItemBase.c:4896
float GetItemModelLength()
Определения ItemBase.c:8580
bool m_ThrowItemOnDrop
Определения ItemBase.c:4904
override bool ReadVarsFromCTX(ParamsReadContext ctx, int version=-1)
Определения ItemBase.c:7841
override void CheckForRoofLimited(float timeTresholdMS=3000)
Roof check for entity, limited by time (anti-spam solution)
Определения ItemBase.c:8871
void Close()
float GetHeatIsolation()
Определения ItemBase.c:8464
void CombineItems(ItemBase other_item, bool use_stack_max=true)
Определения ItemBase.c:7122
void TransferModifiers(PlayerBase reciever)
appears to be deprecated, legacy code
float GetTemperaturePerQuantityWeight()
Used in heat comfort calculations only!
Определения ItemBase.c:9513
bool CanHaveWetness()
Определения ItemBase.c:9470
int m_CleannessMin
Определения ItemBase.c:4886
void TransferAgents(int agents)
transfer agents from another item
Определения ItemBase.c:8804
string IDToName(int id)
Определения ItemBase.c:7689
bool CanBeConsumed(ConsumeConditionData data=null)
Items cannot be consumed if frozen by default. Override for exceptions.
Определения ItemBase.c:9477
float GetHeatIsolationInit()
Определения ItemBase.c:8459
void PlayPlaceSound()
void SetCanBeMovedOverride(bool setting)
Определения ItemBase.c:7529
override bool HasQuantity()
Определения ItemBase.c:8291
float m_VarWetPrev
Определения ItemBase.c:4879
int m_SoundSyncStop
Определения ItemBase.c:4973
bool IsCargoException4x3(EntityAI item)
Определения ItemBase.c:9563
ref TIntArray m_ContinuousActions
Определения ItemBase.c:4928
int GetMuzzleID()
Returns global muzzle ID. If not found, then it gets automatically registered.
Определения ItemBase.c:5549
void LoadParticleConfigOnFire(int id)
Определения ItemBase.c:5234
int m_VarLiquidType
Определения ItemBase.c:4898
int m_QuickBarBonus
Определения ItemBase.c:4900
void PreLoadSoundAttachmentType()
Attachment Sound Type getting from config file.
Определения ItemBase.c:9202
override float GetWetInit()
Определения ItemBase.c:8531
int m_ImpactSoundSurfaceHash
Определения ItemBase.c:4892
int m_SoundSyncPlay
Определения ItemBase.c:4972
int m_MaxOverheatingValue
Определения ItemBase.c:4951
void SetupSpawnedItem(ItemBase item, float health, float quantity)
Определения ItemBase.c:4875
bool m_IsTakeable
Определения ItemBase.c:4903
bool ShouldSplitQuantity(float quantity)
Определения ItemBase.c:6428
static ref map< string, int > m_WeaponTypeToID
Определения ItemBase.c:4943
string GetLockSoundSet()
Определения ItemBase.c:8629
string GetColorString()
Returns item's PROCEDURAL color as formated string, i.e. "#(argb,8,8,3)color(0.15,...
Определения ItemBase.c:8660
array< int > GetValidFinishers()
returns an array of possible finishers
Определения ItemBase.c:9590
void OnAttachmentQuantityChangedEx(ItemBase item, float delta)
Called on server side when some attachment's quantity is changed. Call super.OnAttachmentQuantityChan...
Определения ItemBase.c:6895
class ItemBase extends InventoryItem SpawnItemOnLocation(string object_name, notnull InventoryLocation loc, bool full_quantity)
Определения ItemBase.c:4855
ItemSoundHandler GetItemSoundHandler()
Определения ItemBase.c:9229
override int GetQuantityMin()
Определения ItemBase.c:8280
void SplitIntoStackMaxToInventoryLocationClient(notnull InventoryLocation dst)
Определения ItemBase.c:6634
override int GetQuickBarBonus()
Определения ItemBase.c:5119
override void SetTakeable(bool pState)
Определения ItemBase.c:9184
float m_OverheatingDecayInterval
Определения ItemBase.c:4952
void SetIsPlaceSound(bool is_place_sound)
override void SplitIntoStackMaxClient(EntityAI destination_entity, int slot_id)
Определения ItemBase.c:6448
void HierarchyCheck(out bool hasParent, out bool hasRootAsPlayer, out ItemBase refParentIB)
Определения ItemBase.c:9435
bool CanProcessDecay()
Определения ItemBase.c:9463
void RemoveAudioVisualsOnClient()
Определения Bottle_Base.c:151
void SoundSynchRemote()
static void AddDebugActionsMask(int mask)
Определения ItemBase.c:5630
void PlayDeployLoopSoundEx()
void RemoveLightSourceItem()
Определения ItemBase.c:9579
bool CanRepair(ItemBase item_repair_kit)
Определения ItemBase.c:7493
bool can_this_be_combined
Определения ItemBase.c:4908
EffectSound m_SoundDeploy
Определения ItemBase.c:9673
int m_Count
Определения ItemBase.c:4874
float GetBaitEffectivity()
generic effectivity as a bait for animal catching
Определения ItemBase.c:9626
float GetDeployTime()
how long it takes to deploy this item in seconds
Определения ItemBase.c:9176
override bool IsSplitable()
Определения ItemBase.c:6415
bool DamageItemAttachments(float damage)
Определения ItemBase.c:6399
override void WriteVarsToCTX(ParamsWriteContext ctx)
Определения ItemBase.c:7805
void ConvertEnergyToQuantity()
Определения ItemBase.c:8446
override void RemoveAllAgents()
Определения ItemBase.c:8785
override void SetQuantityToMinimum()
Определения ItemBase.c:8213
bool m_WantPlayImpactSound
Определения ItemBase.c:4889
override float GetTemperatureThawTime()
Определения ItemBase.c:9550
ref map< int, ref array< ref WeaponParticlesOnOverheating > > m_OnOverheatingEffect
Определения ItemBase.c:4942
int m_ColorComponentG
Определения ItemBase.c:4919
float m_StoreLoadedQuantity
Определения ItemBase.c:4876
void MessageToOwnerAction(string text)
Send message to owner player in yellow color.
Определения ItemBase.c:7560
int m_ColorComponentA
Определения ItemBase.c:4921
int m_VarQuantityInit
Определения ItemBase.c:4871
float GetFilterDamageRatio()
Определения ItemBase.c:5534
override void SetLiquidType(int value, bool allow_client=false)
Определения ItemBase.c:8673
void OnQuantityChanged(float delta)
Called on server side when this item's quantity is changed. Call super.OnQuantityChanged(); first whe...
Определения ItemBase.c:6865
void OnApply(PlayerBase player)
override void SetQuantityNormalized(float value, bool destroy_config=true, bool destroy_forced=false)
Sets quantity in normalized 0..1 form between the item's Min a Max values as defined by item's config...
Определения ItemBase.c:8220
bool m_HideSelectionsBySlot
Определения ItemBase.c:4956
bool IsOverheatingEffectActive()
Определения ItemBase.c:5397
void SetIsBeingPlaced(bool is_being_placed)
Определения ItemBase.c:5814
int GetLiquidContainerMask()
Определения ItemBase.c:5751
void SetInventoryLocationToVicinityOrCurrent(EntityAI root, inout InventoryLocation dst)
Определения ItemBase.c:7002
ref Timer m_CheckOverheating
Определения ItemBase.c:4949
void RegisterOverheatingParticle(Particle p, float min_heat_coef, float max_heat_coef, int particle_id, Object parent, vector local_pos, vector local_ori)
Определения ItemBase.c:5445
float GetEnergy()
Определения ItemBase.c:8420
bool CanBeDigged()
Определения ItemBase.c:5830
bool GetActionWidgetOverride(out typename name)
If we need a different (handheld)item action widget displayed, the logic goes in here.
Определения ItemBase.c:9596
bool IsNVG()
Определения ItemBase.c:5762
float GetUnitWeight(bool include_wetness=true)
Obsolete, use GetWeightEx instead.
Определения ItemBase.c:8380
void SetZoneDamageCEInit()
Sets zone damages to match randomized global health set by CE (CE spawn only)
Определения ItemBase.c:9372
bool m_IsDeploySound
Определения ItemBase.c:9675
bool CanEat()
Определения ItemBase.c:7453
static void PlayOverheatingParticles(ItemBase weapon, string ammoType, ItemBase muzzle_owner, ItemBase suppressor, string config_to_search)
Определения ItemBase.c:9079
override bool IsOneHandedBehaviour()
Определения ItemBase.c:9150
void AddLightSourceItem(ItemBase lightsource)
Adds a light source child.
Определения ItemBase.c:9574
bool IsLiquidContainer()
Определения ItemBase.c:5746
FoodStage GetFoodStage()
overridden on Edible_Base; so we don't have to parse configs all the time
Определения ItemBase.c:7473
override float GetSingleInventoryItemWeightEx()
Определения ItemBase.c:8307
void SaveAgents(ParamsWriteContext ctx)
Определения ItemBase.c:8863
override int GetTargetQuantityMax(int attSlotID=-1)
Определения ItemBase.c:8261
int m_CleannessInit
Определения ItemBase.c:4885
float GetDisinfectQuantity(int system=0, Param param1=null)
Определения ItemBase.c:5529
override int GetAgents()
Определения ItemBase.c:8810
int m_VarQuantityMax
Определения ItemBase.c:4873
override bool IsHologram()
Определения ItemBase.c:5825
float GetItemAttachOffset()
Определения ItemBase.c:8589
bool IsPlaceSound()
Определения ItemBase.c:9689
static int GetDebugActionsMask()
Определения ItemBase.c:5615
void ProcessDecay(float delta, bool hasRootAsPlayer)
Определения ItemBase.c:9452
override bool IsItemBase()
Определения ItemBase.c:7606
void PlayDeploySound()
override bool IsTwoHandedBehaviour()
Определения ItemBase.c:9160
void ExplodeAmmo()
Определения ItemBase.c:6302
bool IsCombineAll(ItemBase other_item, bool use_stack_max=false)
Определения ItemBase.c:7078
float GetProtectionLevel(int type, bool consider_filter=false, int system=0)
Определения ItemBase.c:8884
static void PlayBulletCasingEjectParticles(ItemBase weapon, string ammoType, ItemBase muzzle_owner, ItemBase suppressor, string config_to_search)
Определения ItemBase.c:9059
override void OnEnergyAdded()
Определения ItemBase.c:8438
void AffectLiquidContainerOnFill(int liquid_type, float amount)
from enviro source
void AffectLiquidContainerOnTransfer(int liquidType, float amount, float sourceLiquidTemperature)
from other liquid container source
string GetExplosiveTriggerSlotName()
Определения ItemBase.c:5774
EffectSound m_DeployLoopSoundEx
Определения ItemBase.c:9672
override void DeSerializeNumericalVars(array< float > floats)
Определения ItemBase.c:7746
void StopItemDynamicPhysics()
Определения ItemBase.c:9354
bool HasFoodStage()
Определения ItemBase.c:7466
override void SetStoreLoad(bool value)
Определения ItemBase.c:8558
float GetOverheatingValue()
Определения ItemBase.c:5359
bool ContainsAgent(int agent_id)
Определения ItemBase.c:8763
override void AddWet(float value)
Определения ItemBase.c:8506
bool IsLiquidPresent()
Определения ItemBase.c:5741
bool IsFullQuantity()
Определения ItemBase.c:8301
override void EOnContact(IEntity other, Contact extra)
Определения ItemBase.c:6015
void SplitIntoStackMaxHands(PlayerBase player)
Определения ItemBase.c:6770
void SplitIntoStackMaxHandsClient(PlayerBase player)
Определения ItemBase.c:6746
int m_CleannessMax
Определения ItemBase.c:4887
float m_VarStackMax
Определения ItemBase.c:4875
ref Timer m_PhysDropTimer
Определения ItemBase.c:4962
void MessageToOwnerFriendly(string text)
Send message to owner player in green color.
Определения ItemBase.c:7578
override void SetStoreLoadedQuantity(float value)
Определения ItemBase.c:8568
bool m_IsResultOfSplit string m_SoundAttType
distinguish if item has been created as new or it came from splitting (server only flag)
Определения ItemBase.c:4916
void CheckOverheating(ItemBase weapon=null, string ammoType="", ItemBase muzzle_owner=null, ItemBase suppressor=null, string config_to_search="")
Определения ItemBase.c:5380
void UnlockFromParent()
Unlocks this item from its attachment slot of its parent.
Определения ItemBase.c:5695
bool Repair(PlayerBase player, ItemBase item_repair_kit, float specialty_weight)
Определения ItemBase.c:7500
void OnLiquidTypeChanged(int oldType, int newType)
Определения ItemBase.c:8694
void StartOverheating(ItemBase weapon=null, string ammoType="", ItemBase muzzle_owner=null, ItemBase suppressor=null, string config_to_search="")
Определения ItemBase.c:5426
void PlayDeployFinishSound()
bool AllowFoodConsumption()
Определения ItemBase.c:8616
bool m_IsOverheatingEffectActive
Определения ItemBase.c:4947
int m_LiquidContainerMask
Определения ItemBase.c:4897
void ProcessItemWetness(float delta, bool hasParent, bool hasRootAsPlayer, ItemBase refParentIB)
Определения ItemBase.c:9390
override int GetCleanness()
Определения ItemBase.c:8611
bool PairWithDevice(notnull ItemBase otherDevice)
Определения ItemBase.c:9601
bool IsDeploySound()
Определения ItemBase.c:9690
static void RemoveDebugActionsMask(int mask)
Определения ItemBase.c:5635
static void UpdateOverheatingParticles(ItemBase weapon, string ammoType, ItemBase muzzle_owner, ItemBase suppressor, string config_to_search)
Определения ItemBase.c:9099
int m_VarQuantityMin
Определения ItemBase.c:4872
void PerformDamageSystemReinit()
Определения ItemBase.c:9360
override void ClearInventory()
Определения ItemBase.c:8399
static int m_LastRegisteredWeaponID
Определения ItemBase.c:4944
ItemBase GetLightSourceItem()
Определения ItemBase.c:9584
void MessageToOwnerImportant(string text)
Send message to owner player in red color.
Определения ItemBase.c:7596
override float GetItemOverheatThreshold()
Определения ItemBase.c:9534
void StopDeployLoopSoundEx()
bool m_CanThisBeSplit
Определения ItemBase.c:4909
override void SerializeNumericalVars(array< float > floats_out)
Определения ItemBase.c:7710
ItemBase SplitIntoStackMaxToInventoryLocationEx(notnull InventoryLocation dst)
Определения ItemBase.c:6685
float m_ItemModelLength
Определения ItemBase.c:4895
bool m_IsHologram
Определения ItemBase.c:4902
static int m_DebugActionsMask
Определения ItemBase.c:4862
void KillAllOverheatingParticles()
Определения ItemBase.c:5495
bool CanBeCookedOnStick()
Определения ItemBase.c:7483
override int GetQuantityMax()
Определения ItemBase.c:8248
void GetRecipesActions(Man player, out TSelectableActionInfoArray outputList)
Определения ItemBase.c:7156
void OnActivatedByTripWire()
bool IsColorSet()
Определения ItemBase.c:8654
override void RemoveAgent(int agent_id)
Определения ItemBase.c:8776
bool m_ItemBeingDroppedPhys
Определения ItemBase.c:4905
override bool CanPutAsAttachment(EntityAI parent)
Определения ItemBase.c:8966
void PlayDetachSound(string slot_type)
Определения ItemBase.c:9330
static ref map< typename, ref TInputActionMap > m_ItemTypeActionsMap
Определения ItemBase.c:4856
void ProcessItemWetnessAndTemperature(float delta, bool hasParent, bool hasRootAsPlayer, ItemBase refParentIB)
Определения ItemBase.c:9663
override bool IsBeingPlaced()
Определения ItemBase.c:5809
int GetQuantityInit()
Определения ItemBase.c:8285
float ComputeQuantityUsedEx(ItemBase other_item, bool use_stack_max=true)
Определения ItemBase.c:7098
bool IsResultOfSplit()
Определения ItemBase.c:7083
bool m_FixDamageSystemInit
Определения ItemBase.c:4907
float m_ImpactSpeed
Определения ItemBase.c:4891
bool m_IsStoreLoad
Определения ItemBase.c:4910
int GetLiquidTypeInit()
Определения ItemBase.c:8684
string GetDeployFinishSoundset()
ItemBase m_LightSourceItem
Определения ItemBase.c:4925
void LockToParent()
Locks this item in it's current attachment slot of its parent. This makes the "locked" icon visible i...
Определения ItemBase.c:5682
override void SplitIntoStackMaxEx(EntityAI destination_entity, int slot_id)
Определения ItemBase.c:6557
int m_AttachedAgents
Определения ItemBase.c:4933
string m_LockSoundSet
Определения ItemBase.c:4968
void LoadParticleConfigOnOverheating(int id)
Определения ItemBase.c:5303
float m_VarQuantityPrev
Определения ItemBase.c:4870
bool IsSoundSynchRemote()
Определения ItemBase.c:9688
bool m_CanShowQuantity
Определения ItemBase.c:4911
override void OnRightClick()
Определения ItemBase.c:6938
int m_ColorComponentB
Определения ItemBase.c:4920
static ref map< typename, ref TActionAnimOverrideMap > m_ItemActionOverrides
Определения ItemBase.c:4858
bool IsActionTargetVisible()
Определения ItemBase.c:9196
override void OnItemAttachmentSlotChanged(notnull InventoryLocation oldLoc, notnull InventoryLocation newLoc)
Определения ItemBase.c:6050
override void EEHitBy(TotalDamageResult damageResult, int damageType, EntityAI source, int component, string dmgZone, string ammo, vector modelPos, float speedCoef)
Определения ItemBase.c:6339
bool m_IsBeingPlaced
Определения ItemBase.c:4901
int NameToID(string name)
Определения ItemBase.c:7683
void ~ItemBase()
Определения ItemBase.c:5580
override void OnWetLevelChanged(EWetnessLevel newLevel, EWetnessLevel oldLevel)
Определения ItemBase.c:8546
void ClearStopItemSoundServer()
Определения ItemBase.c:9288
override string ChangeIntoOnDetach()
Определения ItemBase.c:6263
float m_VarWetMax
Определения ItemBase.c:4882
void SplitIntoStackMaxToInventoryLocation(notnull InventoryLocation dst)
Определения ItemBase.c:6680
int GetLockType()
Определения ItemBase.c:8624
EffectSound m_SoundDeployFinish
Определения ItemBase.c:9670
override float GetWet()
Определения ItemBase.c:8516
EffectSound m_SoundPlace
Определения ItemBase.c:9671
float GetQuantityNormalizedScripted()
Определения ItemBase.c:8234
override void SetCleanness(int value, bool allow_client=false)
Определения ItemBase.c:8598
bool m_IsPlaceSound
Определения ItemBase.c:9674
override float GetWetMin()
Определения ItemBase.c:8526
ref ItemSoundHandler m_ItemSoundHandler
Определения ItemBase.c:4974
override bool KindOf(string tag)
Определения ItemBase.c:7612
void ItemSoundHandler(ItemBase parent)
Определения ItemSoundHandler.c:31
string Type
Определения JsonDataContaminatedArea.c:11
EffectSound m_LockingSound
Определения Land_Underground_Entrance.c:321
string GetDebugText()
Определения ModifierBase.c:71
PlayerBase GetPlayer()
Определения ModifierBase.c:51
@ LOWEST
Определения PPEConstants.c:54
void PluginItemDiagnostic()
Определения PluginItemDiagnostic.c:74
PluginBase GetPlugin(typename plugin_type)
Определения PluginManager.c:316
EntityAI GetItem()
Определения RadialQuickbarMenu.c:37
override RemotelyActivatedItemBehaviour GetRemotelyActivatedItemBehaviour()
Определения RemoteDetonator.c:272
void RemoteDetonatorTrigger()
Определения RemoteDetonator.c:233
override void OnActivatedByItem(notnull ItemBase item)
Called when this item is activated by other.
Определения RemoteDetonator.c:305
int particle_id
Определения SmokeSimulation.c:28
ETemperatureAccessTypes
Определения TemperatureAccessConstants.c:2
override void Explode(int damageType, string ammoType="")
Определения Trap_LandMine.c:220
bool m_Initialized
Определения UiHintPanel.c:317
void Debug()
Определения UniversalTemperatureSource.c:349
int GetID()
Определения ActionBase.c:1360
void OnItemLocationChanged(ItemBase item)
Определения ActionBase.c:998
GetInputType()
Определения ActionBase.c:215
int m_StanceMask
Определения ActionBase.c:25
int m_CommandUIDProne
Определения ActionBase.c:24
int m_CommandUID
Определения ActionBase.c:23
void OnItemAttachedAtPlayer(EntityAI item, string slot_name)
Определения AnalyticsManagerClient.c:77
proto native UIManager GetUIManager()
proto bool ConfigGetChildName(string path, int index, out string name)
Get name of subclass in config class on path.
proto native float ConfigGetFloat(string path)
Get float value from config on path.
override ScriptCallQueue GetCallQueue(int call_category)
Определения DayZGame.c:1187
proto native void GizmoSelectObject(Object object)
proto native bool ConfigIsExisting(string path)
proto native void ConfigGetTextArray(string path, out TStringArray values)
Get array of strings from config on path.
proto native DayZPlayer GetPlayer()
proto native void GizmoSelectPhysics(Physics physics)
proto int GetTime()
returns mission time in milliseconds
proto native int ConfigGetType(string path)
Returns type of config value.
AnalyticsManagerClient GetAnalyticsClient()
Определения Global/game.c:1568
proto native int ConfigGetChildrenCount(string path)
Get count of subclasses in config class on path.
proto native SoundOnVehicle CreateSoundOnObject(Object source, string sound_name, float distance, bool looped, bool create_local=false)
proto native void ObjectDelete(Object obj)
proto native int GetItemCount()
proto native EntityAI GetItem(int index)
float GetEnergyAtSpawn()
Определения ComponentEnergyManager.c:1280
void SetEnergy0To1(float energy01)
Energy manager: Sets stored energy for this device between 0 and MAX based on relative input value be...
Определения ComponentEnergyManager.c:541
float GetEnergyMaxPristine()
Energy manager: Returns the maximum amount of energy this device can store. It's damage is NOT taken ...
Определения ComponentEnergyManager.c:1275
override void SetAutodestroy(bool auto_destroy)
Sets whether Effect automatically cleans up when it stops.
Определения EffectSound.c:603
bool IsSoundPlaying()
Get whether EffectSound is currently playing.
Определения EffectSound.c:274
override bool IsMan()
Определения 3_Game/Entities/Man.c:44
proto native bool EnumerateInventory(InventoryTraversalType tt, out array< EntityAI > items)
enumerate inventory using traversal type and filling items array
proto native CargoBase GetCargo()
cargo
Определения ItemBase.c:15
proto native bool IsValid()
verify current set inventory location
proto native EntityAI GetParent()
returns parent of current inventory location
proto native int GetSlot()
returns slot id if current type is Attachment
proto native int GetCol()
returns column of cargo if current type is Cargo / ProxyCargo
proto native int GetRow()
returns row of cargo if current type is Cargo / ProxyCargo
bool WriteToContext(ParamsWriteContext ctx)
Определения InventoryLocation.c:469
proto native int GetType()
returns type of InventoryLocation
proto native int GetIdx()
returns index of cargo if current type is Cargo / ProxyCargo
proto native void SetCargo(notnull EntityAI parent, EntityAI e, int idx, int row, int col, bool flip)
sets current inventory location type to Cargo with coordinates (idx, row, col)
proto native bool GetFlip()
returns flip status of cargo
proto native EntityAI GetItem()
returns item of current inventory location
InventoryLocation.
Определения InventoryLocation.c:29
override bool CanDisplayCargo()
Определения UndergroundStash.c:24
override void OnInventoryEnter(Man player)
Определения BarbedWire.c:203
override string GetFoldSoundset()
Определения BaseBuildingBase.c:108
override bool CanPutAsAttachment(EntityAI parent)
Определения ItemBase.c:6
override bool CanReceiveItemIntoCargo(EntityAI item)
Определения TentBase.c:913
override bool OnStoreLoad(ParamsReadContext ctx, int version)
Определения GardenBase.c:199
override void OnWasDetached(EntityAI parent, int slot_id)
override void EEOnAfterLoad()
Определения GardenBase.c:242
override void EEDelete(EntityAI parent)
Определения BaseBuildingBase.c:68
override bool CanBeRepairedByCrafting()
Определения TentBase.c:86
override void OnPlacementStarted(Man player)
Определения BatteryCharger.c:376
override void OnItemLocationChanged(EntityAI old_owner, EntityAI new_owner)
Определения BarbedWire.c:357
override bool IsElectricAppliance()
Определения BatteryCharger.c:43
override bool IsItemTent()
Определения TentBase.c:81
override void SetActions()
override string GetLoopFoldSoundset()
Определения BaseBuildingBase.c:113
override bool CanMakeGardenplot()
Определения FieldShovel.c:3
override void GetDebugActions(out TSelectableActionInfoArrayEx outputList)
Определения PowerGenerator.c:412
override void EEItemLocationChanged(notnull InventoryLocation oldLoc, notnull InventoryLocation newLoc)
Определения HandcuffsLocked.c:12
override WrittenNoteData GetWrittenNoteData()
Определения Paper.c:30
override int GetDamageSystemVersionChange()
Определения BaseBuildingBase.c:1238
override bool SetQuantity(float value, bool destroy_config=true, bool destroy_forced=false, bool allow_client=false, bool clamp_to_stack_max=true)
Определения PileOfWoodenPlanks.c:88
override void InitItemVariables()
Определения Matchbox.c:3
override void SetActionAnimOverrides()
Определения PickAxe.c:28
override void OnCreatePhysics()
Определения BaseBuildingBase.c:489
override string GetDeploySoundset()
Определения BarbedWire.c:392
override float GetBandagingEffectivity()
Определения BandageDressing.c:49
override bool OnAction(int action_id, Man player, ParamsReadContext ctx)
Определения PowerGenerator.c:424
override void EEHealthLevelChanged(int oldLevel, int newLevel, string zone)
Определения BaseBuildingBase.c:496
override void OnStoreSave(ParamsWriteContext ctx)
Определения GardenBase.c:266
override void AfterStoreLoad()
Определения BarbedWire.c:155
override int GetOnDigWormsAmount()
Определения FieldShovel.c:27
override bool IsSelfAdjustingTemperature()
Определения PortableGasStove.c:287
override bool IsPlayerInside(PlayerBase player, string selection)
Определения BaseBuildingBase.c:1037
override void OnVariablesSynchronized()
Определения GardenBase.c:97
override void RefreshPhysics()
Определения BatteryCharger.c:359
override bool CanObstruct()
Определения BaseBuildingBase.c:84
override void OnWasAttached(EntityAI parent, int slot_id)
override bool CanReceiveAttachment(EntityAI attachment, int slotId)
Определения BaseBuildingBase.c:982
override bool CanPutInCargo(EntityAI parent)
Определения GardenBase.c:331
override string GetLoopDeploySoundset()
Определения BarbedWire.c:397
override void OnPlacementComplete(Man player, vector position="0 0 0", vector orientation="0 0 0")
Определения BarbedWire.c:372
override void OnInventoryExit(Man player)
Определения BatteryCharger.c:341
override bool IsTakeable()
Определения BaseBuildingBase.c:1008
override bool IsIgnoredByConstruction()
Определения BaseBuildingBase.c:1170
override void InitItemSounds()
Определения BaseBuildingBase.c:94
override void EEKilled(Object killer)
Определения HandcuffsLocked.c:70
override void OnCombine(ItemBase other_item)
Определения BandageDressing.c:71
override bool CanExplodeInFire()
Определения LargeGasCannister.c:3
override bool IsFacingPlayer(PlayerBase player, string selection)
Определения BaseBuildingBase.c:1032
override bool CanBeCombined(EntityAI other_item, bool reservation_check=true, bool stack_max_limit=false)
Определения Rag.c:61
override bool IsBloodContainer()
Определения BloodContainerBase.c:10
override bool IsClothing()
override bool CanBeSplit()
Определения Rag.c:34
override bool IsDeployable()
Определения BaseBuildingBase.c:365
override void OnRPC(PlayerIdentity sender, int rpc_type, ParamsReadContext ctx)
Определения ToolBase.c:24
override bool CanBeDisinfected()
Определения BandageDressing.c:54
override float GetInfectionChance(int system=0, Param param=null)
Определения BandageDressing.c:59
override void OnEndPlacement()
Определения KitBase.c:65
Определения EnMath.c:7
float GetOverheatingLimitMax()
Определения WeaponParticles.c:417
void SetOverheatingLimitMax(float max)
Определения WeaponParticles.c:407
void SetParticleParams(int particle_id, Object parent, vector local_pos, vector local_ori)
Определения WeaponParticles.c:422
float GetOverheatingLimitMin()
Определения WeaponParticles.c:412
Particle GetParticle()
Определения WeaponParticles.c:397
void SetOverheatingLimitMin(float min)
Определения WeaponParticles.c:402
void RegisterParticle(Particle p)
Определения WeaponParticles.c:392
void Stop()
Legacy function for backwards compatibility with 1.14 and below.
Определения Particle.c:266
void SetControlledDevice(EntityAI pDevice)
Определения RemoteDetonator.c:140
bool OnStoreLoad(ParamsReadContext ctx, int version)
void OnStoreSave(ParamsWriteContext ctx)
proto void Remove(func fn)
remove specific call from queue
proto void CallLater(func fn, int delay=0, bool repeat=false, void param1=NULL, void param2=NULL, void param3=NULL, void param4=NULL, void param5=NULL, void param6=NULL, void param7=NULL, void param8=NULL, void param9=NULL)
adds call into the queue with given parameters and arguments (arguments are held in memory until the ...
proto native void Send()
proto bool Write(void value_out)
proto bool Read(void value_in)
bool m_Loop
Определения ItemSoundHandler.c:5
override void Stop()
Определения DayZPlayerImplement.c:64
proto native float GetDamage(string zoneName, string healthType)
UIScriptedMenu FindMenu(int id)
Returns menu with specific ID if it is open (see MenuID)
Определения UIManager.c:160
override void Refresh()
Определения ChatInputMenu.c:70
void SetCalcDetails(string details)
Определения 3_Game/tools/Debug.c:816
void OnRPC(PlayerIdentity sender, int rpc_type, ParamsReadContext ctx)
Определения WrittenNoteData.c:13
const float LOWEST
Определения EnConvert.c:100
Serializer ParamsReadContext
Определения gameplay.c:15
class LOD Object
InventoryTraversalType
tree traversal type, for more see http://en.wikipedia.org/wiki/Tree_traversal
Определения gameplay.c:6
proto native CGame GetGame()
Serializer ParamsWriteContext
Определения gameplay.c:16
const int DEF_BIOLOGICAL
Определения 3_Game/constants.c:512
const int DEF_CHEMICAL
Определения 3_Game/constants.c:513
const int COMP_TYPE_ENERGY_MANAGER
Определения Component.c:9
ErrorExSeverity
Определения EnDebug.c:62
void Error(string err)
Messagebox with error message.
Определения EnDebug.c:90
enum ShapeType ErrorEx
proto native void SetColor(int color)
array< string > TStringArray
Определения EnScript.c:709
array< int > TIntArray
Определения EnScript.c:711
EntityEvent
Entity events for event-mask, or throwing event from code.
Определения EnEntity.c:45
static const float ITEM_TEMPERATURE_NEUTRAL_ZONE_MIDDLE
Определения 3_Game/constants.c:808
const int VARIABLE_LIQUIDTYPE
Определения 3_Game/constants.c:632
const int VARIABLE_CLEANNESS
Определения 3_Game/constants.c:635
const int VARIABLE_COLOR
Определения 3_Game/constants.c:634
const int VARIABLE_TEMPERATURE
Определения 3_Game/constants.c:630
const int VARIABLE_QUANTITY
Определения 3_Game/constants.c:628
const int VARIABLE_WET
Определения 3_Game/constants.c:631
const int LIQUID_NONE
Определения 3_Game/constants.c:529
static proto float AbsFloat(float f)
Returns absolute value.
const int MENU_INVENTORY
Определения 3_Game/constants.c:180
proto native bool dBodyIsDynamic(notnull IEntity ent)
const int SAT_CRAFTING
Определения 3_Game/constants.c:453
const int SAT_DEBUG_ACTION
Определения 3_Game/constants.c:454
class JsonUndergroundAreaTriggerData GetPosition
Определения UndergroundAreaLoader.c:9
static proto string Format(string fmt, void param1=NULL, void param2=NULL, void param3=NULL, void param4=NULL, void param5=NULL, void param6=NULL, void param7=NULL, void param8=NULL, void param9=NULL)
Gets n-th character from string.
const int CALL_CATEGORY_GAMEPLAY
Определения 3_Game/tools/tools.c:10
const int CALL_CATEGORY_SYSTEM
Определения 3_Game/tools/tools.c:8
proto native int GetColor()