TmpMenu/src/backend/looped/vehicle/horn_boost.cpp

45 lines
1.4 KiB
C++
Raw Normal View History

2021-05-20 23:18:44 +02:00
#include "natives.hpp"
#include "backend/looped_command.hpp"
#include "gta/enums.hpp"
2021-05-20 23:18:44 +02:00
namespace big
{
class horn_boost : looped_command
2021-05-20 23:18:44 +02:00
{
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);
2021-05-20 23:18:44 +02:00
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;
2021-05-20 23:18:44 +02:00
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;
2021-05-20 23:18:44 +02:00
}
};
horn_boost g_horn_boost("hornboost", "Horn Boost", "Boosts your vehicle forward when you sound the horn", g.vehicle.horn_boost);
}