2021-05-20 23:18:44 +02:00
|
|
|
#include "backend/looped/looped.hpp"
|
|
|
|
#include "gta/enums.hpp"
|
|
|
|
#include "natives.hpp"
|
|
|
|
|
|
|
|
namespace big
|
|
|
|
{
|
2022-03-03 02:09:11 +01:00
|
|
|
static constexpr float hornBoostSpeedDefault = 10.f;
|
|
|
|
static float hornBoostSpeed = hornBoostSpeedDefault;
|
|
|
|
static constexpr float hostBoostSpeedMax = 200.f;
|
|
|
|
|
2021-05-20 23:18:44 +02:00
|
|
|
void looped::vehicle_horn_boost()
|
|
|
|
{
|
2022-02-22 01:18:49 +01:00
|
|
|
if (!g->vehicle.horn_boost) return;
|
2022-03-03 02:09:11 +01:00
|
|
|
|
|
|
|
const Vehicle veh = PED::GET_VEHICLE_PED_IS_IN(PLAYER::PLAYER_PED_ID(), false);
|
|
|
|
if (veh == 0)
|
|
|
|
{
|
|
|
|
hornBoostSpeed = hornBoostSpeedDefault;
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (PAD::IS_CONTROL_JUST_PRESSED(0, (int)ControllerInputs::INPUT_VEH_HORN))
|
|
|
|
hornBoostSpeed = ENTITY::GET_ENTITY_SPEED(veh);
|
2021-05-20 23:18:44 +02:00
|
|
|
|
2021-08-17 16:56:41 +02:00
|
|
|
if (PAD::IS_CONTROL_PRESSED(0, (int)ControllerInputs::INPUT_VEH_HORN))
|
2021-05-20 23:18:44 +02:00
|
|
|
{
|
2022-03-03 02:09:11 +01:00
|
|
|
if (hornBoostSpeed < hostBoostSpeedMax) hornBoostSpeed++;
|
2021-05-20 23:18:44 +02:00
|
|
|
|
2022-03-03 02:09:11 +01:00
|
|
|
const auto velocity =
|
|
|
|
ENTITY::GET_OFFSET_FROM_ENTITY_IN_WORLD_COORDS(veh, 0.f, hornBoostSpeed, 0.f) - ENTITY::GET_ENTITY_COORDS(veh, true);
|
|
|
|
ENTITY::SET_ENTITY_VELOCITY(veh, velocity.x, velocity.y, velocity.z);
|
2021-05-20 23:18:44 +02:00
|
|
|
}
|
2022-03-03 02:09:11 +01:00
|
|
|
else if (PAD::IS_CONTROL_JUST_RELEASED(0, (int)ControllerInputs::INPUT_VEH_HORN))
|
|
|
|
hornBoostSpeed = hornBoostSpeedDefault;
|
2021-05-20 23:18:44 +02:00
|
|
|
}
|
|
|
|
}
|