change createmove module order fix backtrack code compiling on release update player::get_hitboxes_internal logic add vector_transform (#30)
This commit is contained in:
parent
9881f79489
commit
c1aa6761a2
@ -67,13 +67,13 @@ workspace "doghook"
|
|||||||
files { "src/**.hh", "src/**.cc" }
|
files { "src/**.hh", "src/**.cc" }
|
||||||
|
|
||||||
filter "system:linux"
|
filter "system:linux"
|
||||||
postbuildcommands {
|
prebuildcommands {
|
||||||
"{MKDIR} %{wks.location}/compile_commands/",
|
"{MKDIR} %{wks.location}/compile_commands/",
|
||||||
"{TOUCH} %{wks.location}/compile_commands/%{cfg.shortname}.json",
|
"{TOUCH} %{wks.location}/compile_commands/%{cfg.shortname}.json",
|
||||||
"{COPY} %{wks.location}/compile_commands/%{cfg.shortname}.json ../compile_commands.json"
|
"{COPY} %{wks.location}/compile_commands/%{cfg.shortname}.json ../compile_commands.json"
|
||||||
}
|
}
|
||||||
filter "system:windows"
|
filter "system:windows"
|
||||||
postbuildcommands {
|
prebuildcommands {
|
||||||
"cmd.exe /c \"" .. "{MKDIR} %{wks.location}/compile_commands/",
|
"cmd.exe /c \"" .. "{MKDIR} %{wks.location}/compile_commands/",
|
||||||
"cmd.exe /c \"" .. "{TOUCH} %{wks.location}/compile_commands/%{cfg.shortname}.json",
|
"cmd.exe /c \"" .. "{TOUCH} %{wks.location}/compile_commands/%{cfg.shortname}.json",
|
||||||
"cmd.exe /c \"" .. "{COPY} %{wks.location}/compile_commands/%{cfg.shortname}.json ../compile_commands.json*"
|
"cmd.exe /c \"" .. "{COPY} %{wks.location}/compile_commands/%{cfg.shortname}.json ../compile_commands.json*"
|
||||||
|
@ -76,8 +76,8 @@ bool hooked_create_move(void *instance, float sample_framerate, UserCmd *user_cm
|
|||||||
|
|
||||||
// Do create_move()
|
// Do create_move()
|
||||||
|
|
||||||
backtrack::create_move(user_cmd);
|
|
||||||
aimbot::create_move(user_cmd);
|
aimbot::create_move(user_cmd);
|
||||||
|
backtrack::create_move(user_cmd);
|
||||||
|
|
||||||
backtrack::create_move_finish(user_cmd);
|
backtrack::create_move_finish(user_cmd);
|
||||||
|
|
||||||
|
@ -288,8 +288,10 @@ static auto try_autoshoot(sdk::UserCmd *cmd) {
|
|||||||
|
|
||||||
// Only allow autoshoot when we are zoomed and can get headshots
|
// Only allow autoshoot when we are zoomed and can get headshots
|
||||||
if (local_weapon->client_class()->class_id == class_id::CTFSniperRifle && (local_player->cond() & 2)) {
|
if (local_weapon->client_class()->class_id == class_id::CTFSniperRifle && (local_player->cond() & 2)) {
|
||||||
if ((local_player->tick_base() * IFace<Globals>()->interval_per_tick - local_player->fov_time()) >= 0.2)
|
auto player_time = local_player->tick_base() * IFace<Globals>()->interval_per_tick;
|
||||||
autoshoot_allowed = true;
|
auto time_delta = player_time - local_player->fov_time();
|
||||||
|
|
||||||
|
if (time_delta >= 0.2) autoshoot_allowed = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (autoshoot_allowed) cmd->buttons |= 1;
|
if (autoshoot_allowed) cmd->buttons |= 1;
|
||||||
|
@ -203,7 +203,7 @@ void create_move_pre_predict(sdk::UserCmd *cmd) {
|
|||||||
#ifdef _DEBUG
|
#ifdef _DEBUG
|
||||||
if (layer_count > backtrack_max_anim_layers)
|
if (layer_count > backtrack_max_anim_layers)
|
||||||
logging::msg("Not enough space for all layers (has %d, needs %d)",
|
logging::msg("Not enough space for all layers (has %d, needs %d)",
|
||||||
backtrack_max_anim_layers, layer_count);
|
backtrack_max_anim_layers, layer_count);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
auto layer_max = std::min<u32>(backtrack_max_anim_layers, layer_count);
|
auto layer_max = std::min<u32>(backtrack_max_anim_layers, layer_count);
|
||||||
@ -228,6 +228,7 @@ static math::Vector hullcolor[8] = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
void create_move(sdk::UserCmd *cmd) {
|
void create_move(sdk::UserCmd *cmd) {
|
||||||
|
#ifdef _DEBUG
|
||||||
for (auto entity : IFace<EntList>()->get_range()) {
|
for (auto entity : IFace<EntList>()->get_range()) {
|
||||||
if (entity->is_valid() == false) continue;
|
if (entity->is_valid() == false) continue;
|
||||||
auto player = entity->to_player();
|
auto player = entity->to_player();
|
||||||
@ -240,19 +241,21 @@ void create_move(sdk::UserCmd *cmd) {
|
|||||||
|
|
||||||
IFace<DebugOverlay>()->add_text_overlay(record.origin, 0, "%d", record.this_tick);
|
IFace<DebugOverlay>()->add_text_overlay(record.origin, 0, "%d", record.this_tick);
|
||||||
|
|
||||||
if (record.this_tick == cmd->tick_count)
|
//if (record.this_tick == cmd->tick_count) {
|
||||||
for (u32 i = 0; i < record.max_hitboxes; i++) {
|
auto &hitboxes = record.hitboxes;
|
||||||
auto &hitboxes = record.hitboxes;
|
for (u32 i = 0; i < record.max_hitboxes; i++) {
|
||||||
|
|
||||||
auto j = (record.this_tick % 8);
|
auto j = (record.this_tick % 8);
|
||||||
auto r = (int)(255.0f * hullcolor[j].x);
|
auto r = (int)(255.0f * hullcolor[j].x);
|
||||||
auto g = (int)(255.0f * hullcolor[j].y);
|
auto g = (int)(255.0f * hullcolor[j].y);
|
||||||
auto b = (int)(255.0f * hullcolor[j].z);
|
auto b = (int)(255.0f * hullcolor[j].z);
|
||||||
|
|
||||||
IFace<DebugOverlay>()->add_box_overlay(hitboxes.origin[i], hitboxes.raw_min[i], hitboxes.raw_max[i], hitboxes.rotation[i], r, g, b, 100, 0);
|
IFace<DebugOverlay>()->add_box_overlay(hitboxes.origin[i], hitboxes.raw_min[i], hitboxes.raw_max[i], hitboxes.rotation[i], r, g, b, 100, 0);
|
||||||
}
|
}
|
||||||
|
//}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
auto create_move_finish(sdk::UserCmd *cmd) -> void {
|
auto create_move_finish(sdk::UserCmd *cmd) -> void {
|
||||||
|
@ -6,6 +6,7 @@
|
|||||||
#include "netvar.hh"
|
#include "netvar.hh"
|
||||||
#include "vfunc.hh"
|
#include "vfunc.hh"
|
||||||
|
|
||||||
|
#include "log.hh"
|
||||||
#include "sdk.hh"
|
#include "sdk.hh"
|
||||||
|
|
||||||
using namespace sdk;
|
using namespace sdk;
|
||||||
@ -210,6 +211,7 @@ static auto get_hitboxes_internal(Player *player, const StudioModel *model, Play
|
|||||||
auto hitbox_set_ptr = model->hitbox_set(0);
|
auto hitbox_set_ptr = model->hitbox_set(0);
|
||||||
assert(hitbox_set_ptr);
|
assert(hitbox_set_ptr);
|
||||||
|
|
||||||
|
// Allow us to use operator[] properly
|
||||||
auto &hitbox_set = *hitbox_set_ptr;
|
auto &hitbox_set = *hitbox_set_ptr;
|
||||||
|
|
||||||
auto hitboxes_count = std::min(128u, hitbox_set.hitboxes_count);
|
auto hitboxes_count = std::min(128u, hitbox_set.hitboxes_count);
|
||||||
@ -221,24 +223,21 @@ static auto get_hitboxes_internal(Player *player, const StudioModel *model, Play
|
|||||||
auto box = hitbox_set[i];
|
auto box = hitbox_set[i];
|
||||||
assert(box);
|
assert(box);
|
||||||
|
|
||||||
math::Vector rotation;
|
const auto &transform = bone_to_world[box->bone];
|
||||||
math::matrix_angles(bone_to_world[box->bone], rotation, origin);
|
|
||||||
|
|
||||||
math::Matrix3x4 rotate_matrix;
|
auto rotated_min = transform.vector_transform(box->min);
|
||||||
rotate_matrix.from_angle(rotation);
|
auto rotated_max = transform.vector_transform(box->max);
|
||||||
|
|
||||||
math::Vector rotated_min, rotated_max;
|
|
||||||
|
|
||||||
rotated_min = rotate_matrix.rotate_vector(box->min);
|
|
||||||
rotated_max = rotate_matrix.rotate_vector(box->max);
|
|
||||||
|
|
||||||
centre = rotated_min.lerp(rotated_max, 0.5);
|
centre = rotated_min.lerp(rotated_max, 0.5);
|
||||||
|
|
||||||
hitboxes->centre[i] = origin + centre;
|
hitboxes->centre[i] = centre;
|
||||||
hitboxes->min[i] = origin + rotated_min;
|
hitboxes->min[i] = rotated_min;
|
||||||
hitboxes->max[i] = origin + rotated_max;
|
hitboxes->max[i] = rotated_max;
|
||||||
|
|
||||||
#ifdef _DEBUG
|
#ifdef _DEBUG
|
||||||
|
math::Vector rotation;
|
||||||
|
math::matrix_angles(transform, &rotation.x);
|
||||||
|
|
||||||
hitboxes->rotation[i] = rotation;
|
hitboxes->rotation[i] = rotation;
|
||||||
hitboxes->origin[i] = origin;
|
hitboxes->origin[i] = origin;
|
||||||
hitboxes->raw_min[i] = box->min;
|
hitboxes->raw_min[i] = box->min;
|
||||||
|
@ -263,6 +263,15 @@ public:
|
|||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
auto vector_transform(const Vector &in) const {
|
||||||
|
Vector column;
|
||||||
|
|
||||||
|
auto out = rotate_vector(in);
|
||||||
|
out += (get_column(3, column), column);
|
||||||
|
|
||||||
|
return out;
|
||||||
|
}
|
||||||
|
|
||||||
auto from_angle(const Vector &angles) {
|
auto from_angle(const Vector &angles) {
|
||||||
auto radian_pitch = to_radians(angles.x);
|
auto radian_pitch = to_radians(angles.x);
|
||||||
auto radian_yaw = to_radians(angles.y);
|
auto radian_yaw = to_radians(angles.y);
|
||||||
@ -351,4 +360,4 @@ inline void matrix_angles(const Matrix3x4 &matrix, Vector &angles, Vector &posit
|
|||||||
|
|
||||||
} // namespace math
|
} // namespace math
|
||||||
|
|
||||||
#define Vector_split_components(v) (v).x, (v).y, (v).z
|
#define vector_split_components(v) (v).x, (v).y, (v).z
|
||||||
|
Reference in New Issue
Block a user