@@ -506,13 +506,17 @@ class GameTab
506506 }
507507 }
508508
509- ImGui::Columns (2 , 0 , false );
509+ ImGui::Columns (3 , 0 , false );
510510
511511 ImGui::Checkbox (" Auto ban" , &S.gameTab .autoBanEnabled );
512512 ImGui::NextColumn ();
513513
514514 ImGui::SliderInt (" Delay##sliderautoBanDelay" , &S.gameTab .autoBanDelay , 0 , 10000 , " %d ms" );
515515
516+ ImGui::NextColumn ();
517+
518+ ImGui::Checkbox (" Instant Mute" , &S.gameTab .instantMute );
519+
516520 ImGui::Columns (1 );
517521
518522 static std::string chosenAutoban = " Auto ban\t\t\t\t Chosen: " + Misc::ChampIdToName (S.gameTab .autoBanId ) + " ###AnimatedAutoban" ;
@@ -630,7 +634,7 @@ class GameTab
630634 return temp;
631635 }
632636
633- static void InstantMessage ()
637+ static void InstantMessage (const bool instantMute = false )
634638 {
635639 auto start = std::chrono::system_clock::now ();
636640 while (true )
@@ -666,7 +670,42 @@ class GameTab
666670 continue ;
667671 }
668672
669- const std::string request = " https://127.0.0.1/lol-chat/v1/conversations/" + participantsArr[0 ][" cid" ].asString () + " /messages" ;
673+ const std::string cid = participantsArr[0 ][" cid" ].asString ();
674+
675+ if (instantMute)
676+ {
677+ std::string champSelect = LCU::Request (" GET" , " /lol-champ-select/v1/session" );
678+ Json::Value rootCSelect;
679+ if (!champSelect.empty () && champSelect.find (" RPC_ERROR" ) == std::string::npos)
680+ {
681+ if (reader->parse (champSelect.c_str (), champSelect.c_str () + static_cast <int >(champSelect.length ()), &rootCSelect, &err))
682+ {
683+ int localPlayerCellId = rootCSelect[" localPlayerCellId" ].asInt ();
684+ for (Json::Value::ArrayIndex i = 0 ; i < rootCSelect[" myTeam" ].size (); i++)
685+ {
686+ Json::Value player = rootCSelect[" myTeam" ][i];
687+ if (player[" cellId" ].asInt () == localPlayerCellId)
688+ continue ;
689+
690+ LCU::Request (" POST" , " /lol-champ-select/v1/toggle-player-muted" ,
691+ std::format (" {{\" summonerId\" :{0},\" puuid\" :\" {1}\" ,\" obfuscatedSummonerId\" :{2},\" obfuscatedPuuid\" :\" {3}\" }}" ,
692+ player[" summonerId" ].asString (), player[" puuid" ].asString (), player[" obfuscatedSummonerId" ].asString (),
693+ player[" obfuscatedPuuid" ].asString ()));
694+
695+ /* LCU::Request("POST", "/telemetry/v1/events/general_metrics_number",
696+ R"({"eventName":"champ_select_toggle_player_muted_clicked","value":"0","spec":"high","isLowSpecModeOn":"false"})");
697+
698+ LCU::Request("POST", std::format("/lol-chat/v1/conversations/{}/messages", cid),
699+ std::format("{{\"body\":\"{} is muted.\",\"type\":\"celebration\"}}", "player"));*/
700+ }
701+ }
702+ }
703+
704+ if (S.gameTab .instantMessage .empty ())
705+ return ;
706+ }
707+
708+ const std::string request = " https://127.0.0.1/lol-chat/v1/conversations/" + cid + " /messages" ;
670709 const std::string body = R"( {"type":"chat", "body":")" + std::string (S.gameTab .instantMessage ) + R"( "})" ;
671710
672711 std::this_thread::sleep_for (std::chrono::milliseconds (S.gameTab .instantMessageDelay ));
@@ -735,14 +774,12 @@ class GameTab
735774 continue ;
736775 }
737776
738- static bool foundCell = false ;
739777 static bool sendMessage = true ;
740778 static int useBackupId = 0 ;
741779 static bool isPicked = false ;
742780
743781 if (rootSearch[" searchState" ].asString () != " Found" ) // not found, not in champ select
744782 {
745- foundCell = false ;
746783 sendMessage = true ;
747784 useBackupId = 0 ;
748785 isPicked = false ;
@@ -753,7 +790,6 @@ class GameTab
753790 std::string getChampSelect = LCU::Request (" GET" , " https://127.0.0.1/lol-champ-select/v1/session" );
754791 if (getChampSelect.find (" RPC_ERROR" ) != std::string::npos) // game found but champ select error means queue pop
755792 {
756- foundCell = false ;
757793 sendMessage = true ;
758794 useBackupId = 0 ;
759795 isPicked = false ;
@@ -771,10 +807,11 @@ class GameTab
771807 continue ;
772808 }
773809
774- if (sendMessage && !S.gameTab .instantMessage .empty ())
810+ if (sendMessage &&
811+ (!S.gameTab .instantMessage .empty () || S.gameTab .instantMute ))
775812 {
776813 sendMessage = false ;
777- std::thread instantMessageThread (&GameTab::InstantMessage);
814+ std::thread instantMessageThread (&GameTab::InstantMessage, S. gameTab . instantMute );
778815 instantMessageThread.detach ();
779816 }
780817
@@ -787,104 +824,83 @@ class GameTab
787824 continue ;
788825 }
789826
790- static int cellId = 0 ;
791- if (!foundCell )
827+ const int cellId = rootChampSelect[ " localPlayerCellId " ]. asInt () ;
828+ for (Json::Value::ArrayIndex j = 0 ; j < rootChampSelect[ " actions " ]. size (); j++ )
792829 {
793- auto myTeam = rootChampSelect[" myTeam" ];
794- std::string summId = rootSession[" summonerId" ].asString ();
795- if (myTeam.isArray ())
830+ auto actions = rootChampSelect[" actions" ][j];
831+ if (!actions.isArray ())
796832 {
797- // get own cellId
798- for (Json::Value::ArrayIndex i = 0 ; i < myTeam.size (); i++)
799- {
800- if (myTeam[i][" summonerId" ].asString () == summId)
801- {
802- cellId = myTeam[i][" cellId" ].asInt ();
803- foundCell = true ;
804- break ;
805- }
806- }
833+ continue ;
807834 }
808- }
809- else
810- {
811- for (Json::Value::ArrayIndex j = 0 ; j < rootChampSelect[" actions" ].size (); j++)
835+ for (Json::Value::ArrayIndex i = 0 ; i < actions.size (); i++)
812836 {
813- auto actions = rootChampSelect[" actions" ][j];
814- if (!actions.isArray ())
815- {
816- continue ;
817- }
818- for (Json::Value::ArrayIndex i = 0 ; i < actions.size (); i++)
837+ // search for own actions
838+ if (actions[i][" actorCellId" ].asInt () == cellId)
819839 {
820- // search for own actions
821- if (actions[i][ " actorCellId " ]. asInt () == cellId )
840+ std::string actionType = actions[i][ " type " ]. asString ();
841+ if (actionType == " pick " && S. gameTab . instalockId && S. gameTab . instalockEnabled )
822842 {
823- std::string actionType = actions[i][ " type " ]. asString ();
824- if (actionType == " pick " && S. gameTab . instalockId && S. gameTab . instalockEnabled )
843+ // if havent picked yet
844+ if (actions[i][ " completed " ]. asBool () == false )
825845 {
826- // if havent picked yet
827- if (actions[i][" completed" ].asBool () == false )
846+ if (!isPicked)
828847 {
829- if (!isPicked)
830- {
831- std::this_thread::sleep_for (std::chrono::milliseconds (S.gameTab .instalockDelay ));
848+ std::this_thread::sleep_for (std::chrono::milliseconds (S.gameTab .instalockDelay ));
832849
833- int currentPick = S.gameTab .instalockId ;
834- if (useBackupId)
835- currentPick = useBackupId;
850+ int currentPick = S.gameTab .instalockId ;
851+ if (useBackupId)
852+ currentPick = useBackupId;
836853
837- LCU::Request (" PATCH" , " https://127.0.0.1/lol-champ-select/v1/session/actions/" + actions[i][" id" ].asString (),
838- R"( {"completed":true,"championId":)" + std::to_string (currentPick) + " }" );
839- }
840- }
841- else
842- {
843- isPicked = true ;
854+ LCU::Request (" PATCH" , " https://127.0.0.1/lol-champ-select/v1/session/actions/" + actions[i][" id" ].asString (),
855+ R"( {"completed":true,"championId":)" + std::to_string (currentPick) + " }" );
844856 }
845857 }
846- else if (actionType == " ban " && S. gameTab . autoBanId && S. gameTab . autoBanEnabled )
858+ else
847859 {
848- if (actions[i][" completed" ].asBool () == false )
849- {
850- std::this_thread::sleep_for (std::chrono::milliseconds (S.gameTab .autoBanDelay ));
851-
852- LCU::Request (" PATCH" , " https://127.0.0.1/lol-champ-select/v1/session/actions/" + actions[i][" id" ].asString (),
853- R"( {"completed":true,"championId":)" + std::to_string (S.gameTab .autoBanId ) + " }" );
854- }
860+ isPicked = true ;
855861 }
856862 }
857- // action that isn't our player, if dodge on ban enabled or backup pick
858- else if ((S.gameTab .dodgeOnBan || S.gameTab .backupId ) && S.gameTab .instalockEnabled && S.gameTab .instalockId )
863+ else if (actionType == " ban" && S.gameTab .autoBanId && S.gameTab .autoBanEnabled )
859864 {
860- if (isPicked)
861- break ;
865+ if (actions[i][" completed" ].asBool () == false )
866+ {
867+ std::this_thread::sleep_for (std::chrono::milliseconds (S.gameTab .autoBanDelay ));
868+
869+ LCU::Request (" PATCH" , " https://127.0.0.1/lol-champ-select/v1/session/actions/" + actions[i][" id" ].asString (),
870+ R"( {"completed":true,"championId":)" + std::to_string (S.gameTab .autoBanId ) + " }" );
871+ }
872+ }
873+ }
874+ // action that isn't our player, if dodge on ban enabled or backup pick
875+ else if ((S.gameTab .dodgeOnBan || S.gameTab .backupId ) && S.gameTab .instalockEnabled && S.gameTab .instalockId )
876+ {
877+ if (isPicked)
878+ break ;
862879
863- if (actions[i][" actorCellId" ].asInt () == cellId)
864- continue ;
880+ if (actions[i][" actorCellId" ].asInt () == cellId)
881+ continue ;
865882
866- if (actions[i][" type" ].asString () == " ban" && actions[i][" completed" ].asBool () == true )
883+ if (actions[i][" type" ].asString () == " ban" && actions[i][" completed" ].asBool () == true )
884+ {
885+ if (actions[i][" championId" ].asInt () == S.gameTab .instalockId )
867886 {
868- if (actions[i][ " championId " ]. asInt () == S.gameTab .instalockId )
887+ if (S.gameTab .dodgeOnBan )
869888 {
870- if (S.gameTab .dodgeOnBan )
871- {
872- LCU::Request (" POST" , R"( https://127.0.0.1/lol-login/v1/session/invoke?destination=lcdsServiceProxy&method=call&args=["","teambuilder-draft","quitV2",""])" , " " );
873- }
874- else if (S.gameTab .backupId )
875- {
876- useBackupId = S.gameTab .backupId ;
877- }
889+ LCU::Request (" POST" , R"( https://127.0.0.1/lol-login/v1/session/invoke?destination=lcdsServiceProxy&method=call&args=["","teambuilder-draft","quitV2",""])" , " " );
878890 }
879- }
880- else if (actions[i][" type" ].asString () == " pick" && actions[i][" completed" ].asBool () == true )
881- {
882- if (S.gameTab .backupId && actions[i][" championId" ].asInt () == S.gameTab .instalockId )
891+ else if (S.gameTab .backupId )
883892 {
884893 useBackupId = S.gameTab .backupId ;
885894 }
886895 }
887896 }
897+ else if (actions[i][" type" ].asString () == " pick" && actions[i][" completed" ].asBool () == true )
898+ {
899+ if (S.gameTab .backupId && actions[i][" championId" ].asInt () == S.gameTab .instalockId )
900+ {
901+ useBackupId = S.gameTab .backupId ;
902+ }
903+ }
888904 }
889905 }
890906 }
0 commit comments