Expert HvHer
- User ID
- 43664
- Messages
- 21
- Reactions
- 239
- Level
- 11
This is a repost of a topic from another forum, I believe that this is the correct code and someone will need it, so I am reposting to this forum.
Thread credit: @william1337
Thread credit: @william1337
class:
class c_base_grenade_projectile {
public:
DWORD* dword0{};
private:
char gap4[ 168 ];
public:
c_vec3 m_local_origin{};
private:
char gapB8[ 10476 ];
public:
c_glow_object* m_glow_object{};
private:
char gap29A8[ 96 ];
public:
c_vec3 m_last_trail_line_pos{};
float m_next_trail_line_time{};
};
hook:
//module: client.dll; sig: 55 8B EC 83 E4 F8 83 EC 68 56 8B F1 8B 4D
void __fastcall hooks::hk_create_grenade_trail( void* ecx, void* edx ) {
const auto this_pointer = static_cast< c_base_grenade_projectile* >( ecx );
if ( !ctx::local( ) || !this_pointer )
return;
if ( this_pointer->m_next_trail_line_time > i::m_globals->m_current_time )
return;
qangle_t grenade_traj_angles;
c_vec3 temp_orientation = ( this_pointer->m_last_trail_line_pos - this_pointer->m_local_origin );
math::vector_angles( temp_orientation, grenade_traj_angles );
static const auto sv_grenade_trajectory_thickness = i::m_cvar->find_var( _( "sv_grenade_trajectory_thickness" ) );
static const auto sv_grenade_trajectory_dash = i::m_cvar->find_var( _( "sv_grenade_trajectory_dash" ) );
static const auto sv_grenade_trajectory_time_spectator = i::m_cvar->find_var( _( "sv_grenade_trajectory_time_spectator" ) );
const auto grenade_traj_thickness = sv_grenade_trajectory_thickness->get_float( );
const auto grenade_traj_min = c_vec3{ 0.0f, -grenade_traj_thickness, -grenade_traj_thickness };
const auto grenade_traj_max = c_vec3{ temp_orientation.length( ), grenade_traj_thickness, grenade_traj_thickness };
const auto team = *reinterpret_cast< int* >( reinterpret_cast< std::uintptr_t >( this_pointer->dword0 ) + 0xF4 );
c_color trace_color;
trace_color.set_color( team == team_ct ? 114, 155, 221 : 224, 175, 86 );
if ( sv_grenade_trajectory_dash->get_int( ) && std::fmod( i::m_globals->m_current_time, 0.1f ) < 0.05f ) {
trace_color[ 0 ] /= 10;
trace_color[ 1 ] /= 10;
trace_color[ 2 ] /= 10;
}
i::m_glow_manager->add_glow_box( this_pointer->m_local_origin, grenade_traj_angles, grenade_traj_min, grenade_traj_max, trace_color, sv_grenade_trajectory_time_spectator->get_float( ), i::m_globals->m_current_time );
this_pointer->m_last_trail_line_pos = this_pointer->m_local_origin;
this_pointer->m_next_trail_line_time = i::m_globals->m_current_time + 0.05f;
}