Advertisement
Guest User

Multirpg

a guest
Apr 8th, 2016
364
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
TCL 30.15 KB | None | 0 0
  1. #You could move the following settings to the botconfig
  2. #In order to make sure you are not putting stuff to the wrong bot, add the bot as user to your bot,
  3. #and update idlereap(bot) to reflect the gamebots user handle in the bot
  4. set idlereap(user) "Marlie"
  5. set idlereap(pass) "8428424248284"
  6. set idlereap(bot)  "multirpg"
  7. set idlereap(defaultalign) "priest"
  8. set idlereap(bankkeep) 200
  9. set idlereap(teamid) 232
  10. #---------------
  11. package require http
  12. namespace path {::tcl::mathop ::tcl::mathfunc}
  13.  
  14. bind join - * idlereap:join
  15. proc idlereap:join {nick host hand chan} {
  16.     global idlereap
  17. #   if {[isbotnick $nick] && [hand2nick $idlereap(bot) ] != ""} {
  18. #       dotimer 5 idlereap:login
  19. #   } elseif {$hand == $idlereap(bot)} {
  20.         idlereap:login
  21. #   }
  22. }
  23.  
  24. #Sp00kie, with his level 9 Hero [2090/3195][2320/3546] has attacked a Skeleton [684/800] and killed it! 0 days, 00:32:53 is removed from Sp00kie's clock. Sp00kie reaches level 40 in 0 days, 14:04:19
  25. bind pubm - *attacked* idlereap:pubm:attackstats
  26. proc idlereap:pubm:attackstats {nick host hand chan args} {
  27.     global idlereap
  28. #   if {$hand != $idlereap(bot)} { return 0 }
  29.     set args [stripcodes bcuarg [lindex $args 0]]
  30.     set offset [+ [lsearch -exact $args "attacked"] 1]
  31.     set creep [lindex $args [+ $offset 1]]
  32.     set roll [str2int [lindex [split [lindex $args [+ $offset 2]] /] 0]]
  33.     lappend idlereap(stats,$creep) $roll
  34. #   dotimer 1 "idlereap:send RAWSTATS2"
  35. }
  36.  
  37. #Moonlander found 139 gold pieces in Skeleton's hands. Moonlander picks them up and now sums 181 total gold.
  38. bind pubm - *hands* idlereap:pubm:payoutstats
  39. proc idlereap:pubm:payoutstats {nick host hand chan args} {
  40.     global idlereap
  41. #   if {$hand != $idlereap(bot)} { return 0 }
  42.     set args [stripcodes bcuarg [lindex $args 0]]
  43.     set offset [+ [lsearch -exact $args "found"] 1]
  44.     set creep [lindex $args [+ $offset 4]]
  45.     set payout [lindex $args $offset]
  46.     set creep [string range $creep 0 [- [string length $creep] 3]]
  47.     lappend idlereap(stats,$creep,payout) $payout
  48. }
  49.  
  50. #I-Know, with his/her level 9 Hero [2768/4480][3072/4973] has tried to slay a Medusa [779/3577] and killed it! 1 day, 02:44:02 is removed from I-Know's clock. I-Know reaches level 52 in 10 days, 00:36:22.
  51. bind pubm - *slay* idlereap:pubm:slaystats
  52. proc idlereap:pubm:slaystats {nick host hand chan args} {
  53.     global idlereap
  54. #   if {$hand != $idlereap(bot)} { return 0 }
  55.     set args [stripcodes bcuarg [lindex $args 0]]
  56.     set offset [+ [lsearch -exact $args "slay"] 2]
  57.     set creep [lindex $args $offset]
  58.     set roll [str2int [lindex [split [lindex $args [+ $offset 1]] /] 0]]
  59.     lappend idlereap(stats,$creep) $roll
  60. #dotimer 1 "idlereap:send RAWSTATS2"
  61. }
  62.  
  63. #I-Know found 153 gold pieces in Medusa's treasure chest. I-Know picks them up and now sums 224 total gold.
  64. bind pubm - *chest* idlereap:pubm:slaypayout
  65. proc idlereap:pubm:slaypayout {nick host hand chan args} {
  66.     global idlereap
  67. #   if {$hand != $idlereap(bot)} { return 0 }
  68.     set args [stripcodes bcuarg [lindex $args 0]]
  69.     set offset [+ [lsearch -exact $args "found"] 1]
  70.     set creep [lindex $args [+ $offset 4]]
  71.     set payout [lindex $args $offset]
  72.     set creep [string range $creep 0 [- [string length $creep] 3]]
  73.     lappend idlereap(stats,$creep,payout) $payout
  74. }
  75.  
  76. bind pubm - * idlereap:pubm
  77. proc idlereap:pubm {nick host hand chan args} {
  78.     global idlereap
  79.     if {$hand != $idlereap(bot)} { return 0 }
  80.     set args [stripcodes bcuarg [lindex $args 0]]
  81.  
  82.     #IdleReap, the level 3 The Scripted One, is now online from ScaryNet, nickname IdleReap. He reaches level 4 in 0 days, 00:14:37.
  83.     if {[string match "$idlereap(user), the level * is now online from *" $args]} {
  84.         dotimer 1 "idlereap:send RAWSTATS2"
  85.         return
  86.     }
  87.  
  88.     #IdleReap, The Scripted One, has attained level 2! He reaches level 3 in 0 days, 00:13:27.
  89.     if {[string match "$idlereap(user), * has attained level *" $args]} {
  90.         dotimer 1 "idlereap:send RAWSTATS2"
  91.         return
  92.     }
  93.  
  94.  
  95.     #Royal Tournament Round 1, Fight 24: IdleReap [19/347] vs Mientje [127/294] ... Mientje advances and gets 20 gold from IdleReap!
  96.     if {[string match "* advances and gets * from $idlereap(user)!" $args]} {
  97.         if {[info exists idlereap(goldtournament)]} { unset idlereap(goldtournament) }
  98.         if {[info exists idlereap(runningtournament)]} {
  99.             dotimer 1 "idlereap:send RAWSTATS2"
  100.             unset idlereap(runningtournament)
  101.         }
  102.         return
  103.     }
  104.  
  105.     #Low-Level Quick Round 3, Fight 2: bbwoIf [373/1351] vs Zer0n [131/607] ... bbwoIf advances!
  106.     if {[string match "* Round * Fight * ... * advances!" $args] && [string match "*$idlereap(user)*" $args]} {
  107.         if {[lindex $args [llength $args]-2] != $idlereap(user)} {
  108.             if {[info exists idlereap(goldtournament)]} { unset idlereap(goldtournament)}
  109.             if {[info exists idlereap(runningtournament)]} {
  110.                 dotimer 1 "idlereap:send RAWSTATS2"
  111.                 unset idlereap(runningtournament)
  112.             }
  113.         }
  114.         return
  115.     }
  116.    
  117.     #s0lid_ found 1858 gold pieces in Sphinx's treasure chest. s0lid_ picks them up and now sums 2330 total gold.
  118.     if {[string match "$idlereap(user) found * gold pieces*" $args]} {
  119.         dotimer 10 "idlereap:send RAWSTATS2"
  120.         return
  121.     }
  122.  
  123.         #The Royal Tournament is starting!
  124.         if {[string match "The * is starting!" $args]} {
  125.                 set idlereap(runningtournament) 1
  126.         }
  127.  
  128.         #The Gold Tournament is finished. Congrats RadioWest!
  129.         if {[string match "The * is finished.*" $args]} {
  130.                 if {[info exists idlereap(goldtournament)]} { unset idlereap(goldtournament) }
  131.                 if {[info exists idlereap(runningtournament)]} {
  132.                         dotimer 1 "idlereap:send RAWSTATS2"
  133.                         unset idlereap(runningtournament)
  134.                 }
  135.                 idlereap:gettournamenttimers
  136.                 return
  137.         }
  138. }
  139.  
  140. bind msgm - * idlereap:msgm
  141. proc idlereap:msgm {nick host hand args} {
  142.     global idlereap
  143. #   if {$hand != $idlereap(bot)} { return 0 }
  144.     set args [stripcodes bcuarg [lindex $args 0]]
  145.   #You are not logged in
  146.     if {[string match "You are not logged in." $args]} {
  147.         idlereap:login
  148.     }  
  149.     #You have deposited 577 gold into the bank.
  150.     if {[string match "You have deposited * gold into the bank." $args]} {
  151.         set amount [lindex $args 3]
  152.         if {[info exists idlereap(bank)]} {
  153.             incr idlereap(bank) $amount
  154.         } else {
  155.             set idlereap(bank) $amount
  156.         }
  157.         incr idlereap(gold) -$amount
  158.         return
  159.     }
  160.  
  161.     #You have withdrawn 146 gold from the bank
  162.     if {[string match "You have withdrawn * gold from the bank." $args]} {
  163.         set amount [lindex $args 3]
  164.  
  165.         if {[info exists idlereap(bank)]} {
  166.             incr idlereap(bank) -$amount
  167.         } else {
  168.             set idlereap(bank) 0
  169.         }
  170.         incr idlereap(gold) $amount
  171.  
  172.         if {[info exists idlereap(goldtournament)]} { return }
  173.         if {$idlereap(level) < 15} { return }
  174.  
  175.         if {$idlereap(gold) >= $idlereap(bankkeep) && $idlereap(bets) < 5 && $idlereap(level) >= 30} {
  176.             idlereap:dobet [- 5 $idlereap(bets)]
  177.             return
  178.         }
  179.  
  180.         for {set i 0} {$i < 100} {incr i} {
  181.             if {$idlereap(gold) >= 1000} {
  182.                 if {$idlereap(engineer) == 0} {
  183.                     idlereap:send "HIRE engineer"
  184.                     incr idlereap(gold) -1000
  185.                     set idlereap(engineer) 1
  186.                     continue
  187.                 }
  188.                 if {$idlereap(hero) == 0 && $idlereap(engineer) == 1} {
  189.                     idlereap:send "SUMMON hero"
  190.                     incr idlereap(gold) -1000
  191.                     set idlereap(hero) 1
  192.                     continue
  193.                 }
  194.             }
  195.             if {$idlereap(gold) >= 200} {
  196.                 if {$idlereap(engineer,level) < 9 && $idlereap(engineer) == 1} {
  197.                     idlereap:send "ENGINEER level"
  198.                     incr idlereap(gold) -200
  199.                     incr idlereap(engineer,level)
  200.                     continue
  201.                 }
  202.                 if {$idlereap(hero,level) < 9 && $idlereap(hero) == 1} {
  203.                     idlereap:send "HERO level"
  204.                     incr idlereap(gold) -200
  205.                     incr idlereap(hero,level)
  206.                     continue
  207.                 }
  208.                 #if {$idlereap(itemsum) >= 10000 && $idlereap(hero,level) == 9 && $idlereap(potion,power) < 2} {
  209.                 #   idlereap:send "BUY power"
  210.                 #   incr idlereap(gold) -200
  211.                 #   incr idlereap(potion,power)
  212.                 #   continue
  213.                 #}
  214.                 #if {$idlereap(itemsum) >= 10000 && $idlereap(hero,level) == 9 && $idlereap(potion,luck) < 2} {
  215.                 #   idlereap:send "BUY luck"
  216.             #   incr idlereap(gold) -200
  217.             #       incr idlereap(potion,luck)
  218.             #       continue
  219.             #   }
  220.             }
  221.             if {$idlereap(engineer) == 1 && $idlereap(engineer,level) == 9} {
  222.                 set items "ring amulet charm weapon helm tunic gloves leggings shield boots"
  223.                 set bought 0
  224.                 foreach item $items {
  225.                     if {![info exists idlereap(item,$item)]} { continue }
  226.                     if {$idlereap(item,$item) >= [* $idlereap(level) 2]} { continue }
  227.    
  228.                     set idiff [- [* $idlereap(level) 2] $idlereap(item,$item)]
  229.                     set imaxbuy [expr floor($idlereap(gold) / 3)]
  230.                     if {$imaxbuy > [* $idlereap(level) 2]} { set imaxbuy [* $idlereap(level) 2] }
  231.                     if {$imaxbuy < $idlereap(item,$item)} { continue }
  232.    
  233.                     set icost_buy [* $imaxbuy 3]
  234.                     set icost_upg [* $idiff 20]
  235.                     if {$icost_upg < $icost_buy && $idlereap(gold) > $icost_buy} {
  236.                         set imaxbuy [expr round($imaxbuy)]
  237.                         idlereap:send "BUY $item $imaxbuy"
  238.                         set idlereap(item,$item) $imaxbuy
  239.                         incr idlereap(gold) -$icost_buy
  240.                         set bought 1
  241.                     }
  242.                 }
  243.                 if {$bought == 1} { continue }
  244.  
  245.                 if {$idlereap(gold) >= 20 && $idlereap(hero,level) == 9} {
  246.                     set lowest ""
  247.                     set lcount 99999999
  248.                     foreach item $items {
  249.                         if {![info exists idlereap(item,$item)]} { continue }
  250.                         if {$idlereap(gold) < 20} { break }
  251.                         if {$idlereap(item,$item) >= [* $idlereap(level) 2] && $idlereap(item,$item) < $lcount} {
  252.                             set lowest $item
  253.                             set lcount $idlereap(item,$item)
  254.                         }
  255.                     }
  256.                     if {$lowest != ""} {
  257.                         set amount [/ $idlereap(gold) 20]
  258.                         if {$amount > 10} { set amount 10 }
  259.                         idlereap:send "UPGRADE $lowest $amount"
  260.                         incr idlereap(item,$lowest) $amount
  261.                         incr idlereap(itemsum) $amount
  262.                         incr idlereap(gold) -[* $amount 20]
  263.                     }
  264.                 }
  265.             }
  266.         }
  267.  
  268.         if {$idlereap(gold) > 0} { idlereap:send "BANK deposit all" }
  269.         return
  270.     }
  271.  
  272.     #You have 59 gold in the bank, and are carrying 300 gold.
  273.     if {[string match "You have * gold in the bank, and are carrying * gold." $args]} {
  274.         dccbroadcast $args
  275.         return
  276.     }
  277.     #if {[string match "You have been invited to team *" $args]} {
  278.     #idlereap:send "team join 242"
  279.     #}
  280.     if {[string match "level *" $args]} {
  281.         set idlereap(level) [str2int [lindex $args [lsearch -exact $args "level"]+1]]
  282.         set idlereap(gold) [str2int [lindex $args [lsearch -exact $args "gold"]+1]]
  283.         set idlereap(bank) [str2int [lindex $args [lsearch -exact $args "bank"]+1]]
  284.         set idlereap(itemsum) [str2int [lindex $args [lsearch -exact $args "sum"]+1]]
  285.         set idlereap(item,ring) [str2int [lindex $args [lsearch -exact $args "ring"]+1]]
  286.         set idlereap(item,amulet) [str2int [lindex $args [lsearch -exact $args "amulet"]+1]]
  287.         set idlereap(item,charm) [str2int [lindex $args [lsearch -exact $args "charm"]+1]]
  288.         set idlereap(item,weapon) [str2int [lindex $args [lsearch -exact $args "weapon"]+1]]
  289.         set idlereap(item,helm) [str2int [lindex $args [lsearch -exact $args "helm"]+1]]
  290.         set idlereap(item,tunic) [str2int [lindex $args [lsearch -exact $args "tunic"]+1]]
  291.         set idlereap(item,gloves) [str2int [lindex $args [lsearch -exact $args "gloves"]+1]]
  292.         set idlereap(item,leggings) [str2int [lindex $args [lsearch -exact $args "leggings"]+1]]
  293.         set idlereap(item,shield) [str2int [lindex $args [lsearch -exact $args "shield"]+1]]
  294.         set idlereap(item,boots) [str2int [lindex $args [lsearch -exact $args "boots"]+1]]
  295.         set idlereap(potion,power) [str2int [lindex $args [lsearch -exact $args "powerpots"]+1]]
  296.         set idlereap(potion,luck) [str2int [lindex $args [lsearch -exact $args "luckpots"]+1]]
  297.         set idlereap(fights) [str2int [lindex $args [lsearch -exact $args "fights"]+1]]
  298.         set idlereap(bets) [str2int [lindex $args [lsearch -exact $args "bets"]+1]]
  299.         set idlereap(hero) [str2int [lindex $args [lsearch -exact $args "hero"]+1]]
  300.         set idlereap(hero,level) [str2int [lindex $args [lsearch -exact $args "hlevel"]+1]]
  301.         set idlereap(engineer) [str2int [lindex $args [lsearch -exact $args "engineer"]+1]]
  302.         set idlereap(engineer,level) [str2int [lindex $args [lsearch -exact $args "englevel"]+1]]
  303.  
  304.         set align [lindex $args [lsearch -exact $args "align"]+1]
  305.         switch -- $align {
  306.             "g" { set idlereap(align) "priest" }
  307.             "n" { set idlereap(align) "human" }
  308.             "e" { set idlereap(align) "undead" }
  309.         }
  310.  
  311.         if {$idlereap(bets) < 5 && $idlereap(level) >= 30 && $idlereap(gold) >= $idlereap(bankkeep)} {
  312.             idlereap:dobet [- 5 $idlereap(bets)]
  313.             return
  314.         }
  315.  
  316.         set attack [str2int [lindex $args [lsearch -exact $args "attackttl"]+1]]
  317.                 if {$idlereap(level) >= 10} {
  318.                         dotimer [+ $attack 10] idlereap:doattack
  319.                 }
  320.  
  321.         set slay [str2int [lindex $args [lsearch -exact $args "slayttl"]+1]]
  322.                 if {$idlereap(level) >= 40} {
  323.                         dotimer [+ $slay 10] idlereap:doslay
  324.                 }
  325.  
  326.         set challenge [str2int [lindex $args [lsearch -exact $args "challengettl"]+1]]
  327.                 if {$idlereap(level) >= 35} {
  328.                         dotimer [+ $challenge 10] "idlereap:send CHALLENGE"
  329.                 }
  330.  
  331.         set idlereap(ttl) [str2int [lindex $args [lsearch -exact $args "ttl"]+1]]
  332.         if {$idlereap(ttl) > 30} {
  333.             dotimer [- $idlereap(ttl) 30] "idlereap:align priest"
  334.         } elseif {$idlereap(ttl) > 120} {
  335.             idlereap:align
  336.         }
  337.  
  338.         if {$idlereap(level) < 15} {
  339.             if {$idlereap(gold) > 0 && ![info exists idlereap(goldtournament)]} {
  340.                 idlereap:send "BANK deposit all"
  341.             }
  342.         } else {
  343.             set sum [+ [- $idlereap(bank) $idlereap(bankkeep)] $idlereap(gold)]
  344.             set withdraw 0
  345.  
  346.             if {$idlereap(level)>=30 && [info exists idlereap(bets)] && $idlereap(bets)<5 && $sum >= $idlereap(bankkeep) && $idlereap(gold) < $idlereap(bankkeep)} {
  347.                 idlereap:send "BANK withdraw [- $idlereap(bankkeep) $idlereap(gold)]"
  348.                 return
  349.             } elseif {$idlereap(engineer) == 0 && $sum >= [expr ($idlereap(level)<29?1000:1100)]} {
  350.                 set withdraw 1
  351.             } elseif {$idlereap(engineer) == 1 && $idlereap(engineer,level) < 10 && $sum >= [expr ($idlereap(level)<29?200:100)]} {
  352.                 set withdraw 1
  353.             }
  354.  
  355.             if {$idlereap(hero) == 0 && $idlereap(itemsum) > 1000 && $idlereap(level) >= 30 && $sum < 1100} {
  356.                 set withdraw 0
  357.             }
  358.  
  359.             if {$idlereap(bank) > [expr ($idlereap(level)<29?0:100)] && $withdraw == 1} {
  360.                 idlereap:send "BANK withdraw [expr $idlereap(bank) - ($idlereap(level)<29?0:100)]"
  361.             } elseif { $idlereap(gold) > 0 && ![info exists idlereap(goldtournament)]} {
  362.                 idlereap:send "BANK deposit all"
  363.             }
  364.         }
  365.  
  366.         if {$idlereap(fights) < 5 && $idlereap(level) >= 10} {
  367.             idlereap:dofight [- 5 $idlereap(fights)]
  368.         }
  369.         return
  370.     }
  371. }
  372.  
  373. bind notc - * idlereap:notc
  374. proc idlereap:notc {nick host hand args {dest ""}} {
  375.     global idlereap botnick
  376. #   if {$hand != $idlereap(bot)} { return 0 }
  377.     if {$dest == ""} { set dest $botnick }
  378.     set args [stripcodes bcuarg $args]
  379.  
  380.     #Logon successful. You reach level 4 in 0 days, 00:14:37.
  381.     if {[string match "Logon successful. You reach level *" $args]} {
  382.         set idlereap(nextlevel) [lrange $args 7 e]
  383.         return
  384.     }
  385. # You can attack again in
  386.  if {[string match "You can * again in *" $args]} {
  387.                 idlereap:send RAWSTATS2
  388.         }
  389.     #Sorry, no such account name. Note that account names are case sensitive.
  390.     if {[string match "Sorry, no such account name. Note that account names are case sensitive." $args]} {
  391.         idlereap:send "REGISTER $idlereap(user) $idlereap(pass) Dark Monk"
  392.     }
  393. }
  394.  
  395. proc idlereap:doattack {} {
  396.     global idlereap
  397.     set creeps "Bush Locust Spider Goblin Lich Skeleton Ghost Shadow Troll Cyclop Mutant Monkey Phoenix Minotaur Beholder"
  398.     #set target [idlereap:creepfinder $creeps]
  399.     #set target [idlereap:creepfinder "Bush Locust Spider Goblin Lich Skeleton Ghost Shadow Troll Cyclop Mutant Monkey Phoenix Minotaur Beholder"]
  400.     set target ""
  401.  
  402.     if {$target == ""} {
  403.         set target "Bush"
  404.         if {$idlereap(level) >  10} { set target "Locust" }
  405.         if {$idlereap(level) >= 15} { set target "Spider" }
  406.         if {$idlereap(level) >= 20} { set target "Goblin" }
  407.         if {$idlereap(level) >= 30} { set target "Lich" }
  408.         if {$idlereap(level) >= 40} { set target "Skeleton" }
  409.         if {$idlereap(level) >= 50} { set target "Ghost" }
  410.         if {$idlereap(itemsum) >= 2200} { set target "Shadow" }
  411.         #if {$idlereap(level) >= 70} { set target "Troll" }
  412.         #if {$idlereap(level) >= 80} { set target "Cyclop" }
  413.         #if {$idlereap(level) >= 90} { set target "Mutant" }
  414.         if {$idlereap(level) >= 70} { set target "Monkey" }
  415.         if {$idlereap(level) >= 110} { set target "Phoenix" }
  416.         if {$idlereap(level) >= 120} { set target "Minotaur" }
  417.         if {$idlereap(level) >= 130} { set target "Beholder" }
  418.     }
  419.  
  420.     idlereap:send "ATTACK $target"
  421. }
  422.  
  423. proc idlereap:doslay {} {
  424.     global idlereap
  425.     set creeps "Medusa Centaur Mammoth Vampire Dragon Sphinx Hippogriff"
  426.     #set target [idlereap:creepfinder $creeps]
  427.     #set target [idlereap:creepfinder "Medusa Centaur Mammoth Vampire Dragon Sphinx Hippogriff"]
  428.     set target "Hippogriff"
  429.     if {$target == "Hippogriff"} {
  430.         if {$idlereap(itemsum) >= 8000} {
  431.             set target "Hippogriff"
  432.         } elseif {$idlereap(itemsum) >= 4000} {
  433.             set target "Sphinx"
  434.         } elseif {$idlereap(itemsum) >= 2000} {
  435.             set target "Dragon"
  436.         } else {
  437.             set target "Centaur"
  438.         }
  439.     }
  440.     idlereap:send "SLAY $target"
  441. }
  442.  
  443. proc idlereap:dofight {{count 5}} {
  444.     global idlereap
  445.     set token [::http::geturl "http://idlerpg.org/rawplayers3.php"]
  446.     if {[::http::ncode $token] != 200} { return }
  447.     set data [::http::data $token]
  448.     ::http::cleanup $token
  449.     set lowest 99999999999
  450.     set victim ""
  451.     set vlevel 0
  452.     set valign ""
  453.  
  454.     set refsum $idlereap(itemsum)
  455.     #if {$idlereap(hero,level) > 0} {
  456.     #   set refsum [+ $refsum [* [/ $refsum 100] [+ 2 $idlereap(hero,level)]]]
  457.     #}
  458.  
  459.     foreach data [split $data "\n"] {
  460.         set char [lindex $data [lsearch -exact $data "char"]+1]
  461.         set level [lindex $data [lsearch -exact $data "level"]+1]
  462.         set online [lindex $data [lsearch -exact $data "online"]+1]
  463.         set team [lindex $data [lsearch -exact $data "team"]+1]
  464.         if {$level < $idlereap(level) || $online == "0"} { continue }
  465.         if {$char == $idlereap(user)} { continue }
  466.         if {$team == $idlereap(teamid)} { continue }
  467.  
  468.         set itemsum [str2int [lindex $data [lsearch -exact $data "amulet"]+1]]
  469.         incr itemsum [str2int [lindex $data [lsearch -exact $data "charm"]+1]]
  470.         incr itemsum [str2int [lindex $data [lsearch -exact $data "helm"]+1]]
  471.         incr itemsum [str2int [lindex $data [lsearch -exact $data "boots"]+1]]
  472.         incr itemsum [str2int [lindex $data [lsearch -exact $data "gloves"]+1]]
  473.         incr itemsum [str2int [lindex $data [lsearch -exact $data "ring"]+1]]
  474.         incr itemsum [str2int [lindex $data [lsearch -exact $data "leggings"]+1]]
  475.         incr itemsum [str2int [lindex $data [lsearch -exact $data "shield"]+1]]
  476.         incr itemsum [str2int [lindex $data [lsearch -exact $data "tunic"]+1]]
  477.         incr itemsum [str2int [lindex $data [lsearch -exact $data "weapon"]+1]]
  478.  
  479.         set tmpsum $itemsum
  480.         if {[str2int [lindex $data [lsearch -exact $data "powerpots"]+1]]>0} {
  481.             set itemsum [+ $itemsum [/ $tmpsum 10]]
  482.         }
  483.         if {[str2int [lindex $data [lsearch -exact $data "luckpots"]+1]]>0} {
  484.             set itemsum [+ $itemsum [/ $tmpsum 10]]
  485.         }
  486.         if {[str2int [lindex $data [lsearch -exact $data "hero"]+1]]>0} {
  487.             set hlevel [+ 2 [str2int [lindex $data [lsearch -exact $data "hlevel"]+1]]]
  488.             set itemsum [+ $itemsum [* [/ $tmpsum 100] $hlevel]]
  489.         }
  490.         set align [lindex $data [lsearch -exact $data "align"]]
  491.         if {$align == "g"} {
  492.             set itemsum [+ $itemsum [/ $tmpsum 10]]
  493.         }
  494.         if {$align == "u"} {
  495.             set itemsum [+ $itemsum [/ $tmpsum 10]]
  496.         }
  497.  
  498. #       if {$refsum < $itemsum} {continue}
  499.        
  500.         if {$itemsum < $lowest} {
  501.             set lowest $itemsum
  502.             set victim $char
  503.             set vlevel $level
  504.             set valign $align
  505.         }
  506.     }
  507.  
  508.     if {$victim != ""} {
  509.         dccbroadcast "Fighting $victim \[L$vlevel:S$lowest:A$valign\]"
  510.         if {$valign == "e"} {
  511.             idlereap:align human
  512.         } elseif {$valign == "g"} {
  513.             idlereap:align undead
  514.         } else {
  515.             idlereap:align priest
  516.         }
  517.         for {set i 0} {$i < $count} {incr i} {
  518.             idlereap:send "FIGHT $victim"
  519.             incr idlereap(fights)
  520.         }
  521.     } else {
  522.         dccbroadcast "No victim found to fight ?!?!?"
  523.     }
  524.     idlereap:align
  525. }
  526.  
  527. proc idlereap:gettournamenttimers {} {
  528.     global idlereap
  529.     set token [::http::geturl "http://idlerpg.org/timers.php"]
  530.     if {[::http::ncode $token] != 200} { return }
  531.     set datahttp [::http::data $token]
  532.     ::http::cleanup $token
  533.     foreach data [split $datahttp "\n"] {
  534.         if {[string match "*displayTimer('*',*);*" $data] && ![string match "*setTimeout*" $data]} {
  535.             regsub -all -- "'" [string range [string trim $data] 14 [expr [string length [string trim $data]] -3]] "" usable
  536.             set tdata [split $usable ,]
  537.             set ttype [lindex $tdata 0]
  538.             if {$ttype == "rt" && $idlereap(level) < 16} { continue }
  539.             if {$ttype == "dm" && $idlereap(level) < 16} { continue }
  540.             if {$ttype == "it" && $idlereap(level) < 25} { continue }
  541.             if {$ttype == "lr1" && $idlereap(level) < 5} { continue }
  542.             if {$ttype == "lr2" && $idlereap(level) < 5} { continue }
  543.             if {$ttype == "gt" && $idlereap(level) < 20} { continue }
  544.             if {$ttype == "cl" && $idlereap(level) < 40} { continue }
  545.             if {$ttype == "cl" || $ttype =="rt" || $ttype == "dm" || $ttype == "gt"} {
  546.                 set remain [expr [lindex $tdata 1] - [unixtime] - 10]
  547.                 if {$remain > 0} {
  548.                     dotimer $remain "idlereap:preparetournament $ttype"
  549.                 }
  550.             }
  551.         }
  552.     }
  553. }
  554.  
  555. proc idlereap:preparetournament {type} {
  556.     global idlereap
  557.     if {$type == "cl" || $type =="rt" || $type == "dm" || $type == "gt"} {
  558.         if {$idlereap(gold)<20 && $idlereap(bank) >= [expr 20 - $idlereap(gold)]} {
  559.             idlereap:send "BANK withdraw [expr 20 - $idlereap(gold)]"
  560.             set idlereap(goldtournament) 1
  561.         }
  562.     }
  563. }
  564.  
  565. proc idlereap:dobet {{count 5}} {
  566.     global idlereap
  567.     set token [::http::geturl "http://idlerpg.org/rawplayers3.php"]
  568.     if {[::http::ncode $token] != 200} { return }
  569.     set datahttp [::http::data $token]
  570.     ::http::cleanup $token
  571.     set idlereap(players) ""
  572.  
  573.     foreach data [split $datahttp "\n"] {
  574.         set char [lindex $data [lsearch -exact $data "char"]+1]
  575.         set level [lindex $data [lsearch -exact $data "level"]+1]
  576.         set online [lindex $data [lsearch -exact $data "online"]+1]
  577.         if {$online == "0" || $online == "" || $level < 30} { continue }
  578.  
  579.         lappend idlereap(players) $char
  580.         set idlereap($char,level) $level
  581.         set idlereap($char,bdiff) [- [str2int [lindex $data [lsearch -exact $data "bwon"]+1]] [str2int [lindex $data [lsearch -exact $data "blost"]+1]]]
  582.  
  583.         set itemsum [str2int [lindex $data [lsearch -exact $data "amulet"]+1]]
  584.         incr itemsum [str2int [lindex $data [lsearch -exact $data "charm"]+1]]
  585.         incr itemsum [str2int [lindex $data [lsearch -exact $data "helm"]+1]]
  586.         incr itemsum [str2int [lindex $data [lsearch -exact $data "boots"]+1]]
  587.         incr itemsum [str2int [lindex $data [lsearch -exact $data "gloves"]+1]]
  588.         incr itemsum [str2int [lindex $data [lsearch -exact $data "ring"]+1]]
  589.         incr itemsum [str2int [lindex $data [lsearch -exact $data "leggings"]+1]]
  590.         incr itemsum [str2int [lindex $data [lsearch -exact $data "shield"]+1]]
  591.         incr itemsum [str2int [lindex $data [lsearch -exact $data "tunic"]+1]]
  592.         incr itemsum [str2int [lindex $data [lsearch -exact $data "weapon"]+1]]
  593.         set idlereap($char,itemsum) $itemsum
  594.     }
  595.  
  596.     set bestratio 0
  597.     set bestsource ""
  598.     set bestdest ""
  599.  
  600.     set bestratio2 0
  601.     set bestsource2 ""
  602.     set bestdest2 ""
  603.  
  604.     foreach source $idlereap(players) {
  605.         foreach dest $idlereap(players) {
  606.             if {$idlereap($source,level) > $idlereap($dest,level)} { continue }
  607.             if {$idlereap($source,itemsum) < $idlereap($dest,itemsum)} { continue }
  608.             set ratio [/ $idlereap($source,itemsum) [double $idlereap($dest,itemsum)]]
  609.             if {$ratio > $bestratio} {
  610.                 set bestratio2 $bestratio
  611.                 set bestsource2 $bestsource
  612.                 set bestdest2 $bestdest
  613.  
  614.                 set bestratio $ratio
  615.                 set bestsource $source
  616.                 set bestdest $dest 
  617.             }
  618.         }
  619.     }
  620.  
  621.     if {$bestsource == "" || $bestdest == ""} { return }
  622.     putlog "Best bet: $bestsource \[L$idlereap($bestsource,level):S$idlereap($bestsource,itemsum):D$idlereap($bestsource,bdiff)\] vs $bestdest \[L$idlereap($bestdest,level):S$idlereap($bestdest,itemsum):D$idlereap($bestdest,bdiff)\] \($bestratio\)"
  623.     putlog "Best alt: $bestsource2 \[L$idlereap($bestsource2,level):S$idlereap($bestsource2,itemsum):D$idlereap($bestsource2,bdiff)\] vs $bestdest2 \[L$idlereap($bestdest2,level):S$idlereap($bestdest2,itemsum):D$idlereap($bestdest2,bdiff)\] \($bestratio2\)"
  624.  
  625.     if {$count == 0} {return}
  626.  
  627.     if {$idlereap(level) >= 30} {
  628.         if {$idlereap(gold) < 100 && $idlereap(bank) > [expr 100-$idlereap(gold)]} {
  629.             set amount [- 100 $idlereap(gold)]
  630.             idlereap:send "BANK withdraw $amount"
  631.         } elseif {$idlereap(gold) < 100} {
  632.             return
  633.         }
  634.  
  635.         for {set i 0} {$i < $count} {incr i} {
  636.             if {$bestdest2 == ""} {
  637.                 idlereap:send "BET $bestsource $bestdest 100"
  638.             } else {
  639.                 idlereap:send "BET $bestsource2 $bestdest2 100"
  640.             }
  641.             incr idlereap(bets)
  642.         }
  643.         idlereap:send RAWSTATS2
  644.     }
  645. }
  646.  
  647. proc idlereap:creepfinder { creeps } {
  648.     global idlereap
  649.         set payout 0
  650.     set recovery 0
  651.  
  652.         set refsum $idlereap(itemsum)
  653.         if {$idlereap(hero,level) > 0} {
  654.                 set refsum [+ $refsum [* [/ $refsum 100] [+ 2 $idlereap(hero,level)]]]
  655.         }
  656.  
  657.         foreach creep $creeps {
  658.                 switch -- $creep {
  659.                         Bush     { if {$idlereap(level) >=  11} { continue } else { set recovery 1 }}
  660.                         Locust   { if {$idlereap(level) >=  15} { continue } else { set recovery 1 }}
  661.                         Spider   { if {$idlereap(level) >=  20} { continue } else { set recovery 2 }}
  662.                         Goblin   { if {$idlereap(level) >=  30} { continue } else { set recovery 2 }}
  663.                         Lich     { if {$idlereap(level) >=  40} { continue } else { set recovery 2 }}
  664.                         Skeleton { if {$idlereap(level) >=  50} { continue } else { set recovery 2 }}
  665.                         Ghost    { if {$idlereap(level) >=  60} { continue } else { set recovery 2 }}
  666.                         Shadow   { if {$idlereap(level) >=  70} { continue } else { set recovery 2 }}
  667.                         Troll    { if {$idlereap(level) >=  80} { continue } else { set recovery 3 }}
  668.                         Cyclop   { if {$idlereap(level) >=  90} { continue } else { set recovery 3 }}
  669.                         Mutant   { if {$idlereap(level) >=  100} { continue } else { set recovery 3 }}
  670.                         Monkey   { if {$idlereap(level) >=  110} { continue } else { set recovery 3 }}
  671.                         Phoenix  { if {$idlereap(level) >=  120} { continue } else { set recovery 4 }}
  672.                         Minotaur { if {$idlereap(level) >=  130} { continue } else { set recovery 4 }}
  673.                 }
  674.                 if {[info exists idlereap(stats,$creep,payout)] && [info exists idlereap(stats,$creep)]} {
  675.                         set avgroll [/ [+ {*}$idlereap(stats,$creep)] [double [llength $idlereap(stats,$creep)]]]
  676.                         if {$avgroll > [/ $refsum 2]} { continue }
  677.  
  678.                         set payavg [/ [+ {*}$idlereap(stats,$creep,payout)] [double [llength $idlereap(stats,$creep,payout)]]]
  679.             if {$recovery != 0} {
  680.                             set paymax [/ [double $payavg] [* $idlereap(level) $recovery]]
  681.             } else {
  682.                 set paymax $payavg
  683.             }
  684.                         if {$paymax > $payout} {
  685.                                 set target $creep
  686.                                 set payout $payavg
  687.                         }
  688.                 }
  689.         set maxsize 20
  690.         if {[info exists idlereap(stats,$creep)] && [llength $idlereap(stats,$creep)] > $maxsize} {
  691.             set idlereap(stats,$creep) [lrange $idlereap(stats,$creep) [- [llength $idlereap(stats,$creep)] $maxsize] e]
  692.  
  693.         }
  694.         if {[info exists idlereap(stats,$creep,payout)] && [llength $idlereap(stats,$creep,payout)] > $maxsize} {
  695.             set idlereap(stats,$creep,payout) [lrange $idlereap(stats,$creep,payout) [- [llength $idlereap(stats,$creep,payout)] $maxsize] e]
  696.         }
  697.         }
  698.     return $target
  699. }
  700.  
  701. bind dcc n dosend idlereap:dcc:send
  702. proc idlereap:dcc:send {from idx args} {
  703.     set args [lindex $args 0]
  704.     idlereap:send $args
  705.     putallbots "send $args"
  706. }
  707.  
  708. bind dcc n dobank idlereap:dcc:bank
  709. proc idlereap:dcc:bank {from idx args} {
  710.     idlereap:send BANK
  711.     putallbots "bank"
  712. }
  713.  
  714. bind dcc n doupdate idlereap:dcc:doupdate
  715. proc idlereap:dcc:doupdate {from idx args} {
  716.     idlereap:send RAWSTATS2
  717.     putallbots "update"
  718. }
  719.  
  720. bind dcc n rehashall idlereap:dcc:rehashall
  721. proc idlereap:dcc:rehashall {from idx args} {
  722.     putallbots "rehash"
  723.     rehash
  724. }
  725.  
  726. bind dcc - bestbet idlereap:dcc:bestbet
  727. proc idlereap:dcc:bestbet {from idx args} {
  728.     idlereap:dobet 0
  729. }
  730.  
  731. bind dcc - bestattack idlereap:dcc:bestattack
  732. proc idlereap:dcc:bestattack {from idx args} {
  733.     set creeps "Bush Locust Spider Goblin Lich Skeleton Ghost Shadow Troll Cyclop Mutant Monkey Phoenix Minotaur Beholder"
  734.     putlog [idlereap:creepfinder $creeps]
  735. }
  736.  
  737. bind dcc - bestslay idlereap:dcc:bestslay
  738. proc idlereap:dcc:bestslay {from idx args} {
  739.     set creeps "Medusa Centaur Mammoth Vampire Dragon Sphinx Hippogriff"
  740.     putlog [idlereap:creepfinder $creeps]
  741. }
  742.  
  743. bind bot - rehash idlereap:bot
  744. bind bot - login idlereap:bot
  745. bind bot - update idlereap:bot
  746. bind bot - bank idlereap:bot
  747. bind bot - send idlereap:bot
  748.  
  749. proc idlereap:bot {from cmd args} {
  750.     set args [lindex $args 0]
  751.     switch -- $cmd {
  752.         "send" {
  753.             idlereap:send $args
  754.         }
  755.         "rehash" {
  756.             dccbroadcast "Rehashing..."
  757.             rehash
  758.         }
  759.         "login" {
  760.             idlereap:login
  761.         }
  762.         "update" {
  763.             idlereap:send RAWSTATS2
  764.             idlereap:gettournamenttimers
  765.         }
  766.         "bank" {
  767.             idlereap:send BANK
  768.         }
  769.     }
  770. }
  771.  
  772. proc idlereap:login {} {
  773.     global idlereap
  774.     idlereap:send "LOGIN $idlereap(user) $idlereap(pass)"
  775. }
  776.  
  777. proc idlereap:align {{align ""}} {
  778.     global idlereap
  779.     if {$align == ""} { set align $idlereap(defaultalign) }
  780.     if {$idlereap(align) != $align} {
  781.         idlereap:send "ALIGN $align"
  782.         set idlereap(align) $align
  783.     }
  784. }
  785.  
  786. proc idlereap:send {message} {
  787.     global idlereap
  788.     dccbroadcast "Sending $message"
  789. #   putmsg [hand2nick $idlereap(bot)] $message
  790.     putmsg $idlereap(bot) $message
  791. }
  792.  
  793. proc dotimer {time command} {
  794.     foreach utime [utimers] {
  795.         if {[lindex $utime 1] == $command} {
  796.             killutimer [lindex $utime end]
  797.         }
  798.     }
  799.     return [utimer $time $command]
  800. }
  801.  
  802. proc str2int {data} {
  803.     set tmp ""
  804.     for {set i 0} {$i < [string length $data]} { incr i } {
  805.         if {[regexp -nocase "\[0-9\]" [string index $data $i] match]} {
  806.             set tmp "$tmp$match"
  807.         }
  808.     }
  809.     return $tmp
  810. }
  811.  
  812. putlog "Multirpg loaded"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement