mirror of
https://github.com/rh-hideout/pokeemerald-expansion.git
synced 2026-03-21 18:04:50 -05:00
Merge ba09d51343 into 7248ff7193
This commit is contained in:
commit
671c7b5ac3
|
|
@ -2274,6 +2274,54 @@ bool32 IsBattlerDamagedByStatus(enum BattlerId battler)
|
|||
|| gSideStatuses[GetBattlerSide(battler)] & (SIDE_STATUS_SEA_OF_FIRE | SIDE_STATUS_DAMAGE_NON_TYPES);
|
||||
}
|
||||
|
||||
static bool32 ShouldAvoidProtectingAgainstPartnerMove(enum BattlerId battler, enum Move protectMove)
|
||||
{
|
||||
enum BattlerId partner = BATTLE_PARTNER(battler);
|
||||
enum Move partnerMove = gAiLogicData->partnerMove;
|
||||
|
||||
if (!IsDoubleBattle()
|
||||
|| !HasPartner(battler)
|
||||
|| partner > battler
|
||||
|| partnerMove == MOVE_NONE
|
||||
|| partnerMove == MOVE_UNAVAILABLE
|
||||
|| MoveIgnoresProtect(partnerMove)
|
||||
|| !AI_IsFaster(battler, partner, protectMove, partnerMove, CONSIDER_PRIORITY)
|
||||
|| !IsAllyProtectingFromMove(partner, partnerMove, protectMove)
|
||||
|| CanIndexMoveFaintTarget(partner, battler, gAiBattleData->chosenMoveIndex[partner], AI_ATTACKING))
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
switch (AI_GetBattlerMoveTargetType(partner, partnerMove))
|
||||
{
|
||||
case TARGET_SELECTED:
|
||||
case TARGET_SMART:
|
||||
case TARGET_DEPENDS:
|
||||
case TARGET_RANDOM:
|
||||
case TARGET_ALLY:
|
||||
case TARGET_USER_OR_ALLY:
|
||||
return gAiBattleData->chosenTarget[partner] == battler;
|
||||
case TARGET_FOES_AND_ALLY:
|
||||
case TARGET_ALL_BATTLERS:
|
||||
if (!DoesBattlerIgnoreAbilityChecks(partner, gAiLogicData->abilities[partner], partnerMove)
|
||||
&& ShouldTriggerAbility(partner, battler, gAiLogicData->abilities[battler]))
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
if (gAiLogicData->holdEffects[battler] == HOLD_EFFECT_WEAKNESS_POLICY
|
||||
&& gAiLogicData->effectiveness[partner][battler][gAiBattleData->chosenMoveIndex[partner]] >= UQ_4_12(2.0))
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
s32 ProtectChecks(enum BattlerId battlerAtk, enum BattlerId battlerDef, enum Move move, enum Move predictedMove)
|
||||
{
|
||||
s32 score = 0;
|
||||
|
|
@ -2293,6 +2341,9 @@ s32 ProtectChecks(enum BattlerId battlerAtk, enum BattlerId battlerDef, enum Mov
|
|||
return WORST_EFFECT;
|
||||
}
|
||||
|
||||
if (ShouldAvoidProtectingAgainstPartnerMove(battlerAtk, move))
|
||||
return WORST_EFFECT;
|
||||
|
||||
/*if (GetMoveResultFlags(predictedMove) & (MOVE_RESULT_NO_EFFECT | MOVE_RESULT_MISSED))
|
||||
{
|
||||
ADJUST_SCORE_PTR(-5);
|
||||
|
|
|
|||
|
|
@ -468,6 +468,27 @@ AI_DOUBLE_BATTLE_TEST("AI will choose Beat Up on an ally with Justified if it wi
|
|||
}
|
||||
}
|
||||
|
||||
AI_DOUBLE_BATTLE_TEST("AI will not use Protect if its ally is about to trigger Justified with Beat Up")
|
||||
{
|
||||
ASSUME(GetMoveEffect(MOVE_BEAT_UP) == EFFECT_BEAT_UP);
|
||||
ASSUME(GetMoveType(MOVE_BEAT_UP) == TYPE_DARK);
|
||||
|
||||
GIVEN {
|
||||
AI_FLAGS(AI_FLAG_CHECK_BAD_MOVE | AI_FLAG_CHECK_VIABILITY | AI_FLAG_TRY_TO_FAINT);
|
||||
PLAYER(SPECIES_WOBBUFFET) { Moves(MOVE_SCRATCH); }
|
||||
PLAYER(SPECIES_CLEFABLE) { Moves(MOVE_SCRATCH); }
|
||||
OPPONENT(SPECIES_PANGORO) { Ability(ABILITY_SCRAPPY); Moves(MOVE_BEAT_UP); }
|
||||
OPPONENT(SPECIES_GROWLITHE) { Ability(ABILITY_JUSTIFIED); Moves(MOVE_PROTECT, MOVE_TACKLE); }
|
||||
} WHEN {
|
||||
TURN {
|
||||
MOVE(playerLeft, MOVE_SCRATCH, target: opponentLeft);
|
||||
MOVE(playerRight, MOVE_SCRATCH, target: opponentRight);
|
||||
EXPECT_MOVE(opponentLeft, MOVE_BEAT_UP, target: opponentRight);
|
||||
NOT_EXPECT_MOVE(opponentRight, MOVE_PROTECT);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
AI_DOUBLE_BATTLE_TEST("AI will choose Earthquake if partner is not alive")
|
||||
{
|
||||
ASSUME(GetMoveTarget(MOVE_EARTHQUAKE) == TARGET_FOES_AND_ALLY);
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user