karifeld 0f09234130 refactor: Modernized/optimized general code, bug fixing and more (#226)
* refactor: Use self globals

* refactor: Use gui::components

* fix(Vehicle Preview): Addresses #119

Previewed vehicle set to unclimbable

Only preview when hovered on vehicle

* fix(Infinite Clip): Disabling it now works

* fix(No Ragdoll): Disabling it now works

Removed unnecessary calls to natives (0xB128377056A54E2A should be enough)

* fix(Spawn): Wrong footer placement

* fix self globals file name typo

* refactor(Mobile): Clear ped tasks when set conditions are met

Only clear ped tasks if pv_teleport_into bool is true and ped is in a vehicle

* feat(Weapons): Remove current weapon

* refactor: Added missing variable in calls to self globals

* refactor: Utilize usage of ControllerInputs

* fix(Vehicle Fly): uninitialized local variable 'ped' used

* refactor(No Ragdoll, Infinite Clip): Only run on boolean change.

* refactor(Infinite Ammo): Simplified code

* refactor: Utilize ControllerInputs in other areas of code

* refactor: Utilize ControllerInputs in other areas of code
2022-05-22 18:38:45 -04:00

53 lines
1.4 KiB
C++

#include "backend/looped/looped.hpp"
#include "gta/enums.hpp"
#include "natives.hpp"
#include "util/math.hpp"
namespace big
{
static float run_speed = 10.f;
static float run_cap = 100.f;
static bool super_run_state = false;
void looped::self_super_run()
{
if (g->self.super_run && PAD::IS_CONTROL_PRESSED(0, (int)ControllerInputs::INPUT_SPRINT))
{
if (run_speed < run_cap) run_speed += .5f;
Vector3 location = self::pos;
Ped ped = self::ped;
//Vector3 rot = CAM::GET_GAMEPLAY_CAM_ROT(2);
Vector3 rot = ENTITY::GET_ENTITY_ROTATION(ped, 2);
float yaw = math::deg_to_rad(rot.z + 90);
Vector3 offset;
offset.x = location.x + (run_speed * cos(yaw));
offset.y = location.y + (run_speed * sin(yaw));
offset.z = location.z + .2f;
float groundZ;
MISC::GET_GROUND_Z_FOR_3D_COORD(offset.x, offset.y, 1000.f, &groundZ, false, false);
if (groundZ < location.z)
offset.z = groundZ;
Vector3 vel = offset - location;
ENTITY::SET_ENTITY_VELOCITY(ped, vel.x, vel.y, vel.z);
g_local_player->m_player_info->m_run_speed = .7f;
}
else if (!g->self.super_run && g->self.super_run != super_run_state)
{
g_local_player->m_player_info->m_run_speed = 1.f;
}
else if (PAD::IS_CONTROL_JUST_RELEASED(0, (int)ControllerInputs::INPUT_SPRINT))
{
run_speed = 10.f;
g_local_player->m_player_info->m_run_speed = 1.f;
}
super_run_state = g->self.super_run;
}
}