2018-02-15 10:59:26 +01:00
|
|
|
#include "global.h"
|
|
|
|
#include "menu.h"
|
|
|
|
#include "party_menu.h"
|
|
|
|
#include "pokemon.h"
|
|
|
|
#include "sound.h"
|
|
|
|
#include "sprite.h"
|
2018-02-15 12:42:02 +01:00
|
|
|
#include "string_util.h"
|
2018-02-15 10:59:26 +01:00
|
|
|
#include "strings.h"
|
|
|
|
#include "task.h"
|
2019-10-18 01:22:03 +02:00
|
|
|
#include "constants/party_menu.h"
|
2018-11-14 01:01:50 +01:00
|
|
|
#include "constants/songs.h"
|
2018-02-15 10:59:26 +01:00
|
|
|
|
2019-10-18 01:22:03 +02:00
|
|
|
static void Task_SoftboiledRestoreHealth(u8 taskId);
|
|
|
|
static void Task_DisplayHPRestoredMessage(u8 taskId);
|
|
|
|
static void Task_FinishSoftboiled(u8 taskId);
|
|
|
|
static void CantUseSoftboiledOnMon(u8 taskId);
|
2018-02-15 10:59:26 +01:00
|
|
|
|
|
|
|
bool8 SetUpFieldMove_SoftBoiled(void)
|
|
|
|
{
|
|
|
|
u16 maxHp;
|
|
|
|
u16 hp;
|
|
|
|
u16 minHp;
|
|
|
|
|
|
|
|
maxHp = GetMonData(&gPlayerParty[GetCursorSelectionMonId()], MON_DATA_MAX_HP);
|
|
|
|
hp = GetMonData(&gPlayerParty[GetCursorSelectionMonId()], MON_DATA_HP);
|
|
|
|
|
|
|
|
minHp = (maxHp / 5);
|
|
|
|
if (hp > minHp)
|
|
|
|
return TRUE;
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2019-10-18 01:22:03 +02:00
|
|
|
void ChooseMonForSoftboiled(u8 taskId)
|
2018-02-15 10:59:26 +01:00
|
|
|
{
|
2019-10-18 01:22:03 +02:00
|
|
|
gPartyMenu.action = PARTY_ACTION_SOFTBOILED;
|
|
|
|
gPartyMenu.slotId2 = gPartyMenu.slotId;
|
|
|
|
AnimatePartySlot(GetCursorSelectionMonId(), 1);
|
|
|
|
DisplayPartyMenuStdMessage(PARTY_MSG_USE_ON_WHICH_MON);
|
|
|
|
gTasks[taskId].func = Task_HandleChooseMonInput;
|
2018-02-15 10:59:26 +01:00
|
|
|
}
|
|
|
|
|
2019-10-18 01:22:03 +02:00
|
|
|
void Task_TryUseSoftboiledOnPartyMon(u8 taskId)
|
2018-02-15 10:59:26 +01:00
|
|
|
{
|
|
|
|
u16 hp;
|
|
|
|
|
2019-10-18 01:22:03 +02:00
|
|
|
u8 userPartyId = gPartyMenu.slotId;
|
|
|
|
u8 recipientPartyId = gPartyMenu.slotId2;
|
|
|
|
if(recipientPartyId > PARTY_SIZE)
|
2018-02-15 10:59:26 +01:00
|
|
|
{
|
2019-10-18 01:22:03 +02:00
|
|
|
gPartyMenu.action = 0;
|
|
|
|
DisplayPartyMenuStdMessage(PARTY_MSG_CHOOSE_MON);
|
|
|
|
gTasks[taskId].func = Task_HandleChooseMonInput;
|
2018-02-15 10:59:26 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2019-10-18 01:22:03 +02:00
|
|
|
hp = GetMonData(&gPlayerParty[recipientPartyId], MON_DATA_HP);
|
|
|
|
if(hp == 0 || userPartyId == recipientPartyId || GetMonData(&gPlayerParty[recipientPartyId], MON_DATA_MAX_HP) == hp)
|
2018-02-15 10:59:26 +01:00
|
|
|
{
|
2019-10-18 01:22:03 +02:00
|
|
|
CantUseSoftboiledOnMon(taskId);
|
2018-02-15 10:59:26 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2019-10-18 01:22:03 +02:00
|
|
|
// Take away Softboiled user's health first (-1)
|
2020-08-21 00:02:00 +02:00
|
|
|
PlaySE(SE_USE_ITEM);
|
2019-10-18 01:22:03 +02:00
|
|
|
PartyMenuModifyHP(taskId, userPartyId, -1, GetMonData(&gPlayerParty[userPartyId], MON_DATA_MAX_HP)/5, Task_SoftboiledRestoreHealth);
|
2018-02-15 10:59:26 +01:00
|
|
|
}
|
|
|
|
|
2019-10-18 01:22:03 +02:00
|
|
|
static void Task_SoftboiledRestoreHealth(u8 taskId)
|
2018-02-15 11:35:27 +01:00
|
|
|
{
|
2020-08-21 00:02:00 +02:00
|
|
|
PlaySE(SE_USE_ITEM);
|
2019-10-18 01:22:03 +02:00
|
|
|
PartyMenuModifyHP(taskId, gPartyMenu.slotId2, 1, GetMonData(&gPlayerParty[gPartyMenu.slotId], MON_DATA_MAX_HP)/5, Task_DisplayHPRestoredMessage);
|
2018-02-15 10:59:26 +01:00
|
|
|
}
|
|
|
|
|
2019-10-18 01:22:03 +02:00
|
|
|
static void Task_DisplayHPRestoredMessage(u8 taskId)
|
2018-02-15 12:42:02 +01:00
|
|
|
{
|
2019-10-18 01:22:03 +02:00
|
|
|
GetMonNickname(&gPlayerParty[gPartyMenu.slotId2], gStringVar1);
|
2018-02-15 12:42:02 +01:00
|
|
|
StringExpandPlaceholders(gStringVar4, gText_PkmnHPRestoredByVar2);
|
2019-10-18 01:22:03 +02:00
|
|
|
DisplayPartyMenuMessage(gStringVar4, FALSE);
|
2020-05-14 10:37:09 +02:00
|
|
|
ScheduleBgCopyTilemapToVram(2);
|
2019-10-18 01:22:03 +02:00
|
|
|
gTasks[taskId].func = Task_FinishSoftboiled;
|
2018-02-15 10:59:26 +01:00
|
|
|
}
|
|
|
|
|
2019-10-18 01:22:03 +02:00
|
|
|
static void Task_FinishSoftboiled(u8 taskId)
|
2018-02-15 18:02:28 +01:00
|
|
|
{
|
2019-10-18 01:22:03 +02:00
|
|
|
if(IsPartyMenuTextPrinterActive() == TRUE)
|
2018-02-15 18:02:28 +01:00
|
|
|
return;
|
2019-10-18 01:22:03 +02:00
|
|
|
gPartyMenu.action = 0;
|
|
|
|
AnimatePartySlot(gPartyMenu.slotId, 0);
|
|
|
|
gPartyMenu.slotId = gPartyMenu.slotId2;
|
|
|
|
AnimatePartySlot(gPartyMenu.slotId2, 1);
|
|
|
|
ClearStdWindowAndFrameToTransparent(6, FALSE);
|
|
|
|
ClearWindowTilemap(6);
|
|
|
|
DisplayPartyMenuStdMessage(PARTY_MSG_CHOOSE_MON);
|
|
|
|
gTasks[taskId].func = Task_HandleChooseMonInput;
|
2018-02-15 18:02:28 +01:00
|
|
|
}
|
|
|
|
|
2019-10-18 01:22:03 +02:00
|
|
|
static void Task_ChooseNewMonForSoftboiled(u8 taskId)
|
2018-02-15 18:02:28 +01:00
|
|
|
{
|
2019-10-18 01:22:03 +02:00
|
|
|
if(IsPartyMenuTextPrinterActive() == TRUE)
|
2018-02-15 18:02:28 +01:00
|
|
|
return;
|
2019-10-18 01:22:03 +02:00
|
|
|
DisplayPartyMenuStdMessage(PARTY_MSG_USE_ON_WHICH_MON);
|
|
|
|
gTasks[taskId].func = Task_HandleChooseMonInput;
|
2018-02-15 18:02:28 +01:00
|
|
|
}
|
|
|
|
|
2019-10-18 01:22:03 +02:00
|
|
|
static void CantUseSoftboiledOnMon(u8 taskId)
|
2018-02-15 18:02:28 +01:00
|
|
|
{
|
|
|
|
PlaySE(SE_SELECT);
|
2019-10-18 01:22:03 +02:00
|
|
|
DisplayPartyMenuMessage(gText_CantBeUsedOnPkmn, FALSE);
|
2020-05-14 10:37:09 +02:00
|
|
|
ScheduleBgCopyTilemapToVram(2);
|
2019-10-18 01:22:03 +02:00
|
|
|
gTasks[taskId].func = Task_ChooseNewMonForSoftboiled;
|
2018-02-15 18:02:28 +01:00
|
|
|
}
|