summaryrefslogtreecommitdiff
path: root/Spawn-Invisible-Player.md
blob: dd029b9a1215c47db20baaed5f03527343701e61 (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
## Spawn Invisible Player

credits to ghoulslash

This feature allows us to spawn the player object as invisible after a warp, which can be useful for cutscenes, etc. Note that the camera will still be centered on the player.

## Define a flag

We'll use a flag to toggle whether or not we want to spawn the player as an invisible object. Open up [include/constants/flags.h](../blob/master/include/constants/flags.h) and either add or replace a flag with the following: `FLAG_SPAWN_INVISIBLE`

## Make the flag functional

1. Open [src/field_player_avatar.c](../blob/master/src/field_player_avatar.c) and find the function `InitPlayerAvatar`. Add the following to the end of the function:
```c
if (FlagGet(FLAG_SPAWN_INVISIBLE))
{
    FlagClear(FLAG_SPAWN_INVISIBLE);
    objectEvent->invisible = TRUE;
}
```

## Use the flag

Now, we can use this in a script as so:
```
EventScript_SetupCutscene::
    lock
    setflag FLAG_SPAWN_INVISIBLE
    warp MAP_PETALBURG_CITY, -1, 30, 40
    release
    end
```

And you would need to then add a map script to run your cutscene in petalburg city.

When you want the player to appear again, you must use the `applymovement` command that includes a `set_visible` movement command.