diff options
-rw-r--r-- | Grant-Grass-type-Pokémon-immunity-to-Powder-Spore-based-moves.md | 22 |
1 files changed, 11 insertions, 11 deletions
diff --git a/Grant-Grass-type-Pokémon-immunity-to-Powder-Spore-based-moves.md b/Grant-Grass-type-Pokémon-immunity-to-Powder-Spore-based-moves.md index 6f10891..c6c6957 100644 --- a/Grant-Grass-type-Pokémon-immunity-to-Powder-Spore-based-moves.md +++ b/Grant-Grass-type-Pokémon-immunity-to-Powder-Spore-based-moves.md @@ -1,4 +1,4 @@ -Generation 6 introduced an interesting mechanic where Grass-type Pokémon are unaffected by moves based on powder/spores, and there are five moves in Generation 2 which meet this criteria: Cotton Spore, Poison Powder, Sleep Powder, Spore and Stun Spore. In this tutorial, we'll implement this immunity and also make the AI discourage these moves if the opponent is Grass-type. +Generation 6 introduced an interesting mechanic where Grass-type Pokémon are unaffected by moves based on powder/spores, and there are five moves in Generation 2 which meet this criteria: Cotton Spore, Poison Powder, Sleep Powder, Spore and Stun Spore. In this tutorial, we'll implement this immunity and also teach the AI how to act properly. ## Contents @@ -23,8 +23,8 @@ Let's create **home/powder_moves.asm**: And include it in [home.asm](../blob/master/home.asm): ```diff -SECTION "Home", ROM0 -... + SECTION "Home", ROM0 + ... +INCLUDE "home/powder_moves.asm" ``` @@ -43,7 +43,7 @@ Go to [home/arrays.asm](../blob/master/home/arrays.asm): ; Return index in b and carry if found. ... ``` -As the comments say, the job of `IsInArray` is to find the value of register `a` in an array loaded in `hl`, and you advance `de` bytes forward in every iteration. We made this small addition so that we have a function that always advances one byte forward in a given array, which we'll use later. +As the comments say, the job of `IsInArray` is to find the value of register `a` in an array loaded in `hl`, and you advance `de` bytes forward. We made this small addition so that we can have a function that always advances one byte forward in a given array, which we'll use later. ## 3. Add a new Battle Command @@ -92,13 +92,13 @@ And then edit [engine/battle/effect_commands.asm](../blob/master/engine/battle/e + ld hl, wEnemyMonType1 + ldh a, [hBattleTurn] + and a -+ jr z, .checkgrasstype ++ jr z, .CheckGrassType + ld hl, wBattleMonType1 + -+.checkgrasstype: ++.CheckGrassType: + ld a, [hli] + cp GRASS -+ jp z, .Immune ++ jr z, .Immune + ld a, [hl] + cp GRASS + ret nz @@ -108,9 +108,9 @@ And then edit [engine/battle/effect_commands.asm](../blob/master/engine/battle/e + ld [wAttackMissed], a + ret ``` -The comments make this self-explanatory. `BattleCommand_CheckPowder` first checks if the move is in the `PowderMoves` list and then checks the opponent's types to determine whether to hit or miss. +The comments make this self-explanatory. `BattleCommand_CheckPowder` first checks if the move is in the `PowderMoves` list and then checks the opponent's types to determine whether it hits or misses. -Before proceeding, let's explain something important. To access the `PowderMoves` list it needs to be included either in the same bank as engine/battle/effect_commands.asm ("Effect Commands") or in the ROM0 bank. We decided to opt for the latter because we're going to check this list from another file that is located in another bank, and ROM0 can be accessed by any file located in any bank (also, the list is pretty short, so it won't fill the bank). **There are more practical workarounds**, so don't get used to this. +Before proceeding, let's explain something important. To access the `PowderMoves` list it needs to be included either in the same bank as engine/battle/effect_commands.asm (which is named "Effect Commands") or in the ROM0 bank. We decided to opt for the latter because we're going to check this list from another file that is located in another bank, and ROM0 can be accessed by *any file* located in *any bank* (also, the list is pretty short, so it won't fill ROM0). **There are more practical workarounds**, so don't get used to this. Anyways, now that we've finally created our new battle command, let's add it to some already existing move effects that are used by Powder/Spore moves. Go to [data/moves/effects.asm](../blob/master/data/moves/effects.asm): @@ -169,7 +169,7 @@ MoveEffects: ; used only for BANK(MoveEffects) `DoSleep` is used by both Sleep Powder and Spore, `SpeedDown2` is used by Cotton Spore, `DoPoison` by Poison Powder, and `DoParalyze` by Stun Spore. -Now the mechanic is completely functional! But remember that I told you we're gonna use the `PowderMoves` list in another file? If you paid attention, I said at the start of the tutorial we're going to modify the AI to discourage these moves depending on the opponent's types. So let's go to the final step! +Now the mechanic is completely functional! But, do you remember that I told you we're gonna use the `PowderMoves` list in another file? If you paid attention, I said at the start of the tutorial we're going to teach the AI how to discourage these moves depending on the opponent's types. So let's go to the final step! ## 4. Make the AI discourage Powder/Spore moves if the opponent is Grass-type @@ -214,6 +214,6 @@ Go to [engine/battle/ai/scoring.asm](../blob/master/engine/battle/ai/scoring.asm ... ``` -Explanation time! (Last one, I swear). The logic behind this is very similar to `BattleCommand_CheckPowder`, where we store the move in `a` and do our powder check; if it's not powder/spore based, we proceed with the original check, but if it is then we check the opponent's types. If the final check succeds, we jump to `.immune` where it discourages the AI from using the move. The `push`s and `pop`s are used to preserve `bc`, `de` and `hl` since `AI_Status` uses the original values every time it checks one of the +Explanation time! (Last one, I swear). The logic behind this is very similar to `BattleCommand_CheckPowder`, where we store the move in `a` and do our powder check; if it's not powder/spore based, we proceed with the original check, but if it is then we check the opponent's types. If the final check succeds, we jump to `.immune` where it discourages the AI from using the move. The `push`s and `pop`s are used to preserve `bc`, `de` and `hl` since `AI_Status` uses the original values to check each of the AI's moves. And that's it! Now that the mechanic is functional and the AI knows how to use it properly, the tutorial is finally complete! |