Skip to content

Commit

Permalink
Simulate ctrl + 5 in game for special skins
Browse files Browse the repository at this point in the history
  • Loading branch information
R3nzTheCodeGOD committed Sep 4, 2022
1 parent f2f849f commit 86d3802
Showing 1 changed file with 41 additions and 30 deletions.
71 changes: 41 additions & 30 deletions R3nzSkin/Hooks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,32 +19,6 @@

LRESULT ImGui_ImplWin32_WndProcHandler(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam);

inline void nextSkin() noexcept
{
if (const auto player{ cheatManager.memory->localPlayer }; player) {
const auto& values{ cheatManager.database->champions_skins[fnv::hash_runtime(player->get_character_data_stack()->base_skin.model.str)] };
cheatManager.config->current_combo_skin_index++;
if (cheatManager.config->current_combo_skin_index > static_cast<std::int32_t>(values.size()))
cheatManager.config->current_combo_skin_index = static_cast<std::int32_t>(values.size());
if (cheatManager.config->current_combo_skin_index > 0)
player->change_skin(values[cheatManager.config->current_combo_skin_index - 1].model_name.c_str(), values[cheatManager.config->current_combo_skin_index - 1].skin_id);
cheatManager.config->save();
}
}

inline void previousSkin() noexcept
{
if (const auto player{ cheatManager.memory->localPlayer }; player) {
const auto& values{ cheatManager.database->champions_skins[fnv::hash_runtime(player->get_character_data_stack()->base_skin.model.str)] };
cheatManager.config->current_combo_skin_index--;
if (cheatManager.config->current_combo_skin_index > 0)
player->change_skin(values[cheatManager.config->current_combo_skin_index - 1].model_name.c_str(), values[cheatManager.config->current_combo_skin_index - 1].skin_id);
else
cheatManager.config->current_combo_skin_index = 1;
cheatManager.config->save();
}
}

static LRESULT WINAPI wndProc(HWND window, UINT msg, WPARAM wParam, LPARAM lParam) noexcept
{
if (::ImGui_ImplWin32_WndProcHandler(window, msg, wParam, lParam))
Expand All @@ -56,11 +30,48 @@ static LRESULT WINAPI wndProc(HWND window, UINT msg, WPARAM wParam, LPARAM lPara
cheatManager.config->save();
}

if (msg == WM_KEYDOWN && wParam == 0x35) {
const auto player{ cheatManager.memory->localPlayer };
if (const auto player{ cheatManager.memory->localPlayer }; (::GetAsyncKeyState(VK_LCONTROL) & 0x8000) && player) {
const auto playerHash{ fnv::hash_runtime(player->get_character_data_stack()->base_skin.model.str) };
if (const auto it{ std::find_if(cheatManager.database->specialSkins.begin(), cheatManager.database->specialSkins.end(),
[&skin = player->get_character_data_stack()->base_skin.skin, &ph = playerHash](const SkinDatabase::specialSkin& x) noexcept -> bool
{
return x.champHash == ph && (x.skinIdStart <= skin && x.skinIdEnd >= skin);
}) };
it != cheatManager.database->specialSkins.end())
{
const auto stack{ player->get_character_data_stack() };
if (stack->base_skin.gear < static_cast<std::int8_t>(it->gears.size()) - 1)
++stack->base_skin.gear;
else
stack->base_skin.gear = static_cast<std::int8_t>(0);

stack->update(true);
}
}
}

if (cheatManager.config->quickSkinChange) {
if (msg == WM_KEYDOWN && wParam == cheatManager.config->nextSkinKey.getKey())
nextSkin();
if (msg == WM_KEYDOWN && wParam == cheatManager.config->previousSkinKey.getKey())
previousSkin();
if (msg == WM_KEYDOWN && wParam == cheatManager.config->nextSkinKey.getKey()) {
if (const auto player{ cheatManager.memory->localPlayer }; player) {
const auto& values{ cheatManager.database->champions_skins[fnv::hash_runtime(player->get_character_data_stack()->base_skin.model.str)] };
if (++cheatManager.config->current_combo_skin_index > static_cast<std::int32_t>(values.size()))
cheatManager.config->current_combo_skin_index = static_cast<std::int32_t>(values.size());
if (cheatManager.config->current_combo_skin_index > 0)
player->change_skin(values[cheatManager.config->current_combo_skin_index - 1].model_name.c_str(), values[cheatManager.config->current_combo_skin_index - 1].skin_id);
cheatManager.config->save();
}
} else if (msg == WM_KEYDOWN && wParam == cheatManager.config->previousSkinKey.getKey()) {
if (const auto player{ cheatManager.memory->localPlayer }; player) {
const auto& values{ cheatManager.database->champions_skins[fnv::hash_runtime(player->get_character_data_stack()->base_skin.model.str)] };
if (--cheatManager.config->current_combo_skin_index > 0)
player->change_skin(values[cheatManager.config->current_combo_skin_index - 1].model_name.c_str(), values[cheatManager.config->current_combo_skin_index - 1].skin_id);
else
cheatManager.config->current_combo_skin_index = 1;
cheatManager.config->save();
}
}
}

return ::CallWindowProcW(originalWndProc, window, msg, wParam, lParam);
Expand Down

0 comments on commit 86d3802

Please sign in to comment.