2021-05-20 23:18:44 +02:00
|
|
|
#include "natives.hpp"
|
2022-12-22 21:23:32 +00:00
|
|
|
#include "backend/looped_command.hpp"
|
|
|
|
#include "gta/enums.hpp"
|
2021-05-20 23:18:44 +02:00
|
|
|
|
|
|
|
namespace big
|
|
|
|
{
|
2022-12-22 21:23:32 +00:00
|
|
|
class horn_boost : looped_command
|
2021-05-20 23:18:44 +02:00
|
|
|
{
|
2022-12-22 21:23:32 +00: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;
|
2022-05-23 06:38:45 +08:00
|
|
|
|
2022-12-22 21:23:32 +00:00
|
|
|
virtual void on_tick() override
|
2022-03-03 02:09:11 +01:00
|
|
|
{
|
2022-12-22 21:23:32 +00:00
|
|
|
Vehicle vehicle = self::veh;
|
2022-03-03 02:09:11 +01:00
|
|
|
|
2022-12-22 21:23:32 +00:00
|
|
|
if (vehicle == 0)
|
|
|
|
{
|
|
|
|
horn_boost_speed = horn_boost_speed_default;
|
|
|
|
return;
|
|
|
|
}
|
2022-03-03 02:09:11 +01:00
|
|
|
|
2022-12-22 21:23:32 +00:00
|
|
|
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
|
|
|
|
2022-12-22 21:23:32 +00: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
|
|
|
|
2022-12-22 21:23:32 +00: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
|
|
|
}
|
2022-12-22 21:23:32 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
horn_boost g_horn_boost("hornboost", "Horn Boost", "Boosts your vehicle forward when you sound the horn", g.vehicle.horn_boost);
|
|
|
|
}
|