From 567a0240f35359c62a75800d7010926122e54d00 Mon Sep 17 00:00:00 2001 From: DizzyEggg Date: Mon, 23 Jul 2018 22:18:56 +0200 Subject: [PATCH] Fix crits and do Worry Seed --- asm/macros/battle_script.inc | 5 +++++ data/battle_scripts_1.s | 19 +++++++++++++++---- include/constants/battle_move_effects.h | 2 +- include/data/battle_moves.h | 6 +++--- src/battle_ai_script_commands.c | 1 + src/battle_message.c | 2 +- src/battle_script_commands.c | 23 ++++++++++++++++++++++- 7 files changed, 48 insertions(+), 10 deletions(-) diff --git a/asm/macros/battle_script.inc b/asm/macros/battle_script.inc index 55b681b802..83876e013a 100644 --- a/asm/macros/battle_script.inc +++ b/asm/macros/battle_script.inc @@ -1243,6 +1243,11 @@ .4byte \ptr .endm + .macro tryworryseed ptr + .byte 0xfe + .4byte \ptr + .endm + @ various command changed to more readable macros .macro cancelmultiturnmoves bank various \bank, VARIOUS_CANCEL_MULTI_TURN_MOVES diff --git a/data/battle_scripts_1.s b/data/battle_scripts_1.s index bcc85341d7..4033aad494 100644 --- a/data/battle_scripts_1.s +++ b/data/battle_scripts_1.s @@ -177,7 +177,7 @@ gBattleScriptsForMoveEffects:: @ 82D86A8 .4byte BattleScript_EffectStockpile .4byte BattleScript_EffectSpitUp .4byte BattleScript_EffectSwallow - .4byte BattleScript_EffectUnusedA3 + .4byte BattleScript_EffectWorrySeed .4byte BattleScript_EffectHail .4byte BattleScript_EffectTorment .4byte BattleScript_EffectFlatter @@ -271,6 +271,18 @@ gBattleScriptsForMoveEffects:: @ 82D86A8 .4byte BattleScript_EffectPowerSplit .4byte BattleScript_EffectGuardSplit +BattleScript_EffectWorrySeed: + attackcanceler + accuracycheck BattleScript_PrintMoveMissed, ACC_CURR_MOVE + attackstring + ppreduce + tryworryseed BattleScript_ButItFailed + attackanimation + waitanimation + printstring STRINGID_PKMNACQUIREDABILITY + waitmessage 0x40 + goto BattleScript_MoveEnd + BattleScript_EffectPowerSplit: attackcanceler attackstring @@ -357,10 +369,10 @@ BattleScript_EffectStealthRock: attackcanceler attackstring ppreduce - setstealthrock STRINGID_POINTEDSTONESFLOAT + setstealthrock BattleScript_ButItFailed attackanimation waitanimation - printstring STRINGID_POISONSPIKESSCATTERED + printstring STRINGID_POINTEDSTONESFLOAT waitmessage 0x40 goto BattleScript_MoveEnd @@ -492,7 +504,6 @@ BattleScript_EffectAlwaysCrit: BattleScript_EffectUnused6e: BattleScript_EffectPursuit: BattleScript_EffectUnused8d: -BattleScript_EffectUnusedA3: BattleScript_EffectPlaceholder200: BattleScript_EffectPlaceholder209: BattleScript_EffectHit:: diff --git a/include/constants/battle_move_effects.h b/include/constants/battle_move_effects.h index e572cf730e..cedebfe85b 100644 --- a/include/constants/battle_move_effects.h +++ b/include/constants/battle_move_effects.h @@ -164,7 +164,7 @@ #define EFFECT_STOCKPILE 160 #define EFFECT_SPIT_UP 161 #define EFFECT_SWALLOW 162 -#define EFFECT_UNUSED_A3 163 +#define EFFECT_WORRY_SEED 163 #define EFFECT_HAIL 164 #define EFFECT_TORMENT 165 #define EFFECT_FLATTER 166 diff --git a/include/data/battle_moves.h b/include/data/battle_moves.h index 88a3826293..6ec868467d 100644 --- a/include/data/battle_moves.h +++ b/include/data/battle_moves.h @@ -4660,7 +4660,7 @@ const struct BattleMove gBattleMoves[MOVES_COUNT_GEN6] = .split = SPLIT_PHYSICAL, }, { // MOVE_WORRY_SEED - .effect = EFFECT_PLACEHOLDER_209, + .effect = EFFECT_WORRY_SEED, .power = 0, .type = TYPE_GRASS, .accuracy = 100, @@ -5764,7 +5764,7 @@ const struct BattleMove gBattleMoves[MOVES_COUNT_GEN6] = .split = SPLIT_PHYSICAL, }, { // MOVE_STORM_THROW - .effect = EFFECT_PLACEHOLDER_209, + .effect = EFFECT_ALWAYS_CRIT, .power = 60, .type = TYPE_FIGHTING, .accuracy = 100, @@ -6292,7 +6292,7 @@ const struct BattleMove gBattleMoves[MOVES_COUNT_GEN6] = .split = SPLIT_PHYSICAL, }, { // MOVE_FROST_BREATH - .effect = EFFECT_PLACEHOLDER_209, + .effect = EFFECT_ALWAYS_CRIT, .power = 60, .type = TYPE_ICE, .accuracy = 90, diff --git a/src/battle_ai_script_commands.c b/src/battle_ai_script_commands.c index 9e2e3a85ba..9a7cf395b9 100644 --- a/src/battle_ai_script_commands.c +++ b/src/battle_ai_script_commands.c @@ -752,6 +752,7 @@ static bool32 AI_GetIfCrit(u32 move, u8 battlerAtk, u8 battlerDef) else isCrit = FALSE; break; + case -2: case 3: case 4: isCrit = TRUE; diff --git a/src/battle_message.c b/src/battle_message.c index 9265c21563..4a4fe36bb8 100644 --- a/src/battle_message.c +++ b/src/battle_message.c @@ -543,7 +543,7 @@ static const u8 sText_PkmnsAbilitySuppressed[] = _("{B_DEF_NAME_WITH_PREFIX}’s static const u8 sText_ShieldedFromCriticalHits[] = _("The {B_CURRENT_MOVE} shielded your\nteam from critical hits!"); static const u8 sText_SwitchedAtkAndSpAtk[] = _("{B_ATK_NAME_WITH_PREFIX} switched all its\nchanges to its Attack and\pSp. Atk with the target!"); static const u8 sText_SwitchedDefAndSpDef[] = _("{B_ATK_NAME_WITH_PREFIX} switched all its\nchanges to its Defense and\pSp. Def with the target!"); -static const u8 sText_PkmnAcquiredAbility[] = _("{B_DEF_NAME_WITH_PREFIX} acquired\n{B_LAST_ABILITY}!"); +static const u8 sText_PkmnAcquiredAbility[] = _("{B_DEF_NAME_WITH_PREFIX} acquired\n{B_DEF_ABILITY}!"); static const u8 sText_PoisonSpikesScattered[] = _("Poison Spikes were scattered\nall around the foe’s team’s\pfeet!"); static const u8 sText_PkmnSwitchedStatChanges[] = _("{B_ATK_NAME_WITH_PREFIX} switched stat changes\nwith the target!"); static const u8 sText_PkmnSurroundedWithVeilOfWater[] = _("{B_ATK_NAME_WITH_PREFIX} surrounded itself\nwith a veil of water!"); diff --git a/src/battle_script_commands.c b/src/battle_script_commands.c index 4c5f43b884..e654ddbb24 100644 --- a/src/battle_script_commands.c +++ b/src/battle_script_commands.c @@ -345,6 +345,7 @@ static void atkFA_swapstatstages(void); static void atkFB_averagestats(void); static void atkFC_jumpifoppositegenders(void); static void atkFD_trygetbaddreamstarget(void); +static void atkFE_tryworryseed(void); void (* const gBattleScriptingCommandsTable[])(void) = { @@ -602,6 +603,7 @@ void (* const gBattleScriptingCommandsTable[])(void) = atkFB_averagestats, atkFC_jumpifoppositegenders, atkFD_trygetbaddreamstarget, + atkFE_tryworryseed, }; struct StatFractions @@ -1316,7 +1318,7 @@ s32 CalcCritChanceStage(u8 battlerAtk, u8 battlerDef, u32 move, bool32 recordAbi || gBattleMoves[move].effect == EFFECT_ALWAYS_CRIT || (abilityAtk == ABILITY_MERCILESS && gBattleMons[battlerDef].status1 & STATUS1_PSN_ANY)) { - critChance = 4; + critChance = -2; } else { @@ -1350,6 +1352,8 @@ static void atk04_critcalc(void) gIsCriticalHit = FALSE; else if (critChance == -1) gIsCriticalHit = FALSE; + else if (critChance == -2) + gIsCriticalHit = TRUE; else if (Random() % sCriticalHitChanceGen3[critChance] == 0) gIsCriticalHit = TRUE; else @@ -10400,3 +10404,20 @@ static void atkFD_trygetbaddreamstarget(void) else gBattlescriptCurrInstr += 5; } + +static void atkFE_tryworryseed(void) +{ + switch (gBattleMons[gBattlerTarget].ability) + { + case ABILITY_INSOMNIA: + case ABILITY_MULTITYPE: + case ABILITY_TRUANT: + case ABILITY_STANCE_CHANGE: + gBattlescriptCurrInstr = T1_READ_PTR(gBattlescriptCurrInstr + 1); + break; + default: + gBattleMons[gBattlerTarget].ability = ABILITY_INSOMNIA; + gBattlescriptCurrInstr += 5; + break; + } +}