Smithing

By Testor on Oct 15, 2009

Smithing Script using MDX Dialog extension for menus and font.
Tells you info on each bar, bars to level with smelting, smithing, and both. double exp included for sc hammers. Defname storing. Tracker built into it (Day, Week, Year).
Requires MDX.
Get MDX here: http://www.mirc.net/projects.php?go=1112480642

ScreenShot http://img203.imageshack.us/img203/2552/091015223020.png

alias Smith {
  if ($dialog(Smith)) { dialog -x Smith }
  dialog -mo Smith Smith
  if ($Sock(Smith)) { .SockClose Smith }
  if ($Sock(Tracker.*)) { .SockClose Tracker.* }
  sockopen Smith rscript.org 80
}
dialog Smith {
  title "Smithing"
  size -1 -1 210 128
  option dbu
  text "Level", 2, 7 4 52 8
  text "Experience", 3, 65 4 55 8
  text "Information", 4, 125 4 83 8
  text "Rank", 6, 7 15 53 8
  check "Morphic Hammers.", 7, 65 14 59 10
  text "", 11, 124 15 82 8
  text "Tracker (1d):", 1, 6 27 54 15
  text "Tracker (1w):", 5, 64 27 55 15
  text "Tracker (1y)", 9, 124 27 82 15
  tab "Experience", 10, 2 41 206 83
  list 8, 4 57 202 64, tab 10 size
  button "Close.", 14, 165 43 41 10, ok
  button "Refresh.", 15, 123 43 41 10,
  tab "Next Level", 12
  list 13, 4 57 202 64, tab 12 size
  tab "Settings", 16
  box "Use SC Hammers By Default", 17, 95 55 84 32, tab 16
  box "Set Default RSN", 18, 5 55 84 32, tab 16
  button "Set.", 19, 55 73 31 12, tab 16
  check "SC Hammers by Default", 20, 100 67 74 10, tab 16
  edit , 21, 10 63 44 10, tab 16
}
on *:Dialog:Smith:Close:*: {
  Sockclose Tracker.* | Sockclose Smith
}
on *:DIALOG:Smith:init:0:{ 
  mdx SetMircVersion $Version | mdx MarkDialog Smith | mdx MarkDialog Smith $dialog(Smith).hwnd 
  mdx SetColor Smith 1,2,3,4,5,6,9,11 text $rgb(0,0,255)
  mdx SetFont Smith 1,2,3,4,5,6,9,11 -11.5 400 Calibri
  mdx SetControlMDX Smith 8,13 ListView report showsel rowselect > $mdxfile(views)
  Did -i Smith 8 1 headerdims 60:1 90:2 90:3 79:4 60:5
  Did -i Smith 8 1 headertext +c Item $chr(9) $+ +c Level Required $chr(9) $+ +c Smelting EXP $chr(9) $+ +c Smithing EXP $chr(9) $+ +c Total
  Did -i Smith 13 1 headerdims 60:1 75:2 85:3 80:4 80:5
  Did -i Smith 13 1 headertext +c Item $chr(9) $+ +c Smelt Only $chr(9) $+ +c Smith Only $chr(9) $+ +c Both $chr(9) $+ +c Bars/Hammer
  SmithCon
  if ($Readini(Smith.ini, Rsn, Hammers) == Yes) { 
    Did -c Smith 7,20
  }
  Did -a Smith 21 $iif($Readini(Smith.ini, Rsn, Rsn), $v1, $Me)
}
on *:SOCKOPEN:Smith:{
  sockwrite -nt $sockname GET $+(/lookup.php?type=stats&user=,$Readini(Smith.ini, Rsn, Rsn)) HTTP/1.1
  sockwrite -nt $sockname Host: rscript.org
  sockwrite -nt $sockname $crlf
}

on *:SOCKREAD:Smith:{
  if ($sockerr) { .sockclose Smith | sockopen Smith rscript.org 80 }
  else {
    var %Smith
    sockread %Smith
    if (Smithing isin %Smith) {
      tokenize 32 $gettok(%Smith,2-,32) 
      Did -ra Smith 2 Level: $2
      Did -ra Smith 3 Experience: $Bytes($xp($Calc($2 + 1)),bd)
      Did -ra Smith 4 Next Level: $xcalc($xp($Calc($2 + 1)) - $3) ( $+ $round($calc($3 / $xp($Calc($2 + 1)) *100),1) $+ % $+ )
      Did -ra Smith 6 Rank: $bytes($1,bd)
      if ($Did(Smith,7).State) { Did -ra Smith 11 Morphic Hammers to level: $Ceil($xCalc($GetTok($Did(Smith,4), 3, 32) / 64000)) }
      sockclose Smith
      .inc %ID
      .sockopen $+(tracker.,%ID) rscript.org 80
      .sockmark $+(tracker.,%ID) $iif($readini(Smith.ini,Rsn,Rsn),$v1,$me)
    }
  }
}
on *:Dialog:Smith:Sclick:*: { 
  if ($Did = 7) {
    if ($Did(Smith,7).state) {
      Did -ra Smith 11 Morphic Hammers to level: $Ceil($xCalc($GetTok($Did(Smith,4), 3, 32) / 64000))
    }
    Else {
      Did -r Smith 11
    }
  }
  Elseif ($Did = 15) {
    if ($Sock(Smith)) { Sockclose Smith }
    SmithCon
    Did -r Smith 1,2,3,4,5,6,9,11
    sockopen Smith rscript.org 80
    .inc %ID
    .sockopen $+(tracker.,%ID) rscript.org 80
    .sockmark $+(tracker.,%ID) $iif($readini(Smith.ini,Rsn,Rsn),$v1,$me)
  }
  if ($Did = 20) {
    if ($Did(Smith,20).state) { Did -c Smith 7 | Writeini Smith.ini Rsn Hammers Yes }
    Elseif (!$Did(Smith,20).state) { Did -u Smith 7 | Did -h Smith 11 | Writeini smith.ini Rsn Hammers No }
  }
  if ($Did = 19) { 
    Writeini Smith.ini Rsn Rsn $Replace($Did(Smith,21),$Chr(32),+)
  }
}
alias SmithCon {
  Did -r Smith 8,13
  Var %c 1
  While (%c <= 11) {
    Var %x $ini(Smith.ini, Level, %c), %xx $Readini(Smith.ini, Level, %x)
    Var %xxx $Readini(Smith.ini, Smelt, %x), %xxxx $Readini(Smith.ini, $iif($Did(Smith,7).state, Hammer, Exp), %x)
    Did -a Smith 8 +c 0 0 0 $Replace(%x,_,$Chr(32)) $chr(9) $+ +c 0 0 0 %xx $chr(9) $+ +c 0 0 0 %xxx $chr(9) $+ +c 0 0 0 %xxxx $chr(9) $+ +c 0 0 0 $Calc(%xxx + %xxxx)
    Inc %c
  }
  Var %o 1, %Exp $Remove($GetTok($Did(Smith,4),3, 32), $Chr(44))
  While (%o <= 11) {
    Var %a $ini(Smith.ini, Smelt, %o), %aa $Calc(%Exp / $Readini(Smith.ini, Smelt, %a))
    Var %aaa $Calc(%Exp / $Readini(Smith.ini, $iif($Did(Smith,7).state, Hammer, Exp), %a)), %aaaa $Calc(%Exp / ($Readini(Smith.ini, $iif($did(Smith,7).state, Hammer, Exp), %a) + $readini(Smith.ini, Smelt, %a)))
    VAr %aaaaa $Readini(Smith.ini, hBar, %a)
    Did -a Smith 13 +c 0 0 0 $Replace(%a,_,$Chr(32)) $chr(9) $+ +c 0 0 0 $Bytes($Ceil(%aa),bd) $chr(9) $+ +c 0 0 0 $Bytes($Ceil(%aaa),bd) $Chr(9) $+ +c 0 0 0 $Bytes($Ceil(%aaaa),bd) $chr(9) $+ +c 0 0 0 $Bytes($Ceil(%aaaaa),bd)
    inc %o
  }
}
alias xp { 
  var %total 0
  var %currlv 1
  while (%currlv < $1) {
    %total = $calc(%total + $floor($calc(%currlv + 300 * (2 ^ (%currlv / 7)))))    
    inc %currlv
  }
  return $floor($calc(%total / 4)) 
}
on *:SOCKOPEN:tracker.*:{
  .sockwrite -nt $sockname GET $+(/lookup.php?type=track&user=,$sock($sockname).mark,&skill=all&time=,86400,$chr(44),604800,$chr(44),1209600,$chr(44),2419200,$chr(44),14515200,$chr(44),31449600) HTTP/1.1
  .sockwrite -nt $sockname Host: www.rscript.org
  .sockwrite -nt $sockname $clrf
}

on *:SOCKREAD:tracker.*:{
  .var %sockreader
  .sockread %sockreader
  if ($regex(%sockreader,/-1/)) {
    .did -a Smith Tracker Gains 1,5,9 Not found.
    .sockclose $sockname | halt
  }
  if ($regex(%sockreader,/start:Smithing:(.*)/)) {
    .hadd -m $sockname start $regml(1)
  }
  if ($regex(%sockreader,/gain:Smithing:(.*):(.*)/)) {
    .var %lvl.gain = $undoexp($hget($sockname,start)), %lvl.start = $undoexp($calc($hget($sockname,start) - $regml(2)))
    .var %lvl.finish = $+($chr(40),$iif(%lvl.start > 99,99,%lvl.start),$iif(%lvl.start != %lvl.gain && %lvl.start < 99,$+(->,%lvl.gain)),$chr(41))
    if ($regml(1) == 86400) { .did -a Smith 1 Track (1 Day): $bytes($regml(2),db) %lvl.finish }
    if ($regml(1) == 604800) { .did -a Smith 5 Track (1 Week): $bytes($regml(2),db) %lvl.finish }
    if ($regml(1) == 31449600) { .did -a Smith 9 Track (1 Year): $bytes($regml(2),db) %lvl.finish }
  }
}
alias undoexp {
  if ($isid) {
    var %e = 0, %x = 1, %y = $1
    while (%e <= %y) {
      inc %e $calc($floor($calc(%x + 300 * 2 ^ (%x / 7))) / 4)
      inc %x
    }
    return $calc(%x - 1)
  }
}

on *:Load: {

  Writeini -n Smith.ini Level Bronze 1
  Writeini -n Smith.ini Level Blurite 8
  Writeini -n Smith.ini Level Iron 15
  Writeini -n Smith.ini Level Elemental 20
  Writeini -n Smith.ini Level Silver 20
  Writeini -n Smith.ini Level Steel 30
  Writeini -n Smith.ini Level Gold 40
  Writeini -n Smith.ini Level Gold_(G) 40
  Writeini -n Smith.ini Level Mithril 50
  Writeini -n Smith.ini Level Adamant 70
  Writeini -n Smith.ini Level Runite 85

  Writeini -n Smith.ini Smelt Bronze 6.2
  Writeini -n Smith.ini Smelt Blurite 8
  Writeini -n Smith.ini Smelt Iron 12.5
  Writeini -n Smith.ini Smelt Elemental 7.5
  Writeini -n Smith.ini Smelt Silver 13.7
  Writeini -n Smith.ini Smelt Steel 17.5
  Writeini -n Smith.ini Smelt Gold 22.5
  Writeini -n Smith.ini Smelt Gold_(G) 56.2
  Writeini -n Smith.ini Smelt Mithril 30
  Writeini -n Smith.ini Smelt Adamant 37.5
  Writeini -n Smith.ini Smelt Runite 50

  Writeini -n Smith.ini Exp Bronze 12
  Writeini -n Smith.ini Exp Blurite 17
  Writeini -n Smith.ini Exp Iron 25
  Writeini -n Smith.ini Exp Elemental 10
  Writeini -n Smith.ini Exp Silver 0
  Writeini -n Smith.ini Exp Steel 37.5
  Writeini -n Smith.ini Exp Gold 0
  Writeini -n Smith.ini Exp Gold_(G) 0
  Writeini -n Smith.ini Exp Mithril 50
  Writeini -n Smith.ini Exp Adamant 62.5
  Writeini -n Smith.ini Exp Runite 75

  Writeini -n Smith.ini Hammer Bronze=24
  Writeini -n Smith.ini Hammer Blurite=0
  Writeini -n Smith.ini Hammer Iron=50
  Writeini -n Smith.ini Hammer Elemental=0
  Writeini -n Smith.ini Hammer Silver=0
  Writeini -n Smith.ini Hammer Steel=75
  Writeini -n Smith.ini Hammer Gold=0
  Writeini -n Smith.ini Hammer Gold_(G)=0
  Writeini -n Smith.ini Hammer Mithril=100
  Writeini -n Smith.ini Hammer Adamant=125
  Writeini -n Smith.ini Hammer Runite=150

  Writeini -n Smith.ini hBar Bronze 2560
  Writeini -n Smith.ini hBar Blurite 0
  Writeini -n Smith.ini hBar Iron 1283
  Writeini -n Smith.ini hBar Elemental 0
  Writeini -n Smith.ini hBar Silver 0
  Writeini -n Smith.ini hBar Steel 854
  Writeini -n Smith.ini hBar Gold 0
  Writeini -n Smith.ini hBar Gold_(G) 0
  Writeini -n Smith.ini hBar Mithril 640
  Writeini -n Smith.ini hBar Adamant 513
  Writeini -n Smith.ini hBar Runite 427
}

Comments

Sign in to comment.
Testor   -  Oct 19, 2009

I don't know really either, haha.

 Respond  
Sorasyn   -  Oct 18, 2009

ah i see :P thanks. I've downloaded MDX before but im new to DLL's and dont really know how to use them.

 Respond  
Testor   -  Oct 18, 2009

MDX can change font colour and font style, aswell as other visual things on dialogs.

mdx SetColor Smith 1,2,3,4,5,6,9,11 text $rgb(0,0,255)
mdx SetFont Smith 1,2,3,4,5,6,9,11 -11.5 400 Calibri

The $Rgb(0,0,255) is the rgb value for the blue colour, if you have a rgb colour chart you can find + change the colour. the Calibri changes the font type to calibri.

 Respond  
Sorasyn   -  Oct 17, 2009

one more thing, im curious as to how you colored your text in the dialog to blue :P

 Respond  
Testor   -  Oct 16, 2009

Ah. I'll change that. Added the $Xp Alias i forgot too D:.

 Respond  
Sorasyn   -  Oct 16, 2009

looks like a nice script :) one thing is this

on *:Start: { 
  Writeini -n Smith.ini Level Bronze 1
  Writeini -n Smith.ini Level Blurite 8
  Writeini -n Smith.ini Level Iron 15
  Writeini -n Smith.ini Level Elemental 20
  Writeini -n Smith.ini Level Silver 20
  Writeini -n Smith.ini Level Steel 30
  Writeini -n Smith.ini Level Gold 40

problem with that is every time you start it up
it'll write the ini file (smith.ini) again and again, making the file massive and repetitive.

you could replace it with

on *:load: { 
  Writeini -n Smith.ini Level Bronze 1
  Writeini -n Smith.ini Level Blurite 8
  Writeini -n Smith.ini Level Iron 15
  Writeini -n Smith.ini Level Elemental 20
  Writeini -n Smith.ini Level Silver 20
  Writeini -n Smith.ini Level Steel 30
  Writeini -n Smith.ini Level Gold 40

that way the only time it writes the ini file is when you first load it into remotes

 Respond  
Are you sure you want to unfollow this person?
Are you sure you want to delete this?
Click "Unsubscribe" to stop receiving notices pertaining to this post.
Click "Subscribe" to resume notices pertaining to this post.