From 3d412a4b30a9f7c7f51ea6562e694315948bd3da Mon Sep 17 00:00:00 2001 From: boris Date: Wed, 28 Nov 2018 16:00:02 +1300 Subject: cleaned up in short, the cheat and loader are now separate solutions. unused stuff was moved into the legacy solution in case anyone wants to compile it or whatever. i can change this back if you want to. also, i configured the loader to compile in x64, and have separate build types for linux and win64 --- cheat/gmod/c_base_weapon.cpp | 87 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 87 insertions(+) create mode 100644 cheat/gmod/c_base_weapon.cpp (limited to 'cheat/gmod/c_base_weapon.cpp') diff --git a/cheat/gmod/c_base_weapon.cpp b/cheat/gmod/c_base_weapon.cpp new file mode 100644 index 0000000..94c5ec6 --- /dev/null +++ b/cheat/gmod/c_base_weapon.cpp @@ -0,0 +1,87 @@ +#include "c_base_weapon.hpp" +#include "context.hpp" +#include "base_cheat.hpp" + +void* c_base_weapon::get_wpn_data( ) { + static auto func = pattern::first_code_match< void*( __thiscall* )( void* ) >( g_gmod.m_chl.dll( ), "0F B7 81 ? ? ? ? 50 E8 ? ? ? ? 83 C4 04 C3" ); + + if ( func ) + return func( this ); + + return nullptr; +} + +bool c_base_weapon::is_cw20( ) { + if( !g_ctx.m_lua ) + return false; + + const auto lua = g_ctx.m_lua; + + this->ce( )->PushEntity( ); + if( !lua->IsType( -1, LUA_TYPE::TYPE_ENTITY ) ) { + lua->Pop( 2 ); + return false; + } + + lua->GetField( -1, xors( "CW20Weapon" ) ); + if( !lua->IsType( -1, LUA_TYPE::TYPE_BOOL ) ) { + lua->Pop( 2 ); + return false; + } + + bool is_cw20 = lua->GetBool( -1 ); + + lua->Pop( 2 ); + + return is_cw20; +} + +bool c_base_weapon::is_fas2( ) { + if( !g_ctx.m_lua ) + return false; + + const auto lua = g_ctx.m_lua; + + this->ce( )->PushEntity( ); + if( !lua->IsType( -1, LUA_TYPE::TYPE_ENTITY ) ) { + lua->Pop( 2 ); + return false; + } + + lua->GetField( -1, xors( "IsFAS2Weapon" ) ); + if( !lua->IsType( -1, LUA_TYPE::TYPE_BOOL ) ) { + lua->Pop( 2 ); + return false; + } + + bool is_fas2 = lua->GetBool( -1 ); + + lua->Pop( 2 ); + + return is_fas2; +} + +float c_base_weapon::get_custom_cone( ) { + if( !g_ctx.m_lua ) + return 0.f; + + const auto lua = g_ctx.m_lua; + + this->ce( )->PushEntity( ); // thank god for this function. + if( !lua->IsType( -1, LUA_TYPE::TYPE_ENTITY ) ) { + lua->Pop( 2 ); + return false; + } + + lua->GetField( -1, xors( "CurCone" ) ); + if( !lua->IsType( -1, LUA_TYPE::TYPE_NUMBER ) ) { + lua->Pop( 2 ); + return false; + } + + float cone = lua->GetNumber( -1 ); + + lua->Pop( 2 ); + + return cone; +} \ No newline at end of file -- cgit v1.2.3