You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
codm/ligma-cheat/ligma-cheat/main.cpp

93 lines
3.3 KiB

#include "bypass/bypass.h"
#include "SDK/assembly-csharp.dll/gamebase.h"
#include "SDK/assembly-csharp.dll/gameengine.h"
#include "SDK/unityengine.dll/unityengine.h"
namespace movement
{
// 0x1DAB2EC
__attribute__((noinline))
float calc_walk_speed()
{
return 12.5f;
}
}
namespace weapon
{
// 0x2E3A99C, 0x2E41190, 0x2E45448
__attribute__((noinline))
bool check_target()
{
return true;
}
// 0x1D835A0
__attribute__((noinline))
gameengine::attackabletarget* find_melee_target(gamebase::pawn* pawn, float range)
{
LOGI("find melee target called! range = %.2f, pawn = %p", range, pawn);
ligma::hook::disable(il2cpp::il2cpp_base() + 0x1D835A0);
auto attack_target = pawn->findmeleeattacktarget<gameengine::attackabletarget*>(range);
ligma::hook::enable(il2cpp::il2cpp_base() + 0x1D835A0);
LOGI("attackable target = %p", attack_target);
if (!attack_target)
{
const auto game_base = gameengine::gameplay::get_game<gamebase::basegame*>();
const auto game_info = gameengine::gameplay::get_gameinfo<gameengine::gameinfo*>();
const auto local_pawn = gameengine::gameplay::get_localpawn<gamebase::pawn*>();
const auto enemy_pawn_list = game_base->enemypawns<il2cpp_list<gamebase::pawn*>*>();
const auto enemy_pawns = enemy_pawn_list->get_items();
for (auto idx = 0u; idx < enemy_pawn_list->get_size(); ++idx)
{
if (enemy_pawns[idx]->get_health())
{
const auto actor_id = game_info->getactorid(enemy_pawns[idx]->get_playerid());
const auto attackable_target = game_base->getattackabletarget<gameengine::attackabletarget*>(actor_id);
// put the pawn on my head
enemy_pawns[idx]->setlocation(local_pawn->get_headposition());
LOGI("player_id => 0x%x, actor_id => 0x%x, attackable_target => %p", enemy_pawns[idx]->get_playerid(), actor_id, attackable_target);
attack_target = attackable_target;
}
}
}
return attack_target;
}
// 0x2E44660
__attribute__((noinline))
bool cast_ray(gameengine::weaponfirecomponentmelee* melee, unityengine::collider* collider, il2cpp_vec3 start, int trace_flag, il2cpp_vec3* dir, gameengine::attackabletarget* hit_target)
{
LOGI("============ cast ray called! ================");
ligma::hook::disable(il2cpp::il2cpp_base() + 0x2E44660);
const auto result = melee->raycastmeleeobb(
reinterpret_cast<std::uintptr_t>(collider),
start, trace_flag,
reinterpret_cast<std::uintptr_t>(dir),
reinterpret_cast<std::uintptr_t>(hit_target)
);
ligma::hook::enable(il2cpp::il2cpp_base() + 0x2E44660);
LOGI("result = %d, hit_target = %p, dir = %p", result, hit_target, dir);
return result;
}
}
__attribute__((constructor))
void init()
{
ligma::bypass::init([&](std::uintptr_t il2cpp_base, void* module_handle) -> bool
{
LOGI("il2cpp base address = %p, module_handle = %p", il2cpp_base, module_handle);
ligma::hook::make_hook(il2cpp_base + 0x1DAB2EC, &movement::calc_walk_speed);
ligma::hook::make_hook(il2cpp_base + 0x1D835A0, &weapon::find_melee_target);
ligma::hook::make_hook(il2cpp_base + 0x2E41190, &weapon::check_target);
ligma::hook::make_hook(il2cpp_base + 0x2E3A99C, &weapon::check_target);
ligma::hook::make_hook(il2cpp_base + 0x2E45448, &weapon::check_target);
ligma::hook::make_hook(il2cpp_base + 0x2E44660, &weapon::cast_ray);
return false;
});
LOGI("installed bypass...");
}