diff options
author | Rangi <remy.oukaour+rangi42@gmail.com> | 2018-07-19 17:05:35 -0400 |
---|---|---|
committer | Rangi <remy.oukaour+rangi42@gmail.com> | 2018-07-19 17:05:35 -0400 |
commit | c4f0021b17c9564b5592911e255d79b4140c167b (patch) | |
tree | 2432a2343796e8b94a47fec4875918d24f7f995c | |
parent | f44e2ff1c5ae5dc9ad5fdde8af5b7e378cd6dd00 (diff) |
Fix RandomPhoneMon
-rw-r--r-- | Allow-more-trainer-parties,-with-individual-DVs,-stat-experience,-and-nicknames.md | 123 |
1 files changed, 122 insertions, 1 deletions
diff --git a/Allow-more-trainer-parties,-with-individual-DVs,-stat-experience,-and-nicknames.md b/Allow-more-trainer-parties,-with-individual-DVs,-stat-experience,-and-nicknames.md index 8a71ffd..c3cbbe1 100644 --- a/Allow-more-trainer-parties,-with-individual-DVs,-stat-experience,-and-nicknames.md +++ b/Allow-more-trainer-parties,-with-individual-DVs,-stat-experience,-and-nicknames.md @@ -69,7 +69,7 @@ Edit [wram.asm](../blob/master/wram.asm): The `wOtherTrainerType` byte will store the trainer type while their data is being read. -Finally, edit [engine/battle/read_trainer_party.asm](../blob/master/engine/battle/read_trainer_party.asm): +Edit [engine/battle/read_trainer_party.asm](../blob/master/engine/battle/read_trainer_party.asm): ```diff ReadTrainerParty: @@ -255,6 +255,57 @@ Finally, edit [engine/battle/read_trainer_party.asm](../blob/master/engine/battl We've replaced the four routines `TrainerType1`, `TrainerType2`, `TrainerType3`, and `TrainerType4` with a single `ReadTrainerPartyPieces` routine. If you compare them all side by side, you'll notice how the chunks of `ReadTrainerPartyPieces` are all taken from the old routines, but now they don't need repeating. +Finally, edit [engine/overworld/wildmons.asm](../blob/master/engine/overworld/wildmons.asm): + +```diff + RandomPhoneMon: + ; Get a random monster owned by the trainer who's calling. + ... + + .skip_name + ld a, BANK(Trainers) + call GetFarByte + inc hl + cp "@" + jr nz, .skip_name + + ld a, BANK(Trainers) + call GetFarByte + inc hl +- ld bc, 2 ; level, species +- cp TRAINERTYPE_NORMAL +- jr z, .got_mon_length +- ld bc, 2 + NUM_MOVES ; level, species, moves +- cp TRAINERTYPE_MOVES +- jr z, .got_mon_length +- ld bc, 2 + 1 ; level, species, item +- cp TRAINERTYPE_ITEM +- jr z, .got_mon_length +- ; TRAINERTYPE_ITEM_MOVES +- ld bc, 2 + 1 + NUM_MOVES ; level, species, item, moves +-.got_mon_length +; b = trainer type + ld b, a +; c = mon length +; All trainers use 2 bytes for level and species + ld c, 2 +; TRAINERTYPE_ITEM uses 1 more byte + bit TRAINERTYPE_ITEM_F, b + jr z, .no_item + inc c +.no_item +; TRAINERTYPE_MOVES uses 4 more bytes + bit TRAINERTYPE_MOVES_F, b + jr z, .no_moves + ld a, 4 + add c + ld c, a +.no_moves +; bc = mon length + xor a + ld b, a +``` + If we stopped here, the code would be cleaner and smaller, but would not do anything new. So let's continue. @@ -363,6 +414,27 @@ LoadEnemyMon: call CopyBytes ``` +Finally, edit [engine/overworld/wildmons.asm](../blob/master/engine/overworld/wildmons.asm) again: + +```diff + RandomPhoneMon: + ; Get a random monster owned by the trainer who's calling. + ... + + ld a, BANK(Trainers) + call GetFarByte + inc hl + ; b = trainer type + ld b, a ++; TRAINERTYPE_NICKNAME has uneven length, so always use the first mon ++ bit TRAINERTYPE_NICKNAME_F, b ++ jr nz, .got_mon + ; c = mon length + ; All trainers use 2 bytes for level and species + ld c, 2 + ... +``` + Now you can give nicknames to enemy Pokémon. Be sure to keep the data in order: level, species, nickname, held item, moves. For example, these are parties for your rival that give him nicknames, held items, and a new Pokémon: @@ -546,6 +618,27 @@ Then edit [engine/battle/core.asm](../blob/master/engine/battle/core.asm) again: ... ``` +Finally, edit [engine/overworld/wildmons.asm](../blob/master/engine/overworld/wildmons.asm) again: + +```diff + RandomPhoneMon: + ; Get a random monster owned by the trainer who's calling. + ... + ; c = mon length + ; All trainers use 2 bytes for level and species + ld c, 2 ++; TRAINERTYPE_DVS uses 2 more bytes ++ bit TRAINERTYPE_DVS_F, b ++ jr z, .no_dvs ++ inc c ++ inc c ++.no_dvs + ; TRAINERTYPE_ITEM uses 1 more byte + bit TRAINERTYPE_ITEM_F, b + jr z, .no_item + ... +``` + Now you can give custom DVs to enemy Pokémon. Be sure to keep the data in order: level, species, nickname, DVs, held item, moves. DVs are specified as `$AD, $SP`, where *A* = attack, *D* = defense, *S* = speed, and *P* = special, with each one going from $0 to $F (15). @@ -719,6 +812,34 @@ Then edit [engine/battle/core.asm](../blob/master/engine/battle/core.asm) again: predef CalcMonStats ``` +Finally, edit [engine/overworld/wildmons.asm](../blob/master/engine/overworld/wildmons.asm) again: + +```diff + RandomPhoneMon: + ; Get a random monster owned by the trainer who's calling. + ... + ; c = mon length + ; All trainers use 2 bytes for level and species + ld c, 2 + ; TRAINERTYPE_DVS uses 2 more bytes + bit TRAINERTYPE_DVS_F, b + jr z, .no_dvs + inc c + inc c + .no_dvs ++; TRAINERTYPE_STAT_EXP uses 10 more bytes ++ bit TRAINERTYPE_STAT_EXP_F, b ++ jr z, .no_stat_exp ++ ld a, 10 ++ add c ++ ld c, a ++.no_stat_exp + ; TRAINERTYPE_ITEM uses 1 more byte + bit TRAINERTYPE_ITEM_F, b + jr z, .no_item + ... +``` + Now you can give custom stat experience to enemy Pokémon. Be sure to keep the data in order: level, species, nickname, DVs, stat experience, held item, moves. Stat experience is specified as five *words*, not bytes, because each of the five stats (HP, Attack, Defense, Speed, and Special) has two-byte experience going from $0000 to $FFFF (65,535). |