diff --git a/Spawn-Invisible-Player.md b/Spawn-Invisible-Player.md new file mode 100644 index 0000000..dd029b9 --- /dev/null +++ b/Spawn-Invisible-Player.md @@ -0,0 +1,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.