All pastes #638146 Raw Edit

stats script

public text v1 · immutable
#638146 ·published 2007-07-29 15:56 UTC
rendered paste body
; ############################################################
; Stats Lookup
; ############################################################
alias c1 { return $+(12 $1-,) }
alias c2 { return $+(4 $1-,) }

on *:TEXT:!stats*:#: {
  if ($1- == *#*) || ($1- == *@*) { halt }
  if ($chan == #idle) { halt }
  tokenize 32 $strip($1-)
  if ($right($1,-1) == stats) var %style = astats

  inc %ID
  if ($len($2-) > 12) {
    /notice $nick $($+(%,stats.display., %ID),2) $c1(The name) $c2($2-) $c1(is too long)
    cleanup %ID
    halt
  }
  elseif ($2) set $+(%,stats.rsn., %ID) $replace($2-,$chr(32),-)
  elseif ($readini(DefRSN.ini,RSNs,$mask($fulladdress,3))) set $+(%,stats.rsn., %ID) $ifmatch
  elseif ($readini(DefRSN.ini,RSNs,$nick)) set $+(%,stats.rsn., %ID) $ifmatch
  else set $+(%,stats.rsn., %ID) $nick

  set $+(%,stats.style., %ID) %style
  set $+(%,stats.skill., %ID) %skill
  set $+(%,stats.display., %ID) $iif($left($1,1) == @,msg $chan, /notice $nick)
  sockopen $+(stats., %ID) hiscore.runescape.com 80
}

on *:TEXT:@stats*:#: {
  if ($1- == *#*) || ($1- == *@*) { halt }
  if ($chan == #idle) { halt }
  tokenize 32 $strip($1-)
  if ($right($1,-1) == stats) var %style = astats

  inc %ID
  if ($len($2-) > 12) {
    /notice $nick $($+(%,stats.display., %ID),2) $c1(The name) $c2($2-) $c1(is too long)
    cleanup %ID
    halt
  }
  elseif ($2) set $+(%,stats.rsn., %ID) $replace($2-,$chr(32),-)
  elseif ($readini(DefRSN.ini,RSNs,$mask($fulladdress,3))) set $+(%,stats.rsn., %ID) $ifmatch
  elseif ($readini(DefRSN.ini,RSNs,$nick)) set $+(%,stats.rsn., %ID) $ifmatch
  else set $+(%,stats.rsn., %ID) $nick

  set $+(%,stats.style., %ID) %style
  set $+(%,stats.skill., %ID) %skill
  set $+(%,stats.display., %ID) $iif($left($1,1) == @,msg $chan, /notice $nick)
  sockopen $+(stats., %ID) hiscore.runescape.com 80
}

on *:TEXT:!defname*:#: {
  if ($2- == $chr(36) $+ ip) || ($2- == $chr(36) $+ readini) || ($3- == $chr(36) $+ ip) || ($4- == $chr(36) $+ ip)  || ($5- == $chr(36) $+ ip)  || ($6- == $chr(36) $+ ip) { notice $nick Invalid Characters! | halt }
  if ($len($2-) > 12) { notice $nick Name too long | halt }

  writeini DefRSN.ini RSNs $mask($fulladdress,3) $2-
  notice $nick Your default RSN for the host $mask($fulladdress,3) has been set to $2-
}

on *:TEXT:!combat*:#: {
  if ($chan == #idle) { halt }
  tokenize 32 $strip($1-)
  var %style = combat

  inc %ID
  if ($len($2-) > 12) {
    /notice $nick $($+(%,stats.display., %ID),2) $c1(The name) $c2($2-) $c1(is too long)
    cleanup %ID
    halt
  }
  elseif ($2) set $+(%,stats.rsn., %ID) $replace($2-,$chr(32),-)
  elseif ($readini(DefRSN.ini,RSNs,$mask($fulladdress,3))) set $+(%,stats.rsn., %ID) $ifmatch
  elseif ($readini(DefRSN.ini,RSNs,$nick)) set $+(%,stats.rsn., %ID) $ifmatch
  else set $+(%,stats.rsn., %ID) $nick

  set $+(%,stats.style., %ID) %style
  set $+(%,stats.skill., %ID) %skill
  set $+(%,stats.display., %ID) $iif($left($1,1) == @,msg $chan, /notice $nick)
  sockopen $+(stats., %ID) hiscore.runescape.com 80
}
on *:TEXT:!cmb*:#: {
  if ($chan == #idle) { halt }
  tokenize 32 $strip($1-)
  var %style = combat

  inc %ID
  if ($len($2-) > 12) {
    /notice $nick $($+(%,stats.display., %ID),2) $c1(The name) $c2($2-) $c1(is too long)
    cleanup %ID
    halt
  }
  elseif ($2) set $+(%,stats.rsn., %ID) $replace($2-,$chr(32),-)
  elseif ($readini(DefRSN.ini,RSNs,$mask($fulladdress,3))) set $+(%,stats.rsn., %ID) $ifmatch
  elseif ($readini(DefRSN.ini,RSNs,$nick)) set $+(%,stats.rsn., %ID) $ifmatch
  else set $+(%,stats.rsn., %ID) $nick

  set $+(%,stats.style., %ID) %style
  set $+(%,stats.skill., %ID) %skill
  set $+(%,stats.display., %ID) $iif($left($1,1) == @,msg $chan, /notice $nick)
  sockopen $+(stats., %ID) hiscore.runescape.com 80
}
on *:TEXT:@cmb*:#: {
  if ($chan == #idle) { halt }
  tokenize 32 $strip($1-)
  var %style = combat

  inc %ID
  if ($len($2-) > 12) {
    /notice $nick $($+(%,stats.display., %ID),2) $c1(The name) $c2($2-) $c1(is too long)
    cleanup %ID
    halt
  }
  elseif ($2) set $+(%,stats.rsn., %ID) $replace($2-,$chr(32),-)
  elseif ($readini(DefRSN.ini,RSNs,$mask($fulladdress,3))) set $+(%,stats.rsn., %ID) $ifmatch
  elseif ($readini(DefRSN.ini,RSNs,$nick)) set $+(%,stats.rsn., %ID) $ifmatch
  else set $+(%,stats.rsn., %ID) $nick

  set $+(%,stats.style., %ID) %style
  set $+(%,stats.skill., %ID) %skill
  set $+(%,stats.display., %ID) $iif($left($1,1) == @,msg $chan, /notice $nick)
  sockopen $+(stats., %ID) hiscore.runescape.com 80
}

on $*:TEXT:/^[!@.](attack|att)/Si:#: {
  if ($1 == !attack) { set %type !attack }
  if ($1 == $chr(64) $+ attack) { set %type $chr(64) $+ attack }
  if ($1 == !att) { set %type !attack }
  if ($1 == $chr(64) $+ att) { set %type $chr(64) $+ attack }
  set %skill2 Attack
  set %name $2
  $common
}
on $*:TEXT:/^[!@.](strength|str)/Si:#: {
  if ($1 == !strength) { set %type !strength }
  if ($1 == $chr(64) $+ strength) { set %type $chr(64) $+ strength }
  if ($1 == !str) { set %type !strength }
  if ($1 == $chr(64) $+ str) { set %type $chr(64) $+ strength }
  set %skill2 Strength
  set %name $2
  $common
}
on $*:TEXT:/^[!@.](defence|def)/Si:#: {
  if ($1 == !defence) { set %type !defence }
  if ($1 == $chr(64) $+ defence) { set %type $chr(64) $+ defence }
  if ($1 == !def) { set %type !defence }
  if ($1 == $chr(64) $+ def) { set %type $chr(64) $+ defence }
  set %skill2 Defence
  set %name $2
  $common
}
on $*:TEXT:/^[!@.](ranged|range)/Si:#: {
  if ($1 == !range) { set %type !range }
  if ($1 == $chr(64) $+ range) { set %type $chr(64) $+ ranged }
  if ($1 == !range) { set %type !range }
  if ($1 == $chr(64) $+ ranged) { set %type $chr(64) $+ ranged }
  set %skill2 Ranged
  set %name $2
  $common
}
on $*:TEXT:/^[!@.](hp|hitpoints|hits)/Si:#: {
  if ($1 == !hitpoints) { set %type !hitpoints }
  if ($1 == $chr(64) $+ hitpoints) { set %type $chr(64) $+ hitpoints }
  if ($1 == !hp) { set %type !hitpoints }
  if ($1 == $chr(64) $+ hp) { set %type $chr(64) $+ hitpoints }
  if ($1 == !hits) { set %type !hitpoints }
  if ($1 == $chr(64) $+ hits) { set %type $chr(64) $+ hitpoints }
  set %skill2 Hitpoints
  set %name $2
  $common
}
on $*:TEXT:/^[!@.](pray|prayer)/Si:#: {
  if ($1 == !prayer) { set %type !prayer }
  if ($1 == $chr(64) $+ prayer) { set %type $chr(64) $+ prayer }
  if ($1 == !pray) { set %type !prayer }
  if ($1 == $chr(64) $+ pray) { set %type $chr(64) $+ prayer }
  set %skill2 Prayer
  set %name $2
  $common
}
on $*:TEXT:/^[!@.](mage|magic)/Si:#: {
  if ($1 == !magic) { set %type !magic }
  if ($1 == $chr(64) $+ magic) { set %type $chr(64) $+ magic }
  if ($1 == !mage) { set %type !magic }
  if ($1 == $chr(64) $+ mage) { set %type $chr(64) $+ magic }
  set %skill2 Magic
  set %name $2
  $common
}
on $*:TEXT:/^[!@.](cook|cooking)/Si:#: {
  if ($1 == !cooking) { set %type !cooking }
  if ($1 == $chr(64) $+ cooking) { set %type $chr(64) $+ cooking }
  if ($1 == !cook) { set %type !cooking }
  if ($1 == $chr(64) $+ cook) { set %type $chr(64) $+ cooking }
  set %skill2 Cooking
  set %name $2
  $common
}
on $*:TEXT:/^[!@.](wc|woodcutting)/Si:#: {
  if ($1 == !woodcutting) { set %type !woodcutting }
  if ($1 == $chr(64) $+ woodcutting) { set %type $chr(64) $+ woodcutting }
  if ($1 == !wc) { set %type !woodcutting }
  if ($1 == $chr(64) $+ wc) { set %type $chr(64) $+ woodcutting }
  set %skill2 Woodcutting
  set %name $2
  $common
}
on $*:TEXT:/^[!@.](fletch|fletching)/Si:#: {
  if ($1 == !fletching) { set %type !fletching }
  if ($1 == $chr(64) $+ fletching) { set %type $chr(64) $+ fletching }
  if ($1 == !fletch) { set %type !fletching }
  if ($1 == $chr(64) $+ fletch) { set %type $chr(64) $+ fletching }
  set %skill2 Fletching
  set %name $2
  $common
}
on $*:TEXT:/^[!@.](fish|fishing)/Si:#: {
  if ($1 == !fishing) { set %type !fishing }
  if ($1 == $chr(64) $+ fishing) { set %type $chr(64) $+ fishing }
  if ($1 == !fish) { set %type !fishing }
  if ($1 == $chr(64) $+ fish) { set %type $chr(64) $+ fishing }
  set %skill2 Fishing
  set %name $2
  $common
}
on $*:TEXT:/^[!@.](fm|firemaking)/Si:#: {
  if ($1 == !firemaking) { set %type !firemaking }
  if ($1 == $chr(64) $+ firemaking) { set %type $chr(64) $+ firemaking }
  if ($1 == !fm) { set %type !firemaking }
  if ($1 == $chr(64) $+ fm) { set %type $chr(64) $+ firemaking }
  set %skill2 Firemaking
  set %name $2
  $common
}
on $*:TEXT:/^[!@.](craft|crafting)/Si:#: {
  if ($1 == !crafting) { set %type !crafting }
  if ($1 == $chr(64) $+ crafting) { set %type $chr(64) $+ crafting }
  if ($1 == !craft) { set %type !crafting }
  if ($1 == $chr(64) $+ craft) { set %type $chr(64) $+ crafting }
  set %skill2 Crafting
  set %name $2
  $common
}
on $*:TEXT:/^[!@.](smith|smithing)/Si:#: {
  if ($1 == !smithing) { set %type !smithing }
  if ($1 == $chr(64) $+ smithing) { set %type $chr(64) $+ smithing }
  if ($1 == !smith) { set %type !smithing }
  if ($1 == $chr(64) $+ smith) { set %type $chr(64) $+ smithing }
  set %skill2 Smithing
  set %name $2
  $common
}
on $*:TEXT:/^[!@.](mine|mining)/Si:#: {
  if ($1 == !mining) { set %type !mining }
  if ($1 == $chr(64) $+ mining) { set %type $chr(64) $+ mining }
  if ($1 == !mine) { set %type !mining }
  if ($1 == $chr(64) $+ mine) { set %type $chr(64) $+ mining }
  set %skill2 Mining
  set %name $2
  $common
}
on $*:TEXT:/^[!@.](herb|herblore)/Si:#: {
  if ($1 == !herblore) { set %type !herblore }
  if ($1 == $chr(64) $+ herblore) { set %type $chr(64) $+ herblore }
  if ($1 == !herb) { set %type !herblore }
  if ($1 == $chr(64) $+ herb) { set %type $chr(64) $+ herblore }
  set %skill2 Herblore
  set %name $2
  $common
}
on $*:TEXT:/^[!@.](agility)/Si:#: {
  if ($1 == !agility) { set %type !agility }
  if ($1 == $chr(64) $+ agility) { set %type $chr(64) $+ agility }
  set %skill2 Agility
  set %name $2
  $common
}
on $*:TEXT:/^[!@.](thieving)/Si:#: {
  if ($1 == !thieving) { set %type !thieving }
  if ($1 == $chr(64) $+ thieving) { set %type $chr(64) $+ thieving }
  set %skill2 Thieving
  set %name $2
  $common
}
on $*:TEXT:/^[!@.](slayer|slay)/Si:#: {
  if ($1 == !slayer) { set %type !slayer }
  if ($1 == $chr(64) $+ slayer) { set %type $chr(64) $+ slayer }
  if ($1 == !slay) { set %type !slayer }
  if ($1 == $chr(64) $+ slay) { set %type $chr(64) $+ slayer }
  set %skill2 Slayer
  set %name $2
  $common
}
on $*:TEXT:/^[!@.](farming|farm)/Si:#: {
  if ($1 == !farmin) { set %type !farmin }
  if ($1 == $chr(64) $+ farmin) { set %type $chr(64) $+ farmin }
  if ($1 == !farm) { set %type !farmin }
  if ($1 == $chr(64) $+ farm) { set %type $chr(64) $+ farmin }
  set %skill2 Farming
  set %name $2
  $common
}
on $*:TEXT:/^[!@.](rc|runecraft|runecrafting)/Si:#: {
  if ($1 == !runecrafting) { set %type !runecrafting }
  if ($1 == $chr(64) $+ runecrafting) { set %type $chr(64) $+ runecrafting }
  if ($1 == !runecraft) { set %type runecrafting }
  if ($1 == $chr(64) $+ runecraft) { set %type $chr(64) $+ runecrafting }
  if ($1 == !rc) { set %type runecrafting }
  if ($1 == $chr(64) $+ rc) { set %type $chr(64) $+ runecrafting }
  set %skill2 Runecraft
  set %name $2
  $common
}
on $*:TEXT:/^[!@.](construction|cs|cons)/Si:#: {
  if ($1 == !construction) { set %type !construction }
  if ($1 == $chr(64) $+ construction) { set %type $chr(64) $+ construction }
  if ($1 == !cons) { set %type construction }
  if ($1 == $chr(64) $+ cons) { set %type $chr(64) $+ construction }
  if ($1 == !cs) { set %type construction }
  if ($1 == $chr(64) $+ cs) { set %type $chr(64) $+ construction }
  set %skill2 Construction
  set %name $2
  $common
}
on $*:TEXT:/^[!@.](hunter|hunt)/Si:#: {
  if ($1 == !hunter) { set %type !hunter }
  if ($1 == $chr(64) $+ hunter) { set %type $chr(64) $+ hunter }
  if ($1 == !hunt) { set %type !huntert }
  if ($1 == $chr(64) $+ hunt) { set %type $chr(64) $+ hunter }
  set %skill2 Hunter
  set %name $2
  $common
}
alias common {
  var %style = istat, %skill = %skill2
  inc %ID
  if ($len(%name) > 12) {
    $($+(%,stats.display., %ID),2) $c1(The name) $c2($2-) $c1(is too long)
    cleanup %ID
    halt
  }
  elseif (%name) set $+(%,stats.rsn., %ID) $replace(%name,$chr(32),-)
  elseif ($readini(DefRSN.ini,RSNs,$mask($fulladdress,3))) set $+(%,stats.rsn., %ID) $ifmatch
  elseif ($readini(DefRSN.ini,RSNs,$nick)) set $+(%,stats.rsn., %ID) $ifmatch
  else set $+(%,stats.rsn., %ID) $nick

  set $+(%,stats.style., %ID) %style
  set $+(%,stats.skill., %ID) %skill
  set $+(%,stats.display., %ID) $iif($left(%type,1) == @,msg $chan, /notice $nick)
  sockopen $+(stats., %ID) hiscore.runescape.com 80
}

on *:sockopen:stats.*: {
  var %id = $gettok($sockname,2,46)
  sockwrite -n $sockname GET /lang/en/aff/runescape/hiscorepersonal.ws?user1= $+ $($+(%,stats.rsn., %ID),2) HTTP/1.1
  sockwrite -n $sockname Host: hiscore.runescape.com $+ $crlf $+ $crlf
}
on *:sockread:stats.*: {
  sockread &Incoming
  bwrite $sockname -1 -1 &Incoming
  if ($bfind(&Incoming, 1, </html>).text) makehash $sockname
  elseif ($bfind(&Incoming, 1, does not feature in the hiscores.).text) {
    $($+(%,stats.display., %ID),2) $c1(The name) $+ $c2($($+(%,stats.rsn.,%ID),2)) $+ $c1(Does not appear in the hiscores)
    cleanup $gettok($sockname,2,46)
  }
}
alias -l makehash {
  var %file = $1
  bread %file 1 $file(%file).size &stats
  var %currentstat, %x = 1
  while (%x) {
    var %x = $bfind(&stats,$calc(%x + 1),<a href="overall.ws?table=)
    var %currentstat = $striptags($bvar(&stats,%x,200).text)
    tokenize 10 %currentstat
    hadd -m %file $1 $2 $3 $4 $xp2next($3,$4)
  }
  process %file
}
alias process {
  var %table = $1, %id = $gettok($1,2,46), %x = 0, $&
    %display = $($+(%,stats.display., %ID),2), $&
    %rsn = $($+(%,stats.rsn., %ID),2), $&
    %skill = $($+(%,stats.skill., %ID),2), $&
    %style = $($+(%,stats.style., %ID),2)
  ;shoot;
  if (%style == astats) {
    while (%x <= 20) {
      tokenize 32 $hget(%table,$setskill(%x))
      if ($2) var %statline = %statline $c1($setskill(%x)) $c2($2)
      inc %x
    }
    %display $c2(Stats for) $c1(%rsn) $+ $c2(:)
    %display %statline
    %statline =
    while (%x <= 23) {
      tokenize 32 $hget(%table,$setskill(%x))
      if ($2) var %statline = %statline $c1($setskill(%x)) $c2($2)
      inc %x
    }

    %display %statline
  }

  elseif (%style == istat) {
    if (!$hget(%table,%skill)) %display $c1(The name) $c2(%rsn) $c1(does not appear in the hiscores for) $c2(%skill)
    else {
      tokenize 32 $hget(%table,%skill)
      %display $c2(%skill) $+ $c1(stats for) $+ $c2(%rsn) $+ 12:
      %display $c1(Rank:) $+ $c2($1) $+ $c1(Level:) $+ $c2($bytes($2,b)) $+ $c1(Exp:) $+ $c2($3) $&
        $iif(%skill != Overall,$c1(Exp to lvl) $+ $c2($calc($2 + 1)) $+ 12: $+ $c2($bytes($4,b)))
    }
  }
  elseif (%style == combat) {
    var %a.mult = .32707, %s.mult = .324, %d.mult = .25, %h.mult = .25, %p.mult = .124, %r.mult = .487, %m.mult = .487
    var %a = $iif($gettok($hget(%table,attack),2,32),$v1,-), $&
      %s = $iif($gettok($hget(%table,strength),2,32),$v1,-), $&
      %d = $iif($gettok($hget(%table,defence),2,32),$v1,-), $&
      %h = $iif($gettok($hget(%table,hitpoints),2,32),$v1,-), $&
      %r = $iif($gettok($hget(%table,ranged),2,32),$v1,-), $&
      %m = $iif($gettok($hget(%table,magic),2,32),$v1,-), $&
      %p = $iif($gettok($hget(%table,prayer),2,32),$v1,-)

    var %meleecombat  = $calc(%a * %a.mult + %s * %s.mult + %d * %d.mult + %h * %h.mult + %p * %p.mult), $&
      %RangedCombat = $calc(%r * %r.mult + %p * %p.mult + %d * %d.mult + %h * %h.mult), $&
      %MagicCombat  = $calc(%m * %m.mult + %p * %p.mult + %d * %d.mult + %h * %h.mult)

    if (%MagicCombat == %RangedCombat) && (%MagicCombat == %RangedCombat) {
      %display $c1(The name) $c2(%rsn) $c1(does not appear in the hiscores for any combat skills)
      cleanup %id
      halt
    }
    elseif (%MagicCombat > %RangedCombat) && (%MagicCombat > %MeleeCombat) var %cmbstyle = Magic, %Combat = %MagicCombat
    elseif (%RangedCombat > %MeleeCombat) var %cmbstyle = Ranged, %Combat = %RangedCombat
    else var %cmbstyle = melee, %combat = %MeleeCombat

    var %cmb.temp = $abs($calc($int($calc(%combat +1)) - %combat)), $&
      %a.2lvl = $ceil($calc(%cmb.temp / %a.mult)), %s.2lvl = $ceil($calc(%cmb.temp / %s.mult)), $&
      %d.2lvl = $ceil($calc(%cmb.temp / %d.mult)), %m.2lvl = $ceil($calc(%cmb.temp / %m.mult)), $&
      %r.2lvl = $ceil($calc(%cmb.temp / %r.mult)), %p.2lvl = $ceil($calc(%cmb.temp / %p.mult))

    if (%cmbstyle == magic) var %dynamic.2lvl = $c1(Magic:) $c2(%m.2lvl)
    elseif (%cmbstyle == Ranged) var %dynamic.2lvl = $c1(Ranged:) $c2(%r.2lvl)
    else var %dynamic.2lvl = $c1(Att:) $c2(%a.2lvl) $c1(Str:) $c2(%s.2lvl)
    var %combat = $round(%combat,2), %next = $ceil(%combat)

    %display $c1(%rsn) $c2(Combat) $c1(%combat) $c2(%cmbstyle style combat)
    %display $c1(Attack:) $c2(%a) $c1(Defence:) $c2(%d) $c1(Strength:) $c2(%s) $c1(Hits:) $c2(%h) $&
      $c1(Mage:) $c2(%m) $c1(Range:) $c2(%r) $c1(Pray:) $c2(%p)
    %display $c1(Levels for) $c2(%next) $+ $c1(:) %dynamic.2lvl $&
      $c1(Def/Hp:) $c2(%d.2lvl) $c1(Prayer:) $c2(%p.2lvl)
  }
  cleanup %id
  /unset %stats.display.*
  /unset %stats.skill.*
  /unset %stats.style.*
  /unset %stats.rsn.*
  /set %usage $calc( ( %usage ) + 1)
}

alias -l cleanup {
  unset $+(%,stats.*.,$1)
  sockclose $+(Stats.,$1)
  .remove $+(Stats.,$1)
}

alias -l xp {
  var %x = 1, %level = $calc($1 - 1), %xp = 0
  while (%x <= %level) {
    var %TempXp = $calc((%x + 300 * 2^(%x / 7)) /4)
    inc %xp %TempXp
    inc %x
  }
  return $int(%xp)
}

alias -l xp2Next {
  var %xp = $remove($2,$chr(44)), %nextxp = $xp($calc($1 + 1))
  return $calc(%nextxp - %xp)
}

alias -l striptags { var %x,%y = $regsub($1-,/(<[^>]+>)/g,$null,%x) | return %x }
alias -l setskill {
  if ($1 == 0) || ($regex($1,/^(st|(skill)?total|overall)$/Si)) return Overall
  elseif ($1 == 1) || ($regex($1,/^at(t|k|tack)$/Si)) return Attack
  elseif ($1 == 2) || ($regex($1,/^def(en[cs]e)?$$/Si)) return Defence
  elseif ($1 == 3) || ($regex($1,/^str(ength)?$/Si)) return Strength
  elseif ($1 == 4) || ($regex($1,/^hp|hit(s|points?)?$/Si)) return Hitpoints
  elseif ($1 == 5) || ($regex($1,/^range(r|d|ing)?$/Si)) return Ranged
  elseif ($1 == 6) || ($regex($1,/^Pray(er)?$$/Si)) return Prayer
  elseif ($1 == 7) || ($regex($1,/^mag(e|ic)$$/Si)) return Magic
  elseif ($1 == 8) || ($regex($1,/^cook(ing)?$/Si)) return Cooking
  elseif ($1 == 9) || ($regex($1,/^wc|wood(cut(ting)?)?$/Si)) return Woodcutting
  elseif ($1 == 10) || ($regex($1,/^fletch(ing)?$/Si)) return Fletching
  elseif ($1 == 11) || ($regex($1,/^fish(ing)?$/Si)) return Fishing
  elseif ($1 == 12) || ($regex($1,/^(fire|fm)(make?(ing)?|ing)?$/Si)) return Firemaking
  elseif ($1 == 13) || ($regex($1,/^craft(ing)?$/Si)) return Crafting
  elseif ($1 == 14) || ($regex($1,/^(smith|smelt)(ing)?$/Si)) return Smithing
  elseif ($1 == 15) || ($regex($1,/^mine(ing)?$/Si)) return Mining
  elseif ($1 == 16) || ($regex($1,/^herb(law|lore)?$/Si)) return Herblore
  elseif ($1 == 17) || ($regex($1,/^agil(ity)?$/Si)) return Agility
  elseif ($1 == 18) || ($regex($1,/^(th(ei|ie)[fv](e|ing)?)$/Si)) return Thieving
  elseif ($1 == 19) || ($regex($1,/^slay(er|ing)?$/Si)) return Slayer
  elseif ($1 == 20) || ($regex($1,/^farm(er|ing)?$/Si)) return Farming
  elseif ($1 == 21) || ($regex($1,/^(rc|runecraft)(er|ing)?$/Si)) return Runecraft
  elseif ($1 == 22) || ($regex($1,/^(construct)(ion|ing)?$/si)) return Construction
  elseif ($1 == 23) || ($regex($1,/^(hunt)(er|ing)?$/si)) return Hunter
}