From 3a10ae9a94e7eeb7b3f6cc3613a27593c764ee94 Mon Sep 17 00:00:00 2001 From: DizzyEggg Date: Sat, 14 Jul 2018 12:54:12 +0200 Subject: [PATCH] Crit changes accomodated to ai scripts --- asm/macros/battle_ai_script.inc | 4 +++- asm/macros/battle_script.inc | 2 +- data/battle_ai_scripts.s | 13 ++++++++----- include/constants/pokemon.h | 14 ++++++++++++++ include/pokemon.h | 12 ------------ src/battle_ai_script_commands.c | 12 +++++++++--- 6 files changed, 35 insertions(+), 22 deletions(-) diff --git a/asm/macros/battle_ai_script.inc b/asm/macros/battle_ai_script.inc index 5e81686bf..40b01d1ec 100644 --- a/asm/macros/battle_ai_script.inc +++ b/asm/macros/battle_ai_script.inc @@ -467,8 +467,10 @@ .byte \bank .endm - .macro nullsub_52 + .macro if_move_flag flag jumpptr .byte 0x52 + .hword \flag + .word \jumpptr .endm .macro nullsub_53 diff --git a/asm/macros/battle_script.inc b/asm/macros/battle_script.inc index 307b90219..1908350b2 100644 --- a/asm/macros/battle_script.inc +++ b/asm/macros/battle_script.inc @@ -356,7 +356,7 @@ .4byte \param0 .endm - .macro jumpiftype2 + .macro nop_42 .byte 0x42 .endm diff --git a/data/battle_ai_scripts.s b/data/battle_ai_scripts.s index 2db1c5728..77be2f354 100644 --- a/data/battle_ai_scripts.s +++ b/data/battle_ai_scripts.s @@ -656,6 +656,7 @@ Score_Plus10: AI_TryToFaint: if_target_is_ally AI_Ret + if_effect EFFECT_HIT, AI_CV_Hit if_effect EFFECT_SLEEP, AI_CV_Sleep if_effect EFFECT_ABSORB, AI_CV_Absorb if_effect EFFECT_EXPLOSION, AI_CV_SelfKO @@ -688,7 +689,6 @@ AI_TryToFaint: if_effect EFFECT_RAZOR_WIND, AI_CV_ChargeUpMove if_effect EFFECT_SUPER_FANG, AI_CV_SuperFang if_effect EFFECT_TRAP, AI_CV_Trap - if_effect EFFECT_HIGH_CRITICAL, AI_CV_HighCrit if_effect EFFECT_CONFUSE, AI_CV_Confuse if_effect EFFECT_ATTACK_UP_2, AI_CV_AttackUp if_effect EFFECT_DEFENSE_UP_2, AI_CV_DefenseUp @@ -768,18 +768,20 @@ AI_TryToFaint: if_effect EFFECT_IMPRISON, AI_CV_Imprison if_effect EFFECT_REFRESH, AI_CV_Refresh if_effect EFFECT_SNATCH, AI_CV_Snatch - if_effect EFFECT_BLAZE_KICK, AI_CV_HighCrit if_effect EFFECT_MUD_SPORT, AI_CV_MudSport if_effect EFFECT_OVERHEAT, AI_CV_Overheat if_effect EFFECT_TICKLE, AI_CV_DefenseDown if_effect EFFECT_COSMIC_POWER, AI_CV_SpDefUp if_effect EFFECT_BULK_UP, AI_CV_DefenseUp - if_effect EFFECT_POISON_TAIL, AI_CV_HighCrit if_effect EFFECT_WATER_SPORT, AI_CV_WaterSport if_effect EFFECT_CALM_MIND, AI_CV_SpDefUp if_effect EFFECT_DRAGON_DANCE, AI_CV_DragonDance end +AI_CV_Hit: + if_move_flag FLAG_HIGH_CRIT AI_CV_HighCrit + end + AI_CV_Sleep: @ 82DCA92 if_has_move_with_effect AI_TARGET, EFFECT_DREAM_EATER, AI_CV_SleepEncourageSlpDamage if_has_move_with_effect AI_TARGET, EFFECT_NIGHTMARE, AI_CV_SleepEncourageSlpDamage @@ -2771,7 +2773,7 @@ BattleAIScript_82DDE57: AI_TryToFaint_TryToEncourageQuickAttack: if_effect EFFECT_EXPLOSION, AI_TryToFaint_End - if_not_effect EFFECT_QUICK_ATTACK, AI_TryToFaint_ScoreUp4 + if_move_flag FLAG_HIGH_CRIT AI_TryToFaint_ScoreUp4 score +2 AI_TryToFaint_ScoreUp4: @@ -2863,7 +2865,9 @@ AI_PreferStrongestMove_End: AI_Risky: if_target_is_ally AI_Ret get_considered_move_effect + if_move_flag FLAG_HIGH_CRIT AI_Risky_RandChance if_not_in_bytes AI_Risky_EffectsToEncourage, AI_Risky_End +AI_Risky_RandChance: if_random_less_than 128, AI_Risky_End score +2 @@ -2875,7 +2879,6 @@ AI_Risky_EffectsToEncourage: .byte EFFECT_EXPLOSION .byte EFFECT_MIRROR_MOVE .byte EFFECT_OHKO - .byte EFFECT_HIGH_CRITICAL .byte EFFECT_CONFUSE .byte EFFECT_METRONOME .byte EFFECT_PSYWAVE diff --git a/include/constants/pokemon.h b/include/constants/pokemon.h index bc66cd07e..821ad3e5b 100644 --- a/include/constants/pokemon.h +++ b/include/constants/pokemon.h @@ -78,4 +78,18 @@ #define STAT_ACC 6 // only in battles #define STAT_EVASION 7 // only in battles +// Move flags. +#define FLAG_MAKES_CONTACT 0x1 +#define FLAG_PROTECT_AFFECTED 0x2 +#define FLAG_MAGICCOAT_AFFECTED 0x4 +#define FLAG_SNATCH_AFFECTED 0x8 +#define FLAG_MIRROR_MOVE_AFFECTED 0x10 +#define FLAG_KINGSROCK_AFFECTED 0x20 +#define FLAG_HIGH_CRIT 0x40 + +// Split defines. +#define SPLIT_PHYSICAL 0x0 +#define SPLIT_SPECIAL 0x1 +#define SPLIT_STATUS 0x2 + #endif // GUARD_CONSTANTS_POKEMON_H diff --git a/include/pokemon.h b/include/pokemon.h index 3bffb98c1..a01026803 100644 --- a/include/pokemon.h +++ b/include/pokemon.h @@ -367,18 +367,6 @@ struct BattleMove u8 split; }; -#define FLAG_MAKES_CONTACT 0x1 -#define FLAG_PROTECT_AFFECTED 0x2 -#define FLAG_MAGICCOAT_AFFECTED 0x4 -#define FLAG_SNATCH_AFFECTED 0x8 -#define FLAG_MIRROR_MOVE_AFFECTED 0x10 -#define FLAG_KINGSROCK_AFFECTED 0x20 -#define FLAG_HIGH_CRIT 0x40 - -#define SPLIT_PHYSICAL 0x0 -#define SPLIT_SPECIAL 0x1 -#define SPLIT_STATUS 0x2 - struct SpindaSpot { u8 x, y; diff --git a/src/battle_ai_script_commands.c b/src/battle_ai_script_commands.c index e82d22576..1fc13c65b 100644 --- a/src/battle_ai_script_commands.c +++ b/src/battle_ai_script_commands.c @@ -135,7 +135,7 @@ static void BattleAICmd_get_move_type_from_result(void); static void BattleAICmd_get_move_power_from_result(void); static void BattleAICmd_get_move_effect_from_result(void); static void BattleAICmd_get_protect_count(void); -static void BattleAICmd_nullsub_52(void); +static void BattleAICmd_if_move_flag(void); static void BattleAICmd_nullsub_53(void); static void BattleAICmd_nullsub_54(void); static void BattleAICmd_nullsub_55(void); @@ -244,7 +244,7 @@ static const BattleAICmdFunc sBattleAICmdTable[] = BattleAICmd_get_move_power_from_result, // 0x4F BattleAICmd_get_move_effect_from_result, // 0x50 BattleAICmd_get_protect_count, // 0x51 - BattleAICmd_nullsub_52, // 0x52 + BattleAICmd_if_move_flag, // 0x52 BattleAICmd_nullsub_53, // 0x53 BattleAICmd_nullsub_54, // 0x54 BattleAICmd_nullsub_55, // 0x55 @@ -2123,8 +2123,14 @@ static void BattleAICmd_get_protect_count(void) gAIScriptPtr += 2; } -static void BattleAICmd_nullsub_52(void) +static void BattleAICmd_if_move_flag(void) { + u16 flag = T1_READ_16(gAIScriptPtr + 1); + + if (gBattleMoves[AI_THINKING_STRUCT->moveConsidered].flags & flag) + gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 3); + else + gAIScriptPtr += 7; } static void BattleAICmd_nullsub_53(void)