Programming Damage Calculator for mIRC

Mekkah

is a Super Moderatoris a Tutor Alumnusis a Site Staff Alumnusis a Live Chat Contributor Alumnusis a CAP Contributor Alumnusis a Contributor Alumnusis a Smogon Media Contributor Alumnusis an Administrator Alumnus
Super Moderator
#1
You may remember my Bracketmaker. I've seen a lot of love for it, and I still had this handy-dandy Damage Calculator stored somewhere. Instructions for use:

1) Get mIRC if you haven't already and open it
2) Go to the Remote by pressing Alt-R
3) Paste the code below
4) Click OK
5) Make sure your Remote is activated. Type /remote on
6) Press F5 and enjoy!

My favourite feature is where the thing calculates the chance the defending Pokemon survives the attack. You can see the outcome of an attack with every single of the 37 RN possibilities. I used this thing for the Magic Stat Numbers guide.

Code:
alias damcalcer { dialog -m damcalcer damcalcer }
alias f5 { damcalcer }

dialog damcalcer {
  title "Mekkah's Damage Calculator"
  size -l -l 400 260
  option dbu

  box "", 501, 5 5 95 60

  text "Level", 1, 10 15 40 10
  edit "", 2, 55 15 20 10

  text "Attack", 3, 10 30 40 10
  edit "", 4, 55 30 20 10

  text "Base Power", 5, 10 45 40 10
  edit "", 6, 55 45 20 10

  box "", 502, 5 65 90 30

  text "Defense", 7, 10 72 40 10
  edit "", 8, 55 72 20 10

  text "HP", 17, 10 82 40 10
  edit "", 18, 55 82 20 10

  box "", 503, 5 95 90 65

  ;STAB, 1.1-items, Choice Band, traits, typing

  text "STAB", 9, 10 100 40 10
  combo 10, 55 100 30 10, drop

  text "Item", 11, 10 115 40 10
  combo 12, 55 115 30 10, drop

  text "Choice Band", 13, 10 130 40 10
  combo 14, 55 130 30 10, drop

  text "Typing", 15, 10 145 40 10
  combo 16, 55 145 30 10, drop

  box "", 504, 105 5 140 225

  text "Rand", 20, 110 15 25 10
  text "Damage", 21, 160 15 40 10
  text "Percentage", 22, 200 15 30 10

  text "217", 31, 110 25 20 10
  text "218", 32, 110 35 20 10
  text "219", 33, 110 45 20 10
  text "220", 34, 110 55 20 10
  text "221", 35, 110 65 20 10
  text "222", 36, 110 75 20 10
  text "223", 37, 110 85 20 10
  text "224", 38, 110 95 20 10
  text "225", 39, 110 105 20 10
  text "226", 40, 110 115 20 10
  text "227", 41, 110 125 20 10
  text "228", 42, 110 135 20 10
  text "229", 43, 110 145 20 10
  text "230", 44, 110 155 20 10
  text "231", 45, 110 165 20 10
  text "232", 46, 110 175 20 10
  text "233", 47, 110 185 20 10
  text "234", 48, 110 195 20 10
  text "235", 49, 110 205 20 10

  text "", 90, 160 25 20 10
  text "", 91, 160 35 20 10
  text "", 92, 160 45 20 10
  text "", 93, 160 55 20 10
  text "", 94, 160 65 20 10
  text "", 95, 160 75 20 10
  text "", 96, 160 85 20 10
  text "", 97, 160 95 20 10
  text "", 98, 160 105 20 10
  text "", 99, 160 115 20 10
  text "", 100, 160 125 20 10
  text "", 101, 160 135 20 10
  text "", 102, 160 145 20 10
  text "", 103, 160 155 20 10
  text "", 104, 160 165 20 10
  text "", 105, 160 175 20 10
  text "", 106, 160 185 20 10
  text "", 107, 160 195 20 10
  text "", 108, 160 205 20 10

  text "", 109, 195 25 20 10
  text "", 110, 195 35 20 10
  text "", 111, 195 45 20 10
  text "", 112, 195 55 20 10
  text "", 113, 195 65 20 10
  text "", 114, 195 75 20 10
  text "", 115, 195 85 20 10
  text "", 116, 195 95 20 10
  text "", 117, 195 105 20 10
  text "", 118, 195 115 20 10
  text "", 119, 195 125 20 10
  text "", 120, 195 135 20 10
  text "", 121, 195 145 20 10
  text "", 122, 195 155 20 10
  text "", 123, 195 165 20 10
  text "", 124, 195 175 20 10
  text "", 125, 195 185 20 10
  text "", 126, 195 195 20 10
  text "", 127, 195 205 20 10

  box "", 505, 245 5 140 225

  text "Rand", 71, 250 15 25 10
  text "Damage", 72, 295 15 40 10
  text "Percentage", 73, 340 15 30 10

  text "236", 50, 250 25 20 10
  text "237", 51, 250 35 20 10
  text "238", 52, 250 45 20 10
  text "239", 53, 250 55 20 10
  text "240", 54, 250 65 20 10
  text "241", 55, 250 75 20 10
  text "242", 56, 250 85 20 10
  text "243", 57, 250 95 20 10
  text "244", 58, 250 105 20 10
  text "245", 59, 250 115 20 10
  text "246", 60, 250 125 20 10
  text "247", 61, 250 135 20 10
  text "248", 62, 250 145 20 10
  text "249", 63, 250 155 20 10
  text "250", 64, 250 165 20 10
  text "251", 65, 250 175 20 10
  text "252", 66, 250 185 20 10
  text "253", 67, 250 195 20 10
  text "254", 68, 250 205 20 10
  text "255", 69, 250 215 20 10

  text "", 128, 295 25 20 10
  text "", 129, 295 35 20 10
  text "", 130, 295 45 20 10
  text "", 131, 295 55 20 10
  text "", 132, 295 65 20 10
  text "", 133, 295 75 20 10
  text "", 134, 295 85 20 10
  text "", 135, 295 95 20 10
  text "", 136, 295 105 20 10
  text "", 137, 295 115 20 10
  text "", 138, 295 125 20 10
  text "", 139, 295 135 20 10
  text "", 140, 295 145 20 10
  text "", 141, 295 155 20 10
  text "", 142, 295 165 20 10
  text "", 143, 295 175 20 10
  text "", 144, 295 185 20 10
  text "", 145, 295 195 20 10
  text "", 146, 295 205 20 10
  text "", 147, 295 215 20 10

  text "", 148, 340 25 20 10
  text "", 149, 340 35 20 10
  text "", 150, 340 45 20 10
  text "", 151, 340 55 20 10
  text "", 152, 340 65 20 10
  text "", 153, 340 75 20 10
  text "", 154, 340 85 20 10
  text "", 155, 340 95 20 10
  text "", 156, 340 105 20 10
  text "", 157, 340 115 20 10
  text "", 158, 340 125 20 10
  text "", 159, 340 135 20 10
  text "", 160, 340 145 20 10
  text "", 161, 340 155 20 10
  text "", 162, 340 165 20 10
  text "", 163, 340 175 20 10
  text "", 164, 340 185 20 10
  text "", 165, 340 195 20 10
  text "", 166, 340 205 20 10
  text "", 167, 340 215 20 10

  box "", 506, 5 160 90 50

  text "Rand", 74, 10 165 20 10
  text "Damage", 75, 30 165 20 10
  text "Percentage", 76, 55 165 30 10

  text "217", 77, 10 175 20 10
  text "236", 78, 10 185 20 10
  text "255", 79, 10 195 20 10

  text "", 80, 30 175 20 10
  text "", 81, 30 185 20 10
  text "", 82, 30 195 20 10

  text "", 83, 55 175 20 10
  text "", 84, 55 185 20 10
  text "", 85, 55 195 20 10

  button "Calculate", 510, 5 215 90 10

  box "", 507, 5 230 85 30
  text "", 201, 10 235 50 10
  text "", 202, 10 245 50 10
}

on *:dialog:damcalcer:init:0: {
  did -a damcalcer 10 1
  did -a damcalcer 10 1.5
  did -a damcalcer 12 1
  did -a damcalcer 12 1.1
  did -a damcalcer 14 1
  did -a damcalcer 14 1.5
  did -a damcalcer 16 0.25
  did -a damcalcer 16 0.5
  did -a damcalcer 16 1
  did -a damcalcer 16 2
  did -a damcalcer 16 4
}

on *:dialog:damcalcer:sclick:510: {
  cp1
  calcsimple
  cp2
  cp3
  surv
}

alias cp1 {
  var %a $int($calc(0.4 * $did(damcalcer,2)))

  var %b $calc(%a + 2)

  var %c $calc( %b * $did(damcalcer,4) * $did(damcalcer,6) )

  var %d $int($calc( %c / $did(damcalcer,8) ))

  var %e $int($calc( %d / 50 ))

  var %f $calc( %e + 2 )

  var %g $int($calc( %f * $did(damcalcer,10) ))

  var %h $int($calc( %g * $did(damcalcer,12) ))

  var %i $int($calc( %h * $did(damcalcer,14) ))

  var %j $int($calc( %i * $did(damcalcer,16) ))

  set %dam1 %j
}

alias calcsimple {
  var %dam.ave $calc( ( %dam1 * 236 ) / 255 ))
  var %dam.min $calc( ( %dam1 * 217 ) / 255 ))

  did -o damcalcer 80 1 $int( $calc( ( %dam1 * 217 ) / 255 ) )
  did -o damcalcer 81 1 $int( $calc( ( %dam1 * 236 ) / 255 ) )
  did -o damcalcer 82 1 $int( %dam1 )

  did -o damcalcer 83 1 $round( $calc( ( %dam.min / $did(damcalcer,18) ) * 100 ) ,2)
  did -o damcalcer 84 1 $round( $calc( ( %dam.ave / $did(damcalcer,18) ) * 100 ) ,2)
  did -o damcalcer 85 1 $round( $calc( ( %dam1 / $did(damcalcer,18) ) * 100 ) ,2)
}

alias cp2 {
  var %didno 90
  while ( %didno < 109 ) {
    var %randno $calc( %didno + 127 )
    did -o damcalcer %didno 1 $int( $calc( ( %dam1 * %randno ) / 255 ) )
    inc %didno
  }
  var %pdidno 109 
  while ( %pdidno < 128 ) {
    var %prandno $calc( %pdidno + 108 )
    did -o damcalcer %pdidno 1 $round( $calc( ( ( %dam1 * %prandno ) / 255 ) / $did(damcalcer,18) * 100) ,2)
    inc %pdidno
  }
}
alias cp3 {
  var %didno 128
  while ( %didno < 148 ) {
    var %randno $calc( %didno + 108 )
    did -o damcalcer %didno 1 $int( $calc( ( %dam1 * %randno ) / 255 ) )
    inc %didno
  }
  var %pdidno 148
  while ( %pdidno < 168 ) {
    var %prandno $calc( %pdidno + 88 )
    did -o damcalcer %pdidno 1 $round( $calc( ( ( %dam1 * %prandno ) / 255 ) / $did(damcalcer,18) * 100) ,2)
    inc %pdidno
  }
}
alias surv {
  var %hp $did(damcalcer,18)
  var %rander 217

  :loop

  if ( %rander < 256 ) {
    var %s1 $int( $calc( %dam1 * %rander ) )
    var %s2 $calc( %s1 / 255 )
    if ( %s2 < %hp ) {
      inc %rander
      goto loop
    }
    else { 
      var %s3 $calc( 255 - %rander )
      var %s4 $calc( 38 - %s3 )
      var %s5 $calc( ( %s4 / 38 ) * 100 ) 
      did -o damcalcer 201 1 %s4 out of 38
      did -o damcalcer 202 1 $round(%s5,2) % chance
      goto end2
    }
  }
  else { goto end }
  :end
  did -o damcalcer 201 1 38 out of 38
  did -o damcalcer 202 1 100 % chance
  :end2
}
 
#6
Mekkah, what's this "Magic Stat" guide you made? I was just about to start making one (see sig) and was thinking that maybe one of the pros has already made it... Have you? If so, where is it?
 

Mekkah

is a Super Moderatoris a Tutor Alumnusis a Site Staff Alumnusis a Live Chat Contributor Alumnusis a CAP Contributor Alumnusis a Contributor Alumnusis a Smogon Media Contributor Alumnusis an Administrator Alumnus
Super Moderator
#7
It is quite close to your wall-breaking project, but it was made for Advance. However, it was not made specifically for walls: I had Ice Beam on Salamence, Thunderbolt on Gyarados and a few others.

As the site is offline it is nowhere to be found, but I might still have it on my computer.

EDIT: All I found so far is a few updates:

Flamethrower/Fire Blast on Metagross

Using a 353/216 HP/Special Defense Metagross as an example here, which is the maximum Leftovers recovery +1 extra, and no Special Defense EVs.

No STAB

Flamethrower, 2HKO:
average: 274
guaranteed: 298

Fire Blast, 2HKO:
average: 236
guaranteed: 217

Flamethrower/Fire Blast, OHKO:
nothing

STAB

Flamethrower, 2HKO:
average: 182
guaranteed: 198

Fire Blast, 2HKO:
anything

Flamethrower, OHKO:
average: 342
guaranteed: 371

Fire Blast, OHKO:
average: 270
guaranteed: 294

SPEED

By popular demand, I added a Speed list of common Pokémon, will be bigger later on. The original list was made by chaos and reposted by ToP, but I made this totally out of database info.

NORMAL STANDARD PLAY - Absolute Max Speeds

Note how these are not always used (and some of these Pokémon being max Speed and +nature is even stupid), but just adding 1 to these guarantees you outspeed any of the group and below.

394 - Aerodactyl, Jolteon
372 - Dugtrio, Sceptile, Alakazam
361 - Raikou, Starmie
350 - Gengar, Tauros
328 - Salamence, Dodrio, Zapdos, Celebi, Slaking, Flygon, Jirachi
317 - Houndoom
295 - Heracross
287 - Gyarados, Milotic
286 - Blaziken, Medicham
262 - Magneton, Breloom
243 - Tyranitar

Anything below is beyond dumb. Only added Tyranitar because some people like to max Speed/Attack on it and use Jolly so it beat Starmie after a Dragon Dance.

NORMAL STANDARD PLAY - More common Speeds

374 - Aerodactyl, Jolteon
363 - Dugtrio, Sceptile, Alakazam
352 - Raikou, Starmie
330 - Tauros, Gengar, Starmie, Dugtrio
300 - Dodrio, Zapdos, Celebi
299 - Salamence, Slaking, Flygon
295 - Heracross
286 - Medicham, Blaziken
273 - Smeargle
264 - Salamence, Gyarados, @Salac Berry Pokémon
262 - Magneton, Breloom
221 - Tyranitar
220 - Gyarados

Now, we come to the slow guys. Usually the Pokémon here are more defensive Pokémon, so speed is less important.

~206: Kingdra, Suicune
~200: Metagross, Tyranitar, Gyarados, Exeggutor, any other weather users
~176: Skarmory, Ludicolo, Magneton, Metagross
~166: Umbreon, Vaporeon
~96: Snorlax
~86: Dusclops

Note how some Pokémon's speeds vary a lot per trainer. Some people feel Starmie's Special Attack and Speed absolutely need to be a top, but I prefer having some defensive EVs and rarely use more than 330 Speed. Same goes for Heracross sometimes, or Raikou. Gengar's Speed usually differs per set: if it's a mixed set, less leftover EVs for Speed.

Of course, that a Pokémon's Speed here is "common" doens't mean you should use it: those are what you will meet the most. Don't be shy to for example bring Metagross to 207, beating any Suicune or Kingdra (without Rain Dance) so you might finish it off. Feel free to put Medicham or Heracross at 274 so it can beat up Smeargle in time. Getting a 98 Speed Dusclops to be able to Will-o-Wisp Snorlax in time is not a bad idea.

EDIT 2: God thanks back then we posted everything on the forums before it was uploaded.

http://www.smogon.com/forums/showthread.php?t=2756
 
#8
I just downloaded mIRC and saw this, I installed it, everything works perfectly, but what is the 38/38 and 100% chance thing? Also, is this up-to-date? If not, how do I delete it so if I ress F5 nothing happens?