summaryrefslogtreecommitdiff
path: root/Remove-Warp-Fadescreen.md
blob: 7d1c4295dd2613d626e953ee9f56c82320597b09 (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
## Remove Warp Fadescreen

credits to ghoulslash

There might come a day where you want to fade the screen to black in a script and play a fanfare, print a message, or do something else, and immediately warp. If you try this in vanilla emerald, the screen will fade FROM black, and then back TO black. Instead, let's create a flag that removes the fadescreen part of the warp script commands and we can do something like this:

Before:                                             After:

<a href="https://imgur.com/1cDuh4f"><img src="https://imgur.com/lkYbY2N.gif" title="source: imgur.com" /></a> <a href="https://imgur.com/1cDuh4f"><img src="https://imgur.com/HdnnlF9.gif" title="source: imgur.com" /></a>


### 1. Define a flag

Add or replace a flag with `FLAG_REMOVE_WARP_FADE` in `include/constants/flags.h`

### 2. Give the flag a purpose

1) Find `WarpFadeOutScreen` in [field_screen_effect.c](../blob/master/src/field_screen_effect.c#L102) and replace the entire function with:


```c
void WarpFadeOutScreen(void)
{
    u8 currentMapType = GetCurrentMapType();
    if (!FlagGet(FLAG_REMOVE_WARP_FADE)) // fadescreen if flag not set
    {
        switch (GetMapPairFadeToType(currentMapType, GetDestinationWarpMapHeader()->mapType))
        {
        case 0:
            FadeScreen(FADE_TO_BLACK, 0);
            break;
        case 1:
            FadeScreen(FADE_TO_WHITE, 0);
        }
    }
    else
    {
        FlagClear(FLAG_REMOVE_WARP_FADE);  // reset flag internally
    }
}
```

### 3. Use in a script! Here is the example in the GIF:
```
VerdanturfTown_EventScript_Camper::
	lock
	faceplayer
	msgbox sText_1, MSGBOX_AUTOCLOSE
	fadescreen FADE_TO_BLACK
	setflag FLAG_REMOVE_WARP_FADE
	msgbox sText_2, MSGBOX_AUTOCLOSE
	warp MAP_RUSTBORO_CITY, 0, 0, 0
	end
```

The flag is cleared internally, so need to worry about that after warping!