1. Welcome to Smogon Forums! Please take a minute to read the rules.

# Programming mIRC Damage Calculator

Discussion in 'Technical Projects' started by Misty, Jun 2, 2007.

1. ### Mistyoh

Joined:
Mar 8, 2005
Messages:
7,153
The attached file is a fairly comprehensive damage calculator, used to calculate damage at level 100, created by me. I'm putting this here because people keep asking for it. To use it, save the file to your computer, then go into mIRC, hit alt+r, select the Aliases tab, then go to File -> Load... From there, find and open the damagecalc.txt file. You should immediately see the following:

dam {
blah blah blah
etc etc etc
stuff
...

Close the window.

Once you've loaded it, the usage is as follows:

/dam <attack> <defense> <base power> [target HP] <multiplier equation>

The multiplier equation is the trickiest part, so here are some examples:

A 359 attack Garchomp, holding Dragon Plate, using Outrage on a Suicune with 350 defense and 404HP:

/dam 359 350 120 404 * 1.5 * 1.2

The 1.5 indicates STAB; the 1.2 indicates the Dragon Plate. The * means that these numbers are being multiplied into the final numbers. If you desire, you can use / to divide -

A 359 attack Garchomp, holding Dragon Plate, using Outrage on a Skarmory with 400 defense and unknown HP:

/dam 359 400 120 * 1.5 * 1.2 / 2

The 1.5 and 1.2 are as before. The / 2 indicates the attack is not very effective, so the damage is halved. Note that the HP parameter is optional.

As a note - Choice items, Soul Dew, any stat boosts or drops, and abilities such as Guts should be multiplied directly into the attack stat. However, you can usually put these in the multipliers - as far as I can tell, it makes no difference.

File size:
853 bytes
Views:
465
2. ### MekkahSuper Moderator

Joined:
Feb 8, 2005
Messages:
14,218
In other words, meybe stop asking "how much does x do to y" and do the hard work yourself. (:

If you're amazing like me and hate aliases you can always change the "dam" from the first line to "alias" dam and put the whole thing in remote. But that's just because I'm awesome.

Joined:
Jan 30, 2007
Messages:
1,385
Thanks, Misty. This will be very useful indeed.
4. ### Akayfortyseven

Joined:
Apr 18, 2006
Messages:
1,145
Thanks for this.
5. ### X-Actnp: Biffy Clyro - Shock Shock

Joined:
Feb 17, 2006
Messages:
4,675
They do make a difference, but it's a minimal one - usually by 1 or 2 damage at most. If people are THAT fussy about their damage calculation (like I am), they must calculate those stat boosts in the attack stat, and not the multipliers, as Misty says. This difference, incidentally, is mainly because of the "+2" part in the damage formula.

Say you have a Choice Banded Tyranitar with a normal 403 attack as an example. This 403 is multiplied by 1.5, giving 604. Say it's using Stone Edge against a Pokemon with 200 defense for neutral damage.

Maximum damage will be ((604 * 100 * 0.84) / 200) + 2) * 1.5 = 382
Minimum damage will be ((604 * 100 * 0.84) / 200) + 2) * 0.85 * 1.5 = 324

If we put the 1.5 in the multipliers part, we'd have:

Maximum damage: ((403 * 100 * 0.84) / 200) + 2) * 1.5 * 1.5 = 384
Minimum damage: ((403 * 100 * 0.84) / 200) + 2) * 0.85 * 1.5 * 1.5 = 325

As I said, this doesn't change the damage percentage much, but, for all the fussy people out there, it makes a difference of 1 or 2 damage.
6. ### _Zero1

Joined:
Jun 12, 2007
Messages:
12
How does this work exactly? I followed all of the steps, but every time I open it I get a bunch of \$ and ? and the occasional word "Attack" or "Defense" here and there... Is there a place I need to open the file or what? Sorry for the dumb question but I've never used mIRC before if that has anything to do with it...
7. ### Mistyoh

Joined:
Mar 8, 2005
Messages:
7,153
Use /dam in a window, as shown... it has no GUI interface, you just enter text and it gives back.
8. ### Spidersonic

Joined:
Mar 25, 2005
Messages:
59
Thanks a lot for this. I'll use it in a project to give the community a list of "magic numbers" for certain pokes to reach; set attacking stats that enable it to OHKO or 2HKO specific walls, more specifically.
9. ### Konako

Joined:
Mar 27, 2007
Messages:
69
When I try to open the attachment it says I'm not allowed to access that page. Help?
10. ### Mistyoh

Joined:
Mar 8, 2005
Messages:
7,153
Probably because you "could be banned".
11. ### TheLegendaryX

Joined:
Jun 15, 2007
Messages:
6
Why can't I open the attachment?

MetalKid's calculator is good but it's a lot of hassle. This one has been recommended to me so I want to try it.
12. ### Haitian

Joined:
Aug 3, 2005
Messages:
114
Is there anyway to make the script work on ChatZilla? I used it on mIRC and it worked like a charm (great work on this, very helpful), but I put it on ChatZilla and get the following on every start-up: "SyntaxError: missing ; before statement @ <file:///C:/My%20Documents/pokes/damagecalc.txt> 1"
13. ### MekkahSuper Moderator

Joined:
Feb 8, 2005
Messages:
14,218
I'm pretty sure it only works for mIRC, that's what the program language is written for.
14. ### Haitian

Joined:
Aug 3, 2005
Messages:
114
I was hoping since the 2 were similar, that it'd work for both. Oh well.
15. ### crabnebula

Joined:
Jul 1, 2006
Messages:
583
No, it doesn't work on chatzilla because mirc has its own scripting language, which I am pretty sure isn't recognized by Chatzilla. My primary reason to switch from chatzilla to mirc :(
16. ### Iggy Koopa

Joined:
Aug 14, 2007
Messages:
3
A modified version

I've made a modified version of the calculator (with some help from Team Rocket Elite).

This version does the following things:
• Calculates OHKO, 2HKO (including Sandstorm and Leftovers) chances.
• Tells you how high an attack stats is required for a guaranteed OHKO for things that have a chance of OHKOing.
• Allow you to enter things such as "405*2" in place of stats to calculate boosted stats more easily (ie Porygon-Z after Nasty Plot using Ice Beam on a max HP/min SpDef Blissey after a Calm Mind would be /dam 405*2 306*1.5 95 714).
Examples:
• Porygon-Z with a +2 SpAtk boost using Ice Beam on a +1 SpDef Blissey: /dam 405*2 306*1.5 95 714
• Persian with a Life Orb using a Technicianed Icy Wind on Skarmory: /dam 251 176 55*1.5 334 *1.3
• Rampardos with a +6 Atk boost holding Life Orb using a super-effective STAB Stone Edge on Dragonite: /dam 471*4 226 100 324 *1.3 *2 *1.5
Code:
```dam {
var %basedam = \$calc((\$int(\$calc(\$int(\$calc(42 * \$int(\$calc(\$1)) * \$int(\$calc(\$3)) / \$int(\$calc(\$2)))) / 50)) + 2) \$iif(\$4 isnum,\$5-,\$4-))
if (\$4 isnum) {
var %mn = \$int(\$calc(%basedam *.85)) | var %mx = \$int(%basedam)
var %min = \$round(\$calc(%mn * 100 / \$4),2) | var %max = \$round(\$calc(%mx * 100 / \$4),2)
if (%mn < \$4 && %mx >= \$4) {
var %i 0 | while (\$int(\$calc(%basedam * ((%i + 85) / 100))) < \$4) { inc %i }
var %x \$int(\$calc(\$1))
while (\$int(\$calc((\$int(\$calc(\$int(\$calc(42 * %x * \$int(\$calc(\$3)) / \$int(\$calc(\$2)))) / 50)) + 2) \$5- *.85)) <= \$4) { inc %x }
var %OHKO ( \$+ \$calc(100 - %i / .16) \$+ % OHKO, \$calc(%x - \$int(\$calc(\$1))) more \$+(point,\$iif(\$calc(%x - \$int(\$calc(\$1))) != 1,s)) required for OHKO)
}
if (%mn < \$int(\$calc(\$4 / 2)) && %mx >= \$int(\$calc(\$4 / 2))) {
var %j 0 | var %a 0 | while (%j <= 16) {
var %i 0 | while (\$calc(\$int(\$calc(%basedam * ((%i + 85) / 100))) + \$int(\$calc(%basedam * ((%j + 85) / 100)))) < \$4 && %i < 15) { inc %i }
inc %a %i | inc %j
}
var %THKO \$calc((256 - %a)/2.56) \$+ % 2HKO
}
if (%mn <= \$int(\$calc(\$4 \$iif(\$calc(\$4 / 16) < 1,/2-1,*15/32))) && %mx >= \$int(\$calc(\$4 \$iif(\$calc(\$4 / 16) < 1,/2-1,*15/32)))) {
var %j 0 | var %a 0 | while (%j <= 16) {
var %i 0 | while (\$calc(\$int(\$calc(%basedam * ((%i + 85)/100))) + \$int(\$calc(%basedam * ((%j + 85)/100)))) < \$int(\$calc(\$4 \$iif(\$calc(\$4 / 16) < 1,-1,*15/16))) && %i < 15) { inc %i }
inc %a %i | inc %j
}
var %THKO \$iif(%THKO,\$+(%THKO,\$chr(44))) \$calc((256 - %a)/2.56) \$+ % \$iif(!%THKO,2HKO) with Sandstorm
}
if (%mn <= \$int(\$calc(\$4 \$iif(\$calc(\$4 / 16) < 1,/2+1,*17/32))) && %mx >= \$int(\$calc(\$4 \$iif(\$calc(\$4 / 16) < 1,/2+1,*17/32)))) {
var %j 0 | var %a 0 | while (%j <= 16) {
var %i 0 | while (\$calc(\$int(\$calc(%basedam * ((%i + 85)/100))) + \$int(\$calc(%basedam * ((%j + 85)/100)))) < \$int(\$calc(\$4 \$iif(\$calc(\$4 / 16) < 1,+1,*17/16))) && %i < 15) { inc %i }
inc %a %i | inc %j
}
var %THKO \$iif(%THKO,\$+(%THKO,\$chr(44))) \$calc((256 - %a)/2.56) \$+ % \$iif(!%THKO,2HKO) with Leftovers
}
echo 4 -a \$1 attack vs \$2 defense, \$3 \$+(power,\$iif(\$5,\$+(\$chr(40),\$5-,\$chr(41))),\$chr(44)) \$4 max HP: %min \$+ % - %max \$+ % \$iif(%OHKO,%OHKO) \$iif(%THKO,\$+(\$chr(40),%THKO,\$chr(41)))
}
else { echo 4 -a \$1 attack vs \$2 defense, \$3 \$+(power,\$iif(\$4,\$+(\$chr(40),\$4-,\$chr(41))),:) \$int(\$calc(%basedam *.85)) - \$int(%basedam) }
}
```
17. ### X-Actnp: Biffy Clyro - Shock Shock

Joined:
Feb 17, 2006
Messages:
4,675
This produces damage percentages that are more accurate. Well done!
18. ### Iggy Koopa

Joined:
Aug 14, 2007
Messages:
3
I just noticed a small problem with the non-HP based damage calculations. It has been fixed and the script has been updated.
19. ### comoesa

Joined:
Feb 11, 2007
Messages:
158
Now all I need to know is how to get too #smogon
20. ### Impetus

Joined:
Oct 4, 2006
Messages:
365
I was just wondering, could I put this program into my calculator (TI-84)? It would be nice to have this handy when I start to brainstorm during class.
21. ### Reflect Suicune

Joined:
Jul 28, 2005
Messages:
589
What does this accomplish?