pokeemerald/src/contest_ai.c

1784 lines
53 KiB
C
Raw Normal View History

2018-08-15 11:43:57 +02:00
#include "global.h"
#include "battle.h"
2018-08-15 11:43:57 +02:00
#include "contest.h"
#include "random.h"
#include "contest_ai.h"
#include "contest_effect.h"
2020-07-12 02:25:56 +02:00
#include "constants/moves.h"
2018-08-15 11:43:57 +02:00
extern const u8 *gAIScriptPtr;
2020-08-21 20:47:55 +02:00
extern const u8 *gContestAI_ScriptsTable[];
2018-08-15 11:43:57 +02:00
2019-04-02 04:09:14 +02:00
static void ContestAICmd_score(void);
2020-07-24 06:14:53 +02:00
static void ContestAICmd_get_appeal_num(void);
static void ContestAICmd_if_appeal_num_less_than(void);
static void ContestAICmd_if_appeal_num_more_than(void);
static void ContestAICmd_if_appeal_num_eq(void);
static void ContestAICmd_if_appeal_num_not_eq(void);
2018-08-15 11:43:57 +02:00
static void ContestAICmd_get_excitement(void);
2019-04-02 04:09:14 +02:00
static void ContestAICmd_if_excitement_less_than(void);
static void ContestAICmd_if_excitement_more_than(void);
static void ContestAICmd_if_excitement_eq(void);
static void ContestAICmd_if_excitement_not_eq(void);
2018-08-15 11:43:57 +02:00
static void ContestAICmd_get_user_order(void);
2019-04-02 04:09:14 +02:00
static void ContestAICmd_if_user_order_less_than(void);
static void ContestAICmd_if_user_order_more_than(void);
static void ContestAICmd_if_user_order_eq(void);
static void ContestAICmd_if_user_order_not_eq(void);
static void ContestAICmd_get_user_condition(void);
static void ContestAICmd_if_user_condition_less_than(void);
static void ContestAICmd_if_user_condition_more_than(void);
static void ContestAICmd_if_user_condition_eq(void);
static void ContestAICmd_if_user_condition_not_eq(void);
2020-08-21 08:36:48 +02:00
static void ContestAICmd_get_points(void);
static void ContestAICmd_if_points_less_than(void);
static void ContestAICmd_if_points_more_than(void);
static void ContestAICmd_if_points_eq(void);
static void ContestAICmd_if_points_not_eq(void);
static void ContestAICmd_get_preliminary_points(void);
static void ContestAICmd_if_preliminary_points_less_than(void);
static void ContestAICmd_if_preliminary_points_more_than(void);
static void ContestAICmd_if_preliminary_points_eq(void);
static void ContestAICmd_if_preliminary_points_not_eq(void);
2018-08-15 11:43:57 +02:00
static void ContestAICmd_get_contest_type(void);
2019-04-02 04:09:14 +02:00
static void ContestAICmd_if_contest_type_eq(void);
static void ContestAICmd_if_contest_type_not_eq(void);
2018-08-15 11:43:57 +02:00
static void ContestAICmd_get_move_excitement(void);
2019-04-02 04:09:14 +02:00
static void ContestAICmd_if_move_excitement_less_than(void);
2020-08-21 08:36:48 +02:00
static void ContestAICmd_if_move_excitement_more_than(void);
2019-04-02 04:09:14 +02:00
static void ContestAICmd_if_move_excitement_eq(void);
static void ContestAICmd_if_move_excitement_not_eq(void);
2018-08-15 11:43:57 +02:00
static void ContestAICmd_get_move_effect(void);
2019-04-02 04:09:14 +02:00
static void ContestAICmd_if_move_effect_eq(void);
static void ContestAICmd_if_move_effect_not_eq(void);
2018-08-15 11:43:57 +02:00
static void ContestAICmd_get_move_effect_type(void);
2019-04-02 04:09:14 +02:00
static void ContestAICmd_if_move_effect_type_eq(void);
static void ContestAICmd_if_move_effect_type_not_eq(void);
static void ContestAICmd_check_most_appealing_move(void);
static void ContestAICmd_if_most_appealing_move(void);
2020-08-21 08:36:48 +02:00
static void ContestAICmd_check_most_jamming_move(void);
static void ContestAICmd_if_most_jamming_move(void);
static void ContestAICmd_get_num_move_hearts(void);
static void ContestAICmd_if_num_move_hearts_less_than(void);
static void ContestAICmd_if_num_move_hearts_more_than(void);
static void ContestAICmd_if_num_move_hearts_eq(void);
static void ContestAICmd_if_num_move_hearts_not_eq(void);
static void ContestAICmd_get_num_move_jam_hearts(void);
static void ContestAICmd_if_num_move_jam_hearts_less_than(void);
static void ContestAICmd_if_num_move_jam_hearts_more_than(void);
static void ContestAICmd_if_num_move_jam_hearts_eq(void);
static void ContestAICmd_if_num_move_jam_hearts_not_eq(void);
2018-08-15 11:43:57 +02:00
static void ContestAICmd_get_move_used_count(void);
2019-04-02 04:09:14 +02:00
static void ContestAICmd_if_most_used_count_less_than(void);
static void ContestAICmd_if_most_used_count_more_than(void);
static void ContestAICmd_if_most_used_count_eq(void);
static void ContestAICmd_if_most_used_count_not_eq(void);
2018-08-15 11:43:57 +02:00
static void ContestAICmd_check_combo_starter(void);
2019-04-02 04:09:14 +02:00
static void ContestAICmd_if_combo_starter(void);
static void ContestAICmd_if_not_combo_starter(void);
2018-08-15 11:43:57 +02:00
static void ContestAICmd_check_combo_finisher(void);
2019-04-02 04:09:14 +02:00
static void ContestAICmd_if_combo_finisher(void);
static void ContestAICmd_if_not_combo_finisher(void);
2018-08-15 11:43:57 +02:00
static void ContestAICmd_check_would_finish_combo(void);
2019-04-02 04:09:14 +02:00
static void ContestAICmd_if_would_finish_combo(void);
static void ContestAICmd_if_would_not_finish_combo(void);
2018-08-15 11:43:57 +02:00
static void ContestAICmd_get_condition(void);
2019-04-02 04:09:14 +02:00
static void ContestAICmd_if_condition_less_than(void);
static void ContestAICmd_if_condition_more_than(void);
static void ContestAICmd_if_condition_eq(void);
static void ContestAICmd_if_condition_not_eq(void);
2018-08-15 11:43:57 +02:00
static void ContestAICmd_get_used_combo_starter(void);
2019-04-02 04:09:14 +02:00
static void ContestAICmd_if_used_combo_starter_less_than(void);
static void ContestAICmd_if_used_combo_starter_more_than(void);
static void ContestAICmd_if_used_combo_starter_eq(void);
static void ContestAICmd_if_used_combo_starter_not_eq(void);
2018-08-15 11:43:57 +02:00
static void ContestAICmd_check_can_participate(void);
2019-04-02 04:09:14 +02:00
static void ContestAICmd_if_can_participate(void);
static void ContestAICmd_if_cannot_participate(void);
2020-08-21 08:36:48 +02:00
static void ContestAICmd_get_completed_combo(void);
static void ContestAICmd_if_completed_combo(void);
static void ContestAICmd_if_not_completed_combo(void);
static void ContestAICmd_get_points_diff(void);
static void ContestAICmd_if_points_more_than_mon(void);
static void ContestAICmd_if_points_less_than_mon(void);
static void ContestAICmd_if_points_eq_mon(void);
static void ContestAICmd_if_points_not_eq_mon(void);
static void ContestAICmd_get_preliminary_points_diff(void);
static void ContestAICmd_if_preliminary_points_more_than_mon(void);
static void ContestAICmd_if_preliminary_points_less_than_mon(void);
static void ContestAICmd_if_preliminary_points_eq_mon(void);
static void ContestAICmd_if_preliminary_points_not_eq_mon(void);
static void ContestAICmd_get_used_moves_effect(void);
static void ContestAICmd_if_used_moves_effect_less_than(void);
static void ContestAICmd_if_used_moves_effect_more_than(void);
static void ContestAICmd_if_used_moves_effect_eq(void);
static void ContestAICmd_if_used_moves_effect_not_eq(void);
static void ContestAICmd_get_used_moves_excitement(void);
static void ContestAICmd_if_used_moves_excitement_less_than(void);
static void ContestAICmd_if_used_moves_excitement_more_than(void);
static void ContestAICmd_if_used_moves_excitement_eq(void);
static void ContestAICmd_if_used_moves_excitement_not_eq(void);
static void ContestAICmd_get_used_moves_effect_type(void);
static void ContestAICmd_if_used_moves_effect_type_eq(void);
static void ContestAICmd_if_used_moves_effect_type_not_eq(void);
static void ContestAICmd_save_result(void);
static void ContestAICmd_setvar(void);
static void ContestAICmd_add(void);
static void ContestAICmd_addvar(void);
static void ContestAICmd_addvar_duplicate(void);
static void ContestAICmd_if_less_than(void);
static void ContestAICmd_if_greater_than(void);
static void ContestAICmd_if_eq(void);
static void ContestAICmd_if_not_eq(void);
static void ContestAICmd_if_less_than_var(void);
static void ContestAICmd_if_greater_than_var(void);
static void ContestAICmd_if_eq_var(void);
static void ContestAICmd_if_not_eq_var(void);
static void ContestAICmd_if_random_less_than(void);
static void ContestAICmd_if_random_greater_than(void);
static void ContestAICmd_goto(void);
2019-04-02 04:09:14 +02:00
static void ContestAICmd_call(void);
static void ContestAICmd_end(void);
static void ContestAICmd_check_user_has_exciting_move(void);
static void ContestAICmd_if_user_has_exciting_move(void);
static void ContestAICmd_if_user_doesnt_have_exciting_move(void);
2020-08-21 08:36:48 +02:00
static void ContestAICmd_check_user_has_move(void);
static void ContestAICmd_if_user_has_move(void);
2020-08-21 20:47:55 +02:00
static void ContestAICmd_if_user_doesnt_have_move(void);
2018-08-15 11:43:57 +02:00
typedef void (* ContestAICmdFunc)(void);
static const ContestAICmdFunc sContestAICmdTable[] =
{
2020-08-21 08:36:48 +02:00
ContestAICmd_score, // 0x00
ContestAICmd_get_appeal_num, // 0x01
ContestAICmd_if_appeal_num_less_than, // 0x02
ContestAICmd_if_appeal_num_more_than, // 0x03
ContestAICmd_if_appeal_num_eq, // 0x04
ContestAICmd_if_appeal_num_not_eq, // 0x05
ContestAICmd_get_excitement, // 0x06
ContestAICmd_if_excitement_less_than, // 0x07
ContestAICmd_if_excitement_more_than, // 0x08
ContestAICmd_if_excitement_eq, // 0x09
ContestAICmd_if_excitement_not_eq, // 0x0A
ContestAICmd_get_user_order, // 0x0B
ContestAICmd_if_user_order_less_than, // 0x0C
ContestAICmd_if_user_order_more_than, // 0x0D
ContestAICmd_if_user_order_eq, // 0x0E
ContestAICmd_if_user_order_not_eq, // 0x0F
ContestAICmd_get_user_condition, // 0x10
ContestAICmd_if_user_condition_less_than, // 0x11
ContestAICmd_if_user_condition_more_than, // 0x12
ContestAICmd_if_user_condition_eq, // 0x13
ContestAICmd_if_user_condition_not_eq, // 0x14
ContestAICmd_get_points, // 0x15
ContestAICmd_if_points_less_than, // 0x16
ContestAICmd_if_points_more_than, // 0x17
ContestAICmd_if_points_eq, // 0x18
ContestAICmd_if_points_not_eq, // 0x19
ContestAICmd_get_preliminary_points, // 0x1A
ContestAICmd_if_preliminary_points_less_than, // 0x1B
ContestAICmd_if_preliminary_points_more_than, // 0x1C
ContestAICmd_if_preliminary_points_eq, // 0x1D
ContestAICmd_if_preliminary_points_not_eq, // 0x1E
ContestAICmd_get_contest_type, // 0x1F
ContestAICmd_if_contest_type_eq, // 0x20
ContestAICmd_if_contest_type_not_eq, // 0x21
ContestAICmd_get_move_excitement, // 0x22
ContestAICmd_if_move_excitement_less_than, // 0x23
ContestAICmd_if_move_excitement_more_than, // 0x24
ContestAICmd_if_move_excitement_eq, // 0x25
ContestAICmd_if_move_excitement_not_eq, // 0x26
ContestAICmd_get_move_effect, // 0x27
ContestAICmd_if_move_effect_eq, // 0x28
ContestAICmd_if_move_effect_not_eq, // 0x29
ContestAICmd_get_move_effect_type, // 0x2A
ContestAICmd_if_move_effect_type_eq, // 0x2B
ContestAICmd_if_move_effect_type_not_eq, // 0x2C
ContestAICmd_check_most_appealing_move, // 0x2D
ContestAICmd_if_most_appealing_move, // 0x2E
ContestAICmd_check_most_jamming_move, // 0x2F
ContestAICmd_if_most_jamming_move, // 0x30
ContestAICmd_get_num_move_hearts, // 0x31
ContestAICmd_if_num_move_hearts_less_than, // 0x32
ContestAICmd_if_num_move_hearts_more_than, // 0x33
ContestAICmd_if_num_move_hearts_eq, // 0x34
ContestAICmd_if_num_move_hearts_not_eq, // 0x35
ContestAICmd_get_num_move_jam_hearts, // 0x36
ContestAICmd_if_num_move_jam_hearts_less_than, // 0x37
ContestAICmd_if_num_move_jam_hearts_more_than, // 0x38
ContestAICmd_if_num_move_jam_hearts_eq, // 0x39
ContestAICmd_if_num_move_jam_hearts_not_eq, // 0x3A
ContestAICmd_get_move_used_count, // 0x3B
ContestAICmd_if_most_used_count_less_than, // 0x3C
ContestAICmd_if_most_used_count_more_than, // 0x3D
ContestAICmd_if_most_used_count_eq, // 0x3E
ContestAICmd_if_most_used_count_not_eq, // 0x3F
ContestAICmd_check_combo_starter, // 0x40
ContestAICmd_if_combo_starter, // 0x41
ContestAICmd_if_not_combo_starter, // 0x42
ContestAICmd_check_combo_finisher, // 0x43
ContestAICmd_if_combo_finisher, // 0x44
ContestAICmd_if_not_combo_finisher, // 0x45
ContestAICmd_check_would_finish_combo, // 0x46
ContestAICmd_if_would_finish_combo, // 0x47
ContestAICmd_if_would_not_finish_combo, // 0x48
ContestAICmd_get_condition, // 0x49
ContestAICmd_if_condition_less_than, // 0x4A
ContestAICmd_if_condition_more_than, // 0x4B
ContestAICmd_if_condition_eq, // 0x4C
ContestAICmd_if_condition_not_eq, // 0x4D
ContestAICmd_get_used_combo_starter, // 0x4E
ContestAICmd_if_used_combo_starter_less_than, // 0x4F
ContestAICmd_if_used_combo_starter_more_than, // 0x50
ContestAICmd_if_used_combo_starter_eq, // 0x51
ContestAICmd_if_used_combo_starter_not_eq, // 0x52
ContestAICmd_check_can_participate, // 0x53
ContestAICmd_if_can_participate, // 0x54
ContestAICmd_if_cannot_participate, // 0x55
ContestAICmd_get_completed_combo, // 0x56
ContestAICmd_if_completed_combo, // 0x57
ContestAICmd_if_not_completed_combo, // 0x58
ContestAICmd_get_points_diff, // 0x59
ContestAICmd_if_points_more_than_mon, // 0x5A
ContestAICmd_if_points_less_than_mon, // 0x5B
ContestAICmd_if_points_eq_mon, // 0x5C
ContestAICmd_if_points_not_eq_mon, // 0x5D
ContestAICmd_get_preliminary_points_diff, // 0x5E
ContestAICmd_if_preliminary_points_more_than_mon, // 0x5F
ContestAICmd_if_preliminary_points_less_than_mon, // 0x60
ContestAICmd_if_preliminary_points_eq_mon, // 0x61
ContestAICmd_if_preliminary_points_not_eq_mon, // 0x62
ContestAICmd_get_used_moves_effect, // 0x63
ContestAICmd_if_used_moves_effect_less_than, // 0x64
ContestAICmd_if_used_moves_effect_more_than, // 0x65
ContestAICmd_if_used_moves_effect_eq, // 0x66
ContestAICmd_if_used_moves_effect_not_eq, // 0x67
ContestAICmd_get_used_moves_excitement, // 0x68
ContestAICmd_if_used_moves_excitement_less_than, // 0x69
ContestAICmd_if_used_moves_excitement_more_than, // 0x6A
ContestAICmd_if_used_moves_excitement_eq, // 0x6B
ContestAICmd_if_used_moves_excitement_not_eq, // 0x6C
ContestAICmd_get_used_moves_effect_type, // 0x6D
ContestAICmd_if_used_moves_effect_type_eq, // 0x6E
ContestAICmd_if_used_moves_effect_type_not_eq, // 0x6F
ContestAICmd_save_result, // 0x70
ContestAICmd_setvar, // 0x71
ContestAICmd_add, // 0x72
ContestAICmd_addvar, // 0x73
ContestAICmd_addvar_duplicate, // 0x74
ContestAICmd_if_less_than, // 0x75
ContestAICmd_if_greater_than, // 0x76
ContestAICmd_if_eq, // 0x77
ContestAICmd_if_not_eq, // 0x78
ContestAICmd_if_less_than_var, // 0x79
ContestAICmd_if_greater_than_var, // 0x7A
ContestAICmd_if_eq_var, // 0x7B
ContestAICmd_if_not_eq_var, // 0x7C
ContestAICmd_if_random_less_than, // 0x7D
ContestAICmd_if_random_greater_than, // 0x7E
ContestAICmd_goto, // 0x7F
ContestAICmd_call, // 0x80
ContestAICmd_end, // 0x81
ContestAICmd_check_user_has_exciting_move, // 0x82
ContestAICmd_if_user_has_exciting_move, // 0x83
ContestAICmd_if_user_doesnt_have_exciting_move, // 0x84
ContestAICmd_check_user_has_move, // 0x85
ContestAICmd_if_user_has_move, // 0x86
2020-08-21 20:47:55 +02:00
ContestAICmd_if_user_doesnt_have_move, // 0x87
2018-08-15 11:43:57 +02:00
};
static void ContestAI_DoAIProcessing(void);
2020-07-12 02:25:56 +02:00
static bool8 GetContestantIdByTurn(u8);
2018-08-15 11:43:57 +02:00
static void AIStackPushVar(const u8 *);
static u8 AIStackPop(void);
2018-08-15 11:50:18 +02:00
void ContestAI_ResetAI(u8 contestantAI)
2018-08-15 11:43:57 +02:00
{
int i;
2019-04-02 06:35:57 +02:00
memset(&eContestAI, 0, sizeof(struct ContestAIInfo));
2018-08-15 11:43:57 +02:00
2020-07-12 02:25:56 +02:00
for (i = 0; i < MAX_MON_MOVES; i++)
eContestAI.moveScores[i] = 100;
2018-08-15 11:43:57 +02:00
2019-04-02 06:35:57 +02:00
eContestAI.contestantId = contestantAI;
eContestAI.stackSize = 0;
2020-08-21 20:47:55 +02:00
eContestAI.aiFlags = gContestMons[eContestAI.contestantId].aiFlags;
2018-08-15 11:43:57 +02:00
}
u8 ContestAI_GetActionToUse(void)
{
2020-08-21 20:47:55 +02:00
while (eContestAI.aiFlags != 0)
2018-08-15 11:43:57 +02:00
{
2020-08-21 20:47:55 +02:00
if (eContestAI.aiFlags & 1)
2018-08-15 11:43:57 +02:00
{
2019-04-02 06:35:57 +02:00
eContestAI.aiState = CONTESTAI_SETTING_UP;
2018-08-15 11:43:57 +02:00
ContestAI_DoAIProcessing();
}
2020-08-21 20:47:55 +02:00
eContestAI.aiFlags >>= 1;
eContestAI.currentAIFlag++;
2019-04-02 06:35:57 +02:00
eContestAI.nextMoveIndex = 0;
2018-08-15 11:43:57 +02:00
}
while (1)
{
2020-07-12 02:25:56 +02:00
// Randomly choose a move index. If it's the move
// with the highest (or tied highest) score, return
2020-07-24 06:14:53 +02:00
u8 moveIdx = Random() & (MAX_MON_MOVES - 1); // % MAX_MON_MOVES doesn't match
2020-07-12 02:25:56 +02:00
u8 score = eContestAI.moveScores[moveIdx];
2018-08-15 11:43:57 +02:00
int i;
2020-07-12 02:25:56 +02:00
for (i = 0; i < MAX_MON_MOVES; i++)
2018-08-15 11:43:57 +02:00
{
2020-07-12 02:25:56 +02:00
if (score < eContestAI.moveScores[i])
2018-08-15 11:43:57 +02:00
break;
}
2020-07-12 02:25:56 +02:00
if (i == MAX_MON_MOVES)
return moveIdx;
2018-08-15 11:43:57 +02:00
}
}
static void ContestAI_DoAIProcessing(void)
{
2019-04-02 06:35:57 +02:00
while (eContestAI.aiState != CONTESTAI_FINISHED)
2018-08-15 11:43:57 +02:00
{
2019-04-02 06:35:57 +02:00
switch(eContestAI.aiState)
2018-08-15 11:43:57 +02:00
{
case CONTESTAI_DO_NOT_PROCESS:
break;
case CONTESTAI_SETTING_UP:
2020-08-21 20:47:55 +02:00
gAIScriptPtr = gContestAI_ScriptsTable[eContestAI.currentAIFlag];
2018-08-15 11:43:57 +02:00
2020-07-12 02:25:56 +02:00
if (gContestMons[eContestAI.contestantId].moves[eContestAI.nextMoveIndex] == MOVE_NONE)
eContestAI.nextMove = MOVE_NONE; // don't process a move that doesn't exist.
2018-08-15 11:43:57 +02:00
else
2019-04-02 06:35:57 +02:00
eContestAI.nextMove = gContestMons[eContestAI.contestantId].moves[eContestAI.nextMoveIndex];
eContestAI.aiState++;
2018-08-15 11:43:57 +02:00
break;
case CONTESTAI_PROCESSING:
2020-07-12 02:25:56 +02:00
if (eContestAI.nextMove != MOVE_NONE)
2019-04-02 04:09:14 +02:00
{
2018-08-15 11:43:57 +02:00
sContestAICmdTable[*gAIScriptPtr](); // run the command.
2019-04-02 04:09:14 +02:00
}
2018-08-15 11:43:57 +02:00
else
{
2020-07-12 02:25:56 +02:00
eContestAI.moveScores[eContestAI.nextMoveIndex] = 0; // don't consider a move that doesn't exist.
2019-04-02 06:35:57 +02:00
eContestAI.aiAction |= 1;
2018-08-15 11:43:57 +02:00
}
2019-04-02 06:35:57 +02:00
if (eContestAI.aiAction & 1)
2018-08-15 11:43:57 +02:00
{
2019-04-02 06:35:57 +02:00
eContestAI.nextMoveIndex++;
2020-07-12 02:25:56 +02:00
if (eContestAI.nextMoveIndex < MAX_MON_MOVES)
2019-04-02 06:35:57 +02:00
eContestAI.aiState = 0;
2018-08-15 11:43:57 +02:00
else
2019-04-02 04:09:14 +02:00
// aiState = CONTESTAI_FINISHED
2019-04-02 06:35:57 +02:00
eContestAI.aiState++;
eContestAI.aiAction &= 0xFE; // TODO: Define action flags
2018-08-15 11:43:57 +02:00
}
break;
}
}
}
2020-07-12 02:25:56 +02:00
static u8 GetContestantIdByTurn(u8 turn)
2018-08-15 11:43:57 +02:00
{
int i;
2020-07-12 02:25:56 +02:00
for (i = 0; i < CONTESTANT_COUNT; i++)
2020-08-15 20:33:08 +02:00
if (eContestAppealResults.turnOrder[i] == turn)
2018-08-15 11:43:57 +02:00
break;
return i;
}
2019-04-02 04:09:14 +02:00
static void ContestAICmd_score(void)
2018-08-15 11:43:57 +02:00
{
2020-07-12 02:25:56 +02:00
s16 score = eContestAI.moveScores[eContestAI.nextMoveIndex] + (s8)gAIScriptPtr[1];
2018-08-15 11:43:57 +02:00
if (score > 255)
score = 255;
else if (score < 0)
score = 0;
2020-07-12 02:25:56 +02:00
eContestAI.moveScores[eContestAI.nextMoveIndex] = score;
2018-08-15 11:43:57 +02:00
gAIScriptPtr += 2;
}
2020-07-24 06:14:53 +02:00
static void ContestAICmd_get_appeal_num(void)
2018-08-15 11:43:57 +02:00
{
2020-07-24 06:14:53 +02:00
eContestAI.scriptResult = eContest.appealNumber;
2018-08-15 11:43:57 +02:00
gAIScriptPtr += 1;
}
2020-07-24 06:14:53 +02:00
static void ContestAICmd_if_appeal_num_less_than(void)
2018-08-15 11:43:57 +02:00
{
2020-07-24 06:14:53 +02:00
ContestAICmd_get_appeal_num();
2018-08-15 11:43:57 +02:00
2019-04-02 06:35:57 +02:00
if (eContestAI.scriptResult < gAIScriptPtr[0])
2018-08-15 11:43:57 +02:00
gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 1);
else
gAIScriptPtr += 5;
}
2020-07-24 06:14:53 +02:00
static void ContestAICmd_if_appeal_num_more_than(void)
2018-08-15 11:43:57 +02:00
{
2020-07-24 06:14:53 +02:00
ContestAICmd_get_appeal_num();
2018-08-15 11:43:57 +02:00
2019-04-02 06:35:57 +02:00
if (eContestAI.scriptResult > gAIScriptPtr[0])
2018-08-15 11:43:57 +02:00
gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 1);
else
gAIScriptPtr += 5;
}
2020-07-24 06:14:53 +02:00
static void ContestAICmd_if_appeal_num_eq(void)
2018-08-15 11:43:57 +02:00
{
2020-07-24 06:14:53 +02:00
ContestAICmd_get_appeal_num();
2018-08-15 11:43:57 +02:00
2019-04-02 06:35:57 +02:00
if (eContestAI.scriptResult == gAIScriptPtr[0])
2018-08-15 11:43:57 +02:00
gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 1);
else
gAIScriptPtr += 5;
}
2020-07-24 06:14:53 +02:00
static void ContestAICmd_if_appeal_num_not_eq(void)
2018-08-15 11:43:57 +02:00
{
2020-07-24 06:14:53 +02:00
ContestAICmd_get_appeal_num();
2018-08-15 11:43:57 +02:00
2019-04-02 06:35:57 +02:00
if (eContestAI.scriptResult != gAIScriptPtr[0])
2018-08-15 11:43:57 +02:00
gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 1);
else
gAIScriptPtr += 5;
}
static void ContestAICmd_get_excitement(void)
{
2019-04-02 06:35:57 +02:00
eContestAI.scriptResult = eContest.applauseLevel;
2018-08-15 11:43:57 +02:00
gAIScriptPtr += 1;
}
2019-04-02 04:09:14 +02:00
static void ContestAICmd_if_excitement_less_than(void)
2018-08-15 11:43:57 +02:00
{
ContestAICmd_get_excitement();
2019-04-02 06:35:57 +02:00
if (eContestAI.scriptResult < gAIScriptPtr[0])
2018-08-15 11:43:57 +02:00
gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 1);
else
gAIScriptPtr += 5;
}
2019-04-02 04:09:14 +02:00
static void ContestAICmd_if_excitement_more_than(void)
2018-08-15 11:43:57 +02:00
{
ContestAICmd_get_excitement();
2019-04-02 06:35:57 +02:00
if (eContestAI.scriptResult > gAIScriptPtr[0])
2018-08-15 11:43:57 +02:00
gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 1);
else
gAIScriptPtr += 5;
}
2019-04-02 04:09:14 +02:00
static void ContestAICmd_if_excitement_eq(void)
2018-08-15 11:43:57 +02:00
{
ContestAICmd_get_excitement();
2019-04-02 06:35:57 +02:00
if (eContestAI.scriptResult == gAIScriptPtr[0])
2018-08-15 11:43:57 +02:00
gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 1);
else
gAIScriptPtr += 5;
}
2019-04-02 04:09:14 +02:00
static void ContestAICmd_if_excitement_not_eq(void)
2018-08-15 11:43:57 +02:00
{
ContestAICmd_get_excitement();
2019-04-02 06:35:57 +02:00
if (eContestAI.scriptResult != gAIScriptPtr[0])
2018-08-15 11:43:57 +02:00
gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 1);
else
gAIScriptPtr += 5;
}
static void ContestAICmd_get_user_order(void)
{
2020-08-15 20:33:08 +02:00
eContestAI.scriptResult = eContestAppealResults.turnOrder[eContestAI.contestantId];
2018-08-15 11:43:57 +02:00
gAIScriptPtr += 1;
}
2019-04-02 04:09:14 +02:00
static void ContestAICmd_if_user_order_less_than(void)
2018-08-15 11:43:57 +02:00
{
ContestAICmd_get_user_order();
2019-04-02 06:35:57 +02:00
if (eContestAI.scriptResult < gAIScriptPtr[0])
2018-08-15 11:43:57 +02:00
gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 1);
else
gAIScriptPtr += 5;
}
2019-04-02 04:09:14 +02:00
static void ContestAICmd_if_user_order_more_than(void)
2018-08-15 11:43:57 +02:00
{
ContestAICmd_get_user_order();
2019-04-02 06:35:57 +02:00
if (eContestAI.scriptResult > gAIScriptPtr[0])
2018-08-15 11:43:57 +02:00
gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 1);
else
gAIScriptPtr += 5;
}
2019-04-02 04:09:14 +02:00
static void ContestAICmd_if_user_order_eq(void)
2018-08-15 11:43:57 +02:00
{
ContestAICmd_get_user_order();
2019-04-02 06:35:57 +02:00
if (eContestAI.scriptResult == gAIScriptPtr[0])
2018-08-15 11:43:57 +02:00
gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 1);
else
gAIScriptPtr += 5;
}
2019-04-02 04:09:14 +02:00
static void ContestAICmd_if_user_order_not_eq(void)
2018-08-15 11:43:57 +02:00
{
ContestAICmd_get_user_order();
2019-04-02 06:35:57 +02:00
if (eContestAI.scriptResult != gAIScriptPtr[0])
2018-08-15 11:43:57 +02:00
gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 1);
else
gAIScriptPtr += 5;
}
2019-04-02 04:09:14 +02:00
static void ContestAICmd_get_user_condition(void)
2018-08-15 11:43:57 +02:00
{
2019-04-02 06:35:57 +02:00
eContestAI.scriptResult = eContestantStatus[eContestAI.contestantId].condition / 10;
2018-08-15 11:43:57 +02:00
gAIScriptPtr += 1;
}
2019-04-02 04:09:14 +02:00
static void ContestAICmd_if_user_condition_less_than(void)
2018-08-15 11:43:57 +02:00
{
2019-04-02 04:09:14 +02:00
ContestAICmd_get_user_condition();
2018-08-15 11:43:57 +02:00
2019-04-02 06:35:57 +02:00
if (eContestAI.scriptResult < gAIScriptPtr[0])
2018-08-15 11:43:57 +02:00
gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 1);
else
gAIScriptPtr += 5;
}
2019-04-02 04:09:14 +02:00
static void ContestAICmd_if_user_condition_more_than(void)
2018-08-15 11:43:57 +02:00
{
2019-04-02 04:09:14 +02:00
ContestAICmd_get_user_condition();
2018-08-15 11:43:57 +02:00
2019-04-02 06:35:57 +02:00
if (eContestAI.scriptResult > gAIScriptPtr[0])
2018-08-15 11:43:57 +02:00
gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 1);
else
gAIScriptPtr += 5;
}
2019-04-02 04:09:14 +02:00
static void ContestAICmd_if_user_condition_eq(void)
2018-08-15 11:43:57 +02:00
{
2019-04-02 04:09:14 +02:00
ContestAICmd_get_user_condition();
2018-08-15 11:43:57 +02:00
2019-04-02 06:35:57 +02:00
if (eContestAI.scriptResult == gAIScriptPtr[0])
2018-08-15 11:43:57 +02:00
gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 1);
else
gAIScriptPtr += 5;
}
2019-04-02 04:09:14 +02:00
static void ContestAICmd_if_user_condition_not_eq(void)
2018-08-15 11:43:57 +02:00
{
2019-04-02 04:09:14 +02:00
ContestAICmd_get_user_condition();
2018-08-15 11:43:57 +02:00
2019-04-02 06:35:57 +02:00
if (eContestAI.scriptResult != gAIScriptPtr[0])
2018-08-15 11:43:57 +02:00
gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 1);
else
gAIScriptPtr += 5;
}
2020-08-21 08:36:48 +02:00
static void ContestAICmd_get_points(void)
2018-08-15 11:43:57 +02:00
{
2019-04-02 06:35:57 +02:00
eContestAI.scriptResult = eContestantStatus[eContestAI.contestantId].pointTotal;
2018-08-15 11:43:57 +02:00
gAIScriptPtr += 1;
}
2020-08-21 08:36:48 +02:00
static void ContestAICmd_if_points_less_than(void)
2018-08-15 11:43:57 +02:00
{
2020-08-21 08:36:48 +02:00
ContestAICmd_get_points();
2018-08-15 11:43:57 +02:00
2019-04-02 06:35:57 +02:00
if (eContestAI.scriptResult < (s16)T1_READ_16(gAIScriptPtr + 0))
2018-08-15 11:43:57 +02:00
gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 2);
else
gAIScriptPtr += 6;
}
2020-08-21 08:36:48 +02:00
static void ContestAICmd_if_points_more_than(void)
2018-08-15 11:43:57 +02:00
{
2020-08-21 08:36:48 +02:00
ContestAICmd_get_points();
2018-08-15 11:43:57 +02:00
2019-04-02 06:35:57 +02:00
if (eContestAI.scriptResult > (s16)T1_READ_16(gAIScriptPtr + 0))
2018-08-15 11:43:57 +02:00
gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 2);
else
gAIScriptPtr += 6;
}
2020-08-21 08:36:48 +02:00
static void ContestAICmd_if_points_eq(void)
2018-08-15 11:43:57 +02:00
{
2020-08-21 08:36:48 +02:00
ContestAICmd_get_points();
2018-08-15 11:43:57 +02:00
2019-04-02 06:35:57 +02:00
if (eContestAI.scriptResult == (s16)T1_READ_16(gAIScriptPtr + 0))
2018-08-15 11:43:57 +02:00
gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 2);
else
gAIScriptPtr += 6;
}
2020-08-21 08:36:48 +02:00
static void ContestAICmd_if_points_not_eq(void)
2018-08-15 11:43:57 +02:00
{
2020-08-21 08:36:48 +02:00
ContestAICmd_get_points();
2018-08-15 11:43:57 +02:00
2019-04-02 06:35:57 +02:00
if (eContestAI.scriptResult != (s16)T1_READ_16(gAIScriptPtr + 0))
2018-08-15 11:43:57 +02:00
gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 2);
else
gAIScriptPtr += 6;
}
2020-08-21 08:36:48 +02:00
static void ContestAICmd_get_preliminary_points(void)
2018-08-15 11:43:57 +02:00
{
2020-07-24 06:14:53 +02:00
eContestAI.scriptResult = gContestMonRound1Points[eContestAI.contestantId];
2018-08-15 11:43:57 +02:00
gAIScriptPtr += 1;
}
2020-08-21 08:36:48 +02:00
static void ContestAICmd_if_preliminary_points_less_than(void)
2018-08-15 11:43:57 +02:00
{
2020-08-21 08:36:48 +02:00
ContestAICmd_get_preliminary_points();
2018-08-15 11:43:57 +02:00
2019-04-02 06:35:57 +02:00
if (eContestAI.scriptResult < (s16)T1_READ_16(gAIScriptPtr + 0))
2018-08-15 11:43:57 +02:00
gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 2);
else
gAIScriptPtr += 6;
}
2020-08-21 08:36:48 +02:00
static void ContestAICmd_if_preliminary_points_more_than(void)
2018-08-15 11:43:57 +02:00
{
2020-08-21 08:36:48 +02:00
ContestAICmd_get_preliminary_points();
2018-08-15 11:43:57 +02:00
2019-04-02 06:35:57 +02:00
if (eContestAI.scriptResult > (s16)T1_READ_16(gAIScriptPtr + 0))
2018-08-15 11:43:57 +02:00
gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 2);
else
gAIScriptPtr += 6;
}
2020-08-21 08:36:48 +02:00
static void ContestAICmd_if_preliminary_points_eq(void)
2018-08-15 11:43:57 +02:00
{
2020-08-21 08:36:48 +02:00
ContestAICmd_get_preliminary_points();
2018-08-15 11:43:57 +02:00
2019-04-02 06:35:57 +02:00
if (eContestAI.scriptResult == (s16)T1_READ_16(gAIScriptPtr + 0))
2018-08-15 11:43:57 +02:00
gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 2);
else
gAIScriptPtr += 6;
}
2020-08-21 08:36:48 +02:00
static void ContestAICmd_if_preliminary_points_not_eq(void)
2018-08-15 11:43:57 +02:00
{
2020-08-21 08:36:48 +02:00
ContestAICmd_get_preliminary_points();
2018-08-15 11:43:57 +02:00
2019-04-02 06:35:57 +02:00
if (eContestAI.scriptResult != (s16)T1_READ_16(gAIScriptPtr + 0))
2018-08-15 11:43:57 +02:00
gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 2);
else
gAIScriptPtr += 6;
}
static void ContestAICmd_get_contest_type(void)
{
2019-04-02 06:35:57 +02:00
eContestAI.scriptResult = gSpecialVar_ContestCategory;
2018-08-15 11:43:57 +02:00
gAIScriptPtr += 1;
}
2019-04-02 04:09:14 +02:00
static void ContestAICmd_if_contest_type_eq(void)
2018-08-15 11:43:57 +02:00
{
ContestAICmd_get_contest_type();
2019-04-02 06:35:57 +02:00
if (eContestAI.scriptResult == gAIScriptPtr[0])
2018-08-15 11:43:57 +02:00
gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 1);
else
gAIScriptPtr += 5;
}
2019-04-02 04:09:14 +02:00
static void ContestAICmd_if_contest_type_not_eq(void)
2018-08-15 11:43:57 +02:00
{
ContestAICmd_get_contest_type();
2019-04-02 06:35:57 +02:00
if (eContestAI.scriptResult != gAIScriptPtr[0])
2018-08-15 11:43:57 +02:00
gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 1);
else
gAIScriptPtr += 5;
}
static void ContestAICmd_get_move_excitement(void)
{
2019-04-02 06:35:57 +02:00
eContestAI.scriptResult = Contest_GetMoveExcitement(gContestMons[eContestAI.contestantId].moves[eContestAI.nextMoveIndex]);
2018-08-15 11:43:57 +02:00
gAIScriptPtr += 1;
}
2019-04-02 04:09:14 +02:00
static void ContestAICmd_if_move_excitement_less_than(void)
2018-08-15 11:43:57 +02:00
{
ContestAICmd_get_move_excitement();
2019-04-02 06:35:57 +02:00
if (eContestAI.scriptResult < (s8)gAIScriptPtr[0])
2018-08-15 11:43:57 +02:00
gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 1);
else
gAIScriptPtr += 5;
}
2020-08-21 08:36:48 +02:00
static void ContestAICmd_if_move_excitement_more_than(void)
2018-08-15 11:43:57 +02:00
{
ContestAICmd_get_move_excitement();
2019-04-02 06:35:57 +02:00
if (eContestAI.scriptResult > (s8)gAIScriptPtr[0])
2018-08-15 11:43:57 +02:00
gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 1);
else
gAIScriptPtr += 5;
}
2019-04-02 04:09:14 +02:00
static void ContestAICmd_if_move_excitement_eq(void)
2018-08-15 11:43:57 +02:00
{
ContestAICmd_get_move_excitement();
2019-04-02 06:35:57 +02:00
if (eContestAI.scriptResult == (s8)gAIScriptPtr[0])
2018-08-15 11:43:57 +02:00
gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 1);
else
gAIScriptPtr += 5;
}
2019-04-02 04:09:14 +02:00
static void ContestAICmd_if_move_excitement_not_eq(void)
2018-08-15 11:43:57 +02:00
{
ContestAICmd_get_move_excitement();
2019-04-02 06:35:57 +02:00
if (eContestAI.scriptResult != (s8)gAIScriptPtr[0])
2018-08-15 11:43:57 +02:00
gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 1);
else
gAIScriptPtr += 5;
}
static void ContestAICmd_get_move_effect(void)
{
2019-04-02 06:35:57 +02:00
u16 move = gContestMons[eContestAI.contestantId].moves[eContestAI.nextMoveIndex];
2018-08-15 11:43:57 +02:00
2019-04-02 06:35:57 +02:00
eContestAI.scriptResult = gContestMoves[move].effect;
2018-08-15 11:43:57 +02:00
gAIScriptPtr += 1;
}
2019-04-02 04:09:14 +02:00
static void ContestAICmd_if_move_effect_eq(void)
2018-08-15 11:43:57 +02:00
{
ContestAICmd_get_move_effect();
2019-04-02 06:35:57 +02:00
if (eContestAI.scriptResult == gAIScriptPtr[0])
2018-08-15 11:43:57 +02:00
gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 1);
else
gAIScriptPtr += 5;
}
2019-04-02 04:09:14 +02:00
static void ContestAICmd_if_move_effect_not_eq(void)
2018-08-15 11:43:57 +02:00
{
ContestAICmd_get_move_effect();
2019-04-02 06:35:57 +02:00
if (eContestAI.scriptResult != gAIScriptPtr[0])
2018-08-15 11:43:57 +02:00
gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 1);
else
gAIScriptPtr += 5;
}
static void ContestAICmd_get_move_effect_type(void)
{
2019-04-02 06:35:57 +02:00
u16 move = gContestMons[eContestAI.contestantId].moves[eContestAI.nextMoveIndex];
2018-08-15 11:43:57 +02:00
2019-04-02 06:35:57 +02:00
eContestAI.scriptResult = gContestEffects[gContestMoves[move].effect].effectType;
2018-08-15 11:43:57 +02:00
gAIScriptPtr += 1;
}
2019-04-02 04:09:14 +02:00
static void ContestAICmd_if_move_effect_type_eq(void)
2018-08-15 11:43:57 +02:00
{
ContestAICmd_get_move_effect_type();
2019-04-02 06:35:57 +02:00
if (eContestAI.scriptResult == gAIScriptPtr[0])
2018-08-15 11:43:57 +02:00
gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 1);
else
gAIScriptPtr += 5;
}
2019-04-02 04:09:14 +02:00
static void ContestAICmd_if_move_effect_type_not_eq(void)
2018-08-15 11:43:57 +02:00
{
ContestAICmd_get_move_effect_type();
2019-04-02 06:35:57 +02:00
if (eContestAI.scriptResult != gAIScriptPtr[0])
2018-08-15 11:43:57 +02:00
gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 1);
else
gAIScriptPtr += 5;
}
2019-04-02 04:09:14 +02:00
static void ContestAICmd_check_most_appealing_move(void)
2018-08-15 11:43:57 +02:00
{
int i;
2019-04-02 06:35:57 +02:00
u16 move = gContestMons[eContestAI.contestantId].moves[eContestAI.nextMoveIndex];
2018-08-15 11:43:57 +02:00
u8 appeal = gContestEffects[gContestMoves[move].effect].appeal;
for (i = 0; i < MAX_MON_MOVES; i++)
2018-08-15 11:43:57 +02:00
{
2019-04-02 06:35:57 +02:00
u16 newMove = gContestMons[eContestAI.contestantId].moves[i];
2018-08-15 11:43:57 +02:00
if (newMove != 0 && appeal < gContestEffects[gContestMoves[newMove].effect].appeal)
break;
}
if (i == MAX_MON_MOVES)
2019-04-02 06:35:57 +02:00
eContestAI.scriptResult = TRUE;
2018-08-15 11:43:57 +02:00
else
2019-04-02 06:35:57 +02:00
eContestAI.scriptResult = FALSE;
2018-08-15 11:43:57 +02:00
gAIScriptPtr += 1;
}
2019-04-02 04:09:14 +02:00
static void ContestAICmd_if_most_appealing_move(void)
2018-08-15 11:43:57 +02:00
{
2019-04-02 04:09:14 +02:00
ContestAICmd_check_most_appealing_move();
2018-08-15 11:43:57 +02:00
2019-04-02 06:35:57 +02:00
if (eContestAI.scriptResult != FALSE)
2018-08-15 11:43:57 +02:00
gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 0);
else
gAIScriptPtr += 4;
}
2020-08-21 08:36:48 +02:00
static void ContestAICmd_check_most_jamming_move(void)
2018-08-15 11:43:57 +02:00
{
int i;
2019-04-02 06:35:57 +02:00
u16 move = gContestMons[eContestAI.contestantId].moves[eContestAI.nextMoveIndex];
2018-08-15 11:43:57 +02:00
u8 jam = gContestEffects[gContestMoves[move].effect].jam;
for (i = 0; i < MAX_MON_MOVES; i++)
2018-08-15 11:43:57 +02:00
{
2019-04-02 06:35:57 +02:00
u16 newMove = gContestMons[eContestAI.contestantId].moves[i];
2020-08-21 08:36:48 +02:00
if (newMove != MOVE_NONE && jam < gContestEffects[gContestMoves[newMove].effect].jam)
2018-08-15 11:43:57 +02:00
break;
}
if (i == MAX_MON_MOVES)
2019-04-02 06:35:57 +02:00
eContestAI.scriptResult = TRUE;
2018-08-15 11:43:57 +02:00
else
2019-04-02 06:35:57 +02:00
eContestAI.scriptResult = FALSE;
2018-08-15 11:43:57 +02:00
gAIScriptPtr += 1;
}
2020-08-21 08:36:48 +02:00
static void ContestAICmd_if_most_jamming_move(void)
2018-08-15 11:43:57 +02:00
{
2020-08-21 08:36:48 +02:00
ContestAICmd_check_most_jamming_move();
2018-08-15 11:43:57 +02:00
2019-04-02 06:35:57 +02:00
if (eContestAI.scriptResult != FALSE)
2018-08-15 11:43:57 +02:00
gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 1);
else
gAIScriptPtr += 5;
}
2020-08-21 08:36:48 +02:00
static void ContestAICmd_get_num_move_hearts(void)
2018-08-15 11:43:57 +02:00
{
2019-04-02 06:35:57 +02:00
u16 move = gContestMons[eContestAI.contestantId].moves[eContestAI.nextMoveIndex];
2018-08-15 11:43:57 +02:00
2019-04-02 06:35:57 +02:00
eContestAI.scriptResult = gContestEffects[gContestMoves[move].effect].appeal / 10;
2018-08-15 11:43:57 +02:00
gAIScriptPtr += 1;
}
2020-08-21 08:36:48 +02:00
static void ContestAICmd_if_num_move_hearts_less_than(void)
2018-08-15 11:43:57 +02:00
{
2020-08-21 08:36:48 +02:00
ContestAICmd_get_num_move_hearts();
2018-08-15 11:43:57 +02:00
2019-04-02 06:35:57 +02:00
if (eContestAI.scriptResult < gAIScriptPtr[0])
2018-08-15 11:43:57 +02:00
gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 1);
else
gAIScriptPtr += 5;
}
2020-08-21 08:36:48 +02:00
static void ContestAICmd_if_num_move_hearts_more_than(void)
2018-08-15 11:43:57 +02:00
{
2020-08-21 08:36:48 +02:00
ContestAICmd_get_num_move_hearts();
2018-08-15 11:43:57 +02:00
2019-04-02 06:35:57 +02:00
if (eContestAI.scriptResult > gAIScriptPtr[0])
2018-08-15 11:43:57 +02:00
gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 1);
else
gAIScriptPtr += 5;
}
2020-08-21 08:36:48 +02:00
static void ContestAICmd_if_num_move_hearts_eq(void)
2018-08-15 11:43:57 +02:00
{
2020-08-21 08:36:48 +02:00
ContestAICmd_get_num_move_hearts();
2018-08-15 11:43:57 +02:00
2019-04-02 06:35:57 +02:00
if (eContestAI.scriptResult == gAIScriptPtr[0])
2018-08-15 11:43:57 +02:00
gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 1);
else
gAIScriptPtr += 5;
}
2020-08-21 08:36:48 +02:00
static void ContestAICmd_if_num_move_hearts_not_eq(void)
2018-08-15 11:43:57 +02:00
{
2020-08-21 08:36:48 +02:00
ContestAICmd_get_num_move_hearts();
2018-08-15 11:43:57 +02:00
2019-04-02 06:35:57 +02:00
if (eContestAI.scriptResult != gAIScriptPtr[0])
2018-08-15 11:43:57 +02:00
gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 1);
else
gAIScriptPtr += 5;
}
2020-08-21 08:36:48 +02:00
static void ContestAICmd_get_num_move_jam_hearts(void)
2018-08-15 11:43:57 +02:00
{
2019-04-02 06:35:57 +02:00
u16 move = gContestMons[eContestAI.contestantId].moves[eContestAI.nextMoveIndex];
2018-08-15 11:43:57 +02:00
2019-04-02 06:35:57 +02:00
eContestAI.scriptResult = gContestEffects[gContestMoves[move].effect].jam / 10;
2018-08-15 11:43:57 +02:00
gAIScriptPtr += 1;
}
2020-08-21 08:36:48 +02:00
static void ContestAICmd_if_num_move_jam_hearts_less_than(void)
2018-08-15 11:43:57 +02:00
{
2020-08-21 08:36:48 +02:00
ContestAICmd_get_num_move_jam_hearts();
2018-08-15 11:43:57 +02:00
2019-04-02 06:35:57 +02:00
if (eContestAI.scriptResult < gAIScriptPtr[0])
2018-08-15 11:43:57 +02:00
gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 1);
else
gAIScriptPtr += 5;
}
2020-08-21 08:36:48 +02:00
static void ContestAICmd_if_num_move_jam_hearts_more_than(void)
2018-08-15 11:43:57 +02:00
{
2020-08-21 08:36:48 +02:00
ContestAICmd_get_num_move_jam_hearts();
2018-08-15 11:43:57 +02:00
2019-04-02 06:35:57 +02:00
if (eContestAI.scriptResult > gAIScriptPtr[0])
2018-08-15 11:43:57 +02:00
gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 1);
else
gAIScriptPtr += 5;
}
2020-08-21 08:36:48 +02:00
static void ContestAICmd_if_num_move_jam_hearts_eq(void)
2018-08-15 11:43:57 +02:00
{
2020-08-21 08:36:48 +02:00
ContestAICmd_get_num_move_jam_hearts();
2018-08-15 11:43:57 +02:00
2019-04-02 06:35:57 +02:00
if (eContestAI.scriptResult == gAIScriptPtr[0])
2018-08-15 11:43:57 +02:00
gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 1);
else
gAIScriptPtr += 5;
}
2020-08-21 08:36:48 +02:00
static void ContestAICmd_if_num_move_jam_hearts_not_eq(void)
2018-08-15 11:43:57 +02:00
{
2020-08-21 08:36:48 +02:00
ContestAICmd_get_num_move_jam_hearts();
2018-08-15 11:43:57 +02:00
2019-04-02 06:35:57 +02:00
if (eContestAI.scriptResult != gAIScriptPtr[0])
2018-08-15 11:43:57 +02:00
gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 1);
else
gAIScriptPtr += 5;
}
static void ContestAICmd_get_move_used_count(void)
{
s16 result;
2019-04-02 06:35:57 +02:00
u16 move = gContestMons[eContestAI.contestantId].moves[eContestAI.nextMoveIndex];
2018-08-15 11:43:57 +02:00
2019-04-02 06:35:57 +02:00
if (move != eContestantStatus[eContestAI.contestantId].prevMove)
2018-08-15 11:43:57 +02:00
result = 0; // move is unique and not reused.
else
2019-04-02 06:35:57 +02:00
result = eContestantStatus[eContestAI.contestantId].moveRepeatCount + 1;
2018-08-15 11:43:57 +02:00
2019-04-02 06:35:57 +02:00
eContestAI.scriptResult = result;
2018-08-15 11:43:57 +02:00
gAIScriptPtr += 1;
}
2019-04-02 04:09:14 +02:00
static void ContestAICmd_if_most_used_count_less_than(void)
2018-08-15 11:43:57 +02:00
{
ContestAICmd_get_move_used_count();
2019-04-02 06:35:57 +02:00
if (eContestAI.scriptResult < gAIScriptPtr[0])
2018-08-15 11:43:57 +02:00
gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 1);
else
gAIScriptPtr += 5;
}
2019-04-02 04:09:14 +02:00
static void ContestAICmd_if_most_used_count_more_than(void)
2018-08-15 11:43:57 +02:00
{
ContestAICmd_get_move_used_count();
2019-04-02 06:35:57 +02:00
if (eContestAI.scriptResult > gAIScriptPtr[0])
2018-08-15 11:43:57 +02:00
gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 1);
else
gAIScriptPtr += 5;
}
2019-04-02 04:09:14 +02:00
static void ContestAICmd_if_most_used_count_eq(void)
2018-08-15 11:43:57 +02:00
{
ContestAICmd_get_move_used_count();
2019-04-02 06:35:57 +02:00
if (eContestAI.scriptResult == gAIScriptPtr[0])
2018-08-15 11:43:57 +02:00
gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 1);
else
gAIScriptPtr += 5;
}
2019-04-02 04:09:14 +02:00
static void ContestAICmd_if_most_used_count_not_eq(void)
2018-08-15 11:43:57 +02:00
{
ContestAICmd_get_move_used_count();
2019-04-02 06:35:57 +02:00
if (eContestAI.scriptResult != gAIScriptPtr[0])
2018-08-15 11:43:57 +02:00
gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 1);
else
gAIScriptPtr += 5;
}
static void ContestAICmd_check_combo_starter(void)
{
u8 result = 0;
int i;
2019-04-02 06:35:57 +02:00
u16 move = gContestMons[eContestAI.contestantId].moves[eContestAI.nextMoveIndex];
2018-08-15 11:43:57 +02:00
for (i = 0; i < MAX_MON_MOVES; i++)
2018-08-15 11:43:57 +02:00
{
2019-04-02 06:35:57 +02:00
if (gContestMons[eContestAI.contestantId].moves[i])
2018-08-15 11:43:57 +02:00
{
2019-04-02 06:35:57 +02:00
result = AreMovesContestCombo(move, gContestMons[eContestAI.contestantId].moves[i]);
2018-08-15 11:43:57 +02:00
if (result)
{
result = 1;
break;
}
}
}
if (result)
result = 1;
2019-04-02 06:35:57 +02:00
eContestAI.scriptResult = result;
2018-08-15 11:43:57 +02:00
gAIScriptPtr += 1;
}
2019-04-02 04:09:14 +02:00
static void ContestAICmd_if_combo_starter(void)
2018-08-15 11:43:57 +02:00
{
ContestAICmd_check_combo_starter();
2020-08-21 08:36:48 +02:00
if (eContestAI.scriptResult)
2018-08-15 11:43:57 +02:00
gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 0);
else
gAIScriptPtr += 4;
}
2019-04-02 04:09:14 +02:00
static void ContestAICmd_if_not_combo_starter(void)
2018-08-15 11:43:57 +02:00
{
ContestAICmd_check_combo_starter();
2020-08-21 08:36:48 +02:00
if (!eContestAI.scriptResult)
2018-08-15 11:43:57 +02:00
gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 0);
else
gAIScriptPtr += 4;
}
static void ContestAICmd_check_combo_finisher(void)
{
u8 result = 0;
int i;
2019-04-02 06:35:57 +02:00
u16 move = gContestMons[eContestAI.contestantId].moves[eContestAI.nextMoveIndex];
2018-08-15 11:43:57 +02:00
for (i = 0; i < MAX_MON_MOVES; i++)
2018-08-15 11:43:57 +02:00
{
2019-04-02 06:35:57 +02:00
if (gContestMons[eContestAI.contestantId].moves[i])
2018-08-15 11:43:57 +02:00
{
2019-04-02 06:35:57 +02:00
result = AreMovesContestCombo(gContestMons[eContestAI.contestantId].moves[i], move);
2018-08-15 11:43:57 +02:00
if (result)
{
result = 1;
break;
}
}
}
if (result)
result = 1;
2019-04-02 06:35:57 +02:00
eContestAI.scriptResult = result;
2018-08-15 11:43:57 +02:00
gAIScriptPtr += 1;
}
2019-04-02 04:09:14 +02:00
static void ContestAICmd_if_combo_finisher(void)
2018-08-15 11:43:57 +02:00
{
ContestAICmd_check_combo_finisher();
2020-08-21 08:36:48 +02:00
if (eContestAI.scriptResult)
2018-08-15 11:43:57 +02:00
gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 0);
else
gAIScriptPtr += 4;
}
2019-04-02 04:09:14 +02:00
static void ContestAICmd_if_not_combo_finisher(void)
2018-08-15 11:43:57 +02:00
{
ContestAICmd_check_combo_finisher();
2020-08-21 08:36:48 +02:00
if (!eContestAI.scriptResult)
2018-08-15 11:43:57 +02:00
gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 0);
else
gAIScriptPtr += 4;
}
static void ContestAICmd_check_would_finish_combo(void)
{
u8 result = 0;
2019-04-02 06:35:57 +02:00
u16 move = gContestMons[eContestAI.contestantId].moves[eContestAI.nextMoveIndex];
2018-08-15 11:43:57 +02:00
2019-04-02 06:35:57 +02:00
if (eContestantStatus[eContestAI.contestantId].prevMove)
result = AreMovesContestCombo(eContestantStatus[eContestAI.contestantId].prevMove, move);
2018-08-15 11:43:57 +02:00
if (result)
result = 1;
2019-04-02 06:35:57 +02:00
eContestAI.scriptResult = result;
2018-08-15 11:43:57 +02:00
gAIScriptPtr += 1;
}
2019-04-02 04:09:14 +02:00
static void ContestAICmd_if_would_finish_combo(void)
2018-08-15 11:43:57 +02:00
{
ContestAICmd_check_would_finish_combo();
2020-08-21 08:36:48 +02:00
if (eContestAI.scriptResult)
2018-08-15 11:43:57 +02:00
gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 0);
else
gAIScriptPtr += 4;
}
2019-04-02 04:09:14 +02:00
static void ContestAICmd_if_would_not_finish_combo(void)
2018-08-15 11:43:57 +02:00
{
ContestAICmd_check_would_finish_combo();
2020-08-21 08:36:48 +02:00
if (!eContestAI.scriptResult)
2018-08-15 11:43:57 +02:00
gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 0);
else
gAIScriptPtr += 4;
}
static void ContestAICmd_get_condition(void)
{
2020-07-12 02:25:56 +02:00
u8 contestant = GetContestantIdByTurn(gAIScriptPtr[1]);
2018-08-15 11:43:57 +02:00
2020-07-12 02:25:56 +02:00
eContestAI.scriptResult = eContestantStatus[contestant].condition / 10;
2018-08-15 11:43:57 +02:00
gAIScriptPtr += 2;
}
2019-04-02 04:09:14 +02:00
static void ContestAICmd_if_condition_less_than(void)
2018-08-15 11:43:57 +02:00
{
ContestAICmd_get_condition();
2019-04-02 06:35:57 +02:00
if (eContestAI.scriptResult < gAIScriptPtr[0])
2018-08-15 11:43:57 +02:00
gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 1);
else
gAIScriptPtr += 5;
}
2019-04-02 04:09:14 +02:00
static void ContestAICmd_if_condition_more_than(void)
2018-08-15 11:43:57 +02:00
{
ContestAICmd_get_condition();
2019-04-02 06:35:57 +02:00
if (eContestAI.scriptResult > gAIScriptPtr[0])
2018-08-15 11:43:57 +02:00
gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 1);
else
gAIScriptPtr += 5;
}
2019-04-02 04:09:14 +02:00
static void ContestAICmd_if_condition_eq(void)
2018-08-15 11:43:57 +02:00
{
ContestAICmd_get_condition();
2019-04-02 06:35:57 +02:00
if (eContestAI.scriptResult == gAIScriptPtr[0])
2018-08-15 11:43:57 +02:00
gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 1);
else
gAIScriptPtr += 5;
}
2019-04-02 04:09:14 +02:00
static void ContestAICmd_if_condition_not_eq(void)
2018-08-15 11:43:57 +02:00
{
ContestAICmd_get_condition();
2019-04-02 06:35:57 +02:00
if (eContestAI.scriptResult != gAIScriptPtr[0])
2018-08-15 11:43:57 +02:00
gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 1);
else
gAIScriptPtr += 5;
}
static void ContestAICmd_get_used_combo_starter(void)
{
2020-07-12 02:25:56 +02:00
u16 result = FALSE;
u8 contestant = GetContestantIdByTurn(gAIScriptPtr[1]);
2018-08-15 11:43:57 +02:00
2020-08-14 01:10:23 +02:00
if (IsContestantAllowedToCombo(contestant))
2020-07-12 02:25:56 +02:00
result = gContestMoves[eContestantStatus[contestant].prevMove].comboStarterId ? TRUE : FALSE;
2018-08-15 11:43:57 +02:00
2019-04-02 06:35:57 +02:00
eContestAI.scriptResult = result;
2018-08-15 11:43:57 +02:00
gAIScriptPtr += 2;
}
2019-04-02 04:09:14 +02:00
static void ContestAICmd_if_used_combo_starter_less_than(void)
2018-08-15 11:43:57 +02:00
{
ContestAICmd_get_used_combo_starter();
2019-04-02 06:35:57 +02:00
if (eContestAI.scriptResult < gAIScriptPtr[0])
2018-08-15 11:43:57 +02:00
gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 1);
else
gAIScriptPtr += 5;
}
2019-04-02 04:09:14 +02:00
static void ContestAICmd_if_used_combo_starter_more_than(void)
2018-08-15 11:43:57 +02:00
{
ContestAICmd_get_used_combo_starter();
2019-04-02 06:35:57 +02:00
if (eContestAI.scriptResult > gAIScriptPtr[0])
2018-08-15 11:43:57 +02:00
gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 1);
else
gAIScriptPtr += 5;
}
2019-04-02 04:09:14 +02:00
static void ContestAICmd_if_used_combo_starter_eq(void)
2018-08-15 11:43:57 +02:00
{
ContestAICmd_get_used_combo_starter();
2019-04-02 06:35:57 +02:00
if (eContestAI.scriptResult == gAIScriptPtr[0])
2018-08-15 11:43:57 +02:00
gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 1);
else
gAIScriptPtr += 5;
}
2019-04-02 04:09:14 +02:00
static void ContestAICmd_if_used_combo_starter_not_eq(void)
2018-08-15 11:43:57 +02:00
{
ContestAICmd_get_used_combo_starter();
2019-04-02 06:35:57 +02:00
if (eContestAI.scriptResult != gAIScriptPtr[0])
2018-08-15 11:43:57 +02:00
gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 1);
else
gAIScriptPtr += 5;
}
static void ContestAICmd_check_can_participate(void)
{
2020-07-12 02:25:56 +02:00
if (Contest_IsMonsTurnDisabled(GetContestantIdByTurn(gAIScriptPtr[1])))
2019-04-02 06:35:57 +02:00
eContestAI.scriptResult = FALSE;
2018-08-15 11:43:57 +02:00
else
2019-04-02 06:35:57 +02:00
eContestAI.scriptResult = TRUE;
2018-08-15 11:43:57 +02:00
gAIScriptPtr += 2;
}
2019-04-02 04:09:14 +02:00
static void ContestAICmd_if_can_participate(void)
2018-08-15 11:43:57 +02:00
{
ContestAICmd_check_can_participate();
2020-08-21 08:36:48 +02:00
if (eContestAI.scriptResult)
2018-08-15 11:43:57 +02:00
gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 0);
else
gAIScriptPtr += 4;
}
2019-04-02 04:09:14 +02:00
static void ContestAICmd_if_cannot_participate(void)
2018-08-15 11:43:57 +02:00
{
ContestAICmd_check_can_participate();
2020-08-21 08:36:48 +02:00
if (!eContestAI.scriptResult)
2018-08-15 11:43:57 +02:00
gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 0);
else
gAIScriptPtr += 4;
}
2020-08-21 08:36:48 +02:00
static void ContestAICmd_get_completed_combo(void)
2018-08-15 11:43:57 +02:00
{
2020-07-12 02:25:56 +02:00
u8 contestant = GetContestantIdByTurn(gAIScriptPtr[1]);
2018-08-15 11:43:57 +02:00
2020-08-21 08:36:48 +02:00
eContestAI.scriptResult = eContestantStatus[contestant].completedComboFlag;
2018-08-15 11:43:57 +02:00
gAIScriptPtr += 2;
}
2020-08-21 08:36:48 +02:00
static void ContestAICmd_if_completed_combo(void)
2018-08-15 11:43:57 +02:00
{
2020-08-21 08:36:48 +02:00
ContestAICmd_get_completed_combo();
2018-08-15 11:43:57 +02:00
2020-08-21 08:36:48 +02:00
if (eContestAI.scriptResult)
2018-08-15 11:43:57 +02:00
gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 0);
else
gAIScriptPtr += 4;
}
2020-08-21 08:36:48 +02:00
static void ContestAICmd_if_not_completed_combo(void)
2018-08-15 11:43:57 +02:00
{
2020-08-21 08:36:48 +02:00
ContestAICmd_get_completed_combo();
2018-08-15 11:43:57 +02:00
2020-08-21 08:36:48 +02:00
if (!eContestAI.scriptResult)
2018-08-15 11:43:57 +02:00
gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 0);
else
gAIScriptPtr += 4;
}
2020-08-21 08:36:48 +02:00
static void ContestAICmd_get_points_diff(void)
2018-08-15 11:43:57 +02:00
{
2020-07-12 02:25:56 +02:00
u8 contestant = GetContestantIdByTurn(gAIScriptPtr[1]);
2018-08-15 11:43:57 +02:00
2020-07-12 02:25:56 +02:00
eContestAI.scriptResult = eContestantStatus[contestant].pointTotal - eContestantStatus[eContestAI.contestantId].pointTotal;
2018-08-15 11:43:57 +02:00
gAIScriptPtr += 2;
}
2020-08-21 08:36:48 +02:00
static void ContestAICmd_if_points_more_than_mon(void)
2018-08-15 11:43:57 +02:00
{
2020-08-21 08:36:48 +02:00
ContestAICmd_get_points_diff();
2018-08-15 11:43:57 +02:00
2019-04-02 06:35:57 +02:00
if (eContestAI.scriptResult < 0)
2018-08-15 11:43:57 +02:00
gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 0);
else
gAIScriptPtr += 4;
}
2020-08-21 08:36:48 +02:00
static void ContestAICmd_if_points_less_than_mon(void)
2018-08-15 11:43:57 +02:00
{
2020-08-21 08:36:48 +02:00
ContestAICmd_get_points_diff();
2018-08-15 11:43:57 +02:00
2019-04-02 06:35:57 +02:00
if (eContestAI.scriptResult > 0)
2018-08-15 11:43:57 +02:00
gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 0);
else
gAIScriptPtr += 4;
}
2020-08-21 08:36:48 +02:00
static void ContestAICmd_if_points_eq_mon(void)
2018-08-15 11:43:57 +02:00
{
2020-08-21 08:36:48 +02:00
ContestAICmd_get_points_diff();
2018-08-15 11:43:57 +02:00
2019-04-02 06:35:57 +02:00
if (eContestAI.scriptResult == 0)
2018-08-15 11:43:57 +02:00
gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 0);
else
gAIScriptPtr += 4;
}
2020-08-21 08:36:48 +02:00
static void ContestAICmd_if_points_not_eq_mon(void)
2018-08-15 11:43:57 +02:00
{
2020-08-21 08:36:48 +02:00
ContestAICmd_get_points_diff();
2018-08-15 11:43:57 +02:00
2019-04-02 06:35:57 +02:00
if (eContestAI.scriptResult != 0)
2018-08-15 11:43:57 +02:00
gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 0);
else
gAIScriptPtr += 4;
}
2020-08-21 08:36:48 +02:00
static void ContestAICmd_get_preliminary_points_diff(void)
2018-08-15 11:43:57 +02:00
{
2020-07-12 02:25:56 +02:00
u8 contestant = GetContestantIdByTurn(gAIScriptPtr[1]);
2018-08-15 11:43:57 +02:00
2020-07-24 06:14:53 +02:00
eContestAI.scriptResult = gContestMonRound1Points[contestant] - gContestMonRound1Points[eContestAI.contestantId];
2018-08-15 11:43:57 +02:00
gAIScriptPtr += 2;
}
2020-08-21 08:36:48 +02:00
static void ContestAICmd_if_preliminary_points_more_than_mon(void)
2018-08-15 11:43:57 +02:00
{
2020-08-21 08:36:48 +02:00
ContestAICmd_get_preliminary_points_diff();
2018-08-15 11:43:57 +02:00
2019-04-02 06:35:57 +02:00
if (eContestAI.scriptResult < 0)
2018-08-15 11:43:57 +02:00
gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 0);
else
gAIScriptPtr += 4;
}
2020-08-21 08:36:48 +02:00
static void ContestAICmd_if_preliminary_points_less_than_mon(void)
2018-08-15 11:43:57 +02:00
{
2020-08-21 08:36:48 +02:00
ContestAICmd_get_preliminary_points_diff();
2018-08-15 11:43:57 +02:00
2019-04-02 06:35:57 +02:00
if (eContestAI.scriptResult > 0)
2018-08-15 11:43:57 +02:00
gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 0);
else
gAIScriptPtr += 4;
}
2020-08-21 08:36:48 +02:00
static void ContestAICmd_if_preliminary_points_eq_mon(void)
2018-08-15 11:43:57 +02:00
{
2020-08-21 08:36:48 +02:00
ContestAICmd_get_preliminary_points_diff();
2018-08-15 11:43:57 +02:00
2019-04-02 06:35:57 +02:00
if (eContestAI.scriptResult == 0)
2018-08-15 11:43:57 +02:00
gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 0);
else
gAIScriptPtr += 4;
}
2020-08-21 08:36:48 +02:00
static void ContestAICmd_if_preliminary_points_not_eq_mon(void)
2018-08-15 11:43:57 +02:00
{
2020-08-21 08:36:48 +02:00
ContestAICmd_get_preliminary_points_diff();
2018-08-15 11:43:57 +02:00
2019-04-02 06:35:57 +02:00
if (eContestAI.scriptResult != 0)
2018-08-15 11:43:57 +02:00
gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 0);
else
gAIScriptPtr += 4;
}
2020-08-21 08:36:48 +02:00
static void ContestAICmd_get_used_moves_effect(void)
2018-08-15 11:43:57 +02:00
{
2020-07-12 02:25:56 +02:00
u8 contestant = GetContestantIdByTurn(gAIScriptPtr[1]);
2020-08-21 08:36:48 +02:00
u8 round = gAIScriptPtr[2];
u16 move = eContest.moveHistory[round][contestant];
2018-08-15 11:43:57 +02:00
2019-04-02 06:35:57 +02:00
eContestAI.scriptResult = gContestMoves[move].effect;
2018-08-15 11:43:57 +02:00
gAIScriptPtr += 3;
}
2020-08-21 08:36:48 +02:00
static void ContestAICmd_if_used_moves_effect_less_than(void)
2018-08-15 11:43:57 +02:00
{
2020-08-21 08:36:48 +02:00
ContestAICmd_get_used_moves_effect();
2018-08-15 11:43:57 +02:00
2019-04-02 06:35:57 +02:00
if (eContestAI.scriptResult < gAIScriptPtr[0])
2018-08-15 11:43:57 +02:00
gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 1);
else
gAIScriptPtr += 5;
}
2020-08-21 08:36:48 +02:00
static void ContestAICmd_if_used_moves_effect_more_than(void)
2018-08-15 11:43:57 +02:00
{
2020-08-21 08:36:48 +02:00
ContestAICmd_get_used_moves_effect();
2018-08-15 11:43:57 +02:00
2019-04-02 06:35:57 +02:00
if (eContestAI.scriptResult > gAIScriptPtr[0])
2018-08-15 11:43:57 +02:00
gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 1);
else
gAIScriptPtr += 5;
}
2020-08-21 08:36:48 +02:00
static void ContestAICmd_if_used_moves_effect_eq(void)
2018-08-15 11:43:57 +02:00
{
2020-08-21 08:36:48 +02:00
ContestAICmd_get_used_moves_effect();
2018-08-15 11:43:57 +02:00
2019-04-02 06:35:57 +02:00
if (eContestAI.scriptResult == gAIScriptPtr[0])
2018-08-15 11:43:57 +02:00
gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 1);
else
gAIScriptPtr += 5;
}
2020-08-21 08:36:48 +02:00
static void ContestAICmd_if_used_moves_effect_not_eq(void)
2018-08-15 11:43:57 +02:00
{
2020-08-21 08:36:48 +02:00
ContestAICmd_get_used_moves_effect();
2018-08-15 11:43:57 +02:00
2019-04-02 06:35:57 +02:00
if (eContestAI.scriptResult != gAIScriptPtr[0])
2018-08-15 11:43:57 +02:00
gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 1);
else
gAIScriptPtr += 5;
}
2020-08-21 08:36:48 +02:00
static void ContestAICmd_get_used_moves_excitement(void)
2018-08-15 11:43:57 +02:00
{
2020-07-12 02:25:56 +02:00
u8 contestant = GetContestantIdByTurn(gAIScriptPtr[1]);
2020-08-21 08:36:48 +02:00
u8 round = gAIScriptPtr[2];
s8 result = eContest.excitementHistory[round][contestant];
2018-08-15 11:43:57 +02:00
2019-04-02 06:35:57 +02:00
eContestAI.scriptResult = result;
2018-08-15 11:43:57 +02:00
gAIScriptPtr += 3;
}
2020-08-21 08:36:48 +02:00
static void ContestAICmd_if_used_moves_excitement_less_than(void)
2018-08-15 11:43:57 +02:00
{
2020-08-21 08:36:48 +02:00
ContestAICmd_get_used_moves_excitement();
2018-08-15 11:43:57 +02:00
2019-04-02 06:35:57 +02:00
if (eContestAI.scriptResult < gAIScriptPtr[0])
2018-08-15 11:43:57 +02:00
gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 1);
else
gAIScriptPtr += 5;
}
2020-08-21 08:36:48 +02:00
static void ContestAICmd_if_used_moves_excitement_more_than(void)
2018-08-15 11:43:57 +02:00
{
2020-08-21 08:36:48 +02:00
ContestAICmd_get_used_moves_excitement();
2018-08-15 11:43:57 +02:00
2019-04-02 06:35:57 +02:00
if (eContestAI.scriptResult > gAIScriptPtr[0])
2018-08-15 11:43:57 +02:00
gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 1);
else
gAIScriptPtr += 5;
}
2020-08-21 08:36:48 +02:00
static void ContestAICmd_if_used_moves_excitement_eq(void)
2018-08-15 11:43:57 +02:00
{
2020-08-21 08:36:48 +02:00
ContestAICmd_get_used_moves_excitement();
2018-08-15 11:43:57 +02:00
2019-04-02 06:35:57 +02:00
if (eContestAI.scriptResult == gAIScriptPtr[0])
2018-08-15 11:43:57 +02:00
gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 1);
else
gAIScriptPtr += 5;
}
2020-08-21 08:36:48 +02:00
static void ContestAICmd_if_used_moves_excitement_not_eq(void)
2018-08-15 11:43:57 +02:00
{
2020-08-21 08:36:48 +02:00
ContestAICmd_get_used_moves_excitement();
2018-08-15 11:43:57 +02:00
2019-04-02 06:35:57 +02:00
if (eContestAI.scriptResult != gAIScriptPtr[0])
2018-08-15 11:43:57 +02:00
gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 1);
else
gAIScriptPtr += 5;
}
2020-08-21 08:36:48 +02:00
static void ContestAICmd_get_used_moves_effect_type(void)
2018-08-15 11:43:57 +02:00
{
2020-07-12 02:25:56 +02:00
u8 contestant = GetContestantIdByTurn(gAIScriptPtr[1]);
2020-08-21 08:36:48 +02:00
u8 round = gAIScriptPtr[2];
u16 move = eContest.moveHistory[round][contestant];
2018-08-15 11:43:57 +02:00
2019-04-02 06:35:57 +02:00
eContestAI.scriptResult = gContestEffects[gContestMoves[move].effect].effectType;
2018-08-15 11:43:57 +02:00
gAIScriptPtr += 3;
}
2020-08-21 08:36:48 +02:00
static void ContestAICmd_if_used_moves_effect_type_eq(void)
2018-08-15 11:43:57 +02:00
{
2020-08-21 08:36:48 +02:00
ContestAICmd_get_used_moves_effect_type();
2018-08-15 11:43:57 +02:00
2019-04-02 06:35:57 +02:00
if (eContestAI.scriptResult == gAIScriptPtr[0])
2018-08-15 11:43:57 +02:00
gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 1);
else
gAIScriptPtr += 5;
}
2020-08-21 08:36:48 +02:00
static void ContestAICmd_if_used_moves_effect_type_not_eq(void)
2018-08-15 11:43:57 +02:00
{
2020-08-21 08:36:48 +02:00
ContestAICmd_get_used_moves_effect_type();
2018-08-15 11:43:57 +02:00
2019-04-02 06:35:57 +02:00
if (eContestAI.scriptResult != gAIScriptPtr[0])
2018-08-15 11:43:57 +02:00
gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 1);
else
gAIScriptPtr += 5;
}
2020-08-21 08:36:48 +02:00
static void ContestAICmd_save_result(void)
2018-08-15 11:43:57 +02:00
{
2020-08-21 08:36:48 +02:00
eContestAI.vars[gAIScriptPtr[1]] = eContestAI.scriptResult;
2018-08-15 11:43:57 +02:00
gAIScriptPtr += 2;
}
2020-08-21 08:36:48 +02:00
static void ContestAICmd_setvar(void)
2018-08-15 11:43:57 +02:00
{
2020-08-21 08:36:48 +02:00
eContestAI.vars[gAIScriptPtr[1]] = T1_READ_16(gAIScriptPtr + 2);
2018-08-15 11:43:57 +02:00
gAIScriptPtr += 4;
}
2020-08-21 08:36:48 +02:00
static void ContestAICmd_add(void)
2018-08-15 11:43:57 +02:00
{
// wtf? shouldn't T1_READ_16 work here? why the signed 8 load by gAIScriptPtr[2]?
2020-08-21 08:36:48 +02:00
eContestAI.vars[gAIScriptPtr[1]] += ((s8)gAIScriptPtr[2] | gAIScriptPtr[3] << 8);
2018-08-15 11:43:57 +02:00
gAIScriptPtr += 4;
}
2020-08-21 08:36:48 +02:00
static void ContestAICmd_addvar(void)
2018-08-15 11:43:57 +02:00
{
2020-08-21 08:36:48 +02:00
eContestAI.vars[gAIScriptPtr[1]] += eContestAI.vars[gAIScriptPtr[2]];
2018-08-15 11:43:57 +02:00
gAIScriptPtr += 3;
}
2020-08-21 08:36:48 +02:00
static void ContestAICmd_addvar_duplicate(void)
2018-08-15 11:43:57 +02:00
{
2020-08-21 08:36:48 +02:00
eContestAI.vars[gAIScriptPtr[1]] += eContestAI.vars[gAIScriptPtr[2]];
2018-08-15 11:43:57 +02:00
gAIScriptPtr += 3;
}
2020-08-21 08:36:48 +02:00
static void ContestAICmd_if_less_than(void)
2018-08-15 11:43:57 +02:00
{
2020-08-21 08:36:48 +02:00
if (eContestAI.vars[gAIScriptPtr[1]] < T1_READ_16(gAIScriptPtr + 2))
2018-08-15 11:43:57 +02:00
gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 4);
else
gAIScriptPtr += 8;
}
2020-08-21 08:36:48 +02:00
static void ContestAICmd_if_greater_than(void)
2018-08-15 11:43:57 +02:00
{
2020-08-21 08:36:48 +02:00
if (eContestAI.vars[gAIScriptPtr[1]] > T1_READ_16(gAIScriptPtr + 2))
2018-08-15 11:43:57 +02:00
gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 4);
else
gAIScriptPtr += 8;
}
2020-08-21 08:36:48 +02:00
static void ContestAICmd_if_eq(void)
2018-08-15 11:43:57 +02:00
{
2020-08-21 08:36:48 +02:00
if (eContestAI.vars[gAIScriptPtr[1]] == T1_READ_16(gAIScriptPtr + 2))
2018-08-15 11:43:57 +02:00
gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 4);
else
gAIScriptPtr += 8;
}
2020-08-21 08:36:48 +02:00
static void ContestAICmd_if_not_eq(void)
2018-08-15 11:43:57 +02:00
{
2020-08-21 08:36:48 +02:00
if (eContestAI.vars[gAIScriptPtr[1]] != T1_READ_16(gAIScriptPtr + 2))
2018-08-15 11:43:57 +02:00
gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 4);
else
gAIScriptPtr += 8;
}
2020-08-21 08:36:48 +02:00
static void ContestAICmd_if_less_than_var(void)
2018-08-15 11:43:57 +02:00
{
2020-08-21 08:36:48 +02:00
if (eContestAI.vars[gAIScriptPtr[1]] < (eContestAI.vars[gAIScriptPtr[2]]))
2018-08-15 11:43:57 +02:00
gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 3);
else
gAIScriptPtr += 7;
}
2020-08-21 08:36:48 +02:00
static void ContestAICmd_if_greater_than_var(void)
2018-08-15 11:43:57 +02:00
{
2020-08-21 08:36:48 +02:00
if (eContestAI.vars[gAIScriptPtr[1]] > (eContestAI.vars[gAIScriptPtr[2]]))
2018-08-15 11:43:57 +02:00
gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 3);
else
gAIScriptPtr += 7;
}
2020-08-21 08:36:48 +02:00
static void ContestAICmd_if_eq_var(void)
2018-08-15 11:43:57 +02:00
{
2020-08-21 08:36:48 +02:00
if (eContestAI.vars[gAIScriptPtr[1]] == (eContestAI.vars[gAIScriptPtr[2]]))
2018-08-15 11:43:57 +02:00
gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 3);
else
gAIScriptPtr += 7;
}
2020-08-21 08:36:48 +02:00
static void ContestAICmd_if_not_eq_var(void)
2018-08-15 11:43:57 +02:00
{
2020-08-21 08:36:48 +02:00
if (eContestAI.vars[gAIScriptPtr[1]] != (eContestAI.vars[gAIScriptPtr[2]]))
2018-08-15 11:43:57 +02:00
gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 3);
else
gAIScriptPtr += 7;
}
2020-08-21 08:36:48 +02:00
// UB: Should just be comparing to gAIScriptPtr[1] in the functions below
2020-08-21 20:47:55 +02:00
// The values passed via gAIScriptPtr[1] range from 0-255
// and vars is an s16[3], so this goes way out of bounds
2020-08-21 08:36:48 +02:00
static void ContestAICmd_if_random_less_than(void)
2018-08-15 11:43:57 +02:00
{
2020-08-21 08:36:48 +02:00
#ifndef UBFIX
if ((Random() & 0xFF) < eContestAI.vars[gAIScriptPtr[1]])
#else
if ((Random() & 0xFF) < gAIScriptPtr[1])
#endif
2018-08-15 11:43:57 +02:00
gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 2);
else
gAIScriptPtr += 6;
}
2020-08-21 08:36:48 +02:00
static void ContestAICmd_if_random_greater_than(void)
2018-08-15 11:43:57 +02:00
{
2020-08-21 08:36:48 +02:00
#ifndef UBFIX
if (((Random()) & 0xFF) > eContestAI.vars[gAIScriptPtr[1]])
#else
if (((Random()) & 0xFF) > gAIScriptPtr[1])
#endif
2018-08-15 11:43:57 +02:00
gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 2);
else
gAIScriptPtr += 6;
}
2020-08-21 08:36:48 +02:00
static void ContestAICmd_goto(void)
2018-08-15 11:43:57 +02:00
{
gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 1);
}
2019-04-02 04:09:14 +02:00
static void ContestAICmd_call(void)
2018-08-15 11:43:57 +02:00
{
AIStackPushVar(gAIScriptPtr + 5);
gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 1);
}
2019-04-02 04:09:14 +02:00
static void ContestAICmd_end(void)
2018-08-15 11:43:57 +02:00
{
if (!AIStackPop())
2019-04-02 06:35:57 +02:00
eContestAI.aiAction |= 1;
2018-08-15 11:43:57 +02:00
}
static void AIStackPushVar(const u8 *ptr)
{
2019-04-02 06:35:57 +02:00
eContestAI.stack[eContestAI.stackSize++] = ptr;
2018-08-15 11:43:57 +02:00
}
static bool8 AIStackPop(void)
{
2019-04-02 06:35:57 +02:00
if (eContestAI.stackSize != 0)
2018-08-15 11:43:57 +02:00
{
2019-04-02 06:35:57 +02:00
--eContestAI.stackSize;
gAIScriptPtr = eContestAI.stack[eContestAI.stackSize];
2018-08-15 11:43:57 +02:00
return TRUE;
}
else
{
return FALSE;
}
}
2019-04-02 04:09:14 +02:00
static void ContestAICmd_check_user_has_exciting_move(void)
2018-08-15 11:43:57 +02:00
{
int result = 0;
int i;
for (i = 0; i < MAX_MON_MOVES; i++)
2018-08-15 11:43:57 +02:00
{
2019-04-02 06:35:57 +02:00
if (gContestMons[eContestAI.contestantId].moves[i])
2018-08-15 11:43:57 +02:00
{
2019-04-02 06:35:57 +02:00
if (Contest_GetMoveExcitement(gContestMons[eContestAI.contestantId].moves[i]) == 1)
2018-08-15 11:43:57 +02:00
{
result = 1;
break;
}
}
}
2019-04-02 06:35:57 +02:00
eContestAI.scriptResult = result;
2018-08-15 11:43:57 +02:00
gAIScriptPtr += 1;
}
2019-04-02 04:09:14 +02:00
static void ContestAICmd_if_user_has_exciting_move(void)
2018-08-15 11:43:57 +02:00
{
2019-04-02 04:09:14 +02:00
ContestAICmd_check_user_has_exciting_move();
2018-08-15 11:43:57 +02:00
2020-08-21 08:36:48 +02:00
if (eContestAI.scriptResult)
2018-08-15 11:43:57 +02:00
gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 0);
else
gAIScriptPtr += 4;
}
2019-04-02 04:09:14 +02:00
static void ContestAICmd_if_user_doesnt_have_exciting_move(void)
2018-08-15 11:43:57 +02:00
{
2019-04-02 04:09:14 +02:00
ContestAICmd_check_user_has_exciting_move();
2018-08-15 11:43:57 +02:00
2020-08-21 08:36:48 +02:00
if (!eContestAI.scriptResult)
2018-08-15 11:43:57 +02:00
gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 0);
else
gAIScriptPtr += 4;
}
2020-08-21 20:47:55 +02:00
// BUG: This is checking if the user has a specific move, but when it's used in the AI script
// they're checking for an effect. Checking for a specific effect would make more sense,
// but given that effects are normally read as a single byte and this reads 2 bytes, it
// seems reading a move was intended and the AI script is using it incorrectly.
2020-12-13 05:28:01 +01:00
// The fix below aligns the function with how it's used by the script, rather than the apparent
// intention of its usage
2020-08-21 08:36:48 +02:00
static void ContestAICmd_check_user_has_move(void)
2018-08-15 11:43:57 +02:00
{
2020-08-21 08:36:48 +02:00
int hasMove = FALSE;
2018-08-15 11:43:57 +02:00
int i;
2020-08-21 08:36:48 +02:00
u16 targetMove = T1_READ_16(gAIScriptPtr + 1);
2018-08-15 11:43:57 +02:00
for (i = 0; i < MAX_MON_MOVES; i++)
2018-08-15 11:43:57 +02:00
{
2020-12-13 05:28:01 +01:00
#ifdef BUGFIX
u16 move = gContestMoves[gContestMons[eContestAI.contestantId].moves[i]].effect;
#else
2019-04-02 06:35:57 +02:00
u16 move = gContestMons[eContestAI.contestantId].moves[i];
2020-12-13 05:28:01 +01:00
#endif
2020-08-21 08:36:48 +02:00
if (move == targetMove)
2018-08-15 11:43:57 +02:00
{
2020-08-21 08:36:48 +02:00
hasMove = TRUE;
2018-08-15 11:43:57 +02:00
break;
}
}
2020-08-21 08:36:48 +02:00
eContestAI.scriptResult = hasMove;
2018-08-15 11:43:57 +02:00
gAIScriptPtr += 3;
}
2020-08-21 08:36:48 +02:00
static void ContestAICmd_if_user_has_move(void)
2018-08-15 11:43:57 +02:00
{
2020-08-21 08:36:48 +02:00
ContestAICmd_check_user_has_move();
2018-08-15 11:43:57 +02:00
2020-08-21 08:36:48 +02:00
if (eContestAI.scriptResult)
2018-08-15 11:43:57 +02:00
gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 0);
else
gAIScriptPtr += 4;
}
2020-08-21 20:47:55 +02:00
static void ContestAICmd_if_user_doesnt_have_move(void)
2018-08-15 11:43:57 +02:00
{
2020-08-21 08:36:48 +02:00
ContestAICmd_check_user_has_move();
2018-08-15 11:43:57 +02:00
2020-08-21 08:36:48 +02:00
if (!eContestAI.scriptResult)
2018-08-15 11:43:57 +02:00
gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 0);
else
gAIScriptPtr += 4;
}