Skip to content

Commit

Permalink
Ability refactor (#3861)
Browse files Browse the repository at this point in the history
* Ability refactor

* Adds abilities to RHH rom header

---------

Co-authored-by: Martin Griffin <martinrgriffin@gmail.com>
  • Loading branch information
Bassoonian and mrgriffin authored Dec 29, 2023
1 parent 16a3954 commit 6bc0bf9
Show file tree
Hide file tree
Showing 15 changed files with 2,105 additions and 1,278 deletions.
2 changes: 0 additions & 2 deletions include/battle_main.h
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,6 @@ extern const struct OamData gOamData_BattleSpriteOpponentSide;
extern const struct OamData gOamData_BattleSpritePlayerSide;
extern const u8 gTypeNames[NUMBER_OF_MON_TYPES][TYPE_NAME_LENGTH + 1];
extern const struct TrainerMoney gTrainerMoneyTable[];
extern const u8 gAbilityNames[][ABILITY_NAME_LENGTH + 1];
extern const u8 *const gAbilityDescriptionPointers[];

extern const u8 gStatusConditionString_PoisonJpn[8];
extern const u8 gStatusConditionString_SleepJpn[8];
Expand Down
7 changes: 7 additions & 0 deletions include/pokemon.h
Original file line number Diff line number Diff line change
Expand Up @@ -509,6 +509,12 @@ struct BattleMove
u16 argument;
};

struct Ability
{
u8 name[ABILITY_NAME_LENGTH + 1];
const u8 *description;
};

#define SPINDA_SPOT_WIDTH 16
#define SPINDA_SPOT_HEIGHT 16

Expand Down Expand Up @@ -577,6 +583,7 @@ extern const u16 gUnionRoomFacilityClasses[];
extern const struct SpriteTemplate gBattlerSpriteTemplates[];
extern const s8 gNatureStatTable[][5];
extern const u32 sExpCandyExperienceTable[];
extern const struct Ability gAbilities[];

void ZeroBoxMonData(struct BoxPokemon *boxMon);
void ZeroMonData(struct Pokemon *mon);
Expand Down
6 changes: 3 additions & 3 deletions src/battle_debug.c
Original file line number Diff line number Diff line change
Expand Up @@ -864,7 +864,7 @@ static void PutAiInfoText(struct BattleDebugMenu *data)
u16 holdEffect = AI_DATA->holdEffects[i];
u16 item = AI_DATA->items[i];
u8 x = (i == B_POSITION_PLAYER_LEFT) ? 83 + (i) * 75 : 83 + (i-1) * 75;
AddTextPrinterParameterized(data->aiMovesWindowId, FONT_SMALL, gAbilityNames[ability], x, 0, 0, NULL);
AddTextPrinterParameterized(data->aiMovesWindowId, FONT_SMALL, gAbilities[ability].name, x, 0, 0, NULL);
AddTextPrinterParameterized(data->aiMovesWindowId, FONT_SMALL, ItemId_GetName(item), x, 15, 0, NULL);
AddTextPrinterParameterized(data->aiMovesWindowId, FONT_SMALL, GetHoldEffectName(holdEffect), x, 30, 0, NULL);
}
Expand Down Expand Up @@ -897,7 +897,7 @@ static void PutAiPartyText(struct BattleDebugMenu *data)
AddTextPrinterParameterized5(data->aiMovesWindowId, FONT_SMALL_NARROW, text, i * 41, 0, 0, NULL, 0, 0);
}

txtPtr = StringCopyN(text, gAbilityNames[aiMons[i].ability], 7); // The screen is too small to fit the whole string, so we need to drop the last letters.
txtPtr = StringCopyN(text, gAbilities[aiMons[i].ability].name, 7); // The screen is too small to fit the whole string, so we need to drop the last letters.
*txtPtr = EOS;
AddTextPrinterParameterized5(data->aiMovesWindowId, FONT_SMALL_NARROW, text, i * 41, 15, 0, NULL, 0, 0);

Expand Down Expand Up @@ -1433,7 +1433,7 @@ static void PrintSecondaryEntries(struct BattleDebugMenu *data)
}
break;
case LIST_ITEM_ABILITY:
PadString(gAbilityNames[gBattleMons[data->battlerId].ability], text);
PadString(gAbilities[gBattleMons[data->battlerId].ability].name, text);
printer.currentY = printer.y = sSecondaryListTemplate.upText_Y;
AddTextPrinter(&printer, 0, NULL);
break;
Expand Down
2 changes: 1 addition & 1 deletion src/battle_interface.c
Original file line number Diff line number Diff line change
Expand Up @@ -3113,7 +3113,7 @@ static void PrintBattlerOnAbilityPopUp(u8 battlerId, u8 spriteId1, u8 spriteId2)

static void PrintAbilityOnAbilityPopUp(u32 ability, u8 spriteId1, u8 spriteId2)
{
PrintOnAbilityPopUp(gAbilityNames[ability],
PrintOnAbilityPopUp(gAbilities[ability].name,
(void*)(OBJ_VRAM0) + (gSprites[spriteId1].oam.tileNum * 32) + 256,
(void*)(OBJ_VRAM0) + (gSprites[spriteId2].oam.tileNum * 32) + 256,
5, 12,
Expand Down
2 changes: 0 additions & 2 deletions src/battle_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -409,8 +409,6 @@ static const u16 sTrainerBallTable[TRAINER_CLASS_COUNT] =
};
#endif

#include "data/text/abilities.h"

static void (* const sTurnActionsFuncsTable[])(void) =
{
[B_ACTION_USE_MOVE] = HandleAction_UseMove,
Expand Down
12 changes: 6 additions & 6 deletions src/battle_message.c
Original file line number Diff line number Diff line change
Expand Up @@ -3407,19 +3407,19 @@ u32 BattleStringExpandPlaceholders(const u8 *src, u8 *dst)
}
break;
case B_TXT_LAST_ABILITY: // last used ability
toCpy = gAbilityNames[gLastUsedAbility];
toCpy = gAbilities[gLastUsedAbility].name;
break;
case B_TXT_ATK_ABILITY: // attacker ability
toCpy = gAbilityNames[sBattlerAbilities[gBattlerAttacker]];
toCpy = gAbilities[sBattlerAbilities[gBattlerAttacker]].name;
break;
case B_TXT_DEF_ABILITY: // target ability
toCpy = gAbilityNames[sBattlerAbilities[gBattlerTarget]];
toCpy = gAbilities[sBattlerAbilities[gBattlerTarget]].name;
break;
case B_TXT_SCR_ACTIVE_ABILITY: // scripting active ability
toCpy = gAbilityNames[sBattlerAbilities[gBattleScripting.battler]];
toCpy = gAbilities[sBattlerAbilities[gBattleScripting.battler]].name;
break;
case B_TXT_EFF_ABILITY: // effect battler ability
toCpy = gAbilityNames[sBattlerAbilities[gEffectBattler]];
toCpy = gAbilities[sBattlerAbilities[gEffectBattler]].name;
break;
case B_TXT_TRAINER1_CLASS: // trainer class name
toCpy = BattleStringGetOpponentClassByTrainerId(gTrainerBattleOpponent_A);
Expand Down Expand Up @@ -3781,7 +3781,7 @@ void ExpandBattleTextBuffPlaceholders(const u8 *src, u8 *dst)
srcID += 2;
break;
case B_BUFF_ABILITY: // ability names
StringAppend(dst, gAbilityNames[T1_READ_16(&src[srcID + 1])]);
StringAppend(dst, gAbilities[T1_READ_16(&src[srcID + 1])].name);
srcID += 3;
break;
case B_BUFF_ITEM: // item name
Expand Down
Loading

0 comments on commit 6bc0bf9

Please sign in to comment.