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

◆ GetLiquidType()

override int SpawnItemOnLocation::GetLiquidType ( )
protected

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

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