From cfd50eb65a3c630b8ed2c4b5141e1842ed0df266 Mon Sep 17 00:00:00 2001 From: Papa Cancer Date: Thu, 28 Feb 2019 14:02:54 +0000 Subject: [PATCH] Grassy Terrain + minor fixes MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Includes strings for all Fixes: ・Psychic Terrain blocks priority if the TARGET is grounded, not the user ・Psychic Terrain no longer targets an opponent ・Terrains no longer boost (or nerf, for Misty) the power of certain moves if the affect mon is semi-invulnerable ・Small fix: Meteor Mash corrected to being a physical attack --- asm/macros/battle_script.inc | 5 +++++ data/battle_scripts_1.s | 17 +++++++++++++++++ include/battle_scripts.h | 2 ++ include/constants/battle_script_commands.h | 1 + include/constants/battle_string_ids.h | 4 ++++ src/battle_message.c | 13 +++++++++++++ src/battle_script_commands.c | 16 ++++++++++++++++ src/battle_util.c | 17 +++++++++++------ src/data/battle_moves.h | 4 ++-- 9 files changed, 71 insertions(+), 8 deletions(-) diff --git a/asm/macros/battle_script.inc b/asm/macros/battle_script.inc index 890202a0c..b3438cd12 100644 --- a/asm/macros/battle_script.inc +++ b/asm/macros/battle_script.inc @@ -1592,6 +1592,11 @@ .macro bringdownairbornebattler battler:req various \battler, VARIOUS_GRAVITY_ON_AIRBORNE_MONS .endm + + .macro checkgrassyterrainheal battler:req, ptr:req + various \battler, VARIOUS_CHECK_IF_GRASSY_TERRAIN_HEALS + .4byte \ptr + .endm @ helpful macros .macro setstatchanger stat:req, stages:req, down:req diff --git a/data/battle_scripts_1.s b/data/battle_scripts_1.s index 087dbd4b4..971a566dc 100644 --- a/data/battle_scripts_1.s +++ b/data/battle_scripts_1.s @@ -6155,6 +6155,23 @@ BattleScript_MoveUsedPsychicTerrainPrevents:: waitmessage 0x40 goto BattleScript_MoveEnd +BattleScript_GrassyTerrainLoop:: + copyarraywithindex gBattlerAttacker, gBattlerByTurnOrder, gBattleCommunication, 0x1 + checkgrassyterrainheal BS_ATTACKER, BattleScript_GrassyTerrainLoopIncrement + printstring STRINGID_GRASSYTERRAINHEALS + waitmessage 0x40 +BattleScript_GrassyTerrainHpChange: + orword gHitMarker, HITMARKER_x20 | HITMARKER_IGNORE_SUBSTITUTE | HITMARKER_x100000 | HITMARKER_GRUDGE + healthbarupdate BS_ATTACKER + datahpupdate BS_ATTACKER +BattleScript_GrassyTerrainLoopIncrement:: + jumpifbyte CMP_NOT_EQUAL, gBattleOutcome, 0, BattleScript_GrassyTerrainLoopEnd + addbyte gBattleCommunication, 0x1 + jumpifbytenotequal gBattleCommunication, gBattlersCount, BattleScript_GrassyTerrainLoop +BattleScript_GrassyTerrainLoopEnd:: + bicword gHitMarker, HITMARKER_x20 | HITMARKER_IGNORE_SUBSTITUTE | HITMARKER_x100000 | HITMARKER_GRUDGE + end2 + BattleScript_AbilityNoSpecificStatLoss:: pause 0x20 call BattleScript_AbilityPopUp diff --git a/include/battle_scripts.h b/include/battle_scripts.h index b9378cb32..a3687ddbe 100644 --- a/include/battle_scripts.h +++ b/include/battle_scripts.h @@ -296,5 +296,7 @@ extern const u8 BattleScript_ElectricSurgeActivates[]; extern const u8 BattleScript_SpectralThiefSteal[]; extern const u8 BattleScript_StatUpMsg[]; extern const u8 BattleScript_DefiantActivates[]; +extern const u8 BattleScript_PowderMoveNoEffect[]; +extern const u8 BattleScript_GrassyTerrainLoop[]; #endif // GUARD_BATTLE_SCRIPTS_H diff --git a/include/constants/battle_script_commands.h b/include/constants/battle_script_commands.h index ac815da69..23fbf75b3 100644 --- a/include/constants/battle_script_commands.h +++ b/include/constants/battle_script_commands.h @@ -137,6 +137,7 @@ #define VARIOUS_SET_POWDER 74 #define VARIOUS_SPECTRAL_THIEF 75 #define VARIOUS_GRAVITY_ON_AIRBORNE_MONS 76 +#define VARIOUS_CHECK_IF_GRASSY_TERRAIN_HEALS 77 // atk80, dmg manipulation #define ATK80_DMG_CHANGE_SIGN 0 diff --git a/include/constants/battle_string_ids.h b/include/constants/battle_string_ids.h index 745fc5469..48737382b 100644 --- a/include/constants/battle_string_ids.h +++ b/include/constants/battle_string_ids.h @@ -519,6 +519,10 @@ #define STRINGID_BELCHCANTSELECT 515 #define STRINGID_SPECTRALTHIEFSTEAL 516 #define STRINGID_GRAVITYGROUNDING 517 +#define STRINGID_MISTYTERRAINPREVENTS 518 +#define STRINGID_GRASSYTERRAINHEALS 519 +#define STRINGID_ELECTRICTERRAINPREVENTS 520 +#define STRINGID_PSYCHICTERRAINPREVENTS 521 #define BATTLESTRINGS_COUNT 529 diff --git a/src/battle_message.c b/src/battle_message.c index 7034931f0..a6d52fd51 100644 --- a/src/battle_message.c +++ b/src/battle_message.c @@ -644,6 +644,10 @@ static const u8 sText_PowderExplodes[] = _("When the flame touched the powder\no static const u8 sText_BelchCantUse[] = _("Belch cannot be used!\p"); static const u8 sText_SpectralThiefSteal[] = _("{B_ATK_NAME_WITH_PREFIX} stole the target's\nboosted stats!"); static const u8 sText_GravityGrounding[] = _("{B_DEF_NAME_WITH_PREFIX} can't stay airborne\nbecause of gravity!"); +static const u8 sText_MistyTerrainPreventsStatus[] = _("{B_DEF_NAME_WITH_PREFIX} surrounds itself\nwith a protective mist!"); +static const u8 sText_GrassyTerrainHeals[] = _("{B_ATK_NAME_WITH_PREFIX} is healed\nby the grassy terrain!"); +static const u8 sText_ElectricTerrainPreventsSleep[] = _("{B_DEF_NAME_WITH_PREFIX} surrounds itself\nwith electrified terrain!"); +static const u8 sText_PsychicTerrainPreventsPriority[] = _("{B_DEF_NAME_WITH_PREFIX} surrounds itself\nwith psychic terrain!"); const u8 *const gBattleStringsTable[BATTLESTRINGS_COUNT] = { @@ -1153,6 +1157,10 @@ const u8 *const gBattleStringsTable[BATTLESTRINGS_COUNT] = [STRINGID_COVEREDINPOWDER - 12] = sText_CoveredInPowder, [STRINGID_POWDEREXPLODES - 12] = sText_PowderExplodes, [STRINGID_GRAVITYGROUNDING - 12] = sText_GravityGrounding, + [STRINGID_MISTYTERRAINPREVENTS - 12] = sText_MistyTerrainPreventsStatus, + [STRINGID_GRASSYTERRAINHEALS - 12] = sText_GrassyTerrainHeals, + [STRINGID_ELECTRICTERRAINPREVENTS - 12] = sText_ElectricTerrainPreventsSleep, + [STRINGID_PSYCHICTERRAINPREVENTS - 12] = sText_PsychicTerrainPreventsPriority, }; const u16 gTerrainStringIds[] = @@ -1160,6 +1168,11 @@ const u16 gTerrainStringIds[] = STRINGID_TERRAINBECOMESMISTY, STRINGID_TERRAINBECOMESGRASSY, STRINGID_TERRAINBECOMESELECTRIC, STRINGID_TERRAINBECOMESPSYCHIC }; +const u16 gTerrainPreventsStringIds[] = +{ + STRINGID_MISTYTERRAINPREVENTS, STRINGID_ELECTRICTERRAINPREVENTS, STRINGID_PSYCHICTERRAINPREVENTS +}; + const u16 gMagicCoatBounceStringIds[] = { STRINGID_PKMNMOVEBOUNCED, STRINGID_PKMNMOVEBOUNCEDABILITY diff --git a/src/battle_script_commands.c b/src/battle_script_commands.c index 61d60c046..ceaa5ece3 100644 --- a/src/battle_script_commands.c +++ b/src/battle_script_commands.c @@ -6368,6 +6368,22 @@ static void atk76_various(void) switch (gBattlescriptCurrInstr[2]) { + case VARIOUS_CHECK_IF_GRASSY_TERRAIN_HEALS: + if ((gStatuses3[gActiveBattler] & (STATUS3_SEMI_INVULNERABLE)) || BATTLER_MAX_HP(gActiveBattler) || !(IsBattlerGrounded(gActiveBattler))) + { + gBattlescriptCurrInstr = T1_READ_PTR(gBattlescriptCurrInstr + 3); + return; + } + gBattleMoveDamage = gBattleMons[gActiveBattler].maxHP / 16; + if (gBattleMoveDamage == 0) + gBattleMoveDamage = 1; + gBattleMoveDamage *= -1; + + if (gAbsentBattlerFlags & gBitTable[gBattlerAttacker]) + gBattleMoveDamage = 0; + + gBattlescriptCurrInstr += 7; + return; case VARIOUS_GRAVITY_ON_AIRBORNE_MONS: if (gStatuses3[gActiveBattler] & STATUS3_ON_AIR) CancelMultiTurnMoves(gActiveBattler); diff --git a/src/battle_util.c b/src/battle_util.c index c93821477..a5bee1ae1 100644 --- a/src/battle_util.c +++ b/src/battle_util.c @@ -1256,6 +1256,11 @@ u8 DoFieldEndTurnEffects(void) gBattleStruct->turnCountersTracker++; break; case ENDTURN_GRASSY_TERRAIN: + if (gFieldStatuses & STATUS_FIELD_GRASSY_TERRAIN) + { + BattleScriptExecute(BattleScript_GrassyTerrainLoop); + effect++; + } if (gFieldStatuses & STATUS_FIELD_GRASSY_TERRAIN && --gFieldTimers.grassyTerrainTimer == 0) { gFieldStatuses &= ~(STATUS_FIELD_GRASSY_TERRAIN); @@ -2344,7 +2349,7 @@ u8 AtkCanceller_UnableToUseMove2(void) gBattleStruct->atkCancellerTracker++; case CANCELLER_PSYCHIC_TERRAIN: if (gFieldStatuses & STATUS_FIELD_PSYCHIC_TERRAIN - && IsBattlerGrounded(gBattlerAttacker) + && IsBattlerGrounded(gBattlerTarget) && GetChosenMovePriority(gBattlerAttacker) > 0 && GetBattlerSide(gBattlerAttacker) != GetBattlerSide(gBattlerTarget)) { @@ -5159,7 +5164,7 @@ static u32 CalcMoveBasePowerAfterModifiers(u16 move, u8 battlerAtk, u8 battlerDe case EFFECT_BULLDOZE: case EFFECT_MAGNITUDE: case EFFECT_EARTHQUAKE: - if (gFieldStatuses & STATUS_FIELD_GRASSY_TERRAIN && IsBattlerGrounded(battlerDef)) + if (gFieldStatuses & STATUS_FIELD_GRASSY_TERRAIN && !(gStatuses3[battlerDef] & STATUS3_SEMI_INVULNERABLE)) MulModifier(&modifier, UQ_4_12(0.5)); break; case EFFECT_KNOCK_OFF: @@ -5175,13 +5180,13 @@ static u32 CalcMoveBasePowerAfterModifiers(u16 move, u8 battlerAtk, u8 battlerDe MulModifier(&modifier, UQ_4_12(2.0)); if (gStatuses3[battlerAtk] & STATUS3_ME_FIRST) MulModifier(&modifier, UQ_4_12(1.5)); - if (gFieldStatuses & STATUS_FIELD_GRASSY_TERRAIN && moveType == TYPE_GRASS && IsBattlerGrounded(battlerAtk)) + if (gFieldStatuses & STATUS_FIELD_GRASSY_TERRAIN && moveType == TYPE_GRASS && IsBattlerGrounded(battlerAtk) && !(gStatuses3[battlerAtk] & STATUS3_SEMI_INVULNERABLE)) MulModifier(&modifier, UQ_4_12(1.5)); - if (gFieldStatuses & STATUS_FIELD_MISTY_TERRAIN && moveType == TYPE_DRAGON && IsBattlerGrounded(battlerDef)) + if (gFieldStatuses & STATUS_FIELD_MISTY_TERRAIN && moveType == TYPE_DRAGON && IsBattlerGrounded(battlerDef) && !(gStatuses3[battlerDef] & STATUS3_SEMI_INVULNERABLE) MulModifier(&modifier, UQ_4_12(0.5)); - if (gFieldStatuses & STATUS_FIELD_ELECTRIC_TERRAIN && moveType == TYPE_ELECTRIC && IsBattlerGrounded(battlerAtk)) + if (gFieldStatuses & STATUS_FIELD_ELECTRIC_TERRAIN && moveType == TYPE_ELECTRIC && IsBattlerGrounded(battlerAtk) && !(gStatuses3[battlerAtk] & STATUS3_SEMI_INVULNERABLE)) MulModifier(&modifier, UQ_4_12(1.5)); - if (gFieldStatuses & STATUS_FIELD_PSYCHIC_TERRAIN && moveType == TYPE_PSYCHIC && IsBattlerGrounded(battlerAtk)) + if (gFieldStatuses & STATUS_FIELD_PSYCHIC_TERRAIN && moveType == TYPE_PSYCHIC && IsBattlerGrounded(battlerAtk) && !(gStatuses3[battlerAtk] & STATUS3_SEMI_INVULNERABLE)) MulModifier(&modifier, UQ_4_12(1.5)); return ApplyModifier(modifier, basePower); diff --git a/src/data/battle_moves.h b/src/data/battle_moves.h index ed39e27f5..6e21f4347 100644 --- a/src/data/battle_moves.h +++ b/src/data/battle_moves.h @@ -4339,7 +4339,7 @@ const struct BattleMove gBattleMoves[MOVES_COUNT] = .target = MOVE_TARGET_SELECTED, .priority = 0, .flags = FLAG_MAKES_CONTACT | FLAG_PROTECT_AFFECTED | FLAG_MIRROR_MOVE_AFFECTED | FLAG_KINGSROCK_AFFECTED | FLAG_IRON_FIST_BOOST, - .split = SPLIT_SPECIAL, + .split = SPLIT_PHYSICAL, }, [MOVE_ASTONISH] = @@ -9003,7 +9003,7 @@ const struct BattleMove gBattleMoves[MOVES_COUNT] = .accuracy = 0, .pp = 10, .secondaryEffectChance = 0, - .target = MOVE_TARGET_SELECTED, + .target = MOVE_TARGET_USER, .priority = 0, .flags = 0, .split = SPLIT_STATUS,