-
Автор темы
- #1
repost from uc (original post is still made by me) because people love reposting my shit on here, apparently
got the idea to do this while trying to rewrite my old nade prediction. naturally i got lazy and i whipped up this solution in about 1 hour.
ways to improve: access entity data directly in DrawNadePrediction hook - i just got lazy and didn't feel like wasting time reversing any more than i have to
sidenote: game's nade prediction is still pretty bad, but it's still better compared to most code floating around the community.
Пожалуйста, авторизуйтесь для просмотра ссылки.
got the idea to do this while trying to rewrite my old nade prediction. naturally i got lazy and i whipped up this solution in about 1 hour.
Пожалуйста, авторизуйтесь для просмотра ссылки.
ways to improve: access entity data directly in DrawNadePrediction hook - i just got lazy and didn't feel like wasting time reversing any more than i have to
sidenote: game's nade prediction is still pretty bad, but it's still better compared to most code floating around the community.
forcing cvar to be always on, but based
DrawNadePrediction hook
CDebugOverlay hooks - prevent game from drawing and get the data we need to draw our own cool lines instead
and finally, draw everything
C++:
#include "../hooks.hh"
/* cvar get bool hook */
bool __fastcall csgo::hooks::hkGetBool ( x86reg ) {
const static auto cl_grenadepreview_returnaddress = reinterpret_cast< void * >( SIG ( MODULE_CLIENT , _ ( "85 C0 74 7D 83 BF" ) ) );
if ( cl_grenadepreview_returnaddress == _ReturnAddress ( ) )
return 1;
return originals::o_getbool ( x86regout );
}
C++:
#include "../hooks.hh"
#include "../hacks/visuals/nadepred.hh"
/* drawnadeprediction_address = SIG ( MODULE_CLIENT , _ ( "55 8B EC 83 E4 F8 83 EC 50 56 57 FF 75 08" ) ); */
void __fastcall csgo::hooks::hkDrawNadePrediction ( x86reg , int a2 , int a3 ) {
/* clear old cache */
csgo::hacks::nade_prediction->m_entries.clear ( );
/* we're ready */
csgo::hacks::nade_prediction->m_hijacking = true;
originals::o_drawnadeprediction ( x86regout , a2 , a3 );
csgo::hacks::nade_prediction->m_hijacking = false;
}
C++:
#include "../hooks.hh"
#include "../hacks/visuals/nadepred.hh"
void __fastcall csgo::hooks::hkAddSphereOverlay ( x86reg , const c_vector3 & origin , float radius , int theta , int phi , int r , int g , int b , int a , float duration ) {
/* retn address if you're a weirdo: 5F 5E 8B E5 5D C2 ? ? CC CC CC CC CC CC CC CC CC CC CC CC CC 55 8B EC 83 E4 ? 83 EC ? 53 56 */
if ( csgo::hacks::nade_prediction->m_hijacking ) {
csgo::hacks::nadepredentry_t entry {};
entry.m_worldpos = origin;
entry.m_kind = 2;
csgo::hacks::nade_prediction->m_entries.push_back ( entry );
/* don't draw anything */
return;
}
originals::o_addsphereoverlay ( x86regout , origin , radius , theta , phi , r , g , b , a , duration );
}
void __fastcall csgo::hooks::hkAddBoxOverlay ( x86reg , const c_vector3 & origin , const c_vector3 & mins , const c_vector3 & maxs , const c_vector3 & orientation , int r , int g , int b , int a , float duration ) {
/* find retn address yourself */
if ( csgo::hacks::nade_prediction->m_hijacking ) {
csgo::hacks::nadepredentry_t entry {};
entry.m_worldpos = origin;
/* [MENTION=280760]Todo[/MENTION]: color check */
entry.m_kind = 0;
csgo::hacks::nade_prediction->m_entries.push_back ( entry );
/* don't draw anything */
return;
}
originals::o_addboxoverlay ( x86regout , origin , mins , maxs , orientation , r , g , b , a , duration );
}
C++:
struct nadepredentry_t {
c_vector3 m_worldpos;
/* something funny about the sphere rendering in CDebugOverlay - it doesn't ignore Z in contrast to everything else in CDebugOverlay */
std::uint8_t m_kind; /* 0 - in air, 1 - hit wall, 2 - final sphere (doesn't always draw i think?) */
};
void paint ( ) {
if ( this->m_entries.empty ( ) )
return;
this->m_drawing = true;
for ( auto & iter : this->m_entries ) {
c_vector3 screenpos {};
if ( csgo::render::world_to_screen ( iter.m_worldpos , screenpos ) ) {
// use your imagination
}
}
this->m_drawing = false;
}