From 9ee677d5674f49a116e48d32f74cd5a84dfa26ed Mon Sep 17 00:00:00 2001 From: DizzyEggg Date: Sun, 24 Dec 2017 19:08:55 +0100 Subject: [PATCH 1/3] commit --- src/battle_ai_script_commands.c | 206 ++++++++++++++++---------------- 1 file changed, 103 insertions(+), 103 deletions(-) diff --git a/src/battle_ai_script_commands.c b/src/battle_ai_script_commands.c index 44be0a4d9..7a30de75b 100644 --- a/src/battle_ai_script_commands.c +++ b/src/battle_ai_script_commands.c @@ -723,14 +723,14 @@ static void BattleAICmd_score(void) static void BattleAICmd_if_hp_less_than(void) { - u16 index; + u16 bank; if (gAIScriptPtr[1] == AI_USER) - index = sBank_AI; + bank = sBank_AI; else - index = gBankTarget; + bank = gBankTarget; - if ((u32)(100 * gBattleMons[index].hp / gBattleMons[index].maxHP) < gAIScriptPtr[2]) + if ((u32)(100 * gBattleMons[bank].hp / gBattleMons[bank].maxHP) < gAIScriptPtr[2]) gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 3); else gAIScriptPtr += 7; @@ -738,14 +738,14 @@ static void BattleAICmd_if_hp_less_than(void) static void BattleAICmd_if_hp_more_than(void) { - u16 index; + u16 bank; if (gAIScriptPtr[1] == AI_USER) - index = sBank_AI; + bank = sBank_AI; else - index = gBankTarget; + bank = gBankTarget; - if ((u32)(100 * gBattleMons[index].hp / gBattleMons[index].maxHP) > gAIScriptPtr[2]) + if ((u32)(100 * gBattleMons[bank].hp / gBattleMons[bank].maxHP) > gAIScriptPtr[2]) gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 3); else gAIScriptPtr += 7; @@ -753,14 +753,14 @@ static void BattleAICmd_if_hp_more_than(void) static void BattleAICmd_if_hp_equal(void) { - u16 index; + u16 bank; if (gAIScriptPtr[1] == AI_USER) - index = sBank_AI; + bank = sBank_AI; else - index = gBankTarget; + bank = gBankTarget; - if ((u32)(100 * gBattleMons[index].hp / gBattleMons[index].maxHP) == gAIScriptPtr[2]) + if ((u32)(100 * gBattleMons[bank].hp / gBattleMons[bank].maxHP) == gAIScriptPtr[2]) gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 3); else gAIScriptPtr += 7; @@ -768,14 +768,14 @@ static void BattleAICmd_if_hp_equal(void) static void BattleAICmd_if_hp_not_equal(void) { - u16 index; + u16 bank; if (gAIScriptPtr[1] == AI_USER) - index = sBank_AI; + bank = sBank_AI; else - index = gBankTarget; + bank = gBankTarget; - if ((u32)(100 * gBattleMons[index].hp / gBattleMons[index].maxHP) != gAIScriptPtr[2]) + if ((u32)(100 * gBattleMons[bank].hp / gBattleMons[bank].maxHP) != gAIScriptPtr[2]) gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 3); else gAIScriptPtr += 7; @@ -783,17 +783,17 @@ static void BattleAICmd_if_hp_not_equal(void) static void BattleAICmd_if_status(void) { - u16 index; - u32 arg; + u16 bank; + u32 status; if (gAIScriptPtr[1] == AI_USER) - index = sBank_AI; + bank = sBank_AI; else - index = gBankTarget; + bank = gBankTarget; - arg = AIScriptRead32(gAIScriptPtr + 2); + status = AIScriptRead32(gAIScriptPtr + 2); - if ((gBattleMons[index].status1 & arg) != 0) + if ((gBattleMons[bank].status1 & status) != 0) gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 6); else gAIScriptPtr += 10; @@ -801,17 +801,17 @@ static void BattleAICmd_if_status(void) static void BattleAICmd_if_not_status(void) { - u16 index; - u32 arg; + u16 bank; + u32 status; if (gAIScriptPtr[1] == AI_USER) - index = sBank_AI; + bank = sBank_AI; else - index = gBankTarget; + bank = gBankTarget; - arg = AIScriptRead32(gAIScriptPtr + 2); + status = AIScriptRead32(gAIScriptPtr + 2); - if ((gBattleMons[index].status1 & arg) == 0) + if ((gBattleMons[bank].status1 & status) == 0) gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 6); else gAIScriptPtr += 10; @@ -819,17 +819,17 @@ static void BattleAICmd_if_not_status(void) static void BattleAICmd_if_status2(void) { - u16 index; - u32 arg; + u16 bank; + u32 status; if (gAIScriptPtr[1] == AI_USER) - index = sBank_AI; + bank = sBank_AI; else - index = gBankTarget; + bank = gBankTarget; - arg = AIScriptRead32(gAIScriptPtr + 2); + status = AIScriptRead32(gAIScriptPtr + 2); - if ((gBattleMons[index].status2 & arg) != 0) + if ((gBattleMons[bank].status2 & status) != 0) gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 6); else gAIScriptPtr += 10; @@ -837,17 +837,17 @@ static void BattleAICmd_if_status2(void) static void BattleAICmd_if_not_status2(void) { - u16 index; - u32 arg; + u16 bank; + u32 status; if (gAIScriptPtr[1] == AI_USER) - index = sBank_AI; + bank = sBank_AI; else - index = gBankTarget; + bank = gBankTarget; - arg = AIScriptRead32(gAIScriptPtr + 2); + status = AIScriptRead32(gAIScriptPtr + 2); - if ((gBattleMons[index].status2 & arg) == 0) + if ((gBattleMons[bank].status2 & status) == 0) gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 6); else gAIScriptPtr += 10; @@ -855,17 +855,17 @@ static void BattleAICmd_if_not_status2(void) static void BattleAICmd_if_status3(void) { - u16 index; - u32 arg; + u16 bank; + u32 status; if (gAIScriptPtr[1] == AI_USER) - index = sBank_AI; + bank = sBank_AI; else - index = gBankTarget; + bank = gBankTarget; - arg = AIScriptRead32(gAIScriptPtr + 2); + status = AIScriptRead32(gAIScriptPtr + 2); - if ((gStatuses3[index] & arg) != 0) + if ((gStatuses3[bank] & status) != 0) gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 6); else gAIScriptPtr += 10; @@ -873,17 +873,17 @@ static void BattleAICmd_if_status3(void) static void BattleAICmd_if_not_status3(void) { - u16 index; - u32 arg; + u16 bank; + u32 status; if (gAIScriptPtr[1] == AI_USER) - index = sBank_AI; + bank = sBank_AI; else - index = gBankTarget; + bank = gBankTarget; - arg = AIScriptRead32(gAIScriptPtr + 2); + status = AIScriptRead32(gAIScriptPtr + 2); - if ((gStatuses3[index] & arg) == 0) + if ((gStatuses3[bank] & status) == 0) gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 6); else gAIScriptPtr += 10; @@ -891,18 +891,18 @@ static void BattleAICmd_if_not_status3(void) static void BattleAICmd_if_side_affecting(void) { - u16 index; - u32 arg1, arg2; + u16 bank; + u32 side, status; if (gAIScriptPtr[1] == AI_USER) - index = sBank_AI; + bank = sBank_AI; else - index = gBankTarget; + bank = gBankTarget; - arg1 = GetBankIdentity(index) & 1; - arg2 = AIScriptRead32(gAIScriptPtr + 2); + side = GET_BANK_SIDE(bank); + status = AIScriptRead32(gAIScriptPtr + 2); - if ((gSideAffecting[arg1] & arg2) != 0) + if ((gSideAffecting[side] & status) != 0) gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 6); else gAIScriptPtr += 10; @@ -910,18 +910,18 @@ static void BattleAICmd_if_side_affecting(void) static void BattleAICmd_if_not_side_affecting(void) { - u16 index; - u32 arg1, arg2; + u16 bank; + u32 side, status; if (gAIScriptPtr[1] == AI_USER) - index = sBank_AI; + bank = sBank_AI; else - index = gBankTarget; + bank = gBankTarget; - arg1 = GetBankIdentity(index) & 1; - arg2 = AIScriptRead32(gAIScriptPtr + 2); + side = GET_BANK_SIDE(bank); + status = AIScriptRead32(gAIScriptPtr + 2); - if ((gSideAffecting[arg1] & arg2) == 0) + if ((gSideAffecting[side] & status) == 0) gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 6); else gAIScriptPtr += 10; @@ -1146,9 +1146,9 @@ static void BattleAICmd_get_type(void) gAIScriptPtr += 2; } -static u8 BattleAI_GetWantedBank(u8 index) +static u8 BattleAI_GetWantedBank(u8 bank) { - switch (index) + switch (bank) { case AI_USER: return sBank_AI; @@ -1300,7 +1300,7 @@ static void BattleAICmd_nullsub_2B(void) static void BattleAICmd_count_alive_pokemon(void) { - u8 index; + u8 bank; u8 bankOnField1, bankOnField2; struct Pokemon *party; int i; @@ -1308,11 +1308,11 @@ static void BattleAICmd_count_alive_pokemon(void) AI_THINKING_STRUCT->funcResult = 0; if (gAIScriptPtr[1] == AI_USER) - index = sBank_AI; + bank = sBank_AI; else - index = gBankTarget; + bank = gBankTarget; - if (GetBankSide(index) == SIDE_PLAYER) + if (GetBankSide(bank) == SIDE_PLAYER) party = gPlayerParty; else party = gEnemyParty; @@ -1320,14 +1320,14 @@ static void BattleAICmd_count_alive_pokemon(void) if (gBattleTypeFlags & BATTLE_TYPE_DOUBLE) { u32 status; - bankOnField1 = gBattlePartyID[index]; - status = GetBankIdentity(index) ^ 2; + bankOnField1 = gBattlePartyID[bank]; + status = GetBankIdentity(bank) ^ 2; bankOnField2 = gBattlePartyID[GetBankByIdentity(status)]; } else // in singles there's only one bank by side { - bankOnField1 = gBattlePartyID[index]; - bankOnField2 = gBattlePartyID[index]; + bankOnField1 = gBattlePartyID[bank]; + bankOnField2 = gBattlePartyID[bank]; } for (i = 0; i < 6; i++) @@ -1358,60 +1358,60 @@ static void BattleAICmd_get_considered_move_effect(void) static void BattleAICmd_get_ability(void) { - u8 index; + u8 bank; if (gAIScriptPtr[1] == AI_USER) - index = sBank_AI; + bank = sBank_AI; else - index = gBankTarget; + bank = gBankTarget; - if(gActiveBank != index) + if(gActiveBank != bank) { - if(BATTLE_HISTORY->abilities[index] != 0) + if(BATTLE_HISTORY->abilities[bank] != 0) { - AI_THINKING_STRUCT->funcResult = BATTLE_HISTORY->abilities[index]; + AI_THINKING_STRUCT->funcResult = BATTLE_HISTORY->abilities[bank]; gAIScriptPtr += 2; return; } // abilities that prevent fleeing. - if (gBattleMons[index].ability == ABILITY_SHADOW_TAG - || gBattleMons[index].ability == ABILITY_MAGNET_PULL - || gBattleMons[index].ability == ABILITY_ARENA_TRAP) + if (gBattleMons[bank].ability == ABILITY_SHADOW_TAG + || gBattleMons[bank].ability == ABILITY_MAGNET_PULL + || gBattleMons[bank].ability == ABILITY_ARENA_TRAP) { - AI_THINKING_STRUCT->funcResult = gBattleMons[index].ability; + AI_THINKING_STRUCT->funcResult = gBattleMons[bank].ability; gAIScriptPtr += 2; return; } - if (gBaseStats[gBattleMons[index].species].ability1 != ABILITY_NONE) + if (gBaseStats[gBattleMons[bank].species].ability1 != ABILITY_NONE) { - if (gBaseStats[gBattleMons[index].species].ability2 != ABILITY_NONE) + if (gBaseStats[gBattleMons[bank].species].ability2 != ABILITY_NONE) { // AI has no knowledge of opponent, so it guesses which ability. if (Random() & 1) { - AI_THINKING_STRUCT->funcResult = gBaseStats[gBattleMons[index].species].ability1; + AI_THINKING_STRUCT->funcResult = gBaseStats[gBattleMons[bank].species].ability1; } else { - AI_THINKING_STRUCT->funcResult = gBaseStats[gBattleMons[index].species].ability2; + AI_THINKING_STRUCT->funcResult = gBaseStats[gBattleMons[bank].species].ability2; } } else { - AI_THINKING_STRUCT->funcResult = gBaseStats[gBattleMons[index].species].ability1; // it's definitely ability 1. + AI_THINKING_STRUCT->funcResult = gBaseStats[gBattleMons[bank].species].ability1; // it's definitely ability 1. } } else { - AI_THINKING_STRUCT->funcResult = gBaseStats[gBattleMons[index].species].ability2; // AI cant actually reach this part since every mon has at least 1 ability. + AI_THINKING_STRUCT->funcResult = gBaseStats[gBattleMons[bank].species].ability2; // AI cant actually reach this part since every mon has at least 1 ability. } } else { // The AI knows its own ability. - AI_THINKING_STRUCT->funcResult = gBattleMons[index].ability; + AI_THINKING_STRUCT->funcResult = gBattleMons[bank].ability; } gAIScriptPtr += 2; } @@ -1569,19 +1569,19 @@ static void BattleAICmd_if_status_in_party(void) struct Pokemon *party; int i; u32 statusToCompareTo; - u8 index; + u8 bank; switch(gAIScriptPtr[1]) { case AI_USER: - index = sBank_AI; + bank = sBank_AI; break; default: - index = gBankTarget; + bank = gBankTarget; break; } - party = (GetBankSide(index) == 0) ? gPlayerParty : gEnemyParty; + party = (GetBankSide(bank) == 0) ? gPlayerParty : gEnemyParty; statusToCompareTo = AIScriptRead32(gAIScriptPtr + 2); @@ -1606,19 +1606,19 @@ static void BattleAICmd_if_status_not_in_party(void) struct Pokemon *party; int i; u32 statusToCompareTo; - u8 index; + u8 bank; switch(gAIScriptPtr[1]) { case 1: - index = sBank_AI; + bank = sBank_AI; break; default: - index = gBankTarget; + bank = gBankTarget; break; } - party = (GetBankSide(index) == 0) ? gPlayerParty : gEnemyParty; + party = (GetBankSide(bank) == 0) ? gPlayerParty : gEnemyParty; statusToCompareTo = AIScriptRead32(gAIScriptPtr + 2); @@ -2280,9 +2280,9 @@ static void BattleAICmd_if_target_is_ally(void) static void BattleAICmd_if_flash_fired(void) { - u8 index = BattleAI_GetWantedBank(gAIScriptPtr[1]); + u8 bank = BattleAI_GetWantedBank(gAIScriptPtr[1]); - if(gBattleResources->flags->flags[index] & UNKNOWN_FLAG_FLASH_FIRE) + if(gBattleResources->flags->flags[bank] & UNKNOWN_FLAG_FLASH_FIRE) gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 2); else gAIScriptPtr += 6; From 5ae6461cc5c43bbeca4cd38efcb340207f762303 Mon Sep 17 00:00:00 2001 From: DizzyEggg Date: Sat, 30 Dec 2017 12:19:02 +0100 Subject: [PATCH 2/3] commit --- src/battle_ai_script_commands.c | 177 ++++++++++++++++---------------- 1 file changed, 87 insertions(+), 90 deletions(-) diff --git a/src/battle_ai_script_commands.c b/src/battle_ai_script_commands.c index 7a30de75b..f03381f70 100644 --- a/src/battle_ai_script_commands.c +++ b/src/battle_ai_script_commands.c @@ -104,30 +104,30 @@ static void BattleAICmd_if_less_than(void); static void BattleAICmd_if_more_than(void); static void BattleAICmd_if_equal(void); static void BattleAICmd_if_not_equal(void); -static void BattleAICmd_if_less_than_32(void); -static void BattleAICmd_if_more_than_32(void); -static void BattleAICmd_if_equal_32(void); -static void BattleAICmd_if_not_equal_32(void); +static void BattleAICmd_if_less_than_ptr(void); +static void BattleAICmd_if_more_than_ptr(void); +static void BattleAICmd_if_equal_ptr(void); +static void BattleAICmd_if_not_equal_ptr(void); static void BattleAICmd_if_move(void); static void BattleAICmd_if_not_move(void); static void BattleAICmd_if_in_bytes(void); static void BattleAICmd_if_not_in_bytes(void); static void BattleAICmd_if_in_hwords(void); static void BattleAICmd_if_not_in_hwords(void); -static void BattleAICmd_if_user_can_damage(void); -static void BattleAICmd_if_user_cant_damage(void); +static void BattleAICmd_if_user_has_attacking_move(void); +static void BattleAICmd_if_user_has_no_attacking_moves(void); static void BattleAICmd_get_turn_count(void); static void BattleAICmd_get_type(void); -static void BattleAICmd_get_last_used_bank_move_power(void); -static void BattleAICmd_is_most_powerful_move(void); +static void BattleAICmd_get_considered_move_power(void); +static void BattleAICmd_get_how_powerful_move_is(void); static void BattleAICmd_get_last_used_bank_move(void); -static void BattleAICmd_if_arg_equal(void); -static void BattleAICmd_if_arg_not_equal(void); -static void BattleAICmd_if_would_go_first(void); -static void BattleAICmd_if_would_not_go_first(void); +static void BattleAICmd_if_equal_(void); +static void BattleAICmd_if_not_equal_(void); +static void BattleAICmd_if_user_goes(void); +static void BattleAICmd_if_user_doesnt_go(void); static void BattleAICmd_nullsub_2A(void); static void BattleAICmd_nullsub_2B(void); -static void BattleAICmd_count_alive_pokemon(void); +static void BattleAICmd_count_usable_party_mons(void); static void BattleAICmd_get_considered_move(void); static void BattleAICmd_get_considered_move_effect(void); static void BattleAICmd_get_ability(void); @@ -147,17 +147,17 @@ static void BattleAICmd_if_stat_level_not_equal(void); static void BattleAICmd_if_can_faint(void); static void BattleAICmd_if_cant_faint(void); static void BattleAICmd_if_has_move(void); -static void BattleAICmd_if_dont_have_move(void); -static void BattleAICmd_if_move_effect(void); -static void BattleAICmd_if_not_move_effect(void); +static void BattleAICmd_if_doesnt_have_move(void); +static void BattleAICmd_if_has_move_with_effect(void); +static void BattleAICmd_if_doesnt_have_move_with_effect(void); static void BattleAICmd_if_any_move_disabled_or_encored(void); static void BattleAICmd_if_curr_move_disabled_or_encored(void); static void BattleAICmd_flee(void); -static void BattleAICmd_if_random_100(void); +static void BattleAICmd_if_random_safari_flee(void); static void BattleAICmd_watch(void); static void BattleAICmd_get_hold_effect(void); static void BattleAICmd_get_gender(void); -static void BattleAICmd_is_first_turn(void); +static void BattleAICmd_is_first_turn_for(void); static void BattleAICmd_get_stockpile_count(void); static void BattleAICmd_is_double_battle(void); static void BattleAICmd_get_used_held_item(void); @@ -172,7 +172,7 @@ static void BattleAICmd_nullsub_55(void); static void BattleAICmd_nullsub_56(void); static void BattleAICmd_nullsub_57(void); static void BattleAICmd_call(void); -static void BattleAICmd_jump(void); +static void BattleAICmd_goto(void); static void BattleAICmd_end(void); static void BattleAICmd_if_level_cond(void); static void BattleAICmd_if_target_taunted(void); @@ -215,30 +215,30 @@ static const BattleAICmdFunc sBattleAICmdTable[] = BattleAICmd_if_more_than, // 0x12 BattleAICmd_if_equal, // 0x13 BattleAICmd_if_not_equal, // 0x14 - BattleAICmd_if_less_than_32, // 0x15 - BattleAICmd_if_more_than_32, // 0x16 - BattleAICmd_if_equal_32, // 0x17 - BattleAICmd_if_not_equal_32, // 0x18 + BattleAICmd_if_less_than_ptr, // 0x15 + BattleAICmd_if_more_than_ptr, // 0x16 + BattleAICmd_if_equal_ptr, // 0x17 + BattleAICmd_if_not_equal_ptr, // 0x18 BattleAICmd_if_move, // 0x19 BattleAICmd_if_not_move, // 0x1A BattleAICmd_if_in_bytes, // 0x1B BattleAICmd_if_not_in_bytes, // 0x1C BattleAICmd_if_in_hwords, // 0x1D BattleAICmd_if_not_in_hwords, // 0x1E - BattleAICmd_if_user_can_damage, // 0x1F - BattleAICmd_if_user_cant_damage, // 0x20 + BattleAICmd_if_user_has_attacking_move, // 0x1F + BattleAICmd_if_user_has_no_attacking_moves, // 0x20 BattleAICmd_get_turn_count, // 0x21 BattleAICmd_get_type, // 0x22 - BattleAICmd_get_last_used_bank_move_power, // 0x23 - BattleAICmd_is_most_powerful_move, // 0x24 + BattleAICmd_get_considered_move_power, // 0x23 + BattleAICmd_get_how_powerful_move_is, // 0x24 BattleAICmd_get_last_used_bank_move, // 0x25 - BattleAICmd_if_arg_equal, // 0x26 - BattleAICmd_if_arg_not_equal, // 0x27 - BattleAICmd_if_would_go_first, // 0x28 - BattleAICmd_if_would_not_go_first, // 0x29 + BattleAICmd_if_equal_, // 0x26 + BattleAICmd_if_not_equal_, // 0x27 + BattleAICmd_if_user_goes, // 0x28 + BattleAICmd_if_user_doesnt_go, // 0x29 BattleAICmd_nullsub_2A, // 0x2A BattleAICmd_nullsub_2B, // 0x2B - BattleAICmd_count_alive_pokemon, // 0x2C + BattleAICmd_count_usable_party_mons, // 0x2C BattleAICmd_get_considered_move, // 0x2D BattleAICmd_get_considered_move_effect, // 0x2E BattleAICmd_get_ability, // 0x2F @@ -258,17 +258,17 @@ static const BattleAICmdFunc sBattleAICmdTable[] = BattleAICmd_if_can_faint, // 0x3D BattleAICmd_if_cant_faint, // 0x3E BattleAICmd_if_has_move, // 0x3F - BattleAICmd_if_dont_have_move, // 0x40 - BattleAICmd_if_move_effect, // 0x41 - BattleAICmd_if_not_move_effect, // 0x42 + BattleAICmd_if_doesnt_have_move, // 0x40 + BattleAICmd_if_has_move_with_effect, // 0x41 + BattleAICmd_if_doesnt_have_move_with_effect, // 0x42 BattleAICmd_if_any_move_disabled_or_encored, // 0x43 BattleAICmd_if_curr_move_disabled_or_encored, // 0x44 BattleAICmd_flee, // 0x45 - BattleAICmd_if_random_100, // 0x46 + BattleAICmd_if_random_safari_flee, // 0x46 BattleAICmd_watch, // 0x47 BattleAICmd_get_hold_effect, // 0x48 BattleAICmd_get_gender, // 0x49 - BattleAICmd_is_first_turn, // 0x4A + BattleAICmd_is_first_turn_for, // 0x4A BattleAICmd_get_stockpile_count, // 0x4B BattleAICmd_is_double_battle, // 0x4C BattleAICmd_get_used_held_item, // 0x4D @@ -283,7 +283,7 @@ static const BattleAICmdFunc sBattleAICmdTable[] = BattleAICmd_nullsub_56, // 0x56 BattleAICmd_nullsub_57, // 0x57 BattleAICmd_call, // 0x58 - BattleAICmd_jump, // 0x59 + BattleAICmd_goto, // 0x59 BattleAICmd_end, // 0x5A BattleAICmd_if_level_cond, // 0x5B BattleAICmd_if_target_taunted, // 0x5C @@ -959,41 +959,41 @@ static void BattleAICmd_if_not_equal(void) gAIScriptPtr += 6; } -static void BattleAICmd_if_less_than_32(void) +static void BattleAICmd_if_less_than_ptr(void) { - const u8 *temp = AIScriptReadPtr(gAIScriptPtr + 1); + const u8 *value = AIScriptReadPtr(gAIScriptPtr + 1); - if (AI_THINKING_STRUCT->funcResult < *temp) + if (AI_THINKING_STRUCT->funcResult < *value) gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 5); else gAIScriptPtr += 9; } -static void BattleAICmd_if_more_than_32(void) +static void BattleAICmd_if_more_than_ptr(void) { - const u8 *temp = AIScriptReadPtr(gAIScriptPtr + 1); + const u8 *value = AIScriptReadPtr(gAIScriptPtr + 1); - if (AI_THINKING_STRUCT->funcResult > *temp) + if (AI_THINKING_STRUCT->funcResult > *value) gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 5); else gAIScriptPtr += 9; } -static void BattleAICmd_if_equal_32(void) +static void BattleAICmd_if_equal_ptr(void) { - const u8 *temp = AIScriptReadPtr(gAIScriptPtr + 1); + const u8 *value = AIScriptReadPtr(gAIScriptPtr + 1); - if (AI_THINKING_STRUCT->funcResult == *temp) + if (AI_THINKING_STRUCT->funcResult == *value) gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 5); else gAIScriptPtr += 9; } -static void BattleAICmd_if_not_equal_32(void) +static void BattleAICmd_if_not_equal_ptr(void) { - const u8 *temp = AIScriptReadPtr(gAIScriptPtr + 1); + const u8 *value = AIScriptReadPtr(gAIScriptPtr + 1); - if (AI_THINKING_STRUCT->funcResult != *temp) + if (AI_THINKING_STRUCT->funcResult != *value) gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 5); else gAIScriptPtr += 9; @@ -1083,7 +1083,7 @@ static void BattleAICmd_if_not_in_hwords(void) gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 5); } -static void BattleAICmd_if_user_can_damage(void) +static void BattleAICmd_if_user_has_attacking_move(void) { s32 i; @@ -1099,7 +1099,7 @@ static void BattleAICmd_if_user_can_damage(void) gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 1); } -static void BattleAICmd_if_user_cant_damage(void) +static void BattleAICmd_if_user_has_no_attacking_moves(void) { s32 i; @@ -1168,23 +1168,23 @@ static void BattleAICmd_is_of_type(void) if(gBattleMons[bank].type1 == gAIScriptPtr[2] || gBattleMons[bank].type2 == gAIScriptPtr[2]) { - AI_THINKING_STRUCT->funcResult = 1; + AI_THINKING_STRUCT->funcResult = TRUE; } else { - AI_THINKING_STRUCT->funcResult = 0; + AI_THINKING_STRUCT->funcResult = FALSE; } gAIScriptPtr += 3; } -static void BattleAICmd_get_last_used_bank_move_power(void) +static void BattleAICmd_get_considered_move_power(void) { AI_THINKING_STRUCT->funcResult = gBattleMoves[AI_THINKING_STRUCT->moveConsidered].power; gAIScriptPtr += 1; } -static void BattleAICmd_is_most_powerful_move(void) +static void BattleAICmd_get_how_powerful_move_is(void) { s32 i, checkedMove; s32 moveDmgs[4]; @@ -1258,7 +1258,7 @@ static void BattleAICmd_get_last_used_bank_move(void) gAIScriptPtr += 2; } -static void BattleAICmd_if_arg_equal(void) +static void BattleAICmd_if_equal_(void) // same as if_equal { if (gAIScriptPtr[1] == AI_THINKING_STRUCT->funcResult) gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 2); @@ -1266,7 +1266,7 @@ static void BattleAICmd_if_arg_equal(void) gAIScriptPtr += 6; } -static void BattleAICmd_if_arg_not_equal(void) +static void BattleAICmd_if_not_equal_(void) // same as if_not_equal { if (gAIScriptPtr[1] != AI_THINKING_STRUCT->funcResult) gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 2); @@ -1274,7 +1274,7 @@ static void BattleAICmd_if_arg_not_equal(void) gAIScriptPtr += 6; } -static void BattleAICmd_if_would_go_first(void) +static void BattleAICmd_if_user_goes(void) { if (GetWhoStrikesFirst(sBank_AI, gBankTarget, TRUE) == gAIScriptPtr[1]) gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 2); @@ -1282,7 +1282,7 @@ static void BattleAICmd_if_would_go_first(void) gAIScriptPtr += 6; } -static void BattleAICmd_if_would_not_go_first(void) +static void BattleAICmd_if_user_doesnt_go(void) { if (GetWhoStrikesFirst(sBank_AI, gBankTarget, TRUE) != gAIScriptPtr[1]) gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 2); @@ -1298,7 +1298,7 @@ static void BattleAICmd_nullsub_2B(void) { } -static void BattleAICmd_count_alive_pokemon(void) +static void BattleAICmd_count_usable_party_mons(void) { u8 bank; u8 bankOnField1, bankOnField2; @@ -1319,10 +1319,10 @@ static void BattleAICmd_count_alive_pokemon(void) if (gBattleTypeFlags & BATTLE_TYPE_DOUBLE) { - u32 status; + u32 identity; bankOnField1 = gBattlePartyID[bank]; - status = GetBankIdentity(bank) ^ 2; - bankOnField2 = gBattlePartyID[GetBankByIdentity(status)]; + identity = GetBankIdentity(bank) ^ BIT_MON; + bankOnField2 = gBattlePartyID[GetBankByIdentity(identity)]; } else // in singles there's only one bank by side { @@ -1330,7 +1330,7 @@ static void BattleAICmd_count_alive_pokemon(void) bankOnField2 = gBattlePartyID[bank]; } - for (i = 0; i < 6; i++) + for (i = 0; i < PARTY_SIZE; i++) { if (i != bankOnField1 && i != bankOnField2 && GetMonData(&party[i], MON_DATA_HP) != 0 @@ -1365,9 +1365,9 @@ static void BattleAICmd_get_ability(void) else bank = gBankTarget; - if(gActiveBank != bank) + if (gActiveBank != bank) { - if(BATTLE_HISTORY->abilities[bank] != 0) + if (BATTLE_HISTORY->abilities[bank] != 0) { AI_THINKING_STRUCT->funcResult = BATTLE_HISTORY->abilities[bank]; gAIScriptPtr += 2; @@ -1581,11 +1581,11 @@ static void BattleAICmd_if_status_in_party(void) break; } - party = (GetBankSide(bank) == 0) ? gPlayerParty : gEnemyParty; + party = (GetBankSide(bank) == SIDE_PLAYER) ? gPlayerParty : gEnemyParty; statusToCompareTo = AIScriptRead32(gAIScriptPtr + 2); - for (i = 0; i < 6; i++) + for (i = 0; i < PARTY_SIZE; i++) { u16 species = GetMonData(&party[i], MON_DATA_SPECIES); u16 hp = GetMonData(&party[i], MON_DATA_HP); @@ -1622,7 +1622,7 @@ static void BattleAICmd_if_status_not_in_party(void) statusToCompareTo = AIScriptRead32(gAIScriptPtr + 2); - for (i = 0; i < 6; i++) + for (i = 0; i < PARTY_SIZE; i++) { u16 species = GetMonData(&party[i], MON_DATA_SPECIES); u16 hp = GetMonData(&party[i], MON_DATA_HP); @@ -1786,14 +1786,14 @@ static void BattleAICmd_if_cant_faint(void) static void BattleAICmd_if_has_move(void) { int i; - const u16 *temp_ptr = (u16 *)(gAIScriptPtr + 2); + const u16 *movePtr = (u16 *)(gAIScriptPtr + 2); - switch(gAIScriptPtr[1]) + switch (gAIScriptPtr[1]) { case AI_USER: for (i = 0; i < 4; i++) { - if (gBattleMons[sBank_AI].moves[i] == *temp_ptr) + if (gBattleMons[sBank_AI].moves[i] == *movePtr) break; } if (i == 4) @@ -1807,7 +1807,7 @@ static void BattleAICmd_if_has_move(void) return; } case AI_USER_PARTNER: - if (gBattleMons[sBank_AI ^ 2].hp == 0) + if (gBattleMons[sBank_AI ^ BIT_MON].hp == 0) { gAIScriptPtr += 8; return; @@ -1816,7 +1816,7 @@ static void BattleAICmd_if_has_move(void) { for (i = 0; i < 4; i++) { - if (gBattleMons[sBank_AI ^ 2].moves[i] == *temp_ptr) + if (gBattleMons[sBank_AI ^ BIT_MON].moves[i] == *movePtr) break; } } @@ -1834,7 +1834,7 @@ static void BattleAICmd_if_has_move(void) case AI_TARGET_PARTNER: for (i = 0; i < 4; i++) { - if (BATTLE_HISTORY->usedMoves[gBankTarget].moves[i] == *temp_ptr) + if (BATTLE_HISTORY->usedMoves[gBankTarget].moves[i] == *movePtr) break; } if (i == 4) @@ -1850,10 +1850,10 @@ static void BattleAICmd_if_has_move(void) } } -static void BattleAICmd_if_dont_have_move(void) +static void BattleAICmd_if_doesnt_have_move(void) { int i; - const u16 *temp_ptr = (u16 *)(gAIScriptPtr + 2); + const u16 *movePtr = (u16 *)(gAIScriptPtr + 2); switch(gAIScriptPtr[1]) { @@ -1861,7 +1861,7 @@ static void BattleAICmd_if_dont_have_move(void) case AI_USER_PARTNER: // UB: no separate check for user partner for (i = 0; i < 4; i++) { - if (gBattleMons[sBank_AI].moves[i] == *temp_ptr) + if (gBattleMons[sBank_AI].moves[i] == *movePtr) break; } if (i != 4) @@ -1878,7 +1878,7 @@ static void BattleAICmd_if_dont_have_move(void) case AI_TARGET_PARTNER: for (i = 0; i < 4; i++) { - if (BATTLE_HISTORY->usedMoves[gBankTarget].moves[i] == *temp_ptr) + if (BATTLE_HISTORY->usedMoves[gBankTarget].moves[i] == *movePtr) break; } if (i != 4) @@ -1894,7 +1894,7 @@ static void BattleAICmd_if_dont_have_move(void) } } -static void BattleAICmd_if_move_effect(void) +static void BattleAICmd_if_has_move_with_effect(void) { int i; @@ -1927,7 +1927,7 @@ static void BattleAICmd_if_move_effect(void) } } -static void BattleAICmd_if_not_move_effect(void) +static void BattleAICmd_if_doesnt_have_move_with_effect(void) { int i; @@ -2023,7 +2023,7 @@ static void BattleAICmd_flee(void) AI_THINKING_STRUCT->aiAction |= (AI_ACTION_DONE | AI_ACTION_FLEE | AI_ACTION_DO_NOT_ATTACK); } -static void BattleAICmd_if_random_100(void) +static void BattleAICmd_if_random_safari_flee(void) { u8 safariFleeRate = gBattleStruct->field_7B * 5; // safari flee rate, from 0-20 @@ -2041,7 +2041,6 @@ static void BattleAICmd_watch(void) static void BattleAICmd_get_hold_effect(void) { u8 bank; - u16 status; if (gAIScriptPtr[1] == AI_USER) bank = sBank_AI; @@ -2049,9 +2048,7 @@ static void BattleAICmd_get_hold_effect(void) bank = gBankTarget; if (gActiveBank != bank) - { AI_THINKING_STRUCT->funcResult = ItemId_GetHoldEffect(BATTLE_HISTORY->itemEffects[bank]); - } else AI_THINKING_STRUCT->funcResult = ItemId_GetHoldEffect(gBattleMons[bank].item); @@ -2093,7 +2090,7 @@ static void BattleAICmd_get_gender(void) gAIScriptPtr += 2; } -static void BattleAICmd_is_first_turn(void) +static void BattleAICmd_is_first_turn_for(void) { u8 bank; @@ -2212,7 +2209,7 @@ static void BattleAICmd_call(void) gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 1); } -static void BattleAICmd_jump(void) +static void BattleAICmd_goto(void) { gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 1); } @@ -2272,7 +2269,7 @@ static void BattleAICmd_if_target_not_taunted(void) static void BattleAICmd_if_target_is_ally(void) { - if((sBank_AI & 1) == (gBankTarget & 1)) + if ((sBank_AI & BIT_SIDE) == (gBankTarget & BIT_SIDE)) gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 1); else gAIScriptPtr += 5; @@ -2282,7 +2279,7 @@ static void BattleAICmd_if_flash_fired(void) { u8 bank = BattleAI_GetWantedBank(gAIScriptPtr[1]); - if(gBattleResources->flags->flags[bank] & UNKNOWN_FLAG_FLASH_FIRE) + if (gBattleResources->flags->flags[bank] & UNKNOWN_FLAG_FLASH_FIRE) gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 2); else gAIScriptPtr += 6; From ca29ad22e8522910e906863e3ab0bfe1f0686d48 Mon Sep 17 00:00:00 2001 From: DizzyEggg Date: Sat, 30 Dec 2017 16:04:31 +0100 Subject: [PATCH 3/3] dump trainer ai scripts --- asm/macros/battle_ai_script.inc | 619 ++++++ data/battle_ai_scripts.s | 3436 ++++++++++++++++++++++++++++++- include/constants/battle_ai.h | 52 + src/battle_ai_script_commands.c | 80 +- 4 files changed, 4083 insertions(+), 104 deletions(-) create mode 100644 asm/macros/battle_ai_script.inc create mode 100644 include/constants/battle_ai.h diff --git a/asm/macros/battle_ai_script.inc b/asm/macros/battle_ai_script.inc new file mode 100644 index 000000000..5e81686bf --- /dev/null +++ b/asm/macros/battle_ai_script.inc @@ -0,0 +1,619 @@ + .macro if_random_less_than param0, param1 + .byte 0x0 + .byte \param0 + .4byte \param1 + .endm + + .macro if_random_greater_than param0, param1 + .byte 0x1 + .byte \param0 + .4byte \param1 + .endm + + .macro if_random_equal param0, param1 + .byte 0x2 + .byte \param0 + .4byte \param1 + .endm + + .macro if_random_not_equal param0, param1 + .byte 0x3 + .byte \param0 + .4byte \param1 + .endm + + .macro score param0 + .byte 0x4 + .byte \param0 + .endm + + .macro if_hp_less_than bank, param1, param2 + .byte 0x5 + .byte \bank + .byte \param1 + .4byte \param2 + .endm + + .macro if_hp_more_than bank, param1, param2 + .byte 0x6 + .byte \bank + .byte \param1 + .4byte \param2 + .endm + + .macro if_hp_equal bank, param1, param2 + .byte 0x7 + .byte \bank + .byte \param1 + .4byte \param2 + .endm + + .macro if_hp_not_equal bank, param1, param2 + .byte 0x8 + .byte \bank + .byte \param1 + .4byte \param2 + .endm + + .macro if_status bank, status1, param2 + .byte 0x9 + .byte \bank + .4byte \status1 + .4byte \param2 + .endm + + .macro if_not_status bank, status1, param2 + .byte 0xa + .byte \bank + .4byte \status1 + .4byte \param2 + .endm + + .macro if_status2 bank, status2, param2 + .byte 0xb + .byte \bank + .4byte \status2 + .4byte \param2 + .endm + + .macro if_not_status2 bank, status2, param2 + .byte 0xc + .byte \bank + .4byte \status2 + .4byte \param2 + .endm + + .macro if_status3 bank, status3, param2 + .byte 0xd + .byte \bank + .4byte \status3 + .4byte \param2 + .endm + + .macro if_not_status3 bank, status3, param2 + .byte 0xe + .byte \bank + .4byte \status3 + .4byte \param2 + .endm + + .macro if_side_affecting bank, sidestatus, param2 + .byte 0xf + .byte \bank + .4byte \sidestatus + .4byte \param2 + .endm + + .macro if_not_side_affecting bank, sidestatus, param2 + .byte 0x10 + .byte \bank + .4byte \sidestatus + .4byte \param2 + .endm + + .macro if_less_than param0, param1 + .byte 0x11 + .byte \param0 + .4byte \param1 + .endm + + .macro if_more_than param0, param1 + .byte 0x12 + .byte \param0 + .4byte \param1 + .endm + + .macro if_equal param0, param1 + .byte 0x13 + .byte \param0 + .4byte \param1 + .endm + + .macro if_not_equal param0, param1 + .byte 0x14 + .byte \param0 + .4byte \param1 + .endm + + .macro if_less_than_ptr param0, param1 + .byte 0x15 + .4byte \param0 + .4byte \param1 + .endm + + .macro if_more_than_ptr param0, param1 + .byte 0x16 + .4byte \param0 + .4byte \param1 + .endm + + .macro if_equal_ptr param0, param1 + .byte 0x17 + .4byte \param0 + .4byte \param1 + .endm + + .macro if_not_equal_ptr param0, param1 + .byte 0x18 + .4byte \param0 + .4byte \param1 + .endm + + .macro if_move param0, param1 + .byte 0x19 + .2byte \param0 + .4byte \param1 + .endm + + .macro if_not_move param0, param1 + .byte 0x1a + .2byte \param0 + .4byte \param1 + .endm + + .macro if_in_bytes param0, param1 + .byte 0x1b + .4byte \param0 + .4byte \param1 + .endm + + .macro if_not_in_bytes param0, param1 + .byte 0x1c + .4byte \param0 + .4byte \param1 + .endm + + .macro if_in_hwords param0, param1 + .byte 0x1d + .4byte \param0 + .4byte \param1 + .endm + + .macro if_not_in_hwords param0, param1 + .byte 0x1e + .4byte \param0 + .4byte \param1 + .endm + + .macro if_user_has_attacking_move param0 + .byte 0x1f + .4byte \param0 + .endm + + .macro if_user_has_no_attacking_moves param0 + .byte 0x20 + .4byte \param0 + .endm + + .macro get_turn_count + .byte 0x21 + .endm + + .macro get_type param0 + .byte 0x22 + .byte \param0 + .endm + + .macro get_considered_move_power + .byte 0x23 + .endm + + .macro get_how_powerful_move_is + .byte 0x24 + .endm + + .macro get_last_used_bank_move bank + .byte 0x25 + .byte \bank + .endm + + .macro if_equal_ param0, param1 + .byte 0x26 + .byte \param0 + .4byte \param1 + .endm + + .macro if_not_equal_ param0, param1 + .byte 0x27 + .byte \param0 + .4byte \param1 + .endm + + .macro if_user_goes param0, param1 + .byte 0x28 + .byte \param0 + .4byte \param1 + .endm + + .macro if_user_doesnt_go param0, param1 + .byte 0x29 + .byte \param0 + .4byte \param1 + .endm + + .macro nullsub_2A + .byte 0x2a + .endm + + .macro nullsub_2B + .byte 0x2b + .endm + + .macro count_usable_party_mons bank + .byte 0x2c + .byte \bank + .endm + + .macro get_considered_move + .byte 0x2d + .endm + + .macro get_considered_move_effect + .byte 0x2e + .endm + + .macro get_ability bank + .byte 0x2f + .byte \bank + .endm + + .macro get_highest_type_effectiveness + .byte 0x30 + .endm + + .macro if_type_effectiveness param0, param1 + .byte 0x31 + .byte \param0 + .4byte \param1 + .endm + + .macro nullsub_32 + .byte 0x32 + .endm + + .macro nullsub_33 + .byte 0x33 + .endm + + .macro if_status_in_party bank, status1, param2 + .byte 0x34 + .byte \bank + .4byte \status1 + .4byte \param2 + .endm + + .macro if_status_not_in_party bank, status1, param2 + .byte 0x35 + .byte \bank + .4byte \status1 + .4byte \param2 + .endm + + .macro get_weather + .byte 0x36 + .endm + + .macro if_effect param0, param1 + .byte 0x37 + .byte \param0 + .4byte \param1 + .endm + + .macro if_not_effect param0, param1 + .byte 0x38 + .byte \param0 + .4byte \param1 + .endm + + .macro if_stat_level_less_than bank, stat, param2, param3 + .byte 0x39 + .byte \bank + .byte \stat + .byte \param2 + .4byte \param3 + .endm + + .macro if_stat_level_more_than bank, stat, param2, param3 + .byte 0x3a + .byte \bank + .byte \stat + .byte \param2 + .4byte \param3 + .endm + + .macro if_stat_level_equal bank, stat, param2, param3 + .byte 0x3b + .byte \bank + .byte \stat + .byte \param2 + .4byte \param3 + .endm + + .macro if_stat_level_not_equal bank, stat, param2, param3 + .byte 0x3c + .byte \bank + .byte \stat + .byte \param2 + .4byte \param3 + .endm + + .macro if_can_faint param0 + .byte 0x3d + .4byte \param0 + .endm + + .macro if_cant_faint param0 + .byte 0x3e + .4byte \param0 + .endm + + .macro if_has_move bank, param1, param2 + .byte 0x3f + .byte \bank + .2byte \param1 + .4byte \param2 + .endm + + .macro if_doesnt_have_move bank, param1, param2 + .byte 0x40 + .byte \bank + .2byte \param1 + .4byte \param2 + .endm + + .macro if_has_move_with_effect bank, param1, param2 + .byte 0x41 + .byte \bank + .byte \param1 + .4byte \param2 + .endm + + .macro if_doesnt_have_move_with_effect bank, param1, param2 + .byte 0x42 + .byte \bank + .byte \param1 + .4byte \param2 + .endm + + .macro if_any_move_disabled_or_encored bank, param1, param2 + .byte 0x43 + .byte \bank + .byte \param1 + .4byte \param2 + .endm + + .macro if_curr_move_disabled_or_encored param0, param1 + .byte 0x44 + .byte \param0 + .4byte \param1 + .endm + + .macro flee + .byte 0x45 + .endm + + .macro if_random_safari_flee param0 + .byte 0x46 + .4byte \param0 + .endm + + .macro watch + .byte 0x47 + .endm + + .macro get_hold_effect bank + .byte 0x48 + .byte \bank + .endm + + .macro get_gender bank + .byte 0x49 + .byte \bank + .endm + + .macro is_first_turn_for bank + .byte 0x4a + .byte \bank + .endm + + .macro get_stockpile_count bank + .byte 0x4b + .byte \bank + .endm + + .macro is_double_battle + .byte 0x4c + .endm + + .macro get_used_held_item bank + .byte 0x4d + .byte \bank + .endm + + .macro get_move_type_from_result + .byte 0x4e + .endm + + .macro get_move_power_from_result + .byte 0x4f + .endm + + .macro get_move_effect_from_result + .byte 0x50 + .endm + + .macro get_protect_count bank + .byte 0x51 + .byte \bank + .endm + + .macro nullsub_52 + .byte 0x52 + .endm + + .macro nullsub_53 + .byte 0x53 + .endm + + .macro nullsub_54 + .byte 0x54 + .endm + + .macro nullsub_55 + .byte 0x55 + .endm + + .macro nullsub_56 + .byte 0x56 + .endm + + .macro nullsub_57 + .byte 0x57 + .endm + + .macro call param0 + .byte 0x58 + .4byte \param0 + .endm + + .macro goto param0 + .byte 0x59 + .4byte \param0 + .endm + + .macro end + .byte 0x5a + .endm + + .macro if_level_cond param0, param1 + .byte 0x5b + .byte \param0 + .4byte \param1 + .endm + + .macro if_target_taunted param0 + .byte 0x5c + .4byte \param0 + .endm + + .macro if_target_not_taunted param0 + .byte 0x5d + .4byte \param0 + .endm + + .macro if_target_is_ally param0 + .byte 0x5e + .4byte \param0 + .endm + + .macro is_of_type bank, type + .byte 0x5f + .byte \bank + .byte \type + .endm + + .macro check_ability bank, ability + .byte 0x60 + .byte \bank + .byte \ability + .endm + + .macro if_flash_fired bank, param1 + .byte 0x61 + .byte \bank + .4byte \param1 + .endm + + .macro if_holds_item bank, param1, param2 + .byte 0x62 + .byte \bank + .2byte \param1 + .4byte \param2 + .endm + +@ useful script macros + .macro get_curr_move_type + get_type AI_TYPE_MOVE + .endm + + .macro get_user_type1 + get_type AI_TYPE1_USER + .endm + + .macro get_user_type2 + get_type AI_TYPE2_USER + .endm + + .macro get_target_type1 + get_type AI_TYPE1_TARGET + .endm + + .macro get_target_type2 + get_type AI_TYPE2_TARGET + .endm + + .macro if_ability bank, ability, ptr + check_ability \bank, \ability + if_equal 1, \ptr + .endm + + .macro if_no_ability bank, ability, ptr + check_ability \bank, \ability + if_equal 0, \ptr + .endm + + .macro if_type bank, type, ptr + is_of_type \bank, \type + if_equal 1, \ptr + .endm + + .macro if_no_type bank, type, ptr + is_of_type \bank, \type + if_equal 0, \ptr + .endm + + .macro if_target_faster ptr + if_user_goes 1, \ptr + .endm + + .macro if_user_faster ptr + if_user_goes 0, \ptr + .endm + + .macro if_double_battle ptr + is_double_battle + if_equal 1, \ptr + .endm + + .macro if_not_double_battle ptr + is_double_battle + if_equal 0, \ptr + .endm + + .macro if_any_move_disabled bank, ptr + if_any_move_disabled_or_encored \bank, 0, \ptr + .endm + + .macro if_any_move_encored bank, ptr + if_any_move_disabled_or_encored \bank, 1, \ptr + .endm diff --git a/data/battle_ai_scripts.s b/data/battle_ai_scripts.s index 834c4bf9d..2b9b6864b 100644 --- a/data/battle_ai_scripts.s +++ b/data/battle_ai_scripts.s @@ -1,81 +1,3393 @@ - .include "asm/macros.inc" - .include "constants/constants.inc" + .include "include/constants/battle_ai.h" + .include "include/constants/abilities.h" + .include "include/constants/items.h" + .include "include/constants/moves.h" + .include "include/constants/battle_move_effects.h" + .include "include/constants/hold_effects.h" + .include "constants/battle_constants.inc" + .include "constants/type_constants.inc" + .include "asm/macros/battle_ai_script.inc" .section script_data, "aw", %progbits .align 2 gBattleAI_ScriptsTable:: @ 82DBEF8 - .4byte gBattleAIScript_82DBF78 - .4byte gBattleAIScript_82DDE3F - .4byte gBattleAIScript_82DC7B0 - .4byte gBattleAIScript_82DDE71 - .4byte gBattleAIScript_82DDEDD - .4byte gBattleAIScript_82DDEC8 - .4byte gBattleAIScript_82DDF09 - .4byte gBattleAIScript_82DDFB4 - .4byte gBattleAIScript_82DE193 - .4byte gBattleAIScript_82DE2ED - .4byte gBattleAIScript_82DE34E - .4byte gBattleAIScript_82DE34E - .4byte gBattleAIScript_82DE34E - .4byte gBattleAIScript_82DE34E - .4byte gBattleAIScript_82DE34E - .4byte gBattleAIScript_82DE34E - .4byte gBattleAIScript_82DE34E - .4byte gBattleAIScript_82DE34E - .4byte gBattleAIScript_82DE34E - .4byte gBattleAIScript_82DE34E - .4byte gBattleAIScript_82DE34E - .4byte gBattleAIScript_82DE34E - .4byte gBattleAIScript_82DE34E - .4byte gBattleAIScript_82DE34E - .4byte gBattleAIScript_82DE34E - .4byte gBattleAIScript_82DE34E - .4byte gBattleAIScript_82DE34E - .4byte gBattleAIScript_82DE34E - .4byte gBattleAIScript_82DE34E - .4byte gBattleAIScript_82DE309 - .4byte gBattleAIScript_82DE337 - .4byte gBattleAIScript_82DE33E + .4byte AI_CheckBadMove + .4byte AI_CheckViability + .4byte AI_TryToFaint + .4byte AI_SetupFirstTurn + .4byte AI_Risky + .4byte AI_PreferStrongestMove + .4byte AI_PreferBatonPass + .4byte AI_DoubleBattle + .4byte AI_HPAware + .4byte AI_Unknown + .4byte AI_Ret + .4byte AI_Ret + .4byte AI_Ret + .4byte AI_Ret + .4byte AI_Ret + .4byte AI_Ret + .4byte AI_Ret + .4byte AI_Ret + .4byte AI_Ret + .4byte AI_Ret + .4byte AI_Ret + .4byte AI_Ret + .4byte AI_Ret + .4byte AI_Ret + .4byte AI_Ret + .4byte AI_Ret + .4byte AI_Ret + .4byte AI_Ret + .4byte AI_Ret + .4byte AI_Roaming + .4byte AI_Safari + .4byte AI_FirstBattle -gBattleAIScript_82DBF78:: @ 82DBF78 - .incbin "baserom.gba", 0x2dbf78, 0x838 +AI_CheckBadMove: + if_target_is_ally AI_Ret + if_move MOVE_FISSURE, BattleAIScript_82DBF92 + if_move MOVE_HORN_DRILL, BattleAIScript_82DBF92 + get_how_powerful_move_is + if_equal 0, BattleAIScript_82DBFFE -gBattleAIScript_82DC7B0:: @ 82DC7B0 - .incbin "baserom.gba", 0x2dc7b0, 0x168F +BattleAIScript_82DBF92: + if_type_effectiveness AI_EFFECTIVENESS_x0, Score_Minus10 + get_ability AI_TARGET + if_equal ABILITY_VOLT_ABSORB, BattleAIScript_82DBFBD + if_equal ABILITY_WATER_ABSORB, BattleAIScript_82DBFCA + if_equal ABILITY_FLASH_FIRE, BattleAIScript_82DBFD7 + if_equal ABILITY_WONDER_GUARD, BattleAIScript_82DBFE4 + if_equal ABILITY_LEVITATE, BattleAIScript_82DBFEF + goto BattleAIScript_82DBFF7 -gBattleAIScript_82DDE3F:: @ 82DDE3F - .incbin "baserom.gba", 0x2dde3f, 0x32 +BattleAIScript_82DBFBD: + get_curr_move_type + if_equal_ TYPE_ELECTRIC, Score_Minus12 + goto BattleAIScript_82DBFF7 -gBattleAIScript_82DDE71:: @ 82DDE71 - .incbin "baserom.gba", 0x2dde71, 0x57 +BattleAIScript_82DBFCA: + get_curr_move_type + if_equal_ TYPE_WATER, Score_Minus12 + goto BattleAIScript_82DBFF7 -gBattleAIScript_82DDEC8:: @ 82DDEC8 - .incbin "baserom.gba", 0x2ddec8, 0x15 +BattleAIScript_82DBFD7: + get_curr_move_type + if_equal_ TYPE_FIRE, Score_Minus12 + goto BattleAIScript_82DBFF7 -gBattleAIScript_82DDEDD:: @ 82DDEDD - .incbin "baserom.gba", 0x2ddedd, 0x2c +BattleAIScript_82DBFE4: + if_type_effectiveness AI_EFFECTIVENESS_x2, BattleAIScript_82DBFF7 + goto Score_Minus10 -gBattleAIScript_82DDF09:: @ 82DDF09 - .incbin "baserom.gba", 0x2ddf09, 0xab +BattleAIScript_82DBFEF: + get_curr_move_type + if_equal_ TYPE_GROUND, Score_Minus10 -gBattleAIScript_82DDFB4:: @ 82DDFB4 - .incbin "baserom.gba", 0x2ddfb4, 0x1df +BattleAIScript_82DBFF7: + get_how_powerful_move_is + if_equal 0, BattleAIScript_82DBFFE -gBattleAIScript_82DE193:: @ 82DE193 - .incbin "baserom.gba", 0x2de193, 0x15a +BattleAIScript_82DBFFE: + get_ability AI_TARGET + if_not_equal ABILITY_SOUNDPROOF, BattleAIScript_82DC045 + if_move MOVE_GROWL, Score_Minus10 + if_move MOVE_ROAR, Score_Minus10 + if_move MOVE_SING, Score_Minus10 + if_move MOVE_SUPERSONIC, Score_Minus10 + if_move MOVE_SCREECH, Score_Minus10 + if_move MOVE_SNORE, Score_Minus10 + if_move MOVE_UPROAR, Score_Minus10 + if_move MOVE_METAL_SOUND, Score_Minus10 + if_move MOVE_GRASS_WHISTLE, Score_Minus10 -gBattleAIScript_82DE2ED:: @ 82DE2ED - .incbin "baserom.gba", 0x2de2ed, 0x1c +BattleAIScript_82DC045: + if_effect EFFECT_SLEEP, BattleAIScript_82DC2D4 + if_effect EFFECT_EXPLOSION, BattleAIScript_82DC2F7 + if_effect EFFECT_DREAM_EATER, BattleAIScript_82DC330 + if_effect EFFECT_ATTACK_UP, BattleAIScript_82DC348 + if_effect EFFECT_DEFENSE_UP, BattleAIScript_82DC351 + if_effect EFFECT_SPEED_UP, BattleAIScript_82DC35A + if_effect EFFECT_SPECIAL_ATTACK_UP, BattleAIScript_82DC363 + if_effect EFFECT_SPECIAL_DEFENSE_UP, BattleAIScript_82DC36C + if_effect EFFECT_ACCURACY_UP, BattleAIScript_82DC375 + if_effect EFFECT_EVASION_UP, BattleAIScript_82DC37E + if_effect EFFECT_ATTACK_DOWN, BattleAIScript_82DC387 + if_effect EFFECT_DEFENSE_DOWN, BattleAIScript_82DC39C + if_effect EFFECT_SPEED_DOWN, BattleAIScript_82DC3A9 + if_effect EFFECT_SPECIAL_ATTACK_DOWN, BattleAIScript_82DC3BF + if_effect EFFECT_SPECIAL_DEFENSE_DOWN, BattleAIScript_82DC3CC + if_effect EFFECT_ACCURACY_DOWN, BattleAIScript_82DC3D9 + if_effect EFFECT_EVASION_DOWN, BattleAIScript_82DC3EE + if_effect EFFECT_HAZE, BattleAIScript_82DC405 + if_effect EFFECT_BIDE, BattleAIScript_82DC4ED + if_effect EFFECT_ROAR, BattleAIScript_82DC47B + if_effect EFFECT_TOXIC, BattleAIScript_82DC48C + if_effect EFFECT_LIGHT_SCREEN, BattleAIScript_82DC4C5 + if_effect EFFECT_OHKO, BattleAIScript_82DC4D0 + if_effect EFFECT_RAZOR_WIND, BattleAIScript_82DC4ED + if_effect EFFECT_SUPER_FANG, BattleAIScript_82DC4ED + if_effect EFFECT_MIST, BattleAIScript_82DC507 + if_effect EFFECT_FOCUS_ENERGY, BattleAIScript_82DC512 + if_effect EFFECT_CONFUSE, BattleAIScript_82DC51D + if_effect EFFECT_ATTACK_UP_2, BattleAIScript_82DC348 + if_effect EFFECT_DEFENSE_UP_2, BattleAIScript_82DC351 + if_effect EFFECT_SPEED_UP_2, BattleAIScript_82DC35A + if_effect EFFECT_SPECIAL_ATTACK_UP_2, BattleAIScript_82DC363 + if_effect EFFECT_SPECIAL_DEFENSE_UP_2, BattleAIScript_82DC36C + if_effect EFFECT_ACCURACY_UP_2, BattleAIScript_82DC375 + if_effect EFFECT_EVASION_UP_2, BattleAIScript_82DC37E + if_effect EFFECT_ATTACK_DOWN_2, BattleAIScript_82DC387 + if_effect EFFECT_DEFENSE_DOWN_2, BattleAIScript_82DC39C + if_effect EFFECT_SPEED_DOWN_2, BattleAIScript_82DC3A9 + if_effect EFFECT_SPECIAL_ATTACK_DOWN_2, BattleAIScript_82DC3BF + if_effect EFFECT_SPECIAL_DEFENSE_DOWN_2, BattleAIScript_82DC3CC + if_effect EFFECT_ACCURACY_DOWN_2, BattleAIScript_82DC3D9 + if_effect EFFECT_EVASION_DOWN_2, BattleAIScript_82DC3EE + if_effect EFFECT_REFLECT, BattleAIScript_82DC53A + if_effect EFFECT_POISON, BattleAIScript_82DC48C + if_effect EFFECT_PARALYZE, BattleAIScript_82DC545 + if_effect EFFECT_SUBSTITUTE, BattleAIScript_82DC568 + if_effect EFFECT_RECHARGE, BattleAIScript_82DC4ED + if_effect EFFECT_LEECH_SEED, BattleAIScript_82DC57A + if_effect EFFECT_DISABLE, BattleAIScript_82DC595 + if_effect EFFECT_LEVEL_DAMAGE, BattleAIScript_82DC4ED + if_effect EFFECT_PSYWAVE, BattleAIScript_82DC4ED + if_effect EFFECT_COUNTER, BattleAIScript_82DC4ED + if_effect EFFECT_ENCORE, BattleAIScript_82DC59D + if_effect EFFECT_SNORE, BattleAIScript_82DC5A5 + if_effect EFFECT_SLEEP_TALK, BattleAIScript_82DC5A5 + if_effect EFFECT_FLAIL, BattleAIScript_82DC4ED + if_effect EFFECT_MEAN_LOOK, BattleAIScript_82DC5B0 + if_effect EFFECT_NIGHTMARE, BattleAIScript_82DC31B + if_effect EFFECT_MINIMIZE, BattleAIScript_82DC37E + if_effect EFFECT_CURSE, BattleAIScript_82DC5BB + if_effect EFFECT_SPIKES, BattleAIScript_82DC5CC + if_effect EFFECT_FORESIGHT, BattleAIScript_82DC5D7 + if_effect EFFECT_PERISH_SONG, BattleAIScript_82DC5E2 + if_effect EFFECT_SANDSTORM, BattleAIScript_82DC5ED + if_effect EFFECT_SWAGGER, BattleAIScript_82DC51D + if_effect EFFECT_ATTRACT, BattleAIScript_82DC5F5 + if_effect EFFECT_RETURN, BattleAIScript_82DC4ED + if_effect EFFECT_PRESENT, BattleAIScript_82DC4ED + if_effect EFFECT_FRUSTRATION, BattleAIScript_82DC4ED + if_effect EFFECT_SAFEGUARD, BattleAIScript_82DC635 + if_effect EFFECT_MAGNITUDE, BattleAIScript_82DC4E5 + if_effect EFFECT_BATON_PASS, BattleAIScript_82DC650 + if_effect EFFECT_SONICBOOM, BattleAIScript_82DC4ED + if_effect EFFECT_RAIN_DANCE, BattleAIScript_82DC659 + if_effect EFFECT_SUNNY_DAY, BattleAIScript_82DC661 + if_effect EFFECT_BELLY_DRUM, BattleAIScript_82DC341 + if_effect EFFECT_PSYCH_UP, BattleAIScript_82DC405 + if_effect EFFECT_MIRROR_COAT, BattleAIScript_82DC4ED + if_effect EFFECT_SKULL_BASH, BattleAIScript_82DC4ED + if_effect EFFECT_FUTURE_SIGHT, BattleAIScript_82DC669 + if_effect EFFECT_TELEPORT, Score_Minus10 + if_effect EFFECT_DEFENSE_CURL, BattleAIScript_82DC351 + if_effect EFFECT_FAKE_OUT, BattleAIScript_82DC680 + if_effect EFFECT_STOCKPILE, BattleAIScript_82DC689 + if_effect EFFECT_SPIT_UP, BattleAIScript_82DC692 + if_effect EFFECT_SWALLOW, BattleAIScript_82DC692 + if_effect EFFECT_HAIL, BattleAIScript_82DC6A1 + if_effect EFFECT_TORMENT, BattleAIScript_82DC6A9 + if_effect EFFECT_FLATTER, BattleAIScript_82DC51D + if_effect EFFECT_WILL_O_WISP, BattleAIScript_82DC6B4 + if_effect EFFECT_MEMENTO, BattleAIScript_82DC640 + if_effect EFFECT_FOCUS_PUNCH, BattleAIScript_82DC4ED + if_effect EFFECT_HELPING_HAND, BattleAIScript_82DC6E3 + if_effect EFFECT_TRICK, BattleAIScript_82DC6EB + if_effect EFFECT_INGRAIN, BattleAIScript_82DC6F4 + if_effect EFFECT_SUPERPOWER, BattleAIScript_82DC4ED + if_effect EFFECT_RECYCLE, BattleAIScript_82DC6FF + if_effect EFFECT_KNOCK_OFF, BattleAIScript_82DC6EB + if_effect EFFECT_ENDEAVOR, BattleAIScript_82DC4ED + if_effect EFFECT_IMPRISON, BattleAIScript_82DC708 + if_effect EFFECT_REFRESH, BattleAIScript_82DC713 + if_effect EFFECT_LOW_KICK, BattleAIScript_82DC4ED + if_effect EFFECT_MUD_SPORT, BattleAIScript_82DC71E + if_effect EFFECT_TICKLE, BattleAIScript_82DC729 + if_effect EFFECT_COSMIC_POWER, BattleAIScript_82DC73A + if_effect EFFECT_BULK_UP, BattleAIScript_82DC74B + if_effect EFFECT_WATER_SPORT, BattleAIScript_82DC75C + if_effect EFFECT_CALM_MIND, BattleAIScript_82DC767 + if_effect EFFECT_DRAGON_DANCE, BattleAIScript_82DC778 + end -gBattleAIScript_82DE309:: @ 82DE309 - .incbin "baserom.gba", 0x2de309, 0x2e +BattleAIScript_82DC2D4: + get_ability AI_TARGET + if_equal ABILITY_INSOMNIA, Score_Minus10 + if_equal ABILITY_VITAL_SPIRIT, Score_Minus10 + if_status AI_TARGET, STATUS_ANY, Score_Minus10 + if_side_affecting AI_TARGET, SIDE_STATUS_SAFEGUARD, Score_Minus10 + end -gBattleAIScript_82DE337:: @ 82DE337 - .incbin "baserom.gba", 0x2de337, 0x7 +BattleAIScript_82DC2F7: + if_type_effectiveness AI_EFFECTIVENESS_x0, Score_Minus10 + get_ability AI_TARGET + if_equal ABILITY_DAMP, Score_Minus10 + count_usable_party_mons AI_USER + if_not_equal 0, BattleAIScript_82DC31A + count_usable_party_mons AI_TARGET + if_not_equal 0, Score_Minus10 + goto Score_Minus1 -gBattleAIScript_82DE33E:: @ 82DE33E - .incbin "baserom.gba", 0x2de33e, 0x10 +BattleAIScript_82DC31A: + end -gBattleAIScript_82DE34E:: @ 82DE34E - .incbin "baserom.gba", 0x2de34e, 0x2 +BattleAIScript_82DC31B: + if_status2 AI_TARGET, STATUS2_NIGHTMARE, Score_Minus10 + if_not_status AI_TARGET, STATUS_SLEEP, Score_Minus8 + end + +BattleAIScript_82DC330: + if_not_status AI_TARGET, STATUS_SLEEP, Score_Minus8 + if_type_effectiveness AI_EFFECTIVENESS_x0, Score_Minus10 + end + +BattleAIScript_82DC341: + if_hp_less_than AI_USER, 51, Score_Minus10 + +BattleAIScript_82DC348: + if_stat_level_equal AI_USER, ATK, 12, Score_Minus10 + end + +BattleAIScript_82DC351: + if_stat_level_equal AI_USER, DEF, 12, Score_Minus10 + end + +BattleAIScript_82DC35A: + if_stat_level_equal AI_USER, SPEED, 12, Score_Minus10 + end + +BattleAIScript_82DC363: + if_stat_level_equal AI_USER, SPATK, 12, Score_Minus10 + end + +BattleAIScript_82DC36C: + if_stat_level_equal AI_USER, SPDEF, 12, Score_Minus10 + end + +BattleAIScript_82DC375: + if_stat_level_equal AI_USER, ACC, 12, Score_Minus10 + end + +BattleAIScript_82DC37E: + if_stat_level_equal AI_USER, EVASION, 12, Score_Minus10 + end + +BattleAIScript_82DC387: + if_stat_level_equal AI_TARGET, ATK, 0, Score_Minus10 + get_ability AI_TARGET + if_equal ABILITY_HYPER_CUTTER, Score_Minus10 + goto BattleAIScript_82DC3F6 + +BattleAIScript_82DC39C: + if_stat_level_equal AI_TARGET, DEF, 0, Score_Minus10 + goto BattleAIScript_82DC3F6 + +BattleAIScript_82DC3A9: + if_stat_level_equal AI_TARGET, SPEED, 0, Score_Minus10 + if_ability AI_TARGET, ABILITY_SPEED_BOOST, Score_Minus10 + goto BattleAIScript_82DC3F6 + +BattleAIScript_82DC3BF: + if_stat_level_equal AI_TARGET, SPATK, 0, Score_Minus10 + goto BattleAIScript_82DC3F6 + +BattleAIScript_82DC3CC: + if_stat_level_equal AI_TARGET, SPDEF, 0, Score_Minus10 + goto BattleAIScript_82DC3F6 + +BattleAIScript_82DC3D9: + if_stat_level_equal AI_TARGET, ACC, 0, Score_Minus10 + get_ability AI_TARGET + if_equal ABILITY_KEEN_EYE, Score_Minus10 + goto BattleAIScript_82DC3F6 + +BattleAIScript_82DC3EE: + if_stat_level_equal AI_TARGET, EVASION, 0, Score_Minus10 + +BattleAIScript_82DC3F6: + get_ability AI_TARGET + if_equal ABILITY_CLEAR_BODY, Score_Minus10 + if_equal ABILITY_WHITE_SMOKE, Score_Minus10 + end + +BattleAIScript_82DC405: + if_stat_level_less_than AI_USER, ATK, 6, BattleAIScript_82DC47A + if_stat_level_less_than AI_USER, DEF, 6, BattleAIScript_82DC47A + if_stat_level_less_than AI_USER, SPEED, 6, BattleAIScript_82DC47A + if_stat_level_less_than AI_USER, SPATK, 6, BattleAIScript_82DC47A + if_stat_level_less_than AI_USER, SPDEF, 6, BattleAIScript_82DC47A + if_stat_level_less_than AI_USER, ACC, 6, BattleAIScript_82DC47A + if_stat_level_less_than AI_USER, EVASION, 6, BattleAIScript_82DC47A + if_stat_level_more_than AI_TARGET, ATK, 6, BattleAIScript_82DC47A + if_stat_level_more_than AI_TARGET, DEF, 6, BattleAIScript_82DC47A + if_stat_level_more_than AI_TARGET, SPEED, 6, BattleAIScript_82DC47A + if_stat_level_more_than AI_TARGET, SPATK, 6, BattleAIScript_82DC47A + if_stat_level_more_than AI_TARGET, SPDEF, 6, BattleAIScript_82DC47A + if_stat_level_more_than AI_TARGET, ACC, 6, BattleAIScript_82DC47A + if_stat_level_more_than AI_TARGET, EVASION, 6, BattleAIScript_82DC47A + goto Score_Minus10 + +BattleAIScript_82DC47A: + end + +BattleAIScript_82DC47B: + count_usable_party_mons AI_TARGET + if_equal 0, Score_Minus10 + get_ability AI_TARGET + if_equal ABILITY_SUCTION_CUPS, Score_Minus10 + end + +BattleAIScript_82DC48C: + get_target_type1 + if_equal TYPE_STEEL, Score_Minus10 + if_equal TYPE_POISON, Score_Minus10 + get_target_type2 + if_equal TYPE_STEEL, Score_Minus10 + if_equal TYPE_POISON, Score_Minus10 + get_ability AI_TARGET + if_equal ABILITY_IMMUNITY, Score_Minus10 + if_status AI_TARGET, STATUS_ANY, Score_Minus10 + if_side_affecting AI_TARGET, SIDE_STATUS_SAFEGUARD, Score_Minus10 + end + +BattleAIScript_82DC4C5: + if_side_affecting AI_USER, SIDE_STATUS_LIGHTSCREEN, Score_Minus8 + end + +BattleAIScript_82DC4D0: + if_type_effectiveness AI_EFFECTIVENESS_x0, Score_Minus10 + get_ability AI_TARGET + if_equal ABILITY_STURDY, Score_Minus10 + if_level_cond 1, Score_Minus10 + end + +BattleAIScript_82DC4E5: + get_ability AI_TARGET + if_equal ABILITY_LEVITATE, Score_Minus10 + +BattleAIScript_82DC4ED: + if_type_effectiveness AI_EFFECTIVENESS_x0, Score_Minus10 + get_ability AI_TARGET + if_not_equal ABILITY_WONDER_GUARD, BattleAIScript_82DC506 + if_type_effectiveness AI_EFFECTIVENESS_x2, BattleAIScript_82DC506 + goto Score_Minus10 + +BattleAIScript_82DC506: + end + +BattleAIScript_82DC507: + if_side_affecting AI_USER, SIDE_STATUS_MIST, Score_Minus8 + end + +BattleAIScript_82DC512: + if_status2 AI_USER, STATUS2_FOCUS_ENERGY, Score_Minus10 + end + +BattleAIScript_82DC51D: + if_status2 AI_TARGET, STATUS2_CONFUSION, Score_Minus5 + get_ability AI_TARGET + if_equal ABILITY_OWN_TEMPO, Score_Minus10 + if_side_affecting AI_TARGET, SIDE_STATUS_SAFEGUARD, Score_Minus10 + end + +BattleAIScript_82DC53A: + if_side_affecting AI_USER, SIDE_STATUS_REFLECT, Score_Minus8 + end + +BattleAIScript_82DC545: + if_type_effectiveness AI_EFFECTIVENESS_x0, Score_Minus10 + get_ability AI_TARGET + if_equal ABILITY_LIMBER, Score_Minus10 + if_status AI_TARGET, STATUS_ANY, Score_Minus10 + if_side_affecting AI_TARGET, SIDE_STATUS_SAFEGUARD, Score_Minus10 + end + +BattleAIScript_82DC568: + if_status2 AI_USER, STATUS2_SUBSTITUTE, Score_Minus8 + if_hp_less_than AI_USER, 26, Score_Minus10 + end + +BattleAIScript_82DC57A: + if_status3 AI_TARGET, STATUS3_LEECHSEED, Score_Minus10 + get_target_type1 + if_equal TYPE_GRASS, Score_Minus10 + get_target_type2 + if_equal TYPE_GRASS, Score_Minus10 + end + +BattleAIScript_82DC595: + if_any_move_disabled AI_TARGET, Score_Minus8 + end + +BattleAIScript_82DC59D: + if_any_move_encored AI_TARGET, Score_Minus8 + end + +BattleAIScript_82DC5A5: + if_not_status AI_USER, STATUS_SLEEP, Score_Minus8 + end + +BattleAIScript_82DC5B0: + if_status2 AI_TARGET, STATUS2_ESCAPE_PREVENTION, Score_Minus10 + end + +BattleAIScript_82DC5BB: + if_stat_level_equal AI_USER, ATK, 12, Score_Minus10 + if_stat_level_equal AI_USER, DEF, 12, Score_Minus8 + end + +BattleAIScript_82DC5CC: + if_side_affecting AI_TARGET, SIDE_STATUS_SPIKES, Score_Minus10 + end + +BattleAIScript_82DC5D7: + if_status2 AI_TARGET, STATUS2_FORESIGHT, Score_Minus10 + end + +BattleAIScript_82DC5E2: + if_status3 AI_TARGET, STATUS3_PERISH_SONG, Score_Minus10 + end + +BattleAIScript_82DC5ED: + get_weather + if_equal AI_WEATHER_SANDSTORM, Score_Minus8 + end + +BattleAIScript_82DC5F5: + if_status2 AI_TARGET, STATUS2_INFATUATION, Score_Minus10 + get_ability AI_TARGET + if_equal ABILITY_OBLIVIOUS, Score_Minus10 + get_gender AI_USER + if_equal 0, BattleAIScript_82DC61A + if_equal 254, BattleAIScript_82DC627 + goto Score_Minus10 + +BattleAIScript_82DC61A: + get_gender AI_TARGET + if_equal 254, BattleAIScript_82DC634 + goto Score_Minus10 + +BattleAIScript_82DC627: + get_gender AI_TARGET + if_equal 0, BattleAIScript_82DC634 + goto Score_Minus10 + +BattleAIScript_82DC634: + end + +BattleAIScript_82DC635: + if_side_affecting AI_USER, SIDE_STATUS_SAFEGUARD, Score_Minus8 + end + +BattleAIScript_82DC640: + if_stat_level_equal AI_TARGET, ATK, 0, Score_Minus10 + if_stat_level_equal AI_TARGET, SPATK, 0, Score_Minus8 + +BattleAIScript_82DC650: + count_usable_party_mons AI_USER + if_equal 0, Score_Minus10 + end + +BattleAIScript_82DC659: + get_weather + if_equal AI_WEATHER_RAIN, Score_Minus8 + end + +BattleAIScript_82DC661: + get_weather + if_equal AI_WEATHER_SUN, Score_Minus8 + end + +BattleAIScript_82DC669: + if_side_affecting AI_TARGET, SIDE_STATUS_FUTUREATTACK, Score_Minus12 + if_side_affecting AI_USER, SIDE_STATUS_FUTUREATTACK, Score_Minus12 + score +5 + end + +BattleAIScript_82DC680: + is_first_turn_for AI_USER + if_equal 0, Score_Minus10 + end + +BattleAIScript_82DC689: + get_stockpile_count AI_USER + if_equal 3, Score_Minus10 + end + +BattleAIScript_82DC692: + if_type_effectiveness AI_EFFECTIVENESS_x0, Score_Minus10 + get_stockpile_count AI_USER + if_equal 0, Score_Minus10 + end + +BattleAIScript_82DC6A1: + get_weather + if_equal AI_WEATHER_HAIL, Score_Minus8 + end + +BattleAIScript_82DC6A9: + if_status2 AI_TARGET, STATUS2_TORMENT, Score_Minus10 + end + +BattleAIScript_82DC6B4: + get_ability AI_TARGET + if_equal ABILITY_WATER_VEIL, Score_Minus10 + if_status AI_TARGET, STATUS_ANY, Score_Minus10 + if_type_effectiveness AI_EFFECTIVENESS_x0, Score_Minus10 + if_type_effectiveness AI_EFFECTIVENESS_x0_5, Score_Minus10 + if_type_effectiveness AI_EFFECTIVENESS_x0_25, Score_Minus10 + if_side_affecting AI_TARGET, SIDE_STATUS_SAFEGUARD, Score_Minus10 + end + +BattleAIScript_82DC6E3: + if_not_double_battle Score_Minus10 + end + +BattleAIScript_82DC6EB: + get_ability AI_TARGET + if_equal ABILITY_STICKY_HOLD, Score_Minus10 + end + +BattleAIScript_82DC6F4: + if_status3 AI_USER, STATUS3_ROOTED, Score_Minus10 + end + +BattleAIScript_82DC6FF: + get_used_held_item AI_USER + if_equal 0, Score_Minus10 + end + +BattleAIScript_82DC708: + if_status3 AI_USER, STATUS3_IMPRISONED_OTHERS, Score_Minus10 + end + +BattleAIScript_82DC713: + if_not_status AI_USER, STATUS_POISON | STATUS_BURN | STATUS_PARALYSIS | STATUS_TOXIC_POISON, Score_Minus10 + end + +BattleAIScript_82DC71E: + if_status3 AI_USER, STATUS3_MUDSPORT, Score_Minus10 + end + +BattleAIScript_82DC729: + if_stat_level_equal AI_TARGET, ATK, 0, Score_Minus10 + if_stat_level_equal AI_TARGET, DEF, 0, Score_Minus8 + end + +BattleAIScript_82DC73A: + if_stat_level_equal AI_USER, DEF, 12, Score_Minus10 + if_stat_level_equal AI_USER, SPDEF, 12, Score_Minus8 + end + +BattleAIScript_82DC74B: + if_stat_level_equal AI_USER, ATK, 12, Score_Minus10 + if_stat_level_equal AI_USER, DEF, 12, Score_Minus8 + end + +BattleAIScript_82DC75C: + if_status3 AI_USER, STATUS3_WATERSPORT, Score_Minus10 + end + +BattleAIScript_82DC767: + if_stat_level_equal AI_USER, SPATK, 12, Score_Minus10 + if_stat_level_equal AI_USER, SPDEF, 12, Score_Minus8 + end + +BattleAIScript_82DC778: + if_stat_level_equal AI_USER, ATK, 12, Score_Minus10 + if_stat_level_equal AI_USER, SPEED, 12, Score_Minus8 + end + +Score_Minus1: + score -1 + end + +Score_Minus2: + score -2 + end + +Score_Minus3: + score -3 + end + +Score_Minus5: + score -5 + end + +Score_Minus8: + score -8 + end + +Score_Minus10: + score -10 + end + +Score_Minus12: + score -12 + end + +Score_Minus30: + score -30 + end + +Score_Plus1: + score +1 + end + +Score_Plus2: + score +2 + end + +Score_Plus3: + score +3 + end + +Score_Plus5: + score +5 + end + +Score_Plus10: + score +10 + end + +AI_TryToFaint: + if_target_is_ally AI_Ret + if_effect EFFECT_SLEEP, BattleAIScript_82DCA92 + if_effect EFFECT_ABSORB, BattleAIScript_82DCAAE + if_effect EFFECT_EXPLOSION, BattleAIScript_82DCAC8 + if_effect EFFECT_DREAM_EATER, BattleAIScript_82DCB26 + if_effect EFFECT_MIRROR_MOVE, BattleAIScript_82DCB3A + if_effect EFFECT_ATTACK_UP, BattleAIScript_82DCBBC + if_effect EFFECT_DEFENSE_UP, BattleAIScript_82DCBF7 + if_effect EFFECT_SPEED_UP, BattleAIScript_82DCC5D + if_effect EFFECT_SPECIAL_ATTACK_UP, BattleAIScript_82DCC73 + if_effect EFFECT_SPECIAL_DEFENSE_UP, BattleAIScript_82DCCAE + if_effect EFFECT_ACCURACY_UP, BattleAIScript_82DCD14 + if_effect EFFECT_EVASION_UP, BattleAIScript_82DCD2E + if_effect EFFECT_ALWAYS_HIT, BattleAIScript_82DCDC8 + if_effect EFFECT_ATTACK_DOWN, BattleAIScript_82DCDF8 + if_effect EFFECT_DEFENSE_DOWN, BattleAIScript_82DCE4A + if_effect EFFECT_SPEED_DOWN, BattleAIScript_82DCE81 + if_effect EFFECT_SPECIAL_ATTACK_DOWN, BattleAIScript_82DCE97 + if_effect EFFECT_SPECIAL_DEFENSE_DOWN, BattleAIScript_82DCEEB + if_effect EFFECT_ACCURACY_DOWN, BattleAIScript_82DCF0C + if_effect EFFECT_EVASION_DOWN, BattleAIScript_82DCFA0 + if_effect EFFECT_HAZE, BattleAIScript_82DCFC1 + if_effect EFFECT_BIDE, BattleAIScript_82DD084 + if_effect EFFECT_ROAR, BattleAIScript_82DD08E + if_effect EFFECT_CONVERSION, BattleAIScript_82DD0C6 + if_effect EFFECT_RESTORE_HP, BattleAIScript_82DD0F7 + if_effect EFFECT_TOXIC, BattleAIScript_82DD150 + if_effect EFFECT_LIGHT_SCREEN, BattleAIScript_82DD18F + if_effect EFFECT_REST, BattleAIScript_82DD1BE + if_effect EFFECT_OHKO, BattleAIScript_82DD21E + if_effect EFFECT_RAZOR_WIND, BattleAIScript_82DDA0B + if_effect EFFECT_SUPER_FANG, BattleAIScript_82DD21F + if_effect EFFECT_TRAP, BattleAIScript_82DD229 + if_effect EFFECT_HIGH_CRITICAL, BattleAIScript_82DD25F + if_effect EFFECT_CONFUSE, BattleAIScript_82DD296 + if_effect EFFECT_ATTACK_UP_2, BattleAIScript_82DCBBC + if_effect EFFECT_DEFENSE_UP_2, BattleAIScript_82DCBF7 + if_effect EFFECT_SPEED_UP_2, BattleAIScript_82DCC5D + if_effect EFFECT_SPECIAL_ATTACK_UP_2, BattleAIScript_82DCC73 + if_effect EFFECT_SPECIAL_DEFENSE_UP_2, BattleAIScript_82DCCAE + if_effect EFFECT_ACCURACY_UP_2, BattleAIScript_82DCD14 + if_effect EFFECT_EVASION_UP_2, BattleAIScript_82DCD2E + if_effect EFFECT_ATTACK_DOWN_2, BattleAIScript_82DCDF8 + if_effect EFFECT_DEFENSE_DOWN_2, BattleAIScript_82DCE4A + if_effect EFFECT_SPEED_DOWN_2, BattleAIScript_82DCE81 + if_effect EFFECT_SPECIAL_ATTACK_DOWN_2, BattleAIScript_82DCE97 + if_effect EFFECT_SPECIAL_DEFENSE_DOWN_2, BattleAIScript_82DCEEB + if_effect EFFECT_ACCURACY_DOWN_2, BattleAIScript_82DCF0C + if_effect EFFECT_EVASION_DOWN_2, BattleAIScript_82DCFA0 + if_effect EFFECT_REFLECT, BattleAIScript_82DD2D3 + if_effect EFFECT_POISON, BattleAIScript_82DD303 + if_effect EFFECT_PARALYZE, BattleAIScript_82DD314 + if_effect EFFECT_SWAGGER, BattleAIScript_82DD286 + if_effect EFFECT_SPEED_DOWN_HIT, BattleAIScript_82DCE6B + if_effect EFFECT_SKY_ATTACK, BattleAIScript_82DDA0B + if_effect EFFECT_VITAL_THROW, BattleAIScript_82DD331 + if_effect EFFECT_SUBSTITUTE, BattleAIScript_82DD354 + if_effect EFFECT_RECHARGE, BattleAIScript_82DD3EA + if_effect EFFECT_LEECH_SEED, BattleAIScript_82DD150 + if_effect EFFECT_DISABLE, BattleAIScript_82DD412 + if_effect EFFECT_COUNTER, BattleAIScript_82DD431 + if_effect EFFECT_ENCORE, BattleAIScript_82DD4E3 + if_effect EFFECT_PAIN_SPLIT, BattleAIScript_82DD54B + if_effect EFFECT_SNORE, BattleAIScript_82DD577 + if_effect EFFECT_LOCK_ON, BattleAIScript_82DD57A + if_effect EFFECT_SLEEP_TALK, BattleAIScript_82DD583 + if_effect EFFECT_DESTINY_BOND, BattleAIScript_82DD590 + if_effect EFFECT_FLAIL, BattleAIScript_82DD5C6 + if_effect EFFECT_HEAL_BELL, BattleAIScript_82DD60B + if_effect EFFECT_THIEF, BattleAIScript_82DD622 + if_effect EFFECT_MEAN_LOOK, BattleAIScript_82DD229 + if_effect EFFECT_MINIMIZE, BattleAIScript_82DCD2E + if_effect EFFECT_CURSE, BattleAIScript_82DD645 + if_effect EFFECT_PROTECT, BattleAIScript_82DD694 + if_effect EFFECT_FORESIGHT, BattleAIScript_82DD75D + if_effect EFFECT_ENDURE, BattleAIScript_82DD78B + if_effect EFFECT_BATON_PASS, BattleAIScript_82DD7A9 + if_effect EFFECT_PURSUIT, BattleAIScript_82DD845 + if_effect EFFECT_MORNING_SUN, BattleAIScript_82DD0DD + if_effect EFFECT_SYNTHESIS, BattleAIScript_82DD0DD + if_effect EFFECT_MOONLIGHT, BattleAIScript_82DD0DD + if_effect EFFECT_RAIN_DANCE, BattleAIScript_82DD87B + if_effect EFFECT_SUNNY_DAY, BattleAIScript_82DD8BA + if_effect EFFECT_BELLY_DRUM, BattleAIScript_82DD8E3 + if_effect EFFECT_PSYCH_UP, BattleAIScript_82DD8F2 + if_effect EFFECT_MIRROR_COAT, BattleAIScript_82DD95A + if_effect EFFECT_SKULL_BASH, BattleAIScript_82DDA0B + if_effect EFFECT_SOLARBEAM, BattleAIScript_82DDA0B + if_effect EFFECT_SEMI_INVULNERABLE, BattleAIScript_82DDA2F + if_effect EFFECT_SOFTBOILED, BattleAIScript_82DD0F7 + if_effect EFFECT_FAKE_OUT, BattleAIScript_82DDAB9 + if_effect EFFECT_SPIT_UP, BattleAIScript_82DDABC + if_effect EFFECT_SWALLOW, BattleAIScript_82DD0F7 + if_effect EFFECT_HAIL, BattleAIScript_82DDACD + if_effect EFFECT_FLATTER, BattleAIScript_82DD28E + if_effect EFFECT_MEMENTO, BattleAIScript_82DCAC8 + if_effect EFFECT_FACADE, BattleAIScript_82DDAF6 + if_effect EFFECT_FOCUS_PUNCH, BattleAIScript_82DDB03 + if_effect EFFECT_SMELLINGSALT, BattleAIScript_82DDB5C + if_effect EFFECT_TRICK, BattleAIScript_82DDB6E + if_effect EFFECT_ROLE_PLAY, BattleAIScript_82DDBB9 + if_effect EFFECT_SUPERPOWER, BattleAIScript_82DDBF0 + if_effect EFFECT_MAGIC_COAT, BattleAIScript_82DDC20 + if_effect EFFECT_RECYCLE, BattleAIScript_82DDC53 + if_effect EFFECT_REVENGE, BattleAIScript_82DDC72 + if_effect EFFECT_BRICK_BREAK, BattleAIScript_82DDCA0 + if_effect EFFECT_KNOCK_OFF, BattleAIScript_82DDCB2 + if_effect EFFECT_ENDEAVOR, BattleAIScript_82DDCCA + if_effect EFFECT_ERUPTION, BattleAIScript_82DDCF6 + if_effect EFFECT_SKILL_SWAP, BattleAIScript_82DDBB9 + if_effect EFFECT_IMPRISON, BattleAIScript_82DDD1E + if_effect EFFECT_REFRESH, BattleAIScript_82DDD2F + if_effect EFFECT_SNATCH, BattleAIScript_82DDD3E + if_effect EFFECT_BLAZE_KICK, BattleAIScript_82DD25F + if_effect EFFECT_MUD_SPORT, BattleAIScript_82DDDA8 + if_effect EFFECT_OVERHEAT, BattleAIScript_82DDDCE + if_effect EFFECT_TICKLE, BattleAIScript_82DCE4A + if_effect EFFECT_COSMIC_POWER, BattleAIScript_82DCCAE + if_effect EFFECT_BULK_UP, BattleAIScript_82DCBF7 + if_effect EFFECT_POISON_TAIL, BattleAIScript_82DD25F + if_effect EFFECT_WATER_SPORT, BattleAIScript_82DDDF6 + if_effect EFFECT_CALM_MIND, BattleAIScript_82DCCAE + if_effect EFFECT_DRAGON_DANCE, BattleAIScript_82DDE1C + end + +BattleAIScript_82DCA92: + if_has_move_with_effect AI_TARGET, EFFECT_DREAM_EATER, BattleAIScript_82DCAA5 + if_has_move_with_effect AI_TARGET, EFFECT_NIGHTMARE, BattleAIScript_82DCAA5 + goto BattleAIScript_82DCAAD + +BattleAIScript_82DCAA5: + if_random_less_than 128, BattleAIScript_82DCAAD + score +1 + +BattleAIScript_82DCAAD: + end + +BattleAIScript_82DCAAE: + if_type_effectiveness AI_EFFECTIVENESS_x0_5, BattleAIScript_82DCABF + if_type_effectiveness AI_EFFECTIVENESS_x0_25, BattleAIScript_82DCABF + goto BattleAIScript_82DCAC7 + +BattleAIScript_82DCABF: + if_random_less_than 50, BattleAIScript_82DCAC7 + score -3 + +BattleAIScript_82DCAC7: + end + +BattleAIScript_82DCAC8: + if_stat_level_less_than AI_TARGET, EVASION, 7, BattleAIScript_82DCAE2 + score -1 + if_stat_level_less_than AI_TARGET, EVASION, 10, BattleAIScript_82DCAE2 + if_random_less_than 128, BattleAIScript_82DCAE2 + score -1 + +BattleAIScript_82DCAE2: + if_hp_less_than AI_USER, 80, BattleAIScript_82DCAFA + if_target_faster BattleAIScript_82DCAFA + if_random_less_than 50, BattleAIScript_82DCB25 + goto Score_Minus3 + +BattleAIScript_82DCAFA: + if_hp_more_than AI_USER, 50, BattleAIScript_82DCB1D + if_random_less_than 128, BattleAIScript_82DCB09 + score +1 + +BattleAIScript_82DCB09: + if_hp_more_than AI_USER, 30, BattleAIScript_82DCB25 + if_random_less_than 50, BattleAIScript_82DCB25 + score +1 + goto BattleAIScript_82DCB25 + +BattleAIScript_82DCB1D: + if_random_less_than 50, BattleAIScript_82DCB25 + score -1 + +BattleAIScript_82DCB25: + end + +BattleAIScript_82DCB26: + if_type_effectiveness AI_EFFECTIVENESS_x0_25, BattleAIScript_82DCB37 + if_type_effectiveness AI_EFFECTIVENESS_x0_5, BattleAIScript_82DCB37 + goto BattleAIScript_82DCB39 + +BattleAIScript_82DCB37: + score -1 + +BattleAIScript_82DCB39: + end + +BattleAIScript_82DCB3A: + if_target_faster BattleAIScript_82DCB58 + get_last_used_bank_move AI_TARGET + if_not_in_hwords sMovesTable_82DCB6C, BattleAIScript_82DCB58 + if_random_less_than 128, BattleAIScript_82DCB6B + score +2 + goto BattleAIScript_82DCB6B + +BattleAIScript_82DCB58: + get_last_used_bank_move AI_TARGET + if_in_hwords sMovesTable_82DCB6C, BattleAIScript_82DCB6B + if_random_less_than 80, BattleAIScript_82DCB6B + score -1 + +BattleAIScript_82DCB6B: + end + +sMovesTable_82DCB6C: + .2byte MOVE_SLEEP_POWDER + .2byte MOVE_LOVELY_KISS + .2byte MOVE_SPORE + .2byte MOVE_HYPNOSIS + .2byte MOVE_SING + .2byte MOVE_GRASS_WHISTLE + .2byte MOVE_SHADOW_PUNCH + .2byte MOVE_SAND_ATTACK + .2byte MOVE_SMOKESCREEN + .2byte MOVE_TOXIC + .2byte MOVE_GUILLOTINE + .2byte MOVE_HORN_DRILL + .2byte MOVE_FISSURE + .2byte MOVE_SHEER_COLD + .2byte MOVE_CROSS_CHOP + .2byte MOVE_AEROBLAST + .2byte MOVE_CONFUSE_RAY + .2byte MOVE_SWEET_KISS + .2byte MOVE_SCREECH + .2byte MOVE_COTTON_SPORE + .2byte MOVE_SCARY_FACE + .2byte MOVE_FAKE_TEARS + .2byte MOVE_METAL_SOUND + .2byte MOVE_THUNDER_WAVE + .2byte MOVE_GLARE + .2byte MOVE_POISON_POWDER + .2byte MOVE_SHADOW_BALL + .2byte MOVE_DYNAMIC_PUNCH + .2byte MOVE_HYPER_BEAM + .2byte MOVE_EXTREME_SPEED + .2byte MOVE_THIEF + .2byte MOVE_COVET + .2byte MOVE_ATTRACT + .2byte MOVE_SWAGGER + .2byte MOVE_TORMENT + .2byte MOVE_FLATTER + .2byte MOVE_TRICK + .2byte MOVE_SUPERPOWER + .2byte MOVE_SKILL_SWAP + .2byte -1 + +BattleAIScript_82DCBBC: + if_stat_level_less_than AI_USER, ATK, 9, BattleAIScript_82DCBD1 + if_random_less_than 100, BattleAIScript_82DCBE0 + score -1 + goto BattleAIScript_82DCBE0 + +BattleAIScript_82DCBD1: + if_hp_not_equal AI_USER, 100, BattleAIScript_82DCBE0 + if_random_less_than 128, BattleAIScript_82DCBE0 + score +2 + +BattleAIScript_82DCBE0: + if_hp_more_than AI_USER, 70, BattleAIScript_82DCBF6 + if_hp_less_than AI_USER, 40, BattleAIScript_82DCBF4 + if_random_less_than 40, BattleAIScript_82DCBF6 + +BattleAIScript_82DCBF4: + score -2 + +BattleAIScript_82DCBF6: + end + +BattleAIScript_82DCBF7: + if_stat_level_less_than AI_USER, DEF, 9, BattleAIScript_82DCC0C + if_random_less_than 100, BattleAIScript_82DCC1B + score -1 + goto BattleAIScript_82DCC1B + +BattleAIScript_82DCC0C: + if_hp_not_equal AI_USER, 100, BattleAIScript_82DCC1B + if_random_less_than 128, BattleAIScript_82DCC1B + score +2 + +BattleAIScript_82DCC1B: + if_hp_less_than AI_USER, 70, BattleAIScript_82DCC28 + if_random_less_than 200, BattleAIScript_82DCC52 + +BattleAIScript_82DCC28: + if_hp_less_than AI_USER, 40, BattleAIScript_82DCC50 + get_last_used_bank_move AI_TARGET + get_move_power_from_result + if_equal 0, BattleAIScript_82DCC4A + get_last_used_bank_move AI_TARGET + get_move_type_from_result + if_not_in_bytes sTypesTable_82DCC53, BattleAIScript_82DCC50 + if_random_less_than 60, BattleAIScript_82DCC52 + +BattleAIScript_82DCC4A: + if_random_less_than 60, BattleAIScript_82DCC52 + +BattleAIScript_82DCC50: + score -2 + +BattleAIScript_82DCC52: + end + +sTypesTable_82DCC53: + .byte TYPE_NORMAL + .byte TYPE_FIGHTING + .byte TYPE_POISON + .byte TYPE_GROUND + .byte TYPE_FLYING + .byte TYPE_ROCK + .byte TYPE_BUG + .byte TYPE_GHOST + .byte TYPE_STEEL + .byte -1 + +BattleAIScript_82DCC5D: + if_target_faster BattleAIScript_82DCC6A + score -3 + goto BattleAIScript_82DCC72 + +BattleAIScript_82DCC6A: + if_random_less_than 70, BattleAIScript_82DCC72 + score +3 + +BattleAIScript_82DCC72: + end + +BattleAIScript_82DCC73: + if_stat_level_less_than AI_USER, SPATK, 9, BattleAIScript_82DCC88 + if_random_less_than 100, BattleAIScript_82DCC97 + score -1 + goto BattleAIScript_82DCC97 + +BattleAIScript_82DCC88: + if_hp_not_equal AI_USER, 100, BattleAIScript_82DCC97 + if_random_less_than 128, BattleAIScript_82DCC97 + score +2 + +BattleAIScript_82DCC97: + if_hp_more_than AI_USER, 70, BattleAIScript_82DCCAD + if_hp_less_than AI_USER, 40, BattleAIScript_82DCCAB + if_random_less_than 70, BattleAIScript_82DCCAD + +BattleAIScript_82DCCAB: + score -2 + +BattleAIScript_82DCCAD: + end + +BattleAIScript_82DCCAE: + if_stat_level_less_than AI_USER, SPDEF, 9, BattleAIScript_82DCCC3 + if_random_less_than 100, BattleAIScript_82DCCD2 + score -1 + goto BattleAIScript_82DCCD2 + +BattleAIScript_82DCCC3: + if_hp_not_equal AI_USER, 100, BattleAIScript_82DCCD2 + if_random_less_than 128, BattleAIScript_82DCCD2 + score +2 + +BattleAIScript_82DCCD2: + if_hp_less_than AI_USER, 70, BattleAIScript_82DCCDF + if_random_less_than 200, BattleAIScript_82DCD09 + +BattleAIScript_82DCCDF: + if_hp_less_than AI_USER, 40, BattleAIScript_82DCD07 + get_last_used_bank_move AI_TARGET + get_move_power_from_result + if_equal 0, BattleAIScript_82DCD01 + get_last_used_bank_move AI_TARGET + get_move_type_from_result + if_in_bytes sTypesTable_82DCD0A, BattleAIScript_82DCD07 + if_random_less_than 60, BattleAIScript_82DCD09 + +BattleAIScript_82DCD01: + if_random_less_than 60, BattleAIScript_82DCD09 + +BattleAIScript_82DCD07: + score -2 + +BattleAIScript_82DCD09: + end + +sTypesTable_82DCD0A: + .byte TYPE_NORMAL + .byte TYPE_FIGHTING + .byte TYPE_POISON + .byte TYPE_GROUND + .byte TYPE_FLYING + .byte TYPE_ROCK + .byte TYPE_BUG + .byte TYPE_GHOST + .byte TYPE_STEEL + .byte -1 + +BattleAIScript_82DCD14: + if_stat_level_less_than AI_USER, ACC, 9, BattleAIScript_82DCD24 + if_random_less_than 50, BattleAIScript_82DCD24 + score -2 + +BattleAIScript_82DCD24: + if_hp_more_than AI_USER, 70, BattleAIScript_82DCD2D + score -2 + +BattleAIScript_82DCD2D: + end + +BattleAIScript_82DCD2E: + if_hp_less_than AI_USER, 90, BattleAIScript_82DCD3D + if_random_less_than 100, BattleAIScript_82DCD3D + score +3 + +BattleAIScript_82DCD3D: + if_stat_level_less_than AI_USER, EVASION, 9, BattleAIScript_82DCD4D + if_random_less_than 128, BattleAIScript_82DCD4D + score -1 + +BattleAIScript_82DCD4D: + if_not_status AI_TARGET, STATUS_TOXIC_POISON, BattleAIScript_82DCD6C + if_hp_more_than AI_USER, 50, BattleAIScript_82DCD64 + if_random_less_than 80, BattleAIScript_82DCD6C + +BattleAIScript_82DCD64: + if_random_less_than 50, BattleAIScript_82DCD6C + score +3 + +BattleAIScript_82DCD6C: + if_not_status3 AI_TARGET, STATUS3_LEECHSEED, BattleAIScript_82DCD7E + if_random_less_than 70, BattleAIScript_82DCD7E + score +3 + +BattleAIScript_82DCD7E: + if_not_status3 AI_USER, STATUS3_ROOTED, BattleAIScript_82DCD90 + if_random_less_than 128, BattleAIScript_82DCD90 + score +2 + +BattleAIScript_82DCD90: + if_not_status2 AI_TARGET, STATUS2_CURSED, BattleAIScript_82DCDA2 + if_random_less_than 70, BattleAIScript_82DCDA2 + score +3 + +BattleAIScript_82DCDA2: + if_hp_more_than AI_USER, 70, BattleAIScript_82DCDC7 + if_stat_level_equal AI_USER, EVASION, 6, BattleAIScript_82DCDC7 + if_hp_less_than AI_USER, 40, BattleAIScript_82DCDC5 + if_hp_less_than AI_TARGET, 40, BattleAIScript_82DCDC5 + if_random_less_than 70, BattleAIScript_82DCDC7 + +BattleAIScript_82DCDC5: + score -2 + +BattleAIScript_82DCDC7: + end + +BattleAIScript_82DCDC8: + if_stat_level_more_than AI_TARGET, EVASION, 10, BattleAIScript_82DCDED + if_stat_level_less_than AI_USER, ACC, 2, BattleAIScript_82DCDED + if_stat_level_more_than AI_TARGET, EVASION, 8, BattleAIScript_82DCDEF + if_stat_level_less_than AI_USER, ACC, 4, BattleAIScript_82DCDEF + goto BattleAIScript_82DCDF7 + +BattleAIScript_82DCDED: + score +1 + +BattleAIScript_82DCDEF: + if_random_less_than 100, BattleAIScript_82DCDF7 + score +1 + +BattleAIScript_82DCDF7: + end + +BattleAIScript_82DCDF8: + if_stat_level_equal AI_TARGET, ATK, 6, BattleAIScript_82DCE1B + score -1 + if_hp_more_than AI_USER, 90, BattleAIScript_82DCE0B + score -1 + +BattleAIScript_82DCE0B: + if_stat_level_more_than AI_TARGET, ATK, 3, BattleAIScript_82DCE1B + if_random_less_than 50, BattleAIScript_82DCE1B + score -2 + +BattleAIScript_82DCE1B: + if_hp_more_than AI_TARGET, 70, BattleAIScript_82DCE24 + score -2 + +BattleAIScript_82DCE24: + get_target_type1 + if_in_bytes sTypesTable_82DCE43, BattleAIScript_82DCE42 + get_target_type2 + if_in_bytes sTypesTable_82DCE43, BattleAIScript_82DCE42 + if_random_less_than 50, BattleAIScript_82DCE42 + score -2 + +BattleAIScript_82DCE42: + end + +sTypesTable_82DCE43: + .byte TYPE_NORMAL + .byte TYPE_FIGHTING + .byte TYPE_GROUND + .byte TYPE_ROCK + .byte TYPE_BUG + .byte TYPE_STEEL + .byte -1 + +BattleAIScript_82DCE4A: + if_hp_less_than AI_USER, 70, BattleAIScript_82DCE59 + if_stat_level_more_than AI_TARGET, DEF, 3, BattleAIScript_82DCE61 + +BattleAIScript_82DCE59: + if_random_less_than 50, BattleAIScript_82DCE61 + score -2 + +BattleAIScript_82DCE61: + if_hp_more_than AI_TARGET, 70, BattleAIScript_82DCE6A + score -2 + +BattleAIScript_82DCE6A: + end + +BattleAIScript_82DCE6B: + if_move MOVE_ICY_WIND, BattleAIScript_82DCE81 + if_move MOVE_ROCK_TOMB, BattleAIScript_82DCE81 + if_move MOVE_MUD_SHOT, BattleAIScript_82DCE81 + end + +BattleAIScript_82DCE81: + if_target_faster BattleAIScript_82DCE8E + score -3 + goto BattleAIScript_82DCE96 + +BattleAIScript_82DCE8E: + if_random_less_than 70, BattleAIScript_82DCE96 + score +2 + +BattleAIScript_82DCE96: + end + +BattleAIScript_82DCE97: + if_stat_level_equal AI_TARGET, ATK, 6, BattleAIScript_82DCEBA + score -1 + if_hp_more_than AI_USER, 90, BattleAIScript_82DCEAA + score -1 + +BattleAIScript_82DCEAA: + if_stat_level_more_than AI_TARGET, SPATK, 3, BattleAIScript_82DCEBA + if_random_less_than 50, BattleAIScript_82DCEBA + score -2 + +BattleAIScript_82DCEBA: + if_hp_more_than AI_TARGET, 70, BattleAIScript_82DCEC3 + score -2 + +BattleAIScript_82DCEC3: + get_target_type1 + if_in_bytes sTypesTable_82DCEE2, BattleAIScript_82DCEE1 + get_target_type2 + if_in_bytes sTypesTable_82DCEE2, BattleAIScript_82DCEE1 + if_random_less_than 50, BattleAIScript_82DCEE1 + score -2 + +BattleAIScript_82DCEE1: + end + +sTypesTable_82DCEE2: + .byte TYPE_FIRE + .byte TYPE_WATER + .byte TYPE_GRASS + .byte TYPE_ELECTRIC + .byte TYPE_PSYCHIC + .byte TYPE_ICE + .byte TYPE_DRAGON + .byte TYPE_DARK + .byte -1 + +BattleAIScript_82DCEEB: + if_hp_less_than AI_USER, 70, BattleAIScript_82DCEFA + if_stat_level_more_than AI_TARGET, SPDEF, 3, BattleAIScript_82DCF02 + +BattleAIScript_82DCEFA: + if_random_less_than 50, BattleAIScript_82DCF02 + score -2 + +BattleAIScript_82DCF02: + if_hp_more_than AI_TARGET, 70, BattleAIScript_82DCF0B + score -2 + +BattleAIScript_82DCF0B: + end + +BattleAIScript_82DCF0C: + if_hp_less_than AI_USER, 70, BattleAIScript_82DCF1A + if_hp_more_than AI_TARGET, 70, BattleAIScript_82DCF22 + +BattleAIScript_82DCF1A: + if_random_less_than 100, BattleAIScript_82DCF22 + score -1 + +BattleAIScript_82DCF22: + if_stat_level_more_than AI_USER, ACC, 4, BattleAIScript_82DCF32 + if_random_less_than 80, BattleAIScript_82DCF32 + score -2 + +BattleAIScript_82DCF32: + if_not_status AI_TARGET, STATUS_TOXIC_POISON, BattleAIScript_82DCF44 + if_random_less_than 70, BattleAIScript_82DCF44 + score +2 + +BattleAIScript_82DCF44: + if_not_status3 AI_TARGET, STATUS3_LEECHSEED, BattleAIScript_82DCF56 + if_random_less_than 70, BattleAIScript_82DCF56 + score +2 + +BattleAIScript_82DCF56: + if_not_status3 AI_USER, STATUS3_ROOTED, BattleAIScript_82DCF68 + if_random_less_than 128, BattleAIScript_82DCF68 + score +1 + +BattleAIScript_82DCF68: + if_not_status2 AI_TARGET, STATUS2_CURSED, BattleAIScript_82DCF7A + if_random_less_than 70, BattleAIScript_82DCF7A + score +2 + +BattleAIScript_82DCF7A: + if_hp_more_than AI_USER, 70, BattleAIScript_82DCF9F + if_stat_level_equal AI_TARGET, ACC, 6, BattleAIScript_82DCF9F + if_hp_less_than AI_USER, 40, BattleAIScript_82DCF9D + if_hp_less_than AI_TARGET, 40, BattleAIScript_82DCF9D + if_random_less_than 70, BattleAIScript_82DCF9F + +BattleAIScript_82DCF9D: + score -2 + +BattleAIScript_82DCF9F: + end + +BattleAIScript_82DCFA0: + if_hp_less_than AI_USER, 70, BattleAIScript_82DCFAF + if_stat_level_more_than AI_TARGET, EVASION, 3, BattleAIScript_82DCFB7 + +BattleAIScript_82DCFAF: + if_random_less_than 50, BattleAIScript_82DCFB7 + score -2 + +BattleAIScript_82DCFB7: + if_hp_more_than AI_TARGET, 70, BattleAIScript_82DCFC0 + score -2 + +BattleAIScript_82DCFC0: + end + +BattleAIScript_82DCFC1: + if_stat_level_more_than AI_USER, ATK, 8, BattleAIScript_82DD016 + if_stat_level_more_than AI_USER, DEF, 8, BattleAIScript_82DD016 + if_stat_level_more_than AI_USER, SPATK, 8, BattleAIScript_82DD016 + if_stat_level_more_than AI_USER, SPDEF, 8, BattleAIScript_82DD016 + if_stat_level_more_than AI_USER, EVASION, 8, BattleAIScript_82DD016 + if_stat_level_less_than AI_TARGET, ATK, 4, BattleAIScript_82DD016 + if_stat_level_less_than AI_TARGET, DEF, 4, BattleAIScript_82DD016 + if_stat_level_less_than AI_TARGET, SPATK, 4, BattleAIScript_82DD016 + if_stat_level_less_than AI_TARGET, SPDEF, 4, BattleAIScript_82DD016 + if_stat_level_less_than AI_TARGET, ACC, 4, BattleAIScript_82DD016 + goto BattleAIScript_82DD01E + +BattleAIScript_82DD016: + if_random_less_than 50, BattleAIScript_82DD01E + score -3 + +BattleAIScript_82DD01E: + if_stat_level_more_than AI_TARGET, ATK, 8, BattleAIScript_82DD07B + if_stat_level_more_than AI_TARGET, DEF, 8, BattleAIScript_82DD07B + if_stat_level_more_than AI_TARGET, SPATK, 8, BattleAIScript_82DD07B + if_stat_level_more_than AI_TARGET, SPDEF, 8, BattleAIScript_82DD07B + if_stat_level_more_than AI_TARGET, EVASION, 8, BattleAIScript_82DD07B + if_stat_level_less_than AI_USER, ATK, 4, BattleAIScript_82DD07B + if_stat_level_less_than AI_USER, DEF, 4, BattleAIScript_82DD07B + if_stat_level_less_than AI_USER, SPATK, 4, BattleAIScript_82DD07B + if_stat_level_less_than AI_USER, SPDEF, 4, BattleAIScript_82DD07B + if_stat_level_less_than AI_USER, ACC, 4, BattleAIScript_82DD07B + if_random_less_than 50, BattleAIScript_82DD083 + score -1 + goto BattleAIScript_82DD083 + +BattleAIScript_82DD07B: + if_random_less_than 50, BattleAIScript_82DD083 + score +3 + +BattleAIScript_82DD083: + end + +BattleAIScript_82DD084: + if_hp_more_than AI_USER, 90, BattleAIScript_82DD08D + score -2 + +BattleAIScript_82DD08D: + end + +BattleAIScript_82DD08E: + if_stat_level_more_than AI_TARGET, ATK, 8, BattleAIScript_82DD0BD + if_stat_level_more_than AI_TARGET, DEF, 8, BattleAIScript_82DD0BD + if_stat_level_more_than AI_TARGET, SPATK, 8, BattleAIScript_82DD0BD + if_stat_level_more_than AI_TARGET, SPDEF, 8, BattleAIScript_82DD0BD + if_stat_level_more_than AI_TARGET, EVASION, 8, BattleAIScript_82DD0BD + score -3 + goto BattleAIScript_82DD0C5 + +BattleAIScript_82DD0BD: + if_random_less_than 128, BattleAIScript_82DD0C5 + score +2 + +BattleAIScript_82DD0C5: + end + +BattleAIScript_82DD0C6: + if_hp_more_than AI_USER, 90, BattleAIScript_82DD0CF + score -2 + +BattleAIScript_82DD0CF: + get_turn_count + if_equal 0, BattleAIScript_82DD0DC + if_random_less_than 200, Score_Minus2 + +BattleAIScript_82DD0DC: + end + +BattleAIScript_82DD0DD: + get_weather + if_equal AI_WEATHER_HAIL, BattleAIScript_82DD0F5 + if_equal AI_WEATHER_RAIN, BattleAIScript_82DD0F5 + if_equal AI_WEATHER_SANDSTORM, BattleAIScript_82DD0F5 + goto BattleAIScript_82DD0F7 + +BattleAIScript_82DD0F5: + score -2 + +BattleAIScript_82DD0F7: + if_hp_equal AI_USER, 100, BattleAIScript_82DD11F + if_target_faster BattleAIScript_82DD126 + score -8 + goto BattleAIScript_82DD14F + +AI_CV_Heal2: + if_hp_less_than AI_USER, 50, BattleAIScript_82DD13A + if_hp_more_than AI_USER, 80, BattleAIScript_82DD11F + if_random_less_than 70, BattleAIScript_82DD13A + +BattleAIScript_82DD11F: + score -3 + goto BattleAIScript_82DD14F + +BattleAIScript_82DD126: + if_hp_less_than AI_USER, 70, BattleAIScript_82DD13A + if_random_less_than 30, BattleAIScript_82DD13A + score -3 + goto BattleAIScript_82DD14F + +BattleAIScript_82DD13A: + if_doesnt_have_move_with_effect AI_TARGET, EFFECT_SNATCH, BattleAIScript_82DD147 + if_random_less_than 100, BattleAIScript_82DD14F + +BattleAIScript_82DD147: + if_random_less_than 20, BattleAIScript_82DD14F + score +2 + +BattleAIScript_82DD14F: + end + +BattleAIScript_82DD150: + if_user_has_no_attacking_moves BattleAIScript_82DD173 + if_hp_more_than AI_USER, 50, BattleAIScript_82DD164 + if_random_less_than 50, BattleAIScript_82DD164 + score -3 + +BattleAIScript_82DD164: + if_hp_more_than AI_TARGET, 50, BattleAIScript_82DD173 + if_random_less_than 50, BattleAIScript_82DD173 + score -3 + +BattleAIScript_82DD173: + if_has_move_with_effect AI_USER, EFFECT_SPECIAL_DEFENSE_UP, BattleAIScript_82DD186 + if_has_move_with_effect AI_USER, EFFECT_PROTECT, BattleAIScript_82DD186 + goto BattleAIScript_82DD18E + +BattleAIScript_82DD186: + if_random_less_than 60, BattleAIScript_82DD18E + score +2 + +BattleAIScript_82DD18E: + end + +BattleAIScript_82DD18F: + if_hp_less_than AI_USER, 50, BattleAIScript_82DD1B2 + get_target_type1 + if_in_bytes sTypesTable_82DD1B5, BattleAIScript_82DD1B4 + get_target_type2 + if_in_bytes sTypesTable_82DD1B5, BattleAIScript_82DD1B4 + if_random_less_than 50, BattleAIScript_82DD1B4 + +BattleAIScript_82DD1B2: + score -2 + +BattleAIScript_82DD1B4: + end + +sTypesTable_82DD1B5: + .byte TYPE_FIRE + .byte TYPE_WATER + .byte TYPE_GRASS + .byte TYPE_ELECTRIC + .byte TYPE_PSYCHIC + .byte TYPE_ICE + .byte TYPE_DRAGON + .byte TYPE_DARK + .byte -1 + +BattleAIScript_82DD1BE: + if_target_faster BattleAIScript_82DD1ED + if_hp_not_equal AI_USER, 100, BattleAIScript_82DD1D2 + score -8 + goto BattleAIScript_82DD21D + +BattleAIScript_82DD1D2: + if_hp_less_than AI_USER, 40, BattleAIScript_82DD208 + if_hp_more_than AI_USER, 50, BattleAIScript_82DD1E6 + if_random_less_than 70, BattleAIScript_82DD208 + +BattleAIScript_82DD1E6: + score -3 + goto BattleAIScript_82DD21D + +BattleAIScript_82DD1ED: + if_hp_less_than AI_USER, 60, BattleAIScript_82DD208 + if_hp_more_than AI_USER, 70, BattleAIScript_82DD201 + if_random_less_than 50, BattleAIScript_82DD208 + +BattleAIScript_82DD201: + score -3 + goto BattleAIScript_82DD21D + +BattleAIScript_82DD208: + if_doesnt_have_move_with_effect AI_TARGET, EFFECT_SNATCH, BattleAIScript_82DD215 + if_random_less_than 50, BattleAIScript_82DD21D + +BattleAIScript_82DD215: + if_random_less_than 10, BattleAIScript_82DD21D + score +3 + +BattleAIScript_82DD21D: + end + +BattleAIScript_82DD21E: + end + +BattleAIScript_82DD21F: + if_hp_more_than AI_TARGET, 50, BattleAIScript_82DD228 + score -1 + +BattleAIScript_82DD228: + end + +BattleAIScript_82DD229: + if_status AI_TARGET, STATUS_TOXIC_POISON, BattleAIScript_82DD256 + if_status2 AI_TARGET, STATUS2_CURSED, BattleAIScript_82DD256 + if_status3 AI_TARGET, STATUS3_PERISH_SONG, BattleAIScript_82DD256 + if_status2 AI_TARGET, STATUS2_INFATUATION, BattleAIScript_82DD256 + goto BattleAIScript_82DD25E + +BattleAIScript_82DD256: + if_random_less_than 128, BattleAIScript_82DD25E + score +1 + +BattleAIScript_82DD25E: + end + +BattleAIScript_82DD25F: + if_type_effectiveness AI_EFFECTIVENESS_x0_25, BattleAIScript_82DD285 + if_type_effectiveness AI_EFFECTIVENESS_x0_5, BattleAIScript_82DD285 + if_type_effectiveness AI_EFFECTIVENESS_x2, BattleAIScript_82DD27D + if_type_effectiveness AI_EFFECTIVENESS_x4, BattleAIScript_82DD27D + if_random_less_than 128, BattleAIScript_82DD285 + +BattleAIScript_82DD27D: + if_random_less_than 128, BattleAIScript_82DD285 + score +1 + +BattleAIScript_82DD285: + end + +BattleAIScript_82DD286: + if_has_move AI_USER, MOVE_PSYCH_UP, BattleAIScript_82DD2B8 + +BattleAIScript_82DD28E: + if_random_less_than 128, BattleAIScript_82DD296 + score +1 + +BattleAIScript_82DD296: + if_hp_more_than AI_TARGET, 70, BattleAIScript_82DD2B7 + if_random_less_than 128, BattleAIScript_82DD2A5 + score -1 + +BattleAIScript_82DD2A5: + if_hp_more_than AI_TARGET, 50, BattleAIScript_82DD2B7 + score -1 + if_hp_more_than AI_TARGET, 30, BattleAIScript_82DD2B7 + score -1 + +BattleAIScript_82DD2B7: + end + +BattleAIScript_82DD2B8: + if_stat_level_more_than AI_TARGET, ATK, 3, BattleAIScript_82DD2D0 + score +3 + get_turn_count + if_not_equal 0, BattleAIScript_82DD2D2 + score +2 + goto BattleAIScript_82DD2D2 + +BattleAIScript_82DD2D0: + score -5 + +BattleAIScript_82DD2D2: + end + +BattleAIScript_82DD2D3: + if_hp_less_than AI_USER, 50, BattleAIScript_82DD2F6 + get_target_type1 + if_in_bytes sTypesTable_82DD2F9, BattleAIScript_82DD2F8 + get_target_type2 + if_in_bytes sTypesTable_82DD2F9, BattleAIScript_82DD2F8 + if_random_less_than 50, BattleAIScript_82DD2F8 + +BattleAIScript_82DD2F6: + score -2 + +BattleAIScript_82DD2F8: + end + +sTypesTable_82DD2F9: + .byte TYPE_NORMAL + .byte TYPE_FIGHTING + .byte TYPE_FLYING + .byte TYPE_POISON + .byte TYPE_GROUND + .byte TYPE_ROCK + .byte TYPE_BUG + .byte TYPE_GHOST + .byte TYPE_STEEL + .byte -1 + +BattleAIScript_82DD303: + if_hp_less_than AI_USER, 50, BattleAIScript_82DD311 + if_hp_more_than AI_TARGET, 50, BattleAIScript_82DD313 + +BattleAIScript_82DD311: + score -1 + +BattleAIScript_82DD313: + end + +BattleAIScript_82DD314: + if_target_faster BattleAIScript_82DD328 + if_hp_more_than AI_USER, 70, BattleAIScript_82DD330 + score -1 + goto BattleAIScript_82DD330 + +BattleAIScript_82DD328: + if_random_less_than 20, BattleAIScript_82DD330 + score +3 + +BattleAIScript_82DD330: + end + +BattleAIScript_82DD331: + if_target_faster BattleAIScript_82DD353 + if_hp_more_than AI_USER, 60, BattleAIScript_82DD353 + if_hp_less_than AI_USER, 40, BattleAIScript_82DD34B + if_random_less_than 180, BattleAIScript_82DD353 + +BattleAIScript_82DD34B: + if_random_less_than 50, BattleAIScript_82DD353 + score -1 + +BattleAIScript_82DD353: + end + +BattleAIScript_82DD354: + if_hp_more_than AI_USER, 90, BattleAIScript_82DD381 + if_hp_more_than AI_USER, 70, BattleAIScript_82DD379 + if_hp_more_than AI_USER, 50, BattleAIScript_82DD371 + if_random_less_than 100, BattleAIScript_82DD371 + score -1 + +BattleAIScript_82DD371: + if_random_less_than 100, BattleAIScript_82DD379 + score -1 + +BattleAIScript_82DD379: + if_random_less_than 100, BattleAIScript_82DD381 + score -1 + +BattleAIScript_82DD381: + if_target_faster BattleAIScript_82DD3E9 + get_last_used_bank_move AI_TARGET + get_move_effect_from_result + if_equal EFFECT_SLEEP, BattleAIScript_82DD3B9 + if_equal EFFECT_TOXIC, BattleAIScript_82DD3B9 + if_equal EFFECT_POISON, BattleAIScript_82DD3B9 + if_equal EFFECT_PARALYZE, BattleAIScript_82DD3B9 + if_equal EFFECT_WILL_O_WISP, BattleAIScript_82DD3B9 + if_equal EFFECT_CONFUSE, BattleAIScript_82DD3C8 + if_equal EFFECT_LEECH_SEED, BattleAIScript_82DD3D7 + goto BattleAIScript_82DD3E9 + +BattleAIScript_82DD3B9: + if_not_status AI_TARGET, STATUS_ANY, BattleAIScript_82DD3E1 + goto BattleAIScript_82DD3E9 + +BattleAIScript_82DD3C8: + if_not_status2 AI_TARGET, STATUS2_CONFUSION, BattleAIScript_82DD3E1 + goto BattleAIScript_82DD3E9 + +BattleAIScript_82DD3D7: + if_status3 AI_TARGET, STATUS3_LEECHSEED, BattleAIScript_82DD3E9 + +BattleAIScript_82DD3E1: + if_random_less_than 100, BattleAIScript_82DD3E9 + score +1 + +BattleAIScript_82DD3E9: + end + +BattleAIScript_82DD3EA: + if_type_effectiveness AI_EFFECTIVENESS_x0_25, BattleAIScript_82DD40F + if_type_effectiveness AI_EFFECTIVENESS_x0_5, BattleAIScript_82DD40F + if_target_faster BattleAIScript_82DD408 + if_hp_more_than AI_USER, 40, BattleAIScript_82DD40F + goto BattleAIScript_82DD411 + +BattleAIScript_82DD408: + if_hp_less_than AI_USER, 60, BattleAIScript_82DD411 + +BattleAIScript_82DD40F: + score -1 + +BattleAIScript_82DD411: + end + +BattleAIScript_82DD412: + if_target_faster BattleAIScript_82DD430 + get_last_used_bank_move AI_TARGET + get_move_power_from_result + if_equal 0, BattleAIScript_82DD428 + score +1 + goto BattleAIScript_82DD430 + +BattleAIScript_82DD428: + if_random_less_than 100, BattleAIScript_82DD430 + score -1 + +BattleAIScript_82DD430: + end + +BattleAIScript_82DD431: + if_status AI_TARGET, STATUS_SLEEP, BattleAIScript_82DD4D6 + if_status2 AI_TARGET, STATUS2_INFATUATION, BattleAIScript_82DD4D6 + if_status2 AI_TARGET, STATUS2_CONFUSION, BattleAIScript_82DD4D6 + if_hp_more_than AI_USER, 30, BattleAIScript_82DD45E + if_random_less_than 10, BattleAIScript_82DD45E + score -1 + +BattleAIScript_82DD45E: + if_hp_more_than AI_USER, 50, BattleAIScript_82DD46D + if_random_less_than 100, BattleAIScript_82DD46D + score -1 + +BattleAIScript_82DD46D: + if_has_move AI_USER, MOVE_MIRROR_COAT, BattleAIScript_82DD4CD + get_last_used_bank_move AI_TARGET + get_move_power_from_result + if_equal 0, BattleAIScript_82DD4A4 + if_target_not_taunted BattleAIScript_82DD48B + if_random_less_than 100, BattleAIScript_82DD48B + score +1 + +BattleAIScript_82DD48B: + get_last_used_bank_move AI_TARGET + get_move_type_from_result + if_not_in_bytes sTypesTable_82DD4D9, BattleAIScript_82DD4D6 + if_random_less_than 100, BattleAIScript_82DD4D8 + score +1 + goto BattleAIScript_82DD4D8 + +BattleAIScript_82DD4A4: + if_target_not_taunted BattleAIScript_82DD4B1 + if_random_less_than 100, BattleAIScript_82DD4B1 + score +1 + +BattleAIScript_82DD4B1: + get_target_type1 + if_in_bytes sTypesTable_82DD4D9, BattleAIScript_82DD4D8 + get_target_type2 + if_in_bytes sTypesTable_82DD4D9, BattleAIScript_82DD4D8 + if_random_less_than 50, BattleAIScript_82DD4D8 + +BattleAIScript_82DD4CD: + if_random_less_than 100, BattleAIScript_82DD4D5 + score +4 + +BattleAIScript_82DD4D5: + end + +BattleAIScript_82DD4D6: + score -1 + +BattleAIScript_82DD4D8: + end + +sTypesTable_82DD4D9: + .byte TYPE_NORMAL + .byte TYPE_FIGHTING + .byte TYPE_FLYING + .byte TYPE_POISON + .byte TYPE_GROUND + .byte TYPE_ROCK + .byte TYPE_BUG + .byte TYPE_GHOST + .byte TYPE_STEEL + .byte -1 + +BattleAIScript_82DD4E3: + if_any_move_disabled AI_TARGET, BattleAIScript_82DD4FC + if_target_faster BattleAIScript_82DD509 + get_last_used_bank_move AI_TARGET + get_move_effect_from_result + if_not_in_bytes sMoveEffectsTable_82DD50C, BattleAIScript_82DD509 + +BattleAIScript_82DD4FC: + if_random_less_than 30, BattleAIScript_82DD50B + score +3 + goto BattleAIScript_82DD50B + +BattleAIScript_82DD509: + score -2 + +BattleAIScript_82DD50B: + end + +sMoveEffectsTable_82DD50C: + .byte EFFECT_DREAM_EATER + .byte EFFECT_ATTACK_UP + .byte EFFECT_DEFENSE_UP + .byte EFFECT_SPEED_UP + .byte EFFECT_SPECIAL_ATTACK_UP + .byte EFFECT_HAZE + .byte EFFECT_ROAR + .byte EFFECT_CONVERSION + .byte EFFECT_TOXIC + .byte EFFECT_LIGHT_SCREEN + .byte EFFECT_REST + .byte EFFECT_SUPER_FANG + .byte EFFECT_SPECIAL_DEFENSE_UP_2 + .byte EFFECT_CONFUSE + .byte EFFECT_POISON + .byte EFFECT_PARALYZE + .byte EFFECT_LEECH_SEED + .byte EFFECT_SPLASH + .byte EFFECT_ATTACK_UP_2 + .byte EFFECT_ENCORE + .byte EFFECT_CONVERSION_2 + .byte EFFECT_LOCK_ON + .byte EFFECT_HEAL_BELL + .byte EFFECT_MEAN_LOOK + .byte EFFECT_NIGHTMARE + .byte EFFECT_PROTECT + .byte EFFECT_SKILL_SWAP + .byte EFFECT_FORESIGHT + .byte EFFECT_PERISH_SONG + .byte EFFECT_SANDSTORM + .byte EFFECT_ENDURE + .byte EFFECT_SWAGGER + .byte EFFECT_ATTRACT + .byte EFFECT_SAFEGUARD + .byte EFFECT_RAIN_DANCE + .byte EFFECT_SUNNY_DAY + .byte EFFECT_BELLY_DRUM + .byte EFFECT_PSYCH_UP + .byte EFFECT_FUTURE_SIGHT + .byte EFFECT_FAKE_OUT + .byte EFFECT_STOCKPILE + .byte EFFECT_SPIT_UP + .byte EFFECT_SWALLOW + .byte EFFECT_HAIL + .byte EFFECT_TORMENT + .byte EFFECT_WILL_O_WISP + .byte EFFECT_FOLLOW_ME + .byte EFFECT_CHARGE + .byte EFFECT_TRICK + .byte EFFECT_ROLE_PLAY + .byte EFFECT_INGRAIN + .byte EFFECT_RECYCLE + .byte EFFECT_KNOCK_OFF + .byte EFFECT_SKILL_SWAP + .byte EFFECT_IMPRISON + .byte EFFECT_REFRESH + .byte EFFECT_GRUDGE + .byte EFFECT_TEETER_DANCE + .byte EFFECT_MUD_SPORT + .byte EFFECT_WATER_SPORT + .byte EFFECT_DRAGON_DANCE + .byte EFFECT_CAMOUFLAGE + .byte -1 + +BattleAIScript_82DD54B: + if_hp_less_than AI_TARGET, 80, BattleAIScript_82DD574 + if_target_faster BattleAIScript_82DD566 + if_hp_more_than AI_USER, 40, BattleAIScript_82DD574 + score +1 + goto BattleAIScript_82DD576 + +BattleAIScript_82DD566: + if_hp_more_than AI_USER, 60, BattleAIScript_82DD574 + score +1 + goto BattleAIScript_82DD576 + +BattleAIScript_82DD574: + score -1 + +BattleAIScript_82DD576: + end + +BattleAIScript_82DD577: + score +2 + end + +BattleAIScript_82DD57A: + if_random_less_than 128, BattleAIScript_82DD582 + score +2 + +BattleAIScript_82DD582: + end + +BattleAIScript_82DD583: + if_status AI_USER, STATUS_SLEEP, Score_Plus10 + score -5 + end + +BattleAIScript_82DD590: + score -1 + if_target_faster BattleAIScript_82DD5C5 + if_hp_more_than AI_USER, 70, BattleAIScript_82DD5C5 + if_random_less_than 128, BattleAIScript_82DD5A7 + score +1 + +BattleAIScript_82DD5A7: + if_hp_more_than AI_USER, 50, BattleAIScript_82DD5C5 + if_random_less_than 128, BattleAIScript_82DD5B6 + score +1 + +BattleAIScript_82DD5B6: + if_hp_more_than AI_USER, 30, BattleAIScript_82DD5C5 + if_random_less_than 100, BattleAIScript_82DD5C5 + score +2 + +BattleAIScript_82DD5C5: + end + +BattleAIScript_82DD5C6: + if_target_faster BattleAIScript_82DD5E6 + if_hp_more_than AI_USER, 33, BattleAIScript_82DD608 + if_hp_more_than AI_USER, 20, BattleAIScript_82DD60A + if_hp_less_than AI_USER, 8, BattleAIScript_82DD5F9 + goto BattleAIScript_82DD5FB + +BattleAIScript_82DD5E6: + if_hp_more_than AI_USER, 60, BattleAIScript_82DD608 + if_hp_more_than AI_USER, 40, BattleAIScript_82DD60A + goto BattleAIScript_82DD5FB + +BattleAIScript_82DD5F9: + score +1 + +BattleAIScript_82DD5FB: + if_random_less_than 100, BattleAIScript_82DD60A + score +1 + goto BattleAIScript_82DD60A + +BattleAIScript_82DD608: + score -1 + +BattleAIScript_82DD60A: + end + +BattleAIScript_82DD60B: + if_status AI_TARGET, STATUS_ANY, BattleAIScript_82DD621 + if_status_in_party AI_TARGET, STATUS_ANY, BattleAIScript_82DD621 + score -5 + +BattleAIScript_82DD621: + end + +BattleAIScript_82DD622: + get_hold_effect AI_TARGET + if_not_in_bytes sHoldEffectsTable_82DD63D, BattleAIScript_82DD63A + if_random_less_than 50, BattleAIScript_82DD63C + score +1 + goto BattleAIScript_82DD63C + +BattleAIScript_82DD63A: + score -2 + +BattleAIScript_82DD63C: + end + +sHoldEffectsTable_82DD63D: + .byte HOLD_EFFECT_CURE_SLP + .byte HOLD_EFFECT_CURE_STATUS + .byte HOLD_EFFECT_RESTORE_HP + .byte HOLD_EFFECT_EVASION_UP + .byte HOLD_EFFECT_LEFTOVERS + .byte HOLD_EFFECT_LIGHT_BALL + .byte HOLD_EFFECT_THICK_CLUB + .byte -1 + +BattleAIScript_82DD645: + get_user_type1 + if_equal TYPE_GHOST, BattleAIScript_82DD68A + get_user_type2 + if_equal TYPE_GHOST, BattleAIScript_82DD68A + if_stat_level_more_than AI_USER, DEF, 9, BattleAIScript_82DD693 + if_random_less_than 128, BattleAIScript_82DD665 + score +1 + +BattleAIScript_82DD665: + if_stat_level_more_than AI_USER, DEF, 7, BattleAIScript_82DD693 + if_random_less_than 128, BattleAIScript_82DD675 + score +1 + +BattleAIScript_82DD675: + if_stat_level_more_than AI_USER, DEF, 6, BattleAIScript_82DD693 + if_random_less_than 128, BattleAIScript_82DD693 + score +1 + goto BattleAIScript_82DD693 + +BattleAIScript_82DD68A: + if_hp_more_than AI_USER, 80, BattleAIScript_82DD693 + score -1 + +BattleAIScript_82DD693: + end + +BattleAIScript_82DD694: + get_protect_count AI_USER + if_more_than 1, BattleAIScript_82DD75A + if_status AI_USER, STATUS_TOXIC_POISON, BattleAIScript_82DD751 + if_status2 AI_USER, STATUS2_CURSED, BattleAIScript_82DD751 + if_status3 AI_USER, STATUS3_PERISH_SONG, BattleAIScript_82DD751 + if_status2 AI_USER, STATUS2_INFATUATION, BattleAIScript_82DD751 + if_status3 AI_USER, STATUS3_LEECHSEED, BattleAIScript_82DD751 + if_status3 AI_USER, STATUS3_YAWN, BattleAIScript_82DD751 + if_has_move_with_effect AI_TARGET, EFFECT_RESTORE_HP, BattleAIScript_82DD751 + if_has_move_with_effect AI_TARGET, EFFECT_DEFENSE_CURL, BattleAIScript_82DD751 + if_status AI_TARGET, STATUS_TOXIC_POISON, BattleAIScript_82DD730 + if_status2 AI_TARGET, STATUS2_CURSED, BattleAIScript_82DD730 + if_status3 AI_TARGET, STATUS3_PERISH_SONG, BattleAIScript_82DD730 + if_status2 AI_TARGET, STATUS2_INFATUATION, BattleAIScript_82DD730 + if_status3 AI_TARGET, STATUS3_LEECHSEED, BattleAIScript_82DD730 + if_status3 AI_TARGET, STATUS3_YAWN, BattleAIScript_82DD730 + get_last_used_bank_move AI_TARGET + get_move_effect_from_result + if_not_equal EFFECT_LOCK_ON, BattleAIScript_82DD730 + goto BattleAIScript_82DD732 + +BattleAIScript_82DD730: + score +2 + +BattleAIScript_82DD732: + if_random_less_than 128, BattleAIScript_82DD73A + score -1 + +BattleAIScript_82DD73A: + get_protect_count AI_USER + if_equal 0, BattleAIScript_82DD75C + score -1 + if_random_less_than 128, BattleAIScript_82DD75C + score -1 + goto BattleAIScript_82DD75C + +BattleAIScript_82DD751: + get_last_used_bank_move AI_TARGET + get_move_effect_from_result + if_not_equal EFFECT_LOCK_ON, BattleAIScript_82DD75C + +BattleAIScript_82DD75A: + score -2 + +BattleAIScript_82DD75C: + end + +BattleAIScript_82DD75D: + get_user_type1 + if_equal TYPE_GHOST, BattleAIScript_82DD77C + get_user_type2 + if_equal TYPE_GHOST, BattleAIScript_82DD77C + if_stat_level_more_than AI_USER, EVASION, 8, BattleAIScript_82DD782 + score -2 + goto BattleAIScript_82DD78A + +BattleAIScript_82DD77C: + if_random_less_than 80, BattleAIScript_82DD78A + +BattleAIScript_82DD782: + if_random_less_than 80, BattleAIScript_82DD78A + score +2 + +BattleAIScript_82DD78A: + end + +BattleAIScript_82DD78B: + if_hp_less_than AI_USER, 4, BattleAIScript_82DD799 + if_hp_less_than AI_USER, 35, BattleAIScript_82DD7A0 + +BattleAIScript_82DD799: + score -1 + goto BattleAIScript_82DD7A8 + +BattleAIScript_82DD7A0: + if_random_less_than 70, BattleAIScript_82DD7A8 + score +1 + +BattleAIScript_82DD7A8: + end + +BattleAIScript_82DD7A9: + if_stat_level_more_than AI_USER, ATK, 8, BattleAIScript_82DD7D6 + if_stat_level_more_than AI_USER, DEF, 8, BattleAIScript_82DD7D6 + if_stat_level_more_than AI_USER, SPATK, 8, BattleAIScript_82DD7D6 + if_stat_level_more_than AI_USER, SPDEF, 8, BattleAIScript_82DD7D6 + if_stat_level_more_than AI_USER, EVASION, 8, BattleAIScript_82DD7D6 + goto BattleAIScript_82DD7FC + +BattleAIScript_82DD7D6: + if_target_faster BattleAIScript_82DD7E8 + if_hp_more_than AI_USER, 60, BattleAIScript_82DD844 + goto BattleAIScript_82DD7EF + +BattleAIScript_82DD7E8: + if_hp_more_than AI_USER, 70, BattleAIScript_82DD844 + +BattleAIScript_82DD7EF: + if_random_less_than 80, BattleAIScript_82DD844 + score +2 + goto BattleAIScript_82DD844 + +BattleAIScript_82DD7FC: + if_stat_level_more_than AI_USER, ATK, 7, BattleAIScript_82DD829 + if_stat_level_more_than AI_USER, DEF, 7, BattleAIScript_82DD829 + if_stat_level_more_than AI_USER, SPATK, 7, BattleAIScript_82DD829 + if_stat_level_more_than AI_USER, SPDEF, 7, BattleAIScript_82DD829 + if_stat_level_more_than AI_USER, EVASION, 7, BattleAIScript_82DD829 + goto BattleAIScript_82DD842 + +BattleAIScript_82DD829: + if_target_faster BattleAIScript_82DD83B + if_hp_more_than AI_USER, 60, BattleAIScript_82DD842 + goto BattleAIScript_82DD844 + +BattleAIScript_82DD83B: + if_hp_less_than AI_USER, 70, BattleAIScript_82DD844 + +BattleAIScript_82DD842: + score -2 + +BattleAIScript_82DD844: + end + +BattleAIScript_82DD845: + is_first_turn_for AI_USER + if_not_equal 0, BattleAIScript_82DD87A + get_target_type1 + if_equal TYPE_GHOST, BattleAIScript_82DD872 + get_target_type1 + if_equal TYPE_PSYCHIC, BattleAIScript_82DD872 + get_target_type2 + if_equal TYPE_GHOST, BattleAIScript_82DD872 + get_target_type2 + if_equal TYPE_PSYCHIC, BattleAIScript_82DD872 + goto BattleAIScript_82DD87A + +BattleAIScript_82DD872: + if_random_less_than 128, BattleAIScript_82DD87A + score +1 + +BattleAIScript_82DD87A: + end + +BattleAIScript_82DD87B: + if_user_faster BattleAIScript_82DD889 + get_ability AI_USER + if_equal ABILITY_SWIFT_SWIM, BattleAIScript_82DD8B0 + +BattleAIScript_82DD889: + if_hp_less_than AI_USER, 40, BattleAIScript_82DD8B7 + get_weather + if_equal AI_WEATHER_HAIL, BattleAIScript_82DD8B0 + if_equal AI_WEATHER_SUN, BattleAIScript_82DD8B0 + if_equal AI_WEATHER_SANDSTORM, BattleAIScript_82DD8B0 + get_ability AI_USER + if_equal ABILITY_RAIN_DISH, BattleAIScript_82DD8B0 + goto BattleAIScript_82DD8B9 + +BattleAIScript_82DD8B0: + score +1 + goto BattleAIScript_82DD8B9 + +BattleAIScript_82DD8B7: + score -1 + +BattleAIScript_82DD8B9: + end + +BattleAIScript_82DD8BA: + if_hp_less_than AI_USER, 40, BattleAIScript_82DD8E0 + get_weather + if_equal AI_WEATHER_HAIL, BattleAIScript_82DD8D9 + if_equal AI_WEATHER_RAIN, BattleAIScript_82DD8D9 + if_equal AI_WEATHER_SANDSTORM, BattleAIScript_82DD8D9 + goto BattleAIScript_82DD8E2 + +BattleAIScript_82DD8D9: + score +1 + goto BattleAIScript_82DD8E2 + +BattleAIScript_82DD8E0: + score -1 + +BattleAIScript_82DD8E2: + end + +BattleAIScript_82DD8E3: + if_hp_less_than AI_USER, 90, BattleAIScript_82DD8EF + goto BattleAIScript_82DD8F1 + +BattleAIScript_82DD8EF: + score -2 + +BattleAIScript_82DD8F1: + end + +BattleAIScript_82DD8F2: + if_stat_level_more_than AI_TARGET, ATK, 8, BattleAIScript_82DD91F + if_stat_level_more_than AI_TARGET, DEF, 8, BattleAIScript_82DD91F + if_stat_level_more_than AI_TARGET, SPATK, 8, BattleAIScript_82DD91F + if_stat_level_more_than AI_TARGET, SPDEF, 8, BattleAIScript_82DD91F + if_stat_level_more_than AI_TARGET, EVASION, 8, BattleAIScript_82DD91F + goto BattleAIScript_82DD957 + +BattleAIScript_82DD91F: + if_stat_level_less_than AI_USER, ATK, 7, BattleAIScript_82DD954 + if_stat_level_less_than AI_USER, DEF, 7, BattleAIScript_82DD954 + if_stat_level_less_than AI_USER, SPATK, 7, BattleAIScript_82DD954 + if_stat_level_less_than AI_USER, SPDEF, 7, BattleAIScript_82DD954 + if_stat_level_less_than AI_USER, EVASION, 7, BattleAIScript_82DD952 + if_random_less_than 50, BattleAIScript_82DD959 + goto BattleAIScript_82DD957 + +BattleAIScript_82DD952: + score +1 + +BattleAIScript_82DD954: + score +1 + end + +BattleAIScript_82DD957: + score -2 + +BattleAIScript_82DD959: + end + +BattleAIScript_82DD95A: + if_status AI_TARGET, STATUS_SLEEP, BattleAIScript_82DD9FF + if_status2 AI_TARGET, STATUS2_INFATUATION, BattleAIScript_82DD9FF + if_status2 AI_TARGET, STATUS2_CONFUSION, BattleAIScript_82DD9FF + if_hp_more_than AI_USER, 30, BattleAIScript_82DD987 + if_random_less_than 10, BattleAIScript_82DD987 + score -1 + +BattleAIScript_82DD987: + if_hp_more_than AI_USER, 50, BattleAIScript_82DD996 + if_random_less_than 100, BattleAIScript_82DD996 + score -1 + +BattleAIScript_82DD996: + if_has_move AI_USER, MOVE_COUNTER, BattleAIScript_82DD9F6 + get_last_used_bank_move AI_TARGET + get_move_power_from_result + if_equal 0, BattleAIScript_82DD9CD + if_target_not_taunted BattleAIScript_82DD9B4 + if_random_less_than 100, BattleAIScript_82DD9B4 + score +1 + +BattleAIScript_82DD9B4: + get_last_used_bank_move AI_TARGET + get_move_type_from_result + if_not_in_bytes sTypesTable_82DDA02, BattleAIScript_82DD9FF + if_random_less_than 100, BattleAIScript_82DDA01 + score +1 + goto BattleAIScript_82DDA01 + +BattleAIScript_82DD9CD: + if_target_not_taunted BattleAIScript_82DD9DA + if_random_less_than 100, BattleAIScript_82DD9DA + score +1 + +BattleAIScript_82DD9DA: + get_target_type1 + if_in_bytes sTypesTable_82DDA02, BattleAIScript_82DDA01 + get_target_type2 + if_in_bytes sTypesTable_82DDA02, BattleAIScript_82DDA01 + if_random_less_than 50, BattleAIScript_82DDA01 + +BattleAIScript_82DD9F6: + if_random_less_than 100, BattleAIScript_82DD9FE + score +4 + +BattleAIScript_82DD9FE: + end + +BattleAIScript_82DD9FF: + score -1 + +BattleAIScript_82DDA01: + end + +sTypesTable_82DDA02: + .byte TYPE_FIRE + .byte TYPE_WATER + .byte TYPE_GRASS + .byte TYPE_ELECTRIC + .byte TYPE_PSYCHIC + .byte TYPE_ICE + .byte TYPE_DRAGON + .byte TYPE_DARK + .byte -1 + +BattleAIScript_82DDA0B: + if_type_effectiveness AI_EFFECTIVENESS_x0_25, BattleAIScript_82DDA2C + if_type_effectiveness AI_EFFECTIVENESS_x0_5, BattleAIScript_82DDA2C + if_has_move_with_effect AI_TARGET, EFFECT_PROTECT, BattleAIScript_82DDA2C + if_hp_more_than AI_USER, 38, BattleAIScript_82DDA2E + score -1 + goto BattleAIScript_82DDA2E + +BattleAIScript_82DDA2C: + score -2 + +BattleAIScript_82DDA2E: + end + +BattleAIScript_82DDA2F: + if_doesnt_have_move_with_effect AI_TARGET, EFFECT_PROTECT, BattleAIScript_82DDA3D + score -1 + goto BattleAIScript_82DDAB4 + +BattleAIScript_82DDA3D: + if_status AI_TARGET, STATUS_TOXIC_POISON, BattleAIScript_82DDAAC + if_status2 AI_TARGET, STATUS2_CURSED, BattleAIScript_82DDAAC + if_status3 AI_TARGET, STATUS3_LEECHSEED, BattleAIScript_82DDAAC + get_weather + if_equal AI_WEATHER_HAIL, BattleAIScript_82DDA6D + if_equal AI_WEATHER_SANDSTORM, BattleAIScript_82DDA88 + goto BattleAIScript_82DDA98 + +BattleAIScript_82DDA6D: + get_user_type1 + if_in_bytes sTypesTable_82DDAB5, BattleAIScript_82DDAAC + get_user_type2 + if_in_bytes sTypesTable_82DDAB5, BattleAIScript_82DDAAC + goto BattleAIScript_82DDA98 + +BattleAIScript_82DDA88: + get_user_type1 + if_equal TYPE_ICE, BattleAIScript_82DDAAC + get_user_type2 + if_equal TYPE_ICE, BattleAIScript_82DDAAC + +BattleAIScript_82DDA98: + if_target_faster BattleAIScript_82DDAB4 + get_last_used_bank_move AI_TARGET + get_move_effect_from_result + if_not_equal EFFECT_LOCK_ON, BattleAIScript_82DDAAC + goto BattleAIScript_82DDAB4 + +BattleAIScript_82DDAAC: + if_random_less_than 80, BattleAIScript_82DDAB4 + score +1 + +BattleAIScript_82DDAB4: + end + +sTypesTable_82DDAB5: + .byte TYPE_GROUND + .byte TYPE_ROCK + .byte TYPE_STEEL + .byte -1 + +BattleAIScript_82DDAB9: + score +2 + end + +BattleAIScript_82DDABC: + get_stockpile_count AI_USER + if_less_than 2, BattleAIScript_82DDACC + if_random_less_than 80, BattleAIScript_82DDACC + score +2 + +BattleAIScript_82DDACC: + end + +BattleAIScript_82DDACD: + if_hp_less_than AI_USER, 40, BattleAIScript_82DDAF3 + get_weather + if_equal AI_WEATHER_SUN, BattleAIScript_82DDAEC + if_equal AI_WEATHER_RAIN, BattleAIScript_82DDAEC + if_equal AI_WEATHER_SANDSTORM, BattleAIScript_82DDAEC + goto BattleAIScript_82DDAF5 + +BattleAIScript_82DDAEC: + score +1 + goto BattleAIScript_82DDAF5 + +BattleAIScript_82DDAF3: + score -1 + +BattleAIScript_82DDAF5: + end + +BattleAIScript_82DDAF6: + if_not_status AI_TARGET, STATUS_POISON | STATUS_BURN | STATUS_PARALYSIS | STATUS_TOXIC_POISON, BattleAIScript_82DDB02 + score +1 + +BattleAIScript_82DDB02: + end + +BattleAIScript_82DDB03: + if_type_effectiveness AI_EFFECTIVENESS_x0_25, BattleAIScript_82DDB42 + if_type_effectiveness AI_EFFECTIVENESS_x0_5, BattleAIScript_82DDB42 + if_status AI_TARGET, STATUS_SLEEP, BattleAIScript_82DDB59 + if_status2 AI_TARGET, STATUS2_INFATUATION, BattleAIScript_82DDB49 + if_status2 AI_TARGET, STATUS2_CONFUSION, BattleAIScript_82DDB49 + is_first_turn_for AI_USER + if_not_equal 0, BattleAIScript_82DDB5B + if_random_less_than 100, BattleAIScript_82DDB5B + score +1 + goto BattleAIScript_82DDB5B + +BattleAIScript_82DDB42: + score -1 + goto BattleAIScript_82DDB5B + +BattleAIScript_82DDB49: + if_random_less_than 100, BattleAIScript_82DDB5B + if_status2 AI_USER, STATUS2_SUBSTITUTE, Score_Plus5 + +BattleAIScript_82DDB59: + score +1 + +BattleAIScript_82DDB5B: + end + +BattleAIScript_82DDB5C: + if_status AI_TARGET, STATUS_PARALYSIS, BattleAIScript_82DDB6B + goto BattleAIScript_82DDB6D + +BattleAIScript_82DDB6B: + score +1 + +BattleAIScript_82DDB6D: + end + +BattleAIScript_82DDB6E: + get_hold_effect AI_USER + if_in_bytes sHoldEffectsTable_82DDBB7, BattleAIScript_82DDB89 + if_in_bytes sHoldEffectsTable_82DDBAF, BattleAIScript_82DDB9B + +BattleAIScript_82DDB82: + score -3 + goto BattleAIScript_82DDBAE + +BattleAIScript_82DDB89: + get_hold_effect AI_TARGET + if_in_bytes sHoldEffectsTable_82DDBB7, BattleAIScript_82DDB82 + score +5 + goto BattleAIScript_82DDBAE + +BattleAIScript_82DDB9B: + get_hold_effect AI_TARGET + if_in_bytes sHoldEffectsTable_82DDBAF, BattleAIScript_82DDB82 + if_random_less_than 50, BattleAIScript_82DDBAE + score +2 + +BattleAIScript_82DDBAE: + end + +sHoldEffectsTable_82DDBAF: + .byte HOLD_EFFECT_CONFUSE_SPICY + .byte HOLD_EFFECT_CONFUSE_DRY + .byte HOLD_EFFECT_CONFUSE_SWEET + .byte HOLD_EFFECT_CONFUSE_BITTER + .byte HOLD_EFFECT_CONFUSE_SOUR + .byte HOLD_EFFECT_MACHO_BRACE + .byte HOLD_EFFECT_CHOICE_BAND + .byte -1 + +sHoldEffectsTable_82DDBB7: + .byte HOLD_EFFECT_CHOICE_BAND + .byte -1 + +BattleAIScript_82DDBB9: + get_ability AI_USER + if_in_bytes sAbilitiesTable_82DDBDF, BattleAIScript_82DDBCF + get_ability AI_TARGET + if_in_bytes sAbilitiesTable_82DDBDF, BattleAIScript_82DDBD6 + +BattleAIScript_82DDBCF: + score -1 + goto BattleAIScript_82DDBDE + +BattleAIScript_82DDBD6: + if_random_less_than 50, BattleAIScript_82DDBDE + score +2 + +BattleAIScript_82DDBDE: + end + +sAbilitiesTable_82DDBDF: + .byte ABILITY_SPEED_BOOST + .byte ABILITY_BATTLE_ARMOR + .byte ABILITY_SAND_VEIL + .byte ABILITY_STATIC + .byte ABILITY_FLASH_FIRE + .byte ABILITY_WONDER_GUARD + .byte ABILITY_EFFECT_SPORE + .byte ABILITY_SWIFT_SWIM + .byte ABILITY_HUGE_POWER + .byte ABILITY_RAIN_DISH + .byte ABILITY_CUTE_CHARM + .byte ABILITY_SHED_SKIN + .byte ABILITY_MARVEL_SCALE + .byte ABILITY_PURE_POWER + .byte ABILITY_CHLOROPHYLL + .byte ABILITY_SHIELD_DUST + .byte -1 + +BattleAIScript_82DDBF0: + if_type_effectiveness AI_EFFECTIVENESS_x0_25, BattleAIScript_82DDC1D + if_type_effectiveness AI_EFFECTIVENESS_x0_5, BattleAIScript_82DDC1D + if_stat_level_less_than AI_USER, ATK, 6, BattleAIScript_82DDC1D + if_target_faster BattleAIScript_82DDC16 + if_hp_more_than AI_USER, 40, BattleAIScript_82DDC1D + goto BattleAIScript_82DDC1F + +BattleAIScript_82DDC16: + if_hp_less_than AI_USER, 60, BattleAIScript_82DDC1F + +BattleAIScript_82DDC1D: + score -1 + +BattleAIScript_82DDC1F: + end + +BattleAIScript_82DDC20: + if_hp_more_than AI_TARGET, 30, BattleAIScript_82DDC2F + if_random_less_than 100, BattleAIScript_82DDC2F + score -1 + +BattleAIScript_82DDC2F: + is_first_turn_for AI_USER + if_equal 0, BattleAIScript_82DDC4A + if_random_less_than 150, BattleAIScript_82DDC52 + score +1 + goto BattleAIScript_82DDC52 + +AI_CV_MagicCoat3: + if_random_less_than 50, BattleAIScript_82DDC52 + +BattleAIScript_82DDC4A: + if_random_less_than 30, BattleAIScript_82DDC52 + score -1 + +BattleAIScript_82DDC52: + end + +BattleAIScript_82DDC53: + get_used_held_item AI_USER + if_not_in_bytes sItemsTable_82DDC6E, BattleAIScript_82DDC6B + if_random_less_than 50, BattleAIScript_82DDC6D + score +1 + goto BattleAIScript_82DDC6D + +BattleAIScript_82DDC6B: + score -2 + +BattleAIScript_82DDC6D: + end + +sItemsTable_82DDC6E: + .byte ITEM_CHESTO_BERRY + .byte ITEM_LUM_BERRY + .byte ITEM_STARF_BERRY + .byte -1 + +BattleAIScript_82DDC72: + if_status AI_TARGET, STATUS_SLEEP, BattleAIScript_82DDC9D + if_status2 AI_TARGET, STATUS2_INFATUATION, BattleAIScript_82DDC9D + if_status2 AI_TARGET, STATUS2_CONFUSION, BattleAIScript_82DDC9D + if_random_less_than 180, BattleAIScript_82DDC9D + score +2 + goto BattleAIScript_82DDC9F + +BattleAIScript_82DDC9D: + score -2 + +BattleAIScript_82DDC9F: + end + +BattleAIScript_82DDCA0: + if_side_affecting AI_TARGET, SIDE_STATUS_REFLECT, BattleAIScript_82DDCAF + goto BattleAIScript_82DDCB1 + +BattleAIScript_82DDCAF: + score +1 + +BattleAIScript_82DDCB1: + end + +BattleAIScript_82DDCB2: + if_hp_less_than AI_TARGET, 30, BattleAIScript_82DDCC9 + is_first_turn_for AI_USER + if_more_than 0, BattleAIScript_82DDCC9 + if_random_less_than 180, BattleAIScript_82DDCC9 + score +1 + +BattleAIScript_82DDCC9: + end + +BattleAIScript_82DDCCA: + if_hp_less_than AI_TARGET, 70, BattleAIScript_82DDCF3 + if_target_faster BattleAIScript_82DDCE5 + if_hp_more_than AI_USER, 40, BattleAIScript_82DDCF3 + score +1 + goto BattleAIScript_82DDCF5 + +BattleAIScript_82DDCE5: + if_hp_more_than AI_USER, 50, BattleAIScript_82DDCF3 + score +1 + goto BattleAIScript_82DDCF5 + +BattleAIScript_82DDCF3: + score -1 + +BattleAIScript_82DDCF5: + end + +BattleAIScript_82DDCF6: + if_type_effectiveness AI_EFFECTIVENESS_x0_25, BattleAIScript_82DDD1B + if_type_effectiveness AI_EFFECTIVENESS_x0_5, BattleAIScript_82DDD1B + if_target_faster BattleAIScript_82DDD14 + if_hp_more_than AI_TARGET, 50, BattleAIScript_82DDD1D + goto BattleAIScript_82DDD1B + +BattleAIScript_82DDD14: + if_hp_more_than AI_TARGET, 70, BattleAIScript_82DDD1D + +BattleAIScript_82DDD1B: + score -1 + +BattleAIScript_82DDD1D: + end + +BattleAIScript_82DDD1E: + is_first_turn_for AI_USER + if_more_than 0, BattleAIScript_82DDD2E + if_random_less_than 100, BattleAIScript_82DDD2E + score +2 + +BattleAIScript_82DDD2E: + end + +BattleAIScript_82DDD2F: + if_hp_less_than AI_TARGET, 50, BattleAIScript_82DDD3B + goto BattleAIScript_82DDD3D + +BattleAIScript_82DDD3B: + score -1 + +BattleAIScript_82DDD3D: + end + +BattleAIScript_82DDD3E: + is_first_turn_for AI_USER + if_equal 1, BattleAIScript_82DDD85 + if_random_less_than 30, BattleAIScript_82DDDA7 + if_target_faster BattleAIScript_82DDD6B + if_hp_not_equal AI_USER, 100, BattleAIScript_82DDD9F + if_hp_less_than AI_TARGET, 70, BattleAIScript_82DDD9F + if_random_less_than 60, BattleAIScript_82DDDA7 + goto BattleAIScript_82DDD9F + +BattleAIScript_82DDD6B: + if_hp_more_than AI_TARGET, 25, BattleAIScript_82DDD9F + if_has_move_with_effect AI_TARGET, EFFECT_RESTORE_HP, BattleAIScript_82DDD85 + if_has_move_with_effect AI_TARGET, EFFECT_DEFENSE_CURL, BattleAIScript_82DDD85 + goto BattleAIScript_82DDD92 + +BattleAIScript_82DDD85: + if_random_less_than 150, BattleAIScript_82DDDA7 + score +2 + goto BattleAIScript_82DDDA7 + +BattleAIScript_82DDD92: + if_random_less_than 230, BattleAIScript_82DDD9F + score +1 + goto BattleAIScript_82DDDA7 + +BattleAIScript_82DDD9F: + if_random_less_than 30, BattleAIScript_82DDDA7 + score -2 + +BattleAIScript_82DDDA7: + end + +BattleAIScript_82DDDA8: + if_hp_less_than AI_USER, 50, BattleAIScript_82DDDCB + get_target_type1 + if_equal TYPE_ELECTRIC, BattleAIScript_82DDDC4 + get_target_type2 + if_equal TYPE_ELECTRIC, BattleAIScript_82DDDC4 + goto BattleAIScript_82DDDCB + +BattleAIScript_82DDDC4: + score +1 + goto BattleAIScript_82DDDCD + +BattleAIScript_82DDDCB: + score -1 + +BattleAIScript_82DDDCD: + end + +BattleAIScript_82DDDCE: + if_type_effectiveness AI_EFFECTIVENESS_x0_25, BattleAIScript_82DDDF3 + if_type_effectiveness AI_EFFECTIVENESS_x0_5, BattleAIScript_82DDDF3 + if_target_faster BattleAIScript_82DDDEC + if_hp_more_than AI_USER, 60, BattleAIScript_82DDDF5 + goto BattleAIScript_82DDDF3 + +BattleAIScript_82DDDEC: + if_hp_more_than AI_USER, 80, BattleAIScript_82DDDF5 + +BattleAIScript_82DDDF3: + score -1 + +BattleAIScript_82DDDF5: + end + +BattleAIScript_82DDDF6: + if_hp_less_than AI_USER, 50, BattleAIScript_82DDE19 + get_target_type1 + if_equal TYPE_FIRE, BattleAIScript_82DDE12 + get_target_type2 + if_equal TYPE_FIRE, BattleAIScript_82DDE12 + goto BattleAIScript_82DDE19 + +BattleAIScript_82DDE12: + score +1 + goto BattleAIScript_82DDE1B + +BattleAIScript_82DDE19: + score -1 + +BattleAIScript_82DDE1B: + end + +BattleAIScript_82DDE1C: + if_target_faster BattleAIScript_82DDE36 + if_hp_more_than AI_USER, 50, BattleAIScript_82DDE3E + if_random_less_than 70, BattleAIScript_82DDE3E + score -1 + goto BattleAIScript_82DDE3E + +BattleAIScript_82DDE36: + if_random_less_than 128, BattleAIScript_82DDE3E + score +1 + +BattleAIScript_82DDE3E: + end + +AI_CheckViability: + if_target_is_ally AI_Ret + if_can_faint BattleAIScript_82DDE60 + get_how_powerful_move_is + if_equal 1, Score_Minus1 + if_type_effectiveness AI_EFFECTIVENESS_x4, BattleAIScript_82DDE57 + end + +BattleAIScript_82DDE57: + if_random_less_than 80, BattleAIScript_82DDE70 + score +2 + end + +BattleAIScript_82DDE60: + if_effect EFFECT_EXPLOSION, BattleAIScript_82DDE70 + if_not_effect EFFECT_QUICK_ATTACK, BattleAIScript_82DDE6E + score +2 + +BattleAIScript_82DDE6E: + score +4 + +BattleAIScript_82DDE70: + end + +AI_SetupFirstTurn: + if_target_is_ally AI_Ret + get_turn_count + if_not_equal 0, BattleAIScript_82DDE8F + get_considered_move_effect + if_not_in_bytes sMoveEffectsTable_82DDE90, BattleAIScript_82DDE8F + if_random_less_than 80, BattleAIScript_82DDE8F + score +2 + +BattleAIScript_82DDE8F: + end + +sMoveEffectsTable_82DDE90: + .byte EFFECT_ATTACK_UP + .byte EFFECT_DEFENSE_UP + .byte EFFECT_SPEED_UP + .byte EFFECT_SPECIAL_ATTACK_UP + .byte EFFECT_SPECIAL_DEFENSE_UP + .byte EFFECT_ACCURACY_UP + .byte EFFECT_EVASION_UP + .byte EFFECT_ATTACK_DOWN + .byte EFFECT_DEFENSE_DOWN + .byte EFFECT_SPEED_DOWN + .byte EFFECT_SPECIAL_ATTACK_DOWN + .byte EFFECT_SPECIAL_DEFENSE_DOWN + .byte EFFECT_ACCURACY_DOWN + .byte EFFECT_EVASION_DOWN + .byte EFFECT_CONVERSION + .byte EFFECT_LIGHT_SCREEN + .byte EFFECT_SPECIAL_DEFENSE_UP_2 + .byte EFFECT_FOCUS_ENERGY + .byte EFFECT_CONFUSE + .byte EFFECT_ATTACK_UP_2 + .byte EFFECT_DEFENSE_UP_2 + .byte EFFECT_SPEED_UP_2 + .byte EFFECT_SPECIAL_ATTACK_UP_2 + .byte EFFECT_SPECIAL_DEFENSE_UP_2 + .byte EFFECT_ACCURACY_UP_2 + .byte EFFECT_EVASION_UP_2 + .byte EFFECT_ATTACK_DOWN_2 + .byte EFFECT_DEFENSE_DOWN_2 + .byte EFFECT_SPEED_DOWN_2 + .byte EFFECT_SPECIAL_ATTACK_DOWN_2 + .byte EFFECT_SPECIAL_DEFENSE_DOWN_2 + .byte EFFECT_ACCURACY_DOWN_2 + .byte EFFECT_EVASION_DOWN_2 + .byte EFFECT_REFLECT + .byte EFFECT_POISON + .byte EFFECT_PARALYZE + .byte EFFECT_SUBSTITUTE + .byte EFFECT_LEECH_SEED + .byte EFFECT_MINIMIZE + .byte EFFECT_CURSE + .byte EFFECT_SWAGGER + .byte EFFECT_CAMOUFLAGE + .byte EFFECT_YAWN + .byte EFFECT_DEFENSE_CURL + .byte EFFECT_TORMENT + .byte EFFECT_FLATTER + .byte EFFECT_WILL_O_WISP + .byte EFFECT_INGRAIN + .byte EFFECT_IMPRISON + .byte EFFECT_TEETER_DANCE + .byte EFFECT_TICKLE + .byte EFFECT_COSMIC_POWER + .byte EFFECT_BULK_UP + .byte EFFECT_CALM_MIND + .byte EFFECT_CAMOUFLAGE + .byte -1 + +AI_PreferStrongestMove: + if_target_is_ally AI_Ret + get_how_powerful_move_is + if_not_equal 0, BattleAIScript_82DDEDC + if_random_less_than 100, BattleAIScript_82DDEDC + score +2 + +BattleAIScript_82DDEDC: + end + +AI_Risky: + if_target_is_ally AI_Ret + get_considered_move_effect + if_not_in_bytes sMoveEffectsTable_82DDEF5, BattleAIScript_82DDEF4 + if_random_less_than 128, BattleAIScript_82DDEF4 + score +2 + +BattleAIScript_82DDEF4: + end + +sMoveEffectsTable_82DDEF5: + .byte EFFECT_SLEEP + .byte EFFECT_EXPLOSION + .byte EFFECT_MIRROR_MOVE + .byte EFFECT_OHKO + .byte EFFECT_HIGH_CRITICAL + .byte EFFECT_CONFUSE + .byte EFFECT_METRONOME + .byte EFFECT_PSYWAVE + .byte EFFECT_COUNTER + .byte EFFECT_DESTINY_BOND + .byte EFFECT_SWAGGER + .byte EFFECT_ATTRACT + .byte EFFECT_PRESENT + .byte EFFECT_ALL_STATS_UP_HIT + .byte EFFECT_BELLY_DRUM + .byte EFFECT_MIRROR_COAT + .byte EFFECT_FOCUS_PUNCH + .byte EFFECT_REVENGE + .byte EFFECT_TEETER_DANCE + .byte -1 + +AI_PreferBatonPass: + if_target_is_ally AI_Ret + count_usable_party_mons AI_USER + if_equal 0, BattleAIScript_82DDFB3 + get_how_powerful_move_is + if_not_equal 0, BattleAIScript_82DDFB3 + if_has_move_with_effect AI_USER, EFFECT_BATON_PASS, BattleAIScript_82DDF2A + if_random_less_than 80, BattleAIScript_82DDEF4 + +BattleAIScript_82DDF2A: + if_move MOVE_SWORDS_DANCE, BattleAIScript_82DDF54 + if_move MOVE_DRAGON_DANCE, BattleAIScript_82DDF54 + if_move MOVE_CALM_MIND, BattleAIScript_82DDF54 + if_effect EFFECT_PROTECT, BattleAIScript_82DDF67 + if_move MOVE_BATON_PASS, BattleAIScript_82DDF7B + if_random_less_than 20, BattleAIScript_82DDEF4 + score +3 + +BattleAIScript_82DDF54: + get_turn_count + if_equal 0, Score_Plus5 + if_hp_less_than AI_USER, 60, Score_Minus10 + goto Score_Plus1 + +BattleAIScript_82DDF67: + get_last_used_bank_move AI_USER + if_in_hwords sMovesTable_82DDF75, Score_Minus2 + score +2 + end + +sMovesTable_82DDF75: + .2byte MOVE_PROTECT + .2byte MOVE_DETECT + .2byte -1 + +BattleAIScript_82DDF7B: + get_turn_count + if_equal 0, Score_Minus2 + if_stat_level_more_than AI_USER, ATK, 8, Score_Plus3 + if_stat_level_more_than AI_USER, ATK, 7, Score_Plus2 + if_stat_level_more_than AI_USER, ATK, 6, Score_Plus1 + if_stat_level_more_than AI_USER, SPATK, 8, Score_Plus3 + if_stat_level_more_than AI_USER, SPATK, 7, Score_Plus2 + if_stat_level_more_than AI_USER, SPATK, 6, Score_Plus1 + end + +BattleAIScript_82DDFB3: + end + +AI_DoubleBattle: + if_target_is_ally AI_TryOnAlly + if_move MOVE_SKILL_SWAP, BattleAIScript_82DE04B + get_curr_move_type + if_move MOVE_EARTHQUAKE, BattleAIScript_82DE010 + if_move MOVE_MAGNITUDE, BattleAIScript_82DE010 + if_equal 13, BattleAIScript_82DE062 + if_equal 10, BattleAIScript_82DE079 + get_ability AI_USER + if_not_equal ABILITY_GUTS, BattleAIScript_82DDFF5 + if_has_move AI_USER_PARTNER, MOVE_HELPING_HAND, BattleAIScript_82DDFED + end + +BattleAIScript_82DDFED: + get_how_powerful_move_is + if_not_equal 0, Score_Plus1 + end + +BattleAIScript_82DDFF5: + if_status AI_USER, STATUS_ANY, BattleAIScript_82DE000 + end + +BattleAIScript_82DE000: + get_how_powerful_move_is + if_equal 0, Score_Minus5 + score +1 + if_equal 2, Score_Plus2 + end + +BattleAIScript_82DE010: + if_ability AI_USER_PARTNER, ABILITY_LEVITATE, Score_Plus2 + if_type AI_USER_PARTNER, TYPE_FLYING, Score_Plus2 + if_type AI_USER_PARTNER, TYPE_FIRE, Score_Minus10 + if_type AI_USER_PARTNER, TYPE_ELECTRIC, Score_Minus10 + if_type AI_USER_PARTNER, TYPE_POISON, Score_Minus10 + if_type AI_USER_PARTNER, TYPE_ROCK, Score_Minus10 + goto Score_Minus3 + +BattleAIScript_82DE04B: + get_ability AI_USER + if_equal ABILITY_TRUANT, Score_Plus5 + get_ability AI_TARGET + if_equal ABILITY_SHADOW_TAG, Score_Plus2 + if_equal ABILITY_PURE_POWER, Score_Plus2 + end + +BattleAIScript_82DE062: + if_no_ability AI_TARGET_PARTNER, ABILITY_LIGHTNING_ROD, BattleAIScript_82DE078 + score -2 + if_no_type AI_TARGET_PARTNER, TYPE_GROUND, BattleAIScript_82DE078 + score -8 + +BattleAIScript_82DE078: + end + +BattleAIScript_82DE079: + if_flash_fired AI_USER, BattleAIScript_82DE080 + end + +BattleAIScript_82DE080: + goto Score_Plus1 + +AI_TryOnAlly: + get_how_powerful_move_is + if_equal 0, BattleAIScript_82DE0B2 + get_curr_move_type + if_equal TYPE_FIRE, BattleAIScript_82DE099 + +AI_DiscourageOnAlly: + goto Score_Minus30 + +BattleAIScript_82DE099: + if_ability AI_USER_PARTNER, ABILITY_FLASH_FIRE, BattleAIScript_82DE0A7 + goto AI_DiscourageOnAlly + +BattleAIScript_82DE0A7: + if_flash_fired AI_USER_PARTNER, AI_DiscourageOnAlly + goto Score_Plus3 + +BattleAIScript_82DE0B2: + if_move MOVE_SKILL_SWAP, BattleAIScript_82DE0DA + if_move MOVE_WILL_O_WISP, BattleAIScript_82DE14F + if_move MOVE_TOXIC, BattleAIScript_82DE14F + if_move MOVE_HELPING_HAND, BattleAIScript_82DE16D + if_move MOVE_SWAGGER, BattleAIScript_82DE178 + goto Score_Minus30_ + +BattleAIScript_82DE0DA: + get_ability AI_TARGET + if_equal ABILITY_TRUANT, Score_Plus10 + get_ability AI_USER + if_not_equal ABILITY_LEVITATE, BattleAIScript_82DE107 + get_ability AI_TARGET + if_equal ABILITY_LEVITATE, Score_Minus30_ + get_target_type1 + if_not_equal TYPE_ELECTRIC, BattleAIScript_82DE107 + score +1 + get_target_type2 + if_not_equal TYPE_ELECTRIC, BattleAIScript_82DE107 + score +1 + end + +BattleAIScript_82DE107: + if_not_equal 14, Score_Minus30_ + if_has_move AI_USER_PARTNER, MOVE_FIRE_BLAST, BattleAIScript_82DE14A + if_has_move AI_USER_PARTNER, MOVE_THUNDER, BattleAIScript_82DE14A + if_has_move AI_USER_PARTNER, MOVE_CROSS_CHOP, BattleAIScript_82DE14A + if_has_move AI_USER_PARTNER, MOVE_HYDRO_PUMP, BattleAIScript_82DE14A + if_has_move AI_USER_PARTNER, MOVE_DYNAMIC_PUNCH, BattleAIScript_82DE14A + if_has_move AI_USER_PARTNER, MOVE_BLIZZARD, BattleAIScript_82DE14A + if_has_move AI_USER_PARTNER, MOVE_MEGAHORN, BattleAIScript_82DE14A + goto Score_Minus30_ + +BattleAIScript_82DE14A: + goto Score_Plus3 + +BattleAIScript_82DE14F: + get_ability AI_TARGET + if_not_equal ABILITY_GUTS, Score_Minus30_ + if_status AI_TARGET, STATUS_ANY, Score_Minus30_ + if_hp_less_than AI_USER, 91, Score_Minus30_ + goto Score_Plus5 + +BattleAIScript_82DE16D: + if_random_less_than 64, Score_Minus1 + goto Score_Plus2 + +BattleAIScript_82DE178: + if_holds_item AI_TARGET, ITEM_PERSIM_BERRY, BattleAIScript_82DE185 + goto Score_Minus30_ + +BattleAIScript_82DE185: + if_stat_level_more_than AI_TARGET, ATK, 7, BattleAIScript_82DE18F + score +3 + +BattleAIScript_82DE18F: + end + +Score_Minus30_: + score -30 + end + +AI_HPAware: + if_target_is_ally AI_TryOnAlly + if_hp_more_than AI_USER, 70, BattleAIScript_82DE1B5 + if_hp_more_than AI_USER, 30, BattleAIScript_82DE1C4 + get_considered_move_effect + if_in_bytes sMoveEffectsTable_82DE258, BattleAIScript_82DE1D3 + goto BattleAIScript_82DE1DB + +BattleAIScript_82DE1B5: + get_considered_move_effect + if_in_bytes sMoveEffectsTable_82DE21F, BattleAIScript_82DE1D3 + goto BattleAIScript_82DE1DB + +BattleAIScript_82DE1C4: + get_considered_move_effect + if_in_bytes sMoveEffectsTable_82DE22D, BattleAIScript_82DE1D3 + goto BattleAIScript_82DE1DB + +BattleAIScript_82DE1D3: + if_random_less_than 50, BattleAIScript_82DE1DB + score -2 + +BattleAIScript_82DE1DB: + if_hp_more_than AI_TARGET, 70, BattleAIScript_82DE1F8 + if_hp_more_than AI_TARGET, 30, BattleAIScript_82DE207 + get_considered_move_effect + if_in_bytes sMoveEffectsTable_82DE2B1, BattleAIScript_82DE216 + goto BattleAIScript_82DE21E + +BattleAIScript_82DE1F8: + get_considered_move_effect + if_in_bytes sMoveEffectsTable_82DE288, BattleAIScript_82DE216 + goto BattleAIScript_82DE21E + +BattleAIScript_82DE207: + get_considered_move_effect + if_in_bytes sMoveEffectsTable_82DE289, BattleAIScript_82DE216 + goto BattleAIScript_82DE21E + +BattleAIScript_82DE216: + if_random_less_than 50, BattleAIScript_82DE21E + score -2 + +BattleAIScript_82DE21E: + end + +sMoveEffectsTable_82DE21F: + .byte EFFECT_EXPLOSION + .byte EFFECT_RESTORE_HP + .byte EFFECT_REST + .byte EFFECT_DESTINY_BOND + .byte EFFECT_FLAIL + .byte EFFECT_ENDURE + .byte EFFECT_MORNING_SUN + .byte EFFECT_SYNTHESIS + .byte EFFECT_MOONLIGHT + .byte EFFECT_SOFTBOILED + .byte EFFECT_MEMENTO + .byte EFFECT_GRUDGE + .byte EFFECT_OVERHEAT + .byte -1 + +sMoveEffectsTable_82DE22D: + .byte EFFECT_EXPLOSION + .byte EFFECT_ATTACK_UP + .byte EFFECT_DEFENSE_UP + .byte EFFECT_SPEED_UP + .byte EFFECT_SPECIAL_ATTACK_UP + .byte EFFECT_SPECIAL_DEFENSE_UP + .byte EFFECT_ACCURACY_UP + .byte EFFECT_EVASION_UP + .byte EFFECT_ATTACK_DOWN + .byte EFFECT_DEFENSE_DOWN + .byte EFFECT_SPEED_DOWN + .byte EFFECT_SPECIAL_ATTACK_DOWN + .byte EFFECT_SPECIAL_DEFENSE_DOWN + .byte EFFECT_ACCURACY_DOWN + .byte EFFECT_EVASION_DOWN + .byte EFFECT_BIDE + .byte EFFECT_CONVERSION + .byte EFFECT_LIGHT_SCREEN + .byte EFFECT_MIST + .byte EFFECT_FOCUS_ENERGY + .byte EFFECT_ATTACK_UP_2 + .byte EFFECT_DEFENSE_UP_2 + .byte EFFECT_SPEED_UP_2 + .byte EFFECT_SPECIAL_ATTACK_UP_2 + .byte EFFECT_SPECIAL_DEFENSE_UP_2 + .byte EFFECT_ACCURACY_UP_2 + .byte EFFECT_EVASION_UP_2 + .byte EFFECT_ATTACK_DOWN_2 + .byte EFFECT_DEFENSE_DOWN_2 + .byte EFFECT_SPEED_DOWN_2 + .byte EFFECT_SPECIAL_ATTACK_DOWN_2 + .byte EFFECT_SPECIAL_DEFENSE_DOWN_2 + .byte EFFECT_ACCURACY_DOWN_2 + .byte EFFECT_EVASION_DOWN_2 + .byte EFFECT_CONVERSION_2 + .byte EFFECT_SAFEGUARD + .byte EFFECT_BELLY_DRUM + .byte EFFECT_TICKLE + .byte EFFECT_COSMIC_POWER + .byte EFFECT_BULK_UP + .byte EFFECT_CALM_MIND + .byte EFFECT_DRAGON_DANCE + .byte -1 + +sMoveEffectsTable_82DE258: + .byte EFFECT_ATTACK_UP + .byte EFFECT_DEFENSE_UP + .byte EFFECT_SPEED_UP + .byte EFFECT_SPECIAL_ATTACK_UP + .byte EFFECT_SPECIAL_DEFENSE_UP + .byte EFFECT_ACCURACY_UP + .byte EFFECT_EVASION_UP + .byte EFFECT_ATTACK_DOWN + .byte EFFECT_DEFENSE_DOWN + .byte EFFECT_SPEED_DOWN + .byte EFFECT_SPECIAL_ATTACK_DOWN + .byte EFFECT_SPECIAL_DEFENSE_DOWN + .byte EFFECT_ACCURACY_DOWN + .byte EFFECT_EVASION_DOWN + .byte EFFECT_BIDE + .byte EFFECT_CONVERSION + .byte EFFECT_LIGHT_SCREEN + .byte EFFECT_MIST + .byte EFFECT_FOCUS_ENERGY + .byte EFFECT_ATTACK_UP_2 + .byte EFFECT_DEFENSE_UP_2 + .byte EFFECT_SPEED_UP_2 + .byte EFFECT_SPECIAL_ATTACK_UP_2 + .byte EFFECT_SPECIAL_DEFENSE_UP_2 + .byte EFFECT_ACCURACY_UP_2 + .byte EFFECT_EVASION_UP_2 + .byte EFFECT_ATTACK_DOWN_2 + .byte EFFECT_DEFENSE_DOWN_2 + .byte EFFECT_SPEED_DOWN_2 + .byte EFFECT_SPECIAL_ATTACK_DOWN_2 + .byte EFFECT_SPECIAL_DEFENSE_DOWN_2 + .byte EFFECT_ACCURACY_DOWN_2 + .byte EFFECT_EVASION_DOWN_2 + .byte EFFECT_RAGE + .byte EFFECT_CONVERSION_2 + .byte EFFECT_LOCK_ON + .byte EFFECT_SAFEGUARD + .byte EFFECT_BELLY_DRUM + .byte EFFECT_PSYCH_UP + .byte EFFECT_MIRROR_COAT + .byte EFFECT_SOLARBEAM + .byte EFFECT_ERUPTION + .byte EFFECT_TICKLE + .byte EFFECT_COSMIC_POWER + .byte EFFECT_BULK_UP + .byte EFFECT_CALM_MIND + .byte EFFECT_DRAGON_DANCE + .byte -1 + +sMoveEffectsTable_82DE288: + .byte -1 + +sMoveEffectsTable_82DE289: + .byte EFFECT_ATTACK_UP + .byte EFFECT_DEFENSE_UP + .byte EFFECT_SPEED_UP + .byte EFFECT_SPECIAL_ATTACK_UP + .byte EFFECT_SPECIAL_DEFENSE_UP + .byte EFFECT_ACCURACY_UP + .byte EFFECT_EVASION_UP + .byte EFFECT_ATTACK_DOWN + .byte EFFECT_DEFENSE_DOWN + .byte EFFECT_SPEED_DOWN + .byte EFFECT_SPECIAL_ATTACK_DOWN + .byte EFFECT_SPECIAL_DEFENSE_DOWN + .byte EFFECT_ACCURACY_DOWN + .byte EFFECT_EVASION_DOWN + .byte EFFECT_MIST + .byte EFFECT_FOCUS_ENERGY + .byte EFFECT_ATTACK_UP_2 + .byte EFFECT_DEFENSE_UP_2 + .byte EFFECT_SPEED_UP_2 + .byte EFFECT_SPECIAL_ATTACK_UP_2 + .byte EFFECT_SPECIAL_DEFENSE_UP_2 + .byte EFFECT_ACCURACY_UP_2 + .byte EFFECT_EVASION_UP_2 + .byte EFFECT_ATTACK_DOWN_2 + .byte EFFECT_DEFENSE_DOWN_2 + .byte EFFECT_SPEED_DOWN_2 + .byte EFFECT_SPECIAL_ATTACK_DOWN_2 + .byte EFFECT_SPECIAL_DEFENSE_DOWN_2 + .byte EFFECT_ACCURACY_DOWN_2 + .byte EFFECT_EVASION_DOWN_2 + .byte EFFECT_POISON + .byte EFFECT_PAIN_SPLIT + .byte EFFECT_PERISH_SONG + .byte EFFECT_SAFEGUARD + .byte EFFECT_TICKLE + .byte EFFECT_COSMIC_POWER + .byte EFFECT_BULK_UP + .byte EFFECT_CALM_MIND + .byte EFFECT_DRAGON_DANCE + .byte -1 + +sMoveEffectsTable_82DE2B1: + .byte EFFECT_SLEEP + .byte EFFECT_EXPLOSION + .byte EFFECT_ATTACK_UP + .byte EFFECT_DEFENSE_UP + .byte EFFECT_SPEED_UP + .byte EFFECT_SPECIAL_ATTACK_UP + .byte EFFECT_SPECIAL_DEFENSE_UP + .byte EFFECT_ACCURACY_UP + .byte EFFECT_EVASION_UP + .byte EFFECT_ATTACK_DOWN + .byte EFFECT_DEFENSE_DOWN + .byte EFFECT_SPEED_DOWN + .byte EFFECT_SPECIAL_ATTACK_DOWN + .byte EFFECT_SPECIAL_DEFENSE_DOWN + .byte EFFECT_ACCURACY_DOWN + .byte EFFECT_EVASION_DOWN + .byte EFFECT_BIDE + .byte EFFECT_CONVERSION + .byte EFFECT_TOXIC + .byte EFFECT_LIGHT_SCREEN + .byte EFFECT_OHKO + .byte EFFECT_SUPER_FANG + .byte EFFECT_SUPER_FANG + .byte EFFECT_MIST + .byte EFFECT_FOCUS_ENERGY + .byte EFFECT_CONFUSE + .byte EFFECT_ATTACK_UP_2 + .byte EFFECT_DEFENSE_UP_2 + .byte EFFECT_SPEED_UP_2 + .byte EFFECT_SPECIAL_ATTACK_UP_2 + .byte EFFECT_SPECIAL_DEFENSE_UP_2 + .byte EFFECT_ACCURACY_UP_2 + .byte EFFECT_EVASION_UP_2 + .byte EFFECT_ATTACK_DOWN_2 + .byte EFFECT_DEFENSE_DOWN_2 + .byte EFFECT_SPEED_DOWN_2 + .byte EFFECT_SPECIAL_ATTACK_DOWN_2 + .byte EFFECT_SPECIAL_DEFENSE_DOWN_2 + .byte EFFECT_ACCURACY_DOWN_2 + .byte EFFECT_EVASION_DOWN_2 + .byte EFFECT_POISON + .byte EFFECT_PARALYZE + .byte EFFECT_PAIN_SPLIT + .byte EFFECT_CONVERSION_2 + .byte EFFECT_LOCK_ON + .byte EFFECT_SPITE + .byte EFFECT_PERISH_SONG + .byte EFFECT_SWAGGER + .byte EFFECT_FURY_CUTTER + .byte EFFECT_ATTRACT + .byte EFFECT_SAFEGUARD + .byte EFFECT_PSYCH_UP + .byte EFFECT_MIRROR_COAT + .byte EFFECT_WILL_O_WISP + .byte EFFECT_TICKLE + .byte EFFECT_COSMIC_POWER + .byte EFFECT_BULK_UP + .byte EFFECT_CALM_MIND + .byte EFFECT_DRAGON_DANCE + .byte -1 + +AI_Unknown: + if_target_is_ally AI_TryOnAlly + if_not_effect EFFECT_SUNNY_DAY, BattleAIScript_82DE308 + if_equal 0, BattleAIScript_82DE308 + is_first_turn_for AI_USER + if_equal 0, BattleAIScript_82DE308 + score +5 + +BattleAIScript_82DE308: + end + +AI_Roaming: + if_status2 AI_USER, STATUS2_WRAPPED, BattleAIScript_82DE336 + if_status2 AI_USER, STATUS2_ESCAPE_PREVENTION, BattleAIScript_82DE336 + get_ability AI_TARGET + if_equal ABILITY_SHADOW_TAG, BattleAIScript_82DE336 + get_ability AI_USER + if_equal ABILITY_LEVITATE, BattleAIScript_82DE335 + get_ability AI_TARGET + if_equal ABILITY_ARENA_TRAP, BattleAIScript_82DE336 + +BattleAIScript_82DE335: + flee + +BattleAIScript_82DE336: + end + +AI_Safari: + if_random_safari_flee BattleAIScript_82DE33D + watch + +BattleAIScript_82DE33D: + flee + +AI_FirstBattle: + if_hp_equal AI_TARGET, 20, BattleAIScript_82DE34D + if_hp_less_than AI_TARGET, 20, BattleAIScript_82DE34D + end + +BattleAIScript_82DE34D: + flee + +AI_Ret: + end diff --git a/include/constants/battle_ai.h b/include/constants/battle_ai.h new file mode 100644 index 000000000..9d89d75f0 --- /dev/null +++ b/include/constants/battle_ai.h @@ -0,0 +1,52 @@ +#ifndef GUARD_BATTLE_AI_H +#define GUARD_BATTLE_AI_H + +// banks enum +#define AI_TARGET 0 +#define AI_USER 1 +#define AI_TARGET_PARTNER 2 +#define AI_USER_PARTNER 3 + +// get_type command +#define AI_TYPE1_TARGET 0 +#define AI_TYPE1_USER 1 +#define AI_TYPE2_TARGET 2 +#define AI_TYPE2_USER 3 +#define AI_TYPE_MOVE 4 + +// type effectiveness +#define AI_EFFECTIVENESS_x4 160 +#define AI_EFFECTIVENESS_x2 80 +#define AI_EFFECTIVENESS_x1 40 +#define AI_EFFECTIVENESS_x0_5 20 +#define AI_EFFECTIVENESS_x0_25 10 +#define AI_EFFECTIVENESS_x0 0 + +// ai weather enum +#define AI_WEATHER_SUN 0 +#define AI_WEATHER_RAIN 1 +#define AI_WEATHER_SANDSTORM 2 +#define AI_WEATHER_HAIL 3 + +// get_how_powerful_move_is +#define MOVE_POWER_DISCOURAGED 0 +#define MOVE_NOT_MOST_POWERFUL 1 +#define MOVE_MOST_POWERFUL 2 + +// script's table id to bit +#define AI_SCRIPT_CHECK_BAD_MOVE (1 << 0) +#define AI_SCRIPT_CHECK_VIABILITY (1 << 1) +#define AI_SCRIPT_TRY_TO_FAINT (1 << 2) +#define AI_SCRIPT_SETUP_FIRST_TURN (1 << 3) +#define AI_SCRIPT_RISKY (1 << 4) +#define AI_SCRIPT_PREFER_STRONGEST_MOVE (1 << 5) +#define AI_SCRIPT_PREFER_BATON_PASS (1 << 6) +#define AI_SCRIPT_DOUBLE_BATTLE (1 << 7) +#define AI_SCRIPT_HP_AWARE (1 << 8) +#define AI_SCRIPT_UNKNOWN (1 << 9) +// 10 - 28 are not used +#define AI_SCRIPT_ROAMING (1 << 29) +#define AI_SCRIPT_SAFARI (1 << 30) +#define AI_SCRIPT_FIRST_BATTLE (1 << 31) + +#endif // GUARD_BATTLE_AI_H diff --git a/src/battle_ai_script_commands.c b/src/battle_ai_script_commands.c index f03381f70..42cf0595f 100644 --- a/src/battle_ai_script_commands.c +++ b/src/battle_ai_script_commands.c @@ -9,6 +9,7 @@ #include "constants/battle_move_effects.h" #include "constants/moves.h" #include "util.h" +#include "constants/battle_ai.h" #define AIScriptRead32(ptr) ((ptr)[0] | (ptr)[1] << 8 | (ptr)[2] << 16 | (ptr)[3] << 24) #define AIScriptRead16(ptr) ((ptr)[0] | (ptr)[1] << 8) @@ -26,14 +27,6 @@ #define AI_THINKING_STRUCT ((struct AI_ThinkingStruct *)(gBattleResources->ai)) #define BATTLE_HISTORY ((struct BattleHistory *)(gBattleResources->battleHistory)) -enum -{ - AI_TARGET, - AI_USER, - AI_TARGET_PARTNER, - AI_USER_PARTNER -}; - // AI states enum { @@ -374,32 +367,34 @@ void BattleAI_SetupAIData(u8 defaultScoreMoves) // decide a random target bank in doubles if (gBattleTypeFlags & BATTLE_TYPE_DOUBLE) { - gBankTarget = (Random() & 2) + (GetBankSide(gActiveBank) ^ 1); + gBankTarget = (Random() & BIT_MON) + (GetBankSide(gActiveBank) ^ BIT_SIDE); if (gAbsentBankFlags & gBitTable[gBankTarget]) - gBankTarget ^= 2; + gBankTarget ^= BIT_MON; } // in singles there's only one choice else - gBankTarget = sBank_AI ^ 1; + { + gBankTarget = sBank_AI ^ BIT_SIDE; + } if (gBattleTypeFlags & BATTLE_TYPE_RECORDED) AI_THINKING_STRUCT->aiFlags = GetAiScriptsInRecordedBattle(); else if (gBattleTypeFlags & BATTLE_TYPE_SAFARI) - AI_THINKING_STRUCT->aiFlags = 0x40000000; + AI_THINKING_STRUCT->aiFlags = AI_SCRIPT_SAFARI; else if (gBattleTypeFlags & BATTLE_TYPE_ROAMER) - AI_THINKING_STRUCT->aiFlags = 0x20000000; + AI_THINKING_STRUCT->aiFlags = AI_SCRIPT_ROAMING; else if (gBattleTypeFlags & BATTLE_TYPE_FIRST_BATTLE) - AI_THINKING_STRUCT->aiFlags = 0x80000000; + AI_THINKING_STRUCT->aiFlags = AI_SCRIPT_FIRST_BATTLE; else if (gBattleTypeFlags & BATTLE_TYPE_FACTORY) AI_THINKING_STRUCT->aiFlags = GetAiScriptsInBattleFactory(); else if (gBattleTypeFlags & (BATTLE_TYPE_FRONTIER | BATTLE_TYPE_EREADER_TRAINER | BATTLE_TYPE_x4000000 | BATTLE_TYPE_SECRET_BASE)) - AI_THINKING_STRUCT->aiFlags = 7; // the smartest possible set + AI_THINKING_STRUCT->aiFlags = AI_SCRIPT_CHECK_BAD_MOVE | AI_SCRIPT_CHECK_VIABILITY | AI_SCRIPT_TRY_TO_FAINT; else if (gBattleTypeFlags & BATTLE_TYPE_TWO_OPPONENTS) AI_THINKING_STRUCT->aiFlags = gTrainers[gTrainerBattleOpponent_A].aiFlags | gTrainers[gTrainerBattleOpponent_B].aiFlags; else AI_THINKING_STRUCT->aiFlags = gTrainers[gTrainerBattleOpponent_A].aiFlags; if (gBattleTypeFlags & BATTLE_TYPE_DOUBLE) - AI_THINKING_STRUCT->aiFlags |= 0x80; // act smart in doubles and don't attack your partner + AI_THINKING_STRUCT->aiFlags |= AI_SCRIPT_DOUBLE_BATTLE; // act smart in doubles and don't attack your partner } u8 BattleAI_ChooseMoveOrAction(void) @@ -1127,19 +1122,19 @@ static void BattleAICmd_get_type(void) switch (typeVar) { - case 1: // player primary type + case AI_TYPE1_USER: // AI user primary type AI_THINKING_STRUCT->funcResult = gBattleMons[sBank_AI].type1; break; - case 0: // enemy primary type + case AI_TYPE1_TARGET: // target primary type AI_THINKING_STRUCT->funcResult = gBattleMons[gBankTarget].type1; break; - case 3: // player secondary type + case AI_TYPE2_USER: // AI user secondary type AI_THINKING_STRUCT->funcResult = gBattleMons[sBank_AI].type2; break; - case 2: // enemy secondary type + case AI_TYPE2_TARGET: // target secondary type AI_THINKING_STRUCT->funcResult = gBattleMons[gBankTarget].type2; break; - case 4: // type of move being pointed to + case AI_TYPE_MOVE: // type of move being pointed to AI_THINKING_STRUCT->funcResult = gBattleMoves[AI_THINKING_STRUCT->moveConsidered].type; break; } @@ -1236,13 +1231,13 @@ static void BattleAICmd_get_how_powerful_move_is(void) } if (checkedMove == 4) - AI_THINKING_STRUCT->funcResult = 2; // is the most powerful + AI_THINKING_STRUCT->funcResult = MOVE_MOST_POWERFUL; // is the most powerful else - AI_THINKING_STRUCT->funcResult = 1; // not most powerful + AI_THINKING_STRUCT->funcResult = MOVE_NOT_MOST_POWERFUL; // not most powerful } else { - AI_THINKING_STRUCT->funcResult = 0; // highly discouraged in terms of power + AI_THINKING_STRUCT->funcResult = MOVE_POWER_DISCOURAGED; // highly discouraged in terms of power } gAIScriptPtr++; @@ -1493,7 +1488,7 @@ static void BattleAICmd_get_highest_type_effectiveness(void) for (i = 0; i < 4; i++) { - gBattleMoveDamage = 40; + gBattleMoveDamage = AI_EFFECTIVENESS_x1; gCurrentMove = gBattleMons[sBank_AI].moves[i]; if (gCurrentMove) @@ -1502,16 +1497,16 @@ static void BattleAICmd_get_highest_type_effectiveness(void) // reduce by 1/3. if (gBattleMoveDamage == 120) - gBattleMoveDamage = 80; + gBattleMoveDamage = AI_EFFECTIVENESS_x2; if (gBattleMoveDamage == 240) - gBattleMoveDamage = 160; + gBattleMoveDamage = AI_EFFECTIVENESS_x4; if (gBattleMoveDamage == 30) - gBattleMoveDamage = 20; + gBattleMoveDamage = AI_EFFECTIVENESS_x0_5; if (gBattleMoveDamage == 15) - gBattleMoveDamage = 10; + gBattleMoveDamage = AI_EFFECTIVENESS_x0_25; if (gBattleMoveFlags & MOVESTATUS_NOTAFFECTED) - gBattleMoveDamage = 0; + gBattleMoveDamage = AI_EFFECTIVENESS_x0; if (AI_THINKING_STRUCT->funcResult < gBattleMoveDamage) AI_THINKING_STRUCT->funcResult = gBattleMoveDamage; @@ -1530,22 +1525,22 @@ static void BattleAICmd_if_type_effectiveness(void) gBattleMoveFlags = 0; gCritMultiplier = 1; - gBattleMoveDamage = 40; + gBattleMoveDamage = AI_EFFECTIVENESS_x1; gCurrentMove = AI_THINKING_STRUCT->moveConsidered; TypeCalc(gCurrentMove, sBank_AI, gBankTarget); if (gBattleMoveDamage == 120) - gBattleMoveDamage = 80; + gBattleMoveDamage = AI_EFFECTIVENESS_x2; if (gBattleMoveDamage == 240) - gBattleMoveDamage = 160; + gBattleMoveDamage = AI_EFFECTIVENESS_x4; if (gBattleMoveDamage == 30) - gBattleMoveDamage = 20; + gBattleMoveDamage = AI_EFFECTIVENESS_x0_5; if (gBattleMoveDamage == 15) - gBattleMoveDamage = 10; + gBattleMoveDamage = AI_EFFECTIVENESS_x0_25; if (gBattleMoveFlags & MOVESTATUS_NOTAFFECTED) - gBattleMoveDamage = 0; + gBattleMoveDamage = AI_EFFECTIVENESS_x0; // store gBattleMoveDamage in a u8 variable because gAIScriptPtr[1] is a u8. damageVar = gBattleMoveDamage; @@ -1618,7 +1613,7 @@ static void BattleAICmd_if_status_not_in_party(void) break; } - party = (GetBankSide(bank) == 0) ? gPlayerParty : gEnemyParty; + party = (GetBankSide(bank) == SIDE_PLAYER) ? gPlayerParty : gEnemyParty; statusToCompareTo = AIScriptRead32(gAIScriptPtr + 2); @@ -1640,13 +1635,13 @@ static void BattleAICmd_if_status_not_in_party(void) static void BattleAICmd_get_weather(void) { if (gBattleWeather & WEATHER_RAIN_ANY) - AI_THINKING_STRUCT->funcResult = 1; + AI_THINKING_STRUCT->funcResult = AI_WEATHER_RAIN; if (gBattleWeather & WEATHER_SANDSTORM_ANY) - AI_THINKING_STRUCT->funcResult = 2; + AI_THINKING_STRUCT->funcResult = AI_WEATHER_SANDSTORM; if (gBattleWeather & WEATHER_SUN_ANY) - AI_THINKING_STRUCT->funcResult = 0; + AI_THINKING_STRUCT->funcResult = AI_WEATHER_SUN; if (gBattleWeather & WEATHER_HAIL_ANY) - AI_THINKING_STRUCT->funcResult = 3; + AI_THINKING_STRUCT->funcResult = AI_WEATHER_HAIL; gAIScriptPtr += 1; } @@ -1904,7 +1899,7 @@ static void BattleAICmd_if_has_move_with_effect(void) case AI_USER_PARTNER: for (i = 0; i < 4; i++) { - if(gBattleMons[sBank_AI].moves[i] != 0 && gBattleMoves[gBattleMons[sBank_AI].moves[i]].effect == gAIScriptPtr[2]) + if (gBattleMons[sBank_AI].moves[i] != 0 && gBattleMoves[gBattleMons[sBank_AI].moves[i]].effect == gAIScriptPtr[2]) break; } if (i == 4) @@ -1916,6 +1911,7 @@ static void BattleAICmd_if_has_move_with_effect(void) case AI_TARGET_PARTNER: for (i = 0; i < 4; i++) { + // UB: checks sBank_AI instead of gBankTarget if (gBattleMons[sBank_AI].moves[i] != 0 && gBattleMoves[BATTLE_HISTORY->usedMoves[gBankTarget].moves[i]].effect == gAIScriptPtr[2]) break; }