Вы находитесь на странице: 1из 12

#!

perl
#League of Legends Auto Accept/Queue/Pick Script [ Normal Draft - Solo/Duo - Flex -
ARAM ]

# run this script while the client is open, to search for a ranked/draft game

use strict;
use warnings;
use MIME::Base64;
use LWP::UserAgent;
use JSON::Parse 'parse_json';
use Time::HiRes qw(sleep);
use POSIX qw(strftime);

my %config = (

# chose your primary and secondary role.


# valid options are TOP JUNGLE MIDDLE BOTTOM UTILITY
# UTILITY is for support role.
# DONT use anything else or it wont work.

PREFER_ROLE1=> uc('UTILITY'),
PREFER_ROLE2=> uc('JUNGLE'),

# 400 = NORMAL DRAFT


# 420 = RANKED SOLO/DUO
# 430 = BLIND PICK
# 440 = RANKED FLEX
# 450 = ARAM

# 400 is predefined but you can set the mode as an argument when launching
the script
# i.e. :: perl script.pl 420 :: for ranked solo/duo

QUEUE => shift || 400,

#top1 = first choice for top, top2 is the second choice if top1 is banned or
picked already
#top3 same idea as top2. rest is self explanatory

# Available spells: cleanse, exhaust, flash, ghost, heal, smite


# teleport, clarity, ignite, barrier, mark

# make sure you write the rune page EXACTLY as it is in your client

top1 => [ ucfirst(''), '', '', '' ],


top2 => [ ucfirst(''), '', '', '' ],
top3 => [ ucfirst(''), '', '', '' ],
top4 => [ ucfirst(''), '', '', '' ],
top5 => [ ucfirst(''), '', '', '' ],

# Champion Spell1 Spell2


Rune Page
jungle1 => [ ucfirst('Teemo'), 'smite', 'ignite', 'Rune page1'
],
jungle2 => [ ucfirst('Shaco'), 'smite', 'ignite', 'Rune page2'
],
jungle3 => [ ucfirst('Rengar'), 'smite', 'ignite', 'Rune page3'
],
jungle4 => [ ucfirst('Singed'), 'smite', 'ignite', 'Rune page4'
],
jungle5 => [ ucfirst('Zac'), 'smite', 'ignite', 'Rune page5'
],

mid1 => [ ucfirst(''), '', '', '' ],


mid2 => [ ucfirst(''), '', '', '' ],
mid3 => [ ucfirst(''), '', '', '' ],
mid4 => [ ucfirst(''), '', '', '' ],
mid5 => [ ucfirst(''), '', '', '' ],

bottom1 => [ ucfirst(''), '', '', '' ],


bottom2 => [ ucfirst(''), '', '', '' ],
bottom3 => [ ucfirst(''), '', '', '' ],
bottom4 => [ ucfirst(''), '', '', '' ],
bottom5 => [ ucfirst(''), '', '', '' ],

utility1 => [ ucfirst('Yuumi'), 'exhaust', 'ignite', 'Rune page6' ],


utility2 => [ ucfirst('Teemo'), 'flash', 'ignite', 'Rune page1' ],
utility3 => [ ucfirst('Lux'), 'flash', 'ignite', 'Rune page6' ],
utility4 => [ ucfirst('Rengar'), 'flash', 'ignite', 'Rune page3' ],
utility5 => [ ucfirst('Janna'), 'flash', 'ignite', 'Rune page6' ],

# preference for champion banning in draft

BANCHAMP1 => ucfirst('Thresh'),


BANCHAMP2 => ucfirst('Yone'),
BANCHAMP3 => ucfirst('Leona'),

# for blind pick Champion Spell1 Spell2 Rune


Page
INSTALOCK => [ ucfirst('Yuumi'), 'exhaust', 'ignite', lc('Rune page6')],

# ARAM spells

ARAM_SPELL1 => lc('flash'),


ARAM_SPELL2 => lc('barrier'),

#cfg stuff, nothing to edit here

AUTOSEARCH => 1,
AUTOCHAMP => 1,

#--------------------------------------------------------------------#
#--------------------------------------------------------------------#
#------- DON'T EDIT BELOW UNLESS YOU KNOW WHAT YOU ARE DOING ------- #
#--------------------------------------------------------------------#
#--------------------------------------------------------------------#

MODES => {
400 => 'Normal Draft',
420 => 'Ranked Solo/Duo',
430 => 'Blind Pick',
440 => 'Ranked Flex',
450 => 'ARAM',
},

red => "\e[1;31m",


green => "\e[1;92m",
yellow => "\e[1;33m",
blue => "\e[1;34m",
pink => "\e[1;35m",
cyan => "\e[1;36m",
white => "\e[1;39m",
reset => "\e[1;0m",

);

my %list = (
'Aatrox' => 266, 'Ahri' => 103, 'Akali' => 84,
'Alistar' => 12,
'Amumu' => 32, 'Anivia' => 34, 'Annie' => 1,
'Aphelios' => 523,
'Ashe' => 22, 'AurelionSol' => 136, 'Azir' => 268,
'Bard' => 432,
'Blitzcrank' => 53, 'Brand' => 63, 'Braum' => 201,
'Caitlyn' => 51,
'Camille' => 164, 'Cassiopeia' => 69, 'Chogath' => 31,
'Corki' => 42,
'Darius' => 122, 'Diana' => 131, 'DrMundo' => 36,
'Draven' => 119,
'Ekko' => 245, 'Elise' => 60, 'Evelynn' => 28,
'Ezreal' => 81,
'Fiddlesticks' => 9, 'Fiora' => 114, 'Fizz' => 105,
'Galio' => 3,
'Gangplank' => 41, 'Garen' => 86, 'Gnar' => 150,
'Gragas' => 79,
'Graves' => 104, 'Hecarim' => 120, 'Heimerdinger' => 74,
'Illaoi' => 420,
'Irelia' => 39, 'Ivern' => 427, 'Janna' => 40,
'JarvanIV' => 59,
'Jax' => 24, 'Jayce' => 126, 'Jhin' => 202,
'Jinx' => 222,
'Kaisa' => 145, 'Kalista' => 429, 'Karma' => 43,
'Karthus' => 30,
'Kassadin' => 38, 'Katarina' => 55, 'Kayle' => 10,
'Kayn' => 141,
'Kennen' => 85, 'Khazix' => 121, 'Kindred' => 203,
'Kled' => 240,
'KogMaw' => 96, 'Leblanc' => 7, 'LeeSin' => 64,
'Leona' => 89,
'Lillia' => 876, 'Lissandra' => 127, 'Lucian' => 236,
'Lulu' => 117,
'Lux' => 99, 'Malphite' => 54, 'Malzahar' => 90,
'Maokai' => 57,
'MasterYi' => 11, 'MissFortune' => 21, 'MonkeyKing' => 62,
'Mordekaiser' => 82,
'Morgana' => 25, 'Nami' => 267, 'Nasus' => 75,
'Nautilus' => 111,
'Neeko' => 518, 'Nidalee' => 76, 'Nocturne' => 56,
'Nunu' => 20,
'Olaf' => 2, 'Orianna' => 61, 'Ornn' => 516,
'Pantheon' => 80,
'Poppy' => 78, 'Pyke' => 555, 'Qiyana' => 246,
'Quinn' => 133,
'Rakan' => 497, 'Rammus' => 33, 'RekSai' => 421,
'Renekton' => 58,
'Rengar' => 107, 'Riven' => 92, 'Rumble' => 68,
'Ryze' => 13,
'Sejuani' => 113, 'Senna' => 235, 'Sett' => 875,
'Shaco' => 35,
'Shen' => 98, 'Shyvana' => 102, 'Singed' => 27,
'Sion' => 14,
'Sivir' => 15, 'Skarner' => 72, 'Sona' => 37,
'Soraka' => 16,
'Swain' => 50, 'Sylas' => 517, 'Syndra' => 134,
'TahmKench' => 223,
'Taliyah' => 163, 'Talon' => 91, 'Taric' => 44,
'Teemo' => 17,
'Thresh' => 412, 'Tristana' => 18, 'Trundle' => 48,
'Tryndamere' => 23,
'TwistedFate' => 4, 'Twitch' => 29, 'Udyr' => 77,
'Urgot' => 6,
'Varus' => 110, 'Vayne' => 67, 'Veigar' => 45,
'Velkoz' => 161,
'Vi' => 254, 'Viktor' => 112, 'Vladimir' => 8,
'Volibear' => 106,
'Warwick' => 19, 'Xayah' => 498, 'Xerath' => 101,
'XinZhao' => 5,
'Yasuo' => 157, 'Yone' => 777, 'Yorick' => 83,
'Yuumi' => 350,
'Zac' => 154, 'Zed' => 238, 'Ziggs' => 115,
'Zilean' => 26,
'Zoe' => 142, 'Zyra' => 143,
);

my %spells = (
cleanse => 1,
exhaust => 3,
flash => 4,
ghost => 6,
heal => 7,
smite => 11,
teleport => 12,
clarity => 13,
ignite => 14,
barrier => 21,
mark => 32, #snowball
);

my %runes = perks();

my @co = (zamanf('GET','lol-gameflow/v1/gameflow-phase'));

my ($picked,$banned,$state);

system('cls');
system('title discord: zamanf#8802');

my $summoner = ${zamanf('GET','lol-summoner/v1/current-summoner')}{summonerId};

print<<INFO;
# discord: zamanf#8802
# run this script while the client is open, to search for a game

$config{cyan}Available Game Modes


$config{red}400$config{white} =>$config{pink} Normal Draft
$config{red}420$config{white} =>$config{pink} Ranked Solo/Duo
$config{red}430$config{white} =>$config{pink} Blind Pick $config{white}
($config{pink}INSTALOCK settings$config{white})
$config{red}440$config{white} =>$config{pink} Ranked Flex
$config{red}450$config{white} =>$config{pink} ARAM $config{white}
($config{pink}Runes automatically set from blitz.gg$config{white})

$config{blue}example$config{pink} perl $0 400

or you can change this $config{blue}QUEUE => shift || $config{red}450,


$config{pink}to your desired mode and just run it or double click the script
$config{reset}
INFO

cfg_check();

while (!$picked) {

state();

if ($state eq 'Lobby') {
if ($config{AUTOSEARCH} == 1) {
search()
}

} elsif ($state eq 'None') {


if ($config{AUTOSEARCH} == 1) {
queue();
}
} elsif ($state eq 'Matchmaking') {
$config{AUTOACCEPT} = 1

} elsif ($state eq 'ReadyCheck') {

if ($config{AUTOACCEPT} == 1) {
acthuman(2);
acceptq();
info("$config{cyan}Match Accepted");
$config{AUTOACCEPT} = 0;
}

} elsif ($state eq 'ChampSelect') {

if ($config{AUTOCHAMP} == 1) {
if ($config{QUEUE} !~ /(?:430|450)/) {
pow(\session()->%*);
}

if ($config{QUEUE} == 430) {
my %hash = session()->%*;

foreach my $x (@{$hash{myTeam}}) {
foreach my $c (keys $x->%*) {
if ($x->{summonerId} eq $summoner) {
if (!$picked) {
blindpick($x->{cellId},
$list{$config{INSTALOCK}->[0]});
spellset($spells{$config{INSTALOCK}->[1]},$spells{$config{INSTALOCK}->[2]});

runeset($runes{ lc( $config{INSTALOCK}->[3] ) });


}
last
}
}
}
}

if ($config{QUEUE} == 450) {
blitzrunes(\session()->%*,'aram');
spellset($spells{$config{ARAM_SPELL1}},
$spells{$config{ARAM_SPELL2}});
exit(0)
}
}

sleep 0.05
}

sub blitzrunes {
my (%hash,@runeids,%runes);
my %session = ($_[0]//{})->%*;

my ($que,$cid,$role) = @_[1,2,3];

$role = $role ? "&role=$role" : " ";

if (!$cid) {
foreach my $x (@{$session{myTeam}}) {
foreach my $c (keys $x->%*) {
if ($x->{summonerId} eq $summoner) {
$cid = (grep { $list{$_} eq $x->{championId} } keys
%list)[0];
last
}
}
}
}

my %set = (
precision => 8000,
domination => 8100,
sorcery => 8200,
inspiration => 8300,
resolve => 8400,
);

my $url = "https://blitz.gg/lol/champions/$cid?queue=$que".$role;
my $ua = LWP::UserAgent->new();
$ua->agent('Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36
(KHTML, like Gecko) Chrome/85.0.4183.83 Safari/537.36');
my $data = $ua->get($url)->content();

while ($data =~ /<img class="ChampionRuneSmall__Styled(?:Rune|


Shard)Img(.*?)>/gsi) {
my $catch = $1;
if ($catch !~ /dOvhFS/gsi) {
if ($catch =~
/https:\/\/blitz-cdn.blitz.gg\/runes\/(.*?)\/active\/(\d+).png/) {
my ($cat,$rid) = ($1,$2);
push@runeids, $2;
if ($cat =~ /(precision|domination|sorcery|inspiration|
resolve)/) {
$hash{$cat} += 1;
}
}
}
}

makespace();

sub makespace {
my @rr;

my @perks = zamanf('GET','lol-perks/v1/pages')->@*;
foreach my $x (0..$#perks) {
if ($perks[$x]{isEditable} == 1) {
push@rr,$perks[$x]{id};
}
}

if ($rr[-1]) {
zamanf('DELETE',"lol-perks/v1/pages/$rr[-1]")
}
}

my @order = (reverse sort { $hash{$a} <=> $hash{$b} } keys %hash);


my ($pid,$sid,$listofid) = ( $set{$order[0]}, $set{$order[1]}, (join
',',@runeids) );

zamanf('POST','lol-perks/v1/pages',
'{"isActive": true,"name": "z: '.$cid.'","primaryStyleId": '.
$pid.
',"selectedPerkIds": ['.$listofid.'],"subStyleId": '.
$sid.'}');
}

sub session {
return \%{ zamanf('GET','lol-lobby-team-builder/champ-select/v1/session') }
}

sub runeset {
info("$config{blue}Rune page $config{white}:: $config{pink}$_[0]");
zamanf('PUT','lol-perks/v1/currentpage',$_[0]);
}

sub spellset {
info("$config{blue}Setting spells $config{pink}$_[0] $config{white}::
$config{pink} $_[1]");
zamanf('PATCH','lol-champ-select/v1/session/my-selection',
'{"spell1Id": '.shift.',"spell2Id": '.shift.',"wardSkinId": 0}');
}
sub pow {

my %zazzzzz = shift->%*;
my @actions = $zazzzzz{actions}->@*;

my $position;
my ($self,$type,$phase) = ($zazzzzz{localPlayerCellId},
$actions[-1][0]{type},$zazzzzz{timer}
{phase});

foreach my $i (0..$zazzzzz{myTeam}->$#*) {
if ($zazzzzz{myTeam}[$i]{cellId} == $self) {
$position = $zazzzzz{myTeam}[$i]{assignedPosition}
}
}

foreach my $x (0..$#actions) {
my @zamanf = $actions[$x]->@*;
foreach my $c (0..$#zamanf) {
if (!$zamanf[$c]{completed}) {
if ($zamanf[$c]{isInProgress} && $phase ne 'PLANNING') {
if ($zamanf[$c]{actorCellId} == $self) {
if ($zamanf[$c]{type} eq 'pick') {

if ($position =~ /(top|jungle|middle|
bottom|utility)/) {
foreach my $x (split /\s+/,"${1}1
${1}2 ${1}3 ${1}4 ${1}5") {
if (!$picked) {

info("$config{blue}Picking$config{white} ->$config{pink} $config{$x}->[0]");


acthuman(2);
zazoom('pick',
$list{$config{$x}->[0]},$zamanf[$c]{id},$self,
$zamanf[$c]
{id},$config{$x}->[0],$config{$x}->[1],$config{$x}->[2],$x)
}
}
}

} elsif ($zamanf[$c]{type} eq 'ban') {


foreach my $x (qw(BANCHAMP1 BANCHAMP2
BANCHAMP3)) {
if (!$banned) {

info("$config{red}Banning$config{white} ->$config{green} $config{$x}");


acthuman(6);
zazoom('ban',
$list{$config{$x}},$zamanf[$c]{id},$self,$self,$config{$x})
}
}
}
}
}
}
}
}
}

sub acthuman {
my $tt = shift || int(rand(6))+2;
info("$config{white}Humanized$config{blue}->$config{red} ${tt}");
sleep $tt;
}

sub blindpick {
info("$config{pink}Instalocking champion $config{cyan}".$config{INSTALOCK}-
>[0]);

zamanf('PATCH',
"lol-lobby-team-builder/champ-select/v1/session/actions/$_[0]",
'{"actorCellId": 0,"championId": '.$_[1].',"completed": true,'.
'"id": 0,"isAllyAction": true,"isInProgress": true,"type": "string"}'
);

$picked = 1;
}

sub zazoom {
my ($type,$champ,$id,$cid,$act) = @_;

my $ret = zamanf('PATCH',
"lol-lobby-team-builder/champ-select/v1/session/actions/$act",
'{"actorCellId": '.$cid.
',"championId": '.$champ.
',"completed": true,"id": '.$id.
',"isAllyAction": true,"isInProgress": true,"type": "string"}'
);

if (!$ret) {
if ($type eq 'ban') {
$banned = 1;
info("$config{red}Banned$config{white} ->$config{pink} $_[-1]");
} else {
info("$config{green}Picked$config{white} ->$config{pink} $_[-
4]");
spellset($spells{$_[-3]},$spells{$_[-2]});
runeset($runes{lc($config{$_[-1]}->[3])});
$picked = 1;
}
} else {
info("$config{red}Failed to $config{cyan}$type$config{red} trying next
champ");
}
}

sub acceptq {
zamanf('POST','lol-matchmaking/v1/ready-check/accept')
}

sub search {
my $ret = zamanf('POST','lol-lobby/v2/lobby/matchmaking/search');
if (!$ret) {
my %foo = %{ zamanf('GET','lol-matchmaking/v1/search') };
if ($foo{lowPriorityData}{reason}) {
my $wait = $foo{lowPriorityData}{penaltyTime}/60;
info("$config{red}$foo{lowPriorityData}{reason} (+$wait
minutes)")
}
}
}

sub state {
$state = zamanf('GET','lol-gameflow/v1/gameflow-phase');
if ($co[-1] ne $state) {
push@co, do { info("$config{pink}$state") && $state }
}
return $state
}

sub position {
info("-> $config{red}($config{blue}$_[0]$config{red}|$config{blue}
$_[1]$config{red})");
info("$config{blue}script made by$config{pink} zamanf#8802");
zamanf('PUT','lol-lobby/v2/lobby/members/localMember/position-preferences',
'{"firstPreference": "'.shift.'","secondPreference":
"'.shift.'"}')

sub perks {
my %z1;
my @perks = zamanf('GET','lol-perks/v1/pages')->@*;
foreach my $x (0..$#perks) {
if ($perks[$x]{isEditable} == 1) {
$z1{lc($perks[$x]{name})} = $perks[$x]{id};
}
}
return %z1
}

sub creds {
my $proc = `WMIC path win32_process get Caption,Commandline | find "--remoting-
auth-token="`;
if ($proc =~ /--remoting-auth-token=(\S+)".*?--app-port=(\d+)/) {
return [ encode_base64(qq(\x72\x69\x6f\x74:$1)), $2 ]
}
}

sub queue {
info("-> $config{red}($config{blue}$config{MODES}{$config{QUEUE}}
$config{red})");
zamanf('POST','lol-lobby/v2/lobby','{"queueId": '.$config{QUEUE}.'}');
if ($config{QUEUE} !~ /430|450/) {
position($config{PREFER_ROLE1},$config{PREFER_ROLE2});
}
}

sub zamanf {
my ($auth,$port) = creds()->@*;
my $ua = LWP::UserAgent->new( ssl_opts => { verify_hostname => 0 },
protocols_allowed => ['https'] );
my $url = "https://127.0.0.1:$port/$_[1]";
my $req = HTTP::Request->new($_[0], $url);
my %zzz = (
'Accept' => 'application/json',
'Content-Type' => 'application/json',
'Authorization' => "Basic $auth"
);

$req->header(%zzz);
$req->content($_[2]);

my $data = $ua->request($req)->content;
if ($data) {
my $jp = JSON::Parse->new();
$jp->copy_literals(1);
my $json = $jp->run($data);
return $json
}
}

sub cfg_check {

if(!grep{/$config{QUEUE}/} keys $config{MODES}->%*) {


ERROR("QUEUE","GAME MODE$config{white} $config{QUEUE}",'NOT PROPERLY
SET')
}

if ($config{QUEUE} =~ /400|420|440/) {
foreach my $x (qw(PREFER_ROLE1 PREFER_ROLE2)) {

my $role = lc($config{$x});
$role = 'mid' if $config{$x} eq 'MIDDLE';

for (1..5) {
if (exists $config{$role.$_}) {
my @check = $config{lc($role).$_}->@*;
unless ($list{$check[0]}) {
ERROR((lc($role).$_),"CHAMPION $config{white}
$check[0]",'not properly set')
}
unless ($spells{$check[1]}) {
ERROR((lc($role).$_),"SPELL ID [1]
$config{white}$check[1]",'not properly set')
}
unless ($spells{$check[2]}) {
ERROR((lc($role).$_),"SPELL ID [2]
$config{white}$check[2]",'not properly set')
}

unless ($runes{$check[3]}) {
print("$config{white}-> $config{pink}Available
rune pages\n");
foreach my $r (keys %runes) {
print("$config{white}::$config{pink}
[$config{white} $config{cyan}$r $config{pink}]\n")
}
ERROR((lc($role).$_),"RUNE PAGE $config{white}
$check[3]",'not properly set!');

}
} else {
ERROR((lc($role).$_),'doesn\'t exist','DELETED?')
}
}
}
}
}

sub info {
print strftime("$config{red}%H$config{white}:$config{red}%M$config{white}:
$config{red}%S$config{green}",
localtime(time)).' '.shift."$config{reset}\n"
}

sub ERROR {
print "$config{white}:: $config{pink}$config{red}ERROR EXIT$config{white} ::
$config{red}".
"\[$config{white} $_[0] $config{red}] $config{blue}$_[1]$config{pink}
$_[2]$config{reset}\n";
exit(0)
}