mirror of
https://github.com/Ninjdai1/pokeemerald.git
synced 2024-12-27 20:24:18 +01:00
Merge pull request #2120 from ghoulslash/be/healblock
Heal Block AI and Pollen Puff Selection Prevention
This commit is contained in:
commit
989ec641f4
@ -172,6 +172,7 @@ void TryToApplyMimicry(u8 battlerId, bool8 various);
|
||||
void TryToRevertMimicry(void);
|
||||
void RestoreBattlerOriginalTypes(u8 battlerId);
|
||||
u32 GetBattlerMoveTargetType(u8 battlerId, u16 move);
|
||||
bool32 CanTargetBattler(u8 battlerAtk, u8 battlerDef, u16 move);
|
||||
// Ability checks
|
||||
bool32 IsRolePlayBannedAbilityAtk(u16 ability);
|
||||
bool32 IsRolePlayBannedAbility(u16 ability);
|
||||
|
@ -438,6 +438,9 @@ static u8 ChooseMoveOrAction_Doubles(void)
|
||||
{
|
||||
if (gBattleMons[sBattler_AI].moves[j] != 0)
|
||||
{
|
||||
if (!CanTargetBattler(sBattler_AI, i, gBattleMons[sBattler_AI].moves[j]))
|
||||
continue;
|
||||
|
||||
if (mostViableMovesScores[0] == AI_THINKING_STRUCT->score[j])
|
||||
{
|
||||
mostViableMovesScores[mostViableMovesNo] = AI_THINKING_STRUCT->score[j];
|
||||
@ -2296,6 +2299,8 @@ static s16 AI_CheckBadMove(u8 battlerAtk, u8 battlerDef, u16 move, s16 score)
|
||||
case EFFECT_HIT_ENEMY_HEAL_ALLY: // pollen puff
|
||||
if (IsTargetingPartner(battlerAtk, battlerDef))
|
||||
{
|
||||
if (gStatuses3[battlerDef] & STATUS3_HEAL_BLOCK)
|
||||
return 0;
|
||||
if (AtMaxHp(battlerDef))
|
||||
score -= 10;
|
||||
else if (gBattleMons[battlerDef].hp > gBattleMons[battlerDef].maxHP / 2)
|
||||
@ -4902,6 +4907,9 @@ static s16 AI_HPAware(u8 battlerAtk, u8 battlerDef, u16 move, s16 score)
|
||||
|| (moveType == TYPE_ELECTRIC && AI_DATA->atkPartnerAbility == ABILITY_VOLT_ABSORB)
|
||||
|| (moveType == TYPE_WATER && (AI_DATA->atkPartnerAbility == ABILITY_DRY_SKIN || AI_DATA->atkPartnerAbility == ABILITY_WATER_ABSORB)))
|
||||
{
|
||||
if (gStatuses3[battlerDef] & STATUS3_HEAL_BLOCK)
|
||||
return 0;
|
||||
|
||||
if (CanTargetFaintAi(FOE(battlerAtk), AI_DATA->battlerAtkPartner)
|
||||
|| (CanTargetFaintAi(BATTLE_PARTNER(FOE(battlerAtk)), AI_DATA->battlerAtkPartner)))
|
||||
score--;
|
||||
|
@ -1605,6 +1605,7 @@ static void OpponentHandleChooseMove(void)
|
||||
else // Wild pokemon - use random move
|
||||
{
|
||||
u16 move;
|
||||
u8 target;
|
||||
do
|
||||
{
|
||||
chosenMoveId = Random() & 3;
|
||||
@ -1615,6 +1616,10 @@ static void OpponentHandleChooseMove(void)
|
||||
BtlController_EmitTwoReturnValues(BUFFER_B, 10, (chosenMoveId) | (gActiveBattler << 8));
|
||||
else if (gBattleTypeFlags & BATTLE_TYPE_DOUBLE)
|
||||
{
|
||||
do {
|
||||
target = GetBattlerAtPosition(Random() & 2);
|
||||
} while (!CanTargetBattler(gActiveBattler, target, move));
|
||||
|
||||
#if B_WILD_NATURAL_ENEMIES == TRUE
|
||||
// Don't bother to loop through table if the move can't attack ally
|
||||
if (!(gBattleMoves[move].target & MOVE_TARGET_BOTH))
|
||||
@ -1641,14 +1646,14 @@ static void OpponentHandleChooseMove(void)
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (isPartnerEnemy)
|
||||
if (isPartnerEnemy && CanTargetBattler(gActiveBattler, target, move))
|
||||
BtlController_EmitTwoReturnValues(BUFFER_B, 10, (chosenMoveId) | (GetBattlerAtPosition(BATTLE_PARTNER(gActiveBattler)) << 8));
|
||||
else
|
||||
BtlController_EmitTwoReturnValues(BUFFER_B, 10, (chosenMoveId) | (GetBattlerAtPosition(Random() & 2) << 8));
|
||||
BtlController_EmitTwoReturnValues(BUFFER_B, 10, (chosenMoveId) | (target << 8));
|
||||
}
|
||||
else
|
||||
#endif
|
||||
BtlController_EmitTwoReturnValues(BUFFER_B, 10, (chosenMoveId) | (GetBattlerAtPosition(Random() & 2) << 8));
|
||||
BtlController_EmitTwoReturnValues(BUFFER_B, 10, (chosenMoveId) | (target << 8));
|
||||
}
|
||||
else
|
||||
BtlController_EmitTwoReturnValues(BUFFER_B, 10, (chosenMoveId) | (GetBattlerAtPosition(B_POSITION_PLAYER_LEFT) << 8));
|
||||
|
@ -436,7 +436,8 @@ static void HandleInputChooseTarget(void)
|
||||
break;
|
||||
}
|
||||
|
||||
if (gAbsentBattlerFlags & gBitTable[gMultiUsePlayerCursor])
|
||||
if (gAbsentBattlerFlags & gBitTable[gMultiUsePlayerCursor]
|
||||
|| !CanTargetBattler(gActiveBattler, gMultiUsePlayerCursor, move))
|
||||
i = 0;
|
||||
} while (i == 0);
|
||||
}
|
||||
@ -485,7 +486,8 @@ static void HandleInputChooseTarget(void)
|
||||
break;
|
||||
}
|
||||
|
||||
if (gAbsentBattlerFlags & gBitTable[gMultiUsePlayerCursor])
|
||||
if (gAbsentBattlerFlags & gBitTable[gMultiUsePlayerCursor]
|
||||
|| !CanTargetBattler(gActiveBattler, gMultiUsePlayerCursor, move))
|
||||
i = 0;
|
||||
} while (i == 0);
|
||||
}
|
||||
|
@ -10103,3 +10103,12 @@ u32 GetBattlerMoveTargetType(u8 battlerId, u16 move)
|
||||
else
|
||||
return gBattleMoves[move].target;
|
||||
}
|
||||
|
||||
bool32 CanTargetBattler(u8 battlerAtk, u8 battlerDef, u16 move)
|
||||
{
|
||||
if (gBattleMoves[move].effect == EFFECT_HIT_ENEMY_HEAL_ALLY
|
||||
&& GetBattlerSide(battlerAtk) == GetBattlerSide(battlerDef)
|
||||
&& gStatuses3[battlerAtk] & STATUS3_HEAL_BLOCK)
|
||||
return FALSE; // Pokémon affected by Heal Block cannot target allies with Pollen Puff
|
||||
return TRUE;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user