Continue documenting generic arguments

This commit is contained in:
GriffinR
2022-06-01 12:41:57 -04:00
parent a8437493c1
commit 34438e6bc4
71 changed files with 1246 additions and 1076 deletions
+59 -40
View File
@@ -73,12 +73,16 @@ struct TourneyTreeLineSection
#define tMode data[2]
#define tPrevTaskId data[3]
#define EFFECTIVENESS_MODE_GOOD 0
#define EFFECTIVENESS_MODE_BAD 1
#define EFFECTIVENESS_MODE_AI_VS_AI 2
static u8 GetDomeTrainerMonIvs(u16);
static void SwapDomeTrainers(int, int, u16 *);
static void CalcDomeMonStats(u16, int, int, u8, u8, int *);
static void CreateDomeOpponentMons(u16);
static int SelectOpponentMonsUsingPersonality(u16, bool8);
static int SelectOpponentMonsUsingOtId(u16, bool8);
static int SelectOpponentMons_Good(u16, bool8);
static int SelectOpponentMons_Bad(u16, bool8);
static int GetTypeEffectivenessPoints(int, int, int);
static int SelectOpponentMonsFromParty(int *, bool8);
static void Task_ShowTourneyInfoCard(u8);
@@ -2589,28 +2593,33 @@ static void CreateDomeOpponentMons(u16 tournamentTrainerId)
}
}
// Returns a bitmask representing which 2 of the trainer's 3 pokemon to select.
// The choice is calculated solely depending on the type effectiveness of their
// movesets against the player's pokemon.
// There is a 50% chance of either a "good" or "bad" selection mode being used.
// In the good mode movesets are preferred which are more effective against the
// player, and in the bad mode the opposite is true. If all 3 pokemon tie, the
// other mode will be tried. If they tie again, the pokemon selection is random.
int GetDomeTrainerSelectedMons(u16 tournamentTrainerId)
{
int selectedMonBits;
if (Random() & 1)
{
selectedMonBits = SelectOpponentMonsUsingPersonality(tournamentTrainerId, FALSE);
selectedMonBits = SelectOpponentMons_Good(tournamentTrainerId, FALSE);
if (selectedMonBits == 0)
selectedMonBits = SelectOpponentMonsUsingOtId(tournamentTrainerId, TRUE);
selectedMonBits = SelectOpponentMons_Bad(tournamentTrainerId, TRUE);
}
else
{
selectedMonBits = SelectOpponentMonsUsingOtId(tournamentTrainerId, FALSE);
selectedMonBits = SelectOpponentMons_Bad(tournamentTrainerId, FALSE);
if (selectedMonBits == 0)
selectedMonBits = SelectOpponentMonsUsingPersonality(tournamentTrainerId, TRUE);
selectedMonBits = SelectOpponentMons_Good(tournamentTrainerId, TRUE);
}
return selectedMonBits;
}
// Could probably use a better name once GetTypeEffectivenessPoints is clarified
// Personality seems to be used to select a different weighting system for type effectiveness points
static int SelectOpponentMonsUsingPersonality(u16 tournamentTrainerId, bool8 allowRandom)
static int SelectOpponentMons_Good(u16 tournamentTrainerId, bool8 allowRandom)
{
int i, moveId, playerMonId;
int partyMovePoints[FRONTIER_PARTY_SIZE];
@@ -2625,12 +2634,12 @@ static int SelectOpponentMonsUsingPersonality(u16 tournamentTrainerId, bool8 all
if (DOME_TRAINERS[tournamentTrainerId].trainerId == TRAINER_FRONTIER_BRAIN)
{
partyMovePoints[i] += GetTypeEffectivenessPoints(GetFrontierBrainMonMove(i, moveId),
GetMonData(&gPlayerParty[playerMonId], MON_DATA_SPECIES, NULL), MON_DATA_PERSONALITY);
GetMonData(&gPlayerParty[playerMonId], MON_DATA_SPECIES, NULL), EFFECTIVENESS_MODE_GOOD);
}
else
{
partyMovePoints[i] += GetTypeEffectivenessPoints(gFacilityTrainerMons[DOME_MONS[tournamentTrainerId][i]].moves[moveId],
GetMonData(&gPlayerParty[playerMonId], MON_DATA_SPECIES, NULL), MON_DATA_PERSONALITY);
GetMonData(&gPlayerParty[playerMonId], MON_DATA_SPECIES, NULL), EFFECTIVENESS_MODE_GOOD);
}
}
}
@@ -2638,8 +2647,8 @@ static int SelectOpponentMonsUsingPersonality(u16 tournamentTrainerId, bool8 all
return SelectOpponentMonsFromParty(partyMovePoints, allowRandom);
}
// See above function, identical but uses MON_DATA_OT_ID
static int SelectOpponentMonsUsingOtId(u16 tournamentTrainerId, bool8 allowRandom)
// Identical to function above, but uses EFFECTIVENESS_MODE_BAD
static int SelectOpponentMons_Bad(u16 tournamentTrainerId, bool8 allowRandom)
{
int i, moveId, playerMonId;
int partyMovePoints[FRONTIER_PARTY_SIZE];
@@ -2654,12 +2663,12 @@ static int SelectOpponentMonsUsingOtId(u16 tournamentTrainerId, bool8 allowRando
if (DOME_TRAINERS[tournamentTrainerId].trainerId == TRAINER_FRONTIER_BRAIN)
{
partyMovePoints[i] += GetTypeEffectivenessPoints(GetFrontierBrainMonMove(i, moveId),
GetMonData(&gPlayerParty[playerMonId], MON_DATA_SPECIES, NULL), MON_DATA_OT_ID);
GetMonData(&gPlayerParty[playerMonId], MON_DATA_SPECIES, NULL), EFFECTIVENESS_MODE_BAD);
}
else
{
partyMovePoints[i] += GetTypeEffectivenessPoints(gFacilityTrainerMons[DOME_MONS[tournamentTrainerId][i]].moves[moveId],
GetMonData(&gPlayerParty[playerMonId], MON_DATA_SPECIES, NULL), MON_DATA_OT_ID);
GetMonData(&gPlayerParty[playerMonId], MON_DATA_SPECIES, NULL), EFFECTIVENESS_MODE_BAD);
}
}
}
@@ -2732,7 +2741,7 @@ static int SelectOpponentMonsFromParty(int *partyMovePoints, bool8 allowRandom)
#define TYPE_x2 40
#define TYPE_x4 80
static int GetTypeEffectivenessPoints(int move, int targetSpecies, int arg2)
static int GetTypeEffectivenessPoints(int move, int targetSpecies, int mode)
{
int defType1, defType2, defAbility, moveType;
int i = 0;
@@ -2748,11 +2757,20 @@ static int GetTypeEffectivenessPoints(int move, int targetSpecies, int arg2)
if (defAbility == ABILITY_LEVITATE && moveType == TYPE_GROUND)
{
if (arg2 == 1)
// They likely meant to return here, as 8 is the number of points normally used in this mode for moves with no effect.
// Because there's no return the value instead gets interpreted by the switch, and the number of points becomes 0.
if (mode == EFFECTIVENESS_MODE_BAD)
{
typePower = 8;
#ifdef BUGFIX
return;
#endif
}
}
else
{
// Calculate a "type power" value to determine the benefit of using this type move against the target.
// This value will then be used to get the number of points to assign to the move.
while (TYPE_EFFECT_ATK_TYPE(i) != TYPE_ENDTABLE)
{
if (TYPE_EFFECT_ATK_TYPE(i) == TYPE_FORESIGHT)
@@ -2764,33 +2782,30 @@ static int GetTypeEffectivenessPoints(int move, int targetSpecies, int arg2)
{
// BUG: the value of TYPE_x2 does not exist in gTypeEffectiveness, so if defAbility is ABILITY_WONDER_GUARD, the conditional always fails
#ifndef BUGFIX
if (TYPE_EFFECT_DEF_TYPE(i) == defType1)
if ((defAbility == ABILITY_WONDER_GUARD && TYPE_EFFECT_MULTIPLIER(i) == TYPE_x2) || defAbility != ABILITY_WONDER_GUARD)
typePower = (typePower * TYPE_EFFECT_MULTIPLIER(i)) / 10;
if (TYPE_EFFECT_DEF_TYPE(i) == defType2 && defType1 != defType2)
if ((defAbility == ABILITY_WONDER_GUARD && TYPE_EFFECT_MULTIPLIER(i) == TYPE_x2) || defAbility != ABILITY_WONDER_GUARD)
typePower = (typePower * TYPE_EFFECT_MULTIPLIER(i)) / 10;
#define WONDER_GUARD_EFFECTIVENESS TYPE_x2
#else
#define WONDER_GUARD_EFFECTIVENESS TYPE_MUL_SUPER_EFFECTIVE
#endif
if (TYPE_EFFECT_DEF_TYPE(i) == defType1)
if ((defAbility == ABILITY_WONDER_GUARD && TYPE_EFFECT_MULTIPLIER(i) == TYPE_MUL_SUPER_EFFECTIVE) || defAbility != ABILITY_WONDER_GUARD)
if ((defAbility == ABILITY_WONDER_GUARD && TYPE_EFFECT_MULTIPLIER(i) == WONDER_GUARD_EFFECTIVENESS) || defAbility != ABILITY_WONDER_GUARD)
typePower = (typePower * TYPE_EFFECT_MULTIPLIER(i)) / 10;
if (TYPE_EFFECT_DEF_TYPE(i) == defType2 && defType1 != defType2)
if ((defAbility == ABILITY_WONDER_GUARD && TYPE_EFFECT_MULTIPLIER(i) == TYPE_MUL_SUPER_EFFECTIVE) || defAbility != ABILITY_WONDER_GUARD)
if ((defAbility == ABILITY_WONDER_GUARD && TYPE_EFFECT_MULTIPLIER(i) == WONDER_GUARD_EFFECTIVENESS) || defAbility != ABILITY_WONDER_GUARD)
typePower = (typePower * TYPE_EFFECT_MULTIPLIER(i)) / 10;
#endif
}
i += 3;
}
}
switch (arg2)
switch (mode)
{
case 0:
case EFFECTIVENESS_MODE_GOOD:
// Weights moves that more effective.
switch (typePower)
{
case TYPE_x0_50:
case TYPE_x0_25:
case TYPE_x0:
case TYPE_x0_25:
case TYPE_x0_50:
default:
typePower = 0;
break;
@@ -2805,22 +2820,24 @@ static int GetTypeEffectivenessPoints(int move, int targetSpecies, int arg2)
break;
}
break;
case 1:
case EFFECTIVENESS_MODE_BAD:
// Weights moves that are less effective.
// Odd that there's no limit on this being used, even the Frontier Brain could end up using this.
switch (typePower)
{
default:
case TYPE_x1:
typePower = 0;
case TYPE_x0:
typePower = 8;
break;
case TYPE_x0_25:
typePower = 4;
break;
case TYPE_x0:
typePower = 8;
break;
case TYPE_x0_50:
typePower = 2;
break;
default:
case TYPE_x1:
typePower = 0;
break;
case TYPE_x2:
typePower = -2;
break;
@@ -2829,7 +2846,9 @@ static int GetTypeEffectivenessPoints(int move, int targetSpecies, int arg2)
break;
}
break;
case 2:
case EFFECTIVENESS_MODE_AI_VS_AI:
// Used as part of calculating the winner in a battle between two AIs.
// Weights moves that are more effective much more strongly in both directions.
switch (typePower)
{
case TYPE_x0:
@@ -5987,7 +6006,7 @@ static void DecideRoundWinners(u8 roundId)
for (monId2 = 0; monId2 < FRONTIER_PARTY_SIZE; monId2++)
{
points1 += GetTypeEffectivenessPoints(gFacilityTrainerMons[DOME_MONS[tournamentId1][monId1]].moves[moveSlot],
gFacilityTrainerMons[DOME_MONS[tournamentId2][monId2]].species, 2);
gFacilityTrainerMons[DOME_MONS[tournamentId2][monId2]].species, EFFECTIVENESS_MODE_AI_VS_AI);
}
}
species = gFacilityTrainerMons[DOME_MONS[tournamentId1][monId1]].species;
@@ -6010,7 +6029,7 @@ static void DecideRoundWinners(u8 roundId)
for (monId2 = 0; monId2 < FRONTIER_PARTY_SIZE; monId2++)
{
points2 += GetTypeEffectivenessPoints(gFacilityTrainerMons[DOME_MONS[tournamentId2][monId1]].moves[moveSlot],
gFacilityTrainerMons[DOME_MONS[tournamentId1][monId2]].species, 2);
gFacilityTrainerMons[DOME_MONS[tournamentId1][monId2]].species, EFFECTIVENESS_MODE_AI_VS_AI);
}
}
species = gFacilityTrainerMons[DOME_MONS[tournamentId2][monId1]].species;