Programming Problem with home made Damage Calc

Hey everyone.

I'm close to finishing a Damage Calculator that works through Microsoft Excel.

(Doing it like this for some cool features you can't do through internet. I'll be giving away more details when it's done.)

The only problem I have at the moment, is that there is a 1% chance that my calc is off by 1-2 HP on level 50 (3-5 HP on level 100).

I'm thinking the faulth lies in the rounding down of the formula, but I can't seem to find a decent explenation where the formula chooses to round down in it's calculations.


Is there anyone that knows this ? If so, could that person please put a detailed answer?
Would help me out so much :/
 

Nix_Hex

Uangaana kasuttortunga!
is a Site Content Manager Alumnusis a Forum Moderator Alumnusis a Researcher Alumnusis a Top Contributor Alumnusis a Battle Simulator Moderator Alumnus
The best thing for you to do right now is to upload the spreadsheet so others can see the formulas and help diagnose the problem and come up with a solution. Post it asap and I'll see what I can do. Thanks for helping out!
 
The best thing for you to do right now is to upload the spreadsheet so others can see the formulas and help diagnose the problem and come up with a solution. Post it asap and I'll see what I can do. Thanks for helping out!
Thanks for offering some help. I'll post the information in a few minutes.

I think i've found the real problem (though don't know how to solve it). I'm not rounding down wrong. I've put some things in the wrong order I think.
It's because my damage calc originated from Gen4, and in Gen 5 and 6, some orders have changed.

:/

I'll post my file in a sec ^_^

EDIT: I can't seem to upload an Excel File, so I'll just type in what my Formula Looks like now, with some screenshots :/
 
Last edited:
Note that I round down at each step (which is noted below in red). I'm not having problems with that, it seems.

(1) Level * 2 / 5
(2) (1) + 2
(3) (2) * BasePower * [Sp]Atk / 50

BasePower = HH * BP * IM * Ch * MS * WS * OAM * FAM
HH= Helping Hand (being 1,5 if yes, else 1)
BP= Looks at the actual base power of a move (combined variating and moves don't don't variate)
IM= Item Multiplier (includes Muscle Band, Wise Glasses, Adamant Orb, Lustrous Orb, Griseous Orb and Type Gems)
Ch= Charge being used, then an Electric Type Attack being used (2 if yes, else 1)
MS= Mudsport (0,5 or 1)
WS= Watersport (0,5 or 1)
OAM= Own Ability Multiplier (There's a lot in here, not gonna write it all down lol)
FAM= Foes Ability Multiplier (Same here. Lot going on in here as well)

[Sp]Atk = If Foul Play -> uses Attack of opponent. If not Foul Play -> Looks for the Final Atk or Final SpAtk (depending on the move being used)
Final Atk: Looks at opponent having Unaware, your stat boosts and the ability Simple being into play. Some abilities and items (Huge Power, Pure Power, Flower Gift, Guts, Toxic Boost, Hustle, Burned without Guts, Choice Band, Light Club, Thick Club and Defeatist)
Final SpAtk: Same thing but with following abilities and items: Solar Power, Flare Boost, Choice Specs, Light Ball, Soul Dew, DeepSeaTooth

(4) (3) / [Sp]Def

[Sp]Def = If Psyshock, Psystrike or Secret Sword it uses Defense, else it looks at the type of move, and checks the Final Def or Final SpDef.
Final Def: Same as with the Attacking stats, but with following abilities and items: Metal Powder, Marvel Scale, Eviolite
Final SpDef: Same again with abilities and items: (Sandstorm + Rock Type), Soul Dew, Metal Powder, DeepSeaScale, Flower Gift, Eviolite, Assault Vest

(5) (4) * Mod1

Mod1= RL * MB * SR * FF
RL= Reflect and Light Screen being up with the necessary abilities.
MB= Multiplayer Battle. In a 2vs2 or 3vs3 some moves have different options.
SR= Sun or Rain Multiplier
FF= Flash Fire Boost

(6) (5) + 2
(7) (6) * CH

CH= Critical Hit, being decided if the move used was Frost Breath or Storm Throw, and if the user has Sniper as an ability.

(8) (7) * Mod2

Mod2= Life Orb * Metronome * Me First

(9) (8) * RANDOM

We have a split of 2 right here. RANDOM being 85 or 100 respectively

(10) (9) / 100
(11) (10) * STAB

STAB= 2, if Adaptability and right typing. 1,5 if right typing and no Adaptability. Else 1.

(12) (11) * Type

Type= Effectiveness, making a choice between 0, 0.25, 0.5, 1, 2, 4

(13) (12) * Mod3

Mod3= Multiscale * (Solid Rock or Filter) * Expert Belt * Tinted Lens * Attack Reducing Berry * Immunity


At this point you get 2 values (because at the RANDOM it gets split up. These 2 values are the Min and Max amount of HP infliction. With a simple calculation you got to %.
Though somewhere along these lines, I mess a bit up, cause I'm off by 1-2 HP sometimes.

(This has happened mostly when I use a Life Orb. It could be that I misplaced that somewhere, along with some other things)

I hope this was clear enough. Here's also a Screenshot of how the excel file (the calcing part) looks right now.

http://i.imgur.com/BG9ScDc.png
 

Nix_Hex

Uangaana kasuttortunga!
is a Site Content Manager Alumnusis a Forum Moderator Alumnusis a Researcher Alumnusis a Top Contributor Alumnusis a Battle Simulator Moderator Alumnus
You can upload it to google drive and make it publicly available, that way I can download it and experiment with it myself because I really need to sit down with the thing. I really only use Excel for data plotting and math algorithms so this will be somewhat new territory for me.
 
Life Orb is supposed to be grouped with Multiscale, EBelt, etc. As is Metronome. Me First belongs with the BasePower multipliers. The exact method of calculating damage can be found here. https://www.smogon.com/bw/articles/bw_complete_damage_formula#final
Thanks, that could very well be it. I already found that link too, but it's so much info to go through, and it was really hard to find the right stuff for me xD
I'm gonna try what you suggested. If the damage calc on Greninja vs Chansey is suddenly fixed, I'll let it know here :)

EDIT: It didnt totally work out. I put those 3 in the right stuff, and something changed, but not enough.

In the same calc (Greninja (8EV, 30IV) Life Orb Low Kick vs Eviolite Chansey (max HP, Max Def, Bold)) I should get 109-133 HP damage on level 50.

First I got 110 - 132, with your changes I go to 109-132.

So something changed for the better, but not everything. I guess I have to keep looking at it.
Your tips were definitaly useful though, so thanx
 
Last edited:

Nix_Hex

Uangaana kasuttortunga!
is a Site Content Manager Alumnusis a Forum Moderator Alumnusis a Researcher Alumnusis a Top Contributor Alumnusis a Battle Simulator Moderator Alumnus
Sorry for another vague answer but in the past I've realized that the way certain operations work in Excel are slightly different than high level languages. Different enough to where 109-132 would happen instead of 109-133. I'll look more closely when a I get a chance.
 

V4Victini

再起不能
is a Battle Simulator Admin Alumnusis a Community Leader Alumnusis a Programmer Alumnusis a Top Researcher Alumnus
Thanks, that could very well be it. I already found that link too, but it's so much info to go through, and it was really hard to find the right stuff for me xD
I'm gonna try what you suggested. If the damage calc on Greninja vs Chansey is suddenly fixed, I'll let it know here :)

EDIT: It didnt totally work out. I put those 3 in the right stuff, and something changed, but not enough.

In the same calc (Greninja (8EV, 30IV) Life Orb Low Kick vs Eviolite Chansey (max HP, Max Def, Bold)) I should get 109-133 HP damage on level 50.

First I got 110 - 132, with your changes I go to 109-132.

So something changed for the better, but not everything. I guess I have to keep looking at it.
Your tips were definitaly useful though, so thanx
Try manually calculating your changes at each step and see if you can find where things go wrong.

EDIT: Also uploading would help us find the little dilemma as well :o
 
Try manually calculating your changes at each step and see if you can find where things go wrong.

EDIT: Also uploading would help us find the little dilemma as well :o
I've send it to NixHex to upload for me. He proposed that himself, since I don't know yet how to do that :/
 

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

Top