feat(Vehicle): Made horn boost based of vehicle heading
Thanks @DayibBaba Closes #67
This commit is contained in:
parent
03576f4d74
commit
ce3f2e3a36
@ -1,24 +1,37 @@
|
|||||||
#include "backend/looped/looped.hpp"
|
#include "backend/looped/looped.hpp"
|
||||||
#include "gta/enums.hpp"
|
#include "gta/enums.hpp"
|
||||||
#include "natives.hpp"
|
#include "natives.hpp"
|
||||||
#include "util/entity.hpp"
|
|
||||||
|
|
||||||
namespace big
|
namespace big
|
||||||
{
|
{
|
||||||
|
static constexpr float hornBoostSpeedDefault = 10.f;
|
||||||
|
static float hornBoostSpeed = hornBoostSpeedDefault;
|
||||||
|
static constexpr float hostBoostSpeedMax = 200.f;
|
||||||
|
|
||||||
void looped::vehicle_horn_boost()
|
void looped::vehicle_horn_boost()
|
||||||
{
|
{
|
||||||
if (!g->vehicle.horn_boost) return;
|
if (!g->vehicle.horn_boost) return;
|
||||||
|
|
||||||
|
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);
|
||||||
|
|
||||||
if (PAD::IS_CONTROL_PRESSED(0, (int)ControllerInputs::INPUT_VEH_HORN))
|
if (PAD::IS_CONTROL_PRESSED(0, (int)ControllerInputs::INPUT_VEH_HORN))
|
||||||
{
|
{
|
||||||
Ped ped = PLAYER::PLAYER_PED_ID();
|
if (hornBoostSpeed < hostBoostSpeedMax) hornBoostSpeed++;
|
||||||
Vehicle veh = PED::GET_VEHICLE_PED_IS_IN(ped, false);
|
|
||||||
|
|
||||||
if (veh == 0) return;
|
const auto velocity =
|
||||||
if (VEHICLE::GET_PED_IN_VEHICLE_SEAT(veh, -1, 0) != ped) return;
|
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);
|
||||||
Vector3 velocity = ENTITY::GET_ENTITY_VELOCITY(veh) * 1.05f;
|
|
||||||
ENTITY::SET_ENTITY_VELOCITY(veh, velocity.x, velocity.y, velocity.z - 0.5f);
|
|
||||||
}
|
}
|
||||||
|
else if (PAD::IS_CONTROL_JUST_RELEASED(0, (int)ControllerInputs::INPUT_VEH_HORN))
|
||||||
|
hornBoostSpeed = hornBoostSpeedDefault;
|
||||||
}
|
}
|
||||||
}
|
}
|
Reference in New Issue
Block a user