From 66a3c13f49f629fe7c971ec671af3f4a73f16438 Mon Sep 17 00:00:00 2001 From: DizzyEggg Date: Sat, 21 Jul 2018 12:56:07 +0200 Subject: [PATCH] Add new Side turn effects --- charmap.txt | 1 + data/battle_scripts_1.s | 15 ++++++ include/battle.h | 2 + include/battle_message.h | 1 + include/battle_scripts.h | 3 ++ include/constants/battle.h | 1 + include/constants/battle_string_ids.h | 5 +- src/battle_debug.c | 41 ++++++++++++++- src/battle_message.c | 17 ++++-- src/battle_util.c | 75 +++++++++++++++++++++++++++ 10 files changed, 154 insertions(+), 7 deletions(-) diff --git a/charmap.txt b/charmap.txt index 02a965106..523545c70 100644 --- a/charmap.txt +++ b/charmap.txt @@ -396,6 +396,7 @@ B_PARTNER_NAME = FD 33 B_BUFF3 = FD 34 B_ATK_TRAINER_NAME = FD 35 B_ATK_TRAINER_CLASS = FD 36 +B_ATK_TEAM = FD 37 @ indicates the end of a town/city name (before " TOWN" or " CITY") NAME_END = FC 00 diff --git a/data/battle_scripts_1.s b/data/battle_scripts_1.s index 96479fd34..5c0092ac1 100644 --- a/data/battle_scripts_1.s +++ b/data/battle_scripts_1.s @@ -3222,6 +3222,21 @@ BattleScript_SideStatusWoreOff:: printstring STRINGID_PKMNSXWOREOFF waitmessage 0x40 end2 + +BattleScript_AuroraVeilEnds:: + printstring STRINGID_AURORAVEILENDS + waitmessage 0x40 + end2 + +BattleScript_LuckyChantEnds:: + printstring STRINGID_LUCKYCHANTENDS + waitmessage 0x40 + end2 + +BattleScript_TailwindEnds:: + printstring STRINGID_TAILWINDENDS + waitmessage 0x40 + end2 BattleScript_SafeguardProtected:: pause 0x20 diff --git a/include/battle.h b/include/battle.h index 6f009b182..b57341908 100644 --- a/include/battle.h +++ b/include/battle.h @@ -258,6 +258,8 @@ struct SideTimer u8 auroraVeilBattlerId; u8 tailwindTimer; u8 tailwindBattlerId; + u8 luckyChantTimer; + u8 luckyChantBattlerId; }; struct FieldTimer diff --git a/include/battle_message.h b/include/battle_message.h index 2332f8919..5efb76267 100644 --- a/include/battle_message.h +++ b/include/battle_message.h @@ -59,6 +59,7 @@ #define B_TXT_BUFF3 0x34 #define B_TXT_ATK_TRAINER_NAME 0x35 #define B_TXT_ATK_TRAINER_CLASS 0x36 +#define B_TXT_ATK_TEAM 0x37 // for B_TXT_BUFF1, B_TXT_BUFF2 and B_TXT_BUFF3 diff --git a/include/battle_scripts.h b/include/battle_scripts.h index febe81623..0fdee16fe 100644 --- a/include/battle_scripts.h +++ b/include/battle_scripts.h @@ -291,5 +291,8 @@ extern const u8 BattleScript_MagnetRiseEndTurn[]; extern const u8 BattleScript_TelekinesisEndTurn[]; extern const u8 BattleScript_HealBlockEndTurn[]; extern const u8 BattleScript_AquaRingHeal[]; +extern const u8 BattleScript_AuroraVeilEnds[]; +extern const u8 BattleScript_LuckyChantEnds[]; +extern const u8 BattleScript_TailwindEnds[]; #endif // GUARD_BATTLE_SCRIPTS_H diff --git a/include/constants/battle.h b/include/constants/battle.h index 045fa2ecc..546ce4dba 100644 --- a/include/constants/battle.h +++ b/include/constants/battle.h @@ -197,6 +197,7 @@ #define SIDE_STATUS_SPIKES_DAMAGED (1 << 9) #define SIDE_STATUS_TAILWIND (1 << 10) #define SIDE_STATUS_AURORA_VEIL (1 << 11) +#define SIDE_STATUS_LUCKY_CHANT (1 << 12) // Field affecting statuses. #define STATUS_FIELD_MAGIC_ROOM 0x1 diff --git a/include/constants/battle_string_ids.h b/include/constants/battle_string_ids.h index 9cd3cf400..e14e18dae 100644 --- a/include/constants/battle_string_ids.h +++ b/include/constants/battle_string_ids.h @@ -1,8 +1,6 @@ #ifndef GUARD_CONSTANTS_BATTLE_STRING_IDS_H #define GUARD_CONSTANTS_BATTLE_STRING_IDS_H -#define BATTLESTRINGS_COUNT 433 - #define BATTLESTRINGS_ID_ADDER 12 // all battlestrings have its ID + 12, because first 5 are reserved #define STRINGID_INTROMSG 0 @@ -447,5 +445,8 @@ #define STRINGID_WATERSPORTENDS 442 #define STRINGID_GRAVITYENDS 443 #define STRINGID_AQUARINGHEAL 444 +#define STRINGID_AURORAVEILENDS 445 + +#define BATTLESTRINGS_COUNT 434 #endif // GUARD_CONSTANTS_BATTLE_STRING_IDS_H diff --git a/src/battle_debug.c b/src/battle_debug.c index 0863b36b5..3f19e6df5 100644 --- a/src/battle_debug.c +++ b/src/battle_debug.c @@ -111,7 +111,10 @@ enum LIST_SIDE_LIGHTSCREEN, LIST_SIDE_SPIKES, LIST_SIDE_SAFEGUARD, - LIST_SIDE_MIST + LIST_SIDE_MIST, + LIST_SIDE_AURORA_VEIL, + LIST_SIDE_LUCKY_CHANT, + LIST_SIDE_TAILWIND }; // const rom data @@ -165,6 +168,9 @@ static const u8 sText_SmackDown[] = _("Smacked Down"); static const u8 sText_Unburden[] = _("Unburden"); static const u8 sText_MiracleEye[] = _("Miracle Eye"); static const u8 sText_AquaRing[] = _("Aqua Ring"); +static const u8 sText_AuroraVeil[] = _("Aurora Veil"); +static const u8 sText_LuckyChant[] = _("Lucky Chant"); +static const u8 sText_Tailwind[] = _("Tailwind"); static const u8 sText_EmptyString[] = _(""); @@ -311,6 +317,9 @@ static const struct ListMenuItem sSideStatusListItems[] = {sText_Spikes, LIST_SIDE_SPIKES}, {sText_Safeguard, LIST_SIDE_SAFEGUARD}, {sText_Mist, LIST_SIDE_MIST}, + {sText_AuroraVeil, LIST_SIDE_AURORA_VEIL}, + {sText_LuckyChant, LIST_SIDE_LUCKY_CHANT}, + {sText_Tailwind, LIST_SIDE_TAILWIND}, }; static const struct ListMenuItem sSecondaryListItems[] = @@ -1066,6 +1075,36 @@ static u8 *GetSideStatusValue(struct BattleDebugMenu *data, bool32 changeStatus, sideTimer->mistBattlerId = data->battlerId; } return &sideTimer->mistTimer; + case LIST_SIDE_AURORA_VEIL: + if (changeStatus) + { + if (statusTrue) + *(u16*)(data->modifyArrows.modifiedValPtr) |= SIDE_STATUS_AURORA_VEIL; + else + *(u16*)(data->modifyArrows.modifiedValPtr) &= ~(SIDE_STATUS_AURORA_VEIL); + sideTimer->auroraVeilBattlerId = data->battlerId; + } + return &sideTimer->auroraVeilTimer; + case LIST_SIDE_LUCKY_CHANT: + if (changeStatus) + { + if (statusTrue) + *(u16*)(data->modifyArrows.modifiedValPtr) |= SIDE_STATUS_LUCKY_CHANT; + else + *(u16*)(data->modifyArrows.modifiedValPtr) &= ~(SIDE_STATUS_LUCKY_CHANT); + sideTimer->luckyChantBattlerId = data->battlerId; + } + return &sideTimer->luckyChantTimer; + case LIST_SIDE_TAILWIND: + if (changeStatus) + { + if (statusTrue) + *(u16*)(data->modifyArrows.modifiedValPtr) |= SIDE_STATUS_TAILWIND; + else + *(u16*)(data->modifyArrows.modifiedValPtr) &= ~(SIDE_STATUS_TAILWIND); + sideTimer->tailwindBattlerId = data->battlerId; + } + return &sideTimer->tailwindTimer; default: return NULL; } diff --git a/src/battle_message.c b/src/battle_message.c index c1dd5bdd4..1b04d361e 100644 --- a/src/battle_message.c +++ b/src/battle_message.c @@ -573,14 +573,12 @@ static const u8 sText_FreedFromSkyDrop[] =_("{B_DEF_NAME_WITH_PREFIX} was freed\ static const u8 sText_PostponeTargetMove[] =_("{B_DEF_NAME_WITH_PREFIX}’s move\nwas postponed!"); static const u8 sText_ReflectTargetsType[] =_("{B_ATK_NAME_WITH_PREFIX}’s type\nchanged to match the {B_DEF_NAME_WITH_PREFIX}’s!"); static const u8 sText_TransferHeldItem[] =_("{B_DEF_NAME_WITH_PREFIX} recieved {B_LAST_ITEM}\nfrom {B_ATK_NAME_WITH_PREFIX}"); - -// These strings are currently placeholders, to be fixed. static const u8 sText_EmbargoEnds[] = _("{B_DEF_NAME_WITH_PREFIX}can\nuse items again!"); static const u8 sText_MagnetRiseEnds[] = _("{B_ATK_NAME_WITH_PREFIX}’s electromagnetism\nwore off!"); static const u8 sText_HealBlockEnds[] = _("{B_DEF_NAME_WITH_PREFIX}’s Heal Block\nwore off!"); static const u8 sText_TelekinesisEnds[] = _("{B_DEF_NAME_WITH_PREFIX} was freed\nfrom the telekinesis!"); -static const u8 sText_TailwindEnds[] = _("The tailwind petered out!"); -static const u8 sText_LuckyChantEnds[] = _("Lucky Chant wore off!"); +static const u8 sText_TailwindEnds[] = _("{B_ATK_TEAM}’s tailwind\n petered out!"); +static const u8 sText_LuckyChantEnds[] = _("{B_ATK_TEAM}’s Lucky Chant\n wore off!"); static const u8 sText_TrickRoomEnds[] = _("The twisted dimensions returned to\nnormal!"); static const u8 sText_WonderRoomEnds[] = _("Wonder Room wore off, and\nDefense and Sp. Def stats returned to normal!"); static const u8 sText_MagicRoomEnds[] = _("Magic Room wore off, and\nheld items’ effects returned to normal!"); @@ -589,6 +587,9 @@ static const u8 sText_WaterSportEnds[] = _("The effects of Water Sport have fade static const u8 sText_GravityEnds[] = _("Gravity returned to normal!"); static const u8 sText_AquaRingHeal[] = _("Aqua Ring restored\n{B_ATK_NAME_WITH_PREFIX}’s HP!"); +// These strings are currently placeholders, to be fixed. +static const u8 sText_AuroraVeilEnds[] = _(""); + const u8 *const gBattleStringsTable[BATTLESTRINGS_COUNT] = { sText_Trainer1LoseText, // 12 @@ -1455,6 +1456,8 @@ const u8 gText_RecordBattleToPass[] = _("Would you like to record your battle\no const u8 gText_BattleRecordedOnPass[] = _("{B_PLAYER_NAME}’s battle result was recorded\non the FRONTIER PASS."); static const u8 sText_LinkTrainerWantsToBattlePause[] = _("{B_20}\nwants to battle!{PAUSE 49}"); static const u8 sText_TwoLinkTrainersWantToBattlePause[] = _("{B_20} and {B_21}\nwant to battle!{PAUSE 49}"); +static const u8 sText_YourTeam[] = _("Your team"); +static const u8 sText_OpposingTeam[] = _("The opposing team"); // This is four lists of moves which use a different attack string in Japanese // to the default. See the documentation for ChooseTypeOfMoveUsedString for more detail. @@ -2891,6 +2894,12 @@ u32 BattleStringExpandPlaceholders(const u8 *src, u8 *dst) break; } break; + case B_TXT_ATK_TEAM: + if (GetBattlerSide(gBattlerAttacker) == B_SIDE_PLAYER) + toCpy = sText_YourTeam; + else + toCpy = sText_OpposingTeam; + break; } if (toCpy != NULL) diff --git a/src/battle_util.c b/src/battle_util.c index 8a67faf1a..fc426d94e 100644 --- a/src/battle_util.c +++ b/src/battle_util.c @@ -748,8 +748,11 @@ enum ENDTURN_ORDER, ENDTURN_REFLECT, ENDTURN_LIGHT_SCREEN, + ENDTURN_AURORA_VEIL, ENDTURN_MIST, + ENDTURN_LUCKY_CHANT, ENDTURN_SAFEGUARD, + ENDTURN_TAILWIND, ENDTURN_WISH, ENDTURN_RAIN, ENDTURN_SANDSTORM, @@ -845,6 +848,30 @@ u8 DoFieldEndTurnEffects(void) gBattleStruct->turnEffectsSide = 0; } break; + case ENDTURN_AURORA_VEIL: + while (gBattleStruct->turnEffectsSide < 2) + { + side = gBattleStruct->turnEffectsSide; + gActiveBattler = gBattlerAttacker = gSideTimers[side].auroraVeilBattlerId; + if (gSideStatuses[side] & SIDE_STATUS_AURORA_VEIL) + { + if (--gSideTimers[side].auroraVeilTimer == 0) + { + gSideStatuses[side] &= ~SIDE_STATUS_AURORA_VEIL; + BattleScriptExecute(BattleScript_AuroraVeilEnds); + effect++; + } + } + gBattleStruct->turnEffectsSide++; + if (effect) + break; + } + if (!effect) + { + gBattleStruct->turnCountersTracker++; + gBattleStruct->turnEffectsSide = 0; + } + break; case ENDTURN_MIST: while (gBattleStruct->turnEffectsSide < 2) { @@ -893,6 +920,54 @@ u8 DoFieldEndTurnEffects(void) gBattleStruct->turnEffectsSide = 0; } break; + case ENDTURN_LUCKY_CHANT: + while (gBattleStruct->turnEffectsSide < 2) + { + side = gBattleStruct->turnEffectsSide; + gActiveBattler = gBattlerAttacker = gSideTimers[side].luckyChantBattlerId; + if (gSideStatuses[side] & SIDE_STATUS_LUCKY_CHANT) + { + if (--gSideTimers[side].luckyChantTimer == 0) + { + gSideStatuses[side] &= ~SIDE_STATUS_LUCKY_CHANT; + BattleScriptExecute(BattleScript_LuckyChantEnds); + effect++; + } + } + gBattleStruct->turnEffectsSide++; + if (effect) + break; + } + if (!effect) + { + gBattleStruct->turnCountersTracker++; + gBattleStruct->turnEffectsSide = 0; + } + break; + case ENDTURN_TAILWIND: + while (gBattleStruct->turnEffectsSide < 2) + { + side = gBattleStruct->turnEffectsSide; + gActiveBattler = gBattlerAttacker = gSideTimers[side].tailwindBattlerId; + if (gSideStatuses[side] & SIDE_STATUS_TAILWIND) + { + if (--gSideTimers[side].tailwindTimer == 0) + { + gSideStatuses[side] &= ~SIDE_STATUS_TAILWIND; + BattleScriptExecute(BattleScript_TailwindEnds); + effect++; + } + } + gBattleStruct->turnEffectsSide++; + if (effect) + break; + } + if (!effect) + { + gBattleStruct->turnCountersTracker++; + gBattleStruct->turnEffectsSide = 0; + } + break; case ENDTURN_WISH: while (gBattleStruct->turnEffectsSide < gBattlersCount) {