2018-02-14 12:54:31 +01:00
|
|
|
#include "global.h"
|
|
|
|
#include "event_data.h"
|
|
|
|
#include "event_scripts.h"
|
|
|
|
#include "field_effect.h"
|
|
|
|
#include "field_player_avatar.h"
|
2018-12-08 22:12:44 +01:00
|
|
|
#include "field_screen_effect.h"
|
2018-12-08 19:05:03 +01:00
|
|
|
#include "field_weather.h"
|
2018-12-24 21:59:05 +01:00
|
|
|
#include "fldeff.h"
|
2018-12-25 18:02:41 +01:00
|
|
|
#include "mirage_tower.h"
|
2018-02-14 12:54:31 +01:00
|
|
|
#include "palette.h"
|
|
|
|
#include "party_menu.h"
|
|
|
|
#include "script.h"
|
|
|
|
#include "sound.h"
|
|
|
|
#include "sprite.h"
|
|
|
|
#include "task.h"
|
|
|
|
#include "wild_encounter.h"
|
2018-11-13 15:19:04 +01:00
|
|
|
#include "constants/field_effects.h"
|
2018-10-17 14:52:26 +02:00
|
|
|
#include "constants/rgb.h"
|
|
|
|
#include "constants/songs.h"
|
2018-02-14 12:54:31 +01:00
|
|
|
|
2018-10-17 14:52:26 +02:00
|
|
|
static void FieldCallback_SweetScent(void);
|
|
|
|
static void StartSweetScentFieldEffect(void);
|
|
|
|
static void TrySweetScentEncounter(u8 taskId);
|
|
|
|
static void FailSweetScentEncounter(u8 taskId);
|
2018-02-14 12:54:31 +01:00
|
|
|
|
|
|
|
bool8 SetUpFieldMove_SweetScent(void)
|
|
|
|
{
|
2018-06-16 00:45:48 +02:00
|
|
|
gFieldCallback2 = FieldCallback_PrepareFadeInFromMenu;
|
2018-10-17 14:52:26 +02:00
|
|
|
gPostMenuFieldCallback = FieldCallback_SweetScent;
|
2018-02-14 12:54:31 +01:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2018-10-17 14:52:26 +02:00
|
|
|
static void FieldCallback_SweetScent(void)
|
2018-02-14 12:54:31 +01:00
|
|
|
{
|
|
|
|
FieldEffectStart(FLDEFF_SWEET_SCENT);
|
|
|
|
gFieldEffectArguments[0] = GetCursorSelectionMonId();
|
|
|
|
}
|
|
|
|
|
2018-10-14 20:00:14 +02:00
|
|
|
bool8 FldEff_SweetScent(void)
|
2018-02-14 12:54:31 +01:00
|
|
|
{
|
|
|
|
u8 taskId;
|
|
|
|
|
2018-12-08 19:05:03 +01:00
|
|
|
SetWeatherScreenFadeOut();
|
2018-02-14 12:54:31 +01:00
|
|
|
taskId = oei_task_add();
|
2018-10-17 14:52:26 +02:00
|
|
|
gTasks[taskId].data[8] = (u32)StartSweetScentFieldEffect >> 16;
|
|
|
|
gTasks[taskId].data[9] = (u32)StartSweetScentFieldEffect;
|
2018-02-14 12:54:31 +01:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2018-10-17 14:52:26 +02:00
|
|
|
static void StartSweetScentFieldEffect(void)
|
2018-02-14 12:54:31 +01:00
|
|
|
{
|
|
|
|
u8 taskId;
|
|
|
|
|
2018-02-15 05:17:42 +01:00
|
|
|
PlaySE(SE_W230);
|
2018-02-14 12:54:31 +01:00
|
|
|
CpuFastSet(gPlttBufferUnfaded, gPaletteDecompressionBuffer, 0x100);
|
|
|
|
CpuFastSet(gPlttBufferFaded, gPlttBufferUnfaded, 0x100);
|
2018-02-15 05:17:42 +01:00
|
|
|
BeginNormalPaletteFade(~(1 << (gSprites[GetPlayerAvatarObjectId()].oam.paletteNum + 16)), 4, 0, 8, RGB_RED);
|
2018-10-17 14:52:26 +02:00
|
|
|
taskId = CreateTask(TrySweetScentEncounter, 0);
|
2018-02-14 12:54:31 +01:00
|
|
|
gTasks[taskId].data[0] = 0;
|
|
|
|
FieldEffectActiveListRemove(FLDEFF_SWEET_SCENT);
|
|
|
|
}
|
|
|
|
|
2018-10-17 14:52:26 +02:00
|
|
|
static void TrySweetScentEncounter(u8 taskId)
|
2018-02-14 12:54:31 +01:00
|
|
|
{
|
|
|
|
if (!gPaletteFade.active)
|
|
|
|
{
|
2018-12-25 18:02:41 +01:00
|
|
|
ClearMirageTowerPulseBlendEffect();
|
2018-02-15 05:17:42 +01:00
|
|
|
BlendPalettes(0x00000040, 8, RGB_RED);
|
2018-02-14 12:54:31 +01:00
|
|
|
if (gTasks[taskId].data[0] == 64)
|
|
|
|
{
|
|
|
|
gTasks[taskId].data[0] = 0;
|
|
|
|
if (SweetScentWildEncounter() == TRUE)
|
|
|
|
{
|
|
|
|
DestroyTask(taskId);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2018-10-17 14:52:26 +02:00
|
|
|
gTasks[taskId].func = FailSweetScentEncounter;
|
2018-02-15 05:17:42 +01:00
|
|
|
BeginNormalPaletteFade(~(1 << (gSprites[GetPlayerAvatarObjectId()].oam.paletteNum + 16)), 4, 8, 0, RGB_RED);
|
2018-12-25 18:02:41 +01:00
|
|
|
TryStartMirageTowerPulseBlendEffect();
|
2018-02-14 12:54:31 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
gTasks[taskId].data[0]++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-10-17 14:52:26 +02:00
|
|
|
static void FailSweetScentEncounter(u8 taskId)
|
2018-02-14 12:54:31 +01:00
|
|
|
{
|
|
|
|
if (!gPaletteFade.active)
|
|
|
|
{
|
|
|
|
CpuFastSet(gPaletteDecompressionBuffer, gPlttBufferUnfaded, 0x100);
|
|
|
|
sub_80AC3E4();
|
2019-04-05 05:26:53 +02:00
|
|
|
ScriptContext1_SetupScript(EventScript_FailSweetScent);
|
2018-02-14 12:54:31 +01:00
|
|
|
DestroyTask(taskId);
|
|
|
|
}
|
|
|
|
}
|