diff --git a/asm/macros/battle_script.inc b/asm/macros/battle_script.inc index 9fa3fe0c3..9384a0f9d 100644 --- a/asm/macros/battle_script.inc +++ b/asm/macros/battle_script.inc @@ -1769,6 +1769,11 @@ various \battler, VARIOUS_TRY_ACTIVATE_GRIM_NEIGH .endm + .macro trysetcorrosivegas battler:req, ptr:req + various \battler, VARIOUS_TRY_SET_CORROSIVE_GAS + .4byte \ptr + .endm + @ helpful macros .macro setstatchanger stat:req, stages:req, down:req setbyte sSTATCHANGER \stat | \stages << 3 | \down << 7 diff --git a/data/battle_scripts_1.s b/data/battle_scripts_1.s index 2e5ad0253..e1e7fbf9d 100644 --- a/data/battle_scripts_1.s +++ b/data/battle_scripts_1.s @@ -373,6 +373,25 @@ gBattleScriptsForMoveEffects:: @ 82D86A8 .4byte BattleScript_EffectScaleShot .4byte BattleScript_EffectMeteorBeam .4byte BattleScript_EffectRisingVoltage + .4byte BattleScript_EffectCorrosiveGas + +BattleScript_EffectCorrosiveGas:: + attackcanceler + accuracycheck BattleScript_PrintMoveMissed, NO_ACC_CALC_CHECK_LOCK_ON + attackstring + ppreduce + jumpifstatus2 BS_TARGET, STATUS2_SUBSTITUTE, BattleScript_PrintMoveMissed + trysetcorrosivegas BS_TARGET, BattleScript_ButItFailed + attackanimation + waitanimation + printstring STRINGID_ITEMMELTED + waitmessage 0x40 + goto BattleScript_MoveEnd + +BattleScript_MeltedItem:: + printstring STRINGID_ITEMMELTED + waitmessage 0x40 + return BattleScript_EffectMeteorBeam:: @ DecideTurn diff --git a/include/battle.h b/include/battle.h index f009cbe7f..7212c4084 100644 --- a/include/battle.h +++ b/include/battle.h @@ -229,6 +229,7 @@ struct WishFutureKnock u8 wishMonId[MAX_BATTLERS_COUNT]; u8 weatherDuration; u8 knockedOffMons[2]; // Each battler is represented by a bit. The array entry is dependent on the battler's side. + u8 meltedItemMons[2]; // Same as above }; struct AI_SavedBattleMon diff --git a/include/battle_scripts.h b/include/battle_scripts.h index f0712fc43..7ae55d01f 100644 --- a/include/battle_scripts.h +++ b/include/battle_scripts.h @@ -369,5 +369,6 @@ extern const u8 BattleScript_JabocaRowapBerryActivates[]; extern const u8 BattleScript_NotAffectedAbilityPopUp[]; extern const u8 BattleScript_BattlerShookOffTaunt[]; extern const u8 BattleScript_BattlerGotOverItsInfatuation[]; +extern const u8 BattleScript_MeltedItem[]; #endif // GUARD_BATTLE_SCRIPTS_H diff --git a/include/constants/battle.h b/include/constants/battle.h index b925904c2..d7bae55c3 100644 --- a/include/constants/battle.h +++ b/include/constants/battle.h @@ -347,6 +347,7 @@ #define MOVE_EFFECT_INCINERATE 0x44 #define MOVE_EFFECT_BUG_BITE 0x45 #define MOVE_EFFECT_SPD_PLUS_1_DEF_MINUS_1 0x46 +#define MOVE_EFFECT_MELT_ITEM 0x4A #define NUM_MOVE_EFFECTS 0x47 #define MOVE_EFFECT_AFFECTS_USER 0x4000 diff --git a/include/constants/battle_move_effects.h b/include/constants/battle_move_effects.h index 03ea11136..d88b34a53 100644 --- a/include/constants/battle_move_effects.h +++ b/include/constants/battle_move_effects.h @@ -357,7 +357,8 @@ #define EFFECT_SCALE_SHOT 351 #define EFFECT_METEOR_BEAM 352 #define EFFECT_RISING_VOLTAGE 353 +#define EFFECT_CORROSIVE_GAS 354 -#define NUM_BATTLE_MOVE_EFFECTS 354 +#define NUM_BATTLE_MOVE_EFFECTS 355 #endif // GUARD_CONSTANTS_BATTLE_MOVE_EFFECTS_H diff --git a/include/constants/battle_script_commands.h b/include/constants/battle_script_commands.h index faaf8f17e..f35dbe2e3 100644 --- a/include/constants/battle_script_commands.h +++ b/include/constants/battle_script_commands.h @@ -173,6 +173,7 @@ #define VARIOUS_DESTROY_ABILITY_POPUP 102 #define VARIOUS_TOTEM_BOOST 103 #define VARIOUS_TRY_ACTIVATE_GRIM_NEIGH 104 +#define VARIOUS_TRY_SET_CORROSIVE_GAS 105 // Cmd_manipulatedamage #define DMG_CHANGE_SIGN 0 diff --git a/include/constants/battle_string_ids.h b/include/constants/battle_string_ids.h index c1e35a312..72f178de7 100644 --- a/include/constants/battle_string_ids.h +++ b/include/constants/battle_string_ids.h @@ -572,8 +572,9 @@ #define STRINGID_PKMNGOTOVERITSINFATUATION 568 #define STRINGID_PKMNINSNAPTRAP 569 #define STRINGID_METEORBEAMCHARGING 570 +#define STRINGID_ITEMMELTED 571 -#define BATTLESTRINGS_COUNT 571 +#define BATTLESTRINGS_COUNT 572 // The below IDs are all indexes into battle message tables, // used to determine which of a set of messages to print. diff --git a/src/battle_message.c b/src/battle_message.c index fd33527a2..4d1ae2ddb 100644 --- a/src/battle_message.c +++ b/src/battle_message.c @@ -698,9 +698,11 @@ static const u8 sText_MicleBerryActivates[] = _("{B_SCR_ACTIVE_NAME_WITH_PREFIX} static const u8 sText_PkmnShookOffTheTaunt[] = _("{B_SCR_ACTIVE_NAME_WITH_PREFIX} shook off\nthe taunt!"); static const u8 sText_PkmnGotOverItsInfatuation[] = _("{B_SCR_ACTIVE_NAME_WITH_PREFIX} got over\nits infatuation!"); static const u8 sText_MeteorBeamCharging[] = _("{B_ATK_NAME_WITH_PREFIX} is overflowing\nwith space energy!"); +static const u8 sText_PkmnItemMelted[] = _("{B_ATK_NAME_WITH_PREFIX} corroded\n{B_DEF_NAME_WITH_PREFIX}'s {B_LAST_ITEM}!"); const u8 *const gBattleStringsTable[BATTLESTRINGS_COUNT] = { + [STRINGID_ITEMMELTED - 12] = sText_PkmnItemMelted, [STRINGID_METEORBEAMCHARGING - 12] = sText_MeteorBeamCharging, [STRINGID_PKMNINSNAPTRAP - 12] = sText_PkmnInSnapTrap, [STRINGID_PKMNGOTOVERITSINFATUATION - 12] = sText_PkmnGotOverItsInfatuation, diff --git a/src/battle_script_commands.c b/src/battle_script_commands.c index 014c3c3c8..9915654c5 100644 --- a/src/battle_script_commands.c +++ b/src/battle_script_commands.c @@ -3021,7 +3021,8 @@ void SetMoveEffect(bool32 primary, u32 certain) | BATTLE_TYPE_LINK | BATTLE_TYPE_RECORDED_LINK | BATTLE_TYPE_SECRET_BASE)) - && (gWishFutureKnock.knockedOffMons[side] & gBitTable[gBattlerPartyIndexes[gBattlerAttacker]])) + && (gWishFutureKnock.knockedOffMons[side] & gBitTable[gBattlerPartyIndexes[gBattlerAttacker]] + || gWishFutureKnock.meltedItemMons[side] & gBitTable[gBattlerPartyIndexes[gBattlerAttacker]])) { gBattlescriptCurrInstr++; } @@ -5267,6 +5268,11 @@ static void Cmd_switchindataupdate(void) { gBattleMons[gActiveBattler].item = 0; } + // check melted items + if (gWishFutureKnock.meltedItemMons[i] & gBitTable[gBattlerPartyIndexes[gActiveBattler]]) + { + gBattleMons[gActiveBattler].item = 0; + } if (gBattleMoves[gCurrentMove].effect == EFFECT_BATON_PASS) { @@ -8422,6 +8428,35 @@ static void Cmd_various(void) gBattlescriptCurrInstr += 7; // exit if loop failed (failsafe) } return; + case VARIOUS_TRY_SET_CORROSIVE_GAS: + if (gBattleMons[gActiveBattler].item != 0 + && CanBattlerGetOrLoseItem(gActiveBattler, gBattleMons[gActiveBattler].item) + && !NoAliveMonsForEitherParty()) + { + if (GetBattlerAbility(gActiveBattler) == ABILITY_STICKY_HOLD && IsBattlerAlive(gActiveBattler)) + { + gBattlerAbility = gActiveBattler; + BattleScriptPushCursor(); + gBattlescriptCurrInstr = BattleScript_StickyHoldActivates; + } + else + { //Item is melted normally + u32 side = GetBattlerSide(gActiveBattler); + + gLastUsedItem = gBattleMons[gActiveBattler].item; + gBattleMons[gActiveBattler].item = 0; + gBattleStruct->choicedMove[gActiveBattler] = 0; + gWishFutureKnock.meltedItemMons[side] |= gBitTable[gBattlerPartyIndexes[gActiveBattler]]; + + CheckSetUnburden(gActiveBattler); + gBattlescriptCurrInstr += 7; + } + } + else + { + gBattlescriptCurrInstr = T1_READ_PTR(gBattlescriptCurrInstr + 3); + } + return; } gBattlescriptCurrInstr += 3; @@ -11206,14 +11241,16 @@ static void Cmd_tryswapitems(void) // trick u8 sideAttacker = GetBattlerSide(gBattlerAttacker); u8 sideTarget = GetBattlerSide(gBattlerTarget); - // you can't swap items if they were knocked off in regular battles + // you can't swap items if they were knocked off or melted in regular battles if (!(gBattleTypeFlags & (BATTLE_TYPE_LINK | BATTLE_TYPE_EREADER_TRAINER | BATTLE_TYPE_FRONTIER | BATTLE_TYPE_SECRET_BASE | BATTLE_TYPE_RECORDED_LINK)) && (gWishFutureKnock.knockedOffMons[sideAttacker] & gBitTable[gBattlerPartyIndexes[gBattlerAttacker]] - || gWishFutureKnock.knockedOffMons[sideTarget] & gBitTable[gBattlerPartyIndexes[gBattlerTarget]])) + || gWishFutureKnock.knockedOffMons[sideTarget] & gBitTable[gBattlerPartyIndexes[gBattlerTarget]] + || gWishFutureKnock.meltedItemMons[sideTarget] & gBitTable[gBattlerPartyIndexes[gBattlerAttacker]] + || gWishFutureKnock.meltedItemMons[sideTarget] & gBitTable[gBattlerPartyIndexes[gBattlerTarget]])) { gBattlescriptCurrInstr = T1_READ_PTR(gBattlescriptCurrInstr + 1); } diff --git a/src/battle_util.c b/src/battle_util.c index 4c46250dc..9d7453bab 100644 --- a/src/battle_util.c +++ b/src/battle_util.c @@ -7215,8 +7215,13 @@ static u16 CalcMoveBasePower(u16 move, u8 battlerAtk, u8 battlerDef) basePower = 120; break; case EFFECT_RISING_VOLTAGE: + #ifdef ITEM_EXPANSION //Air Baloon exception with item expansion branch if (gFieldStatuses & STATUS_FIELD_ELECTRIC_TERRAIN && !IS_BATTLER_OF_TYPE(battlerDef, TYPE_FLYING) && gBattleMons[battlerDef].item != ITEM_AIR_BALLOON && gBattleMons[battlerDef].ability != ABILITY_LEVITATE) + #else + if (gFieldStatuses & STATUS_FIELD_ELECTRIC_TERRAIN && !IS_BATTLER_OF_TYPE(battlerDef, TYPE_FLYING) + && gBattleMons[battlerDef].ability != ABILITY_LEVITATE) + #endif basePower *= 2; break; } diff --git a/src/data/battle_moves.h b/src/data/battle_moves.h index 9e0c18298..20449e446 100644 --- a/src/data/battle_moves.h +++ b/src/data/battle_moves.h @@ -11402,7 +11402,7 @@ const struct BattleMove gBattleMoves[MOVES_COUNT] = [MOVE_CORROSIVE_GAS] = { - .effect = EFFECT_PLACEHOLDER, //TODO + .effect = EFFECT_CORROSIVE_GAS, .power = 0, .type = TYPE_POISON, .accuracy = 100,