-
Автор темы
- #1
Обратите внимание, пользователь заблокирован на форуме. Не рекомендуется проводить сделки.
Сделал максимально костыльно как по мне, но убивать может.
Код:
class c_resolver : public c_singleton<c_resolver>
{
public:
static void instance(c_base_player* player, c_lag_record& lag_record, const c_lag_record previous_record);
static void detect_side_of_playback_rate(const c_base_player* player, c_lag_record& lag_record, c_lag_record previous_record);
static void resolve_stand(c_base_player* player, c_lag_record& lag_record);
static void resolve_moves(c_base_player* player, c_lag_record& lag_record);
static void apply_final_rotation_mode(c_base_player* player, c_lag_record& lag_record);
static void set_abs_angles_and_bones(c_base_player* player, c_lag_record& lag_record, int32_t rotation_mode = 0);
static void setup_resolver_layers(c_base_player* player, c_lag_record& lag_record, int32_t rotation_mode);
};
Код:
void c_resolver::instance(c_base_player* player, c_lag_record& lag_record, const c_lag_record previous_record)
{
if (!player || !player->is_alive())
return;
if (!player->get_anim_state())
return;
/* perhaps there will be questions about 1.2f
* this is done due to the fact that people began to break the velocity with a micro-movement or something like that and the magic value of 1.2f comes out from here
* or no ? hmm, interesting - https://github.com/perilouswithadollarsign/cstrike15_src/blob/f82112a2388b841d72cb62ca48ab1846dfcc11c8/game/shared/cstrike15/csgo_playeranimstate.cpp#L2238
*/
if (player->get_anim_state()->m_velocity.length_2d() > 1.2f || player->get_anim_state()->m_velocity_length_xy > 0.1f && fabsf(player->get_anim_state()->m_velocity_length_z) > 100.0f)
{
lag_record.m_is_moving = true;
lag_record.m_is_standing = false;
resolve_moves(player, lag_record);
//setup_resolver_layers(player, lag_record, lag_record.m_rotation_mode);
//detect_side_of_playback_rate(player, lag_record, previous_record);
}
else
{
lag_record.m_is_moving = false;
lag_record.m_is_standing = true;
resolve_stand(player, lag_record);
}
/* if shot missed -> change current angle */
/* brute side filling in rage-bot if does intersect hitbox */
if (lag_record.m_rotation_mode == g_sdk.m_resolver_data.m_brute_side[player->ent_index()])
{
if (g_sdk.m_resolver_data.m_missed_shots[player->ent_index()] > 0)
{
auto new_rotation = ROTATE_SERVER;
/* fucking cycle xD */
switch (lag_record.m_rotation_mode)
{
case ROTATE_LEFT: new_rotation = ROTATE_RIGHT;
break;
case ROTATE_RIGHT: new_rotation = ROTATE_LOW_RIGHT;
break;
case ROTATE_LOW_RIGHT: new_rotation = ROTATE_LOW_LEFT;
break;
case ROTATE_LOW_LEFT: new_rotation = ROTATE_LEFT;
break;
default: break;
}
/* set new value */
lag_record.m_rotation_mode = new_rotation;
}
}
}
void c_resolver::detect_side_of_playback_rate(const c_base_player* player, c_lag_record& lag_record, c_lag_record previous_record)
{
/* find player's side using animation playback rate
* where the speed is greater, there is most likely the player's side
* @note: delta_center - nervously smoking on the sidelines he-he
*/
lag_record.m_anim_resolved = false;
int m_side = 0;
bool m_can_animate;
if (!(lag_record.m_animation_layers.at(ANIMATION_LAYER_MOVEMENT_MOVE).m_weight * 1000.0f))
{
if (lag_record.m_animation_layers.at(ANIMATION_LAYER_MOVEMENT_MOVE).m_weight * 1000.0f == previous_record.m_animation_layers.at(ANIMATION_LAYER_MOVEMENT_MOVE).m_weight * 1000.0f)
{
const float delta_left = abs(lag_record.m_animation_layers.at(ANIMATION_LAYER_MOVEMENT_MOVE).m_playback_rate - lag_record.m_resolver_layers.at(S_LEFT).at(ANIMATION_LAYER_MOVEMENT_MOVE).m_playback_rate);
const float delta_right = abs(lag_record.m_animation_layers.at(ANIMATION_LAYER_MOVEMENT_MOVE).m_playback_rate - lag_record.m_resolver_layers.at(S_RIGHT).at(ANIMATION_LAYER_MOVEMENT_MOVE).m_playback_rate);
const float delta_center = abs(lag_record.m_animation_layers.at(ANIMATION_LAYER_MOVEMENT_MOVE).m_playback_rate - lag_record.m_resolver_layers.at(S_SERVER).at(ANIMATION_LAYER_MOVEMENT_MOVE).m_playback_rate);
const float delta_quad = abs(lag_record.m_animation_layers.at(ANIMATION_LAYER_MOVEMENT_MOVE).m_playback_rate - lag_record.m_resolver_layers.at(S_QUAD).at(ANIMATION_LAYER_MOVEMENT_MOVE).m_playback_rate);
bool m_finally_active{};
if (!(delta_quad * 1000.f))
{
m_finally_active = true;
}
m_side = 0;
float last_delta = abs(lag_record.m_animation_layers.at(ANIMATION_LAYER_MOVEMENT_MOVE).m_playback_rate - lag_record.m_resolver_layers.at(S_QUAD).at(ANIMATION_LAYER_MOVEMENT_MOVE).m_playback_rate);
if (delta_center * 1000.f || delta_quad < delta_center)
{
m_can_animate = m_finally_active;
}
else
{
m_can_animate = true;
m_side = ROTATE_SERVER;
last_delta = delta_center;
}
if (!(delta_left * 1000.f) && last_delta >= delta_left)
{
m_can_animate = true;
m_side = ROTATE_RIGHT;
last_delta = delta_left;
}
if (!(delta_right * 1000.f) && last_delta >= delta_right)
{
m_can_animate = true;
m_side = ROTATE_LEFT;
//return;
}
}
else
{
m_can_animate = false;
}
}
lag_record.m_anim_resolved = m_can_animate;
lag_record.m_rotation_mode = m_side;
}
void c_resolver::resolve_stand(c_base_player* player, c_lag_record& lag_record)
{
/* get player angle */
const auto feet_delta = math::angle_normalize(math::angle_diff(math::angle_normalize(player->get_lower_body_yaw()), math::angle_normalize(player->get_eye_angles().y)));
const auto eye_diff = math::angle_diff(player->get_eye_angles().y, player->get_anim_state()->m_abs_yaw);
/* the player has just moved from a state of RUNNING to a state of STANDING */
auto stopped_moving = player->get_sequence_activity(lag_record.m_animation_layers.at(ANIMATION_LAYER_ADJUST).m_sequence) == ACT_CSGO_IDLE_ADJUST_STOPPEDMOVING;
/* if player has delta >= 120 (max_desync_delta); */
auto balance_adjust = player->get_sequence_activity(lag_record.m_animation_layers.at(ANIMATION_LAYER_ADJUST).m_sequence) == ACT_CSGO_IDLE_TURN_BALANCEADJUST;
/* a very important thing for rebuild stopped moving
* ref: https://github.com/perilouswithadollarsign/cstrike15_src/blob/f82112a2388b841d72cb62ca48ab1846dfcc11c8/game/shared/cstrike15/csgo_playeranimstate.cpp#L2296
* @note: you can use the logic from there, but only in the other direction, to detect the moves and rebuild something (started_moving_this_frame )
*/
bool stopped_moving_this_frame = false;
if (player->get_anim_state()->m_velocity_length_xy <= 0.1f)
{
stopped_moving_this_frame = player->get_anim_state()->m_duration_still <= 0;
player->get_anim_state()->m_duration_moving = 0.0f;
player->get_anim_state()->m_duration_still += player->get_anim_state()->m_last_update_increment;
}
/* rebuild balance adjust
* thanks to my homies llama & valve
* ref: https://github.com/perilouswithadollarsign/cstrike15_src/blob/f82112a2388b841d72cb62ca48ab1846dfcc11c8/game/shared/cstrike15/csgo_playeranimstate.cpp#L2380
*/
if (player->get_anim_state()->m_ladder_weight == 0.0f && player->get_anim_state()->m_land_anim_multiplier == 0.0f && player->get_anim_state()->m_last_update_increment > 0.0f)
{
const auto current_feet_yaw = player->get_anim_state()->m_abs_yaw_last;
const auto goal_feet_yaw = player->get_anim_state()->m_abs_yaw;
auto eye_delta = current_feet_yaw - goal_feet_yaw;
if (goal_feet_yaw < current_feet_yaw)
{
if (eye_delta >= 180.0f)
eye_delta -= 360.0f;
}
else if (eye_delta <= -180.0f)
eye_delta += 360.0f;
if (eye_delta / player->get_anim_state()->m_last_update_increment > 120.f)
{
lag_record.m_animation_layers.at(ANIMATION_LAYER_ADJUST).m_cycle =
0.0f;
lag_record.m_animation_layers.at(ANIMATION_LAYER_ADJUST).m_weight =
0.0f;
balance_adjust = true;
player->get_anim_state()->m_adjust_started = true;
}
}
/* rebuild stopped moving
* ref: https://github.com/perilouswithadollarsign/cstrike15_src/blob/f82112a2388b841d72cb62ca48ab1846dfcc11c8/game/shared/cstrike15/csgo_playeranimstate.cpp#L2302
*/
if (!player->get_anim_state()->m_adjust_started && stopped_moving_this_frame && player->get_anim_state()->m_on_ground && player->get_anim_state()->m_ladder_weight == 0.0f && player->get_anim_state()->m_land_anim_multiplier == 0.0f /*!landing & !ladder logic*/ && player->get_anim_state()->m_stutter_step < 50.0f)
{
stopped_moving = true;
player->get_anim_state()->m_adjust_started = true;
}
/* just find our side if player meets all three conditions */
if (stopped_moving || balance_adjust || player->get_anim_state()->m_adjust_started)
{
/* detect side */
lag_record.m_rotation_mode = feet_delta > 0.0f && eye_diff > 0.0f ? ROTATE_LEFT : ROTATE_RIGHT;
/* store value for logging */
lag_record.m_feet_delta = feet_delta;
/* update lby
* ref: https://prnt.sc/26jm7xs | https://github.com/perilouswithadollarsign/cstrike15_src/blob/f82112a2388b841d72cb62ca48ab1846dfcc11c8/game/shared/cstrike15/csgo_playeranimstate.cpp#L2353
*/
player->get_anim_state()->m_abs_yaw = math::approach_angle(player->get_lower_body_yaw(), player->get_anim_state()->m_abs_yaw, player->get_anim_state()->m_last_update_increment * 100.0f);
}
/* if rotation mode != server -> push rotation mode to last brute side */
g_sdk.m_resolver_data.m_last_brute_side[player->ent_index()] = lag_record.m_rotation_mode;
}
void c_resolver::resolve_moves(c_base_player* player, c_lag_record& lag_record)
{
/* too hard to explain, a lot of tests have been done with this shit, I'm too lazy */
if (const auto eye_diff = math::angle_normalize(math::angle_diff(player->get_eye_angles().y, player->get_anim_state()->m_abs_yaw)); eye_diff > player->get_max_desync_delta())
{
lag_record.m_rotation_mode = ROTATE_LOW_RIGHT;
}
else
{
if (player->get_min_desync_delta() > eye_diff)
lag_record.m_rotation_mode = ROTATE_LOW_LEFT;
}
/* update lby
* ref: https://prnt.sc/26jm7xs | https://github.com/perilouswithadollarsign/cstrike15_src/blob/f82112a2388b841d72cb62ca48ab1846dfcc11c8/game/shared/cstrike15/csgo_playeranimstate.cpp#L2353
*/
player->get_anim_state()->m_abs_yaw = math::approach_angle(player->get_eye_angles().y, player->get_anim_state()->m_abs_yaw, (player->get_anim_state()->m_walk_to_run_transition * 20.0f + 30.0f) * player->get_anim_state()->m_last_update_increment);
/* if thinking about this logic, you just understand it */
/* if rotation mode != server -> push rotation mode to last brute side */
if (lag_record.m_rotation_mode != S_SERVER)
g_sdk.m_resolver_data.m_last_brute_side[player->ent_index()] = lag_record.m_rotation_mode;
/* else if rotation mode == server -> push last bruted side to rotation side */
else
lag_record.m_rotation_mode = g_sdk.m_resolver_data.m_last_brute_side[player->ent_index()];
}
void c_resolver::set_abs_angles_and_bones(c_base_player* player, c_lag_record& lag_record, const int32_t rotation_mode)
{
switch (rotation_mode)
{
case ROTATE_LEFT:
{
player->get_anim_state()->m_abs_yaw = math::angle_normalize(player->get_eye_angles().y + player->get_min_desync_delta());
c_bone_manager::build_matrix(player, lag_record.m_matrices[ROTATE_LEFT].data(), false);
}
break;
case ROTATE_RIGHT:
{
player->get_anim_state()->m_abs_yaw = math::angle_normalize(player->get_eye_angles().y - player->get_max_desync_delta());
c_bone_manager::build_matrix(player, lag_record.m_matrices[ROTATE_RIGHT].data(), false);
}
break;
default: break;
}
return player->invalidate_physics_recursive(ANGLES_CHANGED);
}
void c_resolver::setup_resolver_layers(c_base_player* player, c_lag_record& lag_record, const int32_t rotation_mode)
{
switch (rotation_mode)
{
case ROTATE_SERVER:
{
memcpy(lag_record.m_resolver_layers.at(S_SERVER).data(), player->get_anim_layers(),
sizeof(c_animation_layer) * ANIMATION_LAYER_COUNT);
}
break;
case ROTATE_LEFT:
case ROTATE_LOW_LEFT:
{
memcpy(lag_record.m_resolver_layers.at(S_LEFT).data(), player->get_anim_layers(),
sizeof(c_animation_layer) * ANIMATION_LAYER_COUNT);
}
break;
case ROTATE_RIGHT:
case ROTATE_LOW_RIGHT:
{
memcpy(lag_record.m_resolver_layers.at(S_RIGHT).data(), player->get_anim_layers(),
sizeof(c_animation_layer) * ANIMATION_LAYER_COUNT);
}
break;
default: break;
}
}
Последнее редактирование: