diff options
-rw-r--r-- | Make-time-and-weather-sensitive-moves-only-weather-dependent.md | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/Make-time-and-weather-sensitive-moves-only-weather-dependent.md b/Make-time-and-weather-sensitive-moves-only-weather-dependent.md index cd93598..0173b27 100644 --- a/Make-time-and-weather-sensitive-moves-only-weather-dependent.md +++ b/Make-time-and-weather-sensitive-moves-only-weather-dependent.md @@ -1,4 +1,9 @@ -In Generation 2 the Day/Night feature was introduced and, along with it, three moves that depend on it: Morning Sun (Morning), Synthesis (Day) and Moonlight (Night). The healing amount is affected by both the active weather and the time of day, which can be ¼ Max HP (no weather and no matching time of day), ½ Max HP (either sunny or matching time of day), 100% Max HP (both sunny and matching time of day), and ⅛ Max HP (rain/sandstorm active and no matching time of day). +In Generation 2 the Day/Night feature was introduced and, along with it, three moves that depend on it: Morning Sun (Morning), Synthesis (Day) and Moonlight (Night). The healing amount is affected by both the active weather and the time of day, according to the following list: + +* ¼ Max HP (No weather and No matching time of day) +* ½ Max HP (either Harsh Sunlight active or Matching time of day) +* 100% Max HP (both Harsh Sunlight active and Matching time of day) +* ⅛ Max HP (Rain/Sandstorm active and no Matching time of day) In Generation 3 onwards it only depends on weather, normally healing ½ max HP with no weather, ⅔ max HP is there's harsh sunlight, and ¼ max HP with any other active weather. The objective of this tutorial will be to make the moves mentioned above behave like in modern generations. @@ -46,7 +51,7 @@ In [engine/battle/core.asm](../blob/master/engine/battle/core.asm) there are fun ... ``` -Here we're creating two functions, one that calculates ⅓ of max HP, and another one that takes the result and doubles it. `GetThirdMaxHP` gets the Max HP of a Pokémon (which is stored in `bc`), and performs an iterative substraction where `a` is increased once while `bc` is decreased three times, until it goes below 0 (underflow), then `a` is decreased once to discount the underflow, loads the value into `c`, checks if it's 0 (in which case is increased once) and finally returns. `GetTwoThirdsMaxHP` calls this function and doubles the result, since 2 * ⅓ = ⅔. +Here we're creating two functions, one that calculates ⅓ of max HP, and another one that takes the result and doubles it. `GetThirdMaxHP` gets the Max HP of a Pokémon (which is stored in `bc`), and performs an iterative substraction where `a` is increased once while `bc` is decreased three times, until it goes below 0 (underflow), then `a` is decreased once to discount the underflow, loads the value into `c`, checks if it's 0 (in which case is increased once, since `c` has to be at least 1) and finally returns. `GetTwoThirdsMaxHP` calls this function and doubles the result, since 2 * ⅓ = ⅔. Now that we can calculate ⅔ of Max HP, let's go to the next step. @@ -100,7 +105,7 @@ Edit [engine/battle/effect_commands.asm](../blob/master/engine/battle/effect_com - dw GetMaxHP + dw GetTwoThirdsMaxHP ``` -So let's explain what's happening. `ld c, 1` serves as our index for `.Multipliers`, which will initially point to `GetHalfMaxHP`. `CompareBytes` compares the current HP with the Max HP to determine whether to apply healing or not, and since we're comparing two bytes at `de` and `hl`, we need to temporarily `inc c`; after the comparison, we `dec c` back to 1. +So let's explain what's happening. `ld c, 1` serves as our index for `.Multipliers`, which will initially point to `GetHalfMaxHP`. `CompareBytes` compares the current HP with the Max HP to determine whether to apply healing or not, and since we're comparing two bytes at `de` and `hl`, we need to temporarily `inc c` (to understand why, read in the code how `CompareBytes` works); after the comparison, we `dec c` back to 1. In Link battles the time of day isn't taken into account, but since we're modifying the code to also behave like this in normal gameplay, we no longer need the code block related to it. |