; ______________________________________________________ ______________________ ; ; Runescape script ; ______________________________________________________ ______________________ ; ______________________________________________________ ______________________ ; Events on *:text:@skills:#: msg $chan Available skills are: $replace($rune_skills,|,$chr(44)) on *:text:@*:#: { var %skills = overall attack defence strength ranged hitpoints magic fletching thieving crafting cooking firemaking fishing smithing mining prayer runecrafting herblore agility var %query = $remove($1,@) if ($istok(%skills,%query,32)) { if ($2) runescape $chan %query $2- else msg $chan You must specify a player name, ie, $1 $nick } else msg $chan You must specify a valid skill, type @skills to see the skill list } ; ______________________________________________________ ______________________ ; Aliases ;; Function: gets data on runescape ;; Usage: /runescape alias runescape { var %sock = runescape. $+ $ticks hadd -m %sock target $1 hadd %sock query $2 hadd %sock name $3- sockopen %sock ttp://hiscore.runescape.com/lang/en/aff/runescape/hiscorepersonal.ws?user1= 80 } ;; Function: simply writes to the object database, a shortcut for the lazy/uninformed ;; Usage: /rune.add alias rune.add { writeini $shortfn($scriptdirrunedb.ini) $1 $2 $$3 } ;; Function: displays the skills list ;; Usage: $rune_skills alias rune_skills { return overall|attack|defence|strength|range|hitpoints|magic|fletching|thieving|crafting|cooking|firemaking|fishing|s mithing|mining|prayer|runecrafting|herblore|agility } ;; Function: delimits a number with a given character (ie, adds commas to large numbers) ;; Usage: $delimit(,) ;; Comments: is an ASCII representation of a char, as used in $gettok alias delimit { var %regex = (^[-+]?\d+?(?=(?>(?:\d{3})+)(?!\d))|\G\d{3}(?=\d)) .echo -q $regsub($1,m~ %regex ~xg,\1 $+ $chr($2),%regex) return %regex } ;; Function: returns the xp needed at a specified level in runescape ;; Usage: $lvlxp() alias lvlxp { var %A, %B, %C, %i = 1 while (%i <= $1) { %A = $floor($calc(%C / 4)) %B = $floor($calc(%i + 300 * 2^(%i / 7))) %C = $calc(%C + %B) inc %i } return %A } ; ______________________________________________________ ______________________ ; Connection on *:sockopen:runescape.*: { ;; remove spaces from the names and replace them with +'s, for URL encoding var %name = $replace($hget($sockname,name),$chr(32),+) sockwrite -n $sockname GET http://hiscore.runescape.com/lang/en/aff/runescape/hiscorepersonal.ws?user1= $+ sockwrite -n $sockname Host: http://hiscore.runescape.com/lang/en/aff/runescape/hiscorepersonal.html sockwrite -n $sockname Connection: close sockwrite -n $sockname } on *:sockread:runescape.*: { var %temp sockread %temp if (*class=c>** iswm %temp) { hadd $sockname subject $nohtml(%temp) hinc $sockname capture } elseif ($nohtml(%temp)) && ($hget($sockname,capture)) { var %cap = $ifmatch, %subject = $hget($sockname,subject) hadd $sockname %subject $+ $gettok(_rank _level _xp,%cap,32) $nohtml(%temp) if (%cap >= 3) hdel $sockname capture else hinc $sockname capture } } on *:sockclose:runescape.*: { ;; type of query the person is asking for: overall, attack, defence, etc var %query = $hget($sockname,query), %results ;; give overall stats --> list the level for each topic if (%query == overall) { var %i = 1 while ($hfind($sockname,*_level,%i,w)) { ;; get the type and value of each topic (ie, type = attack, value = 99) var %type = $gettok($ifmatch,1,95), %value = $hget($sockname,$ifmatch) ;; concatenate the results %results = %results $+([^B],%type,[^B] %value : inc %i } } ;; give stats for each area (attack,defense,etc) else { ;; find the XP for next level var %level = $hget($sockname,%query $+ _level) var %lvlXP = $lvlxp($calc(%level + 1)) ;; find the current XP var %currentXP = $hget($sockname,%query $+ _xp) ;; find how much XP is needed to advance var %needXP = $calc(%lvlXP - $remove(%currentXP,$chr(44))) ;; format the 'stats' part of the message var %stats = [^B]Rank:[^B] $hget($sockname,%query $+ _rank) : [^B]Level:[^B] $hget($sockname,%query $+ _level) : [^B]XP:[^B] %currentXP : [^B]XP required to level:[^B] $delimit(%needXP,44) ;; format and add the 'objects' part of the message var %i = 1, %objects, %file = $shortfn($scriptdirrunedb.ini) ;; cycle through the available objects for the skill in question while ($ini(%file,%query,%i)) { var %object = $ifmatch, %xp = $readini(%file,%query,$ifmatch) if (%xp) %objects = %objects $+([^B],%object,[^B] $floor($calc(%needxp / %xp)) inc %i ;; damned 'smithing' skill requires two lists of objects: smelt, and smith+smelt if (%query == smithing) && (%i > $ini(%file,%query,0)) var %objects = [^B][Smelt][^B] %objects [^B][Smith + Smelt][^B], %query = smelt, %i = 1 } ;; set query back to smithing if (%query == smelt) %query = smithing ;; combine the two var %results = %stats :: %objects } ;; message the results to the target msg $hget($sockname,target) %query stats for $hget($sockname,name) :: $iif($hget($sockname,%query $+ _level),%results,No data found) }