This commit is contained in:
DizzyEggg 2017-12-30 12:19:02 +01:00
parent 9ee677d567
commit 5ae6461cc5

View File

@ -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;