Merge branch 'battle_engine' of https://github.com/rh-hideout/pokeemerald into multistrike

This commit is contained in:
BuffelSaft 2022-05-13 22:40:43 +12:00
commit bb25746e05
9 changed files with 105 additions and 15 deletions

View File

@ -406,6 +406,51 @@ gBattleScriptsForMoveEffects::
.4byte BattleScript_EffectHit @ EFFECT_RISING_VOLTAGE
.4byte BattleScript_EffectHit @ EFFECT_BEAK_BLAST
.4byte BattleScript_EffectCourtChange @ EFFECT_COURT_CHANGE
.4byte BattleScript_EffectSteelBeam @ EFFECT_STEEL_BEAM
BattleScript_EffectSteelBeam::
attackcanceler
attackstring
ppreduce
accuracycheck BattleScript_SteelBeamMiss, ACC_CURR_MOVE
critcalc
damagecalc
adjustdamage
attackanimation
waitanimation
effectivenesssound
hitanimation BS_TARGET
waitstate
healthbarupdate BS_TARGET
datahpupdate BS_TARGET
critmessage
waitmessage B_WAIT_TIME_LONG
resultmessage
waitmessage B_WAIT_TIME_LONG
seteffectwithchance
jumpifability BS_ATTACKER, ABILITY_MAGIC_GUARD, BattleScript_SteelBeamAfterSelfDamage
call BattleScript_SteelBeamSelfDamage
BattleScript_SteelBeamAfterSelfDamage::
waitstate
tryfaintmon BS_ATTACKER
tryfaintmon BS_TARGET
goto BattleScript_MoveEnd
BattleScript_SteelBeamMiss::
pause B_WAIT_TIME_SHORT
effectivenesssound
resultmessage
waitmessage B_WAIT_TIME_LONG
jumpifability BS_ATTACKER, ABILITY_MAGIC_GUARD, BattleScript_MoveEnd
bichalfword gMoveResultFlags, MOVE_RESULT_MISSED
call BattleScript_SteelBeamSelfDamage
orhalfword gMoveResultFlags, MOVE_RESULT_MISSED
goto BattleScript_SteelBeamAfterSelfDamage
BattleScript_SteelBeamSelfDamage::
dmg_1_2_attackerhp
healthbarupdate BS_ATTACKER
datahpupdate BS_ATTACKER
return
BattleScript_EffectCourtChange::
attackcanceler
@ -1247,6 +1292,7 @@ BattleScript_StrengthSapTryHp:
attackanimation
waitanimation
BattleScript_StrengthSapHp:
jumpifstatus3 BS_ATTACKER, STATUS3_HEAL_BLOCK, BattleScript_MoveEnd
jumpiffullhp BS_ATTACKER, BattleScript_MoveEnd
manipulatedamage DMG_BIG_ROOT
healthbarupdate BS_ATTACKER
@ -2385,6 +2431,8 @@ BattleScript_EffectHealPulse:
attackcanceler
attackstring
ppreduce
jumpifstatus3 BS_ATTACKER, STATUS3_HEAL_BLOCK, BattleScript_MoveUsedHealBlockPrevents @ stops pollen puff
jumpifstatus3 BS_TARGET, STATUS3_HEAL_BLOCK, BattleScript_MoveUsedHealBlockPrevents
accuracycheck BattleScript_ButItFailed, NO_ACC_CALC_CHECK_LOCK_ON
jumpifsubstituteblocks BattleScript_ButItFailed
tryhealpulse BS_TARGET, BattleScript_AlreadyAtFullHp
@ -3080,6 +3128,7 @@ BattleScript_EffectAbsorb::
waitmessage B_WAIT_TIME_LONG
resultmessage
waitmessage B_WAIT_TIME_LONG
jumpifstatus3 BS_ATTACKER, STATUS3_HEAL_BLOCK, BattleScript_AbsorbHealBlock
setdrainedhp
manipulatedamage DMG_BIG_ROOT
orword gHitMarker, HITMARKER_IGNORE_SUBSTITUTE | HITMARKER_IGNORE_DISGUISE
@ -3099,6 +3148,7 @@ BattleScript_AbsorbUpdateHp::
waitmessage B_WAIT_TIME_LONG
BattleScript_AbsorbTryFainting::
tryfaintmon BS_ATTACKER
BattleScript_AbsorbHealBlock::
tryfaintmon BS_TARGET
goto BattleScript_MoveEnd
@ -3205,6 +3255,7 @@ BattleScript_DreamEaterWorked:
waitmessage B_WAIT_TIME_LONG
resultmessage
waitmessage B_WAIT_TIME_LONG
jumpifstatus3 BS_ATTACKER, STATUS3_HEAL_BLOCK, BattleScript_DreamEaterTryFaintEnd
setdrainedhp
manipulatedamage DMG_BIG_ROOT
orword gHitMarker, HITMARKER_IGNORE_SUBSTITUTE
@ -7817,7 +7868,7 @@ BattleScript_DrizzleActivates::
call BattleScript_WeatherFormChanges
end3
BattleScript_DefiantActivates::
BattleScript_AbilityRaisesDefenderStat::
pause B_WAIT_TIME_SHORT
call BattleScript_AbilityPopUp
statbuffchange 0, NULL

View File

@ -308,7 +308,7 @@ extern const u8 BattleScript_MistySurgeActivates[];
extern const u8 BattleScript_ElectricSurgeActivates[];
extern const u8 BattleScript_SpectralThiefSteal[];
extern const u8 BattleScript_StatUpMsg[];
extern const u8 BattleScript_DefiantActivates[];
extern const u8 BattleScript_AbilityRaisesDefenderStat[];
extern const u8 BattleScript_PowderMoveNoEffect[];
extern const u8 BattleScript_GrassyTerrainHeals[];
extern const u8 BattleScript_VCreateStatLoss[];

View File

@ -171,6 +171,8 @@
#define B_BRICK_BREAK GEN_7 // In Gen4+, you can destroy your own side's screens. In Gen 5+, screens are not removed if the target is immune.
#define B_WISH_HP_SOURCE GEN_7 // In Gen5+, Wish heals half of the user's max HP instead of the target's.
#define B_RAMPAGE_CANCELLING GEN_7 // In Gen5+, a failed Thrash, etc, will cancel except on its last turn.
#define B_HEAL_BLOCKING GEN_7 // In Gen5+, Heal Block prevents healing by Black Sludge, Leftovers, Shell Bell. Affected Pokémon will not consume held HP-restoring Berries or Berry Juice.
// Draining abilities will not heal but will prevent damage. In Gen6+, Heal Block prevents the use of most HP-draining moves.
// Ability settings
#define B_EXPANDED_ABILITY_NAMES TRUE // If TRUE, ability names are increased from 12 characters to 16 characters.
@ -182,7 +184,7 @@
#define B_FLASH_FIRE_FROZEN GEN_7 // In Gen5+, Flash Fire can trigger even when frozen, when it couldn't before.
#define B_SYNCHRONIZE_NATURE GEN_8 // In Gen8, if a Pokémon with Synchronize is leading the party, it's 100% guaranteed that wild Pokémon will have the same ability, as opposed to 50% previously.
#define B_SYNCHRONIZE_TOXIC GEN_8 // In Gen5+, if a Pokémon with Synchronize is badly poisoned, the opponent will also become badly poisoned. Previously, the opponent would become regular poisoned.
#define B_UPDATED_INTIMIDATE GEN_8 // In Gen8, Intimidate doesn't work on opponents with the Inner Focus, Scrappy, Own Tempo or Oblivious abilities.
#define B_UPDATED_INTIMIDATE GEN_8 // In Gen8, Intimidate doesn't work on opponents with the Inner Focus, Scrappy, Own Tempo or Oblivious abilities. It also activates Rattled.
#define B_PARENTAL_BOND_DAMAGE GEN_8 // In Gen7+, Parental Bond's second hit does 25% of the initial hits damage. Before, it did 50%.
// Item settings

View File

@ -389,7 +389,8 @@
#define EFFECT_RISING_VOLTAGE 383
#define EFFECT_BEAK_BLAST 384
#define EFFECT_COURT_CHANGE 385
#define EFFECT_STEEL_BEAM 386
#define NUM_BATTLE_MOVE_EFFECTS 386
#define NUM_BATTLE_MOVE_EFFECTS 387
#endif // GUARD_CONSTANTS_BATTLE_MOVE_EFFECTS_H

View File

@ -4021,7 +4021,8 @@ static void HandleTurnActionSelectionState(void)
{
BtlController_EmitChoosePokemon(BUFFER_A, PARTY_ACTION_CANT_SWITCH, PARTY_SIZE, ABILITY_NONE, gBattleStruct->battlerPartyOrders[gActiveBattler]);
}
else if ((i = IsAbilityPreventingEscape(gActiveBattler)))
else if ((i = IsAbilityPreventingEscape(gActiveBattler)
&& ItemId_GetHoldEffect(gBattleMons[gActiveBattler].item) != HOLD_EFFECT_SHED_SHELL))
{
BtlController_EmitChoosePokemon(BUFFER_A, ((i - 1) << 4) | PARTY_ACTION_ABILITY_PREVENTS, PARTY_SIZE, gBattleMons[i - 1].ability, gBattleStruct->battlerPartyOrders[gActiveBattler]);
}

View File

@ -220,7 +220,7 @@ static const u8 sText_PkmnForesawAttack[] = _("{B_ATK_NAME_WITH_PREFIX} foresaw\
static const u8 sText_PkmnTookAttack[] = _("{B_DEF_NAME_WITH_PREFIX} took the\n{B_BUFF1} attack!");
static const u8 sText_PkmnChoseXAsDestiny[] = _("{B_ATK_NAME_WITH_PREFIX} chose\n{B_CURRENT_MOVE} as its destiny!");
static const u8 sText_PkmnAttack[] = _("{B_BUFF1}'s attack!");
static const u8 sText_PkmnCenterAttention[] = _("{B_ATK_NAME_WITH_PREFIX} became the\ncenter of attention!");
static const u8 sText_PkmnCenterAttention[] = _("{B_DEF_NAME_WITH_PREFIX} became the\ncenter of attention!");
static const u8 sText_PkmnChargingPower[] = _("{B_ATK_NAME_WITH_PREFIX} began\ncharging power!");
static const u8 sText_NaturePowerTurnedInto[] = _("NATURE POWER turned into\n{B_CURRENT_MOVE}!");
static const u8 sText_PkmnStatusNormal[] = _("{B_ATK_NAME_WITH_PREFIX}'s status\nreturned to normal!");

View File

@ -8028,7 +8028,7 @@ static void Cmd_various(void)
gBattlescriptCurrInstr = T1_READ_PTR(gBattlescriptCurrInstr + 3);
return;
case VARIOUS_CHECK_IF_GRASSY_TERRAIN_HEALS:
if ((gStatuses3[gActiveBattler] & (STATUS3_SEMI_INVULNERABLE))
if ((gStatuses3[gActiveBattler] & (STATUS3_SEMI_INVULNERABLE | STATUS3_HEAL_BLOCK))
|| BATTLER_MAX_HP(gActiveBattler)
|| !gBattleMons[gActiveBattler].hp
|| !(IsBattlerGrounded(gActiveBattler)))
@ -10049,7 +10049,7 @@ static void Cmd_manipulatedamage(void)
gBattleMoveDamage = GetDrainedBigRootHp(gBattlerAttacker, gBattleMoveDamage);
break;
case DMG_1_2_ATTACKER_HP:
gBattleMoveDamage = gBattleMons[gBattlerAttacker].maxHP / 2;
gBattleMoveDamage = (gBattleMons[gBattlerAttacker].maxHP + 1) / 2; // Half of Max HP Rounded UP
break;
case DMG_RECOIL_FROM_IMMUNE:
gBattleMoveDamage = gBattleMons[gBattlerTarget].maxHP / 2;
@ -12578,9 +12578,9 @@ static void Cmd_jumpifattackandspecialattackcannotfall(void) // memento
static void Cmd_setforcedtarget(void) // follow me
{
gSideTimers[GetBattlerSide(gBattlerAttacker)].followmeTimer = 1;
gSideTimers[GetBattlerSide(gBattlerAttacker)].followmeTarget = gBattlerAttacker;
gSideTimers[GetBattlerSide(gBattlerAttacker)].followmePowder = TestMoveFlags(gCurrentMove, FLAG_POWDER);
gSideTimers[GetBattlerSide(gBattlerTarget)].followmeTimer = 1;
gSideTimers[GetBattlerSide(gBattlerTarget)].followmeTarget = gBattlerTarget;
gSideTimers[GetBattlerSide(gBattlerTarget)].followmePowder = TestMoveFlags(gCurrentMove, FLAG_POWDER);
gBattlescriptCurrInstr++;
}

View File

@ -1593,12 +1593,22 @@ void PrepareStringBattle(u16 stringId, u8 battler)
gBattleScripting.stickyWebStatDrop = 0;
gBattlerAbility = gBattlerTarget;
BattleScriptPushCursor();
gBattlescriptCurrInstr = BattleScript_DefiantActivates;
gBattlescriptCurrInstr = BattleScript_AbilityRaisesDefenderStat;
if (targetAbility == ABILITY_DEFIANT)
SET_STATCHANGER(STAT_ATK, 2, FALSE);
else
SET_STATCHANGER(STAT_SPATK, 2, FALSE);
}
#if B_UPDATED_INTIMIDATE >= GEN_8
else if (stringId == STRINGID_PKMNCUTSATTACKWITH && targetAbility == ABILITY_RATTLED
&& CompareStat(gBattlerTarget, STAT_SPEED, MAX_STAT_STAGE, CMP_LESS_THAN))
{
gBattlerAbility = gBattlerTarget;
BattleScriptPushCursor();
gBattlescriptCurrInstr = BattleScript_AbilityRaisesDefenderStat;
SET_STATCHANGER(STAT_SPEED, 1, FALSE);
}
#endif
gActiveBattler = battler;
BtlController_EmitPrintString(BUFFER_A, stringId);
@ -1698,7 +1708,11 @@ bool32 IsHealBlockPreventingMove(u32 battler, u32 move)
switch (gBattleMoves[move].effect)
{
#if B_HEAL_BLOCKING >= GEN_6
case EFFECT_ABSORB:
case EFFECT_STRENGTH_SAP:
case EFFECT_DREAM_EATER:
#endif
case EFFECT_MORNING_SUN:
case EFFECT_MOONLIGHT:
case EFFECT_RESTORE_HP:
@ -1706,7 +1720,7 @@ bool32 IsHealBlockPreventingMove(u32 battler, u32 move)
case EFFECT_ROOST:
case EFFECT_HEALING_WISH:
case EFFECT_WISH:
case EFFECT_DREAM_EATER:
case EFFECT_HEAL_PULSE:
return TRUE;
default:
return FALSE;
@ -5016,7 +5030,11 @@ u8 AbilityBattleEffects(u8 caseID, u8 battler, u16 ability, u8 special, u16 move
if (effect == 1) // Drain Hp ability.
{
#if B_HEAL_BLOCKING >= GEN_5
if (BATTLER_MAX_HP(battler) || gStatuses3[battler] & STATUS3_HEAL_BLOCK)
#else
if (BATTLER_MAX_HP(battler))
#endif
{
if ((gProtectStructs[gBattlerAttacker].notFirstStrike))
gBattlescriptCurrInstr = BattleScript_MonMadeMoveUseless;
@ -6191,7 +6209,11 @@ bool32 HasEnoughHpToEatBerry(u32 battlerId, u32 hpFraction, u32 itemId)
static u8 HealConfuseBerry(u32 battlerId, u32 itemId, u8 flavorId, bool32 end2)
{
#if B_HEAL_BLOCKING >= GEN_5
if (HasEnoughHpToEatBerry(battlerId, 2, itemId) && !(gStatuses3[battlerId] & STATUS3_HEAL_BLOCK))
#else
if (HasEnoughHpToEatBerry(battlerId, 2, itemId))
#endif
{
PREPARE_FLAVOR_BUFFER(gBattleTextBuff1, flavorId);
@ -6377,7 +6399,11 @@ u8 TryHandleSeed(u8 battler, u32 terrainFlag, u8 statId, u16 itemId, bool32 exec
static u8 ItemHealHp(u32 battlerId, u32 itemId, bool32 end2, bool32 percentHeal)
{
#if B_HEAL_BLOCKING >= GEN_5
if (HasEnoughHpToEatBerry(battlerId, 2, itemId) && !(gStatuses3[battlerId] & STATUS3_HEAL_BLOCK)
#else
if (HasEnoughHpToEatBerry(battlerId, 2, itemId)
#endif
&& !(gBattleScripting.overrideBerryRequirements && gBattleMons[battlerId].hp == gBattleMons[battlerId].maxHP))
{
if (percentHeal)
@ -6816,7 +6842,11 @@ u8 ItemBattleEffects(u8 caseID, u8 battlerId, bool8 moveTurn)
break;
case HOLD_EFFECT_LEFTOVERS:
LEFTOVERS:
#if B_HEAL_BLOCKING >= GEN_5
if (gBattleMons[battlerId].hp < gBattleMons[battlerId].maxHP && !moveTurn && !(gStatuses3[battlerId] & STATUS3_HEAL_BLOCK))
#else
if (gBattleMons[battlerId].hp < gBattleMons[battlerId].maxHP && !moveTurn)
#endif
{
gBattleMoveDamage = gBattleMons[battlerId].maxHP / 16;
if (gBattleMoveDamage == 0)
@ -7246,7 +7276,11 @@ u8 ItemBattleEffects(u8 caseID, u8 battlerId, bool8 moveTurn)
if (gSpecialStatuses[gBattlerAttacker].damagedMons // Need to have done damage
&& gBattlerAttacker != gBattlerTarget
&& gBattleMons[gBattlerAttacker].hp != gBattleMons[gBattlerAttacker].maxHP
#if B_HEAL_BLOCKING >= GEN_5
&& gBattleMons[gBattlerAttacker].hp != 0 && !(gStatuses3[battlerId] & STATUS3_HEAL_BLOCK))
#else
&& gBattleMons[gBattlerAttacker].hp != 0)
#endif
{
gLastUsedItem = atkItem;
gPotentialItemEffectBattler = gBattlerAttacker;
@ -8228,7 +8262,8 @@ static u16 CalcMoveBasePower(u16 move, u8 battlerAtk, u8 battlerDef)
basePower *= 2;
break;
case EFFECT_BOLT_BEAK:
if (GetBattlerTurnOrderNum(battlerAtk) < GetBattlerTurnOrderNum(battlerDef))
if (GetBattlerTurnOrderNum(battlerAtk) < GetBattlerTurnOrderNum(battlerDef)
|| gDisableStructs[battlerDef].isFirstTurn == 2)
basePower *= 2;
break;
case EFFECT_ROUND:

View File

@ -11221,7 +11221,7 @@ const struct BattleMove gBattleMoves[MOVES_COUNT] =
[MOVE_STEEL_BEAM] =
{
.effect = EFFECT_RECOIL_50,
.effect = EFFECT_STEEL_BEAM,
.power = 140,
.type = TYPE_STEEL,
.accuracy = 95,