DP Damage Calculator (ruby)

Worked on it a some more.

New in version 7:
• Accepts command line arguments
• Outputs to windows clipboard
• Order of questions and a fair bit of code rewritten.
On the other end of this link is a comprehensive downloadable damage calculator programmed in ruby.
If you have ruby installed on your system then follow these steps to make it work (if you haven't got ruby then get it here)

As of version 7 the win32-clipboard library is also needed (get it from the main download link). It should install using the RubyGems package manager.

If you can't/won't download it or are running linux then you can also comment out the first two lines of code and the 477th line (that starts Clipboard.set_data). A comment in ruby is #.

1. Go to Start > Run
2. type cmd
3. type cd [the directory where you saved the program]
4. type damagecalc7.rb

5. follow the instructions.

You can also pass in arguments from the command line (version 7 only)
All of the command line arguments take the same input as when it asks you the questions, with two exceptions:
? asks you the question but allows you to enter the variable after it in sequence on the commandline
- skips the current question and all that follow it.

The variables are inputted in this order (seperated by a space):
• Move power
• Attack Stat
• Defence Stat
• STAB
• Effectiveness
• Your item
• Your ability
• Burn?
• Foe's Item
• Foe's Ability
• Weather
• Reflect/Light Screen
• Critical Hit

Features:

• Just about every variable imaginable (Sandstorm, life orb, resistance berries, burns etc. it's all there.)
• An average damage output as well as maximum and minimum damage.
• Prompts for input rather than making you type a complicated command.
• Accepts all variables as command line arguments (NEW)
• Output automatically copied to the Windows Clipboard (NEW)

Features not present:
• Me First attack (it has a special modifier)
• Metronome item (I can't be bothered programming it in.)
• Everything else is there...
 
Version History:

damagecalc.rb
First version of the software posted quite soon after the Damage Formula went up. Didn't really do much and some of the results were incorrect.

damagecalc2.rb
An updated version with support for items and a (limited) number of attacking abilities.

damagecalc3.rb
Released after a change to the formula.

I edited the guide slightly again. It turned out that Mod2 is actually done after CH and not before it, so I just swapped their places. I should have realised this before, actually, from one of the tests that is still in my PM box, but now we can confirm it after Peterko did a bit of Critical Hit tests. Thanks once again sir!
Also, added (fatally flawed) support for burns.

damagecalc4.rb
This release does not exist. A FileFront bug meant it wouldn't let me upload this file so I had to rename it to version 5.

damagecalc5.rb
Bugfix release: Mod2 wasn't applied correctly.

damagecalc6.rb
Added more items, weather effects and defending abilities. Also fixed the buggy burn support.

damagecalc7.rb
Current version!

Added support for command line arguments and automatic copy/paste.
 

obi

formerly david stone
is a Site Content Manager Alumnusis a Programmer Alumnusis a Senior Staff Member Alumnusis a Smogon Discord Contributor Alumnusis a Researcher Alumnusis a Top Contributor Alumnusis a Battle Simulator Moderator Alumnus
Heh, I was considering making a damage calculator in Java or something if no one else made something, so this is obviously much better. :toast:
 

X-Act

np: Biffy Clyro - Shock Shock
is a Site Content Manager Alumnusis a Programmer Alumnusis a Smogon Discord Contributor Alumnusis a Top Researcher Alumnusis a Top CAP Contributor Alumnusis a Top Tiering Contributor Alumnusis a Top Contributor Alumnusis a Smogon Media Contributor Alumnusis an Administrator Alumnus
I was actually interested in writing one in Java as well.

Anyway, the reason why I posted the damage formula guide is exactly this reason: for other people to write an accurate damage calculator. I'm pleased that there's already one out. I think Metalkid and others who already have a damage calculator will soon update it to make it accurate as well.
 
Worked on it a some more.

New in version 7:
• Accepts command line arguments
• Outputs to windows clipboard
• Order of questions and a fair bit of code rewritten.

See first post for download link

Any feedback would be much appreciated!
 
I keep getting this...

C:\Documents and Settings\Curt>cd C:\ruby\Curt

C:\ruby\Curt>damagecalc7.rb
c:/ruby/lib/ruby/gems/1.8/gems/win32-clipboard-0.4.3/lib/win32/clipboard.rb:25:
uninitialized constant Win32::Clipboard::Win32API (NameError)
from c:/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:32:in `ge
m_original_require'
from c:/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:32:in `re
quire'
from C:/ruby/Curt/damagecalc7.rb:2

I'm not exactly sure what to do with the windows clipboard once i download it. Any help would be appreciated.
 
that error is caused by not having the Win32 Clipboard gem installed correctly. Run these commands as an admin.

gem uninstall win32-clipboard
gem install win32-clipboard

It should then offer to install dependencies. Accept all the defaults and they will be pulled down automatically from RubyForge.

If that doesn't do it then you could try the automatic installer although I haven't tested it.

Failing that, you should simply comment out the offending lines, namely 1, 2 and 477.

edit: calls to gem update and gem update --system also work wonders.
 
It might be nice to give a non-windows version. It's not like it's difficult to modify manually so that it works, but it would be kind for those who don't have programming experience.
 
It might be nice to give a non-windows version. It's not like it's difficult to modify manually so that it works, but it would be kind for those who don't have programming experience.
What's with this thread necromancy?

I haven't touched the code for this since October of 2007 and have no intention of going back to it now. I know there are a million and one things wrong with this calculator, for a start it uses far too many variables and makes things far too complicated, but until I can be bothered to do a complete rewrite in Pascal with a complete GUI, there are going to be no changes here.

Back when it was created, this the first accurate damage calculator (the only one following X-Act and Peterko's formula) but things have improved a lot since then. Just use libelldra's version - it runs completely in the browser and doesn't have any hefty dependencies or require command-line intervention. Doug also has a secret project which should anytime soon be releasing the best calculator out there with support for more than 2 pokemon etc.
 

Users Who Are Viewing This Thread (Users: 1, Guests: 0)

Top