diff options
-rw-r--r-- | Replace-stat-experience-with-EVs.md | 47 |
1 files changed, 43 insertions, 4 deletions
diff --git a/Replace-stat-experience-with-EVs.md b/Replace-stat-experience-with-EVs.md index c98374b..bac7a65 100644 --- a/Replace-stat-experience-with-EVs.md +++ b/Replace-stat-experience-with-EVs.md @@ -417,9 +417,9 @@ The `CalcMonStatC` implements these formulas for stat values: In those formulas, division rounds down and square root rounds up (for example, √12 = 3.4641… rounds to 4). [Order of operations](https://en.wikipedia.org/wiki/Order_of_operations) is standard PEMDAS. -Anyway, we've just replaced √*exp* in those formulas with simply *EV*. This has consequences for progressing through the game. +Anyway, we've just replaced √*exp* in those formulas with simply *EV*. -Square roots are nonlinear, so early gains to stat experience were contributing relatively larger boosts to stats. EVs are linear, so gaining 4 EVs will be just as beneficial no matter how many you already had. +This change has consequences for progressing through the game. Square roots are nonlinear, so early gains to stat experience were contributing relatively larger boosts to stats. But EVs are linear, so gaining 4 EVs will be just as beneficial no matter how many you already had. For example, 50 EVs are equivalent to 50² = 2,500 stat exp, and 100 EVs are equivalent to 1000² = 10,000 stat exp. But getting from 50 EVs to 100 takes the same effort as from 0 to 50, whereas getting from 2,500 to 10,000 stat exp means gaining another 7,500 stat exp: three times as much effort as the first 2,500. @@ -549,7 +549,7 @@ Next, edit [data/battle_tower/parties.asm](../blob/master/data/battle_tower/part - bigdw 40000 - bigdw 35000 - bigdw 40000 -+ db 223, 200, 200, 187, 200, 200 ; EVs ++ db 224, 200, 200, 188, 200, 200 ; EVs + db 0, 0, 0, 0 ; padding dn 13, 13, 11, 13 ; DVs db 15, 5, 15, 20 ; PP @@ -569,7 +569,46 @@ Next, edit [data/battle_tower/parties.asm](../blob/master/data/battle_tower/part Numerically speaking, you just have to take the square root of each stat experience value and round down to an integer EV; but you also have to insert padding bytes, and don't corrupt the stat values (they also use `bigdw`), and do this for six stats 210 times. -I advise you to learn a scripting language like Python, Perl, Ruby, etc, and write a program to automatically process the file. +You can do this automatically with a Python script. Save this as **bt-evs.py** in the same directory as main.asm: + +```python +from math import sqrt, ceil + +def derive_ev(stat_exp_line): + stat_exp = int(stat_exp_line[len('\tbigdw '):]) + return str(int(ceil(sqrt(stat_exp)))) + +filename = 'data/battle_tower/parties.asm' + +with open(filename, 'r', encoding='utf8') as file: + lines = file.readlines() + +with open(filename, 'w', encoding='utf8') as file: + i = 0 + while i < len(lines): + line = lines[i] + + if line != '\t; Stat exp\n': + file.write(line) + i += 1 + continue + + exp_lines = lines[i+1:i+6] + evs = [derive_ev(exp_line) for exp_line in exp_lines] + evs.append(evs[-1]) # Special -> Sp.Atk and Sp.Def + file.write('\tdb {} ; EVs\n'.format(', '.join(evs))) + file.write('\tdb 0, 0, 0, 0 ; padding\n') + i += 6 + +print('Done!') +``` + +Then run `python3 bt-evs.py`, just like running `make`. It should output: + +``` +$ python3 battle-tower-evs.py +Done! +``` ## 7. Replace `MON_STAT_EXP` with `MON_EVS` everywhere |