From 16d38f5343f5be0a272ac8b4c7616814dd20494f Mon Sep 17 00:00:00 2001 From: DizzyEggg Date: Thu, 26 Jul 2018 21:56:23 +0200 Subject: [PATCH] Add a couple of gen5 abilities --- data/battle_scripts_1.s | 50 ++++++++++++++ include/battle_scripts.h | 4 ++ include/constants/battle_string_ids.h | 6 +- src/battle_debug.c | 2 +- src/battle_message.c | 12 +++- src/battle_script_commands.c | 17 ++++- src/battle_util.c | 95 ++++++++++++++++++++++++++- 7 files changed, 179 insertions(+), 7 deletions(-) diff --git a/data/battle_scripts_1.s b/data/battle_scripts_1.s index 5ec5c41a5..76fa21a7c 100644 --- a/data/battle_scripts_1.s +++ b/data/battle_scripts_1.s @@ -4523,6 +4523,15 @@ BattleScript_RainDishActivates:: healthbarupdate BS_ATTACKER datahpupdate BS_ATTACKER end3 + +BattleScript_SolarPowerActivates:: + orword gHitMarker, HITMARKER_IGNORE_SUBSTITUTE | HITMARKER_x100000 + healthbarupdate BS_ATTACKER + datahpupdate BS_ATTACKER + printstring STRINGID_SOLARPOWERHPDROP + waitmessage 0x40 + tryfaintmon BS_ATTACKER, FALSE, NULL + end3 BattleScript_SandstreamActivates:: pause 0x20 @@ -4754,6 +4763,16 @@ BattleScript_ColorChangeActivates:: waitmessage 0x40 return +BattleScript_CursedBodyActivates:: + printstring STRINGID_CUSEDBODYDISABLED + waitmessage 0x40 + return + +BattleScript_MummyActivates:: + printstring STRINGID_ATTACKERACQUIREDABILITY + waitmessage 0x40 + return + BattleScript_AngryPointActivates:: setbyte sB_ANIM_ARG1 0x38 setbyte sB_ANIM_ARG2 0x0 @@ -4770,6 +4789,37 @@ BattleScript_TargetAbilityStatRaise:: waitmessage 0x40 return +BattleScript_WeakArmorActivates:: + setstatchanger STAT_DEF, 1, TRUE + statbuffchange 0x1, BattleScript_WeakArmorActivatesSpeed + jumpifbyte CMP_LESS_THAN, cMULTISTRING_CHOOSER, 0x2, BattleScript_WeakArmorDefAnim + jumpifbyte CMP_EQUAL, cMULTISTRING_CHOOSER, 0x3, BattleScript_WeakArmorActivatesSpeed + pause 0x10 + printfromtable gStatDownStringIds + waitmessage 0x40 + goto BattleScript_WeakArmorActivatesSpeed +BattleScript_WeakArmorDefAnim: + setgraphicalstatchangevalues + playanimation BS_TARGET, B_ANIM_STATS_CHANGE, sB_ANIM_ARG1 + printstring STRINGID_TARGETABILITYSTATLOWER + waitmessage 0x40 +BattleScript_WeakArmorActivatesSpeed: + setstatchanger STAT_SPEED, 1, FALSE + statbuffchange 0x1, BattleScript_WeakArmorActivatesEnd + jumpifbyte CMP_LESS_THAN, cMULTISTRING_CHOOSER, 0x2, BattleScript_WeakArmorSpeedAnim + jumpifbyte CMP_EQUAL, cMULTISTRING_CHOOSER, 0x3, BattleScript_WeakArmorActivatesEnd + pause 0x10 + printstring STRINGID_TARGETSTATWONTGOHIGHER + waitmessage 0x40 + goto BattleScript_WeakArmorActivatesEnd +BattleScript_WeakArmorSpeedAnim: + setgraphicalstatchangevalues + playanimation BS_TARGET, B_ANIM_STATS_CHANGE, sB_ANIM_ARG1 + printstring STRINGID_TARGETABILITYSTATRAISE + waitmessage 0x40 +BattleScript_WeakArmorActivatesEnd: + return + BattleScript_AttackerAbilityStatRaise:: setgraphicalstatchangevalues playanimation BS_ATTACKER, B_ANIM_STATS_CHANGE, sB_ANIM_ARG1 diff --git a/include/battle_scripts.h b/include/battle_scripts.h index ef220ee56..b5835676f 100644 --- a/include/battle_scripts.h +++ b/include/battle_scripts.h @@ -317,5 +317,9 @@ extern const u8 BattleScript_SwitchInAbilityMsg[]; extern const u8 BattleScript_ToxicSpikesPoisoned[]; extern const u8 BattleScript_ToxicSpikesAbsorbed[]; extern const u8 BattleScript_StickyWebOnSwitchIn[]; +extern const u8 BattleScript_SolarPowerActivates[]; +extern const u8 BattleScript_CursedBodyActivates[]; +extern const u8 BattleScript_MummyActivates[]; +extern const u8 BattleScript_WeakArmorActivates[]; #endif // GUARD_BATTLE_SCRIPTS_H diff --git a/include/constants/battle_string_ids.h b/include/constants/battle_string_ids.h index 42c5c0566..ad4ffd892 100644 --- a/include/constants/battle_string_ids.h +++ b/include/constants/battle_string_ids.h @@ -480,7 +480,11 @@ #define STRINGID_HEALINGWISHCAMETRUE 477 #define STRINGID_HEALINGWISHHEALED 478 #define STRINGID_LUNARDANCECAMETRUE 479 +#define STRINGID_CUSEDBODYDISABLED 480 +#define STRINGID_ATTACKERACQUIREDABILITY 481 +#define STRINGID_TARGETABILITYSTATLOWER 482 +#define STRINGID_TARGETSTATWONTGOHIGHER 483 -#define BATTLESTRINGS_COUNT 490 +#define BATTLESTRINGS_COUNT 496 #endif // GUARD_CONSTANTS_BATTLE_STRING_IDS_H diff --git a/src/battle_debug.c b/src/battle_debug.c index e0b69c4b6..d625cdd70 100644 --- a/src/battle_debug.c +++ b/src/battle_debug.c @@ -1162,7 +1162,7 @@ static void SetUpModifyArrows(struct BattleDebugMenu *data) { case LIST_ITEM_ABILITY: data->modifyArrows.minValue = 0; - data->modifyArrows.maxValue = ABILITIES_COUNT - 1; + data->modifyArrows.maxValue = ABILITIES_COUNT_GEN5 - 1; data->modifyArrows.maxDigits = 3; data->modifyArrows.modifiedValPtr = &gBattleMons[data->battlerId].ability; data->modifyArrows.typeOfVal = VAL_U8; diff --git a/src/battle_message.c b/src/battle_message.c index 258ff58e5..5bdbe9705 100644 --- a/src/battle_message.c +++ b/src/battle_message.c @@ -586,8 +586,9 @@ static const u8 sText_MudSportEnds[] = _("The effects of Mud Sport have faded.") static const u8 sText_WaterSportEnds[] = _("The effects of Water Sport have faded."); 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!"); -static const u8 sText_TargetAbilityRaisedStat[] = _("{B_DEF_NAME_WITH_PREFIX}’s {B_ATK_ABILITY}\n raised its {B_BUFF1}!"); -static const u8 sText_AttackerAbilityRaisedStat[] = _("{B_ATK_NAME_WITH_PREFIX}’s {B_ATK_ABILITY}\n raised its {B_BUFF1}!"); +static const u8 sText_TargetAbilityRaisedStat[] = _("{B_DEF_NAME_WITH_PREFIX}’s {B_DEF_ABILITY}\nraised its {B_BUFF1}!"); +static const u8 sText_TargetAbilityLoweredStat[] = _("{B_DEF_NAME_WITH_PREFIX}’s {B_DEF_ABILITY}\nlowered its {B_BUFF1}!"); +static const u8 sText_AttackerAbilityRaisedStat[] = _("{B_ATK_NAME_WITH_PREFIX}’s {B_ATK_ABILITY}\nraised its {B_BUFF1}!"); static const u8 sText_AuroraVeilEnds[] = _("{B_DEF_NAME_WITH_PREFIX}’s {B_DEF_ABILITY}\nwore off!"); static const u8 sText_ElectricTerrainEnds[] = _("{B_ATK_ABILITY} wore off."); static const u8 sText_MistyTerrainEnds[] = _("{B_ATK_ABILITY} wore off."); @@ -621,6 +622,9 @@ static const u8 sText_StickyWebSwitchIn[] = _(""); static const u8 sText_HealingWishCameTrue[] = _("The healing wish came true\nfor {B_ATK_NAME_WITH_PREFIX}!"); static const u8 sText_HealingWishHealed[] = _("{B_ATK_NAME_WITH_PREFIX} regained health!"); static const u8 sText_LunarDanceCameTrue[] = _("{B_ATK_NAME_WITH_PREFIX} became cloaked\nin mystical moonlight!"); +static const u8 sText_CursedBodyDisabled[] = _("{B_ATK_NAME_WITH_PREFIX}’s {B_BUFF1} was disabled\nby {B_DEF_NAME_WITH_PREFIX}’s {B_DEF_ABILITY}!"); +static const u8 sText_AttackerAquiredAbility[] = _("{B_ATK_NAME_WITH_PREFIX} acquired {B_LAST_ABILITY}!"); +static const u8 sText_TargetStatWontGoHigher[] = _("{B_DEF_NAME_WITH_PREFIX}’s {B_BUFF1}\nwon’t go higher!"); const u8 *const gBattleStringsTable[BATTLESTRINGS_COUNT] = { @@ -1093,6 +1097,10 @@ const u8 *const gBattleStringsTable[BATTLESTRINGS_COUNT] = sText_HealingWishCameTrue, sText_HealingWishHealed, sText_LunarDanceCameTrue, + sText_CursedBodyDisabled, + sText_AttackerAquiredAbility, + sText_TargetAbilityLoweredStat, + sText_TargetStatWontGoHigher, }; const u16 gHealingWishStringIds[] = diff --git a/src/battle_script_commands.c b/src/battle_script_commands.c index ce0c49430..8ff4fddbf 100644 --- a/src/battle_script_commands.c +++ b/src/battle_script_commands.c @@ -1182,9 +1182,12 @@ static void atk01_accuracycheck(void) buff = 0xC; moveAcc = gBattleMoves[move].accuracy; - // check Thunder on sunny weather + // Check Thunder on sunny weather. if (WEATHER_HAS_EFFECT && gBattleWeather & WEATHER_SUN_ANY && gBattleMoves[move].effect == EFFECT_THUNDER) moveAcc = 50; + // Check Wonder Skin. + if (defAbility == ABILITY_WONDER_SKIN && gBattleMoves[move].power == 0) + moveAcc = 50; calc = sAccuracyStageRatios[buff].dividend * moveAcc; calc /= sAccuracyStageRatios[buff].divisor; @@ -7737,6 +7740,7 @@ static void atk96_weatherdamage(void) && ability != ABILITY_SAND_VEIL && ability != ABILITY_SAND_FORCE && ability != ABILITY_SAND_RUSH + && ability != ABILITY_OVERCOAT && !(gStatuses3[gBattlerAttacker] & STATUS3_UNDERGROUND) && !(gStatuses3[gBattlerAttacker] & STATUS3_UNDERWATER)) { @@ -7762,6 +7766,7 @@ static void atk96_weatherdamage(void) } else if (!IS_BATTLER_OF_TYPE(gBattlerAttacker, TYPE_ICE) && ability != ABILITY_SNOW_CLOAK + && ability != ABILITY_OVERCOAT && !(gStatuses3[gBattlerAttacker] & STATUS3_UNDERGROUND) && !(gStatuses3[gBattlerAttacker] & STATUS3_UNDERWATER)) { @@ -9703,13 +9708,21 @@ static void atkE2_switchoutabilities(void) { gActiveBattler = GetBattlerForBattleScript(gBattlescriptCurrInstr[1]); - switch (gBattleMons[gActiveBattler].ability) + switch (GetBattlerAbility(gActiveBattler)) { case ABILITY_NATURAL_CURE: gBattleMons[gActiveBattler].status1 = 0; BtlController_EmitSetMonData(0, REQUEST_STATUS_BATTLE, gBitTable[*(gBattleStruct->field_58 + gActiveBattler)], 4, &gBattleMons[gActiveBattler].status1); MarkBattlerForControllerExec(gActiveBattler); break; + case ABILITY_REGENERATOR: + gBattleMoveDamage = gBattleMons[gActiveBattler].maxHP / 3; + gBattleMoveDamage += gBattleMons[gActiveBattler].hp; + if (gBattleMoveDamage > gBattleMons[gActiveBattler].maxHP) + gBattleMons[gActiveBattler].maxHP = gBattleMons[gActiveBattler].maxHP; + BtlController_EmitSetMonData(0, REQUEST_HP_BATTLE, gBitTable[*(gBattleStruct->field_58 + gActiveBattler)], 2, &gBattleMoveDamage); + MarkBattlerForControllerExec(gActiveBattler); + break; } gBattlescriptCurrInstr += 2; diff --git a/src/battle_util.c b/src/battle_util.c index 05f682691..c4dacd71d 100644 --- a/src/battle_util.c +++ b/src/battle_util.c @@ -2615,6 +2615,16 @@ u8 AbilityBattleEffects(u8 caseID, u8 battler, u8 ability, u8 special, u16 moveA effect++; } break; + case ABILITY_SOLAR_POWER: + if (WEATHER_HAS_EFFECT && gBattleWeather & WEATHER_SUN_ANY) + { + BattleScriptPushCursorAndCallback(BattleScript_SolarPowerActivates); + gBattleMoveDamage = gBattleMons[battler].maxHP / 8; + if (gBattleMoveDamage == 0) + gBattleMoveDamage = 1; + effect++; + } + break; } } break; @@ -2741,6 +2751,88 @@ u8 AbilityBattleEffects(u8 caseID, u8 battler, u8 ability, u8 special, u16 moveA case ABILITYEFFECT_CONTACT: // 4 switch (gLastUsedAbility) { + case ABILITY_JUSTIFIED: + if (!(gMoveResultFlags & MOVE_RESULT_NO_EFFECT) + && TARGET_TURN_DAMAGED + && IsBattlerAlive(battler) + && moveType == TYPE_DARK + && gBattleMons[battler].statStages[STAT_ATK] != 0xC) + { + gBattleMons[battler].statStages[STAT_ATK]++; + SET_STATCHANGER(STAT_ATK, 1, FALSE); + BattleScriptPushCursor(); + gBattlescriptCurrInstr = BattleScript_TargetAbilityStatRaise; + effect++; + } + break; + case ABILITY_RATTLED: + if (!(gMoveResultFlags & MOVE_RESULT_NO_EFFECT) + && TARGET_TURN_DAMAGED + && IsBattlerAlive(battler) + && (moveType == TYPE_DARK || moveType == TYPE_BUG || moveType == TYPE_GHOST) + && gBattleMons[battler].statStages[STAT_SPEED] != 0xC) + { + gBattleMons[battler].statStages[STAT_SPEED]++; + SET_STATCHANGER(STAT_SPEED, 1, FALSE); + BattleScriptPushCursor(); + gBattlescriptCurrInstr = BattleScript_TargetAbilityStatRaise; + effect++; + } + break; + case ABILITY_WEAK_ARMOR: + if (!(gMoveResultFlags & MOVE_RESULT_NO_EFFECT) + && TARGET_TURN_DAMAGED + && IsBattlerAlive(battler) + && (gBattleMons[battler].statStages[STAT_SPEED] != 0xC || gBattleMons[battler].statStages[STAT_DEF] != 0)) + { + BattleScriptPushCursor(); + gBattlescriptCurrInstr = BattleScript_WeakArmorActivates; + effect++; + } + break; + case ABILITY_CURSED_BODY: + if (!(gMoveResultFlags & MOVE_RESULT_NO_EFFECT) + && TARGET_TURN_DAMAGED + && gDisableStructs[gBattlerAttacker].disabledMove == MOVE_NONE + && IsBattlerAlive(gBattlerAttacker) + && ((i = GetBattleMonMoveSlot(&gBattleMons[gBattlerAttacker], gChosenMove)) != 4) + && (Random() % 3) == 0) + { + gDisableStructs[gBattlerAttacker].disabledMove = gChosenMove; + gDisableStructs[gBattlerAttacker].disableTimer1 = 4; + PREPARE_MOVE_BUFFER(gBattleTextBuff1, gChosenMove); + BattleScriptPushCursor(); + gBattlescriptCurrInstr = BattleScript_CursedBodyActivates; + effect++; + } + break; + case ABILITY_MUMMY: + if (!(gMoveResultFlags & MOVE_RESULT_NO_EFFECT) + && IsBattlerAlive(gBattlerAttacker) + && (gBattleMoves[move].flags & FLAG_MAKES_CONTACT)) + { + switch (gBattleMons[gBattlerAttacker].ability) + { + case ABILITY_MUMMY: + case ABILITY_BATTLE_BOND: + case ABILITY_COMATOSE: + case ABILITY_DISGUISE: + case ABILITY_MULTITYPE: + case ABILITY_POWER_CONSTRUCT: + case ABILITY_RKS_SYSTEM: + case ABILITY_SCHOOLING: + case ABILITY_SHIELDS_DOWN: + case ABILITY_STANCE_CHANGE: + break; + default: + gLastUsedAbility = gBattleMons[gBattlerAttacker].ability = ABILITY_MUMMY; + BattleScriptPushCursor(); + gBattlescriptCurrInstr = BattleScript_MummyActivates; + effect++; + break; + } + } + break; case ABILITY_ANGER_POINT: if (!(gMoveResultFlags & MOVE_RESULT_NO_EFFECT) && gIsCriticalHit @@ -2770,13 +2862,14 @@ u8 AbilityBattleEffects(u8 caseID, u8 battler, u8 ability, u8 special, u16 moveA } break; case ABILITY_ROUGH_SKIN: + case ABILITY_IRON_BARBS: if (!(gMoveResultFlags & MOVE_RESULT_NO_EFFECT) && gBattleMons[gBattlerAttacker].hp != 0 && !gProtectStructs[gBattlerAttacker].confusionSelfDmg && TARGET_TURN_DAMAGED && (gBattleMoves[move].flags & FLAG_MAKES_CONTACT)) { - gBattleMoveDamage = gBattleMons[gBattlerAttacker].maxHP / 16; + gBattleMoveDamage = gBattleMons[gBattlerAttacker].maxHP / 8; if (gBattleMoveDamage == 0) gBattleMoveDamage = 1; BattleScriptPushCursor();