This commit is contained in:
DizzyEggg 2020-04-12 12:41:26 +02:00
parent 458809c5f7
commit 8f61445dfe
3 changed files with 23 additions and 1 deletions

View File

@ -539,6 +539,7 @@ struct BattleStruct
u8 lastMoveTarget[MAX_BATTLERS_COUNT]; // The last target on which each mon used a move, for the sake of Instruct
u8 debugHoldEffects[MAX_BATTLERS_COUNT]; // These override actual items' hold effects.
u8 tracedAbility[MAX_BATTLERS_COUNT];
u16 hpBefore[MAX_BATTLERS_COUNT]; // Hp of battlers before using a move. For Berserk
bool8 spriteIgnore0Hp;
struct Illusion illusion[MAX_BATTLERS_COUNT];
};

View File

@ -5068,7 +5068,7 @@ void SetTypeBeforeUsingMove(u16 move, u8 battlerAtk)
static void HandleAction_UseMove(void)
{
u32 side, moveType, var = 4;
u32 i, side, moveType, var = 4;
gBattlerAttacker = gBattlerByTurnOrder[gCurrentTurnActionNumber];
if (gBattleStruct->field_91 & gBitTable[gBattlerAttacker] || !IsBattlerAlive(gBattlerAttacker))
@ -5316,6 +5316,10 @@ static void HandleAction_UseMove(void)
if (gBattleTypeFlags & BATTLE_TYPE_ARENA)
BattleArena_AddMindPoints(gBattlerAttacker);
// Record HP of each battler
for (i = 0; i < MAX_BATTLERS_COUNT; i++)
gBattleStruct->hpBefore[i] = gBattleMons[i].hp;
gCurrentActionFuncId = B_ACTION_EXEC_SCRIPT;
}

View File

@ -3286,6 +3286,23 @@ u8 AbilityBattleEffects(u8 caseID, u8 battler, u8 ability, u8 special, u16 moveA
effect++;
}
break;
case ABILITY_BERSERK:
if (!(gMoveResultFlags & MOVE_RESULT_NO_EFFECT)
&& TARGET_TURN_DAMAGED
&& IsBattlerAlive(battler)
// Had more than half of hp before, now has less
&& gBattleStruct->hpBefore[battler] > gBattleMons[battler].maxHP / 2
&& gBattleMons[battler].hp < gBattleMons[battler].maxHP / 2
&& (gMultiHitCounter == 0 || gMultiHitCounter == 1)
&& !(GetBattlerAbility(gBattlerAttacker) == ABILITY_SHEER_FORCE && gBattleMoves[gCurrentMove].flags & FLAG_SHEER_FORCE_BOOST)
&& gBattleMons[battler].statStages[STAT_SPATK] != 12)
{
SET_STATCHANGER(STAT_SPATK, 1, FALSE);
BattleScriptPushCursor();
gBattlescriptCurrInstr = BattleScript_TargetAbilityStatRaise;
effect++;
}
break;
case ABILITY_WEAK_ARMOR:
if (!(gMoveResultFlags & MOVE_RESULT_NO_EFFECT)
&& TARGET_TURN_DAMAGED