Start pokenav conditions doc
This commit is contained in:
+79
-85
@@ -57,14 +57,14 @@ struct UsePokeblockSession
|
||||
u8 mainState;
|
||||
u8 unused1;
|
||||
u8 timer;
|
||||
u8 statId;
|
||||
u8 condition;
|
||||
u8 numEnhancements;
|
||||
u8 unused2;
|
||||
bool8 monInTopHalf;
|
||||
u8 conditionsBeforeBlock[FLAVOR_COUNT];
|
||||
u8 conditionsAfterBlock[FLAVOR_COUNT];
|
||||
u8 enhancements[FLAVOR_COUNT];
|
||||
s16 pokeblockStatBoosts[FLAVOR_COUNT];
|
||||
u8 conditionsBeforeBlock[CONDITION_COUNT];
|
||||
u8 conditionsAfterBlock[CONDITION_COUNT];
|
||||
u8 enhancements[CONDITION_COUNT];
|
||||
s16 pokeblockStatBoosts[CONDITION_COUNT];
|
||||
u8 numSelections; // num in party + 1 (for Cancel)
|
||||
u8 curSelection;
|
||||
bool8 (*loadNewSelection)(void);
|
||||
@@ -142,7 +142,7 @@ static void LoadAndCreateUpDownSprites(void);
|
||||
static void CalculateNumAdditionalSparkles(u8);
|
||||
static void PrintFirstEnhancement(void);
|
||||
static bool8 TryPrintNextEnhancement(void);
|
||||
static void BufferEnhancedStatText(u8 *, u8, s16);
|
||||
static void BufferEnhancedText(u8 *, u8, s16);
|
||||
static void PrintMenuWindowText(const u8 *);
|
||||
static void CalculatePokeblockEffectiveness(struct Pokeblock *, struct Pokemon *);
|
||||
static void SpriteCB_UpDown(struct Sprite *);
|
||||
@@ -178,22 +178,22 @@ static const u32 sGraphData_Tilemap[] = INCBIN_U32("graphics/pokeblock/use_scree
|
||||
|
||||
// The condition/flavors aren't listed in their normal order in this file, they're listed as shown on the graph going counter-clockwise
|
||||
// Normally they would go Cool/Spicy, Beauty/Dry, Cute/Sweet, Smart/Bitter, Tough/Sour (also graph order, but clockwise)
|
||||
static const u32 sMonDataConditions[FLAVOR_COUNT] =
|
||||
static const u32 sConditionToMonData[CONDITION_COUNT] =
|
||||
{
|
||||
MON_DATA_COOL,
|
||||
MON_DATA_TOUGH,
|
||||
MON_DATA_SMART,
|
||||
MON_DATA_CUTE,
|
||||
MON_DATA_BEAUTY
|
||||
[CONDITION_COOL] = MON_DATA_COOL,
|
||||
[CONDITION_TOUGH] = MON_DATA_TOUGH,
|
||||
[CONDITION_SMART] = MON_DATA_SMART,
|
||||
[CONDITION_CUTE] = MON_DATA_CUTE,
|
||||
[CONDITION_BEAUTY] = MON_DATA_BEAUTY
|
||||
};
|
||||
|
||||
static const u8 sFlavors[FLAVOR_COUNT] =
|
||||
static const u8 sConditionToFlavor[CONDITION_COUNT] =
|
||||
{
|
||||
FLAVOR_SPICY,
|
||||
FLAVOR_SOUR,
|
||||
FLAVOR_BITTER,
|
||||
FLAVOR_SWEET,
|
||||
FLAVOR_DRY
|
||||
[CONDITION_COOL] = FLAVOR_SPICY,
|
||||
[CONDITION_TOUGH] = FLAVOR_SOUR,
|
||||
[CONDITION_SMART] = FLAVOR_BITTER,
|
||||
[CONDITION_CUTE] = FLAVOR_SWEET,
|
||||
[CONDITION_BEAUTY] = FLAVOR_DRY
|
||||
};
|
||||
|
||||
static const u8 sNatureTextColors[] =
|
||||
@@ -286,13 +286,13 @@ static const struct WindowTemplate sUsePokeblockYesNoWinTemplate =
|
||||
.baseBlock = 0x83
|
||||
};
|
||||
|
||||
static const u8 *const sContestStatNames[] =
|
||||
static const u8 *const sConditionNames[CONDITION_COUNT] =
|
||||
{
|
||||
gText_Coolness,
|
||||
gText_Toughness,
|
||||
gText_Smartness,
|
||||
gText_Cuteness,
|
||||
gText_Beauty3
|
||||
[CONDITION_COOL] = gText_Coolness,
|
||||
[CONDITION_TOUGH] = gText_Toughness,
|
||||
[CONDITION_SMART] = gText_Smartness,
|
||||
[CONDITION_CUTE] = gText_Cuteness,
|
||||
[CONDITION_BEAUTY] = gText_Beauty3
|
||||
};
|
||||
|
||||
static const struct SpriteSheet sSpriteSheet_UpDown =
|
||||
@@ -305,13 +305,13 @@ static const struct SpritePalette sSpritePalette_UpDown =
|
||||
gUsePokeblockUpDown_Pal, TAG_UP_DOWN
|
||||
};
|
||||
|
||||
static const s16 sUpDownCoordsOnGraph[FLAVOR_COUNT][2] =
|
||||
static const s16 sUpDownCoordsOnGraph[CONDITION_COUNT][2] =
|
||||
{
|
||||
{156, 36},
|
||||
{117, 59},
|
||||
{117, 118},
|
||||
{197, 118},
|
||||
{197, 59}
|
||||
[CONDITION_COOL] = {156, 36},
|
||||
[CONDITION_TOUGH] = {117, 59},
|
||||
[CONDITION_SMART] = {117, 118},
|
||||
[CONDITION_CUTE] = {197, 118},
|
||||
[CONDITION_BEAUTY] = {197, 59}
|
||||
};
|
||||
|
||||
static const struct OamData sOam_UpDown =
|
||||
@@ -487,7 +487,7 @@ static void LoadUsePokeblockMenu(void)
|
||||
{
|
||||
case 0:
|
||||
sMenu->curMonSpriteId = SPRITE_NONE;
|
||||
InitConditionGraphData(&sMenu->graph);
|
||||
ConditionGraph_Init(&sMenu->graph);
|
||||
sInfo->mainState++;
|
||||
break;
|
||||
case 1:
|
||||
@@ -537,7 +537,7 @@ static void LoadUsePokeblockMenu(void)
|
||||
sInfo->mainState++;
|
||||
break;
|
||||
case 11:
|
||||
sub_81D2754(sMenu->graph.stat[0], sMenu->graph.unk14[0]);
|
||||
sub_81D2754(sMenu->graph.conditions[0], sMenu->graph.unk14[0]);
|
||||
InitConditionGraphState(&sMenu->graph);
|
||||
sInfo->mainState++;
|
||||
break;
|
||||
@@ -767,8 +767,6 @@ static void ShowUsePokeblockMenuForResults(void)
|
||||
|
||||
static void ShowPokeblockResults(void)
|
||||
{
|
||||
u8 var;
|
||||
|
||||
switch (sInfo->mainState)
|
||||
{
|
||||
case 0:
|
||||
@@ -789,8 +787,7 @@ static void ShowPokeblockResults(void)
|
||||
sInfo->mainState++;
|
||||
break;
|
||||
case 3:
|
||||
var = TransitionConditionGraph(&sMenu->graph);
|
||||
if (!var)
|
||||
if (!TransitionConditionGraph(&sMenu->graph))
|
||||
{
|
||||
CalculateNumAdditionalSparkles(GetPartyIdFromSelectionId(sMenu->info.curSelection));
|
||||
if (sMenu->info.curSelection != sMenu->info.numSelections - 1)
|
||||
@@ -906,16 +903,16 @@ static void PrintFirstEnhancement(void)
|
||||
DrawTextBorderOuter(WIN_TEXT, 151, 14);
|
||||
FillWindowPixelBuffer(WIN_TEXT, 17);
|
||||
|
||||
for (sInfo->statId = 0; sInfo->statId < FLAVOR_COUNT; sInfo->statId++)
|
||||
for (sInfo->condition = 0; sInfo->condition < CONDITION_COUNT; sInfo->condition++)
|
||||
{
|
||||
if (sInfo->enhancements[sInfo->statId] != 0)
|
||||
if (sInfo->enhancements[sInfo->condition] != 0)
|
||||
break;
|
||||
}
|
||||
|
||||
if (sInfo->statId < FLAVOR_COUNT)
|
||||
BufferEnhancedStatText(gStringVar4, sInfo->statId, sInfo->enhancements[sInfo->statId]);
|
||||
if (sInfo->condition < CONDITION_COUNT)
|
||||
BufferEnhancedText(gStringVar4, sInfo->condition, sInfo->enhancements[sInfo->condition]);
|
||||
else
|
||||
BufferEnhancedStatText(gStringVar4, sInfo->statId, 0);
|
||||
BufferEnhancedText(gStringVar4, sInfo->condition, 0);
|
||||
|
||||
PrintMenuWindowText(gStringVar4);
|
||||
PutWindowTilemap(WIN_TEXT);
|
||||
@@ -928,20 +925,20 @@ static bool8 TryPrintNextEnhancement(void)
|
||||
|
||||
while (1)
|
||||
{
|
||||
sInfo->statId++;
|
||||
if (sInfo->statId < FLAVOR_COUNT)
|
||||
sInfo->condition++;
|
||||
if (sInfo->condition < CONDITION_COUNT)
|
||||
{
|
||||
if (sInfo->enhancements[sInfo->statId] != 0)
|
||||
if (sInfo->enhancements[sInfo->condition] != 0)
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
sInfo->statId = FLAVOR_COUNT;
|
||||
sInfo->condition = CONDITION_COUNT;
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
BufferEnhancedStatText(gStringVar4, sInfo->statId, sInfo->enhancements[sInfo->statId]);
|
||||
BufferEnhancedText(gStringVar4, sInfo->condition, sInfo->enhancements[sInfo->condition]);
|
||||
PrintMenuWindowText(gStringVar4);
|
||||
CopyWindowToVram(WIN_TEXT, COPYWIN_GFX);
|
||||
|
||||
@@ -969,7 +966,7 @@ static void PrintMenuWindowText(const u8 *message)
|
||||
AddTextPrinterParameterized(WIN_TEXT, FONT_NORMAL, gStringVar4, 0, 1, 0, NULL);
|
||||
}
|
||||
|
||||
static void BufferEnhancedStatText(u8 *dest, u8 statId, s16 enhancement)
|
||||
static void BufferEnhancedText(u8 *dest, u8 condition, s16 enhancement)
|
||||
{
|
||||
switch (enhancement)
|
||||
{
|
||||
@@ -979,7 +976,7 @@ static void BufferEnhancedStatText(u8 *dest, u8 statId, s16 enhancement)
|
||||
case -32768 ... -1: // if < 0
|
||||
if (enhancement)
|
||||
dest[(u16)enhancement] += 0; // something you can't imagine
|
||||
StringCopy(dest, sContestStatNames[statId]);
|
||||
StringCopy(dest, sConditionNames[condition]);
|
||||
StringAppend(dest, gText_WasEnhanced);
|
||||
break;
|
||||
case 0:
|
||||
@@ -992,36 +989,36 @@ static void GetMonConditions(struct Pokemon *mon, u8 *data)
|
||||
{
|
||||
u16 i;
|
||||
|
||||
for (i = 0; i < FLAVOR_COUNT; i++)
|
||||
data[i] = GetMonData(mon, sMonDataConditions[i]);
|
||||
for (i = 0; i < CONDITION_COUNT; i++)
|
||||
data[i] = GetMonData(mon, sConditionToMonData[i]);
|
||||
}
|
||||
|
||||
static void AddPokeblockToConditions(struct Pokeblock *pokeblock, struct Pokemon *mon)
|
||||
{
|
||||
u16 i;
|
||||
s16 cstat;
|
||||
s16 stat;
|
||||
u8 data;
|
||||
|
||||
if (GetMonData(mon, MON_DATA_SHEEN) != 255)
|
||||
if (GetMonData(mon, MON_DATA_SHEEN) != MAX_SHEEN)
|
||||
{
|
||||
CalculatePokeblockEffectiveness(pokeblock, mon);
|
||||
for (i = 0; i < FLAVOR_COUNT; i++)
|
||||
for (i = 0; i < CONDITION_COUNT; i++)
|
||||
{
|
||||
data = GetMonData(mon, sMonDataConditions[i]);
|
||||
cstat = data + sInfo->pokeblockStatBoosts[i];
|
||||
if (cstat < 0)
|
||||
cstat = 0;
|
||||
if (cstat > 255)
|
||||
cstat = 255;
|
||||
data = cstat;
|
||||
SetMonData(mon, sMonDataConditions[i], &data);
|
||||
data = GetMonData(mon, sConditionToMonData[i]);
|
||||
stat = data + sInfo->pokeblockStatBoosts[i];
|
||||
if (stat < 0)
|
||||
stat = 0;
|
||||
if (stat > MAX_CONDITION)
|
||||
stat = MAX_CONDITION;
|
||||
data = stat;
|
||||
SetMonData(mon, sConditionToMonData[i], &data);
|
||||
}
|
||||
|
||||
cstat = (u8)(GetMonData(mon, MON_DATA_SHEEN)) + pokeblock->feel;
|
||||
if (cstat > 255)
|
||||
cstat = 255;
|
||||
stat = (u8)(GetMonData(mon, MON_DATA_SHEEN)) + pokeblock->feel;
|
||||
if (stat > MAX_SHEEN)
|
||||
stat = MAX_SHEEN;
|
||||
|
||||
data = cstat;
|
||||
data = stat;
|
||||
SetMonData(mon, MON_DATA_SHEEN, &data);
|
||||
}
|
||||
}
|
||||
@@ -1035,19 +1032,19 @@ static void CalculateConditionEnhancements(void)
|
||||
GetMonConditions(mon, sInfo->conditionsBeforeBlock);
|
||||
AddPokeblockToConditions(sInfo->pokeblock, mon);
|
||||
GetMonConditions(mon, sInfo->conditionsAfterBlock);
|
||||
for (i = 0; i < FLAVOR_COUNT; i++)
|
||||
for (i = 0; i < CONDITION_COUNT; i++)
|
||||
sInfo->enhancements[i] = sInfo->conditionsAfterBlock[i] - sInfo->conditionsBeforeBlock[i];
|
||||
}
|
||||
|
||||
static void CalculatePokeblockEffectiveness(struct Pokeblock *pokeblock, struct Pokemon *mon)
|
||||
{
|
||||
s8 i, direction, taste;
|
||||
s8 i, direction, flavor;
|
||||
|
||||
sInfo->pokeblockStatBoosts[0] = pokeblock->spicy;
|
||||
sInfo->pokeblockStatBoosts[1] = pokeblock->sour;
|
||||
sInfo->pokeblockStatBoosts[2] = pokeblock->bitter;
|
||||
sInfo->pokeblockStatBoosts[3] = pokeblock->sweet;
|
||||
sInfo->pokeblockStatBoosts[4] = pokeblock->dry;
|
||||
sInfo->pokeblockStatBoosts[CONDITION_COOL] = pokeblock->spicy;
|
||||
sInfo->pokeblockStatBoosts[CONDITION_TOUGH] = pokeblock->sour;
|
||||
sInfo->pokeblockStatBoosts[CONDITION_SMART] = pokeblock->bitter;
|
||||
sInfo->pokeblockStatBoosts[CONDITION_CUTE] = pokeblock->sweet;
|
||||
sInfo->pokeblockStatBoosts[CONDITION_BEAUTY] = pokeblock->dry;
|
||||
|
||||
if (gPokeblockGain > 0)
|
||||
direction = 1;
|
||||
@@ -1056,7 +1053,7 @@ static void CalculatePokeblockEffectiveness(struct Pokeblock *pokeblock, struct
|
||||
else
|
||||
return;
|
||||
|
||||
for (i = 0; i < FLAVOR_COUNT; i++)
|
||||
for (i = 0; i < CONDITION_COUNT; i++)
|
||||
{
|
||||
s16 amount = sInfo->pokeblockStatBoosts[i];
|
||||
s8 boost = amount / 10;
|
||||
@@ -1064,9 +1061,9 @@ static void CalculatePokeblockEffectiveness(struct Pokeblock *pokeblock, struct
|
||||
if (amount % 10 >= 5) // round to the nearest
|
||||
boost++;
|
||||
|
||||
taste = GetMonFlavorRelation(mon, sFlavors[i]);
|
||||
if (taste == direction)
|
||||
sInfo->pokeblockStatBoosts[i] += boost * taste;
|
||||
flavor = GetMonFlavorRelation(mon, sConditionToFlavor[i]);
|
||||
if (flavor == direction)
|
||||
sInfo->pokeblockStatBoosts[i] += boost * flavor;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1075,7 +1072,7 @@ static bool8 IsSheenMaxed(void)
|
||||
if (GetBoxOrPartyMonData(sMenu->party[sMenu->info.curSelection].boxId,
|
||||
sMenu->party[sMenu->info.curSelection].monId,
|
||||
MON_DATA_SHEEN,
|
||||
NULL) == 255)
|
||||
NULL) == MAX_SHEEN)
|
||||
return TRUE;
|
||||
else
|
||||
return FALSE;
|
||||
@@ -1125,7 +1122,7 @@ static void LoadAndCreateUpDownSprites(void)
|
||||
LoadSpritePalette(&sSpritePalette_UpDown);
|
||||
sInfo->numEnhancements = 0;
|
||||
|
||||
for (i = 0; i < FLAVOR_COUNT; i++)
|
||||
for (i = 0; i < CONDITION_COUNT; i++)
|
||||
{
|
||||
if (sInfo->enhancements[i] != 0)
|
||||
{
|
||||
@@ -1487,7 +1484,7 @@ static bool8 LoadNewSelection_CancelToMon(void)
|
||||
sMenu->info.helperState++;
|
||||
break;
|
||||
case 2:
|
||||
if (!TryUpdateConditionMonTransitionOn(&sMenu->graph, &sMenu->curMonXOffset))
|
||||
if (!ConditionGraph_UpdateMonEnter(&sMenu->graph, &sMenu->curMonXOffset))
|
||||
{
|
||||
// Load the new adjacent pokemon (not the one being shown)
|
||||
LoadMonInfo(sMenu->toLoadSelection, sMenu->toLoadId);
|
||||
@@ -1514,7 +1511,7 @@ static bool8 LoadNewSelection_MonToCancel(void)
|
||||
switch (sMenu->info.helperState)
|
||||
{
|
||||
case 0:
|
||||
if (!TryUpdateConditionMonTransitionOff(&sMenu->graph, &sMenu->curMonXOffset))
|
||||
if (!ConditionGraph_UpdateMonExit(&sMenu->graph, &sMenu->curMonXOffset))
|
||||
sMenu->info.helperState++;
|
||||
break;
|
||||
case 1:
|
||||
@@ -1550,7 +1547,7 @@ static bool8 LoadNewSelection_MonToMon(void)
|
||||
sMenu->info.helperState++;
|
||||
break;
|
||||
case 2:
|
||||
if (!TryUpdateConditionMonTransitionOn(&sMenu->graph, &sMenu->curMonXOffset))
|
||||
if (!ConditionGraph_UpdateMonEnter(&sMenu->graph, &sMenu->curMonXOffset))
|
||||
{
|
||||
// Load the new adjacent pokemon (not the one being shown)
|
||||
LoadMonInfo(sMenu->toLoadSelection, sMenu->toLoadId);
|
||||
@@ -1599,10 +1596,7 @@ static void SpriteCB_SelectionIconCancel(struct Sprite *sprite)
|
||||
static void CalculateNumAdditionalSparkles(u8 monIndex)
|
||||
{
|
||||
u8 sheen = GetMonData(&gPlayerParty[monIndex], MON_DATA_SHEEN);
|
||||
|
||||
sMenu->numSparkles[sMenu->curLoadId] = (sheen != 255)
|
||||
? sheen / (255 / (MAX_CONDITION_SPARKLES - 1) + 1)
|
||||
: MAX_CONDITION_SPARKLES - 1;
|
||||
sMenu->numSparkles[sMenu->curLoadId] = GET_NUM_CONDITION_SPARKLES(sheen);
|
||||
}
|
||||
|
||||
static void LoadConditionGfx(void)
|
||||
|
||||
Reference in New Issue
Block a user