diff options
-rw-r--r-- | Allow-more-trainer-parties,-with-individual-DVs,-stat-experience,-and-nicknames.md | 110 |
1 files changed, 109 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 8430caf..59d93f1 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 @@ -1339,4 +1339,112 @@ Anyway, we're done now. Just like [step 1](#1-refactor-trainer-types-to-use-bit- ## 6. Add a trainer type flag for variable parties -[TODO](https://hax.iimarckus.org/topic/7137/) +In this step we'll add a special flag to define variable parties for the same trainer, which will vary depending on the player's number of badges. Let's edit [constants/trainer_data_constants.asm](../blob/master/constants/trainer_data_constants.asm): + +```diff + ; TrainerTypes bits (see engine/battle/read_trainer_party.asm) + const_def + const TRAINERTYPE_MOVES_F ; 0 + const TRAINERTYPE_ITEM_F ; 1 + const TRAINERTYPE_NICKNAME_F ; 2 + const TRAINERTYPE_DVS_F ; 3 + const TRAINERTYPE_STAT_EXP_F ; 4 ++ const TRAINERTYPE_VARIABLE_F ; 5 + + ; Trainer party types (see data/trainers/parties.asm) + TRAINERTYPE_NORMAL EQU 0 + TRAINERTYPE_MOVES EQU 1 << TRAINERTYPE_MOVES_F + TRAINERTYPE_ITEM EQU 1 << TRAINERTYPE_ITEM_F + TRAINERTYPE_ITEM_MOVES EQU TRAINERTYPE_MOVES | TRAINERTYPE_ITEM + TRAINERTYPE_NICKNAME EQU 1 << TRAINERTYPE_NICKNAME_F + TRAINERTYPE_DVS EQU 1 << TRAINERTYPE_DVS_F + TRAINERTYPE_STAT_EXP EQU 1 << TRAINERTYPE_STAT_EXP_F ++TRAINERTYPE_VARIABLE EQU 1 << TRAINERTYPE_VARIABLE_F + + PERFECT_DV EQU $11 ; treated as $FF in enemy party data + PERFECT_STAT_EXP EQU $1337 ; treated as $FFFF in enemy party data +``` + +And edit [engine/battle/read_trainer_party.asm](../blob/master/engine/battle/read_trainer_party.asm) again: + +```diff +ReadTrainerPartyPieces: + ld h, d + ld l, e + ++; Variable? ++ bit TRAINERNTYPE_VARIABLE_F, a ++ jr z, .not_variable ++ ; get badge count in c ++ push hl ++ ld hl, Badges ++ ld b, 2 ++ call CountSetBits ++ pop hl ++ ; Skip that many $fe delimiters ++.outerloop ++ ld a, c ++ and a ++ jr z, .continue ++.innerloop ++ call GetNextTrainerDataByte ++ cp $fe ++ jr nz, .innerloop ++ dec c ++ jr .outerloop ++ ++.continue ++ ; Get trainer type of variable stage ++ call GetNextTrainerDataByte ++ ld [OtherTrainerType], a ++ ; fallthrough ++.not_variable + .loop + ; end? + call GetNextTrainerDataByte + cp -1 + ret z ++ cp $fe ++ ret z + + ; level + ld [wCurPartyLevel], a + ... +``` + +As an example, let's show how it'd work with Falkner: + +``` + FalknerGroup: + ; FALKNER (1) + db "Falkner@", TRAINERTYPE_VARIABLE + + ; No badges + db TRAINERTYPE_MOVES + db 7, PIDGEY, TACKLE, MUD_SLAP, NO_MOVE, NO_MOVE + db 9, PIDGEOTTO, TACKLE, MUD_SLAP, GUST, NO_MOVE + db $fe ; delimiter + + ... + + ; Six badges + db TRAINERTYPE_ITEM_MOVES + db 33, PIDGEOTTO, NO_ITEM, MUD_SLAP, FLY, QUICK_ATTACK, WING_ATTACK + db 35, PIDGEOT, SHARP_BEAK, MUD_SLAP, FLY, QUICK_ATTACK, WING_ATTACK + db $fe ; delimiter + + ... + + ; 16 badges + db TRAINERTYPE_ITEM_MOVES + db 58, PIDGEOT, NO_ITEM, MUD_SLAP, FLY, QUICK_ATTACK, WING_ATTACK + db 60, PIDGEOT, SHARP_BEAK, MUD_SLAP, FLY, QUICK_ATTACK, WING_ATTACK + db $ff ; end +``` + +Now the enemy trainer's team will vary depending on how many badges you have. +A few things to note about this: + +- One trainer ID applies to all 17 parties, depending on your badge count. So you don't have to repeat the trainer's name 17 times. +- Each party can have its own actual type (normal, item, moves, or item+moves). +- Each stage ends in $fe (except the last one ends in $ff) so you cannot use it for individual DV values (unless you change the delimiter's value, of course). |