summaryrefslogtreecommitdiff
path: root/Fix-Snow-Weather.md
blob: 7a3ff309771084f9c0e35340e0b72e6c635fe1d5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
## Fix Snow Weather

Credit to daniilS for the binary implementation this is based off of

In vanilla emerald (and Fire Red!) the WEATHER_SNOW is broken and will only emit a few snowflakes before stopping. Let's fix it!

For starters, open [src/field_weather_effect.c](../blob/master/src/field_weather_effect.c)

### Increase the number of snowflakes (optional)
If you want to have the snow be heavier (or lighter), find `Snow_InitVars` and edit the line `gWeatherPtr->targetSnowflakeSpriteCount = 16;` to a value of your choosing.

### Stop the snow from disappearing
Find the function `UpdateSnowflakeSprite`, and delete the following code (lines 974-998):
```c
    y = (sprite->pos1.y + sprite->centerToCornerVecY + gSpriteCoordOffsetY) & 0xFF;
    if (y > 163 && y < 171)
    {
        sprite->pos1.y = 250 - (gSpriteCoordOffsetY + sprite->centerToCornerVecY);
        sprite->tPosY = sprite->pos1.y * 128;
        sprite->tFallCounter = 0;
        sprite->tFallDuration = 220;
    }
    else if (y > 242 && y < 250)
    {
        sprite->pos1.y = 163;
        sprite->tPosY = sprite->pos1.y * 128;
        sprite->tFallCounter = 0;
        sprite->tFallDuration = 220;
        sprite->invisible = TRUE;
        sprite->callback = WaitSnowflakeSprite;
    }

    if (++sprite->tFallCounter == sprite->tFallDuration)
    {
        InitSnowflakeSpriteMovement(sprite);
        sprite->pos1.y = 250;
        sprite->invisible = TRUE;
        sprite->callback = WaitSnowflakeSprite;
    }
```

### Fix snow spawning upon returning to the overworld
The snow is spawned based on gSpriteCoordOffsetX/Y, which is not updated until after the weather is initialized. To fix this, open [src/field_weather.c](../blob/master/src/field_weather.c).

1. First, add `#include "field_camera.h"` to the top of the file somewhere.
2. Next, add `UpdateCameraPanning();` before `sWeatherFuncs[gWeatherPtr->currWeather].initAll();` in `Task_WeatherInit`

### Hail on Overworld
Credit to Samu, To allow hail on when snow is present, go to **src/battle_util.c**
Search for `switch (GetCurrentWeather())` (Around line 2908) and input these code below the `WEATHER_DROUGHT` code.
```c
                case WEATHER_SNOW:
                    if (!(gBattleWeather & WEATHER_HAIL_ANY))
                    {
                        gBattleWeather = WEATHER_HAIL_ANY;
                        gBattleScripting.animArg1 = B_ANIM_HAIL_CONTINUES;
                        gBattleScripting.battler = battler;
                        effect++;
                    }
                    break;
```

The only thing left to do is to change the text string assigned to the snowy weather when it's casted in battle.

Head over to `src/battle_message.c` and search for `const u16 gWeatherStartsStringIds`.

Once there, make the following change:
```diff
const u16 gWeatherStartsStringIds[] =
{
    [WEATHER_NONE]               = STRINGID_ITISRAINING,
    [WEATHER_SUNNY_CLOUDS]       = STRINGID_ITISRAINING,
    [WEATHER_SUNNY]              = STRINGID_ITISRAINING,
    [WEATHER_RAIN]               = STRINGID_ITISRAINING,
-   [WEATHER_SNOW]               = STRINGID_ITISRAINING,
+   [WEATHER_SNOW]               = STRINGID_STARTEDHAIL,
    [WEATHER_RAIN_THUNDERSTORM]  = STRINGID_ITISRAINING,
    [WEATHER_FOG_HORIZONTAL]     = STRINGID_ITISRAINING,
    [WEATHER_VOLCANIC_ASH]       = STRINGID_ITISRAINING,
    [WEATHER_SANDSTORM]          = STRINGID_SANDSTORMISRAGING,
    [WEATHER_FOG_DIAGONAL]       = STRINGID_ITISRAINING,
    [WEATHER_UNDERWATER]         = STRINGID_ITISRAINING,
    [WEATHER_SHADE]              = STRINGID_ITISRAINING,
    [WEATHER_DROUGHT]            = STRINGID_SUNLIGHTSTRONG,
    [WEATHER_SNOW]               = STRINGID_STARTEDHAIL,
    [WEATHER_DOWNPOUR]           = STRINGID_ITISRAINING,
    [WEATHER_UNDERWATER_BUBBLES] = STRINGID_ITISRAINING,
    [WEATHER_ABNORMAL]           = STRINGID_ITISRAINING
};
```