ai tweaks

This commit is contained in:
DizzyEggg 2020-07-26 13:48:25 +02:00
parent 1ad76ff3d2
commit 3a220d0733
3 changed files with 95 additions and 25 deletions

View File

@ -683,6 +683,13 @@
.byte \battler
.endm
.macro if_has_move_with_accuracy_lt battler:req, value:req, ptr:req
.byte 0x79
.byte \battler
.byte \value
.4byte \ptr
.endm
@ useful script macros
.macro if_has_physical_move battler:req, ptr:req
if_has_move_with_split \battler, SPLIT_PHYSICAL, \ptr

View File

@ -268,6 +268,18 @@ AI_CheckBadMove_CheckEffect: @ 82DC045
if_effect EFFECT_TRICK_ROOM, AI_CBM_TrickRoom
if_effect EFFECT_WONDER_ROOM, AI_CBM_WonderRoom
if_effect EFFECT_MAGIC_ROOM, AI_CBM_MagicRoom
if_effect EFFECT_SOAK, AI_CBM_Soak
if_effect EFFECT_LOCK_ON, AI_CBM_LockOn
end
AI_CBM_LockOn:
if_status3 AI_TARGET, STATUS3_ALWAYS_HITS, Score_Minus10
if_ability AI_TARGET, ABILITY_NO_GUARD, Score_Minus10
if_ability AI_USER, ABILITY_NO_GUARD, Score_Minus10
end
AI_CBM_Soak:
if_type AI_TARGET, TYPE_WATER, Score_Minus10
end
AI_CBM_TrickRoom:
@ -1122,6 +1134,7 @@ AI_CheckViability:
if_effect EFFECT_MIRROR_COAT, AI_CV_MirrorCoat
if_effect EFFECT_SKULL_BASH, AI_CV_ChargeUpMove
if_effect EFFECT_SOLARBEAM, AI_CV_ChargeUpMove
if_effect EFFECT_GEOMANCY, AI_CV_Geomancy
if_effect EFFECT_SEMI_INVULNERABLE, AI_CV_SemiInvulnerable
if_effect EFFECT_SOFTBOILED, AI_CV_Heal
if_effect EFFECT_FAKE_OUT, AI_CV_FakeOut
@ -1970,6 +1983,7 @@ AI_CV_Rest_End:
end
AI_CV_OneHitKO:
if_status3 AI_TARGET, STATUS3_ALWAYS_HITS, Score_Plus5
end
AI_CV_SuperFang:
@ -2034,6 +2048,9 @@ AI_CV_FocusEnergy2:
goto AI_CV_FocusEnergy3
AI_CV_Swagger:
if_doesnt_have_move_with_effect AI_USER, EFFECT_FOUL_PLAY, AI_CV_Swagger2
score +1
AI_CV_Swagger2:
if_has_move AI_USER, MOVE_PSYCH_UP, AI_CV_SwaggerHasPsychUp
AI_CV_Flatter:
@ -2386,10 +2403,32 @@ AI_CV_PainSplit_ScoreDown1:
AI_CV_PainSplit_End:
end
AI_EncourageIfHasOHKO:
if_level_cond 1, AI_EncourageIfHasOHKORet
if_has_move_with_effect AI_USER, EFFECT_OHKO, Score_Plus3
AI_EncourageIfHasOHKORet:
end
AI_EncourageIfHasLowAccuracyMove:
if_ability AI_USER, ABILITY_COMPOUND_EYES, AI_EncourageIfHasVeryLowAccuracyMove
get_hold_effect AI_USER
if_equal HOLD_EFFECT_WIDE_LENS, AI_EncourageIfHasVeryLowAccuracyMove
if_equal HOLD_EFFECT_ZOOM_LENS, AI_EncourageIfHasVeryLowAccuracyMove
if_has_move_with_accuracy_lt AI_USER, 86, Score_Plus3
if_has_move_with_accuracy_lt AI_USER, 91, Score_Plus1
goto Score_Minus1
AI_EncourageIfHasVeryLowAccuracyMove:
if_has_move_with_accuracy_lt AI_USER, 81, Score_Plus3
if_has_move_with_accuracy_lt AI_USER, 86, Score_Plus1
goto Score_Minus1
AI_CV_LockOn:
call AI_EncourageIfHasOHKO
call AI_EncourageIfHasLowAccuracyMove
AI_CV_LockOn2:
if_random_less_than 128, AI_CV_LockOn_End
score +2
score +1
AI_CV_LockOn_End:
end
@ -2854,8 +2893,15 @@ AI_CV_MirrorCoat_ScoreDown1:
AI_CV_MirrorCoat_End:
end
AI_CV_Geomancy:
get_hold_effect AI_USER
if_equal HOLD_EFFECT_POWER_HERB, AI_CV_ChargeUpMove_ScoreUp2
end
AI_CV_ChargeUpMove:
get_hold_effect AI_USER
if_equal HOLD_EFFECT_POWER_HERB, AI_CV_ChargeUpMove_ScoreUp2
if_type_effectiveness AI_EFFECTIVENESS_x0_25, AI_CV_ChargeUpMove_ScoreDown2
if_type_effectiveness AI_EFFECTIVENESS_x0_5, AI_CV_ChargeUpMove_ScoreDown2
if_has_move_with_effect AI_TARGET, EFFECT_PROTECT, AI_CV_ChargeUpMove_ScoreDown2
@ -2868,8 +2914,13 @@ AI_CV_ChargeUpMove_ScoreDown2:
AI_CV_ChargeUpMove_End:
end
AI_CV_ChargeUpMove_ScoreUp2:
score +2
goto AI_CV_ChargeUpMove_End
AI_CV_SemiInvulnerable:
get_hold_effect AI_USER
if_equal HOLD_EFFECT_POWER_HERB, AI_CV_ChargeUpMove_ScoreUp2
if_doesnt_have_move_with_effect AI_TARGET, EFFECT_PROTECT, AI_CV_SemiInvulnerable2
score -1
goto AI_CV_SemiInvulnerable_End

View File

@ -179,6 +179,7 @@ static void Cmd_get_considered_move_split(void);
static void Cmd_get_considered_move_target(void);
static void Cmd_compare_speeds(void);
static void Cmd_is_wakeup_turn(void);
static void Cmd_if_has_move_with_accuracy_lt(void);
// ewram
EWRAM_DATA const u8 *gAIScriptPtr = NULL;
@ -310,6 +311,7 @@ static const BattleAICmdFunc sBattleAICmdTable[] =
Cmd_get_considered_move_target, // 0x76
Cmd_compare_speeds, // 0x77
Cmd_is_wakeup_turn, // 0x78
Cmd_if_has_move_with_accuracy_lt, // 0x79
};
static const u16 sDiscouragedPowerfulMoveEffects[] =
@ -2591,15 +2593,18 @@ static void Cmd_if_cant_use_last_resort(void)
gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 2);
}
static u16 *GetMovesArray(u32 battler)
{
if (IsBattlerAIControlled(battler) || IsBattlerAIControlled(BATTLE_PARTNER(battler)))
return gBattleMons[battler].moves;
else
return gBattleResources->battleHistory->usedMoves[battler];
}
static bool32 HasMoveWithSplit(u32 battler, u32 split)
{
s32 i;
u16 *moves;
if (IsBattlerAIControlled(battler) || IsBattlerAIControlled(BATTLE_PARTNER(battler)))
moves = gBattleMons[battler].moves;
else
moves = gBattleResources->battleHistory->usedMoves[battler];
u16 *moves = GetMovesArray(battler);
for (i = 0; i < MAX_MON_MOVES; i++)
{
@ -2631,14 +2636,9 @@ static void Cmd_if_has_no_move_with_split(void)
static bool32 MovesWithSplitUnusable(u32 attacker, u32 target, u32 split)
{
s32 i, moveType;
u16 *moves;
u32 usable = 0;
u32 unusable = CheckMoveLimitations(attacker, 0, 0xFF);
if (IsBattlerAIControlled(attacker))
moves = gBattleMons[attacker].moves;
else
moves = gBattleResources->battleHistory->usedMoves[attacker];
u16 *moves = GetMovesArray(attacker);
for (i = 0; i < MAX_MON_MOVES; i++)
{
@ -2698,12 +2698,7 @@ static void Cmd_if_cant_use_belch(void)
static void Cmd_if_has_move_with_type(void)
{
u32 i, moveType, battler = BattleAI_GetWantedBattler(gAIScriptPtr[1]);
u16 *moves;
if (IsBattlerAIControlled(battler))
moves = gBattleMons[battler].moves;
else
moves = BATTLE_HISTORY->usedMoves[battler];
u16 *moves = GetMovesArray(battler);
for (i = 0; i < 4; i++)
{
@ -2725,12 +2720,7 @@ static void Cmd_if_has_move_with_type(void)
static void Cmd_if_has_move_with_flag(void)
{
u32 i, flag, battler = BattleAI_GetWantedBattler(gAIScriptPtr[1]);
u16 *moves;
if (IsBattlerAIControlled(battler))
moves = gBattleMons[battler].moves;
else
moves = BATTLE_HISTORY->usedMoves[battler];
u16 *moves = GetMovesArray(battler);
flag = T1_READ_32(gAIScriptPtr + 2);
for (i = 0; i < 4; i++)
@ -2858,3 +2848,25 @@ static void Cmd_is_wakeup_turn(void)
gAIScriptPtr += 2;
}
static void Cmd_if_has_move_with_accuracy_lt(void)
{
u32 i;
u32 battler = BattleAI_GetWantedBattler(gAIScriptPtr[1]);
u32 toCmp = gAIScriptPtr[2];
u16 *moves = GetMovesArray(battler);
for (i = 0; i < MAX_MON_MOVES; i++)
{
if (moves[i] != MOVE_NONE
&& gBattleMoves[moves[i]].effect != EFFECT_OHKO
&& gBattleMoves[moves[i]].accuracy > 1
&& gBattleMoves[moves[i]].accuracy < toCmp)
break;
}
if (i == MAX_MON_MOVES)
gAIScriptPtr += 7;
else
gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 3);
}