diff --git a/data/battle_scripts_1.s b/data/battle_scripts_1.s index 7e34704c90..3ef687f81b 100644 --- a/data/battle_scripts_1.s +++ b/data/battle_scripts_1.s @@ -1021,6 +1021,7 @@ BattleScript_EffectFling: resultmessage waitmessage B_WAIT_TIME_MED jumpiflastuseditemberry BattleScript_EffectFlingConsumeBerry + jumpifability BS_TARGET, ABILITY_SHIELD_DUST, BattleScript_FlingBlockedByShieldDust jumpiflastuseditemholdeffect BS_ATTACKER, HOLD_EFFECT_FLAME_ORB, BattleScript_FlingFlameOrb jumpiflastuseditemholdeffect BS_ATTACKER, HOLD_EFFECT_FLINCH, BattleScript_FlingFlinch jumpiflastuseditemholdeffect BS_ATTACKER, HOLD_EFFECT_LIGHT_BALL, BattleScript_FlingLightBall @@ -1028,6 +1029,7 @@ BattleScript_EffectFling: jumpiflastuseditemholdeffect BS_ATTACKER, HOLD_EFFECT_POISON_POWER, BattleScript_FlingPoisonBarb jumpiflastuseditemholdeffect BS_ATTACKER, HOLD_EFFECT_TOXIC_ORB, BattleScript_FlingToxicOrb jumpiflastuseditemholdeffect BS_ATTACKER, HOLD_EFFECT_RESTORE_STATS, BattleScript_FlingWhiteHerb + goto BattleScript_FlingEnd BattleScript_EffectFlingConsumeBerry: savebattleritem BS_TARGET battleritemtolastuseditem BS_TARGET @@ -1046,14 +1048,19 @@ BattleScript_FlingFailConsumeItem:: removeitem BS_ATTACKER goto BattleScript_FailedFromAtkString +BattleScript_FlingBlockedByShieldDust:: + printstring STRINGID_ITEMWASUSEDUP + waitmessage B_WAIT_TIME_LONG + goto BattleScript_FlingEnd + BattleScript_FlingFlameOrb: - seteffectprimary MOVE_EFFECT_BURN + seteffectsecondary MOVE_EFFECT_BURN goto BattleScript_FlingEnd BattleScript_FlingFlinch: - seteffectprimary MOVE_EFFECT_FLINCH + seteffectsecondary MOVE_EFFECT_FLINCH goto BattleScript_FlingEnd BattleScript_FlingLightBall: - seteffectprimary MOVE_EFFECT_PARALYSIS + seteffectsecondary MOVE_EFFECT_PARALYSIS goto BattleScript_FlingEnd BattleScript_FlingMentalHerb: curecertainstatuses BS_TARGET @@ -1066,10 +1073,10 @@ BattleScript_FlingMentalHerb: restoretarget goto BattleScript_FlingEnd BattleScript_FlingPoisonBarb: - seteffectprimary MOVE_EFFECT_POISON + seteffectsecondary MOVE_EFFECT_POISON goto BattleScript_FlingEnd BattleScript_FlingToxicOrb: - seteffectprimary MOVE_EFFECT_TOXIC + seteffectsecondary MOVE_EFFECT_TOXIC goto BattleScript_FlingEnd BattleScript_FlingWhiteHerb: tryresetnegativestatstages BS_TARGET diff --git a/include/constants/battle_string_ids.h b/include/constants/battle_string_ids.h index c4ca5dee43..e854e9f5e5 100644 --- a/include/constants/battle_string_ids.h +++ b/include/constants/battle_string_ids.h @@ -698,8 +698,9 @@ #define STRINGID_PKMNTELLCHILLINGRECEPTIONJOKE 696 #define STRINGID_HOSPITALITYRESTORATION 697 #define STRINGID_ELECTROSHOCKCHARGING 698 +#define STRINGID_ITEMWASUSEDUP 699 -#define BATTLESTRINGS_COUNT 699 +#define BATTLESTRINGS_COUNT 700 // This is the string id that gBattleStringsTable starts with. // String ids before this (e.g. STRINGID_INTROMSG) are not in the table, diff --git a/src/battle_ai_main.c b/src/battle_ai_main.c index aab46e67be..e61f419aa8 100644 --- a/src/battle_ai_main.c +++ b/src/battle_ai_main.c @@ -1287,9 +1287,6 @@ static s32 AI_CheckBadMove(u32 battlerAtk, u32 battlerDef, u32 move, s32 score) case EFFECT_HIT: // only applies to Vital Throw if (gBattleMoves[move].priority < 0 && AI_STRIKES_FIRST(battlerAtk, battlerDef, move) && aiData->hpPercents[battlerAtk] < 40) ADJUST_SCORE(-2); // don't want to move last - - // TEMPORARY - should applied to all moves regardless of effect - score = AI_CheckMoveEffects(battlerAtk, battlerDef, move, score, aiData, predictedMove, isDoubleBattle); break; default: break; // check move damage @@ -3540,6 +3537,8 @@ static s32 AI_CheckViability(u32 battlerAtk, u32 battlerDef, u32 move, s32 score switch (moveEffect) { case EFFECT_HIT: + // TEMPORARY - should be applied to all moves regardless of effect + score = AI_CheckMoveEffects(battlerAtk, battlerDef, move, score, aiData, predictedMove, isDoubleBattle); break; case EFFECT_SLEEP: case EFFECT_YAWN: diff --git a/src/battle_message.c b/src/battle_message.c index b421836f4a..6a3c00cf23 100644 --- a/src/battle_message.c +++ b/src/battle_message.c @@ -835,6 +835,7 @@ static const u8 sText_SwampEnvelopedSide[] = _("A swamp enveloped\n{B_DEF_TEAM2} static const u8 sText_TheSwampDisappeared[] = _("The swamp around {B_ATK_TEAM2}\nteam disappeared!"); static const u8 sText_HospitalityRestoration[] = _("The {B_ATK_PARTNER_NAME} drank down all\nthe matcha that Sinistcha made!"); static const u8 sText_ElectroShockCharging[] = _("{B_ATK_NAME_WITH_PREFIX} absorbed\nelectricity!"); +static const u8 sText_ItemWasUsedUp[] = _("The {B_LAST_ITEM}\nwas used up..."); const u8 *const gBattleStringsTable[BATTLESTRINGS_COUNT] = { @@ -1525,6 +1526,7 @@ const u8 *const gBattleStringsTable[BATTLESTRINGS_COUNT] = [STRINGID_ULTRABURSTCOMPLETED - BATTLESTRINGS_TABLE_START] = sText_UltraBurstCompleted, [STRINGID_TEAMGAINEDEXP - BATTLESTRINGS_TABLE_START] = sText_TeamGainedEXP, [STRINGID_TARGETCOVEREDINSTICKYCANDYSYRUP - BATTLESTRINGS_TABLE_START] = sText_TargetCoveredInStickyCandySyrup, + [STRINGID_ITEMWASUSEDUP - BATTLESTRINGS_TABLE_START] = sText_ItemWasUsedUp, }; const u16 gTrainerUsedItemStringIds[] = diff --git a/src/battle_script_commands.c b/src/battle_script_commands.c index 54a98d61f2..2de0c94631 100644 --- a/src/battle_script_commands.c +++ b/src/battle_script_commands.c @@ -3228,7 +3228,7 @@ void SetMoveEffect(bool32 primary, bool32 certain) MOVE_EFFECT_PARALYSIS }; gBattleScripting.moveEffect = RandomElement(RNG_TRI_ATTACK, sTriAttackEffects); - SetMoveEffect(FALSE, certain); + SetMoveEffect(primary, certain); } break; case MOVE_EFFECT_CHARGING: @@ -3665,7 +3665,7 @@ void SetMoveEffect(bool32 primary, bool32 certain) { static const u8 sDireClawEffects[] = { MOVE_EFFECT_POISON, MOVE_EFFECT_PARALYSIS, MOVE_EFFECT_SLEEP }; gBattleScripting.moveEffect = RandomElement(RNG_DIRE_CLAW, sDireClawEffects); - SetMoveEffect(FALSE, certain); + SetMoveEffect(primary, certain); } break; case MOVE_EFFECT_STEALTH_ROCK: @@ -3781,7 +3781,7 @@ void SetMoveEffect(bool32 primary, bool32 certain) break; } } - SetMoveEffect(FALSE, certain); + SetMoveEffect(primary, certain); break; } } diff --git a/src/battle_util.c b/src/battle_util.c index ba417982c1..7673998195 100644 --- a/src/battle_util.c +++ b/src/battle_util.c @@ -11430,7 +11430,7 @@ bool32 IsGen6ExpShareEnabled(void) bool32 MoveHasMoveEffect(u32 move, u32 moveEffect) { - u8 i; + u32 i; for (i = 0; i < gBattleMoves[move].numAdditionalEffects; i++) { if (gBattleMoves[move].additionalEffects[i].moveEffect == moveEffect @@ -11442,7 +11442,7 @@ bool32 MoveHasMoveEffect(u32 move, u32 moveEffect) bool32 MoveHasMoveEffectWithChance(u32 move, u32 moveEffect, u32 chance) { - u8 i; + u32 i; for (i = 0; i < gBattleMoves[move].numAdditionalEffects; i++) { if (gBattleMoves[move].additionalEffects[i].moveEffect == moveEffect @@ -11454,7 +11454,7 @@ bool32 MoveHasMoveEffectWithChance(u32 move, u32 moveEffect, u32 chance) bool32 MoveHasMoveEffectSelf(u32 move, u32 moveEffect) { - u8 i; + u32 i; for (i = 0; i < gBattleMoves[move].numAdditionalEffects; i++) { if (gBattleMoves[move].additionalEffects[i].moveEffect == moveEffect diff --git a/test/battle/ai_check_viability.c b/test/battle/ai_check_viability.c index 10adca93f9..1b25432f66 100644 --- a/test/battle/ai_check_viability.c +++ b/test/battle/ai_check_viability.c @@ -72,28 +72,28 @@ AI_SINGLE_BATTLE_TEST("AI sees increased base power of Wake Up Slap") } } -// AI_SINGLE_BATTLE_TEST("AI sees increased base power of Grav Apple") -// { -// u32 movePlayer; -// u16 expectedMove; +AI_SINGLE_BATTLE_TEST("AI sees increased base power of Grav Apple") +{ + u32 movePlayer; + u16 expectedMove; -// PARAMETRIZE { movePlayer = MOVE_CELEBRATE; expectedMove = MOVE_POWER_WHIP; } -// PARAMETRIZE { movePlayer = MOVE_GRAVITY; expectedMove = MOVE_GRAV_APPLE; } + PARAMETRIZE { movePlayer = MOVE_CELEBRATE; expectedMove = MOVE_DRUM_BEATING; } + PARAMETRIZE { movePlayer = MOVE_GRAVITY; expectedMove = MOVE_GRAV_APPLE; } -// GIVEN { -// ASSUME(gBattleMoves[MOVE_GRAV_APPLE].effect == EFFECT_GRAV_APPLE); -// ASSUME(MoveHasMoveEffect(MOVE_GRAV_APPLE, MOVE_EFFECT_DEF_MINUS_1) == TRUE); -// AI_FLAGS(AI_FLAG_CHECK_BAD_MOVE | AI_FLAG_CHECK_VIABILITY | AI_FLAG_TRY_TO_FAINT); -// PLAYER(SPECIES_WOBBUFFET) { HP(81); Speed(20); } -// OPPONENT(SPECIES_WOBBUFFET) { Speed(10); Moves(MOVE_POWER_WHIP, MOVE_GRAV_APPLE); } -// } WHEN { -// TURN { MOVE(player, movePlayer); EXPECT_MOVE(opponent, MOVE_POWER_WHIP); } -// TURN { MOVE(player, MOVE_CELEBRATE); EXPECT_MOVE(opponent, expectedMove); } -// } SCENE { -// if (expectedMove == MOVE_GRAV_APPLE) -// MESSAGE("Wobbuffet fainted!"); -// } -// } + GIVEN { + ASSUME(gBattleMoves[MOVE_GRAV_APPLE].effect == EFFECT_GRAV_APPLE); + ASSUME(MoveHasMoveEffect(MOVE_DRUM_BEATING, MOVE_EFFECT_SPD_MINUS_1) == TRUE); + AI_FLAGS(AI_FLAG_CHECK_BAD_MOVE | AI_FLAG_CHECK_VIABILITY | AI_FLAG_TRY_TO_FAINT); + PLAYER(SPECIES_WOBBUFFET) { HP(81); Speed(20); } + OPPONENT(SPECIES_WOBBUFFET) { Speed(10); Moves(MOVE_DRUM_BEATING, MOVE_GRAV_APPLE); } + } WHEN { + TURN { MOVE(player, movePlayer); EXPECT_MOVE(opponent, MOVE_DRUM_BEATING); } + TURN { MOVE(player, MOVE_CELEBRATE); EXPECT_MOVE(opponent, expectedMove); } + } SCENE { + if (expectedMove == MOVE_GRAV_APPLE) + MESSAGE("Wobbuffet fainted!"); + } +} AI_SINGLE_BATTLE_TEST("AI sees increased base power of Flail") { diff --git a/test/battle/move_effect/fling.c b/test/battle/move_effect/fling.c index a753e63fed..60c2341ced 100644 --- a/test/battle/move_effect/fling.c +++ b/test/battle/move_effect/fling.c @@ -201,46 +201,115 @@ SINGLE_BATTLE_TEST("Fling doesn't consume the item if pokemon is asleep/frozen/p } } -SINGLE_BATTLE_TEST("Fling applies special effects when throwing specific Items") +SINGLE_BATTLE_TEST("Fling applies special effects when throwing specific Items - but is blocked by Shield Dust") { - u16 item, effect; + u16 item, ability; - PARAMETRIZE {item = ITEM_FLAME_ORB; effect = MOVE_EFFECT_BURN; } - PARAMETRIZE {item = ITEM_TOXIC_ORB; effect = MOVE_EFFECT_TOXIC; } - PARAMETRIZE {item = ITEM_POISON_BARB; effect = MOVE_EFFECT_POISON; } - PARAMETRIZE {item = ITEM_LIGHT_BALL; effect = MOVE_EFFECT_PARALYSIS; } - PARAMETRIZE {item = ITEM_RAZOR_FANG; effect = MOVE_EFFECT_FLINCH; } - PARAMETRIZE {item = ITEM_KINGS_ROCK; effect = MOVE_EFFECT_FLINCH; } + PARAMETRIZE {item = ITEM_FLAME_ORB; ability = ABILITY_TELEPATHY; } + PARAMETRIZE {item = ITEM_FLAME_ORB; ability = ABILITY_SHIELD_DUST; } + PARAMETRIZE {item = ITEM_LIGHT_BALL; ability = ABILITY_TELEPATHY; } + PARAMETRIZE {item = ITEM_LIGHT_BALL; ability = ABILITY_SHIELD_DUST; } + PARAMETRIZE {item = ITEM_POISON_BARB; ability = ABILITY_TELEPATHY; } + PARAMETRIZE {item = ITEM_POISON_BARB; ability = ABILITY_SHIELD_DUST; } + PARAMETRIZE {item = ITEM_TOXIC_ORB; ability = ABILITY_TELEPATHY; } + PARAMETRIZE {item = ITEM_TOXIC_ORB; ability = ABILITY_SHIELD_DUST; } + PARAMETRIZE {item = ITEM_RAZOR_FANG; ability = ABILITY_TELEPATHY; } + PARAMETRIZE {item = ITEM_RAZOR_FANG; ability = ABILITY_SHIELD_DUST; } + PARAMETRIZE {item = ITEM_KINGS_ROCK; ability = ABILITY_TELEPATHY; } + PARAMETRIZE {item = ITEM_KINGS_ROCK; ability = ABILITY_SHIELD_DUST; } GIVEN { PLAYER(SPECIES_WOBBUFFET) { Item(item); } - OPPONENT(SPECIES_WOBBUFFET); + OPPONENT(SPECIES_WOBBUFFET) { Ability(ability); } } WHEN { TURN { MOVE(player, MOVE_FLING); } } SCENE { MESSAGE("Wobbuffet used Fling!"); ANIMATION(ANIM_TYPE_MOVE, MOVE_FLING, player); HP_BAR(opponent); - switch (effect) + switch (item) { - case MOVE_EFFECT_BURN: - MESSAGE("Foe Wobbuffet was burned!"); - STATUS_ICON(opponent, STATUS1_BURN); + case ITEM_FLAME_ORB: + if (ability != ABILITY_SHIELD_DUST) + { + MESSAGE("Foe Wobbuffet was burned!"); + STATUS_ICON(opponent, STATUS1_BURN); + } + else + { + NONE_OF { + MESSAGE("Foe Wobbuffet was burned!"); + STATUS_ICON(opponent, STATUS1_BURN); + } + MESSAGE("The Flame Orb was used up..."); + } break; - case MOVE_EFFECT_PARALYSIS: - MESSAGE("Foe Wobbuffet is paralyzed! It may be unable to move!"); - STATUS_ICON(opponent, STATUS1_PARALYSIS); + case ITEM_LIGHT_BALL: + if (ability != ABILITY_SHIELD_DUST) + { + MESSAGE("Foe Wobbuffet is paralyzed! It may be unable to move!"); + STATUS_ICON(opponent, STATUS1_PARALYSIS); + } + else + { + NONE_OF { + MESSAGE("Foe Wobbuffet is paralyzed! It may be unable to move!"); + STATUS_ICON(opponent, STATUS1_PARALYSIS); + } + MESSAGE("The Light Ball was used up..."); + } break; - case MOVE_EFFECT_POISON: - MESSAGE("Foe Wobbuffet was poisoned!"); - STATUS_ICON(opponent, STATUS1_POISON); + case ITEM_POISON_BARB: + if (ability != ABILITY_SHIELD_DUST) + { + MESSAGE("Foe Wobbuffet was poisoned!"); + STATUS_ICON(opponent, STATUS1_POISON); + } + else + { + NONE_OF { + MESSAGE("Foe Wobbuffet was poisoned!"); + STATUS_ICON(opponent, STATUS1_POISON); + } + MESSAGE("The Poison Barb was used up..."); + } break; - case MOVE_EFFECT_TOXIC: - MESSAGE("Foe Wobbuffet is badly poisoned!"); - STATUS_ICON(opponent, STATUS1_TOXIC_POISON); + case ITEM_TOXIC_ORB: + if (ability != ABILITY_SHIELD_DUST) + { + MESSAGE("Foe Wobbuffet is badly poisoned!"); + STATUS_ICON(opponent, STATUS1_TOXIC_POISON); + } + else + { + NONE_OF { + MESSAGE("Foe Wobbuffet is badly poisoned!"); + STATUS_ICON(opponent, STATUS1_TOXIC_POISON); + } + MESSAGE("The Toxic Orb was used up..."); + } break; - case MOVE_EFFECT_FLINCH: - MESSAGE("Foe Wobbuffet flinched!"); + case ITEM_RAZOR_FANG: + case ITEM_KINGS_ROCK: + if (ability != ABILITY_SHIELD_DUST) + { + MESSAGE("Foe Wobbuffet flinched!"); + } + else + { + NONE_OF { + MESSAGE("Foe Wobbuffet flinched!"); + } + switch (item) + { + case ITEM_RAZOR_FANG: + MESSAGE("The Razor Fang was used up..."); + break; + case ITEM_KINGS_ROCK: + MESSAGE("The King's Rock was used up..."); + break; + } + } break; } }