-
Автор темы
- #1
C++:
void c_miscellaneous :: gather_velocity_data (r :: sdk :: c_user_cmd * cmd) {
const auto local_player = r :: impl :: g_entity_list-> get_by_index <r :: sdk :: c_player *> (r :: impl :: g_engine-> get_local_player ());
if (! local_player ||! local_player-> alive ())
return;
if (data.size ()> 80) // change this to change iter-calculated length on velocity graph or just adapt the function so it
// fits more data on various sizes | @c_miscellaneous :: render_velocity_graph - [USER=1292]@UBER[/USER]
data.pop_back ();
utils :: velocity_data_t current_data;
r :: sdk :: vec3_t velocity =
local_player-> get_velocity (); // used the SDK vector class and added functions I also added to math utilities to it, IDK
// why it exist, was it a include guard issue? - [USER=1292]@UBER[/USER]
float speed = velocity.length2D ();
int flags = local_player-> get_flags ();
bool on_ground =
flags &
(1 << 0); // this can be just 1, it's a simple bitfield, but I won't change it unless you decide on doing so - [USER=1292]@UBER[/USER]
current_data.speed = speed;
current_data.on_ground = on_ground;
data.insert (data.begin (), current_data);
}
void c_menu :: draw_visuals () {
if (! g_settings-> get <bool> ("show_movement_indicators"))
return;
const auto local_player {r :: impl :: g_entity_list-> get_by_index <r :: sdk :: c_player *> (r :: impl :: g_engine-> get_local_player ())};
if (data.size () <2)
return;
if (! local_player ||! local_player-> alive ())
return;
int screen_width, screen_height;
r :: impl :: g_engine-> get_screen_size (screen_width, screen_height);
for (std :: size_t i = 0; i! = data.size () - 1; i ++) {
// Gather the needed data
const r :: itself :: hacks :: c_miscellaneous :: utils :: velocity_data_t current {data [I]};
const r :: itself :: hacks :: c_miscellaneous :: utils :: velocity_data_t next {data [i + 1]};
const bool landed {! current.on_ground && next.on_ground};
const float clamped_current_speed {current.speed};
const float clamped_next_speed {next.speed};
}
}
vec2_t position1 = {{(screen_width / 2) + 200 - (i - 1) * 5}, {(screen_width / 2) + 200 - i * 5}};
vec2_t position2 = {{(screen_height - 310) + 130 - (clamped_current_speed * 75/320)},
{(screen_height - 310) + 130 - (clamped_next_speed * 75/320)}};