Skip to content

Commit

Permalink
Added Difficulty Fallback for Trainer Slides (#6088)
Browse files Browse the repository at this point in the history
  • Loading branch information
pkmnsnfrn authored Jan 29, 2025
1 parent bc5adca commit b130a38
Showing 1 changed file with 24 additions and 12 deletions.
36 changes: 24 additions & 12 deletions src/trainer_slide.c
Original file line number Diff line number Diff line change
Expand Up @@ -59,14 +59,14 @@ static const u8* const sTrainerSlides[DIFFICULTY_COUNT][TRAINERS_COUNT][TRAINER_
},
};

static const u8* const sFrontierTrainerSlides[DIFFICULTY_COUNT][TRAINERS_COUNT][TRAINER_SLIDE_COUNT] =
static const u8* const sFrontierTrainerSlides[DIFFICULTY_COUNT][FRONTIER_TRAINERS_COUNT][TRAINER_SLIDE_COUNT] =
{
[DIFFICULTY_NORMAL] =
{
},
};

static const u8* const sTestTrainerSlides[DIFFICULTY_COUNT][FRONTIER_TRAINERS_COUNT][TRAINER_SLIDE_COUNT] =
static const u8* const sTestTrainerSlides[DIFFICULTY_COUNT][TRAINERS_COUNT][TRAINER_SLIDE_COUNT] =
{
#include "../test/battle/trainer_slides.h"
};
Expand Down Expand Up @@ -107,24 +107,36 @@ static u32 GetEnemyMonCount(u32 firstId, u32 lastId, bool32 onlyAlive)
return count;
}

static bool32 DoesTrainerHaveSlideMessage(enum DifficultyLevel difficulty, u32 trainerId, u32 slideId)
static const u8* const *GetTrainerSlideArray(enum DifficultyLevel difficulty, u32 trainerId, u32 slideId)
{
if (gBattleTypeFlags & BATTLE_TYPE_FRONTIER)
return (sFrontierTrainerSlides[difficulty][trainerId][slideId] != NULL);
return sFrontierTrainerSlides[difficulty][trainerId];
else if (TESTING)
return (sTestTrainerSlides[difficulty][trainerId][slideId] != NULL);
return sTestTrainerSlides[difficulty][trainerId];
else
return (sTrainerSlides[difficulty][trainerId][slideId] != NULL);
return sTrainerSlides[difficulty][trainerId];
}

static bool32 DoesTrainerHaveSlideMessage(enum DifficultyLevel difficulty, u32 trainerId, u32 slideId)
{
const u8* const *trainerSlides = GetTrainerSlideArray(difficulty, trainerId, slideId);
const u8* const *trainerSlidesNormal = GetTrainerSlideArray(DIFFICULTY_NORMAL, trainerId, slideId);

if (trainerSlides[slideId] == NULL)
return (trainerSlidesNormal[slideId] != NULL);
else
return TRUE;
}

void SetTrainerSlideMessage(enum DifficultyLevel difficulty, u32 trainerId, u32 slideId)
{
if (gBattleTypeFlags & BATTLE_TYPE_FRONTIER)
gBattleStruct->trainerSlideMsg = sFrontierTrainerSlides[difficulty][trainerId][slideId];
else if (TESTING)
gBattleStruct->trainerSlideMsg = sTestTrainerSlides[difficulty][trainerId][slideId];
const u8* const *trainerSlides = GetTrainerSlideArray(difficulty, trainerId, slideId);
const u8* const *trainerSlidesNormal = GetTrainerSlideArray(DIFFICULTY_NORMAL, trainerId, slideId);

if (trainerSlides[slideId] != NULL)
gBattleStruct->trainerSlideMsg = trainerSlides[slideId];
else
gBattleStruct->trainerSlideMsg = sTrainerSlides[difficulty][trainerId][slideId];
gBattleStruct->trainerSlideMsg = trainerSlidesNormal[slideId];
}

static bool32 ShouldRunTrainerSlidePlayerLandsFirstCriticalHit(enum TrainerSlideType slideId)
Expand Down Expand Up @@ -232,7 +244,7 @@ enum TrainerSlideTargets ShouldDoTrainerSlide(u32 battler, enum TrainerSlideType
return TRAINER_SLIDE_TARGET_NONE;

SetTrainerSlideParamters(battler, &firstId, &lastId, &trainerId, &retValue);
enum DifficultyLevel difficulty = GetTrainerDifficultyLevel(trainerId);
enum DifficultyLevel difficulty = GetCurrentDifficultyLevel();

gBattleScripting.battler = battler;

Expand Down

0 comments on commit b130a38

Please sign in to comment.