mirror of
https://github.com/Ninjdai1/pokeemerald.git
synced 2025-01-28 06:13:59 +01:00
Clean up field_poison.c
This commit is contained in:
parent
06c9e0eb99
commit
06dc93fc2f
@ -179,7 +179,7 @@ extern const u8 gText_EmptyString2[];
|
|||||||
extern const u8 gText_Confirm3[];
|
extern const u8 gText_Confirm3[];
|
||||||
extern const u8 gText_Cancel4[];
|
extern const u8 gText_Cancel4[];
|
||||||
extern const u8 gText_IsThisTheCorrectTime[];
|
extern const u8 gText_IsThisTheCorrectTime[];
|
||||||
extern const u8 gText_PkmnFainted3[];
|
extern const u8 gText_PkmnFainted_FldPsn[];
|
||||||
extern const u8 gText_Coins[];
|
extern const u8 gText_Coins[];
|
||||||
extern const u8 gText_Silver[];
|
extern const u8 gText_Silver[];
|
||||||
extern const u8 gText_Gold[];
|
extern const u8 gText_Gold[];
|
||||||
|
@ -21,9 +21,8 @@ static bool32 IsMonValidSpecies(struct Pokemon *pokemon)
|
|||||||
{
|
{
|
||||||
u16 species = GetMonData(pokemon, MON_DATA_SPECIES2);
|
u16 species = GetMonData(pokemon, MON_DATA_SPECIES2);
|
||||||
if (species == SPECIES_NONE || species == SPECIES_EGG)
|
if (species == SPECIES_NONE || species == SPECIES_EGG)
|
||||||
{
|
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -35,16 +34,14 @@ static bool32 AllMonsFainted(void)
|
|||||||
for (i = 0; i < PARTY_SIZE; i++, pokemon++)
|
for (i = 0; i < PARTY_SIZE; i++, pokemon++)
|
||||||
{
|
{
|
||||||
if (IsMonValidSpecies(pokemon) && GetMonData(pokemon, MON_DATA_HP) != 0)
|
if (IsMonValidSpecies(pokemon) && GetMonData(pokemon, MON_DATA_HP) != 0)
|
||||||
{
|
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void FaintFromFieldPoison(u8 partyIdx)
|
static void FaintFromFieldPoison(u8 partyIdx)
|
||||||
{
|
{
|
||||||
struct Pokemon *pokemon = gPlayerParty + partyIdx;
|
struct Pokemon *pokemon = &gPlayerParty[partyIdx];
|
||||||
u32 status = STATUS1_NONE;
|
u32 status = STATUS1_NONE;
|
||||||
|
|
||||||
AdjustFriendship(pokemon, FRIENDSHIP_EVENT_FAINT_FIELD_PSN);
|
AdjustFriendship(pokemon, FRIENDSHIP_EVENT_FAINT_FIELD_PSN);
|
||||||
@ -55,49 +52,47 @@ static void FaintFromFieldPoison(u8 partyIdx)
|
|||||||
|
|
||||||
static bool32 MonFaintedFromPoison(u8 partyIdx)
|
static bool32 MonFaintedFromPoison(u8 partyIdx)
|
||||||
{
|
{
|
||||||
struct Pokemon *pokemon = gPlayerParty + partyIdx;
|
struct Pokemon *pokemon = &gPlayerParty[partyIdx];
|
||||||
if (IsMonValidSpecies(pokemon) && GetMonData(pokemon, MON_DATA_HP) == 0 && GetAilmentFromStatus(GetMonData(pokemon, MON_DATA_STATUS)) == AILMENT_PSN)
|
if (IsMonValidSpecies(pokemon) && GetMonData(pokemon, MON_DATA_HP) == 0 && GetAilmentFromStatus(GetMonData(pokemon, MON_DATA_STATUS)) == AILMENT_PSN)
|
||||||
{
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#define tState data[0]
|
||||||
|
#define tPartyIdx data[1]
|
||||||
|
|
||||||
static void Task_TryFieldPoisonWhiteOut(u8 taskId)
|
static void Task_TryFieldPoisonWhiteOut(u8 taskId)
|
||||||
{
|
{
|
||||||
s16 *data = gTasks[taskId].data;
|
s16 *data = gTasks[taskId].data;
|
||||||
switch (data[0])
|
switch (tState)
|
||||||
{
|
{
|
||||||
case 0:
|
case 0:
|
||||||
for (; data[1] < PARTY_SIZE; data[1]++)
|
for (; tPartyIdx < PARTY_SIZE; tPartyIdx++)
|
||||||
{
|
{
|
||||||
if (MonFaintedFromPoison(data[1]))
|
if (MonFaintedFromPoison(tPartyIdx))
|
||||||
{
|
{
|
||||||
FaintFromFieldPoison(data[1]);
|
FaintFromFieldPoison(tPartyIdx);
|
||||||
ShowFieldMessage(gText_PkmnFainted3);
|
ShowFieldMessage(gText_PkmnFainted_FldPsn);
|
||||||
data[0]++;
|
tState++;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
data[0] = 2;
|
tState = 2; // Finished checking party
|
||||||
break;
|
break;
|
||||||
case 1:
|
case 1:
|
||||||
|
// Wait for "{mon} fainted" message, then return to party loop
|
||||||
if (IsFieldMessageBoxHidden())
|
if (IsFieldMessageBoxHidden())
|
||||||
{
|
tState--;
|
||||||
data[0]--;
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
if (AllMonsFainted())
|
if (AllMonsFainted())
|
||||||
{
|
{
|
||||||
|
// Battle facilities have their own white out script to handle the challenge loss
|
||||||
if (InBattlePyramid() | InBattlePike() || InTrainerHillChallenge())
|
if (InBattlePyramid() | InBattlePike() || InTrainerHillChallenge())
|
||||||
{
|
|
||||||
gSpecialVar_Result = FLDPSN_FRONTIER_WHITEOUT;
|
gSpecialVar_Result = FLDPSN_FRONTIER_WHITEOUT;
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
|
||||||
gSpecialVar_Result = FLDPSN_WHITEOUT;
|
gSpecialVar_Result = FLDPSN_WHITEOUT;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -109,6 +104,9 @@ static void Task_TryFieldPoisonWhiteOut(u8 taskId)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#undef tState
|
||||||
|
#undef tPartyIdx
|
||||||
|
|
||||||
void TryFieldPoisonWhiteOut(void)
|
void TryFieldPoisonWhiteOut(void)
|
||||||
{
|
{
|
||||||
CreateTask(Task_TryFieldPoisonWhiteOut, 80);
|
CreateTask(Task_TryFieldPoisonWhiteOut, 80);
|
||||||
@ -122,31 +120,31 @@ s32 DoPoisonFieldEffect(void)
|
|||||||
struct Pokemon *pokemon = gPlayerParty;
|
struct Pokemon *pokemon = gPlayerParty;
|
||||||
u32 numPoisoned = 0;
|
u32 numPoisoned = 0;
|
||||||
u32 numFainted = 0;
|
u32 numFainted = 0;
|
||||||
|
|
||||||
for (i = 0; i < PARTY_SIZE; i++)
|
for (i = 0; i < PARTY_SIZE; i++)
|
||||||
{
|
{
|
||||||
if (GetMonData(pokemon, MON_DATA_SANITY_HAS_SPECIES) && GetAilmentFromStatus(GetMonData(pokemon, MON_DATA_STATUS)) == AILMENT_PSN)
|
if (GetMonData(pokemon, MON_DATA_SANITY_HAS_SPECIES) && GetAilmentFromStatus(GetMonData(pokemon, MON_DATA_STATUS)) == AILMENT_PSN)
|
||||||
{
|
{
|
||||||
|
// Apply poison damage
|
||||||
hp = GetMonData(pokemon, MON_DATA_HP);
|
hp = GetMonData(pokemon, MON_DATA_HP);
|
||||||
if (hp == 0 || --hp == 0)
|
if (hp == 0 || --hp == 0)
|
||||||
{
|
|
||||||
numFainted++;
|
numFainted++;
|
||||||
}
|
|
||||||
SetMonData(pokemon, MON_DATA_HP, &hp);
|
SetMonData(pokemon, MON_DATA_HP, &hp);
|
||||||
numPoisoned++;
|
numPoisoned++;
|
||||||
}
|
}
|
||||||
pokemon++;
|
pokemon++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Do screen flash effect
|
||||||
if (numFainted != 0 || numPoisoned != 0)
|
if (numFainted != 0 || numPoisoned != 0)
|
||||||
{
|
|
||||||
FldEffPoison_Start();
|
FldEffPoison_Start();
|
||||||
}
|
|
||||||
if (numFainted != 0)
|
if (numFainted != 0)
|
||||||
{
|
|
||||||
return FLDPSN_FNT;
|
return FLDPSN_FNT;
|
||||||
}
|
|
||||||
if (numPoisoned != 0)
|
if (numPoisoned != 0)
|
||||||
{
|
|
||||||
return FLDPSN_PSN;
|
return FLDPSN_PSN;
|
||||||
}
|
|
||||||
return FLDPSN_NONE;
|
return FLDPSN_NONE;
|
||||||
}
|
}
|
||||||
|
@ -1200,29 +1200,35 @@ bool8 IsLargeBreakableDecoration(u16 metatileId, bool8 checkBase)
|
|||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#define tState data[0]
|
||||||
|
#define tMosaic data[1]
|
||||||
|
|
||||||
static void Task_FieldPoisonEffect(u8 taskId)
|
static void Task_FieldPoisonEffect(u8 taskId)
|
||||||
{
|
{
|
||||||
s16 *data = gTasks[taskId].data;
|
s16 *data = gTasks[taskId].data;
|
||||||
|
|
||||||
switch (data[0])
|
switch (tState)
|
||||||
{
|
{
|
||||||
case 0:
|
case 0:
|
||||||
data[1] += 2;
|
tMosaic += 2;
|
||||||
if (data[1] > 8)
|
if (tMosaic > 8)
|
||||||
data[0]++;
|
tState++;
|
||||||
break;
|
break;
|
||||||
case 1:
|
case 1:
|
||||||
data[1] -= 2;
|
tMosaic -= 2;
|
||||||
if (data[1] == 0)
|
if (tMosaic == 0)
|
||||||
data[0]++;
|
tState++;
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
DestroyTask(taskId);
|
DestroyTask(taskId);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
SetGpuReg(REG_OFFSET_MOSAIC, (data[1] << 4) | data[1]);
|
SetGpuReg(REG_OFFSET_MOSAIC, (tMosaic << 4) | tMosaic);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#undef tState
|
||||||
|
#undef tMosaic
|
||||||
|
|
||||||
void FldEffPoison_Start(void)
|
void FldEffPoison_Start(void)
|
||||||
{
|
{
|
||||||
PlaySE(SE_FIELD_POISON);
|
PlaySE(SE_FIELD_POISON);
|
||||||
|
@ -1186,7 +1186,7 @@ const u8 gText_PsychUp48BP[] = _("PSYCH UP{CLEAR_TO 0x4E}48BP");
|
|||||||
const u8 gText_IcePunch48BP[] = _("ICE PUNCH{CLEAR_TO 0x4E}48BP");
|
const u8 gText_IcePunch48BP[] = _("ICE PUNCH{CLEAR_TO 0x4E}48BP");
|
||||||
const u8 gText_ThunderPunch48BP[] = _("THUNDERPUNCH{CLEAR_TO 0x4E}48BP");
|
const u8 gText_ThunderPunch48BP[] = _("THUNDERPUNCH{CLEAR_TO 0x4E}48BP");
|
||||||
const u8 gText_FirePunch48BP[] = _("FIRE PUNCH{CLEAR_TO 0x4E}48BP");
|
const u8 gText_FirePunch48BP[] = _("FIRE PUNCH{CLEAR_TO 0x4E}48BP");
|
||||||
const u8 gText_PkmnFainted3[] = _("{STR_VAR_1} fainted…\p\n");
|
const u8 gText_PkmnFainted_FldPsn[] = _("{STR_VAR_1} fainted…\p\n");
|
||||||
const u8 gText_Marco[] = _("MARCO");
|
const u8 gText_Marco[] = _("MARCO");
|
||||||
const u8 gText_TrainerCardName[] = _("NAME: ");
|
const u8 gText_TrainerCardName[] = _("NAME: ");
|
||||||
const u8 gText_TrainerCardIDNo[] = _("IDNo.");
|
const u8 gText_TrainerCardIDNo[] = _("IDNo.");
|
||||||
|
Loading…
x
Reference in New Issue
Block a user