2017-11-23 02:10:35 +01:00
|
|
|
#include "global.h"
|
|
|
|
#include "string_util.h"
|
|
|
|
#include "party_menu.h"
|
2017-12-11 19:27:51 +01:00
|
|
|
#include "constants/species.h"
|
2017-11-23 02:10:35 +01:00
|
|
|
#include "task.h"
|
|
|
|
#include "field_message_box.h"
|
|
|
|
#include "strings.h"
|
|
|
|
#include "rom_818CFC8.h"
|
2018-10-30 22:17:03 +01:00
|
|
|
#include "frontier_util.h"
|
2017-11-23 02:10:35 +01:00
|
|
|
#include "pokenav.h"
|
|
|
|
#include "event_data.h"
|
|
|
|
#include "script.h"
|
2017-11-29 14:30:18 +01:00
|
|
|
#include "battle.h"
|
2017-11-23 02:10:35 +01:00
|
|
|
#include "fldeff_80F9BCC.h"
|
2017-11-29 14:30:18 +01:00
|
|
|
#include "field_poison.h"
|
2017-11-23 02:10:35 +01:00
|
|
|
|
|
|
|
static bool32 sub_80F9568(struct Pokemon *pokemon)
|
|
|
|
{
|
|
|
|
u16 species = GetMonData(pokemon, MON_DATA_SPECIES2);
|
|
|
|
if (species == SPECIES_NONE || species == SPECIES_EGG)
|
|
|
|
{
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static bool32 sub_80F958C(void)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
struct Pokemon *pokemon;
|
|
|
|
|
|
|
|
for (pokemon = gPlayerParty, i = 0; i < PARTY_SIZE; i++, pokemon++)
|
|
|
|
{
|
|
|
|
if (sub_80F9568(pokemon) && GetMonData(pokemon, MON_DATA_HP) != 0)
|
|
|
|
{
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void sub_80F95C0(u8 partyIdx)
|
|
|
|
{
|
2017-11-29 14:30:18 +01:00
|
|
|
struct Pokemon *pokemon = gPlayerParty + partyIdx;
|
2018-01-16 22:12:38 +01:00
|
|
|
unsigned int status = STATUS1_NONE;
|
2017-11-23 02:10:35 +01:00
|
|
|
AdjustFriendship(pokemon, 0x07);
|
|
|
|
SetMonData(pokemon, MON_DATA_STATUS, &status);
|
|
|
|
GetMonData(pokemon, MON_DATA_NICKNAME, gStringVar1);
|
|
|
|
StringGetEnd10(gStringVar1);
|
|
|
|
}
|
|
|
|
|
|
|
|
static bool32 sub_80F960C(u8 partyIdx)
|
|
|
|
{
|
2017-11-29 14:30:18 +01:00
|
|
|
struct Pokemon *pokemon = gPlayerParty + partyIdx;
|
|
|
|
if (sub_80F9568(pokemon) && GetMonData(pokemon, MON_DATA_HP) == 0 && pokemon_ailments_get_primary(GetMonData(pokemon, MON_DATA_STATUS)) == AILMENT_PSN)
|
2017-11-23 02:10:35 +01:00
|
|
|
{
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void sub_80F9654(u8 taskId)
|
|
|
|
{
|
2017-11-29 14:30:18 +01:00
|
|
|
s16 *data = gTasks[taskId].data;
|
2017-11-23 02:10:35 +01:00
|
|
|
switch (data[0])
|
|
|
|
{
|
|
|
|
case 0:
|
|
|
|
for (; data[1] < PARTY_SIZE; data[1]++)
|
|
|
|
{
|
|
|
|
if (sub_80F960C(data[1]))
|
|
|
|
{
|
|
|
|
sub_80F95C0(data[1]);
|
|
|
|
ShowFieldMessage(gText_PkmnFainted3);
|
|
|
|
data[0]++;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
data[0] = 2;
|
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
if (IsFieldMessageBoxHidden())
|
|
|
|
{
|
|
|
|
data[0]--;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
if (sub_80F958C())
|
|
|
|
{
|
|
|
|
if (InBattlePyramid() | InBattlePike() || sub_81D5C18())
|
|
|
|
{
|
|
|
|
gSpecialVar_Result = 2;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
gSpecialVar_Result = 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
gSpecialVar_Result = 0;
|
|
|
|
}
|
|
|
|
EnableBothScriptContexts();
|
|
|
|
DestroyTask(taskId);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void sub_80F972C(void)
|
|
|
|
{
|
|
|
|
CreateTask(sub_80F9654, 80);
|
|
|
|
ScriptContext1_Stop();
|
|
|
|
}
|
|
|
|
|
2018-10-17 04:47:08 +02:00
|
|
|
int DoPoisonFieldEffect(void)
|
2017-11-23 02:10:35 +01:00
|
|
|
{
|
|
|
|
int i;
|
2017-11-29 14:30:18 +01:00
|
|
|
unsigned int hp;
|
|
|
|
struct Pokemon *pokemon = gPlayerParty;
|
|
|
|
unsigned int numPoisoned = 0;
|
|
|
|
unsigned int numFainted = 0;
|
2017-11-23 02:10:35 +01:00
|
|
|
for (i = 0; i < PARTY_SIZE; i++)
|
|
|
|
{
|
2017-11-29 14:30:18 +01:00
|
|
|
if (GetMonData(pokemon, MON_DATA_SANITY_BIT2) && pokemon_ailments_get_primary(GetMonData(pokemon, MON_DATA_STATUS)) == AILMENT_PSN)
|
2017-11-23 02:10:35 +01:00
|
|
|
{
|
|
|
|
hp = GetMonData(pokemon, MON_DATA_HP);
|
|
|
|
if (hp == 0 || --hp == 0)
|
|
|
|
{
|
2017-11-29 14:30:18 +01:00
|
|
|
numFainted++;
|
2017-11-23 02:10:35 +01:00
|
|
|
}
|
|
|
|
SetMonData(pokemon, MON_DATA_HP, &hp);
|
2017-11-29 14:30:18 +01:00
|
|
|
numPoisoned++;
|
2017-11-23 02:10:35 +01:00
|
|
|
}
|
|
|
|
pokemon++;
|
|
|
|
}
|
2017-11-29 14:30:18 +01:00
|
|
|
if (numFainted != 0 || numPoisoned != 0)
|
2017-11-23 02:10:35 +01:00
|
|
|
{
|
|
|
|
overworld_poison_effect();
|
|
|
|
}
|
2017-11-29 14:30:18 +01:00
|
|
|
if (numFainted != 0)
|
2017-11-23 02:10:35 +01:00
|
|
|
{
|
2017-11-29 14:30:18 +01:00
|
|
|
return FLDPSN_FNT;
|
2017-11-23 02:10:35 +01:00
|
|
|
}
|
2017-11-29 14:30:18 +01:00
|
|
|
if (numPoisoned != 0)
|
2017-11-23 02:10:35 +01:00
|
|
|
{
|
2017-11-29 14:30:18 +01:00
|
|
|
return FLDPSN_PSN;
|
2017-11-23 02:10:35 +01:00
|
|
|
}
|
2017-11-29 14:30:18 +01:00
|
|
|
return FLDPSN_NONE;
|
2017-11-23 02:10:35 +01:00
|
|
|
}
|