1. New to the forums? Check out our Mentorship Program!
    Our mentors will answer your questions and help you become a part of the community!
  2. Welcome to Smogon Forums! Please take a minute to read the rules.

DP Damage Calculator (ruby)

Discussion in 'Archives' started by timw06, Jul 23, 2007.

Thread Status:
Not open for further replies.
  1. timw06

    timw06

    Joined:
    Jun 27, 2007
    Messages:
    543
    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
    [​IMG]
    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...
  2. timw06

    timw06

    Joined:
    Jun 27, 2007
    Messages:
    543
    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.

    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.
  3. david stone

    david stone Fast-moving, smart, sexy and alarming.
    is a Site Staff Alumnusis a Smogon IRC AOp Alumnusis a Programmer Alumnusis a Super Moderator Alumnusis a Researcher Alumnusis a Contributor Alumnusis a Battle Server Moderator Alumnus

    Joined:
    Aug 3, 2005
    Messages:
    5,150
    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:
  4. X-Act

    X-Act np: Biffy Clyro - Shock Shock
    is a Site Staff Alumnusis a Programmer Alumnusis a Smogon IRC SOp Alumnusis a Researcher Alumnusis a CAP Contributor Alumnusis a Tiering Contributor Alumnusis a Contributor Alumnusis an Administrator Alumnus

    Joined:
    Feb 17, 2006
    Messages:
    4,675
    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.
  5. crabnebula

    crabnebula

    Joined:
    Jul 1, 2006
    Messages:
    583
    I made one in VB. Didn't see you had made one. Oh well :(
  6. timw06

    timw06

    Joined:
    Jun 27, 2007
    Messages:
    543
    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!
  7. chaos

    chaos
    is a member of the Site Staffis a Battle Server Administratoris a Programmeris a Smogon IRC SOPis a Contributor to Smogonis an Administratoris a Tournament Director Alumnusis a Researcher Alumnus
    Owner

    Joined:
    Dec 18, 2004
    Messages:
    9,774
    Hmm... perhaps I should provide a space on the site for various calculators...
  8. Syntacus

    Syntacus

    Joined:
    Oct 2, 2007
    Messages:
    50
    Nice program, Very much appreciated.
    Haven't run in to any problems with it so far.
  9. timw06

    timw06

    Joined:
    Jun 27, 2007
    Messages:
    543
    Thanks

    [/badly disguised bump]
  10. Imblake3

    Imblake3

    Joined:
    Jun 17, 2007
    Messages:
    35
    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.
  11. timw06

    timw06

    Joined:
    Jun 27, 2007
    Messages:
    543
    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.
  12. Imblake3

    Imblake3

    Joined:
    Jun 17, 2007
    Messages:
    35
    It's working now. Thanks for the help.
  13. Medi Guy

    Medi Guy

    Joined:
    Jan 26, 2005
    Messages:
    179
    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.
  14. timw06

    timw06

    Joined:
    Jun 27, 2007
    Messages:
    543
    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.
Thread Status:
Not open for further replies.

Users Viewing Thread (Users: 0, Guests: 0)