summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Make-Sandstorm-raise-the-Special-Defense-of-Rock-type-Pokémon-by-50%.md77
1 files changed, 77 insertions, 0 deletions
diff --git a/Make-Sandstorm-raise-the-Special-Defense-of-Rock-type-Pokémon-by-50%.md b/Make-Sandstorm-raise-the-Special-Defense-of-Rock-type-Pokémon-by-50%.md
new file mode 100644
index 0000000..8af8d2d
--- /dev/null
+++ b/Make-Sandstorm-raise-the-Special-Defense-of-Rock-type-Pokémon-by-50%.md
@@ -0,0 +1,77 @@
+From generation 4 onwards, the Sandstorm weather raises the Special Defense of Rock-type Pokémon by 50%, so in this simple tutorial we'll implement this feature into Pokémon Crystal.
+
+
+## Contents
+
+1. [Create the function SandstormSpDefBoost](#1-stop-wPoisonStepCounter-from-counting-our-steps)
+2. [Call the function while getting the damage stats](#2-call-the-function-during-damage-stats)
+
+
+## 1. Create the function "SandstormSpDefBoost"
+
+In [engine/battle/effect_commands.asm](.../blob/master/engine/battle/effect_commands.asm), create the new function:
+
+```diff
++SandstormSpDefBoost:
++; First, check if Sandstorm is active.
++ ld a, [wBattleWeather]
++ cp WEATHER_SANDSTORM
++ ret nz
++
++; Then, check the opponent's types.
++ ld hl, wEnemyMonType1
++ ldh a, [hBattleTurn]
++ and a
++ jr z, .ok
++ ld hl, wBattleMonType1
++.ok
++ ld a, [hli]
++ cp ROCK
++ jr z, .start_boost
++ ld a, [hl]
++ cp ROCK
++ ret nz
++
++.start_boost
++ ld h, b
++ ld l, c
++ srl b
++ rr c
++ add hl, bc
++ ld b, h
++ ld c, l
++ ret
+```
+The 1st thing you might've noticed is that we're using the opponent's types instead of the user's to perform the boost. This is because we're gonna make the check while getting the damage stats, i.e. when _the user is attacking the opponent_.
+
+## 2. Call the function while getting the damage stats
+
+In the same file, call the newly created function in both `PlayerAttackDamage` and `EnemyAttackDamage`:
+
+```diff
+PlayerAttackDamage:
+ ...
+.special
+ ld hl, wEnemyMonSpclDef
+ ld a, [hli]
+ ld b, a
+ ld c, [hl]
+
++ call SandstormSpDefBoost
+ ...
+```
+
+```diff
+EnemyAttackDamage:
+ ...
+.special
+ ld hl, wBattleMonSpclDef
+ ld a, [hli]
+ ld b, a
+ ld c, [hl]
+
++ call SandstormSpDefBoost
+ ...
+```
+
+And that's it! Now the game will try to perform the boost while getting the Sp. Def of the opponent by first checking the weather and then the opponent's types. If the check is successful, it'll get the 50% boost from the Sandstorm. \ No newline at end of file