1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.
  2. Guest, PO has ceased our separate tiering and adopted Smogon tiers for SM. More information and updates here.

    Dismiss Notice

[Battle Scripting] Damage Calculator Battle Script (v0.205)

Discussion in 'Server and Client Scripting' started by Nicehat, Jun 11, 2015.

  1. Nicehat

    Nicehat PO client damage calc: preview.tinyurl.com/o8e7hss

    Joined:
    Jun 5, 2011
    Messages:
    373
    Likes Received:
    77
    edit: not updating until I feel like playing Pokemon again and have a lot of free time

    June 12, 2015: Updated, see below for details (v0.205)
    After complaining in a general chat thread I figured I'd throw something together myself because why not

    [​IMG]
    Latest Script Link (v0.205) - http://pastebin.com/raw.php?i=TAy7kSXr
    Latest Stable Script (v0.1) - http://pastebin.com/raw.php?i=BYYTuRdX

    Changelog
    Major Changes (v0.1->v0.2)

    -Compatible with cosmetic forme changes (Thanks Cirno)
    -Items implemented (only yours, not opponent's)
    -Psyshock/Psystrike/Freeze Dry implemented
    -Fixed damage moves implemented
    Minor Changes (v0.2->v0.205)
    -Various bugfixes
    -Hopefully reasonably stable now


    Instructions
    Plugins -> Plugin Manager -> check Script Window
    [​IMG]
    Then, Plugins -> Script Window -> Battle Scripts tab and paste everything in
    Turning off Safe Scripts is necessary.
    Probably incompatible with any other battle script you might be using unless you hack them together.
    Read below before complaining about inaccuracies or bugs because they exist and are plentiful (for the moment).

    Features:
    Calculates damage your moves will do to the opposing Pokemon before each turn.
    If any of the opposing Pokemon's moves have been used, it calculates how much damage they will do to you as well.
    Although you know your own stats, you don't know your opponent's EVs so it calculates against three EV spreads:
    For your attacks, calculates against 0 HP/0 (S)Def, 252 HP/0 (S)Def, and 252HP/252+ (S)Def respectively
    For your opponent's attacks, calculates with them at 0 (S)Atk, 252 (S)Atk, and 252+ (S)Atk respectively
    These three spreads generally encompass most standard Pokemon sets, but obviously aren't guaranteed to be accurate if your opponent has a specialized EV spread. Still good enough to guesstimate though (at least you can tell the least possible damage you can do and most possible damage your opponent can do)

    Bugs
    -Berries/other use items don't disappear after use
    -Trick/Knock Off aren't tracked

    Implemented
    -Standard moves (fixed base power and nothing fancy, like Ice Beam or Crunch or what have you)
    -Fixed damage moves (Seismic Toss, Psywave, Sonicboom, etc)
    -Items (mostly every competitively relevant item anyway aka not Metronome or Air Balloon)
    -Compatibility with cosmetic and functional formes
    -Scrappy (if it could possibly exist)
    -Psyshock, Psystrike, Freeze Dry

    Next up
    -Stat boosts/drops
    -Variable base power moves (except for Knock Off, Fury Cutter, Echoed Voice, etc)

    Not implemented yet (in roughly order of priority)
    -Stat boosts/drops
    -Moves with variable base power (Grass Knot, Gyro Ball, Fling, Hex, etc)
    -Field effects (Weather, Gravity, other stuff)
    -Moves that do really weird things (Triple Kick, Foul Play)
    -Foresight/Miracle Eye
    -Transform/Imposter
    -Prettier output (table format?)
    -Less ugly code and other optimizations
    -Don't show opponent's attack if they have 0 PP
    -Previous generations (gen 4+)

    Not implemented and can't/won't implement
    -Opponent's item (possibly eviolite aside, but annoying to track item loss so probably won't)
    -Abilities (with possibly a few exceptions? like Pokemon with only one ability or only one competitive ability e.g. Scizor, Ambipom, Azumarill, though probably better to just leave it mostly consistently unimplemented)
    -Struggle
    -Copycat, Mirror Move, Me First, etc.
    -Hackmons support
    -Metronome (the item) and other similar things (Fury Cutter, Echoed Voice)
    -ADV gen and earlier
     
    Last edited: Jul 27, 2015
  2. Cirno

    Cirno Romantic

    Joined:
    Aug 6, 2011
    Messages:
    517
    Likes Received:
    356
    PO Trainer Name:
    Alice
    Code (text):
    1. var statData = sys.getFileContent('db/pokes/6G/stats.txt').split('\n');
    2.         var pKey = pokeKey(pokeNum);
    3.         var statArray = searchMap(pKey, statData);
    4.        
    5.         var basehp = statArray[0];
    6.         var baseatk = statArray[1];
    7.         var basedef = statArray[2];
    8.         var basesatk = statArray[3];
    9.         var basesdef = statArray[4];
    10.         var basespe = statArray[5];
    you can pretty much fix the alternate formes issue by doing this instead (assuming this sys function works)

    Code (text):
    1.  
    2.         var statArray = sys.pokeBaseStats(pokeNum);
    3.        
    4.         var basehp = statArray[0];
    5.         var baseatk = statArray[1];
    6.         var basedef = statArray[2];
    7.         var basesatk = statArray[3];
    8.         var basesdef = statArray[4];
    9.         var basespe = statArray[5];
     
    Nicehat likes this.
  3. Zoroark

    Zoroark Aka Flare Forum Moderator Server Moderator Forum Moderator Server Moderator

    Joined:
    Jan 29, 2013
    Messages:
    873
    Likes Received:
    1,161
    PO Trainer Name:
    SkyPhoenix / Zoroark
    Well I have got to admit that this calculator thing is really useful when it comes to make choices on moves each turn. Even if this is just the beginning it's proving to be a promising implementation to the simulator. I have to say Nice Job :]

    In other news, I have a lil question about this, not a complain nor anything alike, just confused on this.
    [​IMG]

    The screenshot itself it's self explanatory on what happens. Not sure if you have encountered it yourself but I thought it was worth letting you know.
     
  4. Cirno

    Cirno Romantic

    Joined:
    Aug 6, 2011
    Messages:
    517
    Likes Received:
    356
    PO Trainer Name:
    Alice
    also my above post just fixed that issue
     
  5. Nicehat

    Nicehat PO client damage calc: preview.tinyurl.com/o8e7hss

    Joined:
    Jun 5, 2011
    Messages:
    373
    Likes Received:
    77
    Updated script: included Cirno's fix, changed some things around, and implemented including your item in the calculation! as well as a few other things
    Apparently it's not possible to get your own Pokemon's ability in battle scripts for some reason (AFAIK) so that puts a massive damper on including your Pokemon's ability for the time being

    See OP for details and link to the updated script.

    Going to be really busy next week so don't expect more updates until that dies down.

    (Also man I wish I could rename my thread title, I totally forgot I couldn't do that since I'm too used to it from being Forum Games mod over a year ago lol)
    (If someone could just take the (v0.1) out and capitalize 'Battle' and 'Script' that'd be really appreciated)


    edit: Thanks SkyPhoenix for telling me
     
    Last edited: Jun 12, 2015
  6. Kite

    Kite hi

    Joined:
    Jan 10, 2016
    Messages:
    31
    Likes Received:
    5
    PO Trainer Name:
    [TR]Kite
    Thanks so much for this very valuable battle feature, it takes much guesswork out of battles and just makes life easier ^_^
     
  7. Zoroark

    Zoroark Aka Flare Forum Moderator Server Moderator Forum Moderator Server Moderator

    Joined:
    Jan 29, 2013
    Messages:
    873
    Likes Received:
    1,161
    PO Trainer Name:
    SkyPhoenix / Zoroark
    RIP the dream, this was never finished.
     
    Kite likes this.