Skip to content

Commit fa771e9

Browse files
committed
dodge on ban, backup pick, mass invite to lobby
1 parent 12c540b commit fa771e9

7 files changed

Lines changed: 184 additions & 38 deletions

File tree

KBotExt/GameTab.h

Lines changed: 126 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -225,14 +225,15 @@ class GameTab
225225

226226
ImGui::Separator();
227227

228-
// todo invite everyone from friendlist to lobby button
229-
230228
ImGui::Columns(3, 0, false);
231229
if (ImGui::Button("Start queue"))
232230
{
233231
result = http->Request("POST", "https://127.0.0.1/lol-lobby/v2/lobby/matchmaking/search", "", auth->leagueHeader, "", "", auth->leaguePort);
234232
}
235233
ImGui::NextColumn();
234+
235+
// if you press this during queue search you wont be able to start the queue again
236+
// unless you reenter the lobby :)
236237
if (ImGui::Button("Dodge"))
237238
{
238239
result = http->Request("POST", R"(https://127.0.0.1/lol-login/v1/session/invoke?destination=lcdsServiceProxy&method=call&args=["","teambuilder-draft","quitV2",""])", "", auth->leagueHeader, "", "", auth->leaguePort);
@@ -290,8 +291,35 @@ class GameTab
290291

291292
ImGui::Separator();
292293

294+
ImGui::Columns(3, 0, false);
293295
ImGui::Checkbox("Auto accept", &S.gameTab.autoAcceptEnabled);
294296

297+
ImGui::NextColumn();
298+
if (ImGui::Button("Invite everyone to lobby"))
299+
{
300+
std::string getFriends = http->Request("GET", "https://127.0.0.1/lol-chat/v1/friends", "", auth->leagueHeader, "", "", auth->leaguePort);
301+
302+
Json::CharReaderBuilder builder;
303+
const std::unique_ptr<Json::CharReader> reader(builder.newCharReader());
304+
JSONCPP_STRING err;
305+
Json::Value root;
306+
if (reader->parse(getFriends.c_str(), getFriends.c_str() + static_cast<int>(getFriends.length()), &root, &err))
307+
{
308+
if (root.isArray())
309+
{
310+
for (Json::Value::ArrayIndex i = 0; i < root.size(); ++i)
311+
{
312+
std::string friendSummId = root[i]["summonerId"].asString();
313+
std::string inviteBody = "[{\"toSummonerId\":" + friendSummId + "}]";
314+
http->Request("POST", "https://127.0.0.1/lol-lobby/v2/lobby/invitations", inviteBody,
315+
auth->leagueHeader, "", "", auth->leaguePort);
316+
}
317+
result = "Invited friends to lobby";
318+
}
319+
}
320+
}
321+
ImGui::Columns(1);
322+
295323
ImGui::Columns(2, 0, false);
296324

297325
ImGui::Text("Instant message: ");
@@ -315,13 +343,16 @@ class GameTab
315343
ImGui::SliderInt("Delay##sliderInstalockDelay", &S.gameTab.instalockDelay, 0, 10000, "%d ms");
316344

317345
ImGui::NextColumn();
318-
// todo
319-
bool test11;
320-
ImGui::Checkbox("Dodge on champion ban", &test11);
346+
347+
ImGui::Checkbox("Dodge on champion ban", &S.gameTab.dodgeOnBan);
348+
349+
ImGui::SameLine();
350+
Misc::HelpMarker("Ignores backup pick");
321351

322352
ImGui::Columns(1);
323353

324-
if (ImGui::CollapsingHeader("Instalock champ"))
354+
std::string chosenInstalock = "Instalock champ \t\tChosen: " + Misc::ChampIdToName(S.gameTab.instalockId) + "###AnimatedInstalock";
355+
if (ImGui::CollapsingHeader(chosenInstalock.c_str()))
325356
{
326357
std::vector<std::pair<int, std::string>>instalockChamps = GetInstalockChamps();
327358
for (auto champ : instalockChamps)
@@ -334,26 +365,25 @@ class GameTab
334365
}
335366
}
336367

337-
// todo
338-
if (ImGui::CollapsingHeader("Backup pick"))
368+
std::string chosenBackup = "Backup pick \t\t\tChosen: " + Misc::ChampIdToName(S.gameTab.backupId) + "###AnimatedBackup";
369+
if (ImGui::CollapsingHeader(chosenBackup.c_str()))
339370
{
340371
ImGui::Text("None");
341372
ImGui::SameLine();
342-
//ImGui::RadioButton("##noneBackupPick", &S.gameTab.backupId, 0);
373+
ImGui::RadioButton("##noneBackupPick", &S.gameTab.backupId, 0);
343374
std::vector<std::pair<int, std::string>>instalockChamps = GetInstalockChamps();
344375
for (auto champ : instalockChamps)
345376
{
346377
char bufchamp[128];
347378
sprintf_s(bufchamp, "##Select %s", champ.second.c_str());
348379
ImGui::Text("%s", champ.second.c_str());
349380
ImGui::SameLine();
350-
//ImGui::RadioButton(bufchamp, &S.gameTab.backupId, champ.first);
381+
ImGui::RadioButton(bufchamp, &S.gameTab.backupId, champ.first);
351382
}
352383
}
353384

354-
// todo: backup pick or dodge
355-
356-
if (ImGui::CollapsingHeader("Auto ban"))
385+
std::string chosenAutoban = "Auto ban\t\t\t\tChosen: " + Misc::ChampIdToName(S.gameTab.autoBanId) + "###AnimatedAutoban";
386+
if (ImGui::CollapsingHeader(chosenAutoban.c_str()))
357387
{
358388
if (champSkins.empty())
359389
{
@@ -470,13 +500,22 @@ class GameTab
470500
std::string getChat = http->Request("GET", "https://127.0.0.1/lol-chat/v1/conversations", "", auth->leagueHeader, "", "", auth->leaguePort);
471501
if (reader->parse(getChat.c_str(), getChat.c_str() + static_cast<int>(getChat.length()), &root, &err))
472502
{
473-
std::string lobbyID = root[0]["id"].asString();
474-
std::string request = "https://127.0.0.1/lol-chat/v1/conversations/" + lobbyID + "/messages";
475-
std::string error = "errorCode";
476-
while (error.find("errorCode") != std::string::npos)
503+
if (root.isArray())
477504
{
478-
error = http->Request("POST", request, R"({"type":"chat", "body":")" + std::string(S.gameTab.instantMessage) + R"("})", auth->leagueHeader, "", "", auth->leaguePort);
479-
std::this_thread::sleep_for(std::chrono::milliseconds(1));
505+
for (Json::Value::ArrayIndex i = 0; i < root.size(); i++)
506+
{
507+
if (root[i]["type"].asString() != "championSelect")
508+
continue;
509+
std::string lobbyID = root[i]["id"].asString();
510+
std::string request = "https://127.0.0.1/lol-chat/v1/conversations/" + lobbyID + "/messages";
511+
std::string error = "errorCode";
512+
while (error.find("errorCode") != std::string::npos)
513+
{
514+
error = http->Request("POST", request, R"({"type":"chat", "body":")" + std::string(S.gameTab.instantMessage) + R"("})", auth->leagueHeader, "", "", auth->leaguePort);
515+
std::this_thread::sleep_for(std::chrono::milliseconds(1));
516+
}
517+
break;
518+
}
480519
}
481520
}
482521
}
@@ -489,7 +528,7 @@ class GameTab
489528
{
490529
if (::FindWindowA("RCLIENT", "League of Legends"))
491530
{
492-
if (S.gameTab.autoAcceptEnabled || S.gameTab.autoBanId || (S.gameTab.instalockEnabled && S.gameTab.instalockId))
531+
if (S.gameTab.autoAcceptEnabled || S.gameTab.autoBanId || (S.gameTab.dodgeOnBan && S.gameTab.instalockEnabled) || (S.gameTab.instalockEnabled && S.gameTab.instalockId))
493532
{
494533
Json::Value rootSearch;
495534
Json::Value rootChampSelect;
@@ -502,6 +541,7 @@ class GameTab
502541
{
503542
static bool foundCell = false;
504543
static bool sendMessage = true;
544+
static int useBackupId = 0;
505545
std::string searchState = rootSearch["searchState"].asString();
506546
if (searchState == "Found")
507547
{
@@ -510,15 +550,43 @@ class GameTab
510550
{
511551
foundCell = false;
512552
sendMessage = true;
553+
useBackupId = 0;
513554
if (S.gameTab.autoAcceptEnabled)
514555
{
515556
http->Request("POST", "https://127.0.0.1/lol-matchmaking/v1/ready-check/accept", "", auth->leagueHeader, "", "", auth->leaguePort);
516557
}
558+
std::this_thread::sleep_for(std::chrono::milliseconds(100));
517559
}
518560
else
519561
{
520562
if (reader->parse(getChampSelect.c_str(), getChampSelect.c_str() + static_cast<int>(getChampSelect.length()), &rootChampSelect, &err))
521563
{
564+
//if (S.gameTab.dodgeOnBan && S.gameTab.instalockId && S.gameTab.instalockEnabled)
565+
//{
566+
// // empty on draft? look within actions
567+
// auto myTeamBans = rootChampSelect["bans"]["myTeamBans"];
568+
// if (myTeamBans.isArray())
569+
// {
570+
// for (Json::Value::ArrayIndex i = 0; i < myTeamBans.size(); i++)
571+
// {
572+
// if (myTeamBans[i].asInt() == S.gameTab.instalockId)
573+
// {
574+
// http->Request("POST", R"(https://127.0.0.1/lol-login/v1/session/invoke?destination=lcdsServiceProxy&method=call&args=["","teambuilder-draft","quitV2",""])", "", auth->leagueHeader, "", "", auth->leaguePort);
575+
// }
576+
// }
577+
// }
578+
// auto theirTeamBans = rootChampSelect["bans"]["theirTeamBans"];
579+
// if (theirTeamBans.isArray())
580+
// {
581+
// for (Json::Value::ArrayIndex i = 0; i < theirTeamBans.size(); i++)
582+
// {
583+
// if (theirTeamBans[i].asInt() == S.gameTab.instalockId)
584+
// {
585+
// http->Request("POST", R"(https://127.0.0.1/lol-login/v1/session/invoke?destination=lcdsServiceProxy&method=call&args=["","teambuilder-draft","quitV2",""])", "", auth->leagueHeader, "", "", auth->leaguePort);
586+
// }
587+
// }
588+
// }
589+
//}
522590
if (sendMessage && !S.gameTab.instantMessage.empty())
523591
{
524592
sendMessage = false;
@@ -564,21 +632,26 @@ class GameTab
564632
if (actions[i]["actorCellId"].asInt() == cellId)
565633
{
566634
std::string actionType = actions[i]["type"].asString();
567-
if (actionType == "pick" && S.gameTab.instalockId)
635+
if (actionType == "pick" && S.gameTab.instalockId && S.gameTab.instalockEnabled)
568636
{
569637
// if havent picked yet
570638
if (actions[i]["completed"].asBool() == false)
571639
{
572640
std::this_thread::sleep_for(std::chrono::milliseconds(S.gameTab.instalockDelay));
641+
642+
int currentPick = S.gameTab.instalockId;
643+
if (useBackupId)
644+
currentPick = useBackupId;
645+
573646
http->Request("PATCH", "https://127.0.0.1/lol-champ-select/v1/session/actions/" + actions[i]["id"].asString(),
574-
R"({"completed":true,"championId":)" + std::to_string(S.gameTab.instalockId) + "}", auth->leagueHeader, "", "", auth->leaguePort);
575-
}
576-
else
577-
{
578-
// we picked already, theres nothing to do so sleep
579-
std::this_thread::sleep_for(std::chrono::milliseconds(1000));
580-
break;
647+
R"({"completed":true,"championId":)" + std::to_string(currentPick) + "}", auth->leagueHeader, "", "", auth->leaguePort);
581648
}
649+
//else
650+
//{
651+
// // we picked already, theres nothing to do so sleep
652+
// std::this_thread::sleep_for(std::chrono::milliseconds(1000));
653+
// break;
654+
//}
582655
}
583656
else if (actionType == "ban" && S.gameTab.autoBanId)
584657
{
@@ -588,9 +661,26 @@ class GameTab
588661
R"({"completed":true,"championId":)" + std::to_string(S.gameTab.autoBanId) + "}", auth->leagueHeader, "", "", auth->leaguePort);
589662
}
590663
}
591-
else break;
664+
//else break;
665+
}
666+
// if dodge on ban enabled or backup pick
667+
if ((S.gameTab.dodgeOnBan || S.gameTab.backupId) && S.gameTab.instalockEnabled && S.gameTab.instalockId)
668+
{
669+
if (actions[i]["type"].asString() == "ban" && actions[i]["completed"].asBool() == true)
670+
{
671+
if (actions[i]["championId"].asInt() == S.gameTab.instalockId)
672+
{
673+
if (S.gameTab.dodgeOnBan)
674+
{
675+
http->Request("POST", R"(https://127.0.0.1/lol-login/v1/session/invoke?destination=lcdsServiceProxy&method=call&args=["","teambuilder-draft","quitV2",""])", "", auth->leagueHeader, "", "", auth->leaguePort);
676+
}
677+
else if (S.gameTab.backupId)
678+
{
679+
useBackupId = S.gameTab.backupId;
680+
}
681+
}
682+
}
592683
}
593-
else continue;
594684
}
595685
}
596686
}
@@ -607,12 +697,18 @@ class GameTab
607697
else
608698
{
609699
foundCell = false;
700+
sendMessage = true;
701+
useBackupId = 0;
610702
std::this_thread::sleep_for(std::chrono::milliseconds(1000));
611703
}
612704
}
613705
}
614706
}
615707
}
708+
else
709+
{
710+
std::this_thread::sleep_for(std::chrono::milliseconds(1000));
711+
}
616712

617713
std::this_thread::sleep_for(std::chrono::milliseconds(1));
618714
}

KBotExt/InfoTab.h

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,25 @@ class InfoTab
5252
result = http->Request("GET", "https://127.0.0.1/lol-summoner/v1/summoners/" + std::string(playerName), "", auth->leagueHeader, "", "", auth->leaguePort);
5353
bPressed = true;
5454
}
55+
ImGui::SameLine();
56+
if (ImGui::Button("Me##playerName"))
57+
{
58+
Json::CharReaderBuilder builder;
59+
const std::unique_ptr<Json::CharReader> reader(builder.newCharReader());
60+
JSONCPP_STRING err;
61+
Json::Value root;
62+
63+
std::string mySummId;
64+
65+
std::string getSession = http->Request("GET", "https://127.0.0.1/lol-login/v1/session", "", auth->leagueHeader, "", "", auth->leaguePort);
66+
if (reader->parse(getSession.c_str(), getSession.c_str() + static_cast<int>(getSession.length()), &root, &err))
67+
{
68+
mySummId = root["summonerId"].asString();
69+
}
70+
71+
result = http->Request("GET", "https://127.0.0.1/lol-summoner/v1/summoners/" + mySummId, "", auth->leagueHeader, "", "", auth->leaguePort);
72+
bPressed = true;
73+
}
5574

5675
static Json::StreamWriterBuilder wBuilder;
5776
static std::string sResultJson;

KBotExt/KBotExt.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine
2525
{
2626
LPWSTR* szArgList;
2727
int argCount;
28-
szArgList = CommandLineToArgvW(GetCommandLine(), &argCount);
28+
szArgList = CommandLineToArgvW(GetCommandLineW(), &argCount);
2929
if (argCount > 1)
3030
{
3131
std::string applicationName = utils->WstringToString(szArgList[1]);

KBotExt/Misc.h

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,26 @@ class Misc
9999
Misc::TerminateProcessByName("LeagueClientUxRender.exe");
100100
}
101101

102+
static std::string ChampIdToName(int id)
103+
{
104+
if (!id)
105+
{
106+
return "None";
107+
}
108+
else if (champSkins.empty())
109+
{
110+
return "No data";// "Champion data still downloading";
111+
}
112+
{
113+
for (auto c : champSkins)
114+
{
115+
if (c.key == id)
116+
return c.name;
117+
}
118+
}
119+
return "";
120+
}
121+
102122
static std::string ClearLogs()
103123
{
104124
std::string result = "";
@@ -198,7 +218,7 @@ class Misc
198218
ShellExecuteA(NULL, "open", URL_, NULL, NULL, SW_SHOWNORMAL);
199219
}
200220
AddUnderLine(ImGui::GetStyle().Colors[ImGuiCol_ButtonHovered]);
201-
ImGui::SetTooltip(ICON_FA_LINK " Open in browser\n%s", URL_);
221+
ImGui::SetTooltip(/*ICON_FA_LINK*/ " Open in browser\n%s", URL_);
202222
}
203223
else
204224
{

KBotExt/MiscTab.h

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -334,7 +334,7 @@ class MiscTab
334334

335335
ImGui::SameLine();
336336

337-
ImGui::SetNextItemWidth(S.Window.width / 3);
337+
ImGui::SetNextItemWidth(static_cast<float>(S.Window.width / 3));
338338
if (ImGui::BeginCombo("##comboDisenchant", comboDisenchant, 0))
339339
{
340340
for (size_t n = 0; n < itemsDisenchant.size(); n++)
@@ -362,10 +362,15 @@ class MiscTab
362362
static size_t lastSize = 0;
363363
static std::string closestChampion;
364364
static std::string closestId;
365-
ImGui::SetNextItemWidth(S.Window.width / 3);
365+
ImGui::SetNextItemWidth(static_cast<float>(S.Window.width / 3));
366366
ImGui::InputText("##inputChampionName", bufChampionName, IM_ARRAYSIZE(bufChampionName));
367-
368-
if (lastSize != strlen(bufChampionName))
367+
if (strlen(bufChampionName) < 1)
368+
{
369+
closestChampion = "";
370+
closestId = "";
371+
lastSize = 0;
372+
}
373+
else if (lastSize != strlen(bufChampionName))
369374
{
370375
lastSize = strlen(bufChampionName);
371376
closestChampion = LevenshteinDistance(champNames, bufChampionName);

0 commit comments

Comments
 (0)