Advertisement
Guest User

Untitled

a guest
Jul 21st, 2017
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
mIRC 41.40 KB | None | 0 0
  1. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  2. ;;
  3. ;; %canreply - If 1, bot can reply to .whois, .whoami, .games, .game, .info and such commands
  4. ;; If 0, picking ( hero/player ) is in progress. Disable info commands so it will not flood the bot
  5. ;; %canjoin - If 1, players can join current game, if 0 they cant
  6. ;; %canpickhero - Cptns can pick heroes
  7. ;; %canpickplayer - Cptns can pick players
  8. ;; %game.on - indicates if game is opened or not
  9. ;; %gamenum - nubmer of game
  10. ;; %gamelist
  11. ;; -----------------------------
  12. ;; %player.game - holds number of current game
  13. ;; -----------------------------
  14. ;; %c.gameconfirmed
  15.  
  16. alias gameprefix {
  17. return BGIHL }
  18.  
  19. alias channelname {
  20.   return BGIHL
  21. }
  22.  
  23. alias modes {
  24.   return ap.apxl.ardm.sd.Draft.AutoDraft.Reverse.fullrandom.quickstart.cd.cm
  25.   ;; quickstart compatibility added
  26. }
  27.  
  28. alias topicwelcome {
  29.   return 3Welcome to BG Inhouse League3
  30. }
  31.  
  32. alias topicgame {
  33.   if (%c.challenge) {
  34.     return Sign-up for challenge is opened at the moment,
  35.   }
  36.   else {
  37.     return Sign-up is opened at the moment,
  38.   }
  39. }
  40.  
  41. alias topicmode {
  42.   return mode is %c.gamemode $+ $chr(44)
  43. }
  44.  
  45. alias topichosts {
  46.   if (%c.challenge) {
  47.     return $getname($gettok(%c.gameauths,1,46)) and $getname($gettok(%c.gameauths,2,46)) are the captains.
  48.   }
  49.   else {
  50.     return $getname($gettok(%c.gameauths,1,46)) hosts the game.
  51.   }
  52. }
  53.  
  54. alias topicgames {
  55.   var %line = Games currently in progress:
  56.   var %i = 1
  57.   var %l = $numtok(%gamelist,46)
  58.   if (!%l) { return $null }
  59.   while (%i <= %l) {
  60.     var %g = $gettok(%gamelist,%i,46)
  61.     var %line = %line $get.gamename($($+(%,game.mode_,%g),2),%g)
  62.     inc %i
  63.   }
  64.   return %line
  65. }
  66.  
  67. alias get.gamename {
  68.   return $gameprefix $+ $1 $+ $2
  69. }
  70.  
  71. alias get.gamenamen {
  72.   var %game = $get.gamenum($1)
  73.   if ($hget(gamedata,%game)) { var %mode = $game(%game).mode }
  74.   else { var %mode = $($+(%,game.mode_,%game),2) }
  75.   return $gameprefix $+ %mode $+ %game
  76. }
  77.  
  78. alias gamecheck {
  79.   if (($numtok(%c.gameauths,46) < 10) || (!%c.gameconfirmed)) {
  80.     set %game.on 0
  81.     var %i = 1
  82.     var %l = $numtok(%c.gameauths,46)
  83.     while ( %i <= %l ) {
  84.       var %list = %list $nauth($gettok(%c.gameauths,%i,46))
  85.       inc %i
  86.     }
  87.     if ( %l > 5 ) {
  88.       mode %ch -vvvvv $gettok(%list,1-5,32)
  89.       mode %ch -vvvvv $gettok(%list,5-,32)
  90.     }
  91.     else {
  92.       mode %ch -vvvvv $gettok(%list,1-,32)
  93.     }
  94.     unset %c.gameauths
  95.     set %c.challenge 0
  96.     set %canreply 1
  97.     set %canpickhero 0
  98.     set %canpickplayer 0
  99.     describe %ch Failed to get enough players for a game. Game Aborted!
  100.     topic %ch $topicwelcome $topicgames
  101.   }
  102. }
  103.  
  104. on $*:TEXT:/^(\.startgame|\.sg)$/i:%ch: {
  105.   var %u = $getid2($nick)
  106.   if ( $userlvl(%u) >= 20 ) {
  107.     if (%game.on) { return }
  108.     echo -ag %ch
  109.     if (!$game.canjoin(%u)) { return }
  110.     set %game.on 1
  111.     if (( $2 == mode ) && ($istok($modes,$3,46))) { set %c.gamemode $11 }
  112.     echo -ag %ch
  113.     else { set %c.gamemode cm }
  114.     if ( $3 == quickstart ) { set %c.gamemode cm }
  115.     ;; quickstart compatibility added
  116.     echo -ag %ch
  117.     set %c.gameauths %u
  118.     set %c.gameversion 6.69b
  119.     set %c.gameconfirmed 0
  120.     set %c.gameforbid $null
  121.     set %canpickhero 0
  122.     set %canpickplayer 0
  123.     set %canreply 0
  124.     set %c.pickmode 1
  125.     set %c.challenge 0
  126.     ;; quickstart compatibility added
  127.     set %c.quickstartcptpick 0
  128.     set %c.quickstartplayerpick 0
  129.     echo -ag %ch
  130.     mode %ch +v $nick
  131.     echo -ag %ch
  132.     describe %ch $channelname game starts in 450 seconds. Type .sign to enter
  133.     echo -ag %ch
  134.     ;; topic %ch Welcome to my ASS! Sign-up is opened at the moment, mode is %c.gamemode $+ $chr(44) $getname(%u) hosts the game.
  135.     topic %ch $topicwelcome $topicgame $topicmode $topichosts $topicgames
  136.     echo -ag %ch
  137.     timergamestart 1 450 gamecheck
  138.     echo -ag %ch
  139.     if (!$timer(spamcensure)) { timerspamcensure 1 120 spam.censure }
  140.     echo -ag %ch
  141.     ;; Sign-up for challenge is open at the moment, mode is Draft, Enigma_2008 and Suspekt are the captains
  142.     ;; Sign-up is open at the moment, mode is AutoDraft, traffic|Dark hosts the game.
  143.   }
  144. }
  145.  
  146. on $*:TEXT:/^\.(challenge\b.*|cl\b.*)/i:%ch: {
  147.   var %u = $getid2($nick)
  148.   if ( $userlvl(%u) >= 30 ) {
  149.     if (%game.on) { return }
  150.     ;echo -ag ok
  151.     if (!$2) { return }
  152.     ;echo -ag ok
  153.     var %cu = $getid($2)
  154.     if (!$game.canjoin(%u)) { return }
  155.     ;echo -ag ok
  156.     if (!$game.canjoin(%cu)) { return }
  157.     ;echo -ag ok
  158.     if (%u == %cu) { return }
  159.     if ( $userlvl(%cu) < 30 ) { return }
  160.     ;echo -ag ok
  161.     if (!$nauth(%cu)) { return }
  162.     ;echo -ag ok
  163.     set %game.on 1
  164.     set %c.gamemode cm
  165.     set %c.gameauths %u $+ . $+ %cu
  166.     set %c.gameversion 6.70c
  167.     set %c.gameconfirmed 0
  168.     set %c.challenge 1
  169.     set %canpickhero 0
  170.     set %canpickplayer 0
  171.     set %canreply 0
  172.     ;; quickstart compatibility added
  173.     set %c.quickstartcptpick 0
  174.     set %c.quickstartplayerpick 0
  175.     unset %c.voted
  176.     mode %ch +vv $nick $nauth(%cu)
  177.     describe %ch $channelname challenge starts in 450 seconds. Type .sign to enter
  178.     ;; topic %ch Welcome to my ASS! Sign-up for challenge is opened at the moment, mode is %c.gamemode $+ $chr(44) $getname(%u) and $getname(%cu) are the captains.
  179.     topic %ch $topicwelcome $topicgame $topicmode $topichosts $topicgames
  180.     timergamestart 1 450 gamecheck
  181.     if (!$timer(spamcensure)) { timerspamcensure 1 120 spam.censure }
  182.   }
  183. }
  184.  
  185. on $*:TEXT:/^(\.extend|\.e)$/i:%ch: {
  186.   if (!%game.on) { return }
  187.   var %u = $getid2($nick)
  188.   if (($gettok(%c.gameauths,1,46) == %u) || ((%c.challenge) && ($gettok(%c.gameauths,2,46) == %u))) {
  189.     var %time = $timer(gamestart).secs
  190.     if (%time < 200 ) {
  191.       timergamestart 1 $calc( %time + 450) gamecheck
  192.       describe %ch GameTimer has been extended to $calc( %time + 450 ) seconds
  193.     }
  194.   }
  195.   elseif ( $userlvl(%u) >= $adminlvl ) {
  196.     var %time = $timer(gamestart).secs
  197.     if (%time < 200 ) {
  198.       timergamestart 1 $calc( %time + 450) gamecheck
  199.       describe %ch GameTimer has been extended to $calc( %time + 450 ) seconds
  200.     }
  201.   }
  202. }
  203.  
  204. on $*:TEXT:/^(\.abort|\.reject)$/i:%ch: {
  205.   var %u = $getid2($nick)
  206.   if (($gettok(%c.gameauths,1,46) == %u) || ((%c.challenge) && ($gettok(%c.gameauths,2,46) == %u))) {
  207.     if ((%c.challenge) && ($1 = .abort)) { return }
  208.     if ((!%c.challenge) && ($1 = .reject)) { return }
  209.     if ( %c.gameconfirmed ) { return }
  210.     set %game.on 0
  211.     timergamestart off
  212.     unset %c.gameauths
  213.     set %c.challenge 0
  214.     set %canreply 1
  215.     ;; quickstart compatibility added
  216.     set %c.quickstartcptpick 0
  217.     set %c.quickstartplayerpick 0
  218.     sync.voice
  219.     mode %ch -m
  220.     describe %ch Game aborted!
  221.     topic %ch $topicwelcome $topicgames
  222.     timerextendneed off
  223.   }
  224. }
  225.  
  226. on *:TEXT:.forceabort:%ch: {
  227.   var %u = $getid2($nick)
  228.   if ((($gettok(%c.gameauths,1,46) == %u) || ((%c.challenge) && ($gettok(%c.gameauths,2,46) == %u))) || ($userlvl(%u) >= $adminlvl)) {
  229.     if ((!%c.gameconfirmed) && ($userlvl(%u) < $adminlvl)) { return }
  230.     if (!%game.on) { return }
  231.     if (%c.gameconfirmed) {
  232.       dec %gamenum
  233.       if (%c.challenge) { dec %challnum }
  234.       else { dec %regnum }
  235.     }
  236.     set %game.on 0
  237.     timergamestart off
  238.     timerheropick off
  239.     timerheropickre off
  240.     timercanrepick off
  241.     timerextendneed off
  242.     unset %c.gameauths
  243.     set %c.challenge 0
  244.     set %canpickhero 0
  245.     set %canpickplayer 0
  246.     set %canreply 1
  247.     ;; quickstart compatibility added
  248.     set %c.quickstartcptpick 0
  249.     set %c.quickstartplayerpick 0
  250.     sync.voice
  251.     mode %ch -m
  252.     describe %ch Game aborted!
  253.     topic %ch $topicwelcome $topicgames
  254.   }
  255. }
  256.  
  257. alias game.canjoin {
  258.   if ((!$user($1).ig) && (!$user($1).signed)) { return $true }
  259.   else { return $false }
  260. }
  261.  
  262. alias flush.signout {
  263.   if (%line.signout) {
  264.     describe %ch %line.signout $iif(!%c.challenge,$iif($calc(10 - $numtok(%c.gameauths,46)) != 0, $v1 slots remaining, $getname($gettok(%c.gameauths,1,46)) can start the game(.confirmstart)),$numtok(%c.gameauths,46) players have already signed in.)
  265.   }
  266. }
  267.  
  268. on $*:TEXT:/^(\.sign|\.s)$/i:%ch: {
  269.   var %u = $getid2($nick)
  270.   if ( $userlvl(%u) >= 10 ) {
  271.     if (!%game.on) { return }
  272.     ;echo -ag ok
  273.     if (%c.gameconfirmed) { return }
  274.     if (!$game.canjoin(%u)) { return }
  275.     ;echo -ag ok
  276.     if ((!%c.challenge) && ($istok(%c.gameforbid,%u,46))) { return }
  277.     ;echo -ag ok
  278.     if ((!%c.challenge) && ($numtok(%c.gameauths,46) >= 10)) { return }
  279.     ;echo -ag ok
  280.     set %c.gameauths $addtok(%c.gameauths,%u,46)
  281.     if (!%c.challenge) { mode %ch +v $nick }
  282.     if ($timer(spamsignout)) {
  283.       set %line.signout %line.signout $getname(%u) $+ $enclose($get.exprank(%u)) signed in;
  284.     }
  285.     else {
  286.       describe %ch $getname(%u) $+ $enclose($get.exprank(%u)) signed in; $iif(!%c.challenge,$iif($calc(10 - $numtok(%c.gameauths,46)) != 0, $v1 slots remaining, $getname($gettok(%c.gameauths,1,46)) can start the game(.confirmstart)),$numtok(%c.gameauths,46) players have already signed in.)
  287.       set %line.signout $null
  288.       timerspamsignout 1 7 flush.signout
  289.     }
  290.   }
  291. }
  292.  
  293.  
  294.  
  295. on $*:TEXT:/^(\.out|\.leave)$/i:%ch: {
  296.   var %u = $getid2($nick)
  297.   if (!%game.on) { return }
  298.   if (%c.gameconfirmed) { return }
  299.   if (!$istok(%c.gameauths,%u,46)) { return }
  300.   if (%c.challenge) {
  301.     if ($gettok(%c.gameauths,1,46) == %u ) { return }
  302.     if ($gettok(%c.gameauths,2,46) == %u ) { return }
  303.   }
  304.   set %c.gameauths $remtok(%c.gameauths,%u,1,46)
  305.   mode %ch -v $nick
  306.   if ($timer(spamsignout)) {
  307.     set %line.signout %line.signout $getname(%u) $+ $enclose($get.exprank(%u)) signed out;
  308.   }
  309.   else {
  310.     describe %ch $getname(%u) $+ $enclose($get.exprank(%u)) signed out; $iif(!%c.challenge,$calc(10 - $numtok(%c.gameauths,46)) slots remaining,$numtok(%c.gameauths,46) players have already signed in.)
  311.     set %line.signout $null
  312.     timerspamsignout 1 7 flush.signout
  313.   }
  314. }
  315.  
  316. on *:TEXT:.remove*:%ch: {
  317.   var %u = $getid2($nick)
  318.   var %ku = $getid($2)
  319.   if (!%game.on) { return }
  320.   if (%c.challenge) { return }
  321.   if ($gettok(%c.gameauths,1,46) != %u ) { return }
  322.   if (!$istok(%c.gameauths,%ku,46)) { return }
  323.   if (%u = %ku) { return }
  324.   set %c.gameauths $remtok(%c.gameauths,%ku,1,46)
  325.   set %c.gameforbid $addtok(%c.gameforbid,%ku,46)
  326.   mode %ch -v $nauth(%ku)
  327.   describe %ch $getname(%ku) has been removed from the game; $calc(10 - $numtok(%c.gameauths,46)) slots remaining
  328. }
  329.  
  330. on *:TEXT:.mode*:%ch: {
  331.   if (!%game.on) { return }
  332.   if (%c.gameconfirmed) { return }
  333.   var %u = $getid2($nick)
  334.   if ($istok($modes,$2,46)) {
  335.     if ($gettok(%c.gameauths,1,46) == %u ) {
  336.       if ((!%c.challenge) && ( $2 == quickstart )) { return }
  337.       ;; quickstart compatibility added
  338.       set %c.gamemode $2
  339.       describe %ch Mode is set to $enclose($2)
  340.       topic %ch $topicwelcome $topicgame $topicmode $topichosts $topicgames
  341.       return
  342.     }
  343.   }
  344.   describe %ch Mode is $enclose(%c.gamemode)
  345. }
  346.  
  347. alias get.usernamelistrank {
  348.   var %i = 1
  349.   var %l = $numtok($1,46)
  350.   var %list = $null
  351.   while ( %i <= %l ) {
  352.     var %list = %list $getname($gettok($1,%i,46)) $+ $enclose($get.exprank($gettok($1,%i,46))) $+ $chr(44)
  353.     inc %i
  354.   }
  355.   var %list = $mid(%list,1,$calc($len(%list)-1))
  356.   return %list
  357. }
  358.  
  359. on $*:TEXT:/^(\.listplayers|\.lpl)$/i:%ch: {
  360.   if (!%game.on) { return }
  361.   if ($timer(listplayers)) { return }
  362.   var %i = 1
  363.   var %l = $numtok(%c.gameauths,46)
  364.   while ( %i <= %l ) {
  365.     var %list = %list $getname($gettok(%c.gameauths,%i,46)) $+ $enclose($get.exprank($gettok(%c.gameauths,%i,46))) $+ $chr(44)
  366.     inc %i
  367.   }
  368.   var %list = $mid(%list,1,$calc($len(%list)-1))
  369.   describe %ch $iif(%list,%list $iif(%c.challenge,( $+ $numtok(%c.gameauths,46) players $+ )) have already signed in.,Game is empty) $iif(!%c.challenge,$enclose($calc(10 - $numtok(%c.gameauths,46)) slots remaining))
  370.   timerlistplayers 1 10 noop
  371. }
  372.  
  373. on $*:TEXT:/^(\.listpool|\.lp)$/i:%ch: {
  374.   if (!%game.on) { return }
  375.   if ($timer(listpool)) { return }
  376.   if (%canpickhero) {
  377.     describe %ch Hero pool: $get.heroliste(%c.gameheropool)
  378.   }
  379.   elseif (%canpickplayer) {
  380.     describe %ch Player pool: $get.usernamelistrank(%c.gameplayerpool)
  381.   }
  382.   elseif (%c.quickstartcptpick) {
  383.     describe %ch Hero pool: $get.heroliste(%c.gameherocptpool)
  384.   }
  385.   elseif (%c.quickstartplayerpick) {
  386.     echo -ag QS - playerpick
  387.     describe %ch Player pool: $get.usernamelistqs(%c.gameplayerpool,%c.gameheroplayerpool)
  388.   }
  389.   timerlistpool 1 10 noop
  390. }
  391.  
  392. on $*:TEXT:/^(\.listteams|\.lt)$/i:%ch: {
  393.   if (!%game.on) { return }
  394.   if ($timer(listteams)) { return }
  395.   if ((!%canpickplayer) && (!%c.quickstartplayerpick)) { return }
  396.   Describe %ch Team Sentinel: $get.usernamelist(%c.playersent)
  397.   Describe %ch Team Scourge: $get.usernamelist(%c.playerscrg)
  398.   timerlistteams 1 10 noop
  399. }
  400.  
  401. on *:TEXT:.timeleft:%ch: {
  402.   if (!%game.on) { return }
  403.   if ($timer(listtimeleft)) { return }
  404.   Describe %ch Time left for sign-ups: $timer(gamestart).secs seconds
  405.   timerlisttimeleft 1 10 noop
  406. }
  407.  
  408. on *:TEXT:.games:%ch: {
  409.   if ((!%canreply) && ($userlvl2($nick) < 50 )) { return }
  410.   if ($timer(listcurrentgames)) { return }
  411.   var %line = Games currently in progress:
  412.   var %i = 1
  413.   var %l = $numtok(%gamelist,46)
  414.   while (%i <= %l) {
  415.     var %g = $gettok(%gamelist,%i,46)
  416.     var %line = %line $get.gamename($($+(%,game.mode_,%g),2),%g) $+ $enclose($round($calc(($ctime - $($+(%,game.date_,%g),2)) / 60),0))
  417.     inc %i
  418.   }
  419.   if (!%l) { var %line = %line none }
  420.   describe %ch %line
  421.   timerlistcurrentgames 1 10 noop
  422. }
  423.  
  424. /*
  425. Game IHLDraft50(1/2/2008): Team Sentinel: <all4non[+54] DraKill[+56] 4urapa)[+56] tooSCARY[+57] Zhanis[+65]>
  426. Team Scourge: <U2SantoS[-45] Vavas wt-sk[-42] BigFatPenguinQ GadyaHrenova[-38]> Won by Sentinel
  427. */
  428.  
  429.  
  430. on $*:TEXT:/^\.(gamedetails\s.*|info\s.*|lastgame)/:*: {
  431.   if ($chan) { var %target = $chan }
  432.   else { var %target = $nick }
  433.   if ((!$2) && ($1 == .lastgame )) { var %game = %gamenum }
  434.   elseif (($2) && ($1 == .lastgame )) { var %u = $getid($2) | var %game = $user(%u).lastgame }
  435.   else {
  436.     if ( $1 != .lastgame ) {
  437.       var %game = $get.gamenum($2)
  438.     }
  439.   }
  440.   if (!%game) { return }
  441.   if (%game > %gamenum ) { return }
  442.   if ($hget(gamedata,%game)) {
  443.     var %sent = $gettok($game(%game).plist,1-5,46)
  444.     var %scrg = $gettok($game(%game).plist,6-10,46)
  445.     if ( $game(%game).result == sentinel ) {
  446.       var %sente = $gettok($game(%game).elist,1-5,46)
  447.       var %scrge = $gettok($game(%game).elist,6-10,46)
  448.     }
  449.     elseif ( $game(%game).result == scourge ) {
  450.       var %sente = $gettok($game(%game).aelist,1-5,46)
  451.       var %scrge = $gettok($game(%game).aelist,6-10,46)
  452.     }
  453.     var %result = $game(%game).result
  454.     var %sentl
  455.     var %i = 1
  456.     while ( %i <= 5 ) {
  457.       var %sentl = %sentl $getname($gettok(%sent,%i,46)) $+ $iif(%result != draw,$enclose($iif($gettok(%sente,%i,46) >= 0, + $+ $v1,$v1)))
  458.       inc %i
  459.     }
  460.     var %i = 1
  461.     while ( %i <= 5 ) {
  462.       var %scrgl = %scrgl $getname($gettok(%scrg,%i,46)) $+ $iif(%result != draw,$enclose($iif($gettok(%scrge,%i,46) >= 0, + $+ $v1,$v1)))
  463.       inc %i
  464.     }
  465.     describe %target Game $get.gamename($game(%game).mode,%game) $+ ( $+ $asctime($game(%game).time,HH:nn:ss dd/mm/yy) $+ ) $+ :Result: %result
  466.     describe %target Team Sentinel: < $+ %sentl $+ >
  467.     describe %target Team Scourge: < $+ %scrgl $+ >
  468.   }
  469.   else {
  470.     var %players = $($+(%,game.auths_,%game),2)
  471.     var %mode = $($+(%,game.mode_,%game),2)
  472.     var %date = $($+(%,game.date_,%game),2)
  473.     if ( %date != 1 ) { var %date_s = Still in progress: $round($calc(($ctime - %date) / 60),0) minutes }
  474.     else { var %date_s = Not started yet }
  475.     describe %target Game $get.gamename(%mode,%game) $+ : %date_s
  476.     describe %target Team Sentinel: < $+ $get.usernamelist($gettok(%players,1-5,46)) $+ >
  477.     describe %target Team Scourge: < $+ $get.usernamelist($gettok(%players,6-10,46)) $+ >
  478.   }
  479. }
  480.  
  481. on *:TEXT:.teams*:*: {
  482.   if (((!%canreply) && ($2)) && ($userlvl2($nick) < 50 )) { return }
  483.   var %u = $getid2($nick)
  484.   if (!$2) {
  485.     if ($timer(listcurrentteams)) { return }
  486.     var %game = $user(%u).gamenum
  487.     if (!%game) { return }
  488.     var %h = $($+(%,game.auths_,%game),2)
  489.     Describe %ch Team Sentinel: $get.usernamelist($gettok(%h,1-5,46))
  490.     Describe %ch Team Scourge: $get.usernamelist($gettok(%h,6-10,46))
  491.     timerlistcurrentteams 1 10 noop
  492.   }
  493.   else {
  494.     if ($2 > %gamenum) { return }
  495.     if ($chan) { var %target = $chan }
  496.     else { var %target = $nick }
  497.     var %game = $get.gamenum($2)
  498.     if (!%game) { return }
  499.     ;echo -ag OK
  500.     Describe %target Team Sentinel: $get.usernamelist($gettok($game(%game).plist,1-5,46))
  501.     Describe %target Team Scourge: $get.usernamelist($gettok($game(%game).plist,6-10,46))
  502.   }
  503. }
  504.  
  505.  
  506.  
  507.  
  508. on $*:TEXT:/\.(top|bottom).*/:*: {
  509.   if (($1 != .top) && ($1 != .bottom)) { return }
  510.   var %u = $getid2($nick)
  511.   if (($timer(listtop)) && ($userlvl(%u) < 90)) { return }
  512.   if (!$2) { var %top = 10 }
  513.   else { var %top = $2 }
  514.   if ((%top < 10) && (%top != 3)) { var %top = 10 }
  515.   if (%top > $calc(%rank.users - 10)) { var %top = %rank.users }
  516.   if ($1 == .bottom ) { var %top = %rank.users }
  517.   if (%top != 3) {
  518.     var %i = %top - 9
  519.     var %l = %top
  520.     while ( %i <= %l ) {
  521.       var %tu = $sort.getuser(%i)
  522.       var %topline = %topline %i $+ . $getname(%tu) $+ $enclose($user(%tu).exp) $+ $chr(44)
  523.       inc %i
  524.     }
  525.     var %topline = $mid(%topline,1,$calc($len(%topline) - 1))
  526.     describe $chan Top %top $+ : %topline
  527.   }
  528.   else {
  529.     var %tu = $sort.getuser(1)
  530.     describe $chan 1. $getname(%tu) $+ $enclose($get.exprank(%tu)) $+ ; $user(%tu).win wins $+ , $user(%tu).lost losses $+ , $user(%tu).exp experience;
  531.     var %tu = $sort.getuser(2)
  532.     describe $chan 2. $getname(%tu) $+ $enclose($get.exprank(%tu)) $+ ; $user(%tu).win wins $+ , $user(%tu).lost losses $+ , $user(%tu).exp experience;
  533.     var %tu = $sort.getuser(3)
  534.     describe $chan 3. $getname(%tu) $+ $enclose($get.exprank(%tu)) $+ ; $user(%tu).win wins $+ , $user(%tu).lost losses $+ , $user(%tu).exp experience;
  535.   }
  536.   timerlisttop 1 30 noop
  537. }
  538. ;####################### PICKING & GAMESTART #########################
  539. ;#####################################################################
  540.  
  541. alias pick.whopick {
  542.   if ( $1 == 1 ) { return 1 }
  543.   elseif (( $1 == 2 ) || ( $1 == 3 )) { return 2 }
  544.   elseif (( $1 == 4 ) || ( $1 == 5 )) { return 1 }
  545.   elseif (( $1 == 6 ) || ( $1 == 7 )) { return 2 }
  546.   elseif (( $1 == 8 ) || ( $1 == 9 )) { return 1 }
  547.   elseif ( $1 == 10 ) { return 2 }
  548. }
  549.  
  550. alias get.heroname {
  551.   var %i = 1
  552.   var %l = %heronum
  553.   var %n = 0
  554.   var %needle = / $+ $1- $+ .*/i
  555.   var %list
  556.   while ( %i <= %l ) {
  557.     if ($regex($($+(%,hero_,%i),2),%needle)) {
  558.       inc %n
  559.       var %list = $addtok(%list,$($+(%,hero_,%i),2),46)
  560.     }
  561.     inc %i
  562.   }
  563.   if (%n = 1) { return %list }
  564.   else { return %n }
  565. }
  566.  
  567. alias get.gamemode {
  568.   ;; quickstart compatibility added
  569.   if ($istok(Draft.Reverse.ap.AutoDraft.quickstart,$1,46)) { return ap }
  570.   elseif ( $1 == ardm ) { return ardm }
  571.   elseif ( $1 == apxl ) { return apxl }
  572.   elseif ( $1 == sd ) { return sd }
  573.   elseif ( $1 == Fullrandom ) { return ar }
  574. }
  575.  
  576. on $*:TEXT:/^(\.confirmstart|\.cf)$/i:%ch: {
  577.   var %u = $getid2($nick)
  578.   if (!%game.on) { return }
  579.   if (%c.challenge) { return }
  580.   if ($gettok(%c.gameauths,1,46) != %u ) { return }
  581.   if ($numtok(%c.gameauths,46) < 10) { return }
  582.   if (!$timer(spamcensure)) { timerspamcensure 1 200 spam.censure }
  583.   ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; PROCESSING TEAMS
  584.   echo -ag PROCESSING TEAMS
  585.   var %i = 1
  586.   var %j = 1
  587.   var %max = 10000
  588.   var %min = 1
  589.   var %sort = %c.gameauths
  590.   while ( %i <= 10 ) {
  591.     while ( %j <= 10 ) {
  592.       var %u = $gettok(%sort,%j,46)
  593.       var %exp = $user(%u).exp
  594.       if ((%exp >= %min) && (%exp <= %max)) { %min = %exp | var %p = %j }
  595.       inc %j
  596.     }
  597.     var %max = $user($gettok(%sort,%p,46)).exp
  598.     var %min = 1
  599.     var %pom = $gettok(%sort,%i,46)
  600.     var %sort = $puttok(%sort,$gettok(%sort,%p,46),%i,46)
  601.     var %sort = $puttok(%sort,%pom,%p,46)
  602.     echo -ag $gettok(%sort,%i,46) -- $user($gettok(%sort,%i,46)).exp
  603.     inc %i
  604.     %j = %i
  605.   }
  606.   echo -ag %c.gameauths
  607.   echo -ag %sort
  608.  
  609.   var %i = 1
  610.   var %seed = $r(1,2)
  611.   var %sent
  612.   var %scrg
  613.   while ( %i <= 10 ) {
  614.     if (%seed == 1) {
  615.       if ( 2 \\ %i ) {
  616.         var %sent = $addtok(%sent,$gettok(%sort,%i,46),46)
  617.       }
  618.       else {
  619.         var %scrg = $addtok(%scrg,$gettok(%sort,%i,46),46)
  620.       }
  621.     }
  622.     else {
  623.       if ( 2 // %i ) {
  624.         var %sent = $addtok(%sent,$gettok(%sort,%i,46),46)
  625.       }
  626.       else {
  627.         var %scrg = $addtok(%scrg,$gettok(%sort,%i,46),46)
  628.       }
  629.     }
  630.     inc %i
  631.   }
  632.  
  633.   describe %ch Team Sentinel: $get.usernamelistrank(%sent)
  634.   describe %ch Team Scourge: $get.usernamelistrank(%scrg)
  635.   ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  636.  
  637.   inc %gamenum
  638.   inc %regnum
  639.  
  640.   set %c.gameconfirmed 1
  641.  
  642.   if (!$istok(Draft.Reverse,%c.gamemode,46)) {
  643.     ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; NORMAL GAME OR AUTODRAFT - NO PICKING
  644.     echo -ag NORMAL GAME -> GIVE 'EM SOME STUPID MESSAGE
  645.     describe %ch Game mode is - $+ $get.gamemode(%c.gamemode) $+ ; Game name is $get.gamename(%c.gamemode,%gamenum) $+ ; Map version is %c.gameversion
  646.     set %gamelist $addtok(%gamelist,%gamenum,46)
  647.     set %game.mode_ $+ %gamenum %c.gamemode
  648.     set %game.version_ $+ %gamenum %c.gameversion
  649.     set %game.date_ $+ %gamenum $ctime
  650.     set %game.auths_ $+ %gamenum %sent $+ . $+ %scrg
  651.     set %game.chall_ $+ %gamenum %c.challenge
  652.  
  653.     var %i = 1
  654.     while (%i <= 10) {
  655.       set %player.game_ $+ $gettok(%c.gameauths,%i,46) %gamenum
  656.       inc %i
  657.     }
  658.  
  659.     ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; AUTO DRAFT
  660.     if (%c.gamemode == AutoDraft) {
  661.       echo -ag HERO AUTODRAFT -> PICK MOST PICKED HEROES
  662.       autodraft
  663.     }
  664.     ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  665.  
  666.     set %game.on 0
  667.     unset %c.gameauths
  668.     set %c.challenge 0
  669.     set %canreply 1
  670.     timergamestart off
  671.     timerextendneed off
  672.     timer1 off
  673.     topic %ch $topicwelcome $topicgames
  674.     ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  675.   }
  676.   else {
  677.     ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; DRAFT - ENABLE PICKING
  678.     echo -ag HERO DRAFT -> SET PICKERS AND ENABLE HERO PICKING
  679.     set %game.mode_ $+ %gamenum %c.gamemode
  680.     set %game.version_ $+ %gamenum %c.gameversion
  681.     set %game.auths_ $+ %gamenum %sent $+ . $+ %scrg
  682.     set %game.date_ $+ %gamenum 1
  683.     set %game.chall_ $+ %gamenum %c.challenge
  684.     set %canpickhero 1
  685.     unset %c.herosent
  686.     unset %c.heroscrg
  687.     unset %c.gameheropool
  688.     if ( $r(1,2) == 1 ) {
  689.       set %c.picker1 $gettok(%sent,1,46)
  690.       set %c.picker2 $gettok(%scrg,1,46)
  691.       set %c.first sent
  692.     }
  693.     else  {
  694.       set %c.picker1 $gettok(%scrg,1,46)
  695.       set %c.picker2 $gettok(%sent,1,46)
  696.       set %c.first scrg
  697.     }
  698.     set %c.gameheropool
  699.     while ( $numtok(%c.gameheropool,46) != 20 ) {
  700.       set %c.gameheropool $addtok(%c.gameheropool,$($+(%,hero_,$r(1,90)),2),46)
  701.     }
  702.     var %i = 1
  703.     while ( %i <= 20 ) {
  704.       AddHero.pool $gettok(%c.gameheropool,%i,46)
  705.       inc %i
  706.     }
  707.     mode %ch +m
  708.     describe %ch Game mode is %c.gamemode $+ $chr(44) $+ ; Game name is $get.gamename(%c.gamemode,%gamenum) $+ ; Map version is %c.gameversion $+ ; Hero draft starts now, $getname(%c.picker1) has 90 seconds to pick a hero.
  709.     describe %ch Heroes available: $get.heroliste(%c.gameheropool)
  710.     timergamestart off
  711.     timerheropick 1 90 pick.pickhero random
  712.     timerheropickre 1 70 pick.notify
  713.     ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  714.   }
  715. }
  716.  
  717. on *:TEXT:.ready:%ch: {
  718.   var %u = $getid2($nick)
  719.   if (!%game.on) { return }
  720.   ;echo -ag OK
  721.   if (!%c.challenge) { return }
  722.   ;echo -ag OK
  723.   if (($gettok(%c.gameauths,1,46) != %u ) && ($gettok(%c.gameauths,2,46) != %u )) { return }
  724.   ;echo -ag OK
  725.   if ($numtok(%c.gameauths,46) < 10) { return }
  726.   ;echo -ag OK
  727.   if (!$istok(%c.voted,%u,46)) {
  728.     set %c.voted $addtok(%c.voted,%u,46)
  729.   }
  730.   else { return }
  731.   if ($numtok(%c.voted,46) == 2) {
  732.     if (!$timer(spamcensure)) { timerspamcensure 1 200 spam.censure }
  733.     ;echo -ag OK
  734.     inc %gamenum
  735.     inc %challnum
  736.     if ( $r(1,2) == 1 ) {
  737.       set %c.picker1 $gettok(%c.gameauths,1,46)
  738.       set %c.picker2 $gettok(%c.gameauths,2,46)
  739.       set %c.first sent
  740.     }
  741.     else  {
  742.       set %c.picker1 $gettok(%c.gameauths,2,46)
  743.       set %c.picker2 $gettok(%c.gameauths,1,46)
  744.       set %c.first sent
  745.     }
  746.     set %c.gameplayerpool $gettok(%c.gameauths,3-,46)
  747.     set %c.playersent %c.picker1
  748.     set %c.playerscrg %c.picker2
  749.     set %c.challpickround 1
  750.     set %c.gameconfirmed 1
  751.     timergamestart off
  752.     if ( %c.gamemode == quickstart ) {
  753.       ;;############### quickstart #################
  754.       set %game.date_ $+ %gamenum 1
  755.       set %c.gameheropool
  756.       set %c.gameherocptpool
  757.       set %c.gameheroplayerpool
  758.       unset %c.herosent
  759.       unset %c.heroscrg
  760.       unset %c.repicked
  761.       var %l = $numtok(%c.gameplayerpool,46)
  762.       var %l = $calc(%l + 8)
  763.       while ( $numtok(%c.gameheropool,46) != %l ) {
  764.         set %c.gameheropool $addtok(%c.gameheropool,$($+(%,hero_,$r(1,90)),2),46)
  765.       }
  766.  
  767.       var %i = 1
  768.       while ( %i <= %l ) {
  769.         AddHero.pool $gettok(%c.gameheropool,%i,46)
  770.         inc %i
  771.       }
  772.       set %c.gameherocptpool $gettok(%c.gameheropool,1-8,46)
  773.       set %c.gameheroplayerpool $gettok(%c.gameheropool,9-,46)
  774.       set %c.quickstartcptpick 2
  775.       set %c.quickstartplayerpick 0
  776.       mode %ch +m
  777.       describe %ch Sign-up closed. Captains pick heroes for themselves first, it's $getname(%c.picker1) $+ 's turn to pick.
  778.       ;describe %ch Player pool: $get.usernamelistrank(%c.gameplayerpool)
  779.       describe %ch Heroes available: $get.heroliste(%c.gameherocptpool)
  780.       ;;############### quickstart #################
  781.     }
  782.     else {
  783.       mode %ch +m
  784.       set %canpickplayer 1
  785.       describe %ch Sign-up closed. It's $getname(%c.picker1) $+ 's turn to pick.
  786.       describe %ch Player pool: $get.usernamelistrank(%c.gameplayerpool)
  787.     }
  788.   }
  789. }
  790.  
  791.  
  792. alias autodraft {
  793.   ; Create a pool first
  794.   var %c.gameheropool = .
  795.   while ( $numtok(%c.gameheropool,46) != 20 ) {
  796.     %c.gameheropool = $addtok(%c.gameheropool,$($+(%,hero_,$r(1,90)),2),46)
  797.   }
  798.   ; Add heroes
  799.   var %i = 1
  800.   while ( %i <= 20 ) {
  801.     AddHero.pool $gettok(%c.gameheropool,%i,46)
  802.     inc %i
  803.   }
  804.   ; Sort 10 heroes based on popularity
  805.   var %i = 1
  806.   var %j = 1
  807.   var %max = 10000
  808.   var %min = 0
  809.   var %sort = %c.gameheropool
  810.   while ( %i <= 10 ) {
  811.     while ( %j <= 20 ) {
  812.       var %u = $gettok(%sort,%j,46)
  813.       var %pop = $hero(%u).pop
  814.       if ((%pop >= %min) && (%pop <= %max)) { %min = %pop | var %p = %j }
  815.       inc %j
  816.     }
  817.     var %max = $hero($gettok(%sort,%p,46)).pop
  818.     var %min = 1
  819.     var %pom = $gettok(%sort,%i,46)
  820.     var %sort = $puttok(%sort,$gettok(%sort,%p,46),%i,46)
  821.     var %sort = $puttok(%sort,%pom,%p,46)
  822.     var %pom = $gettok(%sort,%i,46)
  823.     echo -ag %pom -- $hero(%pom).pop
  824.     inc %i
  825.     %j = %i
  826.   }
  827.   echo -ag %sort
  828.   ; Create "hero" teams
  829.   var %i = 1
  830.   var %seed = $r(1,2)
  831.   while ( %i <= 10 ) {
  832.     if (%seed == 1) {
  833.       if ( $pick.whopick(%i) == 1 ) {
  834.         var %sent = $addtok(%sent,$gettok(%sort,%i,46),46)
  835.       }
  836.       else {
  837.         var %scrg = $addtok(%scrg,$gettok(%sort,%i,46),46)
  838.       }
  839.     }
  840.     else {
  841.       if ( $pick.whopick(%i) == 2 ) {
  842.         var %sent = $addtok(%sent,$gettok(%sort,%i,46),46)
  843.       }
  844.       else {
  845.         var %scrg = $addtok(%scrg,$gettok(%sort,%i,46),46)
  846.       }
  847.     }
  848.     if ( %i == 1 ) { AddHero.fp $gettok(%sort,%i,46) }
  849.     if ( %i == 2 ) { AddHero.sp $gettok(%sort,%i,46) }
  850.     if ( %i == 3 ) { AddHero.tp $gettok(%sort,%i,46) }
  851.     inc %i
  852.   }
  853.   describe %ch Sentinel heroes: $get.herolistpop(%sent)
  854.   describe %ch Scourge heroes: $get.herolistpop(%scrg)
  855.  
  856.   var %i = 1
  857.   while (%i <= 10) {
  858.     AddHero.picked $gettok(%sort,%i,46)
  859.     inc %i
  860.   }
  861.   set %game.heroes_ $+ %gamenum %sent $+ . $+ %scrg
  862. }
  863.  
  864. ;############################## PICKING ##############################
  865. ;#####################################################################
  866.  
  867. alias pick.round {
  868.   return $calc(21 - $numtok(%c.gameheropool,46))
  869. }
  870.  
  871. alias get.heronamepool {
  872.   if ($2) { var %herolist = $($+(%,c.gamehero,$2,pool),2) }
  873.   else { var %herolist = %c.gameheropool }
  874.   ;echo -ag %herolist $2
  875.   if ($1 == prophet ) {
  876.     if ($istok(%herolist,prophet,46)) {
  877.       if ($istok(%herolist,death prophet,46)) {
  878.         return prophet
  879.       }
  880.     }
  881.   }
  882.   var %i = 1
  883.   var %l = $numtok(%herolist,46)
  884.   var %n = 0
  885.   var %needle = / $+ $1 $+ .*/i
  886.   var %list
  887.   while ( %i <= %l ) {
  888.     if ($regex($gettok(%herolist,%i,46),%needle)) {
  889.       inc %n
  890.       var %list = $addtok(%list,$gettok(%herolist,%i,46),46)
  891.     }
  892.     inc %i
  893.   }
  894.   ;echo -ag %n %list
  895.   if (%n = 1) { return %list }
  896.   else { return %n }
  897. }
  898.  
  899. alias pick.pickhero {
  900.   if (!$1) { return }
  901.   if ($1 != random) {
  902.     var %hero = $get.heronamepool($1-)
  903.   }
  904.   else {
  905.     var %hero = $gettok(%c.gameheropool,$r(1,$numtok(%c.gameheropool,46)),46)
  906.   }
  907.   if ( %hero !isnum) {
  908.     var %who = $pick.whopick($pick.round)
  909.     if (((%who == 1) && (%c.gamemode != reverse)) || ((%who == 2) && (%c.gamemode == reverse))) {
  910.       if ( %c.first == sent ) {
  911.         set %c.herosent $addtok(%c.herosent,%hero,46)
  912.       }
  913.       else {
  914.         set %c.heroscrg $addtok(%c.heroscrg,%hero,46)
  915.       }
  916.     }
  917.     elseif (((%who == 2) && (%c.gamemode != reverse)) || ((%who == 1) && (%c.gamemode == reverse))) {
  918.       if ( %c.first == sent ) {
  919.         set %c.heroscrg $addtok(%c.heroscrg,%hero,46)
  920.       }
  921.       else {
  922.         set %c.herosent $addtok(%c.herosent,%hero,46)
  923.       }
  924.     }
  925.     if ( $pick.round == 1 ) { AddHero.fp %hero }
  926.     if ( $pick.round == 2 ) { AddHero.sp %hero }
  927.     if ( $pick.round == 3 ) { AddHero.tp %hero }
  928.     set %c.gameheropool $remtok(%c.gameheropool,%hero,1,46)
  929.     if ( $numtok(%c.gameheropool,46) > 10 ) {
  930.       describe %ch $getname($($+(%,c.picker,%who),2)) $iif($1 != random,picked,randomized) %hero $+ ; $getname($($+(%,c.picker,$pick.whopick($pick.round)),2)) has 90 seconds to pick a hero
  931.       timerheropick 1 90 pick.pickhero random
  932.       timerheropickre 1 70 pick.notify
  933.     }
  934.     else {
  935.       describe %ch $getname($($+(%,c.picker,%who),2)) picked %hero $+ ;
  936.       describe %ch Team Sentinel's heroes: $get.heroliste(%c.herosent)
  937.       describe %ch Team Scourge's heroes: $get.heroliste(%c.heroscrg)
  938.       describe %ch Game mode is - $+ $get.gamemode(%c.gamemode) $+ ; Game name is $get.gamename(%c.gamemode,%gamenum) $+ ; Map version is %c.gameversion $+ ; Use .teams and .heroes to get a reminder on the line-ups
  939.       set %gamelist $addtok(%gamelist,%gamenum,46)
  940.       set %game.date_ $+ %gamenum $ctime
  941.       set %game.heroes_ $+ %gamenum %c.herosent $+ . $+ %c.heroscrg
  942.       set %game.on 0
  943.       var %i = 1
  944.       while (%i <= 5) {
  945.         AddHero.picked $gettok(%c.herosent,%i,46)
  946.         AddHero.picked $gettok(%c.heroscrg,%i,46)
  947.         inc %i
  948.       }
  949.       var %i = 1
  950.       var %ga = $($+(%,game.auths_,%gamenum),2)
  951.       while (%i <= 10) {
  952.         set %player.game_ $+ $gettok(%ga,%i,46) %gamenum
  953.         inc %i
  954.       }
  955.       unset %c.gameauths
  956.       unset %c.herosent
  957.       unset %c.heroscrg
  958.       unset %c.gameheropool
  959.       set %canpickhero 0
  960.       set %canpickplayer 0
  961.       set %canreply 1
  962.       set %c.challenge 0
  963.       timerheropick off
  964.       timerheropickre off
  965.       timer 1 3 topic %ch $topicwelcome $topicgames
  966.       mode %ch -m
  967.       if (!$timer(spamcensure)) { timerspamcensure 1 120 spam.censure }
  968.     }
  969.   }
  970.   elseif ( %hero == 0 ) { notice $nick no hero | return }
  971.   else { describe %ch Be more specific ( $+ %hero matches) }
  972. }
  973.  
  974. alias get.usernamelistqs {
  975.   var %i = 1
  976.   var %l = $numtok($1,46)
  977.   var %list = $null
  978.   while ( %i <= %l ) {
  979.     var %list = %list $getname($gettok($1,%i,46)) $+ $enclose($gettok($2,%i,46))
  980.     inc %i
  981.   }
  982.   return %list
  983. }
  984.  
  985. alias pick.qs.pickhero {
  986.   if (!$1) { return }
  987.   if ($1 != random) {
  988.     var %hero = $get.heronamepool($1-,cpt)
  989.   }
  990.   else {
  991.     var %hero = $gettok(%c.gameherocptpool,$r(1,$numtok(%c.gameherocptpool,46)),46)
  992.   }
  993.   if ( %hero !isnum) {
  994.     var %who = $pick.whopick(%c.challpickround)
  995.     if (%who == 1) {
  996.       if ( %c.first == sent ) {
  997.         set %c.herosent $addtok(%c.herosent,%hero,46)
  998.       }
  999.       else {
  1000.         set %c.heroscrg $addtok(%c.heroscrg,%hero,46)
  1001.       }
  1002.     }
  1003.     elseif (%who == 2) {
  1004.       if ( %c.first == sent ) {
  1005.         set %c.heroscrg $addtok(%c.heroscrg,%hero,46)
  1006.       }
  1007.       else {
  1008.         set %c.herosent $addtok(%c.herosent,%hero,46)
  1009.       }
  1010.     }
  1011.     if ( %c.challpickround == 1 ) { AddHero.fp %hero }
  1012.     if ( %c.challpickround == 2 ) { AddHero.sp %hero }
  1013.     set %c.gameherocptpool $remtok(%c.gameherocptpool,%hero,1,46)
  1014.     if ( $numtok(%c.gameherocptpool,46) > 6 ) {
  1015.       describe %ch $getname($($+(%,c.picker,%who),2)) picked %hero $+ ;  $getname($($+(%,c.picker,$pick.whopick($calc( %c.challpickround + 1))),2)) $+ 's turn to pick
  1016.       inc %c.challpickround
  1017.       dec %c.quickstartcptpick
  1018.     }
  1019.     else {
  1020.       describe %ch $getname($($+(%,c.picker,%who),2)) picked %hero $+ ; $getname($($+(%,c.picker,$pick.whopick($calc( %c.challpickround + 1))),2)) $+ 's turn to pick
  1021.       describe %ch Player pool: $get.usernamelistqs(%c.gameplayerpool,%c.gameheroplayerpool)
  1022.       describe %ch Players now have 60 seconds to repick hero. Use .repick to get a new one
  1023.       inc %c.challpickround
  1024.       dec %c.quickstartcptpick
  1025.       timercanrepick 1 60 set %c.quickstartplayerpick 1
  1026.     }
  1027.   }
  1028.   elseif ( %hero == 0 ) { notice $nick no hero | return }
  1029.   else { describe %ch Be more specific ( $+ %hero matches) }
  1030. }
  1031.  
  1032.  
  1033. alias pick.notify {
  1034.   describe %ch Hurry up! 20 seconds remaining for hero choice!
  1035. }
  1036.  
  1037. alias pick.pickplayer {
  1038.   if (!$1) { return }
  1039.   var %u = $getid($1)
  1040.   if (!$istok(%c.gameplayerpool,%u,46)) { return }
  1041.   var %who = $pick.whopick(%c.challpickround)
  1042.   if (%who == 1) {
  1043.     if ( %c.first == sent ) {
  1044.       set %c.playersent $addtok(%c.playersent,%u,46)
  1045.     }
  1046.     else {
  1047.       set %c.playerscrg $addtok(%c.playerscrg,%u,46)
  1048.     }
  1049.   }
  1050.   elseif (%who == 2) {
  1051.     if ( %c.first == sent ) {
  1052.       set %c.playerscrg $addtok(%c.playerscrg,%u,46)
  1053.     }
  1054.     else {
  1055.       set %c.playersent $addtok(%c.playersent,%u,46)
  1056.     }
  1057.   }
  1058.   mode %ch +v $nauth(%u)
  1059.   set %c.gameplayerpool $remtok(%c.gameplayerpool,%u,1,46)
  1060.   if (%c.challpickround < 8 ) {
  1061.     describe %ch $getname($($+(%,c.picker,%who),2)) picked $getname(%u) $+ ; $getname($($+(%,c.picker,$pick.whopick($calc( %c.challpickround + 1))),2)) $+ 's turn to pick
  1062.   }
  1063.   else {
  1064.     if (!$istok(Draft.Reverse,%c.gamemode,46)) {
  1065.       ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; NORMAL GAME OR AUTODRAFT - NO PICKING
  1066.       echo -ag NORMAL GAME -> GIVE 'EM SOME STUPID MESSAGE
  1067.       describe %ch Team Sentinel: $get.usernamelist(%c.playersent)
  1068.       describe %ch Team Scourge: $get.usernamelist(%c.playerscrg)
  1069.       describe %ch Game mode is - $+ $get.gamemode(%c.gamemode) $+ ; Game name is $get.gamename(%c.gamemode,%gamenum) $+ ; Map version is %c.gameversion $+ ; Use .teams and .heroes to get a reminder on the line-ups
  1070.       set %gamelist $addtok(%gamelist,%gamenum,46)
  1071.       set %game.mode_ $+ %gamenum %c.gamemode
  1072.       set %game.version_ $+ %gamenum %c.gameversion
  1073.       set %game.date_ $+ %gamenum $ctime
  1074.       set %game.auths_ $+ %gamenum %c.playersent $+ . $+ %c.playerscrg
  1075.       set %game.chall_ $+ %gamenum %c.challenge
  1076.  
  1077.       var %i = 1
  1078.       var %g = $($+(%,game.auths_,%gamenum),2)
  1079.       while (%i <= 10) {
  1080.         set %player.game_ $+ $gettok(%g,%i,46) %gamenum
  1081.         inc %i
  1082.       }
  1083.  
  1084.       ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; AUTO DRAFT
  1085.       if (%c.gamemode == AutoDraft) {
  1086.         echo -ag HERO AUTODRAFT -> PICK MOST PICKED HEROES
  1087.         autodraft
  1088.       }
  1089.       ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  1090.  
  1091.       set %game.on 0
  1092.       unset %c.gameauths
  1093.       set %c.challenge 0
  1094.       set %canreply 1
  1095.       timergamestart off
  1096.       mode %ch -m
  1097.       topic %ch $topicwelcome $topicgames
  1098.       if (!$timer(spamcensure)) { timerspamcensure 1 120 spam.censure }
  1099.       ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  1100.     }
  1101.     else {
  1102.       ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; DRAFT - ENABLE PICKING
  1103.       echo -ag HERO DRAFT -> SET PICKERS AND ENABLE HERO PICKING
  1104.       set %game.mode_ $+ %gamenum %c.gamemode
  1105.       set %game.version_ $+ %gamenum %c.gameversion
  1106.       set %game.auths_ $+ %gamenum %c.playersent $+ . $+ %c.playerscrg
  1107.       set %game.date_ $+ %gamenum 1
  1108.       set %game.chall_ $+ %gamenum %c.challenge
  1109.       set %canpickhero 1
  1110.       set %canpickplayer 0
  1111.       unset %c.herosent
  1112.       unset %c.heroscrg
  1113.       if ( $r(1,2) == 1 ) {
  1114.         set %c.picker1 $gettok(%c.playersent,1,46)
  1115.         set %c.picker2 $gettok(%c.playerscrg,1,46)
  1116.         set %c.first sent
  1117.       }
  1118.       else  {
  1119.         set %c.picker1 $gettok(%c.playerscrg,1,46)
  1120.         set %c.picker2 $gettok(%c.playersent,1,46)
  1121.         set %c.first scrg
  1122.       }
  1123.       set %c.gameheropool
  1124.       while ( $numtok(%c.gameheropool,46) != 20 ) {
  1125.         set %c.gameheropool $addtok(%c.gameheropool,$($+(%,hero_,$r(1,90)),2),46)
  1126.       }
  1127.       var %i = 1
  1128.       while ( %i <= 20 ) {
  1129.         AddHero.pool $gettok(%c.gameheropool,%i,46)
  1130.         inc %i
  1131.       }
  1132.       mode %ch -m
  1133.       describe %ch Team Sentinel: $get.usernamelist(%c.playersent)
  1134.       describe %ch Team Scourge: $get.usernamelist(%c.playerscrg)
  1135.       describe %ch Game mode is - $+ $get.gamemode(%c.gamemode) $+ ; Game name is $get.gamename(%c.gamemode,%gamenum) $+ ; Map version is %c.gameversion $+ ; Hero draft starts now, $getname(%c.picker1) has 90 seconds to pick a hero.
  1136.       describe %ch Heroes available: $get.heroliste(%c.gameheropool)
  1137.       timergamestart off
  1138.       timerheropick 1 90 pick.pickhero random
  1139.       timerheropickre 1 70 pick.notify
  1140.       ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  1141.     }
  1142.   }
  1143.   inc %c.challpickround
  1144. }
  1145.  
  1146. alias pick.qs.GetHero {
  1147.   var %n = $findtok(%c.gameplayerpool,$1,1,46)
  1148.   set %c.lastheropos %n
  1149.   return $gettok(%c.gameheroplayerpool,%n,46)
  1150. }
  1151.  
  1152. alias pick.qs.pickplayer {
  1153.   if (!$1) { return }
  1154.   var %u = $getid($1)
  1155.   var %hero = $pick.qs.GetHero(%u)
  1156.   if (!$istok(%c.gameplayerpool,%u,46)) { return }
  1157.   var %who = $pick.whopick(%c.challpickround)
  1158.   if (%who == 1) {
  1159.     if ( %c.first == sent ) {
  1160.       set %c.playersent $addtok(%c.playersent,%u,46)
  1161.       set %c.herosent $addtok(%c.herosent,%hero,46)
  1162.     }
  1163.     else {
  1164.       set %c.playerscrg $addtok(%c.playerscrg,%u,46)
  1165.       set %c.heroscrg $addtok(%c.heroscrg,%hero,46)
  1166.     }
  1167.   }
  1168.   elseif (%who == 2) {
  1169.     if ( %c.first == sent ) {
  1170.       set %c.playerscrg $addtok(%c.playerscrg,%u,46)
  1171.       set %c.heroscrg $addtok(%c.heroscrg,%hero,46)
  1172.     }
  1173.     else {
  1174.       set %c.playersent $addtok(%c.playersent,%u,46)
  1175.       set %c.herosent $addtok(%c.herosent,%hero,46)
  1176.     }
  1177.   }
  1178.   mode %ch +v $nauth(%u)
  1179.   set %c.gameplayerpool $remtok(%c.gameplayerpool,%u,1,46)
  1180.   set %c.gameheroplayerpool $deltok(%c.gameheroplayerpool,%c.lastheropos,46)
  1181.   if (%c.challpickround < 10 ) {
  1182.     describe %ch $getname($($+(%,c.picker,%who),2)) picked $getname(%u) $+ $enclose(%hero) $+ ; $getname($($+(%,c.picker,$pick.whopick($calc( %c.challpickround + 1))),2)) $+ 's turn to pick
  1183.   }
  1184.   else {
  1185.     ;describe %ch $($+(%,c.picker,%who),2) picked $getname(%u) $+ $enclose(%hero) $+ ;
  1186.     describe %ch Team Sentinel: $get.usernamelistqs(%c.playersent,%c.herosent)
  1187.     describe %ch Team Scourge: $get.usernamelistqs(%c.playerscrg,%c.heroscrg)
  1188.     describe %ch Game mode is - $+ $get.gamemode(%c.gamemode) $+ ; Game name is $get.gamename(%c.gamemode,%gamenum) $+ ; Map version is %c.gameversion $+ ; Use .teams and .heroes to get a reminder on the line-ups
  1189.     set %gamelist $addtok(%gamelist,%gamenum,46)
  1190.     set %game.date_ $+ %gamenum $ctime
  1191.     set %game.heroes_ $+ %gamenum %c.herosent $+ . $+ %c.heroscrg
  1192.     set %game.mode_ $+ %gamenum %c.gamemode
  1193.     set %game.version_ $+ %gamenum %c.gameversion
  1194.     set %game.auths_ $+ %gamenum %c.playersent $+ . $+ %c.playerscrg
  1195.     set %game.chall_ $+ %gamenum %c.challenge
  1196.     set %game.on 0
  1197.     var %i = 1
  1198.     while (%i <= 5) {
  1199.       AddHero.picked $gettok(%c.herosent,%i,46)
  1200.       AddHero.picked $gettok(%c.heroscrg,%i,46)
  1201.       inc %i
  1202.     }
  1203.     var %i = 1
  1204.     var %ga = $($+(%,game.auths_,%gamenum),2)
  1205.     while (%i <= 10) {
  1206.       set %player.game_ $+ $gettok(%ga,%i,46) %gamenum
  1207.       inc %i
  1208.     }
  1209.     unset %c.gameauths
  1210.     unset %c.herosent
  1211.     unset %c.heroscrg
  1212.     unset %c.gameheropool
  1213.     unset %c.gameherocptpool
  1214.     unset %c.gameheroplayerpool
  1215.     unset %c.repicked
  1216.     set %canpickhero 0
  1217.     set %canpickplayer 0
  1218.     set %c.quickstartcptpick 0
  1219.     set %c.quickstartplayerpick 0
  1220.     set %canreply 1
  1221.     set %c.challenge 0
  1222.     timer 1 3 topic %ch $topicwelcome $topicgames
  1223.     if (!$timer(spamcensure)) { timerspamcensure 1 120 spam.censure }
  1224.   }
  1225.   inc %c.challpickround
  1226. }
  1227.  
  1228. alias flush.repick {
  1229.   if (%line.repick) {
  1230.     describe %ch %line.repick
  1231.   }
  1232. }
  1233.  
  1234. on *:TEXT:.repick:%ch: {
  1235.   var %u = $getid2($nick)
  1236.   if (!$istok(%c.gameplayerpool,%u,46)) { return }
  1237.   if (!$timer(canrepick)) { return }
  1238.   if ($istok(%c.repicked,%u,46)) { return }
  1239.   var %l = $numtok(%c.gameheropool,46)
  1240.   var %l = $calc( %l + 1 )
  1241.   while ( $numtok(%c.gameheropool,46) != %l ) {
  1242.     set %c.gameheropool $addtok(%c.gameheropool,$($+(%,hero_,$r(1,90)),2),46)
  1243.   }
  1244.   var %n = $findtok(%c.gameplayerpool,%u,1,46)
  1245.   var %oldhero = $gettok(%c.gameheroplayerpool,%n,46)
  1246.   var %newhero = $gettok(%c.gameheropool,%l,46)
  1247.   set %c.repicked $addtok(%c.repicked,%u,46)
  1248.   set %c.gameheroplayerpool $puttok(%c.gameheroplayerpool,%newhero,%n,46)
  1249.   ;describe %ch Player $getname(%u) has repicked %oldhero into %newhero
  1250.   if ($timer(spamrepick)) {
  1251.     set %line.repick %line.repick Player $getname(%u) has repicked %oldhero into %newhero $+ ;
  1252.   }
  1253.   else {
  1254.     describe %ch Player $getname(%u) has repicked %oldhero into %newhero $+ ;
  1255.     set %line.repick $null
  1256.     timerspamrepick 1 7 flush.repick
  1257.   }
  1258. }
  1259.  
  1260.  
  1261. on *:TEXT:.pick*:%ch: {
  1262.   ;if ((!%canpickhero) || (!%canpickplayer)) { return }
  1263.   var %u = $getid2($nick)
  1264.   if ((%u != %c.picker1) && (%u != %c.picker2)) { return }
  1265.   if (%canpickhero) {
  1266.     if ( %u != $($+(%,c.picker,$pick.whopick($pick.round)),2)) { notice $nick It's not your turn | return }
  1267.     pick.pickhero $2-
  1268.   }
  1269.   elseif (%canpickplayer) {
  1270.     if ( %u != $($+(%,c.picker,$pick.whopick(%c.challpickround)),2)) { notice $nick It's not your turn | return }
  1271.     pick.pickplayer $2
  1272.   }
  1273.   elseif (%c.QuickStartCptPick) {
  1274.     if ( %u != $($+(%,c.picker,$pick.whopick(%c.challpickround)),2)) { notice $nick It's not your turn | return }
  1275.     echo -ag ok
  1276.     pick.qs.pickhero $2-
  1277.   }
  1278.   elseif (%c.QuickStartPlayerPick) {
  1279.     if ( %u != $($+(%,c.picker,$pick.whopick(%c.challpickround)),2)) { notice $nick It's not your turn | return }
  1280.     echo -ag ok
  1281.     pick.qs.pickplayer $2
  1282.   }
  1283. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement