Skip to content

Commit

Permalink
Added Battle Palace info to struct
Browse files Browse the repository at this point in the history
  • Loading branch information
fdeblasio committed May 13, 2024
1 parent 0577b1b commit eb261d4
Show file tree
Hide file tree
Showing 7 changed files with 96 additions and 107 deletions.
1 change: 0 additions & 1 deletion include/battle_script_commands.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ u8 GetFirstFaintedPartyIndex(u8 battlerId);
bool32 IsMoveAffectedByParentalBond(u32 move, u32 battler);

extern void (* const gBattleScriptingCommandsTable[])(void);
extern const u8 gBattlePalaceNatureToMoveGroupLikelihood[NUM_NATURES][4];
extern const struct StatFractions gAccuracyStageRatios[];

#endif // GUARD_BATTLE_SCRIPT_COMMANDS_H
5 changes: 0 additions & 5 deletions include/constants/battle_palace.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,4 @@
#define PALACE_MOVE_GROUP_DEFENSE 1
#define PALACE_MOVE_GROUP_SUPPORT 2

// In palace doubles battles Pokémon have a target preference depending on nature
#define PALACE_TARGET_STRONGER 0
#define PALACE_TARGET_WEAKER 1
#define PALACE_TARGET_RANDOM 2

#endif //GUARD_CONSTANTS_BATTLE_PALACE_H
8 changes: 8 additions & 0 deletions include/pokemon.h
Original file line number Diff line number Diff line change
Expand Up @@ -600,11 +600,19 @@ enum {
#define ANIM_CAREFUL (ANIM_SASSY + 1)
#define ANIM_QUIRKY (ANIM_CAREFUL + 5)

// In palace double battles, Pokémon have a target preference depending on nature
#define PALACE_TARGET_STRONGER 0
#define PALACE_TARGET_WEAKER 1
#define PALACE_TARGET_RANDOM 2

struct NatureInfo
{
const u8 *name;
u8 backAnim;
u8 pokeBlockAnim[2];
u8 battlePalacePercents[4];
u8 battlePalaceFlavorText;
u8 battlePalaceSmokescreen;
};

#define SPINDA_SPOT_WIDTH 16
Expand Down
31 changes: 0 additions & 31 deletions src/battle_anim_smokescreen.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,37 +15,6 @@
static void SpriteCB_SmokescreenImpactMain(struct Sprite *);
static void SpriteCB_SmokescreenImpact(struct Sprite *);

// The below data for smokescreen starts and ends with some data that belongs to battle_gfx_sfx_util.c

const u8 gBattlePalaceNatureToMoveTarget[NUM_NATURES] =
{
[NATURE_HARDY] = PALACE_TARGET_STRONGER,
[NATURE_LONELY] = PALACE_TARGET_STRONGER,
[NATURE_BRAVE] = PALACE_TARGET_WEAKER,
[NATURE_ADAMANT] = PALACE_TARGET_STRONGER,
[NATURE_NAUGHTY] = PALACE_TARGET_WEAKER,
[NATURE_BOLD] = PALACE_TARGET_WEAKER,
[NATURE_DOCILE] = PALACE_TARGET_RANDOM,
[NATURE_RELAXED] = PALACE_TARGET_STRONGER,
[NATURE_IMPISH] = PALACE_TARGET_STRONGER,
[NATURE_LAX] = PALACE_TARGET_STRONGER,
[NATURE_TIMID] = PALACE_TARGET_WEAKER,
[NATURE_HASTY] = PALACE_TARGET_WEAKER,
[NATURE_SERIOUS] = PALACE_TARGET_WEAKER,
[NATURE_JOLLY] = PALACE_TARGET_STRONGER,
[NATURE_NAIVE] = PALACE_TARGET_RANDOM,
[NATURE_MODEST] = PALACE_TARGET_WEAKER,
[NATURE_MILD] = PALACE_TARGET_STRONGER,
[NATURE_QUIET] = PALACE_TARGET_WEAKER,
[NATURE_BASHFUL] = PALACE_TARGET_WEAKER,
[NATURE_RASH] = PALACE_TARGET_STRONGER,
[NATURE_CALM] = PALACE_TARGET_STRONGER,
[NATURE_GENTLE] = PALACE_TARGET_STRONGER,
[NATURE_SASSY] = PALACE_TARGET_WEAKER,
[NATURE_CAREFUL] = PALACE_TARGET_WEAKER,
[NATURE_QUIRKY] = PALACE_TARGET_STRONGER,
};

static const struct CompressedSpriteSheet sSmokescreenImpactSpriteSheet =
{
.data = gSmokescreenImpactTiles, .size = 0x180, .tag = TAG_SMOKESCREEN
Expand Down
5 changes: 2 additions & 3 deletions src/battle_gfx_sfx_util.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
#include "constants/battle_move_effects.h"


extern const u8 gBattlePalaceNatureToMoveTarget[];
extern const struct CompressedSpriteSheet gSpriteSheet_EnemyShadow;
extern const struct SpriteTemplate gSpriteTemplate_EnemyShadow;

Expand Down Expand Up @@ -138,7 +137,7 @@ u16 ChooseMoveAndTargetInBattlePalace(u32 battler)
// Otherwise use move from "Support" group
for (; i < maxGroupNum; i++)
{
if (gBattlePalaceNatureToMoveGroupLikelihood[GetNatureFromPersonality(gBattleMons[battler].personality)][i] > percent)
if (gNaturesInfo[GetNatureFromPersonality(gBattleMons[battler].personality)].battlePalacePercents[i] > percent)
break;
}
selectedGroup = i - minGroupNum;
Expand Down Expand Up @@ -328,7 +327,7 @@ static u16 GetBattlePalaceTarget(u32 battler)
if (gBattleMons[opposing1].hp == gBattleMons[opposing2].hp)
return (BATTLE_OPPOSITE(battler & BIT_SIDE) + (Random() & 2)) << 8;

switch (gBattlePalaceNatureToMoveTarget[GetNatureFromPersonality(gBattleMons[battler].personality)])
switch (gNaturesInfo[GetNatureFromPersonality(gBattleMons[battler].personality)].battlePalaceSmokescreen)
{
case PALACE_TARGET_STRONGER:
if (gBattleMons[opposing1].hp > gBattleMons[opposing2].hp)
Expand Down
68 changes: 1 addition & 67 deletions src/battle_script_commands.c
Original file line number Diff line number Diff line change
Expand Up @@ -1098,72 +1098,6 @@ static const u8 sTerrainToType[BATTLE_TERRAIN_COUNT] =
[BATTLE_TERRAIN_PLAIN] = (B_CAMOUFLAGE_TYPES >= GEN_4 ? TYPE_GROUND : TYPE_NORMAL),
};

// In Battle Palace, moves are chosen based on the pokemons nature rather than by the player
// Moves are grouped into "Attack", "Defense", or "Support" (see PALACE_MOVE_GROUP_*)
// Each nature has a certain percent chance of selecting a move from a particular group
// and a separate percent chance for each group when at or below 50% HP
// The table below doesn't list percentages for Support because you can subtract the other two
// Support percentages are listed in comments off to the side instead
#define PALACE_STYLE(atk, def, atkLow, defLow) {atk, atk + def, atkLow, atkLow + defLow}

const ALIGNED(4) u8 gBattlePalaceNatureToMoveGroupLikelihood[NUM_NATURES][4] =
{
[NATURE_HARDY] = PALACE_STYLE(61, 7, 61, 7), // 32% support >= 50% HP, 32% support < 50% HP
[NATURE_LONELY] = PALACE_STYLE(20, 25, 84, 8), // 55%, 8%
[NATURE_BRAVE] = PALACE_STYLE(70, 15, 32, 60), // 15%, 8%
[NATURE_ADAMANT] = PALACE_STYLE(38, 31, 70, 15), // 31%, 15%
[NATURE_NAUGHTY] = PALACE_STYLE(20, 70, 70, 22), // 10%, 8%
[NATURE_BOLD] = PALACE_STYLE(30, 20, 32, 58), // 50%, 10%
[NATURE_DOCILE] = PALACE_STYLE(56, 22, 56, 22), // 22%, 22%
[NATURE_RELAXED] = PALACE_STYLE(25, 15, 75, 15), // 60%, 10%
[NATURE_IMPISH] = PALACE_STYLE(69, 6, 28, 55), // 25%, 17%
[NATURE_LAX] = PALACE_STYLE(35, 10, 29, 6), // 55%, 65%
[NATURE_TIMID] = PALACE_STYLE(62, 10, 30, 20), // 28%, 50%
[NATURE_HASTY] = PALACE_STYLE(58, 37, 88, 6), // 5%, 6%
[NATURE_SERIOUS] = PALACE_STYLE(34, 11, 29, 11), // 55%, 60%
[NATURE_JOLLY] = PALACE_STYLE(35, 5, 35, 60), // 60%, 5%
[NATURE_NAIVE] = PALACE_STYLE(56, 22, 56, 22), // 22%, 22%
[NATURE_MODEST] = PALACE_STYLE(35, 45, 34, 60), // 20%, 6%
[NATURE_MILD] = PALACE_STYLE(44, 50, 34, 6), // 6%, 60%
[NATURE_QUIET] = PALACE_STYLE(56, 22, 56, 22), // 22%, 22%
[NATURE_BASHFUL] = PALACE_STYLE(30, 58, 30, 58), // 12%, 12%
[NATURE_RASH] = PALACE_STYLE(30, 13, 27, 6), // 57%, 67%
[NATURE_CALM] = PALACE_STYLE(40, 50, 25, 62), // 10%, 13%
[NATURE_GENTLE] = PALACE_STYLE(18, 70, 90, 5), // 12%, 5%
[NATURE_SASSY] = PALACE_STYLE(88, 6, 22, 20), // 6%, 58%
[NATURE_CAREFUL] = PALACE_STYLE(42, 50, 42, 5), // 8%, 53%
[NATURE_QUIRKY] = PALACE_STYLE(56, 22, 56, 22) // 22%, 22%
};

static const u8 sBattlePalaceNatureToFlavorTextId[NUM_NATURES] =
{
[NATURE_HARDY] = B_MSG_EAGER_FOR_MORE,
[NATURE_LONELY] = B_MSG_GLINT_IN_EYE,
[NATURE_BRAVE] = B_MSG_GETTING_IN_POS,
[NATURE_ADAMANT] = B_MSG_GLINT_IN_EYE,
[NATURE_NAUGHTY] = B_MSG_GLINT_IN_EYE,
[NATURE_BOLD] = B_MSG_GETTING_IN_POS,
[NATURE_DOCILE] = B_MSG_EAGER_FOR_MORE,
[NATURE_RELAXED] = B_MSG_GLINT_IN_EYE,
[NATURE_IMPISH] = B_MSG_GETTING_IN_POS,
[NATURE_LAX] = B_MSG_GROWL_DEEPLY,
[NATURE_TIMID] = B_MSG_GROWL_DEEPLY,
[NATURE_HASTY] = B_MSG_GLINT_IN_EYE,
[NATURE_SERIOUS] = B_MSG_EAGER_FOR_MORE,
[NATURE_JOLLY] = B_MSG_GETTING_IN_POS,
[NATURE_NAIVE] = B_MSG_EAGER_FOR_MORE,
[NATURE_MODEST] = B_MSG_GETTING_IN_POS,
[NATURE_MILD] = B_MSG_GROWL_DEEPLY,
[NATURE_QUIET] = B_MSG_EAGER_FOR_MORE,
[NATURE_BASHFUL] = B_MSG_EAGER_FOR_MORE,
[NATURE_RASH] = B_MSG_GROWL_DEEPLY,
[NATURE_CALM] = B_MSG_GETTING_IN_POS,
[NATURE_GENTLE] = B_MSG_GLINT_IN_EYE,
[NATURE_SASSY] = B_MSG_GROWL_DEEPLY,
[NATURE_CAREFUL] = B_MSG_GROWL_DEEPLY,
[NATURE_QUIRKY] = B_MSG_EAGER_FOR_MORE,
};

static bool32 NoTargetPresent(u8 battler, u32 move)
{
if (!IsBattlerAlive(gBattlerTarget))
Expand Down Expand Up @@ -9196,7 +9130,7 @@ static void Cmd_various(void)
{
gBattleStruct->palaceFlags |= gBitTable[battler];
gBattleCommunication[0] = TRUE;
gBattleCommunication[MULTISTRING_CHOOSER] = sBattlePalaceNatureToFlavorTextId[GetNatureFromPersonality(gBattleMons[battler].personality)];
gBattleCommunication[MULTISTRING_CHOOSER] = gNaturesInfo[GetNatureFromPersonality(gBattleMons[battler].personality)].battlePalaceFlavorText;
}
break;
}
Expand Down
Loading

0 comments on commit eb261d4

Please sign in to comment.