From 1435cd4692fb490471b67f231aeed7e136749d8c Mon Sep 17 00:00:00 2001 From: DizzyEggg Date: Sat, 11 Apr 2020 11:47:13 +0200 Subject: [PATCH] Change inner structure of semi invulerable moves --- data/battle_scripts_1.s | 66 ++++-------------------------------- include/constants/battle.h | 4 +-- include/constants/pokemon.h | 2 ++ src/battle_main.c | 6 ++-- src/battle_script_commands.c | 31 +++-------------- src/battle_util.c | 7 ++-- src/data/battle_moves.h | 16 ++++----- 7 files changed, 25 insertions(+), 107 deletions(-) diff --git a/data/battle_scripts_1.s b/data/battle_scripts_1.s index 7e6e9a68a..0ec6fb236 100644 --- a/data/battle_scripts_1.s +++ b/data/battle_scripts_1.s @@ -1918,9 +1918,7 @@ BattleScript_EffectJudgment: BattleScript_EffectFusionCombo: BattleScript_EffectRevelationDance: BattleScript_EffectBelch: - jumpifnotmove MOVE_SURF, BattleScript_HitFromAtkCanceler - jumpifnostatus3 BS_TARGET, STATUS3_UNDERWATER, BattleScript_HitFromAtkCanceler - orword gHitMarker, HITMARKER_IGNORE_UNDERWATER + BattleScript_HitFromAtkCanceler:: attackcanceler BattleScript_HitFromAccCheck:: @@ -2645,10 +2643,6 @@ BattleScript_EffectDragonRage:: goto BattleScript_HitFromAtkAnimation BattleScript_EffectTrap:: - jumpifnotmove MOVE_WHIRLPOOL, BattleScript_DoWrapEffect - jumpifnostatus3 BS_TARGET, STATUS3_UNDERWATER, BattleScript_DoWrapEffect - orword gHitMarker, HITMARKER_IGNORE_UNDERWATER -BattleScript_DoWrapEffect:: setmoveeffect MOVE_EFFECT_WRAP goto BattleScript_EffectHit @@ -3574,15 +3568,17 @@ BattleScript_EffectThawHit:: goto BattleScript_EffectHit BattleScript_EffectMagnitude:: + jumpifword CMP_COMMON_BITS, gHitMarker, HITMARKER_NO_ATTACKSTRING | HITMARKER_NO_PPDEDUCT, BattleScript_EffectMagnitudeTarget attackcanceler attackstring ppreduce - selectfirstvalidtarget magnitudedamagecalculation pause 0x20 printstring STRINGID_MAGNITUDESTRENGTH waitmessage 0x40 - goto BattleScript_HitsAllWithUndergroundBonusLoop +BattleScript_EffectMagnitudeTarget: + accuracycheck BattleScript_MoveMissedPause, ACC_CURR_MOVE + goto BattleScript_HitFromCritCalc BattleScript_EffectBatonPass:: attackcanceler @@ -3714,8 +3710,6 @@ BattleScript_SkullBashEnd:: goto BattleScript_MoveEnd BattleScript_EffectTwister: - jumpifnostatus3 BS_TARGET, STATUS3_ON_AIR, BattleScript_FlinchEffect - orword gHitMarker, HITMARKER_IGNORE_ON_AIR BattleScript_FlinchEffect: BattleScript_EffectStomp: setmoveeffect MOVE_EFFECT_FLINCH @@ -3724,50 +3718,7 @@ BattleScript_EffectStomp: BattleScript_EffectBulldoze: setmoveeffect MOVE_EFFECT_SPD_MINUS_1 BattleScript_EffectEarthquake: - attackcanceler - attackstring - ppreduce - selectfirstvalidtarget -BattleScript_HitsAllWithUndergroundBonusLoop:: - movevaluescleanup - copyhword sMOVE_EFFECT, sSAVED_MOVE_EFFECT - jumpifnostatus3 BS_TARGET, STATUS3_UNDERGROUND, BattleScript_HitsAllNoUndergroundBonus - orword gHitMarker, HITMARKER_IGNORE_UNDERGROUND - goto BattleScript_DoHitAllWithUndergroundBonus -BattleScript_HitsAllNoUndergroundBonus:: - bicword gHitMarker, HITMARKER_IGNORE_UNDERGROUND -BattleScript_DoHitAllWithUndergroundBonus:: - accuracycheck BattleScript_HitAllWithUndergroundBonusMissed, ACC_CURR_MOVE - critcalc - damagecalc - adjustdamage - attackanimation - waitanimation - effectivenesssound - hitanimation BS_TARGET - waitstate - healthbarupdate BS_TARGET - datahpupdate BS_TARGET - critmessage - waitmessage 0x40 - resultmessage - waitmessage 0x40 - seteffectwithchance - printstring STRINGID_EMPTYSTRING3 - waitmessage 0x1 - tryfaintmon BS_TARGET, FALSE, NULL - moveendto MOVEEND_NEXT_TARGET - jumpifnexttargetvalid BattleScript_HitsAllWithUndergroundBonusLoop - end -BattleScript_HitAllWithUndergroundBonusMissed:: - pause 0x20 - typecalc - effectivenesssound - resultmessage - waitmessage 0x40 - moveendto MOVEEND_NEXT_TARGET - jumpifnexttargetvalid BattleScript_HitsAllWithUndergroundBonusLoop - end + goto BattleScript_EffectHit BattleScript_EffectFutureSight:: attackcanceler @@ -3781,8 +3732,6 @@ BattleScript_EffectFutureSight:: goto BattleScript_MoveEnd BattleScript_EffectGust:: - jumpifnostatus3 BS_TARGET, STATUS3_ON_AIR, BattleScript_EffectHit - orword gHitMarker, HITMARKER_IGNORE_ON_AIR goto BattleScript_EffectHit BattleScript_EffectSolarbeam:: @@ -3804,12 +3753,10 @@ BattleScript_SolarbeamOnFirstTurn:: BattleScript_EffectThunder: setmoveeffect MOVE_EFFECT_PARALYSIS - orword gHitMarker, HITMARKER_IGNORE_ON_AIR goto BattleScript_EffectHit BattleScript_EffectHurricane: setmoveeffect MOVE_EFFECT_CONFUSION - orword gHitMarker, HITMARKER_IGNORE_ON_AIR goto BattleScript_EffectHit BattleScript_EffectTeleport: @@ -4618,7 +4565,6 @@ BattleScript_CosmicPowerEnd:: goto BattleScript_MoveEnd BattleScript_EffectSkyUppercut:: - orword gHitMarker, HITMARKER_IGNORE_ON_AIR goto BattleScript_EffectHit BattleScript_EffectBulkUp:: diff --git a/include/constants/battle.h b/include/constants/battle.h index 48dea68eb..978105ad9 100644 --- a/include/constants/battle.h +++ b/include/constants/battle.h @@ -177,9 +177,7 @@ #define HITMARKER_IGNORE_SAFEGUARD 0x00002000 #define HITMARKER_SYNCHRONISE_EFFECT 0x00004000 #define HITMARKER_RUN 0x00008000 -#define HITMARKER_IGNORE_ON_AIR 0x00010000 -#define HITMARKER_IGNORE_UNDERGROUND 0x00020000 -#define HITMARKER_IGNORE_UNDERWATER 0x00040000 +// 3 free spots because of change in handling of UNDERGROUND/UNDERGWATER/ON AIR #define HITMARKER_UNABLE_TO_USE_MOVE 0x00080000 #define HITMARKER_x100000 0x00100000 #define HITMARKER_x200000 0x00200000 diff --git a/include/constants/pokemon.h b/include/constants/pokemon.h index 87a8606e7..87771a7a6 100644 --- a/include/constants/pokemon.h +++ b/include/constants/pokemon.h @@ -107,6 +107,8 @@ #define FLAG_POWDER 0x80000 #define FLAG_TARGET_ABILITY_IGNORED 0x100000 #define FLAG_DANCE 0x200000 +#define FLAG_DMG_IN_AIR 0x400000 // X2 dmg on air, always hits target on air +#define FLAG_HIT_IN_AIR 0x800000 // dmg is normal, always hits target on air // Split defines. #define SPLIT_PHYSICAL 0x0 diff --git a/src/battle_main.c b/src/battle_main.c index 76cb72701..da7116dbd 100644 --- a/src/battle_main.c +++ b/src/battle_main.c @@ -5659,8 +5659,7 @@ static void HandleAction_NothingIsFainted(void) gCurrentTurnActionNumber++; gCurrentActionFuncId = gActionsByTurnOrder[gCurrentTurnActionNumber]; gHitMarker &= ~(HITMARKER_DESTINYBOND | HITMARKER_IGNORE_SUBSTITUTE | HITMARKER_ATTACKSTRING_PRINTED - | HITMARKER_NO_PPDEDUCT | HITMARKER_IGNORE_SAFEGUARD | HITMARKER_IGNORE_ON_AIR - | HITMARKER_IGNORE_UNDERGROUND | HITMARKER_IGNORE_UNDERWATER | HITMARKER_x100000 + | HITMARKER_NO_PPDEDUCT | HITMARKER_IGNORE_SAFEGUARD | HITMARKER_x100000 | HITMARKER_OBEYS | HITMARKER_x10 | HITMARKER_SYNCHRONISE_EFFECT | HITMARKER_CHARGING | HITMARKER_x4000000); } @@ -5672,8 +5671,7 @@ static void HandleAction_ActionFinished(void) gCurrentActionFuncId = gActionsByTurnOrder[gCurrentTurnActionNumber]; SpecialStatusesClear(); gHitMarker &= ~(HITMARKER_DESTINYBOND | HITMARKER_IGNORE_SUBSTITUTE | HITMARKER_ATTACKSTRING_PRINTED - | HITMARKER_NO_PPDEDUCT | HITMARKER_IGNORE_SAFEGUARD | HITMARKER_IGNORE_ON_AIR - | HITMARKER_IGNORE_UNDERGROUND | HITMARKER_IGNORE_UNDERWATER | HITMARKER_x100000 + | HITMARKER_NO_PPDEDUCT | HITMARKER_IGNORE_SAFEGUARD | HITMARKER_x100000 | HITMARKER_OBEYS | HITMARKER_x10 | HITMARKER_SYNCHRONISE_EFFECT | HITMARKER_CHARGING | HITMARKER_x4000000); diff --git a/src/battle_script_commands.c b/src/battle_script_commands.c index eb4224955..a08781409 100644 --- a/src/battle_script_commands.c +++ b/src/battle_script_commands.c @@ -1217,31 +1217,10 @@ static bool32 AccuracyCalcHelper(u16 move) return TRUE; } - if (!(gHitMarker & HITMARKER_IGNORE_ON_AIR) && gStatuses3[gBattlerTarget] & STATUS3_ON_AIR) - { - gMoveResultFlags |= MOVE_RESULT_MISSED; - JumpIfMoveFailed(7, move); - return TRUE; - } - gHitMarker &= ~HITMARKER_IGNORE_ON_AIR; - - if (!(gHitMarker & HITMARKER_IGNORE_UNDERGROUND) && gStatuses3[gBattlerTarget] & STATUS3_UNDERGROUND) - { - gMoveResultFlags |= MOVE_RESULT_MISSED; - JumpIfMoveFailed(7, move); - return TRUE; - } - gHitMarker &= ~HITMARKER_IGNORE_UNDERGROUND; - - if (!(gHitMarker & HITMARKER_IGNORE_UNDERWATER) && gStatuses3[gBattlerTarget] & STATUS3_UNDERWATER) - { - gMoveResultFlags |= MOVE_RESULT_MISSED; - JumpIfMoveFailed(7, move); - return TRUE; - } - gHitMarker &= ~HITMARKER_IGNORE_UNDERWATER; - - if (gStatuses3[gBattlerTarget] & STATUS3_PHANTOM_FORCE) + if ((gStatuses3[gBattlerTarget] & STATUS3_PHANTOM_FORCE) + || (!(gBattleMoves[move].flags & FLAG_HIT_IN_AIR) && gStatuses3[gBattlerTarget] & STATUS3_ON_AIR) + || (!(gBattleMoves[move].flags & FLAG_DMG_UNDERGROUND) && gStatuses3[gBattlerTarget] & STATUS3_UNDERGROUND) + || (!(gBattleMoves[move].flags & FLAG_DMG_UNDERWATER) && gStatuses3[gBattlerTarget] & STATUS3_UNDERWATER)) { gMoveResultFlags |= MOVE_RESULT_MISSED; JumpIfMoveFailed(7, move); @@ -10030,9 +10009,7 @@ static void Cmd_magnitudedamagecalculation(void) magnitude = 10; } - PREPARE_BYTE_NUMBER_BUFFER(gBattleTextBuff1, 2, magnitude); - for (gBattlerTarget = 0; gBattlerTarget < gBattlersCount; gBattlerTarget++) { if (gBattlerTarget == gBattlerAttacker) diff --git a/src/battle_util.c b/src/battle_util.c index 9792fbb15..3775461df 100644 --- a/src/battle_util.c +++ b/src/battle_util.c @@ -5338,11 +5338,6 @@ static u16 CalcMoveBasePower(u16 move, u8 battlerAtk, u8 battlerDef) if (GetBattlerTurnOrderNum(battlerAtk) > GetBattlerTurnOrderNum(battlerDef)) basePower *= 2; break; - case EFFECT_GUST: - case EFFECT_TWISTER: - if (gStatuses3[battlerDef] & STATUS3_ON_AIR) - basePower *= 2; - break; case EFFECT_ROUND: if (gChosenMoveByBattler[BATTLE_PARTNER(battlerAtk)] == MOVE_ROUND && !(gAbsentBattlerFlags & gBitTable[BATTLE_PARTNER(battlerAtk)])) basePower *= 2; @@ -6033,6 +6028,8 @@ static u32 CalcFinalDmg(u32 dmg, u16 move, u8 battlerAtk, u8 battlerDef, u8 move MulModifier(&finalModifier, UQ_4_12(2.0)); if (gBattleMoves[move].flags & FLAG_DMG_UNDERWATER && gStatuses3[battlerDef] & STATUS3_UNDERWATER) MulModifier(&finalModifier, UQ_4_12(2.0)); + if (gBattleMoves[move].flags & FLAG_DMG_IN_AIR && gStatuses3[battlerDef] & STATUS3_ON_AIR) + MulModifier(&finalModifier, UQ_4_12(2.0)); dmg = ApplyModifier(finalModifier, dmg); if (dmg == 0) diff --git a/src/data/battle_moves.h b/src/data/battle_moves.h index d8d55348e..52981da1e 100644 --- a/src/data/battle_moves.h +++ b/src/data/battle_moves.h @@ -234,7 +234,7 @@ const struct BattleMove gBattleMoves[MOVES_COUNT] = .secondaryEffectChance = 0, .target = MOVE_TARGET_SELECTED, .priority = 0, - .flags = FLAG_PROTECT_AFFECTED | FLAG_MIRROR_MOVE_AFFECTED | FLAG_KINGSROCK_AFFECTED, + .flags = FLAG_PROTECT_AFFECTED | FLAG_MIRROR_MOVE_AFFECTED | FLAG_KINGSROCK_AFFECTED | FLAG_DMG_IN_AIR, .split = SPLIT_SPECIAL, }, @@ -1228,7 +1228,7 @@ const struct BattleMove gBattleMoves[MOVES_COUNT] = .secondaryEffectChance = 30, .target = MOVE_TARGET_SELECTED, .priority = 0, - .flags = FLAG_PROTECT_AFFECTED | FLAG_MIRROR_MOVE_AFFECTED | FLAG_SHEER_FORCE_BOOST, + .flags = FLAG_PROTECT_AFFECTED | FLAG_MIRROR_MOVE_AFFECTED | FLAG_SHEER_FORCE_BOOST | FLAG_HIT_IN_AIR, .split = SPLIT_SPECIAL, }, @@ -1270,7 +1270,7 @@ const struct BattleMove gBattleMoves[MOVES_COUNT] = .secondaryEffectChance = 0, .target = MOVE_TARGET_SELECTED, .priority = 0, - .flags = FLAG_PROTECT_AFFECTED | FLAG_MIRROR_MOVE_AFFECTED, + .flags = FLAG_PROTECT_AFFECTED | FLAG_MIRROR_MOVE_AFFECTED | FLAG_DMG_UNDERGROUND, .split = SPLIT_PHYSICAL, }, @@ -3357,7 +3357,7 @@ const struct BattleMove gBattleMoves[MOVES_COUNT] = .secondaryEffectChance = 20, .target = MOVE_TARGET_BOTH, .priority = 0, - .flags = FLAG_PROTECT_AFFECTED | FLAG_MIRROR_MOVE_AFFECTED | FLAG_KINGSROCK_AFFECTED | FLAG_SHEER_FORCE_BOOST, + .flags = FLAG_PROTECT_AFFECTED | FLAG_MIRROR_MOVE_AFFECTED | FLAG_KINGSROCK_AFFECTED | FLAG_SHEER_FORCE_BOOST | FLAG_DMG_IN_AIR, .split = SPLIT_SPECIAL, }, @@ -4590,7 +4590,7 @@ const struct BattleMove gBattleMoves[MOVES_COUNT] = .secondaryEffectChance = 0, .target = MOVE_TARGET_SELECTED, .priority = 0, - .flags = FLAG_MAKES_CONTACT | FLAG_PROTECT_AFFECTED | FLAG_MIRROR_MOVE_AFFECTED | FLAG_KINGSROCK_AFFECTED | FLAG_IRON_FIST_BOOST, + .flags = FLAG_MAKES_CONTACT | FLAG_PROTECT_AFFECTED | FLAG_MIRROR_MOVE_AFFECTED | FLAG_KINGSROCK_AFFECTED | FLAG_IRON_FIST_BOOST | FLAG_HIT_IN_AIR, .split = SPLIT_PHYSICAL, }, @@ -6726,7 +6726,7 @@ const struct BattleMove gBattleMoves[MOVES_COUNT] = .secondaryEffectChance = 100, .target = MOVE_TARGET_SELECTED, .priority = 0, - .flags = FLAG_PROTECT_AFFECTED | FLAG_MIRROR_MOVE_AFFECTED | FLAG_KINGSROCK_AFFECTED, + .flags = FLAG_PROTECT_AFFECTED | FLAG_MIRROR_MOVE_AFFECTED | FLAG_KINGSROCK_AFFECTED | FLAG_HIT_IN_AIR, .split = SPLIT_PHYSICAL, }, @@ -7609,7 +7609,7 @@ const struct BattleMove gBattleMoves[MOVES_COUNT] = .secondaryEffectChance = 30, .target = MOVE_TARGET_SELECTED, .priority = 0, - .flags = FLAG_PROTECT_AFFECTED | FLAG_MIRROR_MOVE_AFFECTED | FLAG_KINGSROCK_AFFECTED | FLAG_SHEER_FORCE_BOOST, + .flags = FLAG_PROTECT_AFFECTED | FLAG_MIRROR_MOVE_AFFECTED | FLAG_KINGSROCK_AFFECTED | FLAG_SHEER_FORCE_BOOST | FLAG_HIT_IN_AIR, .split = SPLIT_SPECIAL, }, @@ -8627,7 +8627,7 @@ const struct BattleMove gBattleMoves[MOVES_COUNT] = .secondaryEffectChance = 0, .target = MOVE_TARGET_BOTH, .priority = 0, - .flags = FLAG_PROTECT_AFFECTED | FLAG_MIRROR_MOVE_AFFECTED | FLAG_KINGSROCK_AFFECTED, + .flags = FLAG_PROTECT_AFFECTED | FLAG_MIRROR_MOVE_AFFECTED | FLAG_KINGSROCK_AFFECTED | FLAG_HIT_IN_AIR, .split = SPLIT_PHYSICAL, },