Runescape
Posted by Parasite-FT-
Wednesday, November 03, 2004
Description: A script for Runescape people

I'll add comments later

The ini section must be saved to runedb.ini in the same directory as the script

- Para


; ____________________________________________________________________________
;
;      Runescape script
; ____________________________________________________________________________

; ____________________________________________________________________________
;      Events

on *:text:@skills:#bottest: msg $chan Available skills are: $replace($rune_skills,|,$chr(44))

on *:text:@*:#bottest: {
  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 <target> <type> <name of player>
alias runescape {
  var %sock = runescape. $+ $ticks
  hadd -m %sock target $1
  hadd %sock query $2
  hadd %sock name $3-
  sockopen %sock hiscore.runescape.com 80
}

;; Function: simply writes to the object database, a shortcut for the lazy/uninformed
;; Usage: /rune.add <skill type> <object> <xp>
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|smithing|mining|prayer|runecrafting|herblore|agility }

;; Function: delimits a number with a given character (ie, adds commas to large numbers)
;; Usage: $delimit(<number>,<C>)
;; Comments: <C> 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(<level>)
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 /aff/runescape/hiscorepersonal.cgi?username= $+ %name HTTP/1.1
  sockwrite -n $sockname Host: hiscore.runescape.com
  sockwrite -n $sockname Connection: close
  sockwrite -n $sockname
}

on *:sockread:runescape.*: {
  var %temp
  sockread %temp

  if (*class=c>*</a></td>* 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)
}



ini section


[HERBLORE]
superAttack=100
fishing=112.5
superStrength=125
weaponPoison=137.5
superDefence=150
antiFire=157.5
ranging=162.5

[AGILITY]
Gnome=92.5
Barbarian=139.5
Wildnerness=682

[COOKING]
Tuna=100
Lobster=120
Swordfish=140
Shark=210

[MINING]
Iron=35
Coal=50
Mithril=80
Adamant=95

[FISHING]
Lobster=90
Swordfish=100
Shark=110

[THEIVING]
Guard=40
Knight=55
Paladin=70
Hero=80

[MAGIC]
HighLevelAlch=65
SuperHeat=53

[PRAYER]
Bones=4.5
BigBones=15
BabyDragonBones=30
DragonBones=72

[FLETCHING]
YewShort=135
YewLong=150
MagicShort=166.5
MagicLong=183

[FIREMAKING]
Normal=40
Oak=60
WIllow=90
Maple=135
Yew=202.5
Magic=303.75

[WOODCUTTING]
Normal=25
Oak=37.5

[SMITHING]
iron=12.5
steel=17.5
mithril=30
adamantite=37.5
runite=50

[SMELT]
iron=37.5
steel=55
mithri=80
adamantite=100
runite=125

[RANGED]
fireGiant=452
GreaterDemon=364
now that parasite is gone.....
Posted by link762698
Wednesday, February 16, 2005 01:38am PST
who  is gonna finish his projects???
Submit a comment
Oops! You need to login or register before you can post a comment!

ebaum's world