Add AI support for newly added moves

This commit is contained in:
DizzyEggg 2018-12-02 23:50:51 +01:00
parent ad67f4f26f
commit 52d1e69591
4 changed files with 120 additions and 0 deletions

View File

@ -581,6 +581,19 @@
.4byte \ptr
.endm
.macro if_share_type battler1:req, battler2:req, ptr:req
.byte 0x67
.byte \battler1
.byte \battler2
.4byte \ptr
.endm
.macro if_cant_use_last_resort battler:req, ptr:req
.byte 0x68
.byte \battler
.4byte \ptr
.endm
@ useful script macros
.macro if_holds_no_item battler, ptr:req
if_holds_item \battler, 0, \ptr

View File

@ -234,8 +234,89 @@ AI_CheckBadMove_CheckEffect: @ 82DC045
if_effect EFFECT_ATTACK_ACCURACY_UP, AI_CBM_AtkAccUp
if_effect EFFECT_ATTACK_SPATK_UP, AI_CBM_AtkSpAtkUp
if_effect EFFECT_GROWTH, AI_CBM_AtkSpAtkUp
if_effect EFFECT_AROMATIC_MIST, AI_CBM_AromaticMist
if_effect EFFECT_ACUPRESSURE, AI_CBM_Acupressure
if_effect EFFECT_BESTOW, AI_CBM_Bestow
if_effect EFFECT_PSYCHO_SHIFT, AI_CBM_PsychicShift
if_effect EFFECT_DEFOG, AI_CBM_Defog
if_effect EFFECT_SYNCHRONOISE, AI_CBM_Synchronoise
if_effect EFFECT_AUTONOMIZE, AI_CBM_SpeedUp
if_effect EFFECT_TOXIC_THREAD, AI_CBM_ToxicThread
if_effect EFFECT_VENOM_DRENCH, AI_CBM_VenomDrench
if_effect EFFECT_DEFENSE_UP_3, AI_CBM_DefenseUp
if_effect EFFECT_SHIFT_GEAR, AI_CBM_DragonDance
if_effect EFFECT_NOBLE_ROAR, AI_CBM_NobleRoar
if_effect EFFECT_SHELL_SMASH, AI_CBM_ShellSmash
if_effect EFFECT_LAST_RESORT, AI_CBM_LastResort
end
AI_CBM_LastResort:
if_cant_use_last_resort AI_USER, Score_Minus10
end
AI_CBM_ShellSmash:
if_ability AI_USER, ABILITY_CONTRARY, AI_CBM_ShellSmashContrary
if_stat_level_not_equal AI_USER, STAT_SPATK, 12, AI_Ret
if_stat_level_not_equal AI_USER, STAT_SPEED, 12, AI_Ret
if_stat_level_equal AI_USER, STAT_ATK, 12, Score_Minus10
end
AI_CBM_ShellSmashContrary:
if_stat_level_not_equal AI_USER, STAT_DEF, 12, AI_Ret
if_stat_level_equal AI_USER, STAT_SPDEF, 12, Score_Minus10
end
AI_CBM_NobleRoar:
if_stat_level_not_equal AI_TARGET, STAT_SPATK, 12, AI_Ret
if_stat_level_equal AI_TARGET, STAT_ATK, 12, Score_Minus10
end
AI_CBM_VenomDrench:
if_not_status AI_TARGET, STATUS1_PSN_ANY, Score_Minus10
if_stat_level_not_equal AI_TARGET, STAT_SPEED, 12, AI_Ret
if_stat_level_not_equal AI_TARGET, STAT_SPATK, 12, AI_Ret
if_stat_level_equal AI_TARGET, STAT_ATK, 12, Score_Minus10
end
AI_CBM_ToxicThread:
if_stat_level_not_equal AI_TARGET, STAT_SPEED, 12, AI_Ret
goto AI_CBM_Toxic
AI_CBM_Synchronoise:
if_share_type AI_USER, AI_TARGET AI_Ret
goto Score_Minus10
AI_CBM_Defog:
if_side_affecting AI_USER, SIDE_STATUS_SPIKES | SIDE_STATUS_STEALTH_ROCK | SIDE_STATUS_TOXIC_SPIKES | SIDE_STATUS_STICKY_WEB, AI_Ret
goto AI_CBM_EvasionDown
AI_CBM_PsychicShift:
if_not_status AI_USER, STATUS1_ANY, Score_Minus10
if_status AI_TARGET, STATUS1_ANY, Score_Minus10
if_status AI_USER, STATUS1_PARALYSIS, AI_CBM_Paralyze
if_status AI_USER, STATUS1_PSN_ANY, AI_CBM_Toxic
if_status AI_USER, STATUS1_BURN, AI_CBM_WillOWisp
if_status AI_USER, STATUS1_SLEEP, AI_CBM_Sleep
end
AI_CBM_Bestow:
if_holds_no_item AI_USER, Score_Minus10
end
AI_CBM_Acupressure:
if_double_battle AI_Ret
if_stat_level_not_equal AI_USER, STAT_ATK, 12, AI_Ret
if_stat_level_not_equal AI_USER, STAT_DEF, 12, AI_Ret
if_stat_level_not_equal AI_USER, STAT_SPATK, 12, AI_Ret
if_stat_level_not_equal AI_USER, STAT_SPDEF, 12, AI_Ret
if_stat_level_not_equal AI_USER, STAT_SPEED, 12, AI_Ret
if_stat_level_not_equal AI_USER, STAT_ACC, 12, AI_Ret
if_stat_level_equal AI_USER, STAT_EVASION, 12, Score_Minus10
end
AI_CBM_AromaticMist:
if_target_is_ally AI_Ret
goto Score_Minus10
AI_CBM_AtkAccUp:
if_stat_level_not_equal AI_USER, STAT_ATK, 12, AI_Ret
if_stat_level_equal AI_USER, STAT_ACC, 12, Score_Minus10

View File

@ -13,6 +13,7 @@ void BufferMoveToLearnIntoBattleTextBuff2(void);
void HandleBattleWindow(u8 xStart, u8 yStart, u8 xEnd, u8 yEnd, u8 flags);
bool8 UproarWakeUpCheck(u8 battlerId);
bool32 DoesSubstituteBlockMove(u8 battlerAtk, u8 battlerDef, u32 move);
bool32 CanUseLastResort(u8 battlerId);
extern void (* const gBattleScriptingCommandsTable[])(void);
extern const u8 gUnknown_0831C494[][4];

View File

@ -156,6 +156,8 @@ static void BattleAICmd_get_ally_chosen_move(void);
static void BattleAICmd_if_has_no_attacking_moves(void);
static void BattleAICmd_get_hazards_count(void);
static void BattleAICmd_if_doesnt_hold_berry(void);
static void BattleAICmd_if_share_type(void);
static void BattleAICmd_if_cant_use_last_resort(void);
// ewram
EWRAM_DATA const u8 *gAIScriptPtr = NULL;
@ -269,6 +271,8 @@ static const BattleAICmdFunc sBattleAICmdTable[] =
BattleAICmd_if_has_no_attacking_moves, // 0x64
BattleAICmd_get_hazards_count, // 0x65
BattleAICmd_if_doesnt_hold_berry, // 0x66
BattleAICmd_if_share_type, // 0x67
BattleAICmd_if_cant_use_last_resort, // 0x68
};
static const u16 sDiscouragedPowerfulMoveEffects[] =
@ -2526,3 +2530,24 @@ static void BattleAICmd_if_doesnt_hold_berry(void)
else
gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 2);
}
static void BattleAICmd_if_share_type(void)
{
u8 battler1 = BattleAI_GetWantedBattler(gAIScriptPtr[1]);
u8 battler2 = BattleAI_GetWantedBattler(gAIScriptPtr[2]);
if (DoBattlersShareType(battler1, battler2))
gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 3);
else
gAIScriptPtr += 7;
}
static void BattleAICmd_if_cant_use_last_resort(void)
{
u8 battler = BattleAI_GetWantedBattler(gAIScriptPtr[1]);
if (CanUseLastResort(battler))
gAIScriptPtr += 6;
else
gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 2);
}