All right, I finished updating the script for VBA; before I port it to BizHawk, let me make sure these interfaces seem all right...
Damage calculation:
For damage calculation, you need to pass this struct:
DamageCalculationInput = {
EnemyID,
PlayerID,
PlayerPow,
PlayerPowMult,
PlayerBadgeEffect,
EnemyType,
EnemyDef,
EnemyDefMult,
MushroomCounts = {n, s, u, m},
CurrentHammer,
GreatForce,
IsLucky
}
You can either set EnemyID to an actor # (0-5) and it'll calculate the attack power based on the in-game battle data, or set all of the inputs after PlayerID to calculate what the attack power would be without using the in-game data. PlayerID should never be set; it will be set automatically if you use EnemyID, based on which attack you request the power of.
The functions you call with that data are as follows:
Solo attacks:
{mario | luigi}{Jump | Hammer | Hand | CounterJ | CounterH}(dci)
Examples:
marioJump(dci),
luigiCounterH(dci)
Bros. attacks:
{splash | bounce | chopper | knockback | fire | thunder | swing | cyclone}{Bros | BrosAdv}(dci, (hits/strength if applicable))
Examples:
splashBros(dci),
knockbackBrosAdv(dci, hits),
swingBros(dci, strength)
Lucky! chance:
To calculate the chance of a Lucky! hit, use the following struct:
LuckyCalculationInput = {
EnemyID,
PlayerID,
PlayerStache,
PlayerLevel,
EnemyStache,
EnemyLevel,
LuckyAttack
}
Populate EnemyID & PlayerID (use MarioActorID or LuigiActorID for that) to read from memory in battle, or the rest of the values to try out arbitrary inputs, then call the function
luckyChance(lci). Doesn't support the Lucky Mushroom effect, nor do I intend to support it since it's implicitly supported in the in-battle case anyway.
Stache discounts:
Call
buyPrice(base,dg,stache) or
sellPrice(base,dg,stache), using the base price (not the sell price) of the item, its discount group (0 to 5), and the appropriate STACHE value (Mario's or Luigi's alone if only he can use the item, or their average rounded down if either can).
RNG stuff:
nthRandRange(n,range): Returns the result of rand(0,range) using the Nth RNG value. N is
0-indexed, not 1-indexed, and the function isn't guaranteed to work for N greater than 290-ish.
untwistInRange(n,range): Given a desired value N as the result of rand(0, range), returns an RNG seed value that produces the desired result. Can be useful for testing something with a desired random value, although it won't be of any help if the random engine is pointing near the end of the random buffer.