TmpMenu/src/backend/looped/vehicle/horn_boost.cpp
maybegreat48 ce5c317d87 Commands (#725)
* feat(Commands): Prototype command system
* feat(Commands): Chat commands
* refactor(Toxic): convert most options into commands
* feat(Protections): block breakup kicks on other players as host
* refactor(Kicks): convert most options into commands
* refactor(Commands): add labels and descriptions to all commands
* feat(Commands): cleanup on unload
* refactor(Troll): convert most options into commands
* refactor(Misc): convert most options into commands
* refactor(Teleport): convert most options into commands
* feat(Commands): Variadic commands and toggleable bools
* feat(Hotkeys): hotkeys now use commands
* fix(Chat): fix the chat window locking up when a message is sent
* fix(Commands): properly handle spoofed username
* fix(Spam): update filter

Co-authored-by: Yimura <24669514+Yimura@users.noreply.github.com>
2022-12-22 21:23:32 +00:00

45 lines
1.4 KiB
C++

#include "natives.hpp"
#include "backend/looped_command.hpp"
#include "gta/enums.hpp"
namespace big
{
class horn_boost : looped_command
{
using looped_command::looped_command;
static constexpr float horn_boost_speed_default = 10.f;
static constexpr float horn_boost_speed_max = 200.f;
static constexpr float horn_boost_speed_increment = 0.3f;
float horn_boost_speed = horn_boost_speed_default;
virtual void on_tick() override
{
Vehicle vehicle = self::veh;
if (vehicle == 0)
{
horn_boost_speed = horn_boost_speed_default;
return;
}
if (PAD::IS_CONTROL_JUST_PRESSED(0, (int)ControllerInputs::INPUT_VEH_HORN))
horn_boost_speed = ENTITY::GET_ENTITY_SPEED(vehicle);
if (PAD::IS_CONTROL_PRESSED(0, (int)ControllerInputs::INPUT_VEH_HORN))
{
if (horn_boost_speed < horn_boost_speed_max)
horn_boost_speed += horn_boost_speed_increment;
const auto velocity =
ENTITY::GET_OFFSET_FROM_ENTITY_IN_WORLD_COORDS(vehicle, 0.f, horn_boost_speed, 0.f) - ENTITY::GET_ENTITY_COORDS(vehicle, true);
ENTITY::SET_ENTITY_VELOCITY(vehicle, velocity.x, velocity.y, velocity.z);
}
else if (PAD::IS_CONTROL_JUST_RELEASED(0, (int)ControllerInputs::INPUT_VEH_HORN))
horn_boost_speed = horn_boost_speed_default;
}
};
horn_boost g_horn_boost("hornboost", "Horn Boost", "Boosts your vehicle forward when you sound the horn", g.vehicle.horn_boost);
}