mirror of
https://github.com/Ninjdai1/pokeemerald.git
synced 2024-12-27 12:14:20 +01:00
Implement FORM_ITEM_USE. Credits to Lunos for work on Gracidea
This commit is contained in:
parent
6f64c1b2b9
commit
07af84db8a
@ -23,6 +23,8 @@ void ItemUseOutOfBattle_BlackWhiteFlute(u8);
|
||||
void ItemUseOutOfBattle_EvolutionStone(u8);
|
||||
void ItemUseOutOfBattle_Berry(u8);
|
||||
void ItemUseOutOfBattle_EnigmaBerry(u8);
|
||||
void ItemUseOutOfBattle_FormChange(u8);
|
||||
void ItemUseOutOfBattle_FormChange_ConsumedOnUse(u8);
|
||||
void ItemUseOutOfBattle_CannotUse(u8);
|
||||
void ItemUseInBattle_PokeBall(u8);
|
||||
void ItemUseInBattle_StatIncrease(u8);
|
||||
|
@ -59,6 +59,7 @@ void ItemUseCB_TMHM(u8 taskId, TaskFunc task);
|
||||
void ItemUseCB_RareCandy(u8 taskId, TaskFunc task);
|
||||
void ItemUseCB_SacredAsh(u8 taskId, TaskFunc task);
|
||||
void ItemUseCB_EvolutionStone(u8 taskId, TaskFunc task);
|
||||
void ItemUseCB_FormChange(u8 taskId, TaskFunc task);
|
||||
u8 GetItemEffectType(u16 item);
|
||||
void CB2_PartyMenuFromStartMenu(void);
|
||||
void CB2_ChooseMonToGiveItem(void);
|
||||
|
@ -1118,6 +1118,20 @@ void ItemUseInBattle_EnigmaBerry(u8 taskId)
|
||||
}
|
||||
}
|
||||
|
||||
void ItemUseOutOfBattle_FormChange(u8 taskId)
|
||||
{
|
||||
gItemUseCB = ItemUseCB_FormChange;
|
||||
gTasks[taskId].data[0] = FALSE;
|
||||
SetUpItemUseCallback(taskId);
|
||||
}
|
||||
|
||||
void ItemUseOutOfBattle_FormChange_ConsumedOnUse(u8 taskId)
|
||||
{
|
||||
gItemUseCB = ItemUseCB_FormChange;
|
||||
gTasks[taskId].data[0] = TRUE;
|
||||
SetUpItemUseCallback(taskId);
|
||||
}
|
||||
|
||||
void ItemUseOutOfBattle_CannotUse(u8 taskId)
|
||||
{
|
||||
DisplayDadsAdviceCannotUseItemMessage(taskId, gTasks[taskId].tUsingRegisteredKeyItem);
|
||||
|
@ -409,6 +409,8 @@ static bool8 SetUpFieldMove_Dive(void);
|
||||
#include "data/pokemon/tutor_learnsets.h"
|
||||
#include "data/party_menu.h"
|
||||
|
||||
static const u8 ChangedForm[] = _("{STR_VAR_1} changed Forme!{PAUSE_UNTIL_PRESS}");
|
||||
|
||||
// code
|
||||
static void InitPartyMenu(u8 menuType, u8 layout, u8 partyAction, bool8 keepCursorPos, u8 messageId, TaskFunc task, MainCallback callback)
|
||||
{
|
||||
@ -5165,6 +5167,38 @@ void ItemUseCB_EvolutionStone(u8 taskId, TaskFunc task)
|
||||
}
|
||||
}
|
||||
|
||||
void ItemUseCB_FormChange(u8 taskId, TaskFunc task)
|
||||
{
|
||||
struct Pokemon *mon = &gPlayerParty[gPartyMenu.slotId];
|
||||
u16 species = GetMonData(mon, MON_DATA_SPECIES);
|
||||
u16 targetSpecies = GetFormChangeTargetSpecies(mon, FORM_ITEM_USE, gSpecialVar_ItemId);
|
||||
if (targetSpecies != SPECIES_NONE)
|
||||
{
|
||||
gPartyMenuUseExitCallback = TRUE;
|
||||
PlaySE(SE_USE_ITEM);
|
||||
PlayCry2(targetSpecies, 0, 0x7D, 0xA);
|
||||
SetMonData(mon, MON_DATA_SPECIES, &targetSpecies);
|
||||
FreeAndDestroyMonIconSprite(&gSprites[sPartyMenuBoxes[gPartyMenu.slotId].monSpriteId]);
|
||||
CreatePartyMonIconSpriteParameterized(targetSpecies, GetMonData(mon, MON_DATA_PERSONALITY, NULL), &sPartyMenuBoxes[gPartyMenu.slotId], 0);
|
||||
CalculateMonStats(mon);
|
||||
GetMonNickname(mon, gStringVar1);
|
||||
StringExpandPlaceholders(gStringVar4, ChangedForm);
|
||||
DisplayPartyMenuMessage(gStringVar4, FALSE);
|
||||
if (gTasks[taskId].data[0] == TRUE)
|
||||
RemoveBagItem(gSpecialVar_ItemId, 1);
|
||||
ScheduleBgCopyTilemapToVram(2);
|
||||
gTasks[taskId].func = task;
|
||||
}
|
||||
else
|
||||
{
|
||||
gPartyMenuUseExitCallback = FALSE;
|
||||
PlaySE(SE_SELECT);
|
||||
DisplayPartyMenuMessage(gText_WontHaveEffect, TRUE);
|
||||
ScheduleBgCopyTilemapToVram(2);
|
||||
gTasks[taskId].func = task;
|
||||
}
|
||||
}
|
||||
|
||||
u8 GetItemEffectType(u16 item)
|
||||
{
|
||||
const u8 *itemEffect;
|
||||
|
Loading…
Reference in New Issue
Block a user