diff --git a/src/gtasa/effects/cheats/player/GetParachuteEffect.cpp b/src/gtasa/effects/cheats/player/GetParachuteEffect.cpp deleted file mode 100644 index 42cd7b8d..00000000 --- a/src/gtasa/effects/cheats/player/GetParachuteEffect.cpp +++ /dev/null @@ -1,43 +0,0 @@ -#include "effects/OneTimeEffect.h" -#include "util/GameUtil.h" - -class GetParachuteEffect : public OneTimeEffect -{ -public: - bool - CanActivate () override - { - CPlayerPed *player = FindPlayerPed (); - if (!player) return false; - - if (player->m_aWeapons[player->GetWeaponSlot (WEAPON_PARACHUTE)] - .m_eWeaponType - == WEAPON_PARACHUTE) - return false; - - return GameUtil::IsPlayerSafe (); - } - - void - OnStart (EffectInstance *inst) override - { - inst->SetIsOneTimeEffect (); - - CPlayerPed *player = FindPlayerPed (); - if (!player || !CanActivate ()) return; - - GiveParachute (player); - } - - void - GiveParachute (CPed *ped) - { - CStreaming::RequestModel (MODEL_GUN_PARA, 2); - CStreaming::LoadAllRequestedModels (false); - - ped->GiveWeapon (WEAPON_PARACHUTE, 0, 1); - ped->SetCurrentWeapon (WEAPON_PARACHUTE); - } -}; - -DEFINE_EFFECT (GetParachuteEffect, "effect_get_parachute", 0); \ No newline at end of file diff --git a/src/gtasa/effects/cheats/weapon/GiveAK47Effect.cpp b/src/gtasa/effects/cheats/weapon/GiveAK47Effect.cpp deleted file mode 100644 index 8dd567ed..00000000 --- a/src/gtasa/effects/cheats/weapon/GiveAK47Effect.cpp +++ /dev/null @@ -1,30 +0,0 @@ -#include "effects/OneTimeEffect.h" -#include "util/GameUtil.h" - -#include - -class GiveAK47Effect : public OneTimeEffect -{ -public: - bool - CanActivate () override - { - return GameUtil::IsPlayerSafe (); - } - - void - OnStart (EffectInstance *inst) override - { - CPlayerPed *player = FindPlayerPed (); - if (!player) return; - - CStreaming::RequestModel (MODEL_AK47, 2); - CStreaming::LoadAllRequestedModels (false); - - player->GiveWeapon (WEAPON_AK47, 50, 1); - - CStreaming::SetModelIsDeletable (MODEL_AK47); - } -}; - -DEFINE_EFFECT (GiveAK47Effect, "effect_give_ak47", GROUP_WEAPONS); \ No newline at end of file diff --git a/src/gtasa/effects/cheats/weapon/GiveChainsawEffect.cpp b/src/gtasa/effects/cheats/weapon/GiveChainsawEffect.cpp deleted file mode 100644 index 2e63f090..00000000 --- a/src/gtasa/effects/cheats/weapon/GiveChainsawEffect.cpp +++ /dev/null @@ -1,30 +0,0 @@ -#include "effects/OneTimeEffect.h" -#include "util/GameUtil.h" - -#include - -class GiveChainsawEffect : public OneTimeEffect -{ -public: - bool - CanActivate () override - { - return GameUtil::IsPlayerSafe (); - } - - void - OnStart (EffectInstance *inst) override - { - CPlayerPed *player = FindPlayerPed (); - if (!player) return; - - CStreaming::RequestModel (MODEL_CHNSAW, 2); - CStreaming::LoadAllRequestedModels (false); - - player->GiveWeapon (WEAPON_CHAINSAW, 1, 1); - - CStreaming::SetModelIsDeletable (MODEL_CHNSAW); - } -}; - -DEFINE_EFFECT (GiveChainsawEffect, "effect_give_chainsaw", GROUP_WEAPONS); \ No newline at end of file diff --git a/src/gtasa/effects/cheats/weapon/GiveGrenadesEffect.cpp b/src/gtasa/effects/cheats/weapon/GiveGrenadesEffect.cpp deleted file mode 100644 index 2fc66ad8..00000000 --- a/src/gtasa/effects/cheats/weapon/GiveGrenadesEffect.cpp +++ /dev/null @@ -1,30 +0,0 @@ -#include "effects/OneTimeEffect.h" -#include "util/GameUtil.h" - -#include - -class GiveGrenadesEffect : public OneTimeEffect -{ -public: - bool - CanActivate () override - { - return GameUtil::IsPlayerSafe (); - } - - void - OnStart (EffectInstance *inst) override - { - CPlayerPed *player = FindPlayerPed (); - if (!player) return; - - CStreaming::RequestModel (MODEL_GRENADE, 2); - CStreaming::LoadAllRequestedModels (false); - - player->GiveWeapon (WEAPON_GRENADE, 10, 1); - - CStreaming::SetModelIsDeletable (MODEL_GRENADE); - } -}; - -DEFINE_EFFECT (GiveGrenadesEffect, "effect_give_grenades", GROUP_WEAPONS); \ No newline at end of file diff --git a/src/gtasa/effects/cheats/weapon/GiveMinigunEffect.cpp b/src/gtasa/effects/cheats/weapon/GiveMinigunEffect.cpp deleted file mode 100644 index 1778c773..00000000 --- a/src/gtasa/effects/cheats/weapon/GiveMinigunEffect.cpp +++ /dev/null @@ -1,30 +0,0 @@ -#include "effects/OneTimeEffect.h" -#include "util/GameUtil.h" - -#include - -class GiveMinigunEffect : public OneTimeEffect -{ -public: - bool - CanActivate () override - { - return GameUtil::IsPlayerSafe (); - } - - void - OnStart (EffectInstance *inst) override - { - CPlayerPed *player = FindPlayerPed (); - if (!player) return; - - CStreaming::RequestModel (MODEL_MINIGUN, 2); - CStreaming::LoadAllRequestedModels (false); - - player->GiveWeapon (WEAPON_MINIGUN, 100, 1); - - CStreaming::SetModelIsDeletable (MODEL_MINIGUN); - } -}; - -DEFINE_EFFECT (GiveMinigunEffect, "effect_give_minigun", GROUP_WEAPONS); \ No newline at end of file diff --git a/src/gtasa/effects/cheats/weapon/GivePistolEffect.cpp b/src/gtasa/effects/cheats/weapon/GivePistolEffect.cpp deleted file mode 100644 index b61f4aba..00000000 --- a/src/gtasa/effects/cheats/weapon/GivePistolEffect.cpp +++ /dev/null @@ -1,30 +0,0 @@ -#include "effects/OneTimeEffect.h" -#include "util/GameUtil.h" - -#include - -class GivePistolEffect : public OneTimeEffect -{ -public: - bool - CanActivate () override - { - return GameUtil::IsPlayerSafe (); - } - - void - OnStart (EffectInstance *inst) override - { - CPlayerPed *player = FindPlayerPed (); - if (!player) return; - - CStreaming::RequestModel (MODEL_SILENCED, 2); - CStreaming::LoadAllRequestedModels (false); - - player->GiveWeapon (WEAPON_PISTOL_SILENCED, 50, 1); - - CStreaming::SetModelIsDeletable (MODEL_SILENCED); - } -}; - -DEFINE_EFFECT (GivePistolEffect, "effect_give_pistol", GROUP_WEAPONS); \ No newline at end of file diff --git a/src/gtasa/effects/cheats/weapon/GivePlayerAWeaponEffect.cpp b/src/gtasa/effects/cheats/weapon/GivePlayerAWeaponEffect.cpp new file mode 100644 index 00000000..53de10d7 --- /dev/null +++ b/src/gtasa/effects/cheats/weapon/GivePlayerAWeaponEffect.cpp @@ -0,0 +1,105 @@ +#include "effects/OneTimeEffect.h" +#include "util/GameUtil.h" + +#include +#include +#include +#include + +using namespace plugin; +namespace +{ +enum eWeaponSlot : unsigned int +{ + UNARMED, + MELEE, + HANDGUN, + SHOTGUN, + SMG, + RIFLE, + SNIPER, + HEAVY, + THROWN, + SPECIAL, + GIFT, + PARACHUTE, + DETONATOR, +}; +} // namespace + +class GivePlayerAWeapon : public OneTimeEffect +{ +private: + eWeaponType weaponType = WEAPON_BRASSKNUCKLE; + +public: + GivePlayerAWeapon (eWeaponType weapon) : weaponType (weapon) {} + + bool + CanActivate () override + { + CPlayerPed *player = FindPlayerPed (); + if (!player) return false; + + if (player->m_aWeapons[player->GetWeaponSlot (weaponType)].m_eWeaponType + == WEAPON_PARACHUTE) + return false; + + return GameUtil::IsPlayerSafe (); + } + + void + OnStart (EffectInstance *inst) override + { + CPlayerPed *player = FindPlayerPed (); + if (!player) return; + + auto m = CPickups::ModelForWeapon (weaponType); + CStreaming::RequestModel (m, 2); + CStreaming::LoadAllRequestedModels (false); + + const auto *info = CWeaponInfo::GetWeaponInfo (weaponType, 1); + + if (!info) return; + + unsigned int ammo = 0; + + switch (info->m_nSlot) + { + case eWeaponSlot::HANDGUN: ammo = 50; break; + case eWeaponSlot::SHOTGUN: ammo = 35; break; + case eWeaponSlot::SMG: ammo = 100; break; + case eWeaponSlot::RIFLE: ammo = 50; break; + case eWeaponSlot::SNIPER: ammo = 20; break; + case eWeaponSlot::HEAVY: ammo = 10; break; + case eWeaponSlot::THROWN: ammo = 10; break; + case eWeaponSlot::SPECIAL: ammo = 500; break; + default: break; + } + + if (weaponType == WEAPON_MINIGUN) + { + ammo = 250; + } + + Command (player, + weaponType, + ammo); + + CStreaming::SetModelIsDeletable (m); + } +}; + +// clang-format off +DEFINE_EFFECT (GivePlayerAWeapon, "effect_give_ak47", GROUP_WEAPONS, WEAPON_AK47); +DEFINE_EFFECT (GivePlayerAWeapon, "effect_give_uzi", GROUP_WEAPONS, WEAPON_MICRO_UZI); +DEFINE_EFFECT (GivePlayerAWeapon, "effect_give_sniper", GROUP_WEAPONS, WEAPON_SNIPERRIFLE); +DEFINE_EFFECT (GivePlayerAWeapon, "effect_give_shotgun", GROUP_WEAPONS, WEAPON_SPAS12); +DEFINE_EFFECT (GivePlayerAWeapon, "effect_give_rocket_launcher", GROUP_WEAPONS, WEAPON_RLAUNCHER_HS); +DEFINE_EFFECT (GivePlayerAWeapon, "effect_give_pistol", GROUP_WEAPONS, WEAPON_PISTOL_SILENCED); +DEFINE_EFFECT (GivePlayerAWeapon, "effect_give_minigun", GROUP_WEAPONS, WEAPON_MINIGUN); +DEFINE_EFFECT (GivePlayerAWeapon, "effect_weapon_set_4", GROUP_WEAPONS, WEAPON_MINIGUN); +DEFINE_EFFECT (GivePlayerAWeapon, "effect_give_grenades", GROUP_WEAPONS, WEAPON_GRENADE); +DEFINE_EFFECT (GivePlayerAWeapon, "effect_give_chainsaw", GROUP_WEAPONS, WEAPON_CHAINSAW); +DEFINE_EFFECT (GivePlayerAWeapon, "effect_get_parachute", GROUP_WEAPONS, WEAPON_PARACHUTE); +// clang-format on \ No newline at end of file diff --git a/src/gtasa/effects/cheats/weapon/GiveRocketLauncherEffect.cpp b/src/gtasa/effects/cheats/weapon/GiveRocketLauncherEffect.cpp deleted file mode 100644 index 987cd884..00000000 --- a/src/gtasa/effects/cheats/weapon/GiveRocketLauncherEffect.cpp +++ /dev/null @@ -1,31 +0,0 @@ -#include "effects/OneTimeEffect.h" -#include "util/GameUtil.h" - -#include - -class GiveRocketLauncherEffect : public OneTimeEffect -{ -public: - bool - CanActivate () override - { - return GameUtil::IsPlayerSafe (); - } - - void - OnStart (EffectInstance *inst) override - { - CPlayerPed *player = FindPlayerPed (); - if (!player) return; - - CStreaming::RequestModel (MODEL_HEATSEEK, 2); - CStreaming::LoadAllRequestedModels (false); - - player->GiveWeapon (WEAPON_RLAUNCHER_HS, 10, 1); - - CStreaming::SetModelIsDeletable (MODEL_HEATSEEK); - } -}; - -DEFINE_EFFECT (GiveRocketLauncherEffect, "effect_give_rocket_launcher", - GROUP_WEAPONS); \ No newline at end of file diff --git a/src/gtasa/effects/cheats/weapon/GiveShotgunEffect.cpp b/src/gtasa/effects/cheats/weapon/GiveShotgunEffect.cpp deleted file mode 100644 index 0cc0240e..00000000 --- a/src/gtasa/effects/cheats/weapon/GiveShotgunEffect.cpp +++ /dev/null @@ -1,30 +0,0 @@ -#include "effects/OneTimeEffect.h" -#include "util/GameUtil.h" - -#include - -class GiveShotgunEffect : public OneTimeEffect -{ -public: - bool - CanActivate () override - { - return GameUtil::IsPlayerSafe (); - } - - void - OnStart (EffectInstance *inst) override - { - CPlayerPed *player = FindPlayerPed (); - if (!player) return; - - CStreaming::RequestModel (MODEL_SHOTGSPA, 2); - CStreaming::LoadAllRequestedModels (false); - - player->GiveWeapon (WEAPON_SPAS12, 50, 1); - - CStreaming::SetModelIsDeletable (MODEL_SHOTGSPA); - } -}; - -DEFINE_EFFECT (GiveShotgunEffect, "effect_give_shotgun", GROUP_WEAPONS); \ No newline at end of file diff --git a/src/gtasa/effects/cheats/weapon/GiveSniperEffect.cpp b/src/gtasa/effects/cheats/weapon/GiveSniperEffect.cpp deleted file mode 100644 index d6d5b71b..00000000 --- a/src/gtasa/effects/cheats/weapon/GiveSniperEffect.cpp +++ /dev/null @@ -1,30 +0,0 @@ -#include "effects/OneTimeEffect.h" -#include "util/GameUtil.h" - -#include - -class GiveSniperEffect : public OneTimeEffect -{ -public: - bool - CanActivate () override - { - return GameUtil::IsPlayerSafe (); - } - - void - OnStart (EffectInstance *inst) override - { - CPlayerPed *player = FindPlayerPed (); - if (!player) return; - - CStreaming::RequestModel (MODEL_SNIPER, 2); - CStreaming::LoadAllRequestedModels (false); - - player->GiveWeapon (WEAPON_SNIPERRIFLE, 20, 1); - - CStreaming::SetModelIsDeletable (MODEL_SNIPER); - } -}; - -DEFINE_EFFECT (GiveSniperEffect, "effect_give_sniper", GROUP_WEAPONS); \ No newline at end of file diff --git a/src/gtasa/effects/cheats/weapon/GiveUziEffect.cpp b/src/gtasa/effects/cheats/weapon/GiveUziEffect.cpp deleted file mode 100644 index 6c50588e..00000000 --- a/src/gtasa/effects/cheats/weapon/GiveUziEffect.cpp +++ /dev/null @@ -1,30 +0,0 @@ -#include "effects/OneTimeEffect.h" -#include "util/GameUtil.h" - -#include - -class GiveUziEffect : public OneTimeEffect -{ -public: - bool - CanActivate () override - { - return GameUtil::IsPlayerSafe (); - } - - void - OnStart (EffectInstance *inst) override - { - CPlayerPed *player = FindPlayerPed (); - if (!player) return; - - CStreaming::RequestModel (MODEL_MICRO_UZI, 2); - CStreaming::LoadAllRequestedModels (false); - - player->GiveWeapon (WEAPON_MICRO_UZI, 100, 1); - - CStreaming::SetModelIsDeletable (MODEL_MICRO_UZI); - } -}; - -DEFINE_EFFECT (GiveUziEffect, "effect_give_uzi", GROUP_WEAPONS); \ No newline at end of file diff --git a/src/gtasa/effects/cheats/weapon/WeaponSet4Effect.cpp b/src/gtasa/effects/cheats/weapon/WeaponSet4Effect.cpp deleted file mode 100644 index a846df7f..00000000 --- a/src/gtasa/effects/cheats/weapon/WeaponSet4Effect.cpp +++ /dev/null @@ -1,30 +0,0 @@ -#include "effects/OneTimeEffect.h" -#include "util/GameUtil.h" - -#include - -class WeaponSet4Effect : public OneTimeEffect -{ -public: - bool - CanActivate () override - { - return GameUtil::IsPlayerSafe (); - } - - void - OnStart (EffectInstance *inst) override - { - CPlayerPed *player = FindPlayerPed (); - if (!player) return; - - CStreaming::RequestModel (MODEL_MINIGUN, 2); - CStreaming::LoadAllRequestedModels (false); - - player->GiveWeapon (WEAPON_MINIGUN, 500, 1); - - CStreaming::SetModelIsDeletable (MODEL_MINIGUN); - } -}; - -DEFINE_EFFECT (WeaponSet4Effect, "effect_weapon_set_4", GROUP_WEAPONS); \ No newline at end of file