-
Автор темы
- #1
namespace animations {
AnimationRecord AnimationRecord_t [65];
typedef void (__cdecl * fn) (char const * text, va_list);
void warning (char const * text, ...) {
static fn fpMsg = (fn) GetProcAddress (GetModuleHandle (L "tier0.dll"), "Warning");
char buf [950];
va_list vlist;
va_start (vlist, text);
_vsnprintf (buf, sizeof (buf), text, vlist);
va_end (vlist);
sprintf (buf, "% s \ n", buf);
fpMsg (buf, vlist);
}
bool update_incoming;
void error_check (C_BasePlayer * player) {
// Setup animation data structure
auto & data = AnimationRecord_t [player-> EntIndex ()];
// Print error to console when player is not being animated
if (player-> GetPlayerAnimState () -> m_flLastClientSideAnimationUpdateTime == data.old_update_time) {
static float previous;
if (g_GlobalVars-> realtime> = previous + 1.0f) {
warning ("*** ERROR: Entity not properly animated (entity% i:% s)", player-> EntIndex (), player-> GetClientClass () -> m_pNetworkName);
previous = g_GlobalVars-> realtime;
}
}
// Set old update time
data.old_update_time = player-> GetPlayerAnimState () -> m_flLastClientSideAnimationUpdateTime;
}
void check_incoming_update () {
static int old_tick_count;
if (old_tick_count! = g_GlobalVars-> tickcount) {
old_tick_count = g_GlobalVars-> tickcount;
update_incoming = true;
}
}
void conclude_update () {
update_incoming = false;
}
void update_state (C_BasePlayer * player) {
// Find animstate attached to the provided entity
auto state = player-> GetPlayerAnimState ();
// Setup host_timescale convar
static const auto host_timescale = g_CVar-> FindVar ("host_timescale") -> GetFloat ();
// Setup animation data structure
auto & data = AnimationRecord_t [player-> EntIndex ()];
// Update animations this frame
if (player-> GetPlayerAnimState () -> m_iLastClientSideAnimationUpdateFramecount == g_GlobalVars-> framecount) {
player-> GetPlayerAnimState () -> m_iLastClientSideAnimationUpdateFramecount = g_GlobalVars-> framecount - 1;
}
// Fix information related to networked players
if (player! = g_LocalPlayer) {
// Fix update delta
state-> m_flAnimUpdateDelta = fmaxf (g_GlobalVars-> curtime - state-> m_flLastClientSideAnimationUpdateTime, 0.0);
// Thanks, polak!
if (* (float *) ((uintptr_t) & player-> GetAnimOverlays () [0] + 0x138)! = 0.f) {
player-> m_fFlags () | = 1;
}
// Set flags to EFL_DIRTY_VELOCITY
player-> m_iEFlags () & = ~ 0x1000;
}
// Fix player legs being stuck in falling animation
if (player-> GetPlayerAnimState () -> m_flWorldForce <0) {
player-> GetPlayerAnimState () -> m_flTimeSinceInAir = 0.f;
}
// Allow animations to be updated
data.override_animations = false;
// Update player animations
player-> UpdateClientSideAnimation ();
}
void build_matrix (C_BasePlayer * player) {
// Setup animation data structure
auto & data = AnimationRecord_t [player-> EntIndex ()];
// Fix PVS on networked players
if (player! = g_LocalPlayer) {
* reinterpret_cast <int *> (reinterpret_cast <uintptr_t> (player) + 0xA30) = g_GlobalVars-> framecount;
* reinterpret_cast <int *> (reinterpret_cast <uintptr_t> (player) + 0xA28) = 0;
}
// Allow SetupBones to be called
data.allow_setup_bones = true;
// Strip interpolation
* (int *) ((int) player + 236) | = 8;
// Invalidate then setup new bones
player-> InvalidateBoneCache ();
player-> SetupBones (nullptr, -1, 0x7FF00, 0.0f);
// Allow interpolation
* (int *) ((int) player + 236) & = ~ 8;
// Prevent SetupBones from being called on networked players
if (player! = g_LocalPlayer) {
data.allow_setup_bones = false;
}
}
void local_player (C_BasePlayer * player) {
static float goal_feet = player-> GetPlayerAnimState () -> m_flGoalFeetYaw;
static std :: array <float, 24U> sent_pose_params = player-> m_flPoseParameter ();
auto & rdata = AnimationRecord_t [player-> EntIndex ()];
if (update_incoming) {
std :: memcpy (rdata.backup_layers, player-> GetAnimOverlays (), (sizeof (AnimationLayer) * 15));
rdata.override_animations = false;
player-> UpdateClientSideAnimation ();
if (globals :: send_packet) {
goal_feet = player-> GetPlayerAnimState () -> m_flGoalFeetYaw;
sent_pose_params = g_LocalPlayer-> m_flPoseParameter ();
}
}
rdata.override_animations = true;
player-> SetAbsAngles (QAngle (0, goal_feet, 0));
player-> GetPlayerAnimState () -> m_flMagicFraction = 0.f;
std :: memcpy (player-> GetAnimOverlays (), rdata.backup_layers, (sizeof (AnimationLayer) * 15));
player-> m_flPoseParameter () = sent_pose_params;
}
void process (C_BasePlayer * player) {
// Fix our local player seperately
if (player == g_LocalPlayer) {
local_player (player);
return
}
// Setup data structures
auto & data = AnimationRecord_t [player-> EntIndex ()];
// std :: array <float, 24U> sent_pose_params = player-> m_flPoseParameter ();
// Completely revert animations if shit goes south
if (! player-> m_hActiveWeapon () || g_LocalPlayer-> m_iHealth () <= 0) {
data.override_animations = false;
data.allow_setup_bones = true;
return
}
// Calculate when the player shot for on-shot backtrack
// if (data.old_shot_time! = player-> m_hActiveWeapon () -> m_flPostponeFireReadyTime ()) {
// data.shot_update = true;
// data.old_shot_time = player-> m_hActiveWeapon () -> m_flPostponeFireReadyTime ();
//}
//
// if (update_incoming) {
//
// // Resolve enemy's abs yaw
// resolver :: resolve (player);
//
// // Store animation layers and pose parameters
// sent_pose_params = player-> m_flPoseParameter ();
// std :: memcpy (data.backup_layers, player-> GetAnimOverlays (), sizeof (AnimationLayer) * 15);
//
// // Update animations
// update_state (player);
//}
//
// Prevent animations from being updated
//data.override_animations = true;
//
// Restore animation layers and pose parameters
// player-> GetPlayerAnimState () -> m_flMagicFraction = 0.f;
// player-> m_flPoseParameter () = sent_pose_params;
// std :: memcpy (player-> GetAnimOverlays (), data.backup_layers, sizeof (AnimationLayer) * 15);
// Setup new matrix
build_matrix (player);
}
void animate () {
if (! g_EngineClient-> IsConnected () ||! g_EngineClient-> IsInGame ())
return
check_incoming_update ();
for (auto m = 1; m <= 64; m ++) {
auto player = (C_BasePlayer *) g_EntityList-> GetClientEntity (m);
// Entity validation checks
if (! player ||! g_LocalPlayer ||! player-> IsPlayer () || player-> IsDormant ()
|| ! player-> IsAlive ())
continue;
auto & data = AnimationRecord_t [player-> EntIndex ()];
if (player-> m_iHealth () <= 0) {
data.override_animations = false;
data.allow_setup_bones = true;
continue;
}
// Process all player's animations
process (player);
// Check for errors
if (update_incoming)
error_check (player);
}
conclude_update ();
}
}
AnimationRecord AnimationRecord_t [65];
typedef void (__cdecl * fn) (char const * text, va_list);
void warning (char const * text, ...) {
static fn fpMsg = (fn) GetProcAddress (GetModuleHandle (L "tier0.dll"), "Warning");
char buf [950];
va_list vlist;
va_start (vlist, text);
_vsnprintf (buf, sizeof (buf), text, vlist);
va_end (vlist);
sprintf (buf, "% s \ n", buf);
fpMsg (buf, vlist);
}
bool update_incoming;
void error_check (C_BasePlayer * player) {
// Setup animation data structure
auto & data = AnimationRecord_t [player-> EntIndex ()];
// Print error to console when player is not being animated
if (player-> GetPlayerAnimState () -> m_flLastClientSideAnimationUpdateTime == data.old_update_time) {
static float previous;
if (g_GlobalVars-> realtime> = previous + 1.0f) {
warning ("*** ERROR: Entity not properly animated (entity% i:% s)", player-> EntIndex (), player-> GetClientClass () -> m_pNetworkName);
previous = g_GlobalVars-> realtime;
}
}
// Set old update time
data.old_update_time = player-> GetPlayerAnimState () -> m_flLastClientSideAnimationUpdateTime;
}
void check_incoming_update () {
static int old_tick_count;
if (old_tick_count! = g_GlobalVars-> tickcount) {
old_tick_count = g_GlobalVars-> tickcount;
update_incoming = true;
}
}
void conclude_update () {
update_incoming = false;
}
void update_state (C_BasePlayer * player) {
// Find animstate attached to the provided entity
auto state = player-> GetPlayerAnimState ();
// Setup host_timescale convar
static const auto host_timescale = g_CVar-> FindVar ("host_timescale") -> GetFloat ();
// Setup animation data structure
auto & data = AnimationRecord_t [player-> EntIndex ()];
// Update animations this frame
if (player-> GetPlayerAnimState () -> m_iLastClientSideAnimationUpdateFramecount == g_GlobalVars-> framecount) {
player-> GetPlayerAnimState () -> m_iLastClientSideAnimationUpdateFramecount = g_GlobalVars-> framecount - 1;
}
// Fix information related to networked players
if (player! = g_LocalPlayer) {
// Fix update delta
state-> m_flAnimUpdateDelta = fmaxf (g_GlobalVars-> curtime - state-> m_flLastClientSideAnimationUpdateTime, 0.0);
// Thanks, polak!
if (* (float *) ((uintptr_t) & player-> GetAnimOverlays () [0] + 0x138)! = 0.f) {
player-> m_fFlags () | = 1;
}
// Set flags to EFL_DIRTY_VELOCITY
player-> m_iEFlags () & = ~ 0x1000;
}
// Fix player legs being stuck in falling animation
if (player-> GetPlayerAnimState () -> m_flWorldForce <0) {
player-> GetPlayerAnimState () -> m_flTimeSinceInAir = 0.f;
}
// Allow animations to be updated
data.override_animations = false;
// Update player animations
player-> UpdateClientSideAnimation ();
}
void build_matrix (C_BasePlayer * player) {
// Setup animation data structure
auto & data = AnimationRecord_t [player-> EntIndex ()];
// Fix PVS on networked players
if (player! = g_LocalPlayer) {
* reinterpret_cast <int *> (reinterpret_cast <uintptr_t> (player) + 0xA30) = g_GlobalVars-> framecount;
* reinterpret_cast <int *> (reinterpret_cast <uintptr_t> (player) + 0xA28) = 0;
}
// Allow SetupBones to be called
data.allow_setup_bones = true;
// Strip interpolation
* (int *) ((int) player + 236) | = 8;
// Invalidate then setup new bones
player-> InvalidateBoneCache ();
player-> SetupBones (nullptr, -1, 0x7FF00, 0.0f);
// Allow interpolation
* (int *) ((int) player + 236) & = ~ 8;
// Prevent SetupBones from being called on networked players
if (player! = g_LocalPlayer) {
data.allow_setup_bones = false;
}
}
void local_player (C_BasePlayer * player) {
static float goal_feet = player-> GetPlayerAnimState () -> m_flGoalFeetYaw;
static std :: array <float, 24U> sent_pose_params = player-> m_flPoseParameter ();
auto & rdata = AnimationRecord_t [player-> EntIndex ()];
if (update_incoming) {
std :: memcpy (rdata.backup_layers, player-> GetAnimOverlays (), (sizeof (AnimationLayer) * 15));
rdata.override_animations = false;
player-> UpdateClientSideAnimation ();
if (globals :: send_packet) {
goal_feet = player-> GetPlayerAnimState () -> m_flGoalFeetYaw;
sent_pose_params = g_LocalPlayer-> m_flPoseParameter ();
}
}
rdata.override_animations = true;
player-> SetAbsAngles (QAngle (0, goal_feet, 0));
player-> GetPlayerAnimState () -> m_flMagicFraction = 0.f;
std :: memcpy (player-> GetAnimOverlays (), rdata.backup_layers, (sizeof (AnimationLayer) * 15));
player-> m_flPoseParameter () = sent_pose_params;
}
void process (C_BasePlayer * player) {
// Fix our local player seperately
if (player == g_LocalPlayer) {
local_player (player);
return
}
// Setup data structures
auto & data = AnimationRecord_t [player-> EntIndex ()];
// std :: array <float, 24U> sent_pose_params = player-> m_flPoseParameter ();
// Completely revert animations if shit goes south
if (! player-> m_hActiveWeapon () || g_LocalPlayer-> m_iHealth () <= 0) {
data.override_animations = false;
data.allow_setup_bones = true;
return
}
// Calculate when the player shot for on-shot backtrack
// if (data.old_shot_time! = player-> m_hActiveWeapon () -> m_flPostponeFireReadyTime ()) {
// data.shot_update = true;
// data.old_shot_time = player-> m_hActiveWeapon () -> m_flPostponeFireReadyTime ();
//}
//
// if (update_incoming) {
//
// // Resolve enemy's abs yaw
// resolver :: resolve (player);
//
// // Store animation layers and pose parameters
// sent_pose_params = player-> m_flPoseParameter ();
// std :: memcpy (data.backup_layers, player-> GetAnimOverlays (), sizeof (AnimationLayer) * 15);
//
// // Update animations
// update_state (player);
//}
//
// Prevent animations from being updated
//data.override_animations = true;
//
// Restore animation layers and pose parameters
// player-> GetPlayerAnimState () -> m_flMagicFraction = 0.f;
// player-> m_flPoseParameter () = sent_pose_params;
// std :: memcpy (player-> GetAnimOverlays (), data.backup_layers, sizeof (AnimationLayer) * 15);
// Setup new matrix
build_matrix (player);
}
void animate () {
if (! g_EngineClient-> IsConnected () ||! g_EngineClient-> IsInGame ())
return
check_incoming_update ();
for (auto m = 1; m <= 64; m ++) {
auto player = (C_BasePlayer *) g_EntityList-> GetClientEntity (m);
// Entity validation checks
if (! player ||! g_LocalPlayer ||! player-> IsPlayer () || player-> IsDormant ()
|| ! player-> IsAlive ())
continue;
auto & data = AnimationRecord_t [player-> EntIndex ()];
if (player-> m_iHealth () <= 0) {
data.override_animations = false;
data.allow_setup_bones = true;
continue;
}
// Process all player's animations
process (player);
// Check for errors
if (update_incoming)
error_check (player);
}
conclude_update ();
}
}