diff options
37 files changed, 2162 insertions, 1851 deletions
diff --git a/asm/macros/contest_ai_script.inc b/asm/macros/contest_ai_script.inc index 763c3d1c4..9ab7184c3 100644 --- a/asm/macros/contest_ai_script.inc +++ b/asm/macros/contest_ai_script.inc @@ -1,6 +1,8 @@ +@ A large number of the Contest AI commands go unused, so their corresponding macros in this file are similarly unused + @ Add a positive/negative value to the score of the move being evaluated. - .macro score score + .macro score score:req .byte 0x00 .byte \score .endm @@ -9,36 +11,36 @@ .byte 0x01 .endm - .macro if_appeal_num_less_than param, addr + .macro if_appeal_num_less_than num:req, destination:req .byte 0x02 - .byte \param - .4byte \addr + .byte \num + .4byte \destination .endm - .macro if_appeal_num_more_than param, addr + .macro if_appeal_num_more_than num:req, destination:req .byte 0x03 - .byte \param - .4byte \addr + .byte \num + .4byte \destination .endm - .macro if_appeal_num_eq param, addr + .macro if_appeal_num_eq num:req, destination:req .byte 0x04 - .byte \param - .4byte \addr + .byte \num + .4byte \destination .endm - .macro if_appeal_num_not_eq param, addr + .macro if_appeal_num_not_eq num:req, destination:req .byte 0x05 - .byte \param - .4byte \addr + .byte \num + .4byte \destination .endm - .macro if_last_appeal addr:req - if_appeal_num_eq CONTEST_LAST_APPEAL, \addr + .macro if_last_appeal destination:req + if_appeal_num_eq CONTEST_LAST_APPEAL, \destination .endm - .macro if_not_last_appeal addr:req - if_appeal_num_not_eq CONTEST_LAST_APPEAL, \addr + .macro if_not_last_appeal destination:req + if_appeal_num_not_eq CONTEST_LAST_APPEAL, \destination .endm @ audience excitement @@ -47,28 +49,28 @@ .byte 0x06 .endm - .macro if_excitement_less_than param, addr + .macro if_excitement_less_than num:req, destination:req .byte 0x07 - .byte \param - .4byte \addr + .byte \num + .4byte \destination .endm - .macro if_excitement_more_than param, addr + .macro if_excitement_more_than num:req, destination:req .byte 0x08 - .byte \param - .4byte \addr + .byte \num + .4byte \destination .endm - .macro if_excitement_eq param, addr + .macro if_excitement_eq num:req, destination:req .byte 0x09 - .byte \param - .4byte \addr + .byte \num + .4byte \destination .endm - .macro if_excitement_not_eq param, addr + .macro if_excitement_not_eq num:req, destination:req .byte 0x0A - .byte \param - .4byte \addr + .byte \num + .4byte \destination .endm @ the order that the user goes in the current appeal @@ -77,28 +79,28 @@ .byte 0x0B .endm - .macro if_user_order_less_than param addr + .macro if_user_order_less_than num:req, destination:req .byte 0x0C - .byte \param - .4byte \addr + .byte \num + .4byte \destination .endm - .macro if_user_order_more_than param addr + .macro if_user_order_more_than num:req, destination:req .byte 0x0D - .byte \param - .4byte \addr + .byte \num + .4byte \destination .endm - .macro if_user_order_eq param addr + .macro if_user_order_eq num:req, destination:req .byte 0x0E - .byte \param - .4byte \addr + .byte \num + .4byte \destination .endm - .macro if_user_order_not_eq param addr + .macro if_user_order_not_eq num:req, destination:req .byte 0x0F - .byte \param - .4byte \addr + .byte \num + .4byte \destination .endm @ user condition @@ -107,40 +109,89 @@ .byte 0x10 .endm - .macro if_user_condition_less_than param, addr + .macro if_user_condition_less_than num:req, destination:req .byte 0x11 - .byte \param - .4byte \addr + .byte \num + .4byte \destination .endm - .macro if_user_condition_more_than param, addr + .macro if_user_condition_more_than num:req, destination:req .byte 0x12 - .byte \param - .4byte \addr + .byte \num + .4byte \destination .endm - .macro if_user_condition_eq param, addr + .macro if_user_condition_eq num:req, destination:req .byte 0x13 - .byte \param - .4byte \addr + .byte \num + .4byte \destination .endm - .macro if_user_condition_not_eq param, addr + .macro if_user_condition_not_eq num:req, destination:req .byte 0x14 - .byte \param - .4byte \addr + .byte \num + .4byte \destination + .endm + +@ appeal points + + .macro get_point_total + .byte 0x15 + .endm + + .macro if_points_less_than num:req, destination:req + .byte 0x16 + .byte \num + .4byte \destination + .endm + + .macro if_points_more_than num:req, destination:req + .byte 0x17 + .byte \num + .4byte \destination + .endm + + .macro if_points_eq num:req, destination:req + .byte 0x18 + .byte \num + .4byte \destination + .endm + + .macro if_points_not_eq num:req, destination:req + .byte 0x19 + .byte \num + .4byte \destination + .endm + +@ preliminary (pre-appeal) judging points + + .macro get_preliminary_points + .byte 0x1A + .endm + + .macro if_preliminary_points_less_than num:req, destination:req + .byte 0x1B + .byte \num + .4byte \destination + .endm + + .macro if_preliminary_points_more_than num:req, destination:req + .byte 0x1C + .byte \num + .4byte \destination + .endm + + .macro if_preliminary_points_eq num:req, destination:req + .byte 0x1D + .byte \num + .4byte \destination .endm -@ 15 -@ 16 -@ 17 -@ 18 -@ 19 -@ 1A -@ 1B -@ 1C -@ 1D -@ 1E + .macro if_preliminary_points_not_eq num:req, destination:req + .byte 0x1E + .byte \num + .4byte \destination + .endm @ contest type @@ -148,16 +199,16 @@ .byte 0x1F .endm - .macro if_contest_type_eq param, addr + .macro if_contest_type_eq type:req, destination:req .byte 0x20 - .byte \param - .4byte \addr + .byte \type + .4byte \destination .endm - .macro if_contest_type_not_eq param, addr + .macro if_contest_type_not_eq type:req, destination:req .byte 0x21 - .byte \param - .4byte \addr + .byte \type + .4byte \destination .endm @ move excitement (change in excitement due to move) @@ -166,28 +217,28 @@ .byte 0x22 .endm - .macro if_move_excitement_less_than param, addr + .macro if_move_excitement_less_than num:req, destination:req .byte 0x23 - .byte \param - .4byte \addr + .byte \num + .4byte \destination .endm - .macro if_move_excitement_more_than param, addr + .macro if_move_excitement_more_than num:req, destination:req .byte 0x24 - .byte \param - .4byte \addr + .byte \num + .4byte \destination .endm - .macro if_move_excitement_eq param, addr + .macro if_move_excitement_eq num:req, destination:req .byte 0x25 - .byte \param - .4byte \addr + .byte \num + .4byte \destination .endm - .macro if_move_excitement_not_eq param, addr + .macro if_move_excitement_not_eq num:req, destination:req .byte 0x26 - .byte \param - .4byte \addr + .byte \num + .4byte \destination .endm @ move effect @@ -196,16 +247,16 @@ .byte 0x27 .endm - .macro if_effect_eq param, addr + .macro if_effect_eq effect:req, destination:req .byte 0x28 - .byte \param - .4byte \addr + .byte \effect + .4byte \destination .endm - .macro if_effect_not_eq param, addr + .macro if_effect_not_eq effect:req, destination:req .byte 0x29 - .byte \param - .4byte \addr + .byte \effect + .4byte \destination .endm @ move effect type @@ -214,16 +265,16 @@ .byte 0x2A .endm - .macro if_effect_type_eq param, addr + .macro if_effect_type_eq type:req, destination:req .byte 0x2B - .byte \param - .4byte \addr + .byte \type + .4byte \destination .endm - .macro if_effect_type_not_eq param, addr + .macro if_effect_type_not_eq type:req, destination:req .byte 0x2C - .byte \param - .4byte \addr + .byte \type + .4byte \destination .endm @ whether the current move is the most appealing in the user's moveset @@ -232,23 +283,81 @@ .byte 0x2D .endm - .macro if_most_appealing_move addr + .macro if_most_appealing_move destination:req .byte 0x2E - .4byte \addr - .endm - -@ 2F -@ 30 -@ 31 -@ 32 -@ 33 -@ 34 -@ 35 -@ 36 -@ 37 -@ 38 -@ 39 -@ 3A + .4byte \destination + .endm + +@ whether the current move is the most jamming in the user's moveset + + .macro check_most_jamming_move + .byte 0x2F + .endm + + .macro if_most_jamming_move destination:req + .byte 0x30 + .4bye \destination + .endm + +@ number of hearts the current move's appeal would provide + + .macro get_num_move_hearts + .byte 0x31 + .endm + + .macro if_num_move_hearts_less_than num:req, destination:req + .byte 0x32 + .byte \num + .4byte \destination + .endm + + .macro if_num_move_hearts_more_than num:req, destination:req + .byte 0x33 + .byte \num + .4byte \destination + .endm + + .macro if_num_move_hearts_eq num:req, destination:req + .byte 0x34 + .byte \num + .4byte \destination + .endm + + .macro if_num_move_hearts_not_eq num:req, destination:req + .byte 0x35 + .byte \num + .4byte \destination + .endm + +@ number of hearts the current move's jam would remove + + .macro get_num_move_jam_hearts + .byte 0x36 + .endm + + .macro if_num_move_jam_hearts_less_than num:req, destination:req + .byte 0x37 + .byte \num + .4byte \destination + .endm + + .macro if_num_move_jam_hearts_more_than num:req, destination:req + .byte 0x38 + .byte \num + .4byte \destination + .endm + + .macro if_num_move_jam_hearts_eq num:req, destination:req + .byte 0x39 + .byte \num + .4byte \destination + .endm + + .macro if_num_move_jam_hearts_not_eq num:req, destination:req + .byte 0x3A + .byte \num + .4byte \destination + .endm @ number of times current move has been used @@ -256,28 +365,28 @@ .byte 0x3B .endm - .macro if_move_used_count_less_than param, addr + .macro if_move_used_count_less_than num:req, destination:req .byte 0x3C - .byte \param - .4byte \addr + .byte \num + .4byte \destination .endm - .macro if_move_used_count_more_than param, addr + .macro if_move_used_count_more_than num:req, destination:req .byte 0x3D - .byte \param - .4byte \addr + .byte \num + .4byte \destination .endm - .macro if_move_used_count_eq param, addr + .macro if_move_used_count_eq num:req, destination:req .byte 0x3E - .byte \param - .4byte \addr + .byte \num + .4byte \destination .endm - .macro if_move_used_count_not_eq param, addr + .macro if_move_used_count_not_eq num:req, destination:req .byte 0x3F - .byte \param - .4byte \addr + .byte \num + .4byte \destination .endm @ whether the current move is a combo starter (with another move in the moveset) @@ -286,14 +395,14 @@ .byte 0x40 .endm - .macro if_combo_starter addr + .macro if_combo_starter destination:req .byte 0x41 - .4byte \addr + .4byte \destination .endm - .macro if_not_combo_starter addr + .macro if_not_combo_starter destination:req .byte 0x42 - .4byte \addr + .4byte \destination .endm @ whether the current move is a combo finisher (with another move in the moveset) @@ -302,14 +411,14 @@ .byte 0x43 .endm - .macro if_combo_finisher addr + .macro if_combo_finisher destination:req .byte 0x44 - .4byte \addr + .4byte \destination .endm - .macro if_not_combo_finisher addr + .macro if_not_combo_finisher destination:req .byte 0x45 - .4byte \addr + .4byte \destination .endm @ whether the current move would finish a combo @@ -318,170 +427,411 @@ .byte 0x46 .endm - .macro if_would_finish_combo addr + .macro if_would_finish_combo destination:req .byte 0x47 - .4byte \addr + .4byte \destination .endm - .macro if_would_not_finish_combo addr + .macro if_would_not_finish_combo destination:req .byte 0x48 - .4byte \addr + .4byte \destination .endm @ condition of mon (indexed by order) - .macro get_condition mon + .macro get_condition mon:req .byte 0x49 .byte \mon .endm - .macro if_condition_less_than mon, value, addr + .macro if_condition_less_than mon:req, num:req destination:req .byte 0x4A .byte \mon - .byte \value - .4byte \addr + .byte \num + .4byte \destination .endm - .macro if_condition_more_than mon, value, addr + .macro if_condition_more_than mon:req, num:req, destination:req .byte 0x4B .byte \mon - .byte \value - .4byte \addr + .byte \num + .4byte \destination .endm - .macro if_condition_eq mon, value, addr + .macro if_condition_eq mon:req, num:req, destination:req .byte 0x4C .byte \mon - .byte \value - .4byte \addr + .byte \num + .4byte \destination .endm - .macro if_condition_not_eq mon, value, addr + .macro if_condition_not_eq mon:req, num:req, destination:req .byte 0x4D .byte \mon - .byte \value - .4byte \addr + .byte \num + .4byte \destination .endm @ whether the mon used a combo starter move @ Even though this value is always 1 or 0 (i.e. TRUE/FALSE), @ there are less-than and greater-than comparison operations for some reason. - .macro get_used_combo_starter mon + .macro get_used_combo_starter mon:req .byte 0x4E .byte \mon .endm - .macro if_used_combo_starter_less_than mon, value, addr + .macro if_used_combo_starter_less_than mon:req, num:req, destination:req .byte 0x4F .byte \mon - .byte \value - .4byte \addr + .byte \num + .4byte \destination .endm - .macro if_used_combo_starter_more_than mon, value, addr + .macro if_used_combo_starter_more_than mon:req, num:req, destination:req .byte 0x50 .byte \mon - .byte \value - .4byte \addr + .byte \num + .4byte \destination .endm - .macro if_used_combo_starter_eq mon, value, addr + .macro if_used_combo_starter_eq mon:req, num:req, destination:req .byte 0x51 .byte \mon - .byte \value - .4byte \addr + .byte \num + .4byte \destination .endm - .macro if_used_combo_starter_not_eq mon, value, addr + .macro if_used_combo_starter_not_eq mon:req, num:req, destination:req .byte 0x52 .byte \mon - .byte \value - .4byte \addr + .byte \num + .4byte \destination + .endm + + .macro if_used_combo_starter mon:req, destination:req + if_used_combo_starter_eq \mon, TRUE, \destination + .endm + + .macro if_not_used_combo_starter mon:req, destination:req + if_used_combo_starter_eq \mon, FALSE, \destination .endm @ whether the mon can make an appeal - .macro check_can_participate mon + .macro check_can_participate mon:req .byte 0x53 .byte \mon .endm - .macro if_can_participate mon, addr + .macro if_can_participate mon:req, destination:req .byte 0x54 .byte \mon - .4byte \addr + .4byte \destination .endm - .macro if_cannot_participate mon, addr + .macro if_cannot_participate mon:req, destination:req .byte 0x55 .byte \mon - .4byte \addr + .4byte \destination + .endm + +@ whether the mon just completed a combo + + .macro get_completed_combo mon:req + .byte 0x56 + .byte \mon + .4byte \destination .endm -@ 56 -@ 57 + .macro if_completed_combo mon:req, destination:req + .byte 0x57 + .byte \mon + .4byte \destination + .endm - .macro contest_58 param addr + .macro if_not_completed_combo mon:req destination:req .byte 0x58 - .byte \param - .4byte \addr - .endm - -@ 59 -@ 5A -@ 5B -@ 5C -@ 5D -@ 5E -@ 5F -@ 60 -@ 61 -@ 62 -@ 63 -@ 64 -@ 65 -@ 66 -@ 67 -@ 68 -@ 69 -@ 6A -@ 6B -@ 6C -@ 6D -@ 6E -@ 6F -@ 70 -@ 71 -@ 72 -@ 73 -@ 74 -@ 75 -@ 76 -@ 77 -@ 78 -@ 79 -@ 7A -@ 7B -@ 7C - - .macro if_random param addr + .byte \mon + .4byte \destination + .endm + +@ comparing appeal points to another mon + + .macro get_points_diff mon:req + .byte 0x59 + .byte \mon + .endm + + .macro if_points_more_than_mon mon:req, destination:req + .byte 0x5A + .byte \mon + .4byte \destination + .endm + + .macro if_points_less_than_mon mon:req, destination:req + .byte 0x5B + .byte \mon + .4byte \destination + .endm + + .macro if_points_eq_mon mon:req, destination:req + .byte 0x5C + .byte \mon + .4byte \destination + .endm + + .macro if_points_not_eq_mon mon:req, destination:req + .byte 0x5D + .byte \mon + .4byte \destination + .endm + +@ comparing preliminary judging points to another mon + + .macro get_preliminary_points_diff mon:req + .byte 0x5E + .byte \mon + .endm + + .macro if_preliminary_points_more_than_mon mon:req, destination:req + .byte 0x5F + .byte \mon + .4byte \destination + .endm + + .macro if_preliminary_points_less_than_mon mon:req, destination:req + .byte 0x60 + .byte \mon + .4byte \destination + .endm + + .macro if_preliminary_points_eq_mon mon:req, destination:req + .byte 0x61 + .byte \mon + .4byte \destination + .endm + + .macro if_preliminary_points_not_eq_mon mon:req, destination:req + .byte 0x62 + .byte \mon + .4byte \destination + .endm + +@ checking move history for move effect + + .macro get_used_moves_effect mon:req, round:req + .byte 0x63 + .byte \mon + .byte \round + .endm + + .macro if_used_moves_effect_less_than mon:req, round:req, effect:req, destination:req + .byte 0x64 + .byte \mon + .byte \round + .byte \effect + .4byte \destination + .endm + + .macro if_used_moves_effect_more_than mon:req, round:req, effect:req, destination:req + .byte 0x65 + .byte \mon + .byte \round + .byte \effect + .4byte \destination + .endm + + .macro if_used_moves_effect_eq mon:req, round:req, effect:req, destination:req + .byte 0x66 + .byte \mon + .byte \round + .byte \effect + .4byte \destination + .endm + + .macro if_used_moves_effect_not_eq mon:req, round:req, effect:req, destination:req + .byte 0x67 + .byte \mon + .byte \round + .byte \effect + .4byte \destination + .endm + +@ checking move history for excitement + + .macro get_used_moves_excitement mon:req, round:req + .byte 0x68 + .byte \mon + .byte \round + .endm + + .macro if_used_moves_excitement_less_than mon:req, round:req, num:req, destination:req + .byte 0x69 + .byte \mon + .byte \round + .byte \num + .4byte \destination + .endm + + .macro if_used_moves_excitement_more_than mon:req, round:req, num:req, destination:req + .byte 0x6A + .byte \mon + .byte \round + .byte \num + .4byte \destination + .endm + + .macro if_used_moves_excitement_eq mon:req, round:req, num:req, destination:req + .byte 0x6B + .byte \mon + .byte \round + .byte \num + .4byte \destination + .endm + + .macro if_used_moves_excitement_not_eq mon:req, round:req, num:req, destination:req + .byte 0x6C + .byte \mon + .byte \round + .byte \num + .4byte \destination + .endm + +@ checking move history for effect type + + .macro get_used_moves_effect_type mon:req, round:req + .byte 0x6D + .byte \mon + .byte \round + .endm + + .macro if_used_moves_effect_type_eq mon:req, round:req, type:req, destination:req + .byte 0x6E + .byte \mon + .byte \round + .byte \type + .4byte \destination + .endm + + .macro if_used_moves_effect_type_not_eq mon:req, round:req, type:req, destination:req + .byte 0x6F + .byte \mon + .byte \round + .byte \type + .4byte \destination + .endm + +@ generic commands + + .macro save_result varId:req + .byte 0x70 + .byte \varId + .endm + + .macro setvar varId:req, num:req + .byte 0x71 + .byte \varId + .2byte \num + .endm + + .macro add varId:req, num:req + .byte 0x72 + .byte \varId + .2byte \num + .endm + + .macro addvar varId1:req, varId2:req + .byte 0x73 + .byte \varId1 + .byte \varId2 + .endm + + @ Duplicate of above + .macro addvar_duplicate varId1:req, varId2:req + .byte 0x74 + .byte \varId1 + .byte \varId2 + .endm + + .macro if_less_than varId:req, num:req, destination:req + .byte 0x75 + .byte \varId + .2byte \num + .4byte \destination + .endm + + .macro if_greater_than varId:req, num:req, destination:req + .byte 0x76 + .byte \varId + .2byte \num + .4byte \destination + .endm + + .macro if_eq varId:req, num:req, destination:req + .byte 0x77 + .byte \varId + .2byte \num + .4byte \destination + .endm + + .macro if_not_eq varId:req, num:req, destination:req + .byte 0x78 + .byte \varId + .2byte \num + .4byte \destination + .endm + + .macro if_less_than_var varId1:req, varId2:req, destination:req + .byte 0x79 + .byte \varId1 + .byte \varId2 + .4byte \destination + .endm + + .macro if_greater_than_var varId1:req, varId2:req, destination:req + .byte 0x7A + .byte \varId1 + .byte \varId2 + .4byte \destination + .endm + + .macro if_eq_var varId1:req, varId2:req, destination:req + .byte 0x7B + .byte \varId1 + .byte \varId2 + .4byte \destination + .endm + + .macro if_not_eq_var varId1:req, varId2:req, destination:req + .byte 0x7C + .byte \varId1 + .byte \varId2 + .4byte \destination + .endm + + @ NOTE: The random commands are broken (see ContestAICmd_if_random_less_than) + .macro if_random_less_than num:req, destination:req .byte 0x7D - .byte \param - .4byte \addr + .byte \num + .4byte \destination .endm -@ 7E + .macro if_random_greater_than num:req, destination:req + .byte 0x7E + .byte \num + .4byte \destination + .endm - .macro jump addr + .macro goto destination:req .byte 0x7F - .4byte \addr + .4byte \destination .endm - .macro call addr + .macro call destination:req .byte 0x80 - .4byte \addr + .4byte \destination .endm .macro end @@ -492,21 +842,30 @@ .byte 0x82 .endm - .macro if_user_has_exciting_move addr + .macro if_user_has_exciting_move destination:req .byte 0x83 - .4byte \addr + .4byte \destination .endm - .macro if_user_doesnt_have_exciting_move addr + .macro if_user_doesnt_have_exciting_move destination:req .byte 0x84 - .4byte \addr + .4byte \destination .endm -@ 85 -@ 86 + @ This is used incorrectly to check for an effect; see ContestAICmd_check_user_has_move + .macro check_user_has_move move:req + .byte 0x85 + .2byte \move + .endm + + .macro if_user_has_move move:req, destination:req + .byte 0x86 + .2byte \move + .4byte \destination + .endm - .macro if_effect_in_user_moveset param addr + .macro if_user_doesnt_have_move move:req, destination:req .byte 0x87 - .2byte \param - .4byte \addr + .2byte \move + .4byte \destination .endm diff --git a/data/contest_ai_scripts.s b/data/contest_ai_scripts.s index 4a0bed817..e47ccb4c8 100644 --- a/data/contest_ai_scripts.s +++ b/data/contest_ai_scripts.s @@ -13,848 +13,889 @@ enum MON_4 .align 2 -gContestAIChecks:: @ 82DE350 - .4byte AI_CheckForBadMove @ CONTEST_AI_CHECK_BAD_MOVE - .4byte AI_CheckForCombo @ CONTEST_AI_CHECK_COMBO +gContestAI_ScriptsTable:: @ 82DE350 + .4byte AI_CheckBadMove @ CONTEST_AI_CHECK_BAD_MOVE + .4byte AI_CheckCombo @ CONTEST_AI_CHECK_COMBO .4byte AI_CheckBoring @ CONTEST_AI_CHECK_BORING .4byte AI_CheckExcitement @ CONTEST_AI_CHECK_EXCITEMENT .4byte AI_CheckOrder @ CONTEST_AI_CHECK_ORDER - .4byte AI_CheckForGoodMove @ CONTEST_AI_CHECK_GOOD_MOVE + .4byte AI_CheckGoodMove @ CONTEST_AI_CHECK_GOOD_MOVE .4byte AI_Erratic @ CONTEST_AI_ERRATIC - .4byte AI_Nothing // 0x00000080 - .4byte AI_Nothing // 0x00000100 - .4byte AI_Nothing // 0x00000200 - .4byte AI_Nothing // 0x00000400 - .4byte AI_Nothing // 0x00000800 - .4byte AI_Nothing // 0x00001000 - .4byte AI_Nothing // 0x00002000 - .4byte AI_Nothing // 0x00004000 - .4byte AI_Nothing // 0x00008000 - .4byte AI_Nothing // 0x00010000 - .4byte AI_Nothing // 0x00020000 - .4byte AI_Nothing // 0x00040000 - .4byte AI_Nothing // 0x00080000 - .4byte AI_Nothing // 0x00100000 - .4byte AI_Nothing // 0x00200000 - .4byte AI_Nothing // 0x00400000 - .4byte AI_Nothing // 0x00800000 - .4byte AI_Nothing // 0x01000000 - .4byte AI_Nothing // 0x02000000 - .4byte AI_Nothing // 0x04000000 - .4byte AI_Nothing // 0x08000000 - .4byte AI_Nothing // 0x10000000 - .4byte AI_Nothing // 0x20000000 - .4byte AI_Nothing // 0x40000000 - .4byte AI_Nothing // 0x80000000 - - -@ Unreferenced AI routine to encourage moves that improve condition on the first -@ appeal. Additionally, it checks the turn order of the user and the effect -@ type, but the code is buggy and doesn't affect the score. - if_appeal_num_not_eq 0, ContestUnreferenced_80 - if_effect_not_eq CONTEST_EFFECT_IMPROVE_CONDITION_PREVENT_NERVOUSNESS, ContestUnreferenced_80 + .4byte AI_Nothing @ CONTEST_AI_DUMMY_1 + .4byte AI_Nothing @ CONTEST_AI_DUMMY_2 + .4byte AI_Nothing @ CONTEST_AI_DUMMY_3 + .4byte AI_Nothing @ CONTEST_AI_DUMMY_4 + .4byte AI_Nothing @ CONTEST_AI_DUMMY_5 + .4byte AI_Nothing @ CONTEST_AI_DUMMY_6 + .4byte AI_Nothing @ CONTEST_AI_DUMMY_7 + .4byte AI_Nothing @ CONTEST_AI_DUMMY_8 + .4byte AI_Nothing @ CONTEST_AI_DUMMY_9 + .4byte AI_Nothing @ CONTEST_AI_DUMMY_10 + .4byte AI_Nothing @ CONTEST_AI_DUMMY_11 + .4byte AI_Nothing @ CONTEST_AI_DUMMY_12 + .4byte AI_Nothing @ CONTEST_AI_DUMMY_13 + .4byte AI_Nothing @ CONTEST_AI_DUMMY_14 + .4byte AI_Nothing @ CONTEST_AI_DUMMY_15 + .4byte AI_Nothing @ CONTEST_AI_DUMMY_16 + .4byte AI_Nothing @ CONTEST_AI_DUMMY_17 + .4byte AI_Nothing @ CONTEST_AI_DUMMY_18 + .4byte AI_Nothing @ CONTEST_AI_DUMMY_19 + .4byte AI_Nothing @ CONTEST_AI_DUMMY_20 + .4byte AI_Nothing @ CONTEST_AI_DUMMY_21 + .4byte AI_Nothing @ CONTEST_AI_DUMMY_22 + .4byte AI_Nothing @ CONTEST_AI_DUMMY_23 + .4byte AI_Nothing @ CONTEST_AI_DUMMY_24 + .4byte AI_Nothing @ CONTEST_AI_DUMMY_25 + + +@ Unused. Encourages improving condition on the 1st appeal, or startling mons if the users turn is later +AI_CheckTiming: + if_appeal_num_not_eq 0, AI_CheckTiming_SkipCondition + if_effect_not_eq CONTEST_EFFECT_IMPROVE_CONDITION_PREVENT_NERVOUSNESS, AI_CheckTiming_SkipCondition score +10 -ContestUnreferenced_80: - call ContestUnreferenced_0D - end -ContestUnreferenced_0D: - if_user_order_more_than MON_2, ContestUnreferenced_end - if_effect_type_not_eq 2, ContestUnreferenced_end - if_effect_type_not_eq 3, ContestUnreferenced_end - score +10 @ unreachable -ContestUnreferenced_end: - end - -@ Unreferenced AI routine that doesn't make much sense. - if_appeal_num_eq 0, ContestUnreferenced_0F_1 - if_appeal_num_eq 1, ContestUnreferenced_0F_2 - if_appeal_num_eq 2, ContestUnreferenced_0F_3 - if_appeal_num_eq 3, ContestUnreferenced_0F_4 - if_last_appeal ContestUnreferenced_0F_5 - end -ContestUnreferenced_0F_1: - if_user_order_not_eq MON_1, ContestUnreferenced_2B_1 - if_user_order_not_eq MON_2, ContestUnreferenced_2B_2 - if_user_order_not_eq MON_3, ContestUnreferenced_2B_1 - if_user_order_not_eq MON_4, ContestUnreferenced_2B_1 - end -ContestUnreferenced_2B_1: - if_effect_type_eq 1, ContestUnreferenced_score - end -ContestUnreferenced_2B_2: - if_effect_type_eq 1, ContestUnreferenced_score - end - if_effect_type_eq 1, ContestUnreferenced_score - end -ContestUnreferenced_0F_2: - if_user_order_not_eq MON_1, ContestUnreferenced_2B_1 - if_user_order_not_eq MON_2, ContestUnreferenced_2B_1 - if_user_order_not_eq MON_3, ContestUnreferenced_2B_1 - if_user_order_not_eq MON_4, ContestUnreferenced_2B_1 - end -ContestUnreferenced_0F_3: - if_user_order_not_eq MON_1, ContestUnreferenced_2B_1 - if_user_order_not_eq MON_2, ContestUnreferenced_2B_1 - if_user_order_not_eq MON_3, ContestUnreferenced_2B_1 - if_user_order_not_eq MON_4, ContestUnreferenced_2B_1 - end -ContestUnreferenced_0F_4: - if_user_order_not_eq MON_1, ContestUnreferenced_2B_1 - if_user_order_not_eq MON_2, ContestUnreferenced_2B_1 - if_user_order_not_eq MON_3, ContestUnreferenced_2B_1 - if_user_order_not_eq MON_4, ContestUnreferenced_2B_1 - end -ContestUnreferenced_0F_5: - if_user_order_not_eq MON_1, ContestUnreferenced_2B_1 - if_user_order_not_eq MON_2, ContestUnreferenced_2B_1 - if_user_order_not_eq MON_3, ContestUnreferenced_2B_1 - if_user_order_not_eq MON_4, ContestUnreferenced_2B_1 - end -ContestUnreferenced_score: +AI_CheckTiming_SkipCondition: + call AI_CheckTiming_TryStartle + end +AI_CheckTiming_TryStartle: + if_user_order_more_than MON_2, AI_CheckTiming_End + if_effect_type_not_eq CONTEST_EFFECT_TYPE_STARTLE_MON, AI_CheckTiming_End + if_effect_type_not_eq CONTEST_EFFECT_TYPE_STARTLE_MONS, AI_CheckTiming_End + score +10 +AI_CheckTiming_End: + end + +@ Unused, doesnt make much sense +@ Encourages using an avoid being startled move +@ The various appeal and turn checks are pointless, it will always encourage these moves +AI_AvoidStartle: + if_appeal_num_eq 0, AI_AvoidStartle_1stAppeal + if_appeal_num_eq 1, AI_AvoidStartle_2ndAppeal + if_appeal_num_eq 2, AI_AvoidStartle_3rdAppeal + if_appeal_num_eq 3, AI_AvoidStartle_4thAppeal + if_last_appeal AI_AvoidStartle_LastAppeal + end +AI_AvoidStartle_1stAppeal: + if_user_order_not_eq MON_1, AI_AvoidStartle_EncourageIfAvoidMove + if_user_order_not_eq MON_2, AI_AvoidStartle_EncourageIfAvoidMove2 + if_user_order_not_eq MON_3, AI_AvoidStartle_EncourageIfAvoidMove + if_user_order_not_eq MON_4, AI_AvoidStartle_EncourageIfAvoidMove + end +AI_AvoidStartle_EncourageIfAvoidMove: + if_effect_type_eq CONTEST_EFFECT_TYPE_AVOID_STARTLE, AI_AvoidStartle_Encourage + end +AI_AvoidStartle_EncourageIfAvoidMove2: + if_effect_type_eq CONTEST_EFFECT_TYPE_AVOID_STARTLE, AI_AvoidStartle_Encourage + end +AI_AvoidStartle_EncourageIfAvoidMove3: + if_effect_type_eq CONTEST_EFFECT_TYPE_AVOID_STARTLE, AI_AvoidStartle_Encourage + end +AI_AvoidStartle_2ndAppeal: + if_user_order_not_eq MON_1, AI_AvoidStartle_EncourageIfAvoidMove + if_user_order_not_eq MON_2, AI_AvoidStartle_EncourageIfAvoidMove + if_user_order_not_eq MON_3, AI_AvoidStartle_EncourageIfAvoidMove + if_user_order_not_eq MON_4, AI_AvoidStartle_EncourageIfAvoidMove + end +AI_AvoidStartle_3rdAppeal: + if_user_order_not_eq MON_1, AI_AvoidStartle_EncourageIfAvoidMove + if_user_order_not_eq MON_2, AI_AvoidStartle_EncourageIfAvoidMove + if_user_order_not_eq MON_3, AI_AvoidStartle_EncourageIfAvoidMove + if_user_order_not_eq MON_4, AI_AvoidStartle_EncourageIfAvoidMove + end +AI_AvoidStartle_4thAppeal: + if_user_order_not_eq MON_1, AI_AvoidStartle_EncourageIfAvoidMove + if_user_order_not_eq MON_2, AI_AvoidStartle_EncourageIfAvoidMove + if_user_order_not_eq MON_3, AI_AvoidStartle_EncourageIfAvoidMove + if_user_order_not_eq MON_4, AI_AvoidStartle_EncourageIfAvoidMove + end +AI_AvoidStartle_LastAppeal: + if_user_order_not_eq MON_1, AI_AvoidStartle_EncourageIfAvoidMove + if_user_order_not_eq MON_2, AI_AvoidStartle_EncourageIfAvoidMove + if_user_order_not_eq MON_3, AI_AvoidStartle_EncourageIfAvoidMove + if_user_order_not_eq MON_4, AI_AvoidStartle_EncourageIfAvoidMove + end +AI_AvoidStartle_Encourage: score +10 end - +AI_AvoidStartle_End: end -@ Unreferenced AI routine to encourage the most appealing move. - if_most_appealing_move ContestUnreferenced_score2 +@ Unused +AI_PreferMostAppealingMove: + if_most_appealing_move AI_PreferMostAppealingMove_Encourage end -ContestUnreferenced_score2: +AI_PreferMostAppealingMove_Encourage: score +10 end +@ Discourages using the same move multiple times if it would get boring AI_CheckBoring: if_effect_eq CONTEST_EFFECT_REPETITION_NOT_BORING, AI_CheckBoring_NotBoring - if_move_used_count_eq 1, AI_CheckBoring_FirstRepeat - if_move_used_count_eq 2, AI_CheckBoring_SecondRepeat - if_move_used_count_eq 3, AI_CheckBoring_ThirdRepeat - if_move_used_count_eq 4, AI_CheckBoring_FourthRepeat + if_move_used_count_eq 1, AI_CheckBoring_1stRepeat + if_move_used_count_eq 2, AI_CheckBoring_2ndRepeat + if_move_used_count_eq 3, AI_CheckBoring_3rdRepeat + if_move_used_count_eq 4, AI_CheckBoring_4thRepeat @ No repeats end -AI_CheckBoring_FirstRepeat: +AI_CheckBoring_1stRepeat: score -5 end -AI_CheckBoring_SecondRepeat: +AI_CheckBoring_2ndRepeat: score -15 end -AI_CheckBoring_ThirdRepeat: +AI_CheckBoring_3rdRepeat: score -20 end -AI_CheckBoring_FourthRepeat: +AI_CheckBoring_4thRepeat: score -25 end AI_CheckBoring_NotBoring: end +@ Strongly encourages using an exciting move if user is in a position to receive the max excitement bonus +@ Encourages using exciting moves in general +@ If the user doesnt have a good exciting move to use, then encourage lowering excitement to prevent +@ opponents from benefitting from the excitement AI_CheckExcitement: - if_move_excitement_less_than 0, AI_contest09_081DC2AB - if_move_excitement_eq 0, AI_contest7D_4_081DC2AB - if_move_excitement_eq 1, AI_contest3D_081DC2AB - end -AI_contest09_081DC2AB: - if_excitement_eq 4, AI_contest0F_1_081DC2AB - if_excitement_eq 3, AI_contest0F_2_081DC2AB - if_user_has_exciting_move AI_end_081DC2AB + if_move_excitement_less_than 0, AI_CheckExcitement_Negative + if_move_excitement_eq 0, AI_CheckExcitement_Neutral + if_move_excitement_eq 1, AI_CheckExcitement_Positive + end +AI_CheckExcitement_Negative: + if_excitement_eq 4, AI_CheckExcitement_Negative_1AwayFromMax + if_excitement_eq 3, AI_CheckExcitement_Negative_2AwayFromMax + if_user_has_exciting_move AI_CheckExcitement_End score +15 end -AI_contest0F_1_081DC2AB: - if_user_order_not_eq MON_1, AI_contest7D_1_081DC2AB - if_random 51, AI_end_081DC2AB +AI_CheckExcitement_Negative_1AwayFromMax: + if_user_order_not_eq MON_1, AI_CheckExcitement_Negative_1AwayFromMax_Not1stUp + if_random_less_than 51, AI_CheckExcitement_End score +20 end -AI_contest7D_1_081DC2AB: - if_random 127, AI_end_081DC2AB +AI_CheckExcitement_Negative_1AwayFromMax_Not1stUp: + if_random_less_than 127, AI_CheckExcitement_End score -10 end -AI_contest0F_2_081DC2AB: - if_user_order_not_eq MON_1, AI_contest7D_3_081DC2AB - if_last_appeal AI_score_081DC2AB -AI_contest7D_2_081DC2AB: - if_random 51, AI_end_081DC2AB +AI_CheckExcitement_Negative_2AwayFromMax: + if_user_order_not_eq MON_1, AI_CheckExcitement_Negative_2AwayFromMax_Not1stUp + if_last_appeal AI_CheckExcitement_Negative_2AwayFromMax_LastAppeal + if_random_less_than 51, AI_CheckExcitement_End score +10 end -AI_score_081DC2AB: +AI_CheckExcitement_Negative_2AwayFromMax_LastAppeal: score +15 end -AI_contest7D_3_081DC2AB: - if_random 127, AI_end_081DC2AB +AI_CheckExcitement_Negative_2AwayFromMax_Not1stUp: + if_random_less_than 127, AI_CheckExcitement_End score +10 end -AI_contest7D_4_081DC2AB: - if_random 127, AI_end_081DC2AB +AI_CheckExcitement_Neutral: + if_random_less_than 127, AI_CheckExcitement_End score +10 end -AI_contest3D_081DC2AB: - if_move_used_count_more_than 0, AI_contest29_081DC2AB - if_user_order_not_eq MON_1, AI_contest7D_5_081DC2AB - if_excitement_not_eq 4, AI_contest7D_5_081DC2AB +AI_CheckExcitement_Positive: + if_move_used_count_more_than 0, AI_CheckExcitement_Positive_Repeat + if_user_order_not_eq MON_1, AI_CheckExcitement_Positive_Not1stUpForMax + if_excitement_not_eq 4, AI_CheckExcitement_Positive_Not1stUpForMax score +30 end -AI_contest7D_5_081DC2AB: - if_random 100, AI_end_081DC2AB +AI_CheckExcitement_Positive_Not1stUpForMax: + if_random_less_than 100, AI_CheckExcitement_End score +10 end -AI_contest29_081DC2AB: - if_effect_not_eq CONTEST_EFFECT_REPETITION_NOT_BORING, AI_end_081DC2AB - if_user_order_not_eq MON_1, AI_contest7D_5_081DC2AB - if_excitement_not_eq 4, AI_contest7D_5_081DC2AB +AI_CheckExcitement_Positive_Repeat: + if_effect_not_eq CONTEST_EFFECT_REPETITION_NOT_BORING, AI_CheckExcitement_End + if_user_order_not_eq MON_1, AI_CheckExcitement_Positive_Not1stUpForMax + if_excitement_not_eq 4, AI_CheckExcitement_Positive_Not1stUpForMax score +30 end -AI_end_081DC2AB: +AI_CheckExcitement_End: end -AI_CheckForCombo: - if_would_finish_combo AI_score_081DC348 - call AI_contest3F_081DC348 - call AI_contest45_081DC348 +@ Strongly encourages using a move if it would finish a combo +@ Encourages using a move if it would start a combo, esp if the user goes earlier +@ Discourages starting a combo in the last round +@ Discourages using a combo finisher when its combo starter hasnt been used yet +AI_CheckCombo: + if_would_finish_combo AI_CheckCombo_WouldFinish + call AI_CheckCombo_CheckStarter + call AI_CheckCombo_CheckFinisherWithoutStarter end -AI_contest3F_081DC348: - if_move_used_count_not_eq 0, AI_end_081DC348 - if_not_combo_starter AI_end_081DC348 - if_user_order_eq MON_1, AI_contest04_1_081DC348 - if_user_order_eq MON_2, AI_contest04_2_081DC348 - if_user_order_eq MON_3, AI_contest04_3_081DC348 - if_user_order_eq MON_4, AI_contest04_4_081DC348 +AI_CheckCombo_CheckStarter: + if_move_used_count_not_eq 0, AI_CheckCombo_End + if_not_combo_starter AI_CheckCombo_End + if_user_order_eq MON_1, AI_CheckCombo_Starter1stUp + if_user_order_eq MON_2, AI_CheckCombo_Starter2ndUp + if_user_order_eq MON_3, AI_CheckCombo_Starter3rdUp + if_user_order_eq MON_4, AI_CheckCombo_StarterLast end -AI_contest45_081DC348: - if_not_combo_finisher AI_end_081DC348 +AI_CheckCombo_CheckFinisherWithoutStarter: + if_not_combo_finisher AI_CheckCombo_End score -10 end -AI_score_081DC348: +AI_CheckCombo_WouldFinish: score +25 end -AI_contest04_1_081DC348: - if_last_appeal AI_contest7D_081DC348 - if_random 150, AI_end_081DC348 +AI_CheckCombo_Starter1stUp: + if_last_appeal AI_CheckCombo_StarterOnLastAppeal + if_random_less_than 150, AI_CheckCombo_End score +10 end -AI_contest04_2_081DC348: - if_last_appeal AI_contest7D_081DC348 - if_random 125, AI_end_081DC348 +AI_CheckCombo_Starter2ndUp: + if_last_appeal AI_CheckCombo_StarterOnLastAppeal + if_random_less_than 125, AI_CheckCombo_End score +10 end -AI_contest04_3_081DC348: - if_last_appeal AI_contest7D_081DC348 - if_random 50, AI_end_081DC348 +AI_CheckCombo_Starter3rdUp: + if_last_appeal AI_CheckCombo_StarterOnLastAppeal + if_random_less_than 50, AI_CheckCombo_End score +10 end -AI_contest04_4_081DC348: - if_last_appeal AI_contest7D_081DC348 +AI_CheckCombo_StarterLast: + if_last_appeal AI_CheckCombo_StarterOnLastAppeal score +10 end -AI_contest7D_081DC348: - if_random 125, AI_end_081DC348 +AI_CheckCombo_StarterOnLastAppeal: + if_random_less_than 125, AI_CheckCombo_End score -15 end -AI_end_081DC348: - end - -AI_CheckForGoodMove: - if_effect_eq CONTEST_EFFECT_BETTER_WITH_GOOD_CONDITION, ContestEffect39 - if_effect_eq CONTEST_EFFECT_NEXT_APPEAL_EARLIER, ContestEffect40 - if_effect_eq CONTEST_EFFECT_NEXT_APPEAL_LATER, ContestEffect41 - if_effect_eq CONTEST_EFFECT_REPETITION_NOT_BORING, ContestEffect3 - if_effect_eq CONTEST_EFFECT_IMPROVE_CONDITION_PREVENT_NERVOUSNESS, ContestEffect38 - if_effect_eq CONTEST_EFFECT_DONT_EXCITE_AUDIENCE, ContestEffect47 - if_effect_eq CONTEST_EFFECT_APPEAL_AS_GOOD_AS_PREV_ONES, ContestEffect31 - if_effect_eq CONTEST_EFFECT_APPEAL_AS_GOOD_AS_PREV_ONE, ContestEffect32 - if_effect_eq CONTEST_EFFECT_BETTER_WHEN_AUDIENCE_EXCITED, ContestEffect46 - if_effect_eq CONTEST_EFFECT_WORSEN_CONDITION_OF_PREV_MONS, ContestEffect27 - if_effect_eq CONTEST_EFFECT_SHIFT_JUDGE_ATTENTION, ContestEffect16or17 - if_effect_eq CONTEST_EFFECT_STARTLE_MON_WITH_JUDGES_ATTENTION, ContestEffect16or17 - if_effect_eq CONTEST_EFFECT_MAKE_FOLLOWING_MONS_NERVOUS, ContestEffect_FollowingMonsNervous - if_effect_eq CONTEST_EFFECT_JAMS_OTHERS_BUT_MISS_ONE_TURN, ContestEffect18 - end - -ContestEffect39: - if_user_condition_eq 3, ContestEffect39_score1 - if_user_condition_eq 2, ContestEffect39_score2 - if_user_condition_eq 1, ContestEffect39_score3 - if_user_condition_eq 0, ContestEffect39_score4 - end -ContestEffect39_score1: +AI_CheckCombo_End: + end + +@ Checks if move should be encouraged based on its effect +AI_CheckGoodMove: + if_effect_eq CONTEST_EFFECT_BETTER_WITH_GOOD_CONDITION, AI_CGM_BetterWithGoodCondition + if_effect_eq CONTEST_EFFECT_NEXT_APPEAL_EARLIER, AI_CGM_NextAppealEarlier + if_effect_eq CONTEST_EFFECT_NEXT_APPEAL_LATER, AI_CGM_NextAppealLater + if_effect_eq CONTEST_EFFECT_REPETITION_NOT_BORING, AI_CGM_RepetitionNotBoring + if_effect_eq CONTEST_EFFECT_IMPROVE_CONDITION_PREVENT_NERVOUSNESS, AI_CGM_ImproveCondition + if_effect_eq CONTEST_EFFECT_DONT_EXCITE_AUDIENCE, AI_CGM_DontExciteAudience + if_effect_eq CONTEST_EFFECT_APPEAL_AS_GOOD_AS_PREV_ONES, AI_CGM_AppealAsGoodAsPrevOnes + if_effect_eq CONTEST_EFFECT_APPEAL_AS_GOOD_AS_PREV_ONE, AI_CGM_AppealAsGoodAsPrevOne + if_effect_eq CONTEST_EFFECT_BETTER_WHEN_AUDIENCE_EXCITED, AI_CGM_BetterWhenAudienceExcited + if_effect_eq CONTEST_EFFECT_WORSEN_CONDITION_OF_PREV_MONS, AI_CGM_WorsenConditionOfPrevMons + if_effect_eq CONTEST_EFFECT_SHIFT_JUDGE_ATTENTION, AI_CGM_TargetMonWithJudgesAttention + if_effect_eq CONTEST_EFFECT_STARTLE_MON_WITH_JUDGES_ATTENTION, AI_CGM_TargetMonWithJudgesAttention + if_effect_eq CONTEST_EFFECT_MAKE_FOLLOWING_MONS_NERVOUS, AI_CGM_MakeFollowingMonsNervous + if_effect_eq CONTEST_EFFECT_JAMS_OTHERS_BUT_MISS_ONE_TURN, AI_CGM_JamsOthersButMissOneTurn + end + +AI_CGM_BetterWithGoodCondition: + if_user_condition_eq 3, AI_CGM_BetterWithGoodCondition_3 + if_user_condition_eq 2, AI_CGM_BetterWithGoodCondition_2 + if_user_condition_eq 1, AI_CGM_BetterWithGoodCondition_1 + if_user_condition_eq 0, AI_CGM_BetterWithGoodCondition_0 + end +AI_CGM_BetterWithGoodCondition_3: score +20 end -ContestEffect39_score2: - if_random 125, ContestEffectEnd +AI_CGM_BetterWithGoodCondition_2: + if_random_less_than 125, AI_CGM_End score +15 end -ContestEffect39_score3: - if_random 125, ContestEffectEnd +AI_CGM_BetterWithGoodCondition_1: + if_random_less_than 125, AI_CGM_End score +5 end -ContestEffect39_score4: +AI_CGM_BetterWithGoodCondition_0: score -20 end -ContestEffect40: - if_effect_in_user_moveset CONTEST_EFFECT_BETTER_IF_FIRST, ContestEffectEnd - if_random 50, ContestEffectEnd +AI_CGM_NextAppealEarlier: + if_user_doesnt_have_move CONTEST_EFFECT_BETTER_IF_FIRST, AI_CGM_End + if_random_less_than 50, AI_CGM_End score +20 end -ContestEffect41: - if_effect_in_user_moveset CONTEST_EFFECT_BETTER_IF_LAST, ContestEffectEnd - if_random 50, ContestEffectEnd +AI_CGM_NextAppealLater: + if_user_doesnt_have_move CONTEST_EFFECT_BETTER_IF_LAST, AI_CGM_End + if_random_less_than 50, AI_CGM_End score +20 end -ContestEffect3: - if_user_order_not_eq MON_4, ContestEffectEnd - if_random 50, ContestEffectEnd +AI_CGM_RepetitionNotBoring: + if_user_order_not_eq MON_4, AI_CGM_End + if_random_less_than 50, AI_CGM_End score +15 end - if_last_appeal ContestEffect3_7D - if_random 220, ContestEffect3_score + +AI_CGM_Unused: + if_last_appeal AI_CGM_Unused_LastAppeal + if_random_less_than 220, AI_CGM_Unused_Discourage score +10 end -ContestEffect3_7D: - if_random 20, ContestEffectEnd +AI_CGM_Unused_LastAppeal: + if_random_less_than 20, AI_CGM_End score +15 end -ContestEffect3_score: +AI_CGM_Unused_Discourage: score -20 end -ContestEffect38: - if_effect_in_user_moveset CONTEST_EFFECT_BETTER_WITH_GOOD_CONDITION, ContestEffect38_contest04 - if_user_condition_eq 3, ContestEffect38_score1 - if_random 50, ContestEffectEnd +@ Enourages improving condition, esp if user has moves better with good condition or on 1st appeal +@ Discourages improving condition if at max condition, or if last appeal +AI_CGM_ImproveCondition: + if_user_doesnt_have_move CONTEST_EFFECT_BETTER_WITH_GOOD_CONDITION, AI_CGM_ImproveCondition_CheckAppealNum + if_user_condition_eq 3, AI_CGM_ImproveCondition_AtMax + if_random_less_than 50, AI_CGM_End score +15 end -ContestEffect38_score1: +AI_CGM_ImproveCondition_AtMax: score -10 end -ContestEffect38_contest04: - if_last_appeal ContestEffect38_score2 - if_appeal_num_eq 0, ContestEffect38_random - if_move_used_count_eq 1, ContestEffectEnd - if_random 125, ContestEffectEnd +AI_CGM_ImproveCondition_CheckAppealNum: + if_last_appeal AI_CGM_ImproveCondition_LastAppeal + if_appeal_num_eq 0, AI_CGM_ImproveCondition_FirstAppeal + if_move_used_count_eq 1, AI_CGM_End + if_random_less_than 125, AI_CGM_End score +10 end -ContestEffect38_random: - if_random 100, ContestEffectEnd +AI_CGM_ImproveCondition_FirstAppeal: + if_random_less_than 100, AI_CGM_End score +10 end -ContestEffect38_score2: +AI_CGM_ImproveCondition_LastAppeal: score -10 end -ContestEffect47: - if_move_used_count_eq 1, ContestEffectEnd - if_user_order_eq MON_1, ContestEffect47_random - if_user_order_eq MON_2, ContestEffect47_random - if_not_last_appeal ContestEffectEnd - if_user_has_exciting_move ContestEffectEnd - if_excitement_less_than 1, ContestEffectEnd +@ Encourage stopping audience excitement early in the appeal, or last appeal if no better options +AI_CGM_DontExciteAudience: + if_move_used_count_eq 1, AI_CGM_End + if_user_order_eq MON_1, AI_CGM_DontExciteAudience_EarlyTurn + if_user_order_eq MON_2, AI_CGM_DontExciteAudience_EarlyTurn + if_not_last_appeal AI_CGM_End + if_user_has_exciting_move AI_CGM_End + if_excitement_less_than 1, AI_CGM_End score +10 end -ContestEffect47_random: - if_random 127, ContestEffectEnd +AI_CGM_DontExciteAudience_EarlyTurn: + if_random_less_than 127, AI_CGM_End score +10 end -ContestEffect31: - if_user_order_eq MON_2, ContestEffect31_score1 - if_user_order_eq MON_3, ContestEffect31_score2 - if_user_order_eq MON_4, ContestEffect31_score3 +@ Encourages move the later the user goes +AI_CGM_AppealAsGoodAsPrevOnes: + if_user_order_eq MON_2, AI_CGM_AppealAsGoodAsPrevOnes_2ndUp + if_user_order_eq MON_3, AI_CGM_AppealAsGoodAsPrevOnes_3rdUp + if_user_order_eq MON_4, AI_CGM_AppealAsGoodAsPrevOnes_Last end -ContestEffect31_score1: +AI_CGM_AppealAsGoodAsPrevOnes_2ndUp: score +5 end -ContestEffect31_score2: +AI_CGM_AppealAsGoodAsPrevOnes_3rdUp: score +15 end -ContestEffect31_score3: +AI_CGM_AppealAsGoodAsPrevOnes_Last: score +20 end -ContestEffect32: - if_user_order_eq MON_1, ContestEffect32_score1 - if_user_order_eq MON_2, ContestEffect32_score2 - if_user_order_eq MON_3, ContestEffect32_score3 - if_user_order_eq MON_4, ContestEffect32_score5 +@ Encourages move more for each opponent who will have a turn before the user +AI_CGM_AppealAsGoodAsPrevOne: + if_user_order_eq MON_1, AI_CGM_AppealAsGoodAsPrevOne_1stUp + if_user_order_eq MON_2, AI_CGM_AppealAsGoodAsPrevOne_2ndUp + if_user_order_eq MON_3, AI_CGM_AppealAsGoodAsPrevOne_3rdUp + if_user_order_eq MON_4, AI_CGM_AppealAsGoodAsPrevOne_Last end -ContestEffect32_score1: +AI_CGM_AppealAsGoodAsPrevOne_1stUp: score -10 end -ContestEffect32_score2: - if_cannot_participate MON_1, ContestEffectEnd +AI_CGM_AppealAsGoodAsPrevOne_2ndUp: + if_cannot_participate MON_1, AI_CGM_End score +5 end -ContestEffect32_score3: - if_cannot_participate MON_1, ContestEffect32_score4 +AI_CGM_AppealAsGoodAsPrevOne_3rdUp: + if_cannot_participate MON_1, AI_CGM_AppealAsGoodAsPrevOne_3rdUp_CheckMon2 score +5 - jump ContestEffect32_score4 + goto AI_CGM_AppealAsGoodAsPrevOne_3rdUp_CheckMon2 end -ContestEffect32_score4: - if_cannot_participate MON_2, ContestEffectEnd +AI_CGM_AppealAsGoodAsPrevOne_3rdUp_CheckMon2: + if_cannot_participate MON_2, AI_CGM_End score +5 end -ContestEffect32_score5: - if_cannot_participate MON_1, ContestEffect32_score6 +AI_CGM_AppealAsGoodAsPrevOne_Last: + if_cannot_participate MON_1, AI_CGM_AppealAsGoodAsPrevOne_Last_CheckMon2 score +5 - jump ContestEffect32_score6 + goto AI_CGM_AppealAsGoodAsPrevOne_Last_CheckMon2 end -ContestEffect32_score6: - if_cannot_participate MON_2, ContestEffect32_score7 +AI_CGM_AppealAsGoodAsPrevOne_Last_CheckMon2: + if_cannot_participate MON_2, AI_CGM_AppealAsGoodAsPrevOne_Last_CheckMon3 score +5 - jump ContestEffect32_score7 + goto AI_CGM_AppealAsGoodAsPrevOne_Last_CheckMon3 end -ContestEffect32_score7: - if_cannot_participate MON_3, ContestEffectEnd +AI_CGM_AppealAsGoodAsPrevOne_Last_CheckMon3: + if_cannot_participate MON_3, AI_CGM_End score +5 end -ContestEffect46: - if_user_order_eq MON_1, ContestEffect46_05 - if_user_order_more_than MON_1, ContestEffect46_score4 +@ Encourage move if audience is close to full exictement and user goes first +@ See bug note, only does this on 1st appeal (when it will never happen) +AI_CGM_BetterWhenAudienceExcited: + if_user_order_eq MON_1, AI_CGM_BetterWhenAudienceExcited_1stUp + if_user_order_more_than MON_1, AI_CGM_BetterWhenAudienceExcited_Not1stUp end -ContestEffect46_05: - if_appeal_num_not_eq 0, ContestEffect46_score1 - if_excitement_eq 4, ContestEffect46_score2 - if_excitement_eq 3, ContestEffect46_score3 +AI_CGM_BetterWhenAudienceExcited_1stUp: + @ BUG: Should be if_appeal_num_eq 0 + @ 1st up on 1st appeal excitement will always be 0 + if_appeal_num_not_eq 0, AI_CGM_BetterWhenAudienceExcited_Not1stAppeal + if_excitement_eq 4, AI_CGM_BetterWhenAudienceExcited_1AwayFromMax + if_excitement_eq 3, AI_CGM_BetterWhenAudienceExcited_2AwayFromMax end -ContestEffect46_score1: - if_random 125, ContestEffectEnd +AI_CGM_BetterWhenAudienceExcited_Not1stAppeal: + if_random_less_than 125, AI_CGM_End score -15 end -ContestEffect46_score2: - if_random 125, ContestEffectEnd +AI_CGM_BetterWhenAudienceExcited_1AwayFromMax: + if_random_less_than 125, AI_CGM_End score +20 end -ContestEffect46_score3: - if_random 125, ContestEffectEnd +AI_CGM_BetterWhenAudienceExcited_2AwayFromMax: + if_random_less_than 125, AI_CGM_End score +15 end -ContestEffect46_score4: - if_random 178, ContestEffectEnd +AI_CGM_BetterWhenAudienceExcited_Not1stUp: + if_random_less_than 178, AI_CGM_End score +10 end -ContestEffect27: - if_user_order_eq MON_1, ContestEffectEnd - jump ContestEffect27_55_1 +@ Encourage move more for each condition star the prev mons have +AI_CGM_WorsenConditionOfPrevMons: + if_user_order_eq MON_1, AI_CGM_End + goto AI_CGM_WorsenConditionOfPrevMons_CheckMon1 end -ContestEffect27_55_1: - if_cannot_participate MON_1, ContestEffect27_noscore - if_condition_eq MON_1, 0, ContestEffect27_noscore - if_condition_eq MON_1, 1, ContestEffect27_score1 - if_condition_eq MON_1, 2, ContestEffect27_score2 - if_condition_eq MON_1, 3, ContestEffect27_score3 +AI_CGM_WorsenConditionOfPrevMons_CheckMon1: + if_cannot_participate MON_1, AI_CGM_WorsenConditionOfPrevMons_TryCheckMon2 + if_condition_eq MON_1, 0, AI_CGM_WorsenConditionOfPrevMons_TryCheckMon2 + if_condition_eq MON_1, 1, AI_CGM_WorsenConditionOfPrevMons_Mon1Has1Star + if_condition_eq MON_1, 2, AI_CGM_WorsenConditionOfPrevMons_Mon1Has2Stars + if_condition_eq MON_1, 3, AI_CGM_WorsenConditionOfPrevMons_Mon1Has3Stars end -ContestEffect27_score1: - if_random 125, ContestEffect27_55_2 +AI_CGM_WorsenConditionOfPrevMons_Mon1Has1Star: + if_random_less_than 125, AI_CGM_WorsenConditionOfPrevMons_CheckMon2 score +5 - if_user_order_more_than MON_2, ContestEffect27_55_2 + if_user_order_more_than MON_2, AI_CGM_WorsenConditionOfPrevMons_CheckMon2 end -ContestEffect27_score2: - if_random 125, ContestEffect27_55_2 +AI_CGM_WorsenConditionOfPrevMons_Mon1Has2Stars: + if_random_less_than 125, AI_CGM_WorsenConditionOfPrevMons_CheckMon2 score +10 - if_user_order_more_than MON_2, ContestEffect27_55_2 + if_user_order_more_than MON_2, AI_CGM_WorsenConditionOfPrevMons_CheckMon2 end -ContestEffect27_score3: - if_random 125, ContestEffect27_55_2 +AI_CGM_WorsenConditionOfPrevMons_Mon1Has3Stars: + if_random_less_than 125, AI_CGM_WorsenConditionOfPrevMons_CheckMon2 score +15 - if_user_order_more_than MON_2, ContestEffect27_55_2 + if_user_order_more_than MON_2, AI_CGM_WorsenConditionOfPrevMons_CheckMon2 end -ContestEffect27_noscore: - if_user_order_more_than MON_2, ContestEffect27_55_2 +AI_CGM_WorsenConditionOfPrevMons_TryCheckMon2: + if_user_order_more_than MON_2, AI_CGM_WorsenConditionOfPrevMons_CheckMon2 end -ContestEffect27_55_2: - if_cannot_participate MON_2, ContestEffect27_noscore2 - if_condition_eq MON_2, 0, ContestEffect27_noscore2 - if_condition_eq MON_2, 1, ContestEffect27_score4 - if_condition_eq MON_2, 2, ContestEffect27_score5 - if_condition_eq MON_2, 3, ContestEffect27_score6 +AI_CGM_WorsenConditionOfPrevMons_CheckMon2: + if_cannot_participate MON_2, AI_CGM_WorsenConditionOfPrevMons_TryCheckMon3 + if_condition_eq MON_2, 0, AI_CGM_WorsenConditionOfPrevMons_TryCheckMon3 + if_condition_eq MON_2, 1, AI_CGM_WorsenConditionOfPrevMons_Mon2Has1Star + if_condition_eq MON_2, 2, AI_CGM_WorsenConditionOfPrevMons_Mon2Has2Stars + if_condition_eq MON_2, 3, AI_CGM_WorsenConditionOfPrevMons_Mon2Has3Stars end -ContestEffect27_score4: - if_random 125, ContestEffect27_55_3 +AI_CGM_WorsenConditionOfPrevMons_Mon2Has1Star: + if_random_less_than 125, AI_CGM_WorsenConditionOfPrevMons_CheckMon3 score +5 - if_user_order_more_than MON_3, ContestEffect27_55_3 + if_user_order_more_than MON_3, AI_CGM_WorsenConditionOfPrevMons_CheckMon3 end -ContestEffect27_score5: - if_random 125, ContestEffect27_55_3 +AI_CGM_WorsenConditionOfPrevMons_Mon2Has2Stars: + if_random_less_than 125, AI_CGM_WorsenConditionOfPrevMons_CheckMon3 score +10 - if_user_order_more_than MON_3, ContestEffect27_55_3 + if_user_order_more_than MON_3, AI_CGM_WorsenConditionOfPrevMons_CheckMon3 end -ContestEffect27_score6: - if_random 125, ContestEffect27_55_3 +AI_CGM_WorsenConditionOfPrevMons_Mon2Has3Stars: + if_random_less_than 125, AI_CGM_WorsenConditionOfPrevMons_CheckMon3 score +15 - if_user_order_more_than MON_3, ContestEffect27_55_3 + if_user_order_more_than MON_3, AI_CGM_WorsenConditionOfPrevMons_CheckMon3 end -ContestEffect27_noscore2: - if_user_order_more_than MON_3, ContestEffect27_55_3 +AI_CGM_WorsenConditionOfPrevMons_TryCheckMon3: + if_user_order_more_than MON_3, AI_CGM_WorsenConditionOfPrevMons_CheckMon3 end -ContestEffect27_55_3: - if_cannot_participate MON_3, ContestEffect27_end - if_condition_eq MON_3, 0, ContestEffect27_end - if_condition_eq MON_3, 1, ContestEffect27_score7 - if_condition_eq MON_3, 2, ContestEffect27_score8 - if_condition_eq MON_3, 3, ContestEffect27_score9 +AI_CGM_WorsenConditionOfPrevMons_CheckMon3: + if_cannot_participate MON_3, AI_CGM_WorsenConditionOfPrevMons_end + if_condition_eq MON_3, 0, AI_CGM_WorsenConditionOfPrevMons_end + if_condition_eq MON_3, 1, AI_CGM_WorsenConditionOfPrevMons_Mon3Has1Star + if_condition_eq MON_3, 2, AI_CGM_WorsenConditionOfPrevMons_Mon3Has2Stars + if_condition_eq MON_3, 3, AI_CGM_WorsenConditionOfPrevMons_Mon3Has3Stars end -ContestEffect27_score7: - if_random 125, ContestEffectEnd +AI_CGM_WorsenConditionOfPrevMons_Mon3Has1Star: + if_random_less_than 125, AI_CGM_End score +5 end -ContestEffect27_score8: - if_random 125, ContestEffectEnd +AI_CGM_WorsenConditionOfPrevMons_Mon3Has2Stars: + if_random_less_than 125, AI_CGM_End score +10 end -ContestEffect27_score9: - if_random 125, ContestEffectEnd +AI_CGM_WorsenConditionOfPrevMons_Mon3Has3Stars: + if_random_less_than 125, AI_CGM_End score +15 end -ContestEffect27_end: +AI_CGM_WorsenConditionOfPrevMons_end: end -ContestEffect16or17: - if_user_order_eq MON_1, ContestEffectEnd - jump ContestEffect16or17_55 +@ Encourage if a prev mon has started a combo, esp if they havent completed it yet +@ BUG: Incorrectly uses if_used_combo_starter below, instead of if_not_used_combo_starter +@ As a result it encourages move if a prev mon has not begun a combo +AI_CGM_TargetMonWithJudgesAttention: + if_user_order_eq MON_1, AI_CGM_End + goto AI_CGM_TargetMonWithJudgesAttention_CheckMon1 end -ContestEffect16or17_55: - if_cannot_participate MON_1, ContestEffect16or17_0E_1 - if_used_combo_starter_eq MON_1, TRUE, ContestEffect16or17_0E_1 - if_random 125, ContestEffect16or17_0E_1 +AI_CGM_TargetMonWithJudgesAttention_CheckMon1: + if_cannot_participate MON_1, AI_CGM_TargetMonWithJudgesAttention_CheckMon2 + if_used_combo_starter MON_1, AI_CGM_TargetMonWithJudgesAttention_CheckMon2 + if_random_less_than 125, AI_CGM_TargetMonWithJudgesAttention_CheckMon2 score +2 - contest_58 MON_1, ContestEffect16or17_0E_1 + if_not_completed_combo MON_1, AI_CGM_TargetMonWithJudgesAttention_CheckMon2 score +8 end -ContestEffect16or17_0E_1: - if_user_order_eq MON_2, ContestEffectEnd - if_cannot_participate MON_2, ContestEffect16or17_0E_2 - if_used_combo_starter_eq MON_2, TRUE, ContestEffect16or17_0E_2 - if_random 125, ContestEffect16or17_0E_2 +AI_CGM_TargetMonWithJudgesAttention_CheckMon2: + if_user_order_eq MON_2, AI_CGM_End + if_cannot_participate MON_2, AI_CGM_TargetMonWithJudgesAttention_CheckMon3 + if_used_combo_starter MON_2, AI_CGM_TargetMonWithJudgesAttention_CheckMon3 + if_random_less_than 125, AI_CGM_TargetMonWithJudgesAttention_CheckMon3 score +2 - contest_58 MON_2, ContestEffect16or17_0E_2 + if_not_completed_combo MON_2, AI_CGM_TargetMonWithJudgesAttention_CheckMon3 score +8 end -ContestEffect16or17_0E_2: - if_user_order_eq MON_3, ContestEffectEnd - if_cannot_participate MON_3, ContestEffectEnd - if_used_combo_starter_eq MON_3, TRUE, ContestEffectEnd - if_random 125, ContestEffectEnd +AI_CGM_TargetMonWithJudgesAttention_CheckMon3: + if_user_order_eq MON_3, AI_CGM_End + if_cannot_participate MON_3, AI_CGM_End + if_used_combo_starter MON_3, AI_CGM_End + if_random_less_than 125, AI_CGM_End score +2 - contest_58 MON_3, ContestEffectEnd + if_not_completed_combo MON_3, AI_CGM_End score +8 end -ContestEffect_FollowingMonsNervous: - if_user_order_eq MON_4, ContestEffectEnd - jump ContestEffect_FollowingMonsNervous_CheckMon4 +@ Encourage making mons nervous that have started a combo and can appeal after the user +AI_CGM_MakeFollowingMonsNervous: + if_user_order_eq MON_4, AI_CGM_End + goto AI_CGM_MakeFollowingMonsNervous_CheckMon4 end -ContestEffect_FollowingMonsNervous_CheckMon4: - if_cannot_participate MON_4, ContestEffect_FollowingMonsNervous_CheckMon3 - if_used_combo_starter_eq MON_4, FALSE, ContestEffect_FollowingMonsNervous_CheckMon3 +AI_CGM_MakeFollowingMonsNervous_CheckMon4: + if_cannot_participate MON_4, AI_CGM_MakeFollowingMonsNervous_CheckMon3 + if_not_used_combo_starter MON_4, AI_CGM_MakeFollowingMonsNervous_CheckMon3 score +5 - if_random 125, ContestEffect16or17_0E_1 + if_random_less_than 125, AI_CGM_TargetMonWithJudgesAttention_CheckMon2 score +5 end -ContestEffect_FollowingMonsNervous_CheckMon3: - if_user_order_eq MON_3, ContestEffectEnd - if_cannot_participate MON_3, ContestEffect_FollowingMonsNervous_CheckMon2 - if_used_combo_starter_eq MON_3, FALSE, ContestEffect_FollowingMonsNervous_CheckMon2 +AI_CGM_MakeFollowingMonsNervous_CheckMon3: + if_user_order_eq MON_3, AI_CGM_End + if_cannot_participate MON_3, AI_CGM_MakeFollowingMonsNervous_CheckMon2 + if_not_used_combo_starter MON_3, AI_CGM_MakeFollowingMonsNervous_CheckMon2 score +5 - if_random 125, ContestEffect16or17_0E_2 + if_random_less_than 125, AI_CGM_TargetMonWithJudgesAttention_CheckMon3 score +5 end -ContestEffect_FollowingMonsNervous_CheckMon2: - if_user_order_eq MON_2, ContestEffectEnd - if_cannot_participate MON_2, ContestEffectEnd - if_used_combo_starter_eq MON_2, FALSE, ContestEffectEnd +AI_CGM_MakeFollowingMonsNervous_CheckMon2: + if_user_order_eq MON_2, AI_CGM_End + if_cannot_participate MON_2, AI_CGM_End + if_not_used_combo_starter MON_2, AI_CGM_End score +5 - if_random 125, ContestEffectEnd + if_random_less_than 125, AI_CGM_End score +5 end -ContestEffect18: - if_last_appeal ContestEffect18_score1 - jump ContestEffect18_0E +@ Encourages move if users turn is later, or if its the last appeal +AI_CGM_JamsOthersButMissOneTurn: + if_last_appeal AI_CGM_JamsOthersButMissOneTurn_LastAppeal + goto AI_CGM_JamsOthersButMissOneTurn_TurnOrder end -ContestEffect18_score1: +AI_CGM_JamsOthersButMissOneTurn_LastAppeal: score +5 - jump ContestEffect18_0E + goto AI_CGM_JamsOthersButMissOneTurn_TurnOrder end -ContestEffect18_0E: - if_user_order_eq MON_1, ContestEffect18_score2 - if_user_order_eq MON_2, ContestEffect18_random1 - if_user_order_eq MON_3, ContestEffect18_random2 - if_user_order_eq MON_4, ContestEffect18_random3 +AI_CGM_JamsOthersButMissOneTurn_TurnOrder: + if_user_order_eq MON_1, AI_CGM_JamsOthersButMissOneTurn_1stUp + if_user_order_eq MON_2, AI_CGM_JamsOthersButMissOneTurn_2ndUp + if_user_order_eq MON_3, AI_CGM_JamsOthersButMissOneTurn_3rdUp + if_user_order_eq MON_4, AI_CGM_JamsOthersButMissOneTurn_Last end -ContestEffect18_score2: +AI_CGM_JamsOthersButMissOneTurn_1stUp: score -15 end -ContestEffect18_random1: - if_random 125, ContestEffectEnd +AI_CGM_JamsOthersButMissOneTurn_2ndUp: + if_random_less_than 125, AI_CGM_End score -10 end -ContestEffect18_random2: - if_random 125, ContestEffectEnd +AI_CGM_JamsOthersButMissOneTurn_3rdUp: + if_random_less_than 125, AI_CGM_End score +5 end -ContestEffect18_random3: - if_random 125, ContestEffectEnd +AI_CGM_JamsOthersButMissOneTurn_Last: + if_random_less_than 125, AI_CGM_End score +15 end -ContestEffectEnd: +AI_CGM_End: end @ Randomly encourage moves in Cute, Smart, and Tough contests. AI_Erratic: - if_contest_type_eq CONTEST_CATEGORY_CUTE, Erratic_CuteSmartTough - if_contest_type_eq CONTEST_CATEGORY_SMART, Erratic_CuteSmartTough - if_contest_type_eq CONTEST_CATEGORY_TOUGH, Erratic_CuteSmartTough + if_contest_type_eq CONTEST_CATEGORY_CUTE, AI_Erratic_CuteSmartTough + if_contest_type_eq CONTEST_CATEGORY_SMART, AI_Erratic_CuteSmartTough + if_contest_type_eq CONTEST_CATEGORY_TOUGH, AI_Erratic_CuteSmartTough end -Erratic_CuteSmartTough: - if_random 125, Erratic_NoScoreIncrease +AI_Erratic_CuteSmartTough: + if_random_less_than 125, AI_Erratic_End score +10 end -Erratic_NoScoreIncrease: - end - -AI_CheckForBadMove: - if_effect_eq CONTEST_EFFECT_STARTLE_FRONT_MON, ContestEffect2_8 - if_effect_eq CONTEST_EFFECT_STARTLE_PREV_MON, ContestEffect2_8 - if_effect_eq CONTEST_EFFECT_BADLY_STARTLE_FRONT_MON, ContestEffect2_8 - if_effect_eq CONTEST_EFFECT_STARTLE_PREV_MON_2, ContestEffect2_8 - if_effect_eq CONTEST_EFFECT_APPEAL_AS_GOOD_AS_PREV_ONE, ContestEffect2_8 - if_effect_eq CONTEST_EFFECT_BETTER_IF_SAME_TYPE, ContestEffect2_8 - if_effect_eq CONTEST_EFFECT_BETTER_IF_DIFF_TYPE, ContestEffect2_8 - if_effect_eq CONTEST_EFFECT_AFFECTED_BY_PREV_APPEAL, ContestEffect2_8 - if_effect_eq CONTEST_EFFECT_SLIGHTLY_STARTLE_PREV_MONS, ContestEffect2_9 - if_effect_eq CONTEST_EFFECT_STARTLE_PREV_MONS, ContestEffect2_9 - if_effect_eq CONTEST_EFFECT_BADLY_STARTLE_PREV_MONS, ContestEffect2_9 - if_effect_eq CONTEST_EFFECT_STARTLE_PREV_MONS_2, ContestEffect2_9 - if_effect_eq CONTEST_EFFECT_STARTLE_MON_WITH_JUDGES_ATTENTION, ContestEffect2_9 - if_effect_eq CONTEST_EFFECT_SHIFT_JUDGE_ATTENTION, ContestEffect2_9 - if_effect_eq CONTEST_EFFECT_JAMS_OTHERS_BUT_MISS_ONE_TURN, ContestEffect2_9 - if_effect_eq CONTEST_EFFECT_STARTLE_MONS_SAME_TYPE_APPEAL, ContestEffect2_9 - if_effect_eq CONTEST_EFFECT_BADLY_STARTLE_MONS_WITH_GOOD_APPEALS, ContestEffect2_9 - if_effect_eq CONTEST_EFFECT_STARTLE_MONS_COOL_APPEAL, ContestEffect2_9 - if_effect_eq CONTEST_EFFECT_STARTLE_MONS_BEAUTY_APPEAL, ContestEffect2_9 - if_effect_eq CONTEST_EFFECT_STARTLE_MONS_CUTE_APPEAL, ContestEffect2_9 - if_effect_eq CONTEST_EFFECT_STARTLE_MONS_SMART_APPEAL, ContestEffect2_9 - if_effect_eq CONTEST_EFFECT_STARTLE_MONS_TOUGH_APPEAL, ContestEffect2_9 - if_effect_eq CONTEST_EFFECT_BADLY_STARTLES_MONS_IN_GOOD_CONDITION, ContestEffect2_9 - if_effect_eq CONTEST_EFFECT_WORSEN_CONDITION_OF_PREV_MONS, ContestEffect2_9 - if_effect_eq CONTEST_EFFECT_APPEAL_AS_GOOD_AS_PREV_ONES, ContestEffect2_9 - if_effect_eq CONTEST_EFFECT_MAKE_FOLLOWING_MON_NERVOUS, ContestEffect2_25 - if_effect_eq CONTEST_EFFECT_MAKE_FOLLOWING_MONS_NERVOUS, ContestEffect2_26 - if_effect_eq CONTEST_EFFECT_DONT_EXCITE_AUDIENCE, ContestEffect2_26 - if_effect_eq CONTEST_EFFECT_IMPROVE_CONDITION_PREVENT_NERVOUSNESS, ContestEffect2_38 - if_effect_eq CONTEST_EFFECT_AVOID_STARTLE_ONCE, ContestEffect2_4 - if_effect_eq CONTEST_EFFECT_AVOID_STARTLE, ContestEffect2_4 - if_effect_eq CONTEST_EFFECT_AVOID_STARTLE_SLIGHTLY, ContestEffect2_4 - if_effect_eq CONTEST_EFFECT_GREAT_APPEAL_BUT_NO_MORE_MOVES, ContestEffect2_2 - end - -ContestEffect2_8: - if_user_order_eq MON_1, ContestEffect2_8_score1 - if_user_order_eq MON_2, ContestEffect2_8_score2 - if_user_order_eq MON_3, ContestEffect2_8_score3 - if_user_order_eq MON_4, ContestEffect2_8_score4 - end -ContestEffect2_8_score1: +AI_Erratic_End: + end + +@ Checks if move should be discouraged based on its effect +AI_CheckBadMove: + if_effect_eq CONTEST_EFFECT_STARTLE_FRONT_MON, AI_CBM_DependsOnPrevMon + if_effect_eq CONTEST_EFFECT_STARTLE_PREV_MON, AI_CBM_DependsOnPrevMon + if_effect_eq CONTEST_EFFECT_BADLY_STARTLE_FRONT_MON, AI_CBM_DependsOnPrevMon + if_effect_eq CONTEST_EFFECT_STARTLE_PREV_MON_2, AI_CBM_DependsOnPrevMon + if_effect_eq CONTEST_EFFECT_APPEAL_AS_GOOD_AS_PREV_ONE, AI_CBM_DependsOnPrevMon + if_effect_eq CONTEST_EFFECT_BETTER_IF_SAME_TYPE, AI_CBM_DependsOnPrevMon + if_effect_eq CONTEST_EFFECT_BETTER_IF_DIFF_TYPE, AI_CBM_DependsOnPrevMon + if_effect_eq CONTEST_EFFECT_AFFECTED_BY_PREV_APPEAL, AI_CBM_DependsOnPrevMon + if_effect_eq CONTEST_EFFECT_SLIGHTLY_STARTLE_PREV_MONS, AI_CBM_DependsOnPrevMons + if_effect_eq CONTEST_EFFECT_STARTLE_PREV_MONS, AI_CBM_DependsOnPrevMons + if_effect_eq CONTEST_EFFECT_BADLY_STARTLE_PREV_MONS, AI_CBM_DependsOnPrevMons + if_effect_eq CONTEST_EFFECT_STARTLE_PREV_MONS_2, AI_CBM_DependsOnPrevMons + if_effect_eq CONTEST_EFFECT_STARTLE_MON_WITH_JUDGES_ATTENTION, AI_CBM_DependsOnPrevMons + if_effect_eq CONTEST_EFFECT_SHIFT_JUDGE_ATTENTION, AI_CBM_DependsOnPrevMons + if_effect_eq CONTEST_EFFECT_JAMS_OTHERS_BUT_MISS_ONE_TURN, AI_CBM_DependsOnPrevMons + if_effect_eq CONTEST_EFFECT_STARTLE_MONS_SAME_TYPE_APPEAL, AI_CBM_DependsOnPrevMons + if_effect_eq CONTEST_EFFECT_BADLY_STARTLE_MONS_WITH_GOOD_APPEALS, AI_CBM_DependsOnPrevMons + if_effect_eq CONTEST_EFFECT_STARTLE_MONS_COOL_APPEAL, AI_CBM_DependsOnPrevMons + if_effect_eq CONTEST_EFFECT_STARTLE_MONS_BEAUTY_APPEAL, AI_CBM_DependsOnPrevMons + if_effect_eq CONTEST_EFFECT_STARTLE_MONS_CUTE_APPEAL, AI_CBM_DependsOnPrevMons + if_effect_eq CONTEST_EFFECT_STARTLE_MONS_SMART_APPEAL, AI_CBM_DependsOnPrevMons + if_effect_eq CONTEST_EFFECT_STARTLE_MONS_TOUGH_APPEAL, AI_CBM_DependsOnPrevMons + if_effect_eq CONTEST_EFFECT_BADLY_STARTLES_MONS_IN_GOOD_CONDITION, AI_CBM_DependsOnPrevMons + if_effect_eq CONTEST_EFFECT_WORSEN_CONDITION_OF_PREV_MONS, AI_CBM_DependsOnPrevMons + if_effect_eq CONTEST_EFFECT_APPEAL_AS_GOOD_AS_PREV_ONES, AI_CBM_DependsOnPrevMons + if_effect_eq CONTEST_EFFECT_MAKE_FOLLOWING_MON_NERVOUS, AI_CBM_DependsOnNextMon + if_effect_eq CONTEST_EFFECT_MAKE_FOLLOWING_MONS_NERVOUS, AI_CBM_DependsOnNextMons + if_effect_eq CONTEST_EFFECT_DONT_EXCITE_AUDIENCE, AI_CBM_DependsOnNextMons + if_effect_eq CONTEST_EFFECT_IMPROVE_CONDITION_PREVENT_NERVOUSNESS, AI_CBM_ImproveCondition + if_effect_eq CONTEST_EFFECT_AVOID_STARTLE_ONCE, AI_CBM_AvoidStartle + if_effect_eq CONTEST_EFFECT_AVOID_STARTLE, AI_CBM_AvoidStartle + if_effect_eq CONTEST_EFFECT_AVOID_STARTLE_SLIGHTLY, AI_CBM_AvoidStartle + if_effect_eq CONTEST_EFFECT_GREAT_APPEAL_BUT_NO_MORE_MOVES, AI_CBM_NoMoreMoves + end + +@ If previous mon is skipping turn (or user is first), discourage move +AI_CBM_DependsOnPrevMon: + if_user_order_eq MON_1, AI_CBM_DependsOnPrevMon_1stUp + if_user_order_eq MON_2, AI_CBM_DependsOnPrevMon_2ndUp + if_user_order_eq MON_3, AI_CBM_DependsOnPrevMon_3rdUp + if_user_order_eq MON_4, AI_CBM_DependsOnPrevMon_Last + end +AI_CBM_DependsOnPrevMon_1stUp: score -10 end -ContestEffect2_8_score2: - if_can_participate MON_1, ContestEffectEnd2 +AI_CBM_DependsOnPrevMon_2ndUp: + if_can_participate MON_1, AI_CBM_End score -10 end -ContestEffect2_8_score3: - if_can_participate MON_2, ContestEffectEnd2 +AI_CBM_DependsOnPrevMon_3rdUp: + if_can_participate MON_2, AI_CBM_End score -10 end -ContestEffect2_8_score4: - if_can_participate MON_3, ContestEffectEnd2 +AI_CBM_DependsOnPrevMon_Last: + if_can_participate MON_3, AI_CBM_End score -10 end -ContestEffect2_9: - if_user_order_eq MON_1, ContestEffect2_9_score1 - if_user_order_eq MON_2, ContestEffect2_9_score2 - if_user_order_eq MON_3, ContestEffect2_9_score3 - if_user_order_eq MON_4, ContestEffect2_9_score4 +@ If previous mons are all skipping turns (or user is first), discourage move +AI_CBM_DependsOnPrevMons: + if_user_order_eq MON_1, AI_CBM_DependsOnPrevMons_1stUp + if_user_order_eq MON_2, AI_CBM_DependsOnPrevMons_2ndUp + if_user_order_eq MON_3, AI_CBM_DependsOnPrevMons_3rdUp + if_user_order_eq MON_4, AI_CBM_DependsOnPrevMons_Last end -ContestEffect2_9_score1: +AI_CBM_DependsOnPrevMons_1stUp: score -20 end -ContestEffect2_9_score2: - if_can_participate MON_1, ContestEffectEnd2 +AI_CBM_DependsOnPrevMons_2ndUp: + if_can_participate MON_1, AI_CBM_End score -15 end -ContestEffect2_9_score3: - if_can_participate MON_1, ContestEffectEnd2 - if_can_participate MON_2, ContestEffectEnd2 +AI_CBM_DependsOnPrevMons_3rdUp: + if_can_participate MON_1, AI_CBM_End + if_can_participate MON_2, AI_CBM_End score -15 end -ContestEffect2_9_score4: - if_can_participate MON_1, ContestEffectEnd2 - if_can_participate MON_2, ContestEffectEnd2 - if_can_participate MON_3, ContestEffectEnd2 +AI_CBM_DependsOnPrevMons_Last: + if_can_participate MON_1, AI_CBM_End + if_can_participate MON_2, AI_CBM_End + if_can_participate MON_3, AI_CBM_End score -15 end -ContestEffect2_25: - if_user_order_eq MON_1, ContestEffect2_25_score1 - if_user_order_eq MON_2, ContestEffect2_25_score2 - if_user_order_eq MON_3, ContestEffect2_25_score3 +@ If next mon is skipping turn (or user is last), discourage move +AI_CBM_DependsOnNextMon: + if_user_order_eq MON_1, AI_CBM_DependsOnNextMon_1stUp + if_user_order_eq MON_2, AI_CBM_DependsOnNextMon_2ndUp + if_user_order_eq MON_3, AI_CBM_DependsOnNextMon_3rdUp score -10 end -ContestEffect2_25_score1: - if_can_participate MON_2, ContestEffectEnd2 +AI_CBM_DependsOnNextMon_1stUp: + if_can_participate MON_2, AI_CBM_End score -10 end -ContestEffect2_25_score2: - if_can_participate MON_3, ContestEffectEnd2 +AI_CBM_DependsOnNextMon_2ndUp: + if_can_participate MON_3, AI_CBM_End score -10 end -ContestEffect2_25_score3: - if_can_participate MON_4, ContestEffectEnd2 +AI_CBM_DependsOnNextMon_3rdUp: + if_can_participate MON_4, AI_CBM_End score -10 end -ContestEffect2_26: - if_user_order_eq MON_1, ContestEffect2_26_score1 - if_user_order_eq MON_2, ContestEffect2_26_score2 - if_user_order_eq MON_3, ContestEffect2_26_score3 +@ If next mons are all skipping turns (or user is last), discourage move +AI_CBM_DependsOnNextMons: + if_user_order_eq MON_1, AI_CBM_DependsOnNextMons_1stUp + if_user_order_eq MON_2, AI_CBM_DependsOnNextMons_2ndUp + if_user_order_eq MON_3, AI_CBM_DependsOnNextMons_3rdUp score -10 end -ContestEffect2_26_score1: - if_can_participate MON_2, ContestEffectEnd2 - if_can_participate MON_3, ContestEffectEnd2 - if_can_participate MON_4, ContestEffectEnd2 +AI_CBM_DependsOnNextMons_1stUp: + if_can_participate MON_2, AI_CBM_End + if_can_participate MON_3, AI_CBM_End + if_can_participate MON_4, AI_CBM_End score -10 end -ContestEffect2_26_score2: - if_can_participate MON_3, ContestEffectEnd2 - if_can_participate MON_4, ContestEffectEnd2 +AI_CBM_DependsOnNextMons_2ndUp: + if_can_participate MON_3, AI_CBM_End + if_can_participate MON_4, AI_CBM_End score -10 end -ContestEffect2_26_score3: - if_can_participate MON_4, ContestEffectEnd2 +AI_CBM_DependsOnNextMons_3rdUp: + if_can_participate MON_4, AI_CBM_End score -10 end -ContestEffect2_38: - if_user_condition_less_than 3, ContestEffectEnd2 +@ If at max condition, discourage move +AI_CBM_ImproveCondition: + if_user_condition_less_than 3, AI_CBM_End score -20 end -ContestEffect2_4: - if_user_order_eq MON_1, ContestEffect2_4_score1 - if_user_order_eq MON_2, ContestEffect2_4_score2 - if_user_order_eq MON_3, ContestEffect2_4_score3 +@ If there are no upcoming mons who can make an appeal (or if user is last), discourage move +@ Identical to AI_CBM_DependsOnNextMons +AI_CBM_AvoidStartle: + if_user_order_eq MON_1, AI_CBM_AvoidStartle_1stUp + if_user_order_eq MON_2, AI_CBM_AvoidStartle_2ndUp + if_user_order_eq MON_3, AI_CBM_AvoidStartle_3rdUp score -10 end -ContestEffect2_4_score1: - if_can_participate MON_2, ContestEffectEnd2 - if_can_participate MON_3, ContestEffectEnd2 - if_can_participate MON_4, ContestEffectEnd2 +AI_CBM_AvoidStartle_1stUp: + if_can_participate MON_2, AI_CBM_End + if_can_participate MON_3, AI_CBM_End + if_can_participate MON_4, AI_CBM_End score -10 end -ContestEffect2_4_score2: - if_can_participate MON_3, ContestEffectEnd2 - if_can_participate MON_4, ContestEffectEnd2 +AI_CBM_AvoidStartle_2ndUp: + if_can_participate MON_3, AI_CBM_End + if_can_participate MON_4, AI_CBM_End score -10 end -ContestEffect2_4_score3: - if_can_participate MON_4, ContestEffectEnd2 +AI_CBM_AvoidStartle_3rdUp: + if_can_participate MON_4, AI_CBM_End score -10 end -ContestEffect2_2: - if_appeal_num_eq 0, ContestEffect2_2_score1 - if_appeal_num_eq 1, ContestEffect2_2_score2 - if_appeal_num_eq 2, ContestEffect2_2_score3 - if_appeal_num_eq 3, ContestEffect2_2_score4 - if_last_appeal ContestEffect2_2_score5 +@ Very good if its the last appeal, otherwise discourage move +AI_CBM_NoMoreMoves: + if_appeal_num_eq 0, AI_CBM_NoMoreMoves_1stAppeal + if_appeal_num_eq 1, AI_CBM_NoMoreMoves_2ndAppeal + if_appeal_num_eq 2, AI_CBM_NoMoreMoves_3rdAppeal + if_appeal_num_eq 3, AI_CBM_NoMoreMoves_4thAppeal + if_last_appeal AI_CBM_NoMoreMoves_LastAppeal end -ContestEffect2_2_score1: - if_random 20, ContestEffectEnd2 +AI_CBM_NoMoreMoves_1stAppeal: + if_random_less_than 20, AI_CBM_End score -15 end -ContestEffect2_2_score2: - if_random 40, ContestEffectEnd2 +AI_CBM_NoMoreMoves_2ndAppeal: + if_random_less_than 40, AI_CBM_End score -15 end -ContestEffect2_2_score3: - if_random 60, ContestEffectEnd2 +AI_CBM_NoMoreMoves_3rdAppeal: + if_random_less_than 60, AI_CBM_End score -15 end -ContestEffect2_2_score4: - if_random 80, ContestEffectEnd2 +AI_CBM_NoMoreMoves_4thAppeal: + if_random_less_than 80, AI_CBM_End score -15 end -ContestEffect2_2_score5: - if_random 20, ContestEffectEnd2 +AI_CBM_NoMoreMoves_LastAppeal: + if_random_less_than 20, AI_CBM_End score +20 end -ContestEffectEnd2: +AI_CBM_End: end +@ Encourages/discourages move affected by the move order +@ e.g. use BETTER_IF_FIRST moves if user is first, dont use AVOID_STARTLE moves if last AI_CheckOrder: - if_user_order_eq MON_1, AI_effectcheck1_081DCA4C - if_user_order_eq MON_2, AI_effectcheck2_081DCA4C - if_user_order_eq MON_3, AI_effectcheck3_081DCA4C - if_user_order_eq MON_4, AI_effectcheck4_081DCA4C + if_user_order_eq MON_1, AI_CheckOrder_1stUp + if_user_order_eq MON_2, AI_CheckOrder_2ndUp + if_user_order_eq MON_3, AI_CheckOrder_3rdUp + if_user_order_eq MON_4, AI_CheckOrder_Last end -AI_effectcheck1_081DCA4C: - if_effect_eq CONTEST_EFFECT_BETTER_IF_FIRST, AI_score1_081DCA4C - if_effect_eq CONTEST_EFFECT_BETTER_WHEN_LATER, AI_score2_081DCA4C - if_effect_type_eq 1, AI_random1_081DCA4C +AI_CheckOrder_1stUp: + if_effect_eq CONTEST_EFFECT_BETTER_IF_FIRST, AI_CheckOrder_1stUp_Encourage + if_effect_eq CONTEST_EFFECT_BETTER_WHEN_LATER, AI_CheckOrder_1stUp_Discourage + if_effect_type_eq CONTEST_EFFECT_TYPE_AVOID_STARTLE, AI_CheckOrder_1stUp_RandomEncourage end -AI_score1_081DCA4C: +AI_CheckOrder_1stUp_Encourage: score +15 end -AI_score2_081DCA4C: +AI_CheckOrder_1stUp_Discourage: score -15 end -AI_random1_081DCA4C: - if_random 100, ContestEffectEnd2 +AI_CheckOrder_1stUp_RandomEncourage: + if_random_less_than 100, AI_CBM_End score +10 end -AI_effectcheck2_081DCA4C: - if_effect_eq CONTEST_EFFECT_BETTER_WHEN_LATER, AI_score3_081DCA4C - if_effect_type_eq 1, AI_random2_081DCA4C +AI_CheckOrder_2ndUp: + if_effect_eq CONTEST_EFFECT_BETTER_WHEN_LATER, AI_CheckOrder_2ndUp_Discourage + if_effect_type_eq CONTEST_EFFECT_TYPE_AVOID_STARTLE, AI_CheckOrder_2ndUp_RandomEncourage end -AI_score3_081DCA4C: +AI_CheckOrder_2ndUp_Discourage: score -5 end -AI_random2_081DCA4C: - if_random 125, ContestEffectEnd2 +AI_CheckOrder_2ndUp_RandomEncourage: + if_random_less_than 125, AI_CBM_End score +10 end -AI_effectcheck3_081DCA4C: - if_effect_eq CONTEST_EFFECT_BETTER_WHEN_LATER, AI_score4_081DCA4C - if_effect_eq CONTEST_EFFECT_APPEAL_AS_GOOD_AS_PREV_ONES, AI_score4_081DCA4C - if_effect_eq CONTEST_EFFECT_USER_MORE_EASILY_STARTLED, AI_score4_081DCA4C +AI_CheckOrder_3rdUp: + if_effect_eq CONTEST_EFFECT_BETTER_WHEN_LATER, AI_CheckOrder_3rdUp_Encourage + if_effect_eq CONTEST_EFFECT_APPEAL_AS_GOOD_AS_PREV_ONES, AI_CheckOrder_3rdUp_Encourage + if_effect_eq CONTEST_EFFECT_USER_MORE_EASILY_STARTLED, AI_CheckOrder_3rdUp_Encourage end -AI_score4_081DCA4C: +AI_CheckOrder_3rdUp_Encourage: score +5 end -AI_effectcheck4_081DCA4C: - if_effect_eq CONTEST_EFFECT_BETTER_WHEN_LATER, AI_score5_081DCA4C - if_effect_eq CONTEST_EFFECT_BETTER_IF_LAST, AI_score5_081DCA4C - if_effect_eq CONTEST_EFFECT_APPEAL_AS_GOOD_AS_PREV_ONES, AI_score5_081DCA4C - if_effect_eq CONTEST_EFFECT_USER_MORE_EASILY_STARTLED, AI_score5_081DCA4C - if_effect_eq CONTEST_EFFECT_JAMS_OTHERS_BUT_MISS_ONE_TURN, AI_score7_081DCA4C - if_effect_type_eq 1, AI_score6_081DCA4C - if_effect_type_eq 3, AI_random3_081DCA4C +AI_CheckOrder_Last: + if_effect_eq CONTEST_EFFECT_BETTER_WHEN_LATER, AI_CheckOrder_Last_StronglyEncourage + if_effect_eq CONTEST_EFFECT_BETTER_IF_LAST, AI_CheckOrder_Last_StronglyEncourage + if_effect_eq CONTEST_EFFECT_APPEAL_AS_GOOD_AS_PREV_ONES, AI_CheckOrder_Last_StronglyEncourage + if_effect_eq CONTEST_EFFECT_USER_MORE_EASILY_STARTLED, AI_CheckOrder_Last_StronglyEncourage + if_effect_eq CONTEST_EFFECT_JAMS_OTHERS_BUT_MISS_ONE_TURN, AI_CheckOrder_Last_Encourage + if_effect_type_eq CONTEST_EFFECT_TYPE_AVOID_STARTLE, AI_CheckOrder_Last_Discourage + if_effect_type_eq CONTEST_EFFECT_TYPE_STARTLE_MONS, AI_CheckOrder_Last_RandomEncourage end -AI_score5_081DCA4C: +AI_CheckOrder_Last_StronglyEncourage: score +15 end -AI_score6_081DCA4C: +AI_CheckOrder_Last_Discourage: score -10 end -AI_random3_081DCA4C: - if_random 125, ContestEffectEnd2 +AI_CheckOrder_Last_RandomEncourage: + if_random_less_than 125, AI_CBM_End score +10 end -AI_score7_081DCA4C: +AI_CheckOrder_Last_Encourage: score +5 end diff --git a/gflib/text.c b/gflib/text.c index 07fd23109..636fe50a9 100644 --- a/gflib/text.c +++ b/gflib/text.c @@ -475,15 +475,15 @@ u8 GetLastTextColor(u8 colorType) \ for (; i < toY; i++) \ { \ - asm("":::"sl"); \ + asm("":::"sl"); /* NONMATCHING */ \ r5 = *(ptr++); \ for (j = fromX; j < toX; j++) \ { \ const u32 toOrr = r5 & 0xF; \ if (toOrr) \ { \ - dst = windowTiles + ((j / 8) * 32) + ((j & 7) >> 1) + ((i / 8) * widthOffset) + ((i & 7) * 4); \ - bits = ((j & 1) * 4); \ + dst = windowTiles + ((j / 8) * 32) + ((j & 7) >> 1) + ((i / 8) * widthOffset) + ((i & 7) * 4); \ + bits = ((j & 1) * 4); \ *dst = (toOrr << bits) | ((0xF0 >> bits) & *dst); \ } \ r5 >>= 4; \ diff --git a/include/constants/contest.h b/include/constants/contest.h index 5ec4c4f69..9eb6b26e4 100644 --- a/include/constants/contest.h +++ b/include/constants/contest.h @@ -52,6 +52,37 @@ #define CONTEST_AI_CHECK_ORDER (1 << 4) #define CONTEST_AI_CHECK_GOOD_MOVE (1 << 5) #define CONTEST_AI_ERRATIC (1 << 6) +#define CONTEST_AI_DUMMY_1 (1 << 7) +#define CONTEST_AI_DUMMY_2 (1 << 8) +#define CONTEST_AI_DUMMY_3 (1 << 9) +#define CONTEST_AI_DUMMY_4 (1 << 10) +#define CONTEST_AI_DUMMY_5 (1 << 11) +#define CONTEST_AI_DUMMY_6 (1 << 12) +#define CONTEST_AI_DUMMY_7 (1 << 13) +#define CONTEST_AI_DUMMY_8 (1 << 14) +#define CONTEST_AI_DUMMY_9 (1 << 15) +#define CONTEST_AI_DUMMY_10 (1 << 16) +#define CONTEST_AI_DUMMY_11 (1 << 17) +#define CONTEST_AI_DUMMY_12 (1 << 18) +#define CONTEST_AI_DUMMY_13 (1 << 19) +#define CONTEST_AI_DUMMY_14 (1 << 20) +#define CONTEST_AI_DUMMY_15 (1 << 21) +#define CONTEST_AI_DUMMY_16 (1 << 22) +#define CONTEST_AI_DUMMY_17 (1 << 23) +#define CONTEST_AI_DUMMY_18 (1 << 24) +#define CONTEST_AI_DUMMY_19 (1 << 25) +#define CONTEST_AI_DUMMY_20 (1 << 26) +#define CONTEST_AI_DUMMY_21 (1 << 27) +#define CONTEST_AI_DUMMY_22 (1 << 28) +#define CONTEST_AI_DUMMY_23 (1 << 29) +#define CONTEST_AI_DUMMY_24 (1 << 30) +#define CONTEST_AI_DUMMY_25 (1 << 31) + +// The below scripts are used by every AI contest opponent +// It includes every non-dummy script +#define CONTEST_AI_COMMON (CONTEST_AI_CHECK_BAD_MOVE | CONTEST_AI_CHECK_COMBO | CONTEST_AI_CHECK_BORING | \ + CONTEST_AI_CHECK_EXCITEMENT | CONTEST_AI_CHECK_ORDER | CONTEST_AI_CHECK_GOOD_MOVE | CONTEST_AI_ERRATIC | \ + CONTEST_AI_DUMMY_1 | CONTEST_AI_DUMMY_2 | CONTEST_AI_DUMMY_3 | CONTEST_AI_DUMMY_4 | CONTEST_AI_DUMMY_5) #define CONTEST_EFFECT_HIGHLY_APPEALING 0 #define CONTEST_EFFECT_USER_MORE_EASILY_STARTLED 1 @@ -102,6 +133,16 @@ #define CONTEST_EFFECT_BETTER_WHEN_AUDIENCE_EXCITED 46 #define CONTEST_EFFECT_DONT_EXCITE_AUDIENCE 47 +// Each of the above effects is grouped into one of these effect type categories +// Only a few of these get checked by the AI, the rest go unused +#define CONTEST_EFFECT_TYPE_APPEAL 0 +#define CONTEST_EFFECT_TYPE_AVOID_STARTLE 1 +#define CONTEST_EFFECT_TYPE_STARTLE_MON 2 +#define CONTEST_EFFECT_TYPE_STARTLE_MONS 3 +#define CONTEST_EFFECT_TYPE_WORSEN 4 +#define CONTEST_EFFECT_TYPE_SPECIAL_APPEAL 5 +#define CONTEST_EFFECT_TYPE_TURN_ORDER 6 + #define COMBO_STARTER_RAIN_DANCE 1 #define COMBO_STARTER_RAGE 2 #define COMBO_STARTER_FOCUS_ENERGY 3 diff --git a/include/constants/pokemon.h b/include/constants/pokemon.h index 286726838..f026fa0e3 100644 --- a/include/constants/pokemon.h +++ b/include/constants/pokemon.h @@ -230,6 +230,7 @@ #define STATUS_PRIMARY_POKERUS 6 #define STATUS_PRIMARY_FAINTED 7 +#define MAX_PER_STAT_EVS 255 #define MAX_TOTAL_EVS 510 #define EV_ITEM_RAISE_LIMIT 100 diff --git a/include/contest.h b/include/contest.h index d008b8fce..1dd4340bd 100644 --- a/include/contest.h +++ b/include/contest.h @@ -90,7 +90,7 @@ struct ContestPokemon u8 nickname[POKEMON_NAME_LENGTH + 1]; u8 trainerName[PLAYER_NAME_LENGTH + 1]; u8 trainerGfxId; - u32 aiChecks; + u32 aiFlags; u8 whichRank:2; u8 aiPool_Cool:1; u8 aiPool_Beauty:1; @@ -201,7 +201,7 @@ struct ContestantStatus bool8 repeatedMove:1; bool8 unused2:1; bool8 repeatedPrevMove:1; // never read - bool8 unk15_3:1; + bool8 completedComboFlag:1; bool8 hasJudgesAttention:1; bool8 judgesAttentionWasRemoved:1; bool8 usedComboMove:1; @@ -231,10 +231,10 @@ struct ContestAIInfo /*0x05*/ u8 moveScores[MAX_MON_MOVES]; /*0x09*/ u8 aiAction; /*0x0A*/ u8 filler[6]; - /*0x10*/ u8 currentAICheck; - /*0x14*/ u32 aiChecks; + /*0x10*/ u8 currentAIFlag; + /*0x14*/ u32 aiFlags; /*0x18*/ s16 scriptResult; - /*0x1A*/ s16 scriptArr[3]; + /*0x1A*/ s16 vars[3]; /*0x20*/ const u8 *stack[8]; /*0x40*/ u8 stackSize; /*0x41*/ u8 contestantId; diff --git a/include/menu.h b/include/menu.h index a57b3718f..1bd800742 100644 --- a/include/menu.h +++ b/include/menu.h @@ -8,6 +8,12 @@ #define MENU_NOTHING_CHOSEN -2 #define MENU_B_PRESSED -1 +#define MENU_CURSOR_DELTA_NONE 0 +#define MENU_CURSOR_DELTA_UP -1 +#define MENU_CURSOR_DELTA_DOWN 1 +#define MENU_CURSOR_DELTA_LEFT -1 +#define MENU_CURSOR_DELTA_RIGHT 1 + enum { SAVE_MENU_NAME, @@ -77,7 +83,7 @@ void AddTextPrinterForMessage(bool8 allowSkippingDelayWithButtonPress); void AddItemMenuActionTextPrinters(u8 windowId, u8 fontId, u8 left, u8 top, u8 letterSpacing, u8 lineHeight, u8 itemCount, const struct MenuAction *strs, const u8 *a8); void sub_8198DBC(u8 windowId, u8 fontId, u8 left, u8 top, u8 a4, u8 itemCount, u8 itemCount2, const struct MenuAction *strs, const u8 *a8); u8 sub_8199944(u8 windowId, u8 optionWidth, u8 columns, u8 rows, u8 initialCursorPos); -u8 sub_8199134(s8, s8); +u8 ChangeListMenuCursorPosition(s8 deltaX, s8 deltaY); u8 GetStartMenuWindowId(void); void ListMenuLoadStdPalAt(u8, u8); u8 Menu_MoveCursor(s8 cursorDelta); diff --git a/src/battle_gfx_sfx_util.c b/src/battle_gfx_sfx_util.c index 83818798a..b1bb61aaf 100644 --- a/src/battle_gfx_sfx_util.c +++ b/src/battle_gfx_sfx_util.c @@ -1014,15 +1014,12 @@ void BattleLoadSubstituteOrMonSpriteGfx(u8 battlerId, bool8 loadMonSprite) palOffset = (battlerId * 16) + 0x100; LoadCompressedPalette(gSubstituteDollPal, palOffset, 32); } - else + else if (!IsContest()) { - if (!IsContest()) - { - if (GetBattlerSide(battlerId) != B_SIDE_PLAYER) - BattleLoadOpponentMonSpriteGfx(&gEnemyParty[gBattlerPartyIndexes[battlerId]], battlerId); - else - BattleLoadPlayerMonSpriteGfx(&gPlayerParty[gBattlerPartyIndexes[battlerId]], battlerId); - } + if (GetBattlerSide(battlerId) != B_SIDE_PLAYER) + BattleLoadOpponentMonSpriteGfx(&gEnemyParty[gBattlerPartyIndexes[battlerId]], battlerId); + else + BattleLoadPlayerMonSpriteGfx(&gPlayerParty[gBattlerPartyIndexes[battlerId]], battlerId); } } diff --git a/src/battle_main.c b/src/battle_main.c index 43ee1dde1..935a53ffe 100644 --- a/src/battle_main.c +++ b/src/battle_main.c @@ -4851,40 +4851,38 @@ static void SetActionsAndBattlersTurnOrder(void) gBattleStruct->focusPunchBattlerId = 0; return; } - else + for (gActiveBattler = 0; gActiveBattler < gBattlersCount; gActiveBattler++) { - for (gActiveBattler = 0; gActiveBattler < gBattlersCount; gActiveBattler++) + if (gChosenActionByBattler[gActiveBattler] == B_ACTION_USE_ITEM || gChosenActionByBattler[gActiveBattler] == B_ACTION_SWITCH) { - if (gChosenActionByBattler[gActiveBattler] == B_ACTION_USE_ITEM || gChosenActionByBattler[gActiveBattler] == B_ACTION_SWITCH) - { - gActionsByTurnOrder[turnOrderId] = gChosenActionByBattler[gActiveBattler]; - gBattlerByTurnOrder[turnOrderId] = gActiveBattler; - turnOrderId++; - } + gActionsByTurnOrder[turnOrderId] = gChosenActionByBattler[gActiveBattler]; + gBattlerByTurnOrder[turnOrderId] = gActiveBattler; + turnOrderId++; } - for (gActiveBattler = 0; gActiveBattler < gBattlersCount; gActiveBattler++) + } + for (gActiveBattler = 0; gActiveBattler < gBattlersCount; gActiveBattler++) + { + if (gChosenActionByBattler[gActiveBattler] != B_ACTION_USE_ITEM && gChosenActionByBattler[gActiveBattler] != B_ACTION_SWITCH) { - if (gChosenActionByBattler[gActiveBattler] != B_ACTION_USE_ITEM && gChosenActionByBattler[gActiveBattler] != B_ACTION_SWITCH) - { - gActionsByTurnOrder[turnOrderId] = gChosenActionByBattler[gActiveBattler]; - gBattlerByTurnOrder[turnOrderId] = gActiveBattler; - turnOrderId++; - } + gActionsByTurnOrder[turnOrderId] = gChosenActionByBattler[gActiveBattler]; + gBattlerByTurnOrder[turnOrderId] = gActiveBattler; + turnOrderId++; } - for (i = 0; i < gBattlersCount - 1; i++) + } + for (i = 0; i < gBattlersCount - 1; i++) + { + for (j = i + 1; j < gBattlersCount; j++) { - for (j = i + 1; j < gBattlersCount; j++) + u8 battler1 = gBattlerByTurnOrder[i]; + u8 battler2 = gBattlerByTurnOrder[j]; + + if (gActionsByTurnOrder[i] != B_ACTION_USE_ITEM + && gActionsByTurnOrder[j] != B_ACTION_USE_ITEM + && gActionsByTurnOrder[i] != B_ACTION_SWITCH + && gActionsByTurnOrder[j] != B_ACTION_SWITCH) { - u8 battler1 = gBattlerByTurnOrder[i]; - u8 battler2 = gBattlerByTurnOrder[j]; - if (gActionsByTurnOrder[i] != B_ACTION_USE_ITEM - && gActionsByTurnOrder[j] != B_ACTION_USE_ITEM - && gActionsByTurnOrder[i] != B_ACTION_SWITCH - && gActionsByTurnOrder[j] != B_ACTION_SWITCH) - { - if (GetWhoStrikesFirst(battler1, battler2, FALSE)) - SwapTurnOrder(i, j); - } + if (GetWhoStrikesFirst(battler1, battler2, FALSE)) + SwapTurnOrder(i, j); } } } @@ -4962,12 +4960,8 @@ static void CheckFocusPunch_ClearVarsBeforeTurnStarts(void) } TryClearRageStatuses(); - gCurrentTurnActionNumber = 0; -{ - // something stupid needed to match - u8 zero; - gCurrentActionFuncId = gActionsByTurnOrder[(zero = 0)]; -} + gCurrentTurnActionNumber = 0; //See comment underneath + gCurrentActionFuncId = gActionsByTurnOrder[gCurrentTurnActionNumber]; //Should be gActionsByTurnOrder[(gCurrentTurnActionNumber = 0)], but that doesn't match gDynamicBasePower = 0; gBattleStruct->dynamicMoveType = 0; gBattleMainFunc = RunTurnActionsFunctions; @@ -4990,13 +4984,10 @@ static void RunTurnActionsFunctions(void) gHitMarker &= ~(HITMARKER_x100000); gBattleMainFunc = sEndTurnFuncsTable[gBattleOutcome & 0x7F]; } - else + else if (gBattleStruct->savedTurnActionNumber != gCurrentTurnActionNumber) // action turn has been done, clear hitmarker bits for another battlerId { - if (gBattleStruct->savedTurnActionNumber != gCurrentTurnActionNumber) // action turn has been done, clear hitmarker bits for another battlerId - { - gHitMarker &= ~(HITMARKER_NO_ATTACKSTRING); - gHitMarker &= ~(HITMARKER_UNABLE_TO_USE_MOVE); - } + gHitMarker &= ~(HITMARKER_NO_ATTACKSTRING); + gHitMarker &= ~(HITMARKER_UNABLE_TO_USE_MOVE); } } diff --git a/src/battle_pyramid_bag.c b/src/battle_pyramid_bag.c index 33daed80c..e038e71e1 100644 --- a/src/battle_pyramid_bag.c +++ b/src/battle_pyramid_bag.c @@ -970,7 +970,7 @@ static void HandleMenuActionInput(u8 taskId) if (id > 0 && IsValidMenuAction(id - 2)) { PlaySE(SE_SELECT); - sub_8199134(0, -1); + ChangeListMenuCursorPosition(MENU_CURSOR_DELTA_NONE, MENU_CURSOR_DELTA_UP); } } else if (gMain.newKeys & DPAD_DOWN) @@ -978,7 +978,7 @@ static void HandleMenuActionInput(u8 taskId) if (id < gPyramidBagResources->menuActionsCount - 2 && IsValidMenuAction(id + 2)) { PlaySE(SE_SELECT); - sub_8199134(0, 1); + ChangeListMenuCursorPosition(MENU_CURSOR_DELTA_NONE, MENU_CURSOR_DELTA_DOWN); } } else if (gMain.newKeys & DPAD_LEFT || GetLRKeysPressed() == MENU_L_PRESSED) @@ -986,7 +986,7 @@ static void HandleMenuActionInput(u8 taskId) if (id & 1 && IsValidMenuAction(id - 1)) { PlaySE(SE_SELECT); - sub_8199134(-1, 0); + ChangeListMenuCursorPosition(MENU_CURSOR_DELTA_LEFT, MENU_CURSOR_DELTA_NONE); } } else if (gMain.newKeys & DPAD_RIGHT || GetLRKeysPressed() == MENU_R_PRESSED) @@ -994,7 +994,7 @@ static void HandleMenuActionInput(u8 taskId) if (!(id & 1) && IsValidMenuAction(id + 1)) { PlaySE(SE_SELECT); - sub_8199134(1, 0); + ChangeListMenuCursorPosition(MENU_CURSOR_DELTA_RIGHT, MENU_CURSOR_DELTA_NONE); } } else if (gMain.newKeys & A_BUTTON) diff --git a/src/battle_tent.c b/src/battle_tent.c index b2db0e39c..0a03fc167 100644 --- a/src/battle_tent.c +++ b/src/battle_tent.c @@ -355,7 +355,11 @@ static void GenerateOpponentMons(void) { u16 trainerId; s32 i, j, k; - register const u16 *monSet asm("r9"); // Fix me. Compiler insists on moving that variable into stack. + #ifndef NONMATCHING + register const u16 *monSet asm("r9"); // Fix me. Compiler insists on moving that variable into stack. + #else + const u16 *monSet; + #endif u16 species[FRONTIER_PARTY_SIZE]; u16 heldItems[FRONTIER_PARTY_SIZE]; s32 monId = 0; diff --git a/src/battle_tower.c b/src/battle_tower.c index 09c9f0416..0333c4397 100644 --- a/src/battle_tower.c +++ b/src/battle_tower.c @@ -1466,7 +1466,9 @@ u8 GetFrontierOpponentClass(u16 trainerId) else { trainerClass = gFacilityClassToTrainerClass[gSaveBlock2Ptr->frontier.towerRecords[trainerId - TRAINER_RECORD_MIXING_FRIEND].facilityClass]; - asm(""); + #ifndef NONMATCHING + asm(""); + #endif } } else @@ -1478,7 +1480,9 @@ u8 GetFrontierOpponentClass(u16 trainerId) else { trainerClass = gFacilityClassToTrainerClass[gApprentices[gSaveBlock2Ptr->apprentices[trainerId - TRAINER_RECORD_MIXING_APPRENTICE].id].facilityClass]; - asm(""); + #ifndef NONMATCHING + asm(""); + #endif } } diff --git a/src/battle_transition.c b/src/battle_transition.c index 4a290cce7..559279e74 100644 --- a/src/battle_transition.c +++ b/src/battle_transition.c @@ -3974,7 +3974,9 @@ static bool8 Phase2_FrontierLogoWave_Func4(struct Task *task) for (i = 0; i < 160; i++, var6 += var8) { s16 index = var6 / 256; - asm(""); + #ifndef NONMATCHING + asm(""); + #endif gScanlineEffectRegBuffers[0][i] = sTransitionStructPtr->field_16 + Sin(index, amplitude); } diff --git a/src/contest.c b/src/contest.c index e5bf62e75..fbd42a007 100644 --- a/src/contest.c +++ b/src/contest.c @@ -999,8 +999,6 @@ void ResetLinkContestBoolean(void) static void SetupContestGpuRegs(void) { - u16 savedIme; - SetGpuReg(REG_OFFSET_DISPCNT, DISPCNT_OBJ_1D_MAP); SetGpuReg(REG_OFFSET_BLDCNT, 0); SetGpuReg(REG_OFFSET_BLDALPHA, 0); @@ -2789,7 +2787,7 @@ void CreateContestMonFromParty(u8 partyIndex) gContestMons[gContestPlayerMonIndex].trainerGfxId = OBJ_EVENT_GFX_LINK_BRENDAN; else gContestMons[gContestPlayerMonIndex].trainerGfxId = OBJ_EVENT_GFX_LINK_MAY; - gContestMons[gContestPlayerMonIndex].aiChecks = 0; + gContestMons[gContestPlayerMonIndex].aiFlags = 0; gContestMons[gContestPlayerMonIndex].highestRank = 0; gContestMons[gContestPlayerMonIndex].species = GetMonData(&gPlayerParty[partyIndex], MON_DATA_SPECIES); GetMonData(&gPlayerParty[partyIndex], MON_DATA_NICKNAME, name); @@ -3410,8 +3408,7 @@ static void GetAllChosenMoves(void) static void RankContestants(void) { - s32 i; - s32 j; + s32 i, j; s16 arr[CONTESTANT_COUNT]; for (i = 0; i < CONTESTANT_COUNT; i++) @@ -3486,11 +3483,10 @@ static bool8 ContestantCanUseTurn(u8 contestant) { if (eContestantStatus[contestant].numTurnsSkipped != 0 || eContestantStatus[contestant].noMoreTurns) return FALSE; - else - return TRUE; + return TRUE; } -static void ResetContestantStatuses(void) +static void SetContestantStatusesForNextRound(void) { s32 i; @@ -3541,8 +3537,7 @@ bool8 Contest_IsMonsTurnDisabled(u8 contestant) { if (eContestantStatus[contestant].numTurnsSkipped != 0 || eContestantStatus[contestant].noMoreTurns) return TRUE; - else - return FALSE; + return FALSE; } static void CalculateTotalPointsForContestant(u8 contestant) @@ -4483,19 +4478,16 @@ static void CalculateAppealMoveImpact(u8 contestant) eContestantStatus[contestant].usedComboMove = TRUE; eContestantStatus[contestant].hasJudgesAttention = FALSE; eContestantStatus[contestant].comboAppealBonus = eContestantStatus[contestant].baseAppeal * eContestantStatus[contestant].completedCombo; - eContestantStatus[contestant].unk15_3 = TRUE; + eContestantStatus[contestant].completedComboFlag = TRUE; // Redundant with completedCombo, used by AI + } + else if (gContestMoves[eContestantStatus[contestant].currMove].comboStarterId != 0) + { + eContestantStatus[contestant].hasJudgesAttention = TRUE; + eContestantStatus[contestant].usedComboMove = TRUE; } else { - if (gContestMoves[eContestantStatus[contestant].currMove].comboStarterId != 0) - { - eContestantStatus[contestant].hasJudgesAttention = TRUE; - eContestantStatus[contestant].usedComboMove = TRUE; - } - else - { - eContestantStatus[contestant].hasJudgesAttention = FALSE; - } + eContestantStatus[contestant].hasJudgesAttention = FALSE; } } if (eContestantStatus[contestant].repeatedMove) @@ -5172,7 +5164,7 @@ static void Task_ResetForNextRound(u8 taskId) eContest.waitForLink = TRUE; if (IsPlayerLinkLeader()) - ResetContestantStatuses(); + SetContestantStatusesForNextRound(); taskId2 = CreateTask(Task_LinkContest_CommunicateAppealsState, 0); SetTaskFuncWithFollowupFunc(taskId2, Task_LinkContest_CommunicateAppealsState, Task_EndWaitForLink); ContestPrintLinkStandby(); @@ -5180,7 +5172,7 @@ static void Task_ResetForNextRound(u8 taskId) } else { - ResetContestantStatuses(); + SetContestantStatusesForNextRound(); gTasks[taskId].data[0] = 3; } break; @@ -5620,7 +5612,7 @@ void ClearContestWinnerPicsInContestHall(void) s32 i; for (i = 0; i < 8; i++) - gSaveBlock1Ptr->contestWinners[i] = gUnknown_08587FA4[i]; + gSaveBlock1Ptr->contestWinners[i] = gDefaultContestWinners[i]; } static void SetContestLiveUpdateFlags(u8 contestant) diff --git a/src/contest_ai.c b/src/contest_ai.c index b5e91c314..2f048718f 100644 --- a/src/contest_ai.c +++ b/src/contest_ai.c @@ -7,7 +7,7 @@ #include "constants/moves.h" extern const u8 *gAIScriptPtr; -extern const u8 *gContestAIChecks[]; +extern const u8 *gContestAI_ScriptsTable[]; static void ContestAICmd_score(void); static void ContestAICmd_get_appeal_num(void); @@ -30,22 +30,22 @@ 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); -static void ContestAICmd_unk_15(void); -static void ContestAICmd_unk_16(void); -static void ContestAICmd_unk_17(void); -static void ContestAICmd_unk_18(void); -static void ContestAICmd_unk_19(void); -static void ContestAICmd_unk_1A(void); -static void ContestAICmd_unk_1B(void); -static void ContestAICmd_unk_1C(void); -static void ContestAICmd_unk_1D(void); -static void ContestAICmd_unk_1E(void); +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); static void ContestAICmd_get_contest_type(void); static void ContestAICmd_if_contest_type_eq(void); static void ContestAICmd_if_contest_type_not_eq(void); static void ContestAICmd_get_move_excitement(void); static void ContestAICmd_if_move_excitement_less_than(void); -static void ContestAICmd_if_move_excitement_greater_than(void); +static void ContestAICmd_if_move_excitement_more_than(void); static void ContestAICmd_if_move_excitement_eq(void); static void ContestAICmd_if_move_excitement_not_eq(void); static void ContestAICmd_get_move_effect(void); @@ -56,18 +56,18 @@ 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); -static void ContestAICmd_unk_2F(void); -static void ContestAICmd_unk_30(void); -static void ContestAICmd_unk_31(void); -static void ContestAICmd_unk_32(void); -static void ContestAICmd_unk_33(void); -static void ContestAICmd_unk_34(void); -static void ContestAICmd_unk_35(void); -static void ContestAICmd_unk_36(void); -static void ContestAICmd_unk_37(void); -static void ContestAICmd_unk_38(void); -static void ContestAICmd_unk_39(void); -static void ContestAICmd_unk_3A(void); +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); static void ContestAICmd_get_move_used_count(void); static void ContestAICmd_if_most_used_count_less_than(void); static void ContestAICmd_if_most_used_count_more_than(void); @@ -95,197 +95,197 @@ static void ContestAICmd_if_used_combo_starter_not_eq(void); static void ContestAICmd_check_can_participate(void); static void ContestAICmd_if_can_participate(void); static void ContestAICmd_if_cannot_participate(void); -static void ContestAICmd_get_val_812A188(void); -static void ContestAICmd_unk_57(void); -static void ContestAICmd_contest_58(void); -static void ContestAICmd_unk_59(void); -static void ContestAICmd_unk_5A(void); -static void ContestAICmd_unk_5B(void); -static void ContestAICmd_unk_5C(void); -static void ContestAICmd_unk_5D(void); -static void ContestAICmd_unk_5E(void); -static void ContestAICmd_unk_5F(void); -static void ContestAICmd_unk_60(void); -static void ContestAICmd_unk_61(void); -static void ContestAICmd_unk_62(void); -static void ContestAICmd_unk_63(void); -static void ContestAICmd_unk_64(void); -static void ContestAICmd_unk_65(void); -static void ContestAICmd_unk_66(void); -static void ContestAICmd_unk_67(void); -static void ContestAICmd_unk_68(void); -static void ContestAICmd_unk_69(void); -static void ContestAICmd_unk_6A(void); -static void ContestAICmd_unk_6B(void); -static void ContestAICmd_unk_6C(void); -static void ContestAICmd_unk_6D(void); -static void ContestAICmd_unk_6E(void); -static void ContestAICmd_unk_6F(void); -static void ContestAICmd_unk_70(void); -static void ContestAICmd_unk_71(void); -static void ContestAICmd_unk_72(void); -static void ContestAICmd_unk_73(void); -static void ContestAICmd_unk_74(void); -static void ContestAICmd_unk_75(void); -static void ContestAICmd_unk_76(void); -static void ContestAICmd_unk_77(void); -static void ContestAICmd_unk_78(void); -static void ContestAICmd_unk_79(void); -static void ContestAICmd_unk_7A(void); -static void ContestAICmd_unk_7B(void); -static void ContestAICmd_unk_7C(void); -static void ContestAICmd_if_random(void); -static void ContestAICmd_unk_7E(void); -static void ContestAICmd_jump(void); +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); 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); -static void ContestAICmd_unk_85(void); -static void ContestAICmd_unk_86(void); -static void ContestAICmd_if_effect_in_user_moveset(void); +static void ContestAICmd_check_user_has_move(void); +static void ContestAICmd_if_user_has_move(void); +static void ContestAICmd_if_user_doesnt_have_move(void); typedef void (* ContestAICmdFunc)(void); static const ContestAICmdFunc sContestAICmdTable[] = { - 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_unk_15, // 0x15 - ContestAICmd_unk_16, // 0x16 - ContestAICmd_unk_17, // 0x17 - ContestAICmd_unk_18, // 0x18 - ContestAICmd_unk_19, // 0x19 - ContestAICmd_unk_1A, // 0x1A - ContestAICmd_unk_1B, // 0x1B - ContestAICmd_unk_1C, // 0x1C - ContestAICmd_unk_1D, // 0x1D - ContestAICmd_unk_1E, // 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_greater_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_unk_2F, // 0x2F - ContestAICmd_unk_30, // 0x30 - ContestAICmd_unk_31, // 0x31 - ContestAICmd_unk_32, // 0x32 - ContestAICmd_unk_33, // 0x33 - ContestAICmd_unk_34, // 0x34 - ContestAICmd_unk_35, // 0x35 - ContestAICmd_unk_36, // 0x36 - ContestAICmd_unk_37, // 0x37 - ContestAICmd_unk_38, // 0x38 - ContestAICmd_unk_39, // 0x39 - ContestAICmd_unk_3A, // 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_val_812A188, // 0x56 - ContestAICmd_unk_57, // 0x57 - ContestAICmd_contest_58, // 0x58 - ContestAICmd_unk_59, // 0x59 - ContestAICmd_unk_5A, // 0x5A - ContestAICmd_unk_5B, // 0x5B - ContestAICmd_unk_5C, // 0x5C - ContestAICmd_unk_5D, // 0x5D - ContestAICmd_unk_5E, // 0x5E - ContestAICmd_unk_5F, // 0x5F - ContestAICmd_unk_60, // 0x60 - ContestAICmd_unk_61, // 0x61 - ContestAICmd_unk_62, // 0x62 - ContestAICmd_unk_63, // 0x63 - ContestAICmd_unk_64, // 0x64 - ContestAICmd_unk_65, // 0x65 - ContestAICmd_unk_66, // 0x66 - ContestAICmd_unk_67, // 0x67 - ContestAICmd_unk_68, // 0x68 - ContestAICmd_unk_69, // 0x69 - ContestAICmd_unk_6A, // 0x6A - ContestAICmd_unk_6B, // 0x6B - ContestAICmd_unk_6C, // 0x6C - ContestAICmd_unk_6D, // 0x6D - ContestAICmd_unk_6E, // 0x6E - ContestAICmd_unk_6F, // 0x6F - ContestAICmd_unk_70, // 0x70 - ContestAICmd_unk_71, // 0x71 - ContestAICmd_unk_72, // 0x72 - ContestAICmd_unk_73, // 0x73 - ContestAICmd_unk_74, // 0x74 - ContestAICmd_unk_75, // 0x75 - ContestAICmd_unk_76, // 0x76 - ContestAICmd_unk_77, // 0x77 - ContestAICmd_unk_78, // 0x78 - ContestAICmd_unk_79, // 0x79 - ContestAICmd_unk_7A, // 0x7A - ContestAICmd_unk_7B, // 0x7B - ContestAICmd_unk_7C, // 0x7C - ContestAICmd_if_random, // 0x7D - ContestAICmd_unk_7E, // 0x7E - ContestAICmd_jump, // 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_unk_85, // 0x85 - ContestAICmd_unk_86, // 0x86 - ContestAICmd_if_effect_in_user_moveset, // 0x87 + 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 + ContestAICmd_if_user_doesnt_have_move, // 0x87 }; static void ContestAI_DoAIProcessing(void); @@ -303,20 +303,20 @@ void ContestAI_ResetAI(u8 contestantAI) eContestAI.contestantId = contestantAI; eContestAI.stackSize = 0; - eContestAI.aiChecks = gContestMons[eContestAI.contestantId].aiChecks; + eContestAI.aiFlags = gContestMons[eContestAI.contestantId].aiFlags; } u8 ContestAI_GetActionToUse(void) { - while (eContestAI.aiChecks != 0) + while (eContestAI.aiFlags != 0) { - if (eContestAI.aiChecks & 1) + if (eContestAI.aiFlags & 1) { eContestAI.aiState = CONTESTAI_SETTING_UP; ContestAI_DoAIProcessing(); } - eContestAI.aiChecks >>= 1; - eContestAI.currentAICheck++; + eContestAI.aiFlags >>= 1; + eContestAI.currentAIFlag++; eContestAI.nextMoveIndex = 0; } @@ -346,7 +346,7 @@ static void ContestAI_DoAIProcessing(void) case CONTESTAI_DO_NOT_PROCESS: break; case CONTESTAI_SETTING_UP: - gAIScriptPtr = gContestAIChecks[eContestAI.currentAICheck]; + gAIScriptPtr = gContestAI_ScriptsTable[eContestAI.currentAIFlag]; if (gContestMons[eContestAI.contestantId].moves[eContestAI.nextMoveIndex] == MOVE_NONE) eContestAI.nextMove = MOVE_NONE; // don't process a move that doesn't exist. @@ -588,15 +588,15 @@ static void ContestAICmd_if_user_condition_not_eq(void) gAIScriptPtr += 5; } -static void ContestAICmd_unk_15(void) +static void ContestAICmd_get_points(void) { eContestAI.scriptResult = eContestantStatus[eContestAI.contestantId].pointTotal; gAIScriptPtr += 1; } -static void ContestAICmd_unk_16(void) +static void ContestAICmd_if_points_less_than(void) { - ContestAICmd_unk_15(); + ContestAICmd_get_points(); if (eContestAI.scriptResult < (s16)T1_READ_16(gAIScriptPtr + 0)) gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 2); @@ -604,9 +604,9 @@ static void ContestAICmd_unk_16(void) gAIScriptPtr += 6; } -static void ContestAICmd_unk_17(void) +static void ContestAICmd_if_points_more_than(void) { - ContestAICmd_unk_15(); + ContestAICmd_get_points(); if (eContestAI.scriptResult > (s16)T1_READ_16(gAIScriptPtr + 0)) gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 2); @@ -614,9 +614,9 @@ static void ContestAICmd_unk_17(void) gAIScriptPtr += 6; } -static void ContestAICmd_unk_18(void) +static void ContestAICmd_if_points_eq(void) { - ContestAICmd_unk_15(); + ContestAICmd_get_points(); if (eContestAI.scriptResult == (s16)T1_READ_16(gAIScriptPtr + 0)) gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 2); @@ -624,9 +624,9 @@ static void ContestAICmd_unk_18(void) gAIScriptPtr += 6; } -static void ContestAICmd_unk_19(void) +static void ContestAICmd_if_points_not_eq(void) { - ContestAICmd_unk_15(); + ContestAICmd_get_points(); if (eContestAI.scriptResult != (s16)T1_READ_16(gAIScriptPtr + 0)) gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 2); @@ -634,15 +634,15 @@ static void ContestAICmd_unk_19(void) gAIScriptPtr += 6; } -static void ContestAICmd_unk_1A(void) +static void ContestAICmd_get_preliminary_points(void) { eContestAI.scriptResult = gContestMonRound1Points[eContestAI.contestantId]; gAIScriptPtr += 1; } -static void ContestAICmd_unk_1B(void) +static void ContestAICmd_if_preliminary_points_less_than(void) { - ContestAICmd_unk_1A(); + ContestAICmd_get_preliminary_points(); if (eContestAI.scriptResult < (s16)T1_READ_16(gAIScriptPtr + 0)) gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 2); @@ -650,9 +650,9 @@ static void ContestAICmd_unk_1B(void) gAIScriptPtr += 6; } -static void ContestAICmd_unk_1C(void) +static void ContestAICmd_if_preliminary_points_more_than(void) { - ContestAICmd_unk_1A(); + ContestAICmd_get_preliminary_points(); if (eContestAI.scriptResult > (s16)T1_READ_16(gAIScriptPtr + 0)) gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 2); @@ -660,9 +660,9 @@ static void ContestAICmd_unk_1C(void) gAIScriptPtr += 6; } -static void ContestAICmd_unk_1D(void) +static void ContestAICmd_if_preliminary_points_eq(void) { - ContestAICmd_unk_1A(); + ContestAICmd_get_preliminary_points(); if (eContestAI.scriptResult == (s16)T1_READ_16(gAIScriptPtr + 0)) gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 2); @@ -670,9 +670,9 @@ static void ContestAICmd_unk_1D(void) gAIScriptPtr += 6; } -static void ContestAICmd_unk_1E(void) +static void ContestAICmd_if_preliminary_points_not_eq(void) { - ContestAICmd_unk_1A(); + ContestAICmd_get_preliminary_points(); if (eContestAI.scriptResult != (s16)T1_READ_16(gAIScriptPtr + 0)) gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 2); @@ -722,7 +722,7 @@ static void ContestAICmd_if_move_excitement_less_than(void) gAIScriptPtr += 5; } -static void ContestAICmd_if_move_excitement_greater_than(void) +static void ContestAICmd_if_move_excitement_more_than(void) { ContestAICmd_get_move_excitement(); @@ -839,7 +839,7 @@ static void ContestAICmd_if_most_appealing_move(void) gAIScriptPtr += 4; } -static void ContestAICmd_unk_2F(void) +static void ContestAICmd_check_most_jamming_move(void) { int i; u16 move = gContestMons[eContestAI.contestantId].moves[eContestAI.nextMoveIndex]; @@ -848,7 +848,7 @@ static void ContestAICmd_unk_2F(void) for (i = 0; i < MAX_MON_MOVES; i++) { u16 newMove = gContestMons[eContestAI.contestantId].moves[i]; - if (newMove != 0 && jam < gContestEffects[gContestMoves[newMove].effect].jam) + if (newMove != MOVE_NONE && jam < gContestEffects[gContestMoves[newMove].effect].jam) break; } @@ -860,9 +860,9 @@ static void ContestAICmd_unk_2F(void) gAIScriptPtr += 1; } -static void ContestAICmd_unk_30(void) +static void ContestAICmd_if_most_jamming_move(void) { - ContestAICmd_unk_2F(); + ContestAICmd_check_most_jamming_move(); if (eContestAI.scriptResult != FALSE) gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 1); @@ -870,7 +870,7 @@ static void ContestAICmd_unk_30(void) gAIScriptPtr += 5; } -static void ContestAICmd_unk_31(void) +static void ContestAICmd_get_num_move_hearts(void) { u16 move = gContestMons[eContestAI.contestantId].moves[eContestAI.nextMoveIndex]; @@ -878,9 +878,9 @@ static void ContestAICmd_unk_31(void) gAIScriptPtr += 1; } -static void ContestAICmd_unk_32(void) +static void ContestAICmd_if_num_move_hearts_less_than(void) { - ContestAICmd_unk_31(); + ContestAICmd_get_num_move_hearts(); if (eContestAI.scriptResult < gAIScriptPtr[0]) gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 1); @@ -888,9 +888,9 @@ static void ContestAICmd_unk_32(void) gAIScriptPtr += 5; } -static void ContestAICmd_unk_33(void) +static void ContestAICmd_if_num_move_hearts_more_than(void) { - ContestAICmd_unk_31(); + ContestAICmd_get_num_move_hearts(); if (eContestAI.scriptResult > gAIScriptPtr[0]) gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 1); @@ -898,9 +898,9 @@ static void ContestAICmd_unk_33(void) gAIScriptPtr += 5; } -static void ContestAICmd_unk_34(void) +static void ContestAICmd_if_num_move_hearts_eq(void) { - ContestAICmd_unk_31(); + ContestAICmd_get_num_move_hearts(); if (eContestAI.scriptResult == gAIScriptPtr[0]) gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 1); @@ -908,9 +908,9 @@ static void ContestAICmd_unk_34(void) gAIScriptPtr += 5; } -static void ContestAICmd_unk_35(void) +static void ContestAICmd_if_num_move_hearts_not_eq(void) { - ContestAICmd_unk_31(); + ContestAICmd_get_num_move_hearts(); if (eContestAI.scriptResult != gAIScriptPtr[0]) gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 1); @@ -918,7 +918,7 @@ static void ContestAICmd_unk_35(void) gAIScriptPtr += 5; } -static void ContestAICmd_unk_36(void) +static void ContestAICmd_get_num_move_jam_hearts(void) { u16 move = gContestMons[eContestAI.contestantId].moves[eContestAI.nextMoveIndex]; @@ -926,9 +926,9 @@ static void ContestAICmd_unk_36(void) gAIScriptPtr += 1; } -static void ContestAICmd_unk_37(void) +static void ContestAICmd_if_num_move_jam_hearts_less_than(void) { - ContestAICmd_unk_36(); + ContestAICmd_get_num_move_jam_hearts(); if (eContestAI.scriptResult < gAIScriptPtr[0]) gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 1); @@ -936,9 +936,9 @@ static void ContestAICmd_unk_37(void) gAIScriptPtr += 5; } -static void ContestAICmd_unk_38(void) +static void ContestAICmd_if_num_move_jam_hearts_more_than(void) { - ContestAICmd_unk_36(); + ContestAICmd_get_num_move_jam_hearts(); if (eContestAI.scriptResult > gAIScriptPtr[0]) gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 1); @@ -946,9 +946,9 @@ static void ContestAICmd_unk_38(void) gAIScriptPtr += 5; } -static void ContestAICmd_unk_39(void) +static void ContestAICmd_if_num_move_jam_hearts_eq(void) { - ContestAICmd_unk_36(); + ContestAICmd_get_num_move_jam_hearts(); if (eContestAI.scriptResult == gAIScriptPtr[0]) gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 1); @@ -956,9 +956,9 @@ static void ContestAICmd_unk_39(void) gAIScriptPtr += 5; } -static void ContestAICmd_unk_3A(void) +static void ContestAICmd_if_num_move_jam_hearts_not_eq(void) { - ContestAICmd_unk_36(); + ContestAICmd_get_num_move_jam_hearts(); if (eContestAI.scriptResult != gAIScriptPtr[0]) gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 1); @@ -1050,7 +1050,7 @@ static void ContestAICmd_if_combo_starter(void) { ContestAICmd_check_combo_starter(); - if (eContestAI.scriptResult != 0) + if (eContestAI.scriptResult) gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 0); else gAIScriptPtr += 4; @@ -1060,7 +1060,7 @@ static void ContestAICmd_if_not_combo_starter(void) { ContestAICmd_check_combo_starter(); - if (eContestAI.scriptResult == 0) + if (!eContestAI.scriptResult) gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 0); else gAIScriptPtr += 4; @@ -1096,7 +1096,7 @@ static void ContestAICmd_if_combo_finisher(void) { ContestAICmd_check_combo_finisher(); - if (eContestAI.scriptResult != 0) + if (eContestAI.scriptResult) gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 0); else gAIScriptPtr += 4; @@ -1106,7 +1106,7 @@ static void ContestAICmd_if_not_combo_finisher(void) { ContestAICmd_check_combo_finisher(); - if (eContestAI.scriptResult == 0) + if (!eContestAI.scriptResult) gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 0); else gAIScriptPtr += 4; @@ -1131,7 +1131,7 @@ static void ContestAICmd_if_would_finish_combo(void) { ContestAICmd_check_would_finish_combo(); - if (eContestAI.scriptResult != 0) + if (eContestAI.scriptResult) gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 0); else gAIScriptPtr += 4; @@ -1141,7 +1141,7 @@ static void ContestAICmd_if_would_not_finish_combo(void) { ContestAICmd_check_would_finish_combo(); - if (eContestAI.scriptResult == 0) + if (!eContestAI.scriptResult) gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 0); else gAIScriptPtr += 4; @@ -1261,7 +1261,7 @@ static void ContestAICmd_if_can_participate(void) { ContestAICmd_check_can_participate(); - if (eContestAI.scriptResult != 0) + if (eContestAI.scriptResult) gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 0); else gAIScriptPtr += 4; @@ -1271,41 +1271,41 @@ static void ContestAICmd_if_cannot_participate(void) { ContestAICmd_check_can_participate(); - if (eContestAI.scriptResult == 0) + if (!eContestAI.scriptResult) gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 0); else gAIScriptPtr += 4; } -static void ContestAICmd_get_val_812A188(void) +static void ContestAICmd_get_completed_combo(void) { u8 contestant = GetContestantIdByTurn(gAIScriptPtr[1]); - eContestAI.scriptResult = eContestantStatus[contestant].unk15_3; + eContestAI.scriptResult = eContestantStatus[contestant].completedComboFlag; gAIScriptPtr += 2; } -static void ContestAICmd_unk_57(void) +static void ContestAICmd_if_completed_combo(void) { - ContestAICmd_get_val_812A188(); + ContestAICmd_get_completed_combo(); - if (eContestAI.scriptResult != 0) + if (eContestAI.scriptResult) gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 0); else gAIScriptPtr += 4; } -static void ContestAICmd_contest_58(void) +static void ContestAICmd_if_not_completed_combo(void) { - ContestAICmd_get_val_812A188(); + ContestAICmd_get_completed_combo(); - if (eContestAI.scriptResult == 0) + if (!eContestAI.scriptResult) gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 0); else gAIScriptPtr += 4; } -static void ContestAICmd_unk_59(void) +static void ContestAICmd_get_points_diff(void) { u8 contestant = GetContestantIdByTurn(gAIScriptPtr[1]); @@ -1313,9 +1313,9 @@ static void ContestAICmd_unk_59(void) gAIScriptPtr += 2; } -static void ContestAICmd_unk_5A(void) +static void ContestAICmd_if_points_more_than_mon(void) { - ContestAICmd_unk_59(); + ContestAICmd_get_points_diff(); if (eContestAI.scriptResult < 0) gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 0); @@ -1323,9 +1323,9 @@ static void ContestAICmd_unk_5A(void) gAIScriptPtr += 4; } -static void ContestAICmd_unk_5B(void) +static void ContestAICmd_if_points_less_than_mon(void) { - ContestAICmd_unk_59(); + ContestAICmd_get_points_diff(); if (eContestAI.scriptResult > 0) gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 0); @@ -1333,9 +1333,9 @@ static void ContestAICmd_unk_5B(void) gAIScriptPtr += 4; } -static void ContestAICmd_unk_5C(void) +static void ContestAICmd_if_points_eq_mon(void) { - ContestAICmd_unk_59(); + ContestAICmd_get_points_diff(); if (eContestAI.scriptResult == 0) gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 0); @@ -1343,9 +1343,9 @@ static void ContestAICmd_unk_5C(void) gAIScriptPtr += 4; } -static void ContestAICmd_unk_5D(void) +static void ContestAICmd_if_points_not_eq_mon(void) { - ContestAICmd_unk_59(); + ContestAICmd_get_points_diff(); if (eContestAI.scriptResult != 0) gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 0); @@ -1353,7 +1353,7 @@ static void ContestAICmd_unk_5D(void) gAIScriptPtr += 4; } -static void ContestAICmd_unk_5E(void) +static void ContestAICmd_get_preliminary_points_diff(void) { u8 contestant = GetContestantIdByTurn(gAIScriptPtr[1]); @@ -1361,9 +1361,9 @@ static void ContestAICmd_unk_5E(void) gAIScriptPtr += 2; } -static void ContestAICmd_unk_5F(void) +static void ContestAICmd_if_preliminary_points_more_than_mon(void) { - ContestAICmd_unk_5E(); + ContestAICmd_get_preliminary_points_diff(); if (eContestAI.scriptResult < 0) gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 0); @@ -1371,9 +1371,9 @@ static void ContestAICmd_unk_5F(void) gAIScriptPtr += 4; } -static void ContestAICmd_unk_60(void) +static void ContestAICmd_if_preliminary_points_less_than_mon(void) { - ContestAICmd_unk_5E(); + ContestAICmd_get_preliminary_points_diff(); if (eContestAI.scriptResult > 0) gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 0); @@ -1381,9 +1381,9 @@ static void ContestAICmd_unk_60(void) gAIScriptPtr += 4; } -static void ContestAICmd_unk_61(void) +static void ContestAICmd_if_preliminary_points_eq_mon(void) { - ContestAICmd_unk_5E(); + ContestAICmd_get_preliminary_points_diff(); if (eContestAI.scriptResult == 0) gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 0); @@ -1391,9 +1391,9 @@ static void ContestAICmd_unk_61(void) gAIScriptPtr += 4; } -static void ContestAICmd_unk_62(void) +static void ContestAICmd_if_preliminary_points_not_eq_mon(void) { - ContestAICmd_unk_5E(); + ContestAICmd_get_preliminary_points_diff(); if (eContestAI.scriptResult != 0) gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 0); @@ -1401,19 +1401,19 @@ static void ContestAICmd_unk_62(void) gAIScriptPtr += 4; } -static void ContestAICmd_unk_63(void) +static void ContestAICmd_get_used_moves_effect(void) { u8 contestant = GetContestantIdByTurn(gAIScriptPtr[1]); - u8 turn = gAIScriptPtr[2]; - u16 move = eContest.moveHistory[turn][contestant]; + u8 round = gAIScriptPtr[2]; + u16 move = eContest.moveHistory[round][contestant]; eContestAI.scriptResult = gContestMoves[move].effect; gAIScriptPtr += 3; } -static void ContestAICmd_unk_64(void) +static void ContestAICmd_if_used_moves_effect_less_than(void) { - ContestAICmd_unk_63(); + ContestAICmd_get_used_moves_effect(); if (eContestAI.scriptResult < gAIScriptPtr[0]) gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 1); @@ -1421,9 +1421,9 @@ static void ContestAICmd_unk_64(void) gAIScriptPtr += 5; } -static void ContestAICmd_unk_65(void) +static void ContestAICmd_if_used_moves_effect_more_than(void) { - ContestAICmd_unk_63(); + ContestAICmd_get_used_moves_effect(); if (eContestAI.scriptResult > gAIScriptPtr[0]) gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 1); @@ -1431,9 +1431,9 @@ static void ContestAICmd_unk_65(void) gAIScriptPtr += 5; } -static void ContestAICmd_unk_66(void) +static void ContestAICmd_if_used_moves_effect_eq(void) { - ContestAICmd_unk_63(); + ContestAICmd_get_used_moves_effect(); if (eContestAI.scriptResult == gAIScriptPtr[0]) gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 1); @@ -1441,9 +1441,9 @@ static void ContestAICmd_unk_66(void) gAIScriptPtr += 5; } -static void ContestAICmd_unk_67(void) +static void ContestAICmd_if_used_moves_effect_not_eq(void) { - ContestAICmd_unk_63(); + ContestAICmd_get_used_moves_effect(); if (eContestAI.scriptResult != gAIScriptPtr[0]) gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 1); @@ -1451,19 +1451,19 @@ static void ContestAICmd_unk_67(void) gAIScriptPtr += 5; } -static void ContestAICmd_unk_68(void) +static void ContestAICmd_get_used_moves_excitement(void) { u8 contestant = GetContestantIdByTurn(gAIScriptPtr[1]); - u8 turn = gAIScriptPtr[2]; - s8 result = eContest.excitementHistory[turn][contestant]; + u8 round = gAIScriptPtr[2]; + s8 result = eContest.excitementHistory[round][contestant]; eContestAI.scriptResult = result; gAIScriptPtr += 3; } -static void ContestAICmd_unk_69(void) +static void ContestAICmd_if_used_moves_excitement_less_than(void) { - ContestAICmd_unk_68(); + ContestAICmd_get_used_moves_excitement(); if (eContestAI.scriptResult < gAIScriptPtr[0]) gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 1); @@ -1471,9 +1471,9 @@ static void ContestAICmd_unk_69(void) gAIScriptPtr += 5; } -static void ContestAICmd_unk_6A(void) +static void ContestAICmd_if_used_moves_excitement_more_than(void) { - ContestAICmd_unk_68(); + ContestAICmd_get_used_moves_excitement(); if (eContestAI.scriptResult > gAIScriptPtr[0]) gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 1); @@ -1481,9 +1481,9 @@ static void ContestAICmd_unk_6A(void) gAIScriptPtr += 5; } -static void ContestAICmd_unk_6B(void) +static void ContestAICmd_if_used_moves_excitement_eq(void) { - ContestAICmd_unk_68(); + ContestAICmd_get_used_moves_excitement(); if (eContestAI.scriptResult == gAIScriptPtr[0]) gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 1); @@ -1491,9 +1491,9 @@ static void ContestAICmd_unk_6B(void) gAIScriptPtr += 5; } -static void ContestAICmd_unk_6C(void) +static void ContestAICmd_if_used_moves_excitement_not_eq(void) { - ContestAICmd_unk_68(); + ContestAICmd_get_used_moves_excitement(); if (eContestAI.scriptResult != gAIScriptPtr[0]) gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 1); @@ -1501,19 +1501,19 @@ static void ContestAICmd_unk_6C(void) gAIScriptPtr += 5; } -static void ContestAICmd_unk_6D(void) +static void ContestAICmd_get_used_moves_effect_type(void) { u8 contestant = GetContestantIdByTurn(gAIScriptPtr[1]); - u8 turn = gAIScriptPtr[2]; - u16 move = eContest.moveHistory[turn][contestant]; + u8 round = gAIScriptPtr[2]; + u16 move = eContest.moveHistory[round][contestant]; eContestAI.scriptResult = gContestEffects[gContestMoves[move].effect].effectType; gAIScriptPtr += 3; } -static void ContestAICmd_unk_6E(void) +static void ContestAICmd_if_used_moves_effect_type_eq(void) { - ContestAICmd_unk_6D(); + ContestAICmd_get_used_moves_effect_type(); if (eContestAI.scriptResult == gAIScriptPtr[0]) gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 1); @@ -1521,9 +1521,9 @@ static void ContestAICmd_unk_6E(void) gAIScriptPtr += 5; } -static void ContestAICmd_unk_6F(void) +static void ContestAICmd_if_used_moves_effect_type_not_eq(void) { - ContestAICmd_unk_6D(); + ContestAICmd_get_used_moves_effect_type(); if (eContestAI.scriptResult != gAIScriptPtr[0]) gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 1); @@ -1531,119 +1531,129 @@ static void ContestAICmd_unk_6F(void) gAIScriptPtr += 5; } -static void ContestAICmd_unk_70(void) +static void ContestAICmd_save_result(void) { - eContestAI.scriptArr[gAIScriptPtr[1]] = eContestAI.scriptResult; + eContestAI.vars[gAIScriptPtr[1]] = eContestAI.scriptResult; gAIScriptPtr += 2; } -static void ContestAICmd_unk_71(void) +static void ContestAICmd_setvar(void) { - eContestAI.scriptArr[gAIScriptPtr[1]] = T1_READ_16(gAIScriptPtr + 2); + eContestAI.vars[gAIScriptPtr[1]] = T1_READ_16(gAIScriptPtr + 2); gAIScriptPtr += 4; } -static void ContestAICmd_unk_72(void) +static void ContestAICmd_add(void) { // wtf? shouldn't T1_READ_16 work here? why the signed 8 load by gAIScriptPtr[2]? - eContestAI.scriptArr[gAIScriptPtr[1]] += ((s8)gAIScriptPtr[2] | gAIScriptPtr[3] << 8); + eContestAI.vars[gAIScriptPtr[1]] += ((s8)gAIScriptPtr[2] | gAIScriptPtr[3] << 8); gAIScriptPtr += 4; } -static void ContestAICmd_unk_73(void) +static void ContestAICmd_addvar(void) { - eContestAI.scriptArr[gAIScriptPtr[1]] += eContestAI.scriptArr[gAIScriptPtr[2]]; + eContestAI.vars[gAIScriptPtr[1]] += eContestAI.vars[gAIScriptPtr[2]]; gAIScriptPtr += 3; } -static void ContestAICmd_unk_74(void) +static void ContestAICmd_addvar_duplicate(void) { - eContestAI.scriptArr[gAIScriptPtr[1]] += eContestAI.scriptArr[gAIScriptPtr[2]]; + eContestAI.vars[gAIScriptPtr[1]] += eContestAI.vars[gAIScriptPtr[2]]; gAIScriptPtr += 3; } -static void ContestAICmd_unk_75(void) +static void ContestAICmd_if_less_than(void) { - if (eContestAI.scriptArr[gAIScriptPtr[1]] < T1_READ_16(gAIScriptPtr + 2)) + if (eContestAI.vars[gAIScriptPtr[1]] < T1_READ_16(gAIScriptPtr + 2)) gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 4); else gAIScriptPtr += 8; } -static void ContestAICmd_unk_76(void) +static void ContestAICmd_if_greater_than(void) { - if (eContestAI.scriptArr[gAIScriptPtr[1]] > T1_READ_16(gAIScriptPtr + 2)) + if (eContestAI.vars[gAIScriptPtr[1]] > T1_READ_16(gAIScriptPtr + 2)) gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 4); else gAIScriptPtr += 8; } -static void ContestAICmd_unk_77(void) +static void ContestAICmd_if_eq(void) { - if (eContestAI.scriptArr[gAIScriptPtr[1]] == T1_READ_16(gAIScriptPtr + 2)) + if (eContestAI.vars[gAIScriptPtr[1]] == T1_READ_16(gAIScriptPtr + 2)) gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 4); else gAIScriptPtr += 8; } -static void ContestAICmd_unk_78(void) +static void ContestAICmd_if_not_eq(void) { - if (eContestAI.scriptArr[gAIScriptPtr[1]] != T1_READ_16(gAIScriptPtr + 2)) + if (eContestAI.vars[gAIScriptPtr[1]] != T1_READ_16(gAIScriptPtr + 2)) gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 4); else gAIScriptPtr += 8; } -static void ContestAICmd_unk_79(void) +static void ContestAICmd_if_less_than_var(void) { - if (eContestAI.scriptArr[gAIScriptPtr[1]] < (eContestAI.scriptArr[gAIScriptPtr[2]])) + if (eContestAI.vars[gAIScriptPtr[1]] < (eContestAI.vars[gAIScriptPtr[2]])) gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 3); else gAIScriptPtr += 7; } -static void ContestAICmd_unk_7A(void) +static void ContestAICmd_if_greater_than_var(void) { - if (eContestAI.scriptArr[gAIScriptPtr[1]] > (eContestAI.scriptArr[gAIScriptPtr[2]])) + if (eContestAI.vars[gAIScriptPtr[1]] > (eContestAI.vars[gAIScriptPtr[2]])) gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 3); else gAIScriptPtr += 7; } -static void ContestAICmd_unk_7B(void) +static void ContestAICmd_if_eq_var(void) { - if (eContestAI.scriptArr[gAIScriptPtr[1]] == (eContestAI.scriptArr[gAIScriptPtr[2]])) + if (eContestAI.vars[gAIScriptPtr[1]] == (eContestAI.vars[gAIScriptPtr[2]])) gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 3); else gAIScriptPtr += 7; } -static void ContestAICmd_unk_7C(void) +static void ContestAICmd_if_not_eq_var(void) { - if (eContestAI.scriptArr[gAIScriptPtr[1]] != (eContestAI.scriptArr[gAIScriptPtr[2]])) + if (eContestAI.vars[gAIScriptPtr[1]] != (eContestAI.vars[gAIScriptPtr[2]])) gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 3); else gAIScriptPtr += 7; } -static void ContestAICmd_if_random(void) +// UB: Should just be comparing to gAIScriptPtr[1] in the functions below +// The values passed via gAIScriptPtr[1] range from 0-255 +// and vars is an s16[3], so this goes way out of bounds +static void ContestAICmd_if_random_less_than(void) { - if ((Random() & 0xFF) < eContestAI.scriptArr[gAIScriptPtr[1]]) +#ifndef UBFIX + if ((Random() & 0xFF) < eContestAI.vars[gAIScriptPtr[1]]) +#else + if ((Random() & 0xFF) < gAIScriptPtr[1]) +#endif gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 2); else gAIScriptPtr += 6; } -static void ContestAICmd_unk_7E(void) +static void ContestAICmd_if_random_greater_than(void) { - if ((Random() & 0xFF) > eContestAI.scriptArr[gAIScriptPtr[1]]) +#ifndef UBFIX + if (((Random()) & 0xFF) > eContestAI.vars[gAIScriptPtr[1]]) +#else + if (((Random()) & 0xFF) > gAIScriptPtr[1]) +#endif gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 2); else gAIScriptPtr += 6; } -// jump -static void ContestAICmd_jump(void) +static void ContestAICmd_goto(void) { gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 1); } @@ -1704,7 +1714,7 @@ static void ContestAICmd_if_user_has_exciting_move(void) { ContestAICmd_check_user_has_exciting_move(); - if (eContestAI.scriptResult != 0) + if (eContestAI.scriptResult) gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 0); else gAIScriptPtr += 4; @@ -1714,47 +1724,53 @@ static void ContestAICmd_if_user_doesnt_have_exciting_move(void) { ContestAICmd_check_user_has_exciting_move(); - if (eContestAI.scriptResult == 0) + if (!eContestAI.scriptResult) gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 0); else gAIScriptPtr += 4; } -static void ContestAICmd_unk_85(void) +// 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. +// In any case, to fix it to correctly check for effects replace the u16 move assignment with +// u16 move = gContestMoves[gContestMons[eContestAI.contestantId].moves[i]].effect; +static void ContestAICmd_check_user_has_move(void) { - int result = 0; + int hasMove = FALSE; int i; - u16 arg = T1_READ_16(gAIScriptPtr + 1); + u16 targetMove = T1_READ_16(gAIScriptPtr + 1); for (i = 0; i < MAX_MON_MOVES; i++) { u16 move = gContestMons[eContestAI.contestantId].moves[i]; - if (move == arg) + if (move == targetMove) { - result = 1; + hasMove = TRUE; break; } } - eContestAI.scriptResult = result; + eContestAI.scriptResult = hasMove; gAIScriptPtr += 3; } -static void ContestAICmd_unk_86(void) +static void ContestAICmd_if_user_has_move(void) { - ContestAICmd_unk_85(); + ContestAICmd_check_user_has_move(); - if (eContestAI.scriptResult != 0) + if (eContestAI.scriptResult) gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 0); else gAIScriptPtr += 4; } -static void ContestAICmd_if_effect_in_user_moveset(void) +static void ContestAICmd_if_user_doesnt_have_move(void) { - ContestAICmd_unk_85(); + ContestAICmd_check_user_has_move(); - if (eContestAI.scriptResult == 0) + if (!eContestAI.scriptResult) gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 0); else gAIScriptPtr += 4; diff --git a/src/contest_effect.c b/src/contest_effect.c index 8d1bbb298..1fe21daab 100644 --- a/src/contest_effect.c +++ b/src/contest_effect.c @@ -68,7 +68,10 @@ bool8 AreMovesContestCombo(u16 lastMove, u16 nextMove) if (lastMoveComboStarterId == 0) return FALSE; - else if (lastMoveComboStarterId == nextMoveComboMoves[0] || lastMoveComboStarterId == nextMoveComboMoves[1] || lastMoveComboStarterId == nextMoveComboMoves[2] || lastMoveComboStarterId == nextMoveComboMoves[3]) + else if (lastMoveComboStarterId == nextMoveComboMoves[0] + || lastMoveComboStarterId == nextMoveComboMoves[1] + || lastMoveComboStarterId == nextMoveComboMoves[2] + || lastMoveComboStarterId == nextMoveComboMoves[3]) return gComboStarterLookupTable[lastMoveComboStarterId]; else return FALSE; diff --git a/src/contest_painting.c b/src/contest_painting.c index 5dd4a70a5..a0c39dfc7 100644 --- a/src/contest_painting.c +++ b/src/contest_painting.c @@ -384,8 +384,6 @@ static void InitContestMonPixels(u16 species, u8 whichSprite) } } -#ifdef NONMATCHING -// functionally equivalent. static void _InitContestMonPixels(u8 *spriteGfx, u16 *palette, u16 (*destPixels)[64][64]) { u16 tileY, tileX, pixelY, pixelX; @@ -399,125 +397,21 @@ static void _InitContestMonPixels(u8 *spriteGfx, u16 *palette, u16 (*destPixels) { for (pixelX = 0; pixelX < 8; pixelX++) { - int offset = 32 * (8 * tileY + tileX) + (pixelY * 4 + pixelX / 2); - colorIndex = spriteGfx[offset]; + colorIndex = spriteGfx[((tileY * 8) + tileX) * 32 + (pixelY << 2) + (pixelX >> 1)]; if (pixelX & 1) colorIndex >>= 4; else - colorIndex &= 0xF; + colorIndex &= 0xF; // %=16 works here too. Both match - if (colorIndex == 0) // transparent pixel - (*destPixels)[8 * tileY + pixelY][tileX * 8 + pixelX] = 0x8000; + if (colorIndex == 0) // transparent pixel + (*destPixels)[tileY * 8 + pixelY][tileX * 8 + pixelX] = 0x8000; else - (*destPixels)[8 * tileY + pixelY][tileX * 8 + pixelX] = palette[colorIndex]; + (*destPixels)[tileY * 8 + pixelY][tileX * 8 + pixelX] = palette[colorIndex]; } } } } } -#else -NAKED -static void _InitContestMonPixels(u8 *spriteGfx, u16 *palette, u16 (*destPixels)[64][64]) -{ - asm_unified("\n\ - push {r4-r7,lr}\n\ - mov r7, r10\n\ - mov r6, r9\n\ - mov r5, r8\n\ - push {r5-r7}\n\ - sub sp, 0xC\n\ - mov r10, r0\n\ - mov r9, r1\n\ - str r2, [sp]\n\ - movs r0, 0\n\ -_08130394:\n\ - movs r3, 0\n\ - adds r1, r0, 0x1\n\ - str r1, [sp, 0x4]\n\ - lsls r0, 3\n\ - str r0, [sp, 0x8]\n\ -_0813039E:\n\ - movs r1, 0\n\ - adds r2, r3, 0x1\n\ - mov r8, r2\n\ - ldr r7, [sp, 0x8]\n\ - adds r0, r7, r3\n\ - lsls r0, 5\n\ - mov r12, r0\n\ - lsls r4, r3, 3\n\ -_081303AE:\n\ - movs r3, 0\n\ - lsls r0, r1, 2\n\ - adds r6, r1, 0x1\n\ - mov r2, r12\n\ - adds r5, r2, r0\n\ - ldr r7, [sp, 0x8]\n\ - adds r0, r7, r1\n\ - lsls r0, 7\n\ - ldr r1, [sp]\n\ - adds r2, r0, r1\n\ -_081303C2:\n\ - lsrs r0, r3, 1\n\ - adds r0, r5, r0\n\ - add r0, r10\n\ - ldrb r1, [r0]\n\ - movs r0, 0x1\n\ - ands r0, r3\n\ - cmp r0, 0\n\ - beq _081303D6\n\ - lsrs r1, 4\n\ - b _081303DA\n\ -_081303D6:\n\ - movs r0, 0xF\n\ - ands r1, r0\n\ -_081303DA:\n\ - cmp r1, 0\n\ - bne _081303EC\n\ - adds r0, r4, r3\n\ - lsls r0, 1\n\ - adds r0, r2\n\ - movs r7, 0x80\n\ - lsls r7, 8\n\ - adds r1, r7, 0\n\ - b _081303F8\n\ -_081303EC:\n\ - adds r0, r4, r3\n\ - lsls r0, 1\n\ - adds r0, r2\n\ - lsls r1, 1\n\ - add r1, r9\n\ - ldrh r1, [r1]\n\ -_081303F8:\n\ - strh r1, [r0]\n\ - adds r0, r3, 0x1\n\ - lsls r0, 16\n\ - lsrs r3, r0, 16\n\ - cmp r3, 0x7\n\ - bls _081303C2\n\ - lsls r0, r6, 16\n\ - lsrs r1, r0, 16\n\ - cmp r1, 0x7\n\ - bls _081303AE\n\ - mov r1, r8\n\ - lsls r0, r1, 16\n\ - lsrs r3, r0, 16\n\ - cmp r3, 0x7\n\ - bls _0813039E\n\ - ldr r2, [sp, 0x4]\n\ - lsls r0, r2, 16\n\ - lsrs r0, 16\n\ - cmp r0, 0x7\n\ - bls _08130394\n\ - add sp, 0xC\n\ - pop {r3-r5}\n\ - mov r8, r3\n\ - mov r9, r4\n\ - mov r10, r5\n\ - pop {r4-r7}\n\ - pop {r0}\n\ - bx r0"); -} -#endif #define VRAM_PICTURE_DATA(x, y) (((u16 *)(BG_SCREEN_ADDR(12)))[(y) * 32 + (x)]) diff --git a/src/data/contest_moves.h b/src/data/contest_moves.h index 5460ac806..658528210 100644 --- a/src/data/contest_moves.h +++ b/src/data/contest_moves.h @@ -2838,289 +2838,289 @@ const struct ContestEffect gContestEffects[] = { [CONTEST_EFFECT_HIGHLY_APPEALING] = { - .effectType = 0, + .effectType = CONTEST_EFFECT_TYPE_APPEAL, .appeal = 40, .jam = 0, }, [CONTEST_EFFECT_USER_MORE_EASILY_STARTLED] = { - .effectType = 0, + .effectType = CONTEST_EFFECT_TYPE_APPEAL, .appeal = 60, .jam = 0, }, [CONTEST_EFFECT_GREAT_APPEAL_BUT_NO_MORE_MOVES] = { - .effectType = 0, + .effectType = CONTEST_EFFECT_TYPE_APPEAL, .appeal = 80, .jam = 0, }, [CONTEST_EFFECT_REPETITION_NOT_BORING] = { - .effectType = 0, + .effectType = CONTEST_EFFECT_TYPE_APPEAL, .appeal = 30, .jam = 0, }, [CONTEST_EFFECT_AVOID_STARTLE_ONCE] = { - .effectType = 1, + .effectType = CONTEST_EFFECT_TYPE_AVOID_STARTLE, .appeal = 20, .jam = 0, }, [CONTEST_EFFECT_AVOID_STARTLE] = { - .effectType = 1, + .effectType = CONTEST_EFFECT_TYPE_AVOID_STARTLE, .appeal = 10, .jam = 0, }, [CONTEST_EFFECT_AVOID_STARTLE_SLIGHTLY] = { - .effectType = 1, + .effectType = CONTEST_EFFECT_TYPE_AVOID_STARTLE, .appeal = 30, .jam = 0, }, [CONTEST_EFFECT_USER_LESS_EASILY_STARTLED] = { - .effectType = 1, + .effectType = CONTEST_EFFECT_TYPE_AVOID_STARTLE, .appeal = 30, .jam = 0, }, [CONTEST_EFFECT_STARTLE_FRONT_MON] = { - .effectType = 2, + .effectType = CONTEST_EFFECT_TYPE_STARTLE_MON, .appeal = 30, .jam = 20, }, [CONTEST_EFFECT_SLIGHTLY_STARTLE_PREV_MONS] = { - .effectType = 3, + .effectType = CONTEST_EFFECT_TYPE_STARTLE_MONS, .appeal = 30, .jam = 10, }, [CONTEST_EFFECT_STARTLE_PREV_MON] = { - .effectType = 2, + .effectType = CONTEST_EFFECT_TYPE_STARTLE_MON, .appeal = 20, .jam = 30, }, [CONTEST_EFFECT_STARTLE_PREV_MONS] = { - .effectType = 3, + .effectType = CONTEST_EFFECT_TYPE_STARTLE_MONS, .appeal = 20, .jam = 20, }, [CONTEST_EFFECT_BADLY_STARTLE_FRONT_MON] = { - .effectType = 2, + .effectType = CONTEST_EFFECT_TYPE_STARTLE_MON, .appeal = 10, .jam = 40, }, [CONTEST_EFFECT_BADLY_STARTLE_PREV_MONS] = { - .effectType = 3, + .effectType = CONTEST_EFFECT_TYPE_STARTLE_MONS, .appeal = 10, .jam = 30, }, [CONTEST_EFFECT_STARTLE_PREV_MON_2] = { - .effectType = 2, + .effectType = CONTEST_EFFECT_TYPE_STARTLE_MON, .appeal = 30, .jam = 20, }, [CONTEST_EFFECT_STARTLE_PREV_MONS_2] = { - .effectType = 3, + .effectType = CONTEST_EFFECT_TYPE_STARTLE_MONS, .appeal = 30, .jam = 10, }, [CONTEST_EFFECT_SHIFT_JUDGE_ATTENTION] = { - .effectType = 4, + .effectType = CONTEST_EFFECT_TYPE_WORSEN, .appeal = 30, .jam = 0, }, [CONTEST_EFFECT_STARTLE_MON_WITH_JUDGES_ATTENTION] = { - .effectType = 3, + .effectType = CONTEST_EFFECT_TYPE_STARTLE_MONS, .appeal = 20, .jam = 10, }, [CONTEST_EFFECT_JAMS_OTHERS_BUT_MISS_ONE_TURN] = { - .effectType = 3, + .effectType = CONTEST_EFFECT_TYPE_STARTLE_MONS, .appeal = 40, .jam = 40, }, [CONTEST_EFFECT_STARTLE_MONS_SAME_TYPE_APPEAL] = { - .effectType = 3, + .effectType = CONTEST_EFFECT_TYPE_STARTLE_MONS, .appeal = 20, .jam = 10, }, [CONTEST_EFFECT_STARTLE_MONS_COOL_APPEAL] = { - .effectType = 3, + .effectType = CONTEST_EFFECT_TYPE_STARTLE_MONS, .appeal = 20, .jam = 10, }, [CONTEST_EFFECT_STARTLE_MONS_BEAUTY_APPEAL] = { - .effectType = 3, + .effectType = CONTEST_EFFECT_TYPE_STARTLE_MONS, .appeal = 20, .jam = 10, }, [CONTEST_EFFECT_STARTLE_MONS_CUTE_APPEAL] = { - .effectType = 3, + .effectType = CONTEST_EFFECT_TYPE_STARTLE_MONS, .appeal = 20, .jam = 10, }, [CONTEST_EFFECT_STARTLE_MONS_SMART_APPEAL] = { - .effectType = 3, + .effectType = CONTEST_EFFECT_TYPE_STARTLE_MONS, .appeal = 20, .jam = 10, }, [CONTEST_EFFECT_STARTLE_MONS_TOUGH_APPEAL] = { - .effectType = 3, + .effectType = CONTEST_EFFECT_TYPE_STARTLE_MONS, .appeal = 20, .jam = 10, }, [CONTEST_EFFECT_MAKE_FOLLOWING_MON_NERVOUS] = { - .effectType = 4, + .effectType = CONTEST_EFFECT_TYPE_WORSEN, .appeal = 20, .jam = 0, }, [CONTEST_EFFECT_MAKE_FOLLOWING_MONS_NERVOUS] = { - .effectType = 4, + .effectType = CONTEST_EFFECT_TYPE_WORSEN, .appeal = 20, .jam = 0, }, [CONTEST_EFFECT_WORSEN_CONDITION_OF_PREV_MONS] = { - .effectType = 4, + .effectType = CONTEST_EFFECT_TYPE_WORSEN, .appeal = 30, .jam = 0, }, [CONTEST_EFFECT_BADLY_STARTLES_MONS_IN_GOOD_CONDITION] = { - .effectType = 3, + .effectType = CONTEST_EFFECT_TYPE_STARTLE_MONS, .appeal = 30, .jam = 10, }, [CONTEST_EFFECT_BETTER_IF_FIRST] = { - .effectType = 5, + .effectType = CONTEST_EFFECT_TYPE_SPECIAL_APPEAL, .appeal = 20, .jam = 0, }, [CONTEST_EFFECT_BETTER_IF_LAST] = { - .effectType = 5, + .effectType = CONTEST_EFFECT_TYPE_SPECIAL_APPEAL, .appeal = 20, .jam = 0, }, [CONTEST_EFFECT_APPEAL_AS_GOOD_AS_PREV_ONES] = { - .effectType = 5, + .effectType = CONTEST_EFFECT_TYPE_SPECIAL_APPEAL, .appeal = 10, .jam = 0, }, [CONTEST_EFFECT_APPEAL_AS_GOOD_AS_PREV_ONE] = { - .effectType = 5, + .effectType = CONTEST_EFFECT_TYPE_SPECIAL_APPEAL, .appeal = 10, .jam = 0, }, [CONTEST_EFFECT_BETTER_WHEN_LATER] = { - .effectType = 5, + .effectType = CONTEST_EFFECT_TYPE_SPECIAL_APPEAL, .appeal = 10, .jam = 0, }, [CONTEST_EFFECT_QUALITY_DEPENDS_ON_TIMING] = { - .effectType = 5, + .effectType = CONTEST_EFFECT_TYPE_SPECIAL_APPEAL, .appeal = 10, .jam = 0, }, [CONTEST_EFFECT_BETTER_IF_SAME_TYPE] = { - .effectType = 5, + .effectType = CONTEST_EFFECT_TYPE_SPECIAL_APPEAL, .appeal = 20, .jam = 0, }, [CONTEST_EFFECT_BETTER_IF_DIFF_TYPE] = { - .effectType = 5, + .effectType = CONTEST_EFFECT_TYPE_SPECIAL_APPEAL, .appeal = 20, .jam = 0, }, [CONTEST_EFFECT_AFFECTED_BY_PREV_APPEAL] = { - .effectType = 5, + .effectType = CONTEST_EFFECT_TYPE_SPECIAL_APPEAL, .appeal = 30, .jam = 0, }, [CONTEST_EFFECT_IMPROVE_CONDITION_PREVENT_NERVOUSNESS] = { - .effectType = 5, + .effectType = CONTEST_EFFECT_TYPE_SPECIAL_APPEAL, .appeal = 10, .jam = 0, }, [CONTEST_EFFECT_BETTER_WITH_GOOD_CONDITION] = { - .effectType = 5, + .effectType = CONTEST_EFFECT_TYPE_SPECIAL_APPEAL, .appeal = 10, .jam = 0, }, [CONTEST_EFFECT_NEXT_APPEAL_EARLIER] = { - .effectType = 6, + .effectType = CONTEST_EFFECT_TYPE_TURN_ORDER, .appeal = 30, .jam = 0, }, [CONTEST_EFFECT_NEXT_APPEAL_LATER] = { - .effectType = 6, + .effectType = CONTEST_EFFECT_TYPE_TURN_ORDER, .appeal = 30, .jam = 0, }, [CONTEST_EFFECT_MAKE_SCRAMBLING_TURN_ORDER_EASIER] = { - .effectType = 6, + .effectType = CONTEST_EFFECT_TYPE_TURN_ORDER, .appeal = 30, .jam = 0, }, [CONTEST_EFFECT_SCRAMBLE_NEXT_TURN_ORDER] = { - .effectType = 6, + .effectType = CONTEST_EFFECT_TYPE_TURN_ORDER, .appeal = 30, .jam = 0, }, [CONTEST_EFFECT_EXCITE_AUDIENCE_IN_ANY_CONTEST] = { - .effectType = 5, + .effectType = CONTEST_EFFECT_TYPE_SPECIAL_APPEAL, .appeal = 10, .jam = 0, }, [CONTEST_EFFECT_BADLY_STARTLE_MONS_WITH_GOOD_APPEALS] = { - .effectType = 3, + .effectType = CONTEST_EFFECT_TYPE_STARTLE_MONS, .appeal = 20, .jam = 10, }, [CONTEST_EFFECT_BETTER_WHEN_AUDIENCE_EXCITED] = { - .effectType = 5, + .effectType = CONTEST_EFFECT_TYPE_SPECIAL_APPEAL, .appeal = 10, .jam = 0, }, [CONTEST_EFFECT_DONT_EXCITE_AUDIENCE] = { - .effectType = 4, + .effectType = CONTEST_EFFECT_TYPE_WORSEN, .appeal = 30, .jam = 0, }, diff --git a/src/data/contest_opponents.h b/src/data/contest_opponents.h index 53868fc84..6de931ef2 100644 --- a/src/data/contest_opponents.h +++ b/src/data/contest_opponents.h @@ -100,7 +100,44 @@ #define CONTEST_OPPONENT_TREY 94 #define CONTEST_OPPONENT_LANE 95 -const struct ContestWinner gUnknown_08587FA4[] = +// All contest opponents have a common set of AI flags (which contains all of the actually +// useful AI scripts, as well as some dummys) and a random combination of 2-3 dummy flags. +// Seems that like the battle AI they had more plans for this than what ended up in the final game +#define CONTEST_AI_SET_1 (CONTEST_AI_COMMON | CONTEST_AI_DUMMY_20 | CONTEST_AI_DUMMY_21) +#define CONTEST_AI_SET_2 (CONTEST_AI_COMMON | CONTEST_AI_DUMMY_19 | CONTEST_AI_DUMMY_25) +#define CONTEST_AI_SET_3 (CONTEST_AI_COMMON | CONTEST_AI_DUMMY_18 | CONTEST_AI_DUMMY_23) +#define CONTEST_AI_SET_4 (CONTEST_AI_COMMON | CONTEST_AI_DUMMY_17 | CONTEST_AI_DUMMY_23) +#define CONTEST_AI_SET_5 (CONTEST_AI_COMMON | CONTEST_AI_DUMMY_16 | CONTEST_AI_DUMMY_25) +#define CONTEST_AI_SET_6 (CONTEST_AI_COMMON | CONTEST_AI_DUMMY_15 | CONTEST_AI_DUMMY_22) +#define CONTEST_AI_SET_7 (CONTEST_AI_COMMON | CONTEST_AI_DUMMY_14 | CONTEST_AI_DUMMY_23) +#define CONTEST_AI_SET_8 (CONTEST_AI_COMMON | CONTEST_AI_DUMMY_13 | CONTEST_AI_DUMMY_21) +#define CONTEST_AI_SET_9 (CONTEST_AI_COMMON | CONTEST_AI_DUMMY_12 | CONTEST_AI_DUMMY_24) +#define CONTEST_AI_SET_A (CONTEST_AI_COMMON | CONTEST_AI_DUMMY_11 | CONTEST_AI_DUMMY_25) +#define CONTEST_AI_SET_B (CONTEST_AI_COMMON | CONTEST_AI_DUMMY_10 | CONTEST_AI_DUMMY_21) +#define CONTEST_AI_SET_C (CONTEST_AI_COMMON | CONTEST_AI_DUMMY_9 | CONTEST_AI_DUMMY_21) +#define CONTEST_AI_SET_D (CONTEST_AI_COMMON | CONTEST_AI_DUMMY_8 | CONTEST_AI_DUMMY_22 | CONTEST_AI_DUMMY_25) +#define CONTEST_AI_SET_E (CONTEST_AI_COMMON | CONTEST_AI_DUMMY_7 | CONTEST_AI_DUMMY_24) +#define CONTEST_AI_SET_F (CONTEST_AI_COMMON | CONTEST_AI_DUMMY_6 | CONTEST_AI_DUMMY_25) +#define CONTEST_AI_SET_10 (CONTEST_AI_COMMON | CONTEST_AI_DUMMY_20 | CONTEST_AI_DUMMY_23) +#define CONTEST_AI_SET_11 (CONTEST_AI_COMMON | CONTEST_AI_DUMMY_18 | CONTEST_AI_DUMMY_25) +#define CONTEST_AI_SET_12 (CONTEST_AI_COMMON | CONTEST_AI_DUMMY_17 | CONTEST_AI_DUMMY_25) +#define CONTEST_AI_SET_13 (CONTEST_AI_COMMON | CONTEST_AI_DUMMY_16 | CONTEST_AI_DUMMY_22) +#define CONTEST_AI_SET_14 (CONTEST_AI_COMMON | CONTEST_AI_DUMMY_15 | CONTEST_AI_DUMMY_21) +#define CONTEST_AI_SET_15 (CONTEST_AI_COMMON | CONTEST_AI_DUMMY_14 | CONTEST_AI_DUMMY_22) +#define CONTEST_AI_SET_16 (CONTEST_AI_COMMON | CONTEST_AI_DUMMY_13 | CONTEST_AI_DUMMY_25) +#define CONTEST_AI_SET_17 (CONTEST_AI_COMMON | CONTEST_AI_DUMMY_12 | CONTEST_AI_DUMMY_23 | CONTEST_AI_DUMMY_25) +#define CONTEST_AI_SET_18 (CONTEST_AI_COMMON | CONTEST_AI_DUMMY_10 | CONTEST_AI_DUMMY_25) +#define CONTEST_AI_SET_19 (CONTEST_AI_COMMON | CONTEST_AI_DUMMY_9 | CONTEST_AI_DUMMY_25) +#define CONTEST_AI_SET_1A (CONTEST_AI_COMMON | CONTEST_AI_DUMMY_8 | CONTEST_AI_DUMMY_25) +#define CONTEST_AI_SET_1B (CONTEST_AI_COMMON | CONTEST_AI_DUMMY_7 | CONTEST_AI_DUMMY_21) +#define CONTEST_AI_SET_1C (CONTEST_AI_COMMON | CONTEST_AI_DUMMY_6 | CONTEST_AI_DUMMY_21) +#define CONTEST_AI_SET_1D (CONTEST_AI_COMMON | CONTEST_AI_DUMMY_20 | CONTEST_AI_DUMMY_25) +#define CONTEST_AI_SET_1E (CONTEST_AI_COMMON | CONTEST_AI_DUMMY_15 | CONTEST_AI_DUMMY_25) +#define CONTEST_AI_SET_1F (CONTEST_AI_COMMON | CONTEST_AI_DUMMY_14 | CONTEST_AI_DUMMY_25) +#define CONTEST_AI_SET_20 (CONTEST_AI_COMMON | CONTEST_AI_DUMMY_12 | CONTEST_AI_DUMMY_25) +#define CONTEST_AI_SET_21 (CONTEST_AI_COMMON | CONTEST_AI_DUMMY_7 | CONTEST_AI_DUMMY_25) + +const struct ContestWinner gDefaultContestWinners[] = { { .personality = 0, @@ -183,7 +220,7 @@ const struct ContestPokemon gContestOpponents[] = .nickname = _("POOCHY"), .trainerName = _("JIMMY"), .trainerGfxId = OBJ_EVENT_GFX_BOY_1, - .aiChecks = 0xC000FFF, + .aiFlags = CONTEST_AI_SET_1, .whichRank = CONTEST_RANK_NORMAL, .aiPool_Cool = TRUE, .aiPool_Beauty = FALSE, @@ -211,7 +248,7 @@ const struct ContestPokemon gContestOpponents[] = .nickname = _("MUSILLE"), .trainerName = _("EDITH"), .trainerGfxId = OBJ_EVENT_GFX_GIRL_1, - .aiChecks = 0x82000FFF, + .aiFlags = CONTEST_AI_SET_2, .whichRank = CONTEST_RANK_NORMAL, .aiPool_Cool = FALSE, .aiPool_Beauty = FALSE, @@ -239,7 +276,7 @@ const struct ContestPokemon gContestOpponents[] = .nickname = _("DUSTER"), .trainerName = _("EVAN"), .trainerGfxId = OBJ_EVENT_GFX_LITTLE_BOY, - .aiChecks = 0x21000FFF, + .aiFlags = CONTEST_AI_SET_3, .whichRank = CONTEST_RANK_NORMAL, .aiPool_Cool = FALSE, .aiPool_Beauty = TRUE, @@ -267,7 +304,7 @@ const struct ContestPokemon gContestOpponents[] = .nickname = _("DOTS"), .trainerName = _("KELSEY"), .trainerGfxId = OBJ_EVENT_GFX_WOMAN_1, - .aiChecks = 0x20800FFF, + .aiFlags = CONTEST_AI_SET_4, .whichRank = CONTEST_RANK_NORMAL, .aiPool_Cool = FALSE, .aiPool_Beauty = FALSE, @@ -295,7 +332,7 @@ const struct ContestPokemon gContestOpponents[] = .nickname = _("TATAY"), .trainerName = _("MADISON"), .trainerGfxId = OBJ_EVENT_GFX_POKEFAN_F, - .aiChecks = 0x80400FFF, + .aiFlags = CONTEST_AI_SET_5, .whichRank = CONTEST_RANK_NORMAL, .aiPool_Cool = TRUE, .aiPool_Beauty = FALSE, @@ -323,7 +360,7 @@ const struct ContestPokemon gContestOpponents[] = .nickname = _("NINDA"), .trainerName = _("RAYMOND"), .trainerGfxId = OBJ_EVENT_GFX_BLACK_BELT, - .aiChecks = 0x10200FFF, + .aiFlags = CONTEST_AI_SET_6, .whichRank = CONTEST_RANK_NORMAL, .aiPool_Cool = FALSE, .aiPool_Beauty = FALSE, @@ -351,7 +388,7 @@ const struct ContestPokemon gContestOpponents[] = .nickname = _("SMISH"), .trainerName = _("GRANT"), .trainerGfxId = OBJ_EVENT_GFX_YOUNGSTER, - .aiChecks = 0x20100FFF, + .aiFlags = CONTEST_AI_SET_7, .whichRank = CONTEST_RANK_NORMAL, .aiPool_Cool = FALSE, .aiPool_Beauty = FALSE, @@ -379,7 +416,7 @@ const struct ContestPokemon gContestOpponents[] = .nickname = _("SLEAL"), .trainerName = _("PAIGE"), .trainerGfxId = OBJ_EVENT_GFX_WOMAN_4, - .aiChecks = 0x8080FFF, + .aiFlags = CONTEST_AI_SET_8, .whichRank = CONTEST_RANK_NORMAL, .aiPool_Cool = FALSE, .aiPool_Beauty = TRUE, @@ -407,7 +444,7 @@ const struct ContestPokemon gContestOpponents[] = .nickname = _("SLOKTH"), .trainerName = _("ALEC"), .trainerGfxId = OBJ_EVENT_GFX_CAMPER, - .aiChecks = 0x40040FFF, + .aiFlags = CONTEST_AI_SET_9, .whichRank = CONTEST_RANK_NORMAL, .aiPool_Cool = FALSE, .aiPool_Beauty = TRUE, @@ -435,7 +472,7 @@ const struct ContestPokemon gContestOpponents[] = .nickname = _("WHIRIS"), .trainerName = _("SYDNEY"), .trainerGfxId = OBJ_EVENT_GFX_LASS, - .aiChecks = 0x80020FFF, + .aiFlags = CONTEST_AI_SET_A, .whichRank = CONTEST_RANK_NORMAL, .aiPool_Cool = TRUE, .aiPool_Beauty = FALSE, @@ -463,7 +500,7 @@ const struct ContestPokemon gContestOpponents[] = .nickname = _("MAHITA"), .trainerName = _("MORRIS"), .trainerGfxId = OBJ_EVENT_GFX_SCHOOL_KID_M, - .aiChecks = 0x8010FFF, + .aiFlags = CONTEST_AI_SET_B, .whichRank = CONTEST_RANK_NORMAL, .aiPool_Cool = TRUE, .aiPool_Beauty = FALSE, @@ -491,7 +528,7 @@ const struct ContestPokemon gContestOpponents[] = .nickname = _("RONAR"), .trainerName = _("MARIAH"), .trainerGfxId = OBJ_EVENT_GFX_GIRL_2, - .aiChecks = 0x8008FFF, + .aiFlags = CONTEST_AI_SET_C, .whichRank = CONTEST_RANK_NORMAL, .aiPool_Cool = TRUE, .aiPool_Beauty = FALSE, @@ -519,7 +556,7 @@ const struct ContestPokemon gContestOpponents[] = .nickname = _("BATRO"), .trainerName = _("RUSSELL"), .trainerGfxId = OBJ_EVENT_GFX_MAN_3, - .aiChecks = 0x90004FFF, + .aiFlags = CONTEST_AI_SET_D, .whichRank = CONTEST_RANK_NORMAL, .aiPool_Cool = FALSE, .aiPool_Beauty = TRUE, @@ -547,7 +584,7 @@ const struct ContestPokemon gContestOpponents[] = .nickname = _("GULIN"), .trainerName = _("MELANIE"), .trainerGfxId = OBJ_EVENT_GFX_TWIN, - .aiChecks = 0x40002FFF, + .aiFlags = CONTEST_AI_SET_E, .whichRank = CONTEST_RANK_NORMAL, .aiPool_Cool = FALSE, .aiPool_Beauty = FALSE, @@ -575,7 +612,7 @@ const struct ContestPokemon gContestOpponents[] = .nickname = _("RIKELEC"), .trainerName = _("CHANCE"), .trainerGfxId = OBJ_EVENT_GFX_RICH_BOY, - .aiChecks = 0x80001FFF, + .aiFlags = CONTEST_AI_SET_F, .whichRank = CONTEST_RANK_NORMAL, .aiPool_Cool = TRUE, .aiPool_Beauty = TRUE, @@ -603,7 +640,7 @@ const struct ContestPokemon gContestOpponents[] = .nickname = _("BULBY"), .trainerName = _("AGATHA"), .trainerGfxId = OBJ_EVENT_GFX_WOMAN_2, - .aiChecks = 0xC000FFF, + .aiFlags = CONTEST_AI_SET_1, .whichRank = CONTEST_RANK_NORMAL, .aiPool_Cool = FALSE, .aiPool_Beauty = FALSE, @@ -631,7 +668,7 @@ const struct ContestPokemon gContestOpponents[] = .nickname = _("FUTTERBE"), .trainerName = _("BEAU"), .trainerGfxId = OBJ_EVENT_GFX_HEX_MANIAC, - .aiChecks = 0x82000FFF, + .aiFlags = CONTEST_AI_SET_2, .whichRank = CONTEST_RANK_NORMAL, .aiPool_Cool = FALSE, .aiPool_Beauty = TRUE, @@ -659,7 +696,7 @@ const struct ContestPokemon gContestOpponents[] = .nickname = _("PIDEOT"), .trainerName = _("KAY"), .trainerGfxId = OBJ_EVENT_GFX_WOMAN_5, - .aiChecks = 0x21000FFF, + .aiFlags = CONTEST_AI_SET_3, .whichRank = CONTEST_RANK_NORMAL, .aiPool_Cool = TRUE, .aiPool_Beauty = TRUE, @@ -687,7 +724,7 @@ const struct ContestPokemon gContestOpponents[] = .nickname = _("DIGLE"), .trainerName = _("CALE"), .trainerGfxId = OBJ_EVENT_GFX_HIKER, - .aiChecks = 0x20800FFF, + .aiFlags = CONTEST_AI_SET_4, .whichRank = CONTEST_RANK_NORMAL, .aiPool_Cool = FALSE, .aiPool_Beauty = FALSE, @@ -715,7 +752,7 @@ const struct ContestPokemon gContestOpponents[] = .nickname = _("WAGIL"), .trainerName = _("CAITLIN"), .trainerGfxId = OBJ_EVENT_GFX_TUBER_F, - .aiChecks = 0x80400FFF, + .aiFlags = CONTEST_AI_SET_5, .whichRank = CONTEST_RANK_NORMAL, .aiPool_Cool = FALSE, .aiPool_Beauty = TRUE, @@ -743,7 +780,7 @@ const struct ContestPokemon gContestOpponents[] = .nickname = _("TOTDIL"), .trainerName = _("COLBY"), .trainerGfxId = OBJ_EVENT_GFX_NINJA_BOY, - .aiChecks = 0x10200FFF, + .aiFlags = CONTEST_AI_SET_6, .whichRank = CONTEST_RANK_NORMAL, .aiPool_Cool = TRUE, .aiPool_Beauty = TRUE, @@ -771,7 +808,7 @@ const struct ContestPokemon gContestOpponents[] = .nickname = _("BALEDY"), .trainerName = _("KYLIE"), .trainerGfxId = OBJ_EVENT_GFX_BEAUTY, - .aiChecks = 0x20100FFF, + .aiFlags = CONTEST_AI_SET_7, .whichRank = CONTEST_RANK_NORMAL, .aiPool_Cool = TRUE, .aiPool_Beauty = FALSE, @@ -799,7 +836,7 @@ const struct ContestPokemon gContestOpponents[] = .nickname = _("BIRDLY"), .trainerName = _("LIAM"), .trainerGfxId = OBJ_EVENT_GFX_MAN_5, - .aiChecks = 0x8080FFF, + .aiFlags = CONTEST_AI_SET_8, .whichRank = CONTEST_RANK_NORMAL, .aiPool_Cool = FALSE, .aiPool_Beauty = FALSE, @@ -827,7 +864,7 @@ const struct ContestPokemon gContestOpponents[] = .nickname = _("TARVITAR"), .trainerName = _("MILO"), .trainerGfxId = OBJ_EVENT_GFX_MANIAC, - .aiChecks = 0x40040FFF, + .aiFlags = CONTEST_AI_SET_9, .whichRank = CONTEST_RANK_NORMAL, .aiPool_Cool = FALSE, .aiPool_Beauty = FALSE, @@ -855,7 +892,7 @@ const struct ContestPokemon gContestOpponents[] = .nickname = _("RELIA"), .trainerName = _("KARINA"), .trainerGfxId = OBJ_EVENT_GFX_PICNICKER, - .aiChecks = 0x24000FFF, + .aiFlags = CONTEST_AI_SET_10, .whichRank = CONTEST_RANK_SUPER, .aiPool_Cool = FALSE, .aiPool_Beauty = TRUE, @@ -883,7 +920,7 @@ const struct ContestPokemon gContestOpponents[] = .nickname = _("DUODO"), .trainerName = _("BOBBY"), .trainerGfxId = OBJ_EVENT_GFX_RUNNING_TRIATHLETE_M, - .aiChecks = 0x82000FFF, + .aiFlags = CONTEST_AI_SET_2, .whichRank = CONTEST_RANK_SUPER, .aiPool_Cool = TRUE, .aiPool_Beauty = TRUE, @@ -911,7 +948,7 @@ const struct ContestPokemon gContestOpponents[] = .nickname = _("PINCHIN"), .trainerName = _("CLAIRE"), .trainerGfxId = OBJ_EVENT_GFX_GIRL_1, - .aiChecks = 0x81000FFF, + .aiFlags = CONTEST_AI_SET_11, .whichRank = CONTEST_RANK_SUPER, .aiPool_Cool = FALSE, .aiPool_Beauty = FALSE, @@ -939,7 +976,7 @@ const struct ContestPokemon gContestOpponents[] = .nickname = _("NACAC"), .trainerName = _("WILLIE"), .trainerGfxId = OBJ_EVENT_GFX_LITTLE_BOY, - .aiChecks = 0x80800FFF, + .aiFlags = CONTEST_AI_SET_12, .whichRank = CONTEST_RANK_SUPER, .aiPool_Cool = TRUE, .aiPool_Beauty = FALSE, @@ -967,7 +1004,7 @@ const struct ContestPokemon gContestOpponents[] = .nickname = _("SHRAND"), .trainerName = _("CASSIDY"), .trainerGfxId = OBJ_EVENT_GFX_POKEFAN_F, - .aiChecks = 0x10400FFF, + .aiFlags = CONTEST_AI_SET_13, .whichRank = CONTEST_RANK_SUPER, .aiPool_Cool = TRUE, .aiPool_Beauty = FALSE, @@ -995,7 +1032,7 @@ const struct ContestPokemon gContestOpponents[] = .nickname = _("TOYBAL"), .trainerName = _("MORGAN"), .trainerGfxId = OBJ_EVENT_GFX_BLACK_BELT, - .aiChecks = 0x8200FFF, + .aiFlags = CONTEST_AI_SET_14, .whichRank = CONTEST_RANK_SUPER, .aiPool_Cool = FALSE, .aiPool_Beauty = TRUE, @@ -1023,7 +1060,7 @@ const struct ContestPokemon gContestOpponents[] = .nickname = _("CHAMCHAM"), .trainerName = _("SUMMER"), .trainerGfxId = OBJ_EVENT_GFX_WOMAN_4, - .aiChecks = 0x10100FFF, + .aiFlags = CONTEST_AI_SET_15, .whichRank = CONTEST_RANK_SUPER, .aiPool_Cool = TRUE, .aiPool_Beauty = TRUE, @@ -1051,7 +1088,7 @@ const struct ContestPokemon gContestOpponents[] = .nickname = _("SPININ"), .trainerName = _("MILES"), .trainerGfxId = OBJ_EVENT_GFX_CAMPER, - .aiChecks = 0x80080FFF, + .aiFlags = CONTEST_AI_SET_16, .whichRank = CONTEST_RANK_SUPER, .aiPool_Cool = FALSE, .aiPool_Beauty = FALSE, @@ -1079,7 +1116,7 @@ const struct ContestPokemon gContestOpponents[] = .nickname = _("SWABY"), .trainerName = _("AUDREY"), .trainerGfxId = OBJ_EVENT_GFX_LASS, - .aiChecks = 0xA0040FFF, + .aiFlags = CONTEST_AI_SET_17, .whichRank = CONTEST_RANK_SUPER, .aiPool_Cool = FALSE, .aiPool_Beauty = TRUE, @@ -1107,7 +1144,7 @@ const struct ContestPokemon gContestOpponents[] = .nickname = _("POINKER"), .trainerName = _("AVERY"), .trainerGfxId = OBJ_EVENT_GFX_SCHOOL_KID_M, - .aiChecks = 0x80020FFF, + .aiFlags = CONTEST_AI_SET_A, .whichRank = CONTEST_RANK_SUPER, .aiPool_Cool = FALSE, .aiPool_Beauty = FALSE, @@ -1135,7 +1172,7 @@ const struct ContestPokemon gContestOpponents[] = .nickname = _("KECON"), .trainerName = _("ARIANA"), .trainerGfxId = OBJ_EVENT_GFX_GIRL_2, - .aiChecks = 0x80010FFF, + .aiFlags = CONTEST_AI_SET_18, .whichRank = CONTEST_RANK_SUPER, .aiPool_Cool = FALSE, .aiPool_Beauty = FALSE, @@ -1163,7 +1200,7 @@ const struct ContestPokemon gContestOpponents[] = .nickname = _("GOLDEN"), .trainerName = _("ASHTON"), .trainerGfxId = OBJ_EVENT_GFX_MAN_3, - .aiChecks = 0x80008FFF, + .aiFlags = CONTEST_AI_SET_19, .whichRank = CONTEST_RANK_SUPER, .aiPool_Cool = TRUE, .aiPool_Beauty = TRUE, @@ -1191,7 +1228,7 @@ const struct ContestPokemon gContestOpponents[] = .nickname = _("BOBOACH"), .trainerName = _("SANDRA"), .trainerGfxId = OBJ_EVENT_GFX_TWIN, - .aiChecks = 0x80004FFF, + .aiFlags = CONTEST_AI_SET_1A, .whichRank = CONTEST_RANK_SUPER, .aiPool_Cool = FALSE, .aiPool_Beauty = FALSE, @@ -1219,7 +1256,7 @@ const struct ContestPokemon gContestOpponents[] = .nickname = _("CORPY"), .trainerName = _("CARSON"), .trainerGfxId = OBJ_EVENT_GFX_YOUNGSTER, - .aiChecks = 0x8002FFF, + .aiFlags = CONTEST_AI_SET_1B, .whichRank = CONTEST_RANK_SUPER, .aiPool_Cool = TRUE, .aiPool_Beauty = TRUE, @@ -1247,7 +1284,7 @@ const struct ContestPokemon gContestOpponents[] = .nickname = _("TADO"), .trainerName = _("KATRINA"), .trainerGfxId = OBJ_EVENT_GFX_WOMAN_1, - .aiChecks = 0x8001FFF, + .aiFlags = CONTEST_AI_SET_1C, .whichRank = CONTEST_RANK_SUPER, .aiPool_Cool = FALSE, .aiPool_Beauty = TRUE, @@ -1275,7 +1312,7 @@ const struct ContestPokemon gContestOpponents[] = .nickname = _("BROWLO"), .trainerName = _("LUKE"), .trainerGfxId = OBJ_EVENT_GFX_FAT_MAN, - .aiChecks = 0xC000FFF, + .aiFlags = CONTEST_AI_SET_1, .whichRank = CONTEST_RANK_SUPER, .aiPool_Cool = FALSE, .aiPool_Beauty = FALSE, @@ -1303,7 +1340,7 @@ const struct ContestPokemon gContestOpponents[] = .nickname = _("FETCHIN"), .trainerName = _("RAUL"), .trainerGfxId = OBJ_EVENT_GFX_MAN_5, - .aiChecks = 0x82000FFF, + .aiFlags = CONTEST_AI_SET_2, .whichRank = CONTEST_RANK_SUPER, .aiPool_Cool = TRUE, .aiPool_Beauty = FALSE, @@ -1331,7 +1368,7 @@ const struct ContestPokemon gContestOpponents[] = .nickname = _("SEELEY"), .trainerName = _("JADA"), .trainerGfxId = OBJ_EVENT_GFX_WOMAN_2, - .aiChecks = 0x21000FFF, + .aiFlags = CONTEST_AI_SET_3, .whichRank = CONTEST_RANK_SUPER, .aiPool_Cool = FALSE, .aiPool_Beauty = TRUE, @@ -1359,7 +1396,7 @@ const struct ContestPokemon gContestOpponents[] = .nickname = _("DROWZIN"), .trainerName = _("ZEEK"), .trainerGfxId = OBJ_EVENT_GFX_PSYCHIC_M, - .aiChecks = 0x20800FFF, + .aiFlags = CONTEST_AI_SET_4, .whichRank = CONTEST_RANK_SUPER, .aiPool_Cool = FALSE, .aiPool_Beauty = TRUE, @@ -1387,7 +1424,7 @@ const struct ContestPokemon gContestOpponents[] = .nickname = _("HITEMON"), .trainerName = _("DIEGO"), .trainerGfxId = OBJ_EVENT_GFX_EXPERT_M, - .aiChecks = 0x80400FFF, + .aiFlags = CONTEST_AI_SET_5, .whichRank = CONTEST_RANK_SUPER, .aiPool_Cool = TRUE, .aiPool_Beauty = FALSE, @@ -1415,7 +1452,7 @@ const struct ContestPokemon gContestOpponents[] = .nickname = _("BLISS"), .trainerName = _("ALIYAH"), .trainerGfxId = OBJ_EVENT_GFX_TEALA, - .aiChecks = 0x10200FFF, + .aiFlags = CONTEST_AI_SET_6, .whichRank = CONTEST_RANK_SUPER, .aiPool_Cool = FALSE, .aiPool_Beauty = TRUE, @@ -1443,7 +1480,7 @@ const struct ContestPokemon gContestOpponents[] = .nickname = _("KIDLEK"), .trainerName = _("NATALIA"), .trainerGfxId = OBJ_EVENT_GFX_POKEFAN_F, - .aiChecks = 0x20100FFF, + .aiFlags = CONTEST_AI_SET_7, .whichRank = CONTEST_RANK_SUPER, .aiPool_Cool = TRUE, .aiPool_Beauty = FALSE, @@ -1471,7 +1508,7 @@ const struct ContestPokemon gContestOpponents[] = .nickname = _("SNUBBINS"), .trainerName = _("DEVIN"), .trainerGfxId = OBJ_EVENT_GFX_GENTLEMAN, - .aiChecks = 0x8080FFF, + .aiFlags = CONTEST_AI_SET_8, .whichRank = CONTEST_RANK_SUPER, .aiPool_Cool = FALSE, .aiPool_Beauty = FALSE, @@ -1499,7 +1536,7 @@ const struct ContestPokemon gContestOpponents[] = .nickname = _("DREAVIS"), .trainerName = _("TYLOR"), .trainerGfxId = OBJ_EVENT_GFX_HEX_MANIAC, - .aiChecks = 0x40040FFF, + .aiFlags = CONTEST_AI_SET_9, .whichRank = CONTEST_RANK_SUPER, .aiPool_Cool = FALSE, .aiPool_Beauty = TRUE, @@ -1527,7 +1564,7 @@ const struct ContestPokemon gContestOpponents[] = .nickname = _("LAIRN"), .trainerName = _("RONNIE"), .trainerGfxId = OBJ_EVENT_GFX_HIKER, - .aiChecks = 0x84000FFF, + .aiFlags = CONTEST_AI_SET_1D, .whichRank = CONTEST_RANK_HYPER, .aiPool_Cool = FALSE, .aiPool_Beauty = FALSE, @@ -1555,7 +1592,7 @@ const struct ContestPokemon gContestOpponents[] = .nickname = _("SHIFTY"), .trainerName = _("CLAUDIA"), .trainerGfxId = OBJ_EVENT_GFX_GIRL_1, - .aiChecks = 0x82000FFF, + .aiFlags = CONTEST_AI_SET_2, .whichRank = CONTEST_RANK_HYPER, .aiPool_Cool = TRUE, .aiPool_Beauty = TRUE, @@ -1583,7 +1620,7 @@ const struct ContestPokemon gContestOpponents[] = .nickname = _("NINAS"), .trainerName = _("ELIAS"), .trainerGfxId = OBJ_EVENT_GFX_LITTLE_BOY, - .aiChecks = 0x81000FFF, + .aiFlags = CONTEST_AI_SET_11, .whichRank = CONTEST_RANK_HYPER, .aiPool_Cool = FALSE, .aiPool_Beauty = FALSE, @@ -1611,7 +1648,7 @@ const struct ContestPokemon gContestOpponents[] = .nickname = _("WELOW"), .trainerName = _("JADE"), .trainerGfxId = OBJ_EVENT_GFX_POKEFAN_F, - .aiChecks = 0x80800FFF, + .aiFlags = CONTEST_AI_SET_12, .whichRank = CONTEST_RANK_HYPER, .aiPool_Cool = TRUE, .aiPool_Beauty = TRUE, @@ -1639,7 +1676,7 @@ const struct ContestPokemon gContestOpponents[] = .nickname = _("YENA"), .trainerName = _("FRANCIS"), .trainerGfxId = OBJ_EVENT_GFX_BLACK_BELT, - .aiChecks = 0x80400FFF, + .aiFlags = CONTEST_AI_SET_5, .whichRank = CONTEST_RANK_HYPER, .aiPool_Cool = FALSE, .aiPool_Beauty = FALSE, @@ -1667,7 +1704,7 @@ const struct ContestPokemon gContestOpponents[] = .nickname = _("TIFLY"), .trainerName = _("ALISHA"), .trainerGfxId = OBJ_EVENT_GFX_WOMAN_4, - .aiChecks = 0x80200FFF, + .aiFlags = CONTEST_AI_SET_1E, .whichRank = CONTEST_RANK_HYPER, .aiPool_Cool = FALSE, .aiPool_Beauty = TRUE, @@ -1695,7 +1732,7 @@ const struct ContestPokemon gContestOpponents[] = .nickname = _("KINGSEA"), .trainerName = _("SAUL"), .trainerGfxId = OBJ_EVENT_GFX_CAMPER, - .aiChecks = 0x80100FFF, + .aiFlags = CONTEST_AI_SET_1F, .whichRank = CONTEST_RANK_HYPER, .aiPool_Cool = TRUE, .aiPool_Beauty = FALSE, @@ -1723,7 +1760,7 @@ const struct ContestPokemon gContestOpponents[] = .nickname = _("CASTER"), .trainerName = _("FELICIA"), .trainerGfxId = OBJ_EVENT_GFX_LASS, - .aiChecks = 0x80080FFF, + .aiFlags = CONTEST_AI_SET_16, .whichRank = CONTEST_RANK_HYPER, .aiPool_Cool = TRUE, .aiPool_Beauty = TRUE, @@ -1751,7 +1788,7 @@ const struct ContestPokemon gContestOpponents[] = .nickname = _("CHOKEM"), .trainerName = _("EMILIO"), .trainerGfxId = OBJ_EVENT_GFX_SCHOOL_KID_M, - .aiChecks = 0x80040FFF, + .aiFlags = CONTEST_AI_SET_20, .whichRank = CONTEST_RANK_HYPER, .aiPool_Cool = TRUE, .aiPool_Beauty = FALSE, @@ -1779,7 +1816,7 @@ const struct ContestPokemon gContestOpponents[] = .nickname = _("LOMBE"), .trainerName = _("KARLA"), .trainerGfxId = OBJ_EVENT_GFX_GIRL_2, - .aiChecks = 0x80020FFF, + .aiFlags = CONTEST_AI_SET_A, .whichRank = CONTEST_RANK_HYPER, .aiPool_Cool = FALSE, .aiPool_Beauty = TRUE, @@ -1807,7 +1844,7 @@ const struct ContestPokemon gContestOpponents[] = .nickname = _("VIPES"), .trainerName = _("DARRYL"), .trainerGfxId = OBJ_EVENT_GFX_MAN_3, - .aiChecks = 0x80010FFF, + .aiFlags = CONTEST_AI_SET_18, .whichRank = CONTEST_RANK_HYPER, .aiPool_Cool = FALSE, .aiPool_Beauty = FALSE, @@ -1835,7 +1872,7 @@ const struct ContestPokemon gContestOpponents[] = .nickname = _("MERAIL"), .trainerName = _("SELENA"), .trainerGfxId = OBJ_EVENT_GFX_EXPERT_F, - .aiChecks = 0x80008FFF, + .aiFlags = CONTEST_AI_SET_19, .whichRank = CONTEST_RANK_HYPER, .aiPool_Cool = FALSE, .aiPool_Beauty = TRUE, @@ -1863,7 +1900,7 @@ const struct ContestPokemon gContestOpponents[] = .nickname = _("KARPAG"), .trainerName = _("NOEL"), .trainerGfxId = OBJ_EVENT_GFX_YOUNGSTER, - .aiChecks = 0x80004FFF, + .aiFlags = CONTEST_AI_SET_1A, .whichRank = CONTEST_RANK_HYPER, .aiPool_Cool = FALSE, .aiPool_Beauty = FALSE, @@ -1891,7 +1928,7 @@ const struct ContestPokemon gContestOpponents[] = .nickname = _("LUNONE"), .trainerName = _("LACEY"), .trainerGfxId = OBJ_EVENT_GFX_WOMAN_1, - .aiChecks = 0x80002FFF, + .aiFlags = CONTEST_AI_SET_21, .whichRank = CONTEST_RANK_HYPER, .aiPool_Cool = FALSE, .aiPool_Beauty = TRUE, @@ -1919,7 +1956,7 @@ const struct ContestPokemon gContestOpponents[] = .nickname = _("ABSO"), .trainerName = _("CORBIN"), .trainerGfxId = OBJ_EVENT_GFX_MANIAC, - .aiChecks = 0x80001FFF, + .aiFlags = CONTEST_AI_SET_F, .whichRank = CONTEST_RANK_HYPER, .aiPool_Cool = TRUE, .aiPool_Beauty = TRUE, @@ -1947,7 +1984,7 @@ const struct ContestPokemon gContestOpponents[] = .nickname = _("EGGSOR"), .trainerName = _("GRACIE"), .trainerGfxId = OBJ_EVENT_GFX_PICNICKER, - .aiChecks = 0xC000FFF, + .aiFlags = CONTEST_AI_SET_1, .whichRank = CONTEST_RANK_HYPER, .aiPool_Cool = FALSE, .aiPool_Beauty = FALSE, @@ -1975,7 +2012,7 @@ const struct ContestPokemon gContestOpponents[] = .nickname = _("CUBIN"), .trainerName = _("COLTIN"), .trainerGfxId = OBJ_EVENT_GFX_MAN_4, - .aiChecks = 0x82000FFF, + .aiFlags = CONTEST_AI_SET_2, .whichRank = CONTEST_RANK_HYPER, .aiPool_Cool = FALSE, .aiPool_Beauty = FALSE, @@ -2003,7 +2040,7 @@ const struct ContestPokemon gContestOpponents[] = .nickname = _("HITMON"), .trainerName = _("ELLIE"), .trainerGfxId = OBJ_EVENT_GFX_EXPERT_F, - .aiChecks = 0x21000FFF, + .aiFlags = CONTEST_AI_SET_3, .whichRank = CONTEST_RANK_HYPER, .aiPool_Cool = TRUE, .aiPool_Beauty = FALSE, @@ -2031,7 +2068,7 @@ const struct ContestPokemon gContestOpponents[] = .nickname = _("SURTLE"), .trainerName = _("MARCUS"), .trainerGfxId = OBJ_EVENT_GFX_SAILOR, - .aiChecks = 0x20800FFF, + .aiFlags = CONTEST_AI_SET_4, .whichRank = CONTEST_RANK_HYPER, .aiPool_Cool = FALSE, .aiPool_Beauty = FALSE, @@ -2059,7 +2096,7 @@ const struct ContestPokemon gContestOpponents[] = .nickname = _("KHANKAN"), .trainerName = _("KIARA"), .trainerGfxId = OBJ_EVENT_GFX_GIRL_3, - .aiChecks = 0x80400FFF, + .aiFlags = CONTEST_AI_SET_5, .whichRank = CONTEST_RANK_HYPER, .aiPool_Cool = TRUE, .aiPool_Beauty = FALSE, @@ -2087,7 +2124,7 @@ const struct ContestPokemon gContestOpponents[] = .nickname = _("PINOC"), .trainerName = _("BRYCE"), .trainerGfxId = OBJ_EVENT_GFX_BUG_CATCHER, - .aiChecks = 0x10200FFF, + .aiFlags = CONTEST_AI_SET_6, .whichRank = CONTEST_RANK_HYPER, .aiPool_Cool = FALSE, .aiPool_Beauty = TRUE, @@ -2115,7 +2152,7 @@ const struct ContestPokemon gContestOpponents[] = .nickname = _("DILTOT"), .trainerName = _("JAMIE"), .trainerGfxId = OBJ_EVENT_GFX_WOMAN_5, - .aiChecks = 0x20100FFF, + .aiFlags = CONTEST_AI_SET_7, .whichRank = CONTEST_RANK_HYPER, .aiPool_Cool = FALSE, .aiPool_Beauty = FALSE, @@ -2143,7 +2180,7 @@ const struct ContestPokemon gContestOpponents[] = .nickname = _("DOOMOND"), .trainerName = _("JORGE"), .trainerGfxId = OBJ_EVENT_GFX_GENTLEMAN, - .aiChecks = 0x8080FFF, + .aiFlags = CONTEST_AI_SET_8, .whichRank = CONTEST_RANK_HYPER, .aiPool_Cool = TRUE, .aiPool_Beauty = TRUE, @@ -2171,7 +2208,7 @@ const struct ContestPokemon gContestOpponents[] = .nickname = _("MILKAN"), .trainerName = _("DEVON"), .trainerGfxId = OBJ_EVENT_GFX_POKEFAN_M, - .aiChecks = 0x40040FFF, + .aiFlags = CONTEST_AI_SET_9, .whichRank = CONTEST_RANK_HYPER, .aiPool_Cool = FALSE, .aiPool_Beauty = TRUE, @@ -2199,7 +2236,7 @@ const struct ContestPokemon gContestOpponents[] = .nickname = _("RADOS"), .trainerName = _("JUSTINA"), .trainerGfxId = OBJ_EVENT_GFX_PICNICKER, - .aiChecks = 0x84000FFF, + .aiFlags = CONTEST_AI_SET_1D, .whichRank = CONTEST_RANK_MASTER, .aiPool_Cool = TRUE, .aiPool_Beauty = TRUE, @@ -2227,7 +2264,7 @@ const struct ContestPokemon gContestOpponents[] = .nickname = _("LOUDERD"), .trainerName = _("RALPH"), .trainerGfxId = OBJ_EVENT_GFX_EXPERT_M, - .aiChecks = 0x82000FFF, + .aiFlags = CONTEST_AI_SET_2, .whichRank = CONTEST_RANK_MASTER, .aiPool_Cool = TRUE, .aiPool_Beauty = FALSE, @@ -2255,7 +2292,7 @@ const struct ContestPokemon gContestOpponents[] = .nickname = _("SITTY"), .trainerName = _("ROSA"), .trainerGfxId = OBJ_EVENT_GFX_GIRL_1, - .aiChecks = 0x81000FFF, + .aiFlags = CONTEST_AI_SET_11, .whichRank = CONTEST_RANK_MASTER, .aiPool_Cool = FALSE, .aiPool_Beauty = TRUE, @@ -2283,7 +2320,7 @@ const struct ContestPokemon gContestOpponents[] = .nickname = _("SLING"), .trainerName = _("KEATON"), .trainerGfxId = OBJ_EVENT_GFX_LITTLE_BOY, - .aiChecks = 0x80800FFF, + .aiFlags = CONTEST_AI_SET_12, .whichRank = CONTEST_RANK_MASTER, .aiPool_Cool = FALSE, .aiPool_Beauty = FALSE, @@ -2311,7 +2348,7 @@ const struct ContestPokemon gContestOpponents[] = .nickname = _("TARIA"), .trainerName = _("MAYRA"), .trainerGfxId = OBJ_EVENT_GFX_POKEFAN_F, - .aiChecks = 0x80400FFF, + .aiFlags = CONTEST_AI_SET_5, .whichRank = CONTEST_RANK_MASTER, .aiPool_Cool = TRUE, .aiPool_Beauty = TRUE, @@ -2339,7 +2376,7 @@ const struct ContestPokemon gContestOpponents[] = .nickname = _("LIRKI"), .trainerName = _("LAMAR"), .trainerGfxId = OBJ_EVENT_GFX_RICH_BOY, - .aiChecks = 0x80200FFF, + .aiFlags = CONTEST_AI_SET_1E, .whichRank = CONTEST_RANK_MASTER, .aiPool_Cool = TRUE, .aiPool_Beauty = FALSE, @@ -2367,7 +2404,7 @@ const struct ContestPokemon gContestOpponents[] = .nickname = _("BLOSSOM"), .trainerName = _("AUBREY"), .trainerGfxId = OBJ_EVENT_GFX_WOMAN_4, - .aiChecks = 0x80100FFF, + .aiFlags = CONTEST_AI_SET_1F, .whichRank = CONTEST_RANK_MASTER, .aiPool_Cool = FALSE, .aiPool_Beauty = TRUE, @@ -2395,7 +2432,7 @@ const struct ContestPokemon gContestOpponents[] = .nickname = _("EYESAB"), .trainerName = _("NIGEL"), .trainerGfxId = OBJ_EVENT_GFX_CAMPER, - .aiChecks = 0x80080FFF, + .aiFlags = CONTEST_AI_SET_16, .whichRank = CONTEST_RANK_MASTER, .aiPool_Cool = FALSE, .aiPool_Beauty = FALSE, @@ -2423,7 +2460,7 @@ const struct ContestPokemon gContestOpponents[] = .nickname = _("UTAN"), .trainerName = _("CAMILLE"), .trainerGfxId = OBJ_EVENT_GFX_LASS, - .aiChecks = 0x80040FFF, + .aiFlags = CONTEST_AI_SET_20, .whichRank = CONTEST_RANK_MASTER, .aiPool_Cool = FALSE, .aiPool_Beauty = FALSE, @@ -2451,7 +2488,7 @@ const struct ContestPokemon gContestOpponents[] = .nickname = _("PEDOS"), .trainerName = _("DEON"), .trainerGfxId = OBJ_EVENT_GFX_SCHOOL_KID_M, - .aiChecks = 0x80020FFF, + .aiFlags = CONTEST_AI_SET_A, .whichRank = CONTEST_RANK_MASTER, .aiPool_Cool = TRUE, .aiPool_Beauty = FALSE, @@ -2479,7 +2516,7 @@ const struct ContestPokemon gContestOpponents[] = .nickname = _("LUVIS"), .trainerName = _("JANELLE"), .trainerGfxId = OBJ_EVENT_GFX_GIRL_2, - .aiChecks = 0x80010FFF, + .aiFlags = CONTEST_AI_SET_18, .whichRank = CONTEST_RANK_MASTER, .aiPool_Cool = FALSE, .aiPool_Beauty = FALSE, @@ -2507,7 +2544,7 @@ const struct ContestPokemon gContestOpponents[] = .nickname = _("HEROSS"), .trainerName = _("HEATH"), .trainerGfxId = OBJ_EVENT_GFX_MAN_3, - .aiChecks = 0x80008FFF, + .aiFlags = CONTEST_AI_SET_19, .whichRank = CONTEST_RANK_MASTER, .aiPool_Cool = TRUE, .aiPool_Beauty = FALSE, @@ -2535,7 +2572,7 @@ const struct ContestPokemon gContestOpponents[] = .nickname = _("RODLECT"), .trainerName = _("SASHA"), .trainerGfxId = OBJ_EVENT_GFX_TWIN, - .aiChecks = 0x80004FFF, + .aiFlags = CONTEST_AI_SET_1A, .whichRank = CONTEST_RANK_MASTER, .aiPool_Cool = TRUE, .aiPool_Beauty = TRUE, @@ -2563,7 +2600,7 @@ const struct ContestPokemon gContestOpponents[] = .nickname = _("CHUPY"), .trainerName = _("FRANKIE"), .trainerGfxId = OBJ_EVENT_GFX_YOUNGSTER, - .aiChecks = 0x80002FFF, + .aiFlags = CONTEST_AI_SET_21, .whichRank = CONTEST_RANK_MASTER, .aiPool_Cool = FALSE, .aiPool_Beauty = TRUE, @@ -2591,7 +2628,7 @@ const struct ContestPokemon gContestOpponents[] = .nickname = _("WOBET"), .trainerName = _("HELEN"), .trainerGfxId = OBJ_EVENT_GFX_WOMAN_1, - .aiChecks = 0x80001FFF, + .aiFlags = CONTEST_AI_SET_F, .whichRank = CONTEST_RANK_MASTER, .aiPool_Cool = TRUE, .aiPool_Beauty = TRUE, @@ -2619,7 +2656,7 @@ const struct ContestPokemon gContestOpponents[] = .nickname = _("GAREN"), .trainerName = _("CAMILE"), .trainerGfxId = OBJ_EVENT_GFX_HEX_MANIAC, - .aiChecks = 0xC000FFF, + .aiFlags = CONTEST_AI_SET_1, .whichRank = CONTEST_RANK_MASTER, .aiPool_Cool = TRUE, .aiPool_Beauty = FALSE, @@ -2647,7 +2684,7 @@ const struct ContestPokemon gContestOpponents[] = .nickname = _("GONPOR"), .trainerName = _("MARTIN"), .trainerGfxId = OBJ_EVENT_GFX_SCIENTIST_1, - .aiChecks = 0x82000FFF, + .aiFlags = CONTEST_AI_SET_2, .whichRank = CONTEST_RANK_MASTER, .aiPool_Cool = TRUE, .aiPool_Beauty = TRUE, @@ -2675,7 +2712,7 @@ const struct ContestPokemon gContestOpponents[] = .nickname = _("DRITE"), .trainerName = _("SERGIO"), .trainerGfxId = OBJ_EVENT_GFX_BOY_1, - .aiChecks = 0x21000FFF, + .aiFlags = CONTEST_AI_SET_3, .whichRank = CONTEST_RANK_MASTER, .aiPool_Cool = TRUE, .aiPool_Beauty = FALSE, @@ -2703,7 +2740,7 @@ const struct ContestPokemon gContestOpponents[] = .nickname = _("MEOWY"), .trainerName = _("KAILEY"), .trainerGfxId = OBJ_EVENT_GFX_TWIN, - .aiChecks = 0x20800FFF, + .aiFlags = CONTEST_AI_SET_4, .whichRank = CONTEST_RANK_MASTER, .aiPool_Cool = FALSE, .aiPool_Beauty = FALSE, @@ -2731,7 +2768,7 @@ const struct ContestPokemon gContestOpponents[] = .nickname = _("NYX"), .trainerName = _("PERLA"), .trainerGfxId = OBJ_EVENT_GFX_BEAUTY, - .aiChecks = 0x80400FFF, + .aiFlags = CONTEST_AI_SET_5, .whichRank = CONTEST_RANK_MASTER, .aiPool_Cool = FALSE, .aiPool_Beauty = TRUE, @@ -2759,7 +2796,7 @@ const struct ContestPokemon gContestOpponents[] = .nickname = _("GEPITO"), .trainerName = _("CLARA"), .trainerGfxId = OBJ_EVENT_GFX_WOMAN_2, - .aiChecks = 0x10200FFF, + .aiFlags = CONTEST_AI_SET_6, .whichRank = CONTEST_RANK_MASTER, .aiPool_Cool = FALSE, .aiPool_Beauty = FALSE, @@ -2787,7 +2824,7 @@ const struct ContestPokemon gContestOpponents[] = .nickname = _("SPEON"), .trainerName = _("JAKOB"), .trainerGfxId = OBJ_EVENT_GFX_PSYCHIC_M, - .aiChecks = 0x20100FFF, + .aiFlags = CONTEST_AI_SET_7, .whichRank = CONTEST_RANK_MASTER, .aiPool_Cool = TRUE, .aiPool_Beauty = TRUE, @@ -2815,7 +2852,7 @@ const struct ContestPokemon gContestOpponents[] = .nickname = _("SLOWGO"), .trainerName = _("TREY"), .trainerGfxId = OBJ_EVENT_GFX_SAILOR, - .aiChecks = 0x8080FFF, + .aiFlags = CONTEST_AI_SET_8, .whichRank = CONTEST_RANK_MASTER, .aiPool_Cool = FALSE, .aiPool_Beauty = FALSE, @@ -2843,7 +2880,7 @@ const struct ContestPokemon gContestOpponents[] = .nickname = _("URSING"), .trainerName = _("LANE"), .trainerGfxId = OBJ_EVENT_GFX_BLACK_BELT, - .aiChecks = 0x40040FFF, + .aiFlags = CONTEST_AI_SET_9, .whichRank = CONTEST_RANK_MASTER, .aiPool_Cool = TRUE, .aiPool_Beauty = FALSE, diff --git a/src/data/graphics/pokemon.h b/src/data/graphics/pokemon.h index fd4d8b95d..bce0b7a21 100644 --- a/src/data/graphics/pokemon.h +++ b/src/data/graphics/pokemon.h @@ -2698,7 +2698,8 @@ const u8 gMonIcon_Deoxys[] = INCBIN_U8("graphics/pokemon/deoxys/icon.4bpp"); const u8 gMonIcon_DeoxysSpeed[] = INCBIN_U8("graphics/pokemon/deoxys/icon_speed.4bpp"); const u8 gMonIcon_DeoxysSpeedWide[] = INCBIN_U8("graphics/unused/deoxys_speed_icon_wide.4bpp"); -asm(".space 0x6800"); +// Probably the leftover space from the other Deoxys forms +static const u8 sEmpty[0x6800] = {0}; const u16 gUnknown_D437F8[] = INCBIN_U16("graphics/unknown/unknown_D437F8.bin"); diff --git a/src/dewford_trend.c b/src/dewford_trend.c index 9c5e69d99..e3b98859c 100644 --- a/src/dewford_trend.c +++ b/src/dewford_trend.c @@ -225,7 +225,9 @@ void TrendyPhraseIsOld(void) if (gSaveBlock1Ptr->easyChatPairs[0].unk0_0 - gSaveBlock1Ptr->easyChatPairs[1].unk0_0 < 2) { - asm("":::"r2"); //Force the compiler to store address of gSaveBlock1 in r3 instead of r2 + #ifndef NONMATCHING + asm("":::"r2"); //Force the compiler to store address of gSaveBlock1 in r3 instead of r2 + #endif if (!gSaveBlock1Ptr->easyChatPairs[0].unk1_6 && gSaveBlock1Ptr->easyChatPairs[1].unk1_6) result = 1; } diff --git a/src/event_object_movement.c b/src/event_object_movement.c index a076a2a22..72de880c8 100644 --- a/src/event_object_movement.c +++ b/src/event_object_movement.c @@ -8216,15 +8216,13 @@ bool8 FreezeObjectEvent(struct ObjectEvent *objectEvent) { return TRUE; } - else - { - objectEvent->frozen = 1; - objectEvent->spriteAnimPausedBackup = gSprites[objectEvent->spriteId].animPaused; - objectEvent->spriteAffineAnimPausedBackup = gSprites[objectEvent->spriteId].affineAnimPaused; - gSprites[objectEvent->spriteId].animPaused = 1; - gSprites[objectEvent->spriteId].affineAnimPaused = 1; - return FALSE; - } + + objectEvent->frozen = 1; + objectEvent->spriteAnimPausedBackup = gSprites[objectEvent->spriteId].animPaused; + objectEvent->spriteAffineAnimPausedBackup = gSprites[objectEvent->spriteId].affineAnimPaused; + gSprites[objectEvent->spriteId].animPaused = 1; + gSprites[objectEvent->spriteId].affineAnimPaused = 1; + return FALSE; } void FreezeObjectEvents(void) @@ -8397,8 +8395,8 @@ bool8 sub_80976EC(struct Sprite *sprite) if (sprite->data[5] > 15) return TRUE; - else - return FALSE; + + return FALSE; } static const s8 sFigure8XOffsets[FIGURE_8_LENGTH] = { @@ -8478,15 +8476,15 @@ static bool8 AnimateSpriteInFigure8(struct Sprite *sprite) return finished; } -static const s8 gUnknown_0850E802[] = { +static const s8 gUnknown_0850E802[16] = { -4, -6, -8, -10, -11, -12, -12, -12, -11, -10, -9, -8, -6, -4, 0, 0 }; -static const s8 gUnknown_0850E812[] = { +static const s8 gUnknown_0850E812[16] = { 0, -2, -3, -4, -5, -6, -6, -6, -5, -5, -4, -3, -2, 0, 0, 0 }; -static const s8 gUnknown_0850E822[] = { +static const s8 gUnknown_0850E822[16] = { -2, -4, -6, -8, -9, -10, -10, -10, -9, -8, -6, -5, -3, -2, 0, 0 }; @@ -8509,23 +8507,11 @@ void sub_809783C(struct Sprite *sprite, u8 a2, u8 a3, u8 a4) sprite->data[6] = 0; } -static const s16 gUnknown_0850E840[] = { - 16, 16, 32, -}; - -static const u8 gUnknown_0850E846[] = { - 0, 0, 1, -}; - u8 sub_809785C(struct Sprite *sprite) { - s16 v5[3]; - u8 v6[3]; - u8 v2; - - memcpy(v5, gUnknown_0850E840, 6); // TODO: get rid of memcpy - memcpy(v6, gUnknown_0850E846, 3); - v2 = 0; + s16 v5[] = {16, 16, 32}; + u8 v6[] = {0, 0, 1}; + u8 v2 = 0; if (sprite->data[4]) Step1(sprite, sprite->data[3]); @@ -8546,23 +8532,11 @@ u8 sub_809785C(struct Sprite *sprite) return v2; } -static const s16 gUnknown_0850E84A[] = { - 32, 32, 64, -}; - -static const u8 gUnknown_0850E850[] = { - 1, 1, 2, -}; - u8 sub_80978E4(struct Sprite *sprite) { - s16 v5[3]; - u8 v6[3]; - u8 v2; - - memcpy(v5, gUnknown_0850E84A, 6); - memcpy(v6, gUnknown_0850E850, 3); - v2 = 0; + s16 v5[] = {32, 32, 64}; + u8 v6[] = {1, 1, 2}; + u8 v2 = 0; if (sprite->data[4] && !(sprite->data[6] & 1)) Step1(sprite, sprite->data[3]); @@ -8590,12 +8564,9 @@ static void SetMovementDelay(struct Sprite *sprite, s16 timer) static bool8 WaitForMovementDelay(struct Sprite *sprite) { - sprite->data[3]--; - - if (sprite->data[3] == 0) + if (--sprite->data[3] == 0) return TRUE; - else - return FALSE; + return FALSE; } void SetAndStartSpriteAnim(struct Sprite *sprite, u8 animNum, u8 animCmdIndex) @@ -8609,8 +8580,7 @@ bool8 SpriteAnimEnded(struct Sprite *sprite) { if (sprite->animEnded) return TRUE; - else - return FALSE; + return FALSE; } void UpdateObjectEventSpriteVisibility(struct Sprite *sprite, bool8 invisible) @@ -8789,14 +8759,14 @@ static void UpdateObjectEventSpritePosition(struct Sprite *sprite) { switch(sprite->tAnimNum) { + case 0: + break; case UNION_ROOM_SPAWN_IN: MoveUnionRoomObjectDown(sprite); break; case UNION_ROOM_SPAWN_OUT: MoveUnionRoomObjectUp(sprite); break; - case 0: - break; default: sprite->tAnimNum = 0; break; @@ -8877,8 +8847,7 @@ u8 MovementAction_StoreAndLockAnim_Step0(struct ObjectEvent *objectEvent, struct } else { - u8 i; - u8 firstFreeSlot; + u8 i, firstFreeSlot; bool32 found; for (firstFreeSlot = 16, found = FALSE, i = 0; i < 16; i++) { diff --git a/src/fldeff_cut.c b/src/fldeff_cut.c index 785f7b426..991617713 100644 --- a/src/fldeff_cut.c +++ b/src/fldeff_cut.c @@ -227,9 +227,7 @@ bool8 SetUpFieldMove_Cut(void) y = gPlayerFacingPosition.y + sHyperCutStruct[i].y; tileCuttable = TRUE; - j = 0; - do - { + for (j = 0; j < 2; ++j) { if (sHyperCutStruct[i].unk2[j] == 0) break; if (cutTiles[(u8)(sHyperCutStruct[i].unk2[j] - 1)] == FALSE) @@ -237,7 +235,7 @@ bool8 SetUpFieldMove_Cut(void) tileCuttable = FALSE; break; } - } while (++j <= 1); + } if (tileCuttable == TRUE) { @@ -253,11 +251,8 @@ bool8 SetUpFieldMove_Cut(void) sHyperCutTiles[tileArrayId] = TRUE; ret = TRUE; } - else - { - if (MetatileBehavior_IsCuttableGrass(tileBehavior) == TRUE) - sHyperCutTiles[tileArrayId] = TRUE; - } + else if (MetatileBehavior_IsCuttableGrass(tileBehavior) == TRUE) + sHyperCutTiles[tileArrayId] = TRUE; } } } diff --git a/src/frontier_pass.c b/src/frontier_pass.c index 858777738..702f6c098 100644 --- a/src/frontier_pass.c +++ b/src/frontier_pass.c @@ -1239,7 +1239,9 @@ static void sub_80C6104(u8 cursorArea, u8 previousCursorArea) if (!var) { - asm("":::"r4"); + #ifndef NONMATCHING + asm("":::"r4"); + #endif if (previousCursorArea == CURSOR_AREA_NOTHING || previousCursorArea > CURSOR_AREA_CANCEL) return; } diff --git a/src/graphics.c b/src/graphics.c index f43260c61..9a8d9f845 100644 --- a/src/graphics.c +++ b/src/graphics.c @@ -987,8 +987,7 @@ const u16 gTilesetAnims_BattleDomePals0_1[] = INCBIN_U16("graphics/battle_fronti const u16 gTilesetAnims_BattleDomePals0_2[] = INCBIN_U16("graphics/battle_frontier/dome_anim3.gbapal"); const u16 gTilesetAnims_BattleDomePals0_3[] = INCBIN_U16("graphics/battle_frontier/dome_anim4.gbapal"); -// 8D856C0 -asm(".2byte 0x013F, 0x0119, 0x0113, 0x010E"); // unused? +static const u16 sUnused0[] = {0x13F, 0x119, 0x113, 0x10E}; const u16 gUnknown_08D856C8[] = INCBIN_U16("graphics/battle_frontier/pyramid_light.gbapal"); // unfaded pal for the player light in battle pyramid @@ -1362,17 +1361,17 @@ const u8 gBerryBlenderMarubatsuTiles[] = INCBIN_U8("graphics/berry_blender/marub const u8 gBerryBlenderParticlesTiles[] = INCBIN_U8("graphics/berry_blender/particles.4bpp"); -asm(".space 0x120"); +static const u8 sEmpty0[0x120] = {0}; const u8 gBerryBlenderCountdownNumbersTiles[] = INCBIN_U8("graphics/berry_blender/countdown_numbers.4bpp"); const u8 gBerryBlenderStartTiles[] = INCBIN_U8("graphics/berry_blender/start.4bpp"); -asm(".space 0x200"); +static const u8 sEmpty1[0x200] = {0}; const u8 gBerryBlenderArrowTiles[] = INCBIN_U8("graphics/berry_blender/arrow.4bpp"); -asm(".space 0x2C0"); +static const u8 sEmpty2[0x2C0] = {0}; const u16 gEasyChatCursor_Pal[] = INCBIN_U16("graphics/easy_chat/cursor.gbapal"); const u32 gEasyChatCursor_Gfx[] = INCBIN_U32("graphics/easy_chat/cursor.4bpp.lz"); @@ -1481,8 +1480,7 @@ const u16 gTradeGba_Pal[] = INCBIN_U16("graphics/link/gba.gbapal"); const u16 gTradeGba2_Pal[] = INCBIN_U16("graphics/link/gba_pal2.gbapal"); const u8 gTradeGba_Gfx[] = INCBIN_U8("graphics/link/gba.4bpp"); -// 8DD8760 -asm(".space 0x20"); //blank palette?? +static const u16 sEmptyPal[16] = {0}; #include "data/graphics/berry_fix.h" @@ -1564,10 +1562,10 @@ const u32 gUnknown_08DE34B8[] = INCBIN_U32("graphics/berry_crusher/tiles.4bpp.lz const u32 gUnknown_08DE3FD4[] = INCBIN_U32("graphics/berry_crusher/tiles.bin.lz"); // random garbage at the end. -asm(".space 0x54BAC \n\ - .byte 0x0D, 0x00, 0x58, 0x02 \n\ - .space 0x1145 \n\ - .byte 0x02 \n\ - .space 0x3242 \n\ - .byte 0x40 \n\ - .space 0x13"); +static const u8 sEmpty3[0x54BAC] = {0}; +static const u8 sUnused1[] = {0x0D, 0x00, 0x58, 0x02}; +static const u8 sEmpty4[0x1145] = {0}; +static const u8 sUnused2[] = {0x02}; +static const u8 sEmpty5[0x3242] = {0}; +static const u8 sUnused3[] = {0x40}; +static const u8 sEmpty6[0x13] = {0}; diff --git a/src/item_menu.c b/src/item_menu.c index c3ccd3d9d..f2c7b25d8 100755 --- a/src/item_menu.c +++ b/src/item_menu.c @@ -52,6 +52,13 @@ #include "battle_pike.h" #include "constants/rgb.h" +enum +{ + SWITCH_POCKET_NONE, + SWITCH_POCKET_LEFT, + SWITCH_POCKET_RIGHT +}; + void GoToBagMenu(u8 bagMenuType, u8 pocketId, void (*postExitMenuMainCallback2)()); void CB2_Bag(void); bool8 SetupBagMenu(void); @@ -62,7 +69,7 @@ void AllocateBagItemListBuffers(void); void LoadBagItemListBuffers(u8); void BagMenu_PrintPocketNames(const u8*, const u8*); void BagMenu_CopyPocketNameToWindow(u32); -void BagMenu_DrawPocketIndicatorSquare(u8, u8); +static void DrawPocketIndicatorSquare(u8 x, bool8 isCurrentPocket); void CreatePocketScrollArrowPair(void); void CreatePocketSwitchArrowPair(void); void BagMenu_PrepareTMHMMoveWindow(void); @@ -80,16 +87,16 @@ u16 BagGetQuantityByPocketPosition(u8, u16); void BagDestroyPocketSwitchArrowPair(void); void TaskCloseBagMenu_2(u8); u8 AddItemMessageWindow(u8); -void bag_menu_RemoveBagItem_message_window(u8); +void BagMenu_RemoveBagItemMessageindow(u8); void set_callback3_to_bag(u8); void PrintItemDepositAmount(u8, s16); -u8 BagMenu_AddWindow(u8); -u8 GetSwitchBagPocketDirection(void); -void SwitchBagPocket(u8, s16, u16); -bool8 sub_81AC2C0(void); -void BagMenu_SwapItems(u8); -void sub_81AC10C(u8); -void sub_81AC3C0(u8); +static u8 BagMenu_AddWindow(u8); +static u8 GetSwitchBagPocketDirection(void); +static void SwitchBagPocket(u8, s16, u16); +static bool8 CanSwapItems(void); +static void BagMenu_SwapItems(u8 taskId); +static void sub_81AC10C(u8); +static void Task_HandleSwappingItemsInput(u8); void sub_81AC498(u8); void sub_81AC590(u8); void PrintTMHMMoveData(u16); @@ -106,19 +113,18 @@ void BagMenu_YesNo(u8, u8, const struct YesNoFuncTable*); void Task_ActuallyToss(u8); void ItemMenu_Cancel(u8); void sub_81AD350(u8); -void BagMenu_PrintItemCantBeHeld(u8); -void DisplayCurrentMoneyWindow(void); -void DisplaySellItemPriceAndConfirm(u8); +static void BagMenu_PrintItemCantBeHeld(u8); +static void DisplayCurrentMoneyWindow(void); +static void DisplaySellItemPriceAndConfirm(u8); void sub_81AD730(u8); void sub_81AD6E4(u8); -void bag_menu_remove_money_window(void); -void bag_menu_RemoveBagItem_message_window(u8); -void Task_BuyHowManyDialogueHandleInput(u8); -void sub_81AD8C8(u8); -void sub_81AD9C0(u8); -void sub_81ADB14(u8); -void sub_81ADA7C(u8); -void sub_81ADC0C(u8); +static void RemoveMoneyWindow(void); +static void Task_SellHowManyDialogueHandleInput(u8); +static void BagMenu_Sell_UpdateItemListAndMoney(u8); +static void BagMenu_Sell_WaitForABPress(u8); +static void BagMenu_TryDepositItem(u8); +static void Task_ChooseHowManyToDeposit(u8 taskId); +static void BagMenu_Deposit_WaitForABPress(u8); void CB2_ApprenticeExitBagMenu(void); void CB2_FavorLadyExitBagMenu(void); void CB2_QuizLadyExitBagMenu(void); @@ -686,7 +692,7 @@ bool8 SetupBagMenu(void) case 13: BagMenu_PrintPocketNames(gPocketNamesStringsTable[gBagPositionStruct.pocket], 0); BagMenu_CopyPocketNameToWindow(0); - BagMenu_DrawPocketIndicatorSquare(gBagPositionStruct.pocket, 1); + DrawPocketIndicatorSquare(gBagPositionStruct.pocket, TRUE); gMain.state++; break; case 14: @@ -1109,7 +1115,7 @@ void BagMenu_InitListsMenu(u8 taskId) s16* data = gTasks[taskId].data; u16* scrollPos = &gBagPositionStruct.scrollPosition[gBagPositionStruct.pocket]; u16* cursorPos = &gBagPositionStruct.cursorPosition[gBagPositionStruct.pocket]; - bag_menu_RemoveBagItem_message_window(4); + BagMenu_RemoveBagItemMessageindow(4); DestroyListMenuTask(data[0], scrollPos, cursorPos); UpdatePocketItemList(gBagPositionStruct.pocket); SetInitialScrollAndCursorPositions(gBagPositionStruct.pocket); @@ -1152,16 +1158,16 @@ void Task_BagMenu_HandleInput(u8 taskId) { switch (GetSwitchBagPocketDirection()) { - case 1: - SwitchBagPocket(taskId, -1, 0); + case SWITCH_POCKET_LEFT: + SwitchBagPocket(taskId, MENU_CURSOR_DELTA_LEFT, 0); return; - case 2: - SwitchBagPocket(taskId, 1, 0); + case SWITCH_POCKET_RIGHT: + SwitchBagPocket(taskId, MENU_CURSOR_DELTA_RIGHT, 0); return; default: if (gMain.newKeys & SELECT_BUTTON) { - if (sub_81AC2C0() == 1) + if (CanSwapItems() == TRUE) { ListMenuGetScrollAndRow(data[0], scrollPos, cursorPos); if ((*scrollPos + *cursorPos) != gBagMenu->numItemStacks[gBagPositionStruct.pocket] - 1) @@ -1215,26 +1221,26 @@ void set_callback3_to_bag(u8 taskId) gTasks[taskId].func = Task_BagMenu_HandleInput; } -u8 GetSwitchBagPocketDirection(void) +static u8 GetSwitchBagPocketDirection(void) { u8 LRKeys; if (gBagMenu->pocketSwitchDisabled) - return 0; + return SWITCH_POCKET_NONE; LRKeys = GetLRKeysPressed(); if ((gMain.newKeys & DPAD_LEFT) || LRKeys == MENU_L_PRESSED) { PlaySE(SE_SELECT); - return 1; + return SWITCH_POCKET_LEFT; } if ((gMain.newKeys & DPAD_RIGHT) || LRKeys == MENU_R_PRESSED) { PlaySE(SE_SELECT); - return 2; + return SWITCH_POCKET_RIGHT; } - return 0; + return SWITCH_POCKET_NONE; } -void ChangeBagPocketId(u8 *bagPocketId, s8 deltaBagPocketId) +static void ChangeBagPocketId(u8 *bagPocketId, s8 deltaBagPocketId) { if (deltaBagPocketId == 1 && *bagPocketId == POCKETS_COUNT - 1) *bagPocketId = 0; @@ -1244,7 +1250,7 @@ void ChangeBagPocketId(u8 *bagPocketId, s8 deltaBagPocketId) *bagPocketId += deltaBagPocketId; } -void SwitchBagPocket(u8 taskId, s16 deltaBagPocketId, u16 a3) +static void SwitchBagPocket(u8 taskId, s16 deltaBagPocketId, u16 a3) { s16* data = gTasks[taskId].data; u8 pocketId; @@ -1263,7 +1269,7 @@ void SwitchBagPocket(u8 taskId, s16 deltaBagPocketId, u16 a3) } pocketId = gBagPositionStruct.pocket; ChangeBagPocketId(&pocketId, deltaBagPocketId); - if (deltaBagPocketId == 1) + if (deltaBagPocketId == MENU_CURSOR_DELTA_RIGHT) { BagMenu_PrintPocketNames(gPocketNamesStringsTable[gBagPositionStruct.pocket], gPocketNamesStringsTable[pocketId]); BagMenu_CopyPocketNameToWindow(0); @@ -1273,8 +1279,8 @@ void SwitchBagPocket(u8 taskId, s16 deltaBagPocketId, u16 a3) BagMenu_PrintPocketNames(gPocketNamesStringsTable[pocketId], gPocketNamesStringsTable[gBagPositionStruct.pocket]); BagMenu_CopyPocketNameToWindow(8); } - BagMenu_DrawPocketIndicatorSquare(gBagPositionStruct.pocket, 0); - BagMenu_DrawPocketIndicatorSquare(pocketId, 1); + DrawPocketIndicatorSquare(gBagPositionStruct.pocket, FALSE); + DrawPocketIndicatorSquare(pocketId, TRUE); FillBgTilemapBufferRect_Palette0(2, 11, 14, 2, 15, 16); ScheduleBgCopyTilemapToVram(2); SetBagVisualPocketId(pocketId, 1); @@ -1291,15 +1297,15 @@ void sub_81AC10C(u8 taskId) { switch (GetSwitchBagPocketDirection()) { - case 1: + case SWITCH_POCKET_LEFT: ChangeBagPocketId(&gBagPositionStruct.pocket, data[11]); SwitchTaskToFollowupFunc(taskId); - SwitchBagPocket(taskId, -1, 1); + SwitchBagPocket(taskId, MENU_CURSOR_DELTA_LEFT, 1); return; - case 2: + case SWITCH_POCKET_RIGHT: ChangeBagPocketId(&gBagPositionStruct.pocket, data[11]); SwitchTaskToFollowupFunc(taskId); - SwitchBagPocket(taskId, 1, 1); + SwitchBagPocket(taskId, MENU_CURSOR_DELTA_RIGHT, 1); return; } } @@ -1336,16 +1342,16 @@ void sub_81AC23C(u8 a) ScheduleBgCopyTilemapToVram(2); } -void BagMenu_DrawPocketIndicatorSquare(u8 x, u8 is_current_bag) +static void DrawPocketIndicatorSquare(u8 x, bool8 isCurrentPocket) { - if (is_current_bag == 0) + if (!isCurrentPocket) FillBgTilemapBufferRect_Palette0(2, 0x1017, x + 5, 3, 1, 1); else FillBgTilemapBufferRect_Palette0(2, 0x102B, x + 5, 3, 1, 1); ScheduleBgCopyTilemapToVram(2); } -bool8 sub_81AC2C0(void) +static bool8 CanSwapItems(void) { if (gBagPositionStruct.location <= ITEMMENULOCATION_BATTLE) { @@ -1370,10 +1376,10 @@ void BagMenu_SwapItems(u8 taskId) sub_80D4FEC(data[1]); BagDestroyPocketSwitchArrowPair(); BagMenu_PrintCursor_(data[0], 2); - gTasks[taskId].func = sub_81AC3C0; + gTasks[taskId].func = Task_HandleSwappingItemsInput; } -void sub_81AC3C0(u8 taskId) +static void Task_HandleSwappingItemsInput(u8 taskId) { s16* data = gTasks[taskId].data; int input; @@ -1642,7 +1648,7 @@ void Task_HandleOutOfBattleItemMenuInput(u8 taskId) if (cursorPos > 0 && sub_81ACDFC(cursorPos - 2)) { PlaySE(SE_SELECT); - sub_8199134(0, -1); + ChangeListMenuCursorPosition(MENU_CURSOR_DELTA_NONE, MENU_CURSOR_DELTA_UP); } } else if (gMain.newKeys & DPAD_DOWN) @@ -1650,7 +1656,7 @@ void Task_HandleOutOfBattleItemMenuInput(u8 taskId) if (cursorPos < (gBagMenu->contextMenuNumItems - 2) && sub_81ACDFC(cursorPos + 2)) { PlaySE(SE_SELECT); - sub_8199134(0, 1); + ChangeListMenuCursorPosition(MENU_CURSOR_DELTA_NONE, MENU_CURSOR_DELTA_DOWN); } } else if ((gMain.newKeys & DPAD_LEFT) || GetLRKeysPressed() == MENU_L_PRESSED) @@ -1658,7 +1664,7 @@ void Task_HandleOutOfBattleItemMenuInput(u8 taskId) if ((cursorPos & 1) && sub_81ACDFC(cursorPos - 1)) { PlaySE(SE_SELECT); - sub_8199134(-1, 0); + ChangeListMenuCursorPosition(MENU_CURSOR_DELTA_LEFT, MENU_CURSOR_DELTA_NONE); } } else if ((gMain.newKeys & DPAD_RIGHT) || GetLRKeysPressed() == MENU_R_PRESSED) @@ -1666,7 +1672,7 @@ void Task_HandleOutOfBattleItemMenuInput(u8 taskId) if (!(cursorPos & 1) && sub_81ACDFC(cursorPos + 1)) { PlaySE(SE_SELECT); - sub_8199134(1, 0); + ChangeListMenuCursorPosition(MENU_CURSOR_DELTA_RIGHT, MENU_CURSOR_DELTA_NONE); } } else if (gMain.newKeys & A_BUTTON) @@ -1869,7 +1875,7 @@ void BagMenu_PrintThereIsNoPokemon(u8 taskId) DisplayItemMessage(taskId, 1, gText_NoPokemon, sub_81AD350); } -void BagMenu_PrintItemCantBeHeld(u8 taskId) +static void BagMenu_PrintItemCantBeHeld(u8 taskId) { CopyItemName(gSpecialVar_ItemId, gStringVar1); StringExpandPlaceholders(gStringVar4, gText_Var1CantBeHeld); @@ -2010,7 +2016,7 @@ void Task_ItemContext_Sell(u8 taskId) } } -void DisplaySellItemPriceAndConfirm(u8 taskId) +static void DisplaySellItemPriceAndConfirm(u8 taskId) { s16* data = gTasks[taskId].data; @@ -2028,8 +2034,8 @@ void BagMenu_CancelSell(u8 taskId) { s16* data = gTasks[taskId].data; - bag_menu_remove_money_window(); - bag_menu_RemoveBagItem_message_window(4); + RemoveMoneyWindow(); + BagMenu_RemoveBagItemMessageindow(4); BagMenu_PrintCursor_(data[0], 0); set_callback3_to_bag(taskId); } @@ -2041,10 +2047,10 @@ void sub_81AD730(u8 taskId) PrintItemSoldAmount(windowId, 1, (ItemId_GetPrice(gSpecialVar_ItemId) / 2) * tItemCount); DisplayCurrentMoneyWindow(); - gTasks[taskId].func = Task_BuyHowManyDialogueHandleInput; + gTasks[taskId].func = Task_SellHowManyDialogueHandleInput; } -void Task_BuyHowManyDialogueHandleInput(u8 taskId) +static void Task_SellHowManyDialogueHandleInput(u8 taskId) { s16* data = gTasks[taskId].data; @@ -2062,9 +2068,9 @@ void Task_BuyHowManyDialogueHandleInput(u8 taskId) { PlaySE(SE_SELECT); BagMenu_PrintCursor_(data[0], 0); - bag_menu_remove_money_window(); + RemoveMoneyWindow(); BagMenu_RemoveWindow(8); - bag_menu_RemoveBagItem_message_window(4); + BagMenu_RemoveBagItemMessageindow(4); set_callback3_to_bag(taskId); } } @@ -2076,10 +2082,10 @@ void BagMenu_ConfirmSell(u8 taskId) CopyItemName(gSpecialVar_ItemId, gStringVar2); ConvertIntToDecimalStringN(gStringVar1, (ItemId_GetPrice(gSpecialVar_ItemId) / 2) * tItemCount, STR_CONV_MODE_LEFT_ALIGN, 6); StringExpandPlaceholders(gStringVar4, gText_TurnedOverVar1ForVar2); - DisplayItemMessage(taskId, 1, gStringVar4, sub_81AD8C8); + DisplayItemMessage(taskId, 1, gStringVar4, BagMenu_Sell_UpdateItemListAndMoney); } -void sub_81AD8C8(u8 taskId) +static void BagMenu_Sell_UpdateItemListAndMoney(u8 taskId) { s16* data = gTasks[taskId].data; u16* scrollPos = &gBagPositionStruct.scrollPosition[gBagPositionStruct.pocket]; @@ -2095,15 +2101,15 @@ void sub_81AD8C8(u8 taskId) data[0] = ListMenuInit(&gMultiuseListMenuTemplate, *scrollPos, *cursorPos); BagMenu_PrintCursor_(data[0], 2); PrintMoneyAmountInMoneyBox(gBagMenu->windowPointers[9], GetMoney(&gSaveBlock1Ptr->money), 0); - gTasks[taskId].func = sub_81AD9C0; + gTasks[taskId].func = BagMenu_Sell_WaitForABPress; } -void sub_81AD9C0(u8 taskId) +static void BagMenu_Sell_WaitForABPress(u8 taskId) { if (gMain.newKeys & (A_BUTTON | B_BUTTON)) { PlaySE(SE_SELECT); - bag_menu_remove_money_window(); + RemoveMoneyWindow(); BagMenu_InitListsMenu(taskId); } } @@ -2115,7 +2121,7 @@ void Task_ItemContext_Deposit(u8 taskId) tItemCount = 1; if (data[2] == 1) { - sub_81ADB14(taskId); + BagMenu_TryDepositItem(taskId); } else { @@ -2124,11 +2130,11 @@ void Task_ItemContext_Deposit(u8 taskId) FillWindowPixelBuffer(1, PIXEL_FILL(0)); BagMenu_Print(1, 1, gStringVar4, 3, 1, 0, 0, 0, 0); sub_81ABC3C(7); - gTasks[taskId].func = sub_81ADA7C; + gTasks[taskId].func = Task_ChooseHowManyToDeposit; } } -void sub_81ADA7C(u8 taskId) +static void Task_ChooseHowManyToDeposit(u8 taskId) { s16* data = gTasks[taskId].data; @@ -2140,7 +2146,7 @@ void sub_81ADA7C(u8 taskId) { PlaySE(SE_SELECT); BagMenu_RemoveWindow(7); - sub_81ADB14(taskId); + BagMenu_TryDepositItem(taskId); } else if (gMain.newKeys & B_BUTTON) { @@ -2152,7 +2158,7 @@ void sub_81ADA7C(u8 taskId) } } -void sub_81ADB14(u8 taskId) +static void BagMenu_TryDepositItem(u8 taskId) { s16* data = gTasks[taskId].data; @@ -2160,7 +2166,7 @@ void sub_81ADB14(u8 taskId) if (ItemId_GetImportance(gSpecialVar_ItemId)) { BagMenu_Print(1, 1, gText_CantStoreImportantItems, 3, 1, 0, 0, 0, 0); - gTasks[taskId].func = sub_81ADC0C; + gTasks[taskId].func = BagMenu_Deposit_WaitForABPress; } else if (AddPCItem(gSpecialVar_ItemId, tItemCount) == TRUE) { @@ -2173,11 +2179,11 @@ void sub_81ADB14(u8 taskId) else { BagMenu_Print(1, 1, gText_NoRoomForItems, 3, 1, 0, 0, 0, 0); - gTasks[taskId].func = sub_81ADC0C; + gTasks[taskId].func = BagMenu_Deposit_WaitForABPress; } } -void sub_81ADC0C(u8 taskId) +static void BagMenu_Deposit_WaitForABPress(u8 taskId) { s16* data = gTasks[taskId].data; @@ -2248,7 +2254,7 @@ void Task_WallyTutorialBagMenu(u8 taskId) { case 0x66: PlaySE(SE_SELECT); - SwitchBagPocket(taskId, 1, 0); + SwitchBagPocket(taskId, MENU_CURSOR_DELTA_RIGHT, 0); data[8]++; break; case 0xCC: @@ -2414,7 +2420,7 @@ u8 AddItemMessageWindow(u8 which) return *ptr; } -void bag_menu_RemoveBagItem_message_window(u8 which) +void BagMenu_RemoveBagItemMessageindow(u8 which) { u8 *ptr = &gBagMenu->windowPointers[which]; if (*ptr != 0xFF) @@ -2433,14 +2439,14 @@ void BagMenu_YesNo(u8 a, u8 b, const struct YesNoFuncTable *funcTable) CreateYesNoMenuWithCallbacks(a, &sContextMenuWindowTemplates[b], 1, 0, 2, 1, 14, funcTable); } -void DisplayCurrentMoneyWindow(void) +static void DisplayCurrentMoneyWindow(void) { u8 windowId = BagMenu_AddWindow(9); PrintMoneyAmountInMoneyBoxWithBorder(windowId, 1, 14, GetMoney(&gSaveBlock1Ptr->money)); AddMoneyLabelObject(19, 11); } -void bag_menu_remove_money_window(void) +static void RemoveMoneyWindow(void) { BagMenu_RemoveWindow(9); RemoveMoneyLabelObject(); diff --git a/src/librfu_intr.c b/src/librfu_intr.c index 23962a937..1361be40e 100644 --- a/src/librfu_intr.c +++ b/src/librfu_intr.c @@ -148,7 +148,11 @@ static void sio32intr_clock_slave(void) { u32 regSIODATA32; u32 r0; - register u32 reqLen asm("r2"); + #ifndef NONMATCHING + register u32 reqLen asm("r2"); + #else + u32 reqLen; + #endif gSTWIStatus->timerActive = 0; STWI_set_timer_in_RAM(100); diff --git a/src/link_rfu_2.c b/src/link_rfu_2.c index 3372aa766..a8ead95d6 100644 --- a/src/link_rfu_2.c +++ b/src/link_rfu_2.c @@ -876,8 +876,7 @@ static void sub_800F498(u16 *a0, u8 *a1) static bool32 RfuProcessEnqueuedRecvBlock(void) { - u8 i; - u8 j; + u8 i, j; u8 sp00[MAX_RFU_PLAYERS * (2 * (CMD_LENGTH - 1))]; u8 sp48[2 * (CMD_LENGTH - 1)]; u8 status; @@ -923,7 +922,7 @@ static bool32 RfuProcessEnqueuedRecvBlock(void) static void HandleSendFailure(u8 unused, u32 flags) { - s32 i, j; + s32 i, j, temp; const u8 *r10 = Rfu.sendBlock.payload; for (i = 0; i < Rfu.sendBlock.count; i++) @@ -933,14 +932,15 @@ static void HandleSendFailure(u8 unused, u32 flags) sResendBlock16[0] = RFU_COMMAND_0x8900 | i; for (j = 0; j < 7; j++) { - sResendBlock16[j + 1] = (r10[12 * i + (j << 1) + 1] << 8) | r10[12 * i + (j << 1) + 0]; + temp = j << 1; + sResendBlock16[j + 1] = (r10[i * 12 + temp + 1] << 8) | r10[i * 12 + temp]; } + for (j = 0; j < 7; j++) { - sResendBlock8[2 * j + 1] = sResendBlock16[j] >> 8; - sResendBlock8[2 * j + 0] = sResendBlock16[j]; - - j++;j--; // Needed to match; + temp = j << 1; + sResendBlock8[temp + 1] = sResendBlock16[j] >> 8; + sResendBlock8[temp + 0] = sResendBlock16[j] & 0xff; } RfuSendQueue_Enqueue(&Rfu.sendQueue, sResendBlock8); Rfu.sendBlock.failedFlags |= (1 << i); @@ -1024,8 +1024,7 @@ void sub_800F850(void) static void RfuHandleReceiveCommand(u8 unused) { - u16 i; - u16 j; + u16 i, j; for (i = 0; i < MAX_RFU_PLAYERS; i++) { @@ -1039,7 +1038,7 @@ static void RfuHandleReceiveCommand(u8 unused) if (gRfuLinkStatus->parentChild == MODE_CHILD) { Rfu.playerCount = gRecvCmds[i][1]; - Rfu.multiplayerId = sub_800F74C((u8 *)(gRecvCmds[i] + 2)); + Rfu.multiplayerId = sub_800F74C((u8 *)(&gRecvCmds[i][2])); } break; case RFU_COMMAND_0x8800: @@ -1238,10 +1237,9 @@ void sub_800FE50(void *a0) bool32 Rfu_InitBlockSend(const u8 *src, size_t size) { bool8 r4; - if (Rfu.callback != NULL) - return FALSE; - if (gSendCmd[0] != 0) + if (Rfu.callback != NULL || gSendCmd[0] != 0) return FALSE; + if (Rfu.sendBlock.sending) { sRfuDebug.unk_83++; @@ -1419,16 +1417,12 @@ void Rfu_SetCloseLinkCallback(void) static void SendReadyExitStandbyUntilAllReady(void) { - u8 playerCount; - u8 i; + u8 i, playerCount; - if (GetMultiplayerId() != 0) + if (GetMultiplayerId() != 0 && Rfu.recvQueue.count == 0 && Rfu.resendExitStandbyTimer > 60) { - if (Rfu.recvQueue.count == 0 && Rfu.resendExitStandbyTimer > 60) - { - RfuPrepareSendBuffer(RFU_COMMAND_READY_EXIT_STANDBY); - Rfu.resendExitStandbyTimer = 0; - } + RfuPrepareSendBuffer(RFU_COMMAND_READY_EXIT_STANDBY); + Rfu.resendExitStandbyTimer = 0; } playerCount = GetLinkPlayerCount(); for (i = 0; i < playerCount; i++) @@ -1458,8 +1452,7 @@ static void LinkLeaderReadyToExitStandby(void) // RFU equivalent of LinkCB_Standby and LinkCB_StandbyForAll static void Rfu_LinkStandby(void) { - u8 i; - u8 playerCount; + u8 i, playerCount; if (GetMultiplayerId() != 0) { @@ -1555,28 +1548,28 @@ static bool8 CheckForLeavingGroupMembers(void) bool8 memberLeft = FALSE; for (i = 0; i < RFU_CHILD_MAX; i++) { - if (Rfu.partnerSendStatuses[i] < RFU_STATUS_JOIN_GROUP_OK - || Rfu.partnerSendStatuses[i] > RFU_STATUS_JOIN_GROUP_NO) + if (Rfu.partnerSendStatuses[i] == RFU_STATUS_JOIN_GROUP_OK + || Rfu.partnerSendStatuses[i] == RFU_STATUS_JOIN_GROUP_NO) { - if (gRfuSlotStatusNI[i]->recv.state == SLOT_STATE_RECV_SUCCESS - || gRfuSlotStatusNI[i]->recv.state == SLOT_STATE_RECV_SUCCESS_AND_SENDSIDE_UNKNOWN) - { - if (Rfu.partnerRecvStatuses[i] == RFU_STATUS_LEAVE_GROUP_NOTICE) - { - Rfu.partnerSendStatuses[i] = RFU_STATUS_LEAVE_GROUP; - Rfu.partnerRecvStatuses[i] = RFU_STATUS_10; - rfu_clearSlot(TYPE_NI_RECV, i); - rfu_NI_setSendData(1 << i, 8, &Rfu.partnerSendStatuses[i], 1); - memberLeft = TRUE; - } + continue; + } - } - else if (gRfuSlotStatusNI[Rfu.childSlot]->recv.state == SLOT_STATE_RECV_FAILED) - rfu_clearSlot(TYPE_NI_RECV, i); + if (gRfuSlotStatusNI[i]->recv.state == SLOT_STATE_RECV_SUCCESS + || gRfuSlotStatusNI[i]->recv.state == SLOT_STATE_RECV_SUCCESS_AND_SENDSIDE_UNKNOWN) + { + if (Rfu.partnerRecvStatuses[i] == RFU_STATUS_LEAVE_GROUP_NOTICE) { - + Rfu.partnerSendStatuses[i] = RFU_STATUS_LEAVE_GROUP; + Rfu.partnerRecvStatuses[i] = RFU_STATUS_10; + rfu_clearSlot(TYPE_NI_RECV, i); + rfu_NI_setSendData(1 << i, 8, &Rfu.partnerSendStatuses[i], 1); + memberLeft = TRUE; } } + else if (gRfuSlotStatusNI[Rfu.childSlot]->recv.state == SLOT_STATE_RECV_FAILED) + { + rfu_clearSlot(TYPE_NI_RECV, i); + } } return memberLeft; } @@ -2097,8 +2090,7 @@ static void sub_80111FC(void) static void sub_801120C(u8 msg, u8 paramCount) { - u8 i; - u8 disconnectFlag = 0; + u8 i, disconnectFlag = 0; switch (msg) { case LMAN_MSG_INITIALIZE_COMPLETED: diff --git a/src/list_menu.c b/src/list_menu.c index ebf02bab6..ef55f5872 100644 --- a/src/list_menu.c +++ b/src/list_menu.c @@ -1282,7 +1282,7 @@ void ListMenuSetUpRedOutlineCursorSpriteOamTable(u16 rowWidth, u16 rowHeight, st { subsprites[id] = sSubsprite_RedOutline3; subsprites[id].x = i - 120; - subsprites[id].y = 136; + subsprites[id].y = -120; id++; subsprites[id] = sSubsprite_RedOutline6; @@ -904,7 +904,9 @@ void CgbModVol(struct CgbChannel *chan) // Force chan->rightVolume and chan->leftVolume to be read from memory again, // even though there is no reason to do so. // The command line option "-fno-gcse" achieves the same result as this. - asm("" : : : "memory"); + #ifndef NONMATCHING + asm("" : : : "memory"); + #endif chan->eg = (u32)(chan->rightVolume + chan->leftVolume) >> 4; if (chan->eg > 15) diff --git a/src/menu.c b/src/menu.c index ac2f7d85b..f3334919c 100644 --- a/src/menu.c +++ b/src/menu.c @@ -1299,10 +1299,12 @@ u8 sub_8198F58(u8 windowId, u8 fontId, u8 left, u8 top, u8 a4, u8 cursorHeight, else sMenu.cursorPos = pos; - sub_8199134(0, 0); + // Why call this when it's not gonna move? + ChangeListMenuCursorPosition(MENU_CURSOR_DELTA_NONE, MENU_CURSOR_DELTA_NONE); return sMenu.cursorPos; } +// Unused u8 sub_8198FD4(u8 windowId, u8 fontId, u8 left, u8 top, u8 a4, u8 a5, u8 a6, u8 a7) { u8 cursorHeight = GetMenuCursorDimensionByFont(fontId, 1); @@ -1333,40 +1335,28 @@ void sub_8199060(u8 oldCursorPos, u8 newCursorPos) 0); } -u8 sub_8199134(s8 deltaX, s8 deltaY) +u8 ChangeListMenuCursorPosition(s8 deltaX, s8 deltaY) { u8 oldPos = sMenu.cursorPos; if (deltaX != 0) { if ((sMenu.cursorPos % sMenu.columns) + deltaX < 0) - { sMenu.cursorPos += sMenu.columns - 1; - } else if ((sMenu.cursorPos % sMenu.columns) + deltaX >= sMenu.columns) - { sMenu.cursorPos = (sMenu.cursorPos / sMenu.columns) * sMenu.columns; - } else - { sMenu.cursorPos += deltaX; - } } if (deltaY != 0) { if ((sMenu.cursorPos / sMenu.columns) + deltaY < 0) - { sMenu.cursorPos += sMenu.columns * (sMenu.rows - 1); - } else if ((sMenu.cursorPos / sMenu.columns) + deltaY >= sMenu.rows) - { sMenu.cursorPos -= sMenu.columns * (sMenu.rows - 1); - } else - { sMenu.cursorPos += (sMenu.columns * deltaY); - } } if (sMenu.cursorPos > sMenu.maxCursorPos) @@ -1381,7 +1371,7 @@ u8 sub_8199134(s8 deltaX, s8 deltaY) } } -u8 sub_81991F8(s8 deltaX, s8 deltaY) +u8 ChangeGridMenuCursorPosition(s8 deltaX, s8 deltaY) { u8 oldPos = sMenu.cursorPos; @@ -1429,25 +1419,25 @@ s8 sub_8199284(void) else if (gMain.newKeys & DPAD_UP) { PlaySE(SE_SELECT); - sub_8199134(0, -1); + ChangeListMenuCursorPosition(MENU_CURSOR_DELTA_NONE, MENU_CURSOR_DELTA_UP); return MENU_NOTHING_CHOSEN; } else if (gMain.newKeys & DPAD_DOWN) { PlaySE(SE_SELECT); - sub_8199134(0, 1); + ChangeListMenuCursorPosition(MENU_CURSOR_DELTA_NONE, MENU_CURSOR_DELTA_DOWN); return MENU_NOTHING_CHOSEN; } else if (gMain.newKeys & DPAD_LEFT || GetLRKeysPressed() == MENU_L_PRESSED) { PlaySE(SE_SELECT); - sub_8199134(-1, 0); + ChangeListMenuCursorPosition(MENU_CURSOR_DELTA_LEFT, MENU_CURSOR_DELTA_NONE); return MENU_NOTHING_CHOSEN; } else if (gMain.newKeys & DPAD_RIGHT || GetLRKeysPressed() == MENU_R_PRESSED) { PlaySE(SE_SELECT); - sub_8199134(1, 0); + ChangeListMenuCursorPosition(MENU_CURSOR_DELTA_RIGHT, MENU_CURSOR_DELTA_NONE); return MENU_NOTHING_CHOSEN; } @@ -1469,25 +1459,25 @@ s8 Menu_ProcessInputGridLayout(void) } else if (gMain.newKeys & DPAD_UP) { - if (oldPos != sub_81991F8(0, -1)) + if (oldPos != ChangeGridMenuCursorPosition(0, -1)) PlaySE(SE_SELECT); return MENU_NOTHING_CHOSEN; } else if (gMain.newKeys & DPAD_DOWN) { - if (oldPos != sub_81991F8(0, 1)) + if (oldPos != ChangeGridMenuCursorPosition(0, 1)) PlaySE(SE_SELECT); return MENU_NOTHING_CHOSEN; } else if (gMain.newKeys & DPAD_LEFT || GetLRKeysPressed() == MENU_L_PRESSED) { - if (oldPos != sub_81991F8(-1, 0)) + if (oldPos != ChangeGridMenuCursorPosition(-1, 0)) PlaySE(SE_SELECT); return MENU_NOTHING_CHOSEN; } else if (gMain.newKeys & DPAD_RIGHT || GetLRKeysPressed() == MENU_R_PRESSED) { - if (oldPos != sub_81991F8(1, 0)) + if (oldPos != ChangeGridMenuCursorPosition(1, 0)) PlaySE(SE_SELECT); return MENU_NOTHING_CHOSEN; } @@ -1509,31 +1499,32 @@ s8 sub_81993D8(void) else if ((gMain.newAndRepeatedKeys & DPAD_ANY) == DPAD_UP) { PlaySE(SE_SELECT); - sub_8199134(0, -1); + ChangeListMenuCursorPosition(MENU_CURSOR_DELTA_NONE, MENU_CURSOR_DELTA_UP); return MENU_NOTHING_CHOSEN; } else if ((gMain.newAndRepeatedKeys & DPAD_ANY) == DPAD_DOWN) { PlaySE(SE_SELECT); - sub_8199134(0, 1); + ChangeListMenuCursorPosition(MENU_CURSOR_DELTA_NONE, MENU_CURSOR_DELTA_DOWN); return MENU_NOTHING_CHOSEN; } else if ((gMain.newAndRepeatedKeys & DPAD_ANY) == DPAD_LEFT || GetLRKeysPressedAndHeld() == MENU_L_PRESSED) { PlaySE(SE_SELECT); - sub_8199134(-1, 0); + ChangeListMenuCursorPosition(MENU_CURSOR_DELTA_LEFT, MENU_CURSOR_DELTA_NONE); return MENU_NOTHING_CHOSEN; } else if ((gMain.newAndRepeatedKeys & DPAD_ANY) == DPAD_RIGHT || GetLRKeysPressedAndHeld() == MENU_R_PRESSED) { PlaySE(SE_SELECT); - sub_8199134(1, 0); + ChangeListMenuCursorPosition(MENU_CURSOR_DELTA_RIGHT, MENU_CURSOR_DELTA_NONE); return MENU_NOTHING_CHOSEN; } return MENU_NOTHING_CHOSEN; } +//Unused s8 sub_8199484(void) { u8 oldPos = sMenu.cursorPos; @@ -1549,25 +1540,25 @@ s8 sub_8199484(void) } else if ((gMain.newAndRepeatedKeys & DPAD_ANY) == DPAD_UP) { - if (oldPos != sub_81991F8(0, -1)) + if (oldPos != ChangeGridMenuCursorPosition(0, -1)) PlaySE(SE_SELECT); return MENU_NOTHING_CHOSEN; } else if ((gMain.newAndRepeatedKeys & DPAD_ANY) == DPAD_DOWN) { - if (oldPos != sub_81991F8(0, 1)) + if (oldPos != ChangeGridMenuCursorPosition(0, 1)) PlaySE(SE_SELECT); return MENU_NOTHING_CHOSEN; } else if ((gMain.newAndRepeatedKeys & DPAD_ANY) == DPAD_LEFT || GetLRKeysPressedAndHeld() == MENU_L_PRESSED) { - if (oldPos != sub_81991F8(-1, 0)) + if (oldPos != ChangeGridMenuCursorPosition(-1, 0)) PlaySE(SE_SELECT); return MENU_NOTHING_CHOSEN; } else if ((gMain.newAndRepeatedKeys & DPAD_ANY) == DPAD_RIGHT || GetLRKeysPressedAndHeld() == MENU_R_PRESSED) { - if (oldPos != sub_81991F8(1, 0)) + if (oldPos != ChangeGridMenuCursorPosition(1, 0)) PlaySE(SE_SELECT); return MENU_NOTHING_CHOSEN; } @@ -1732,7 +1723,8 @@ u8 sub_8199944(u8 windowId, u8 optionWidth, u8 columns, u8 rows, u8 initialCurso else sMenu.cursorPos = pos; - sub_8199134(0, 0); + // Why call this when it's not gonna move? + ChangeListMenuCursorPosition(MENU_CURSOR_DELTA_NONE, MENU_CURSOR_DELTA_NONE); return sMenu.cursorPos; } diff --git a/src/menu_specialized.c b/src/menu_specialized.c index a99c5c9d0..d402ecb51 100644 --- a/src/menu_specialized.c +++ b/src/menu_specialized.c @@ -894,76 +894,73 @@ static u8 *GetConditionMenuMonString(u8 *dst, u16 boxId, u16 monId) { return StringCopyPadded(dst, gText_EggNickname, 0, 12); } + GetBoxOrPartyMonData(boxId, monId, MON_DATA_NICKNAME, dst); + StringGetEnd10(dst); + species = GetBoxOrPartyMonData(boxId, monId, MON_DATA_SPECIES, NULL); + if (boxId == TOTAL_BOXES_COUNT) // Party mon. + { + level = GetMonData(&gPlayerParty[monId], MON_DATA_LEVEL); + gender = GetMonGender(&gPlayerParty[monId]); + } else { - GetBoxOrPartyMonData(boxId, monId, MON_DATA_NICKNAME, dst); - StringGetEnd10(dst); - species = GetBoxOrPartyMonData(boxId, monId, MON_DATA_SPECIES, NULL); - if (boxId == TOTAL_BOXES_COUNT) // Party mon. - { - level = GetMonData(&gPlayerParty[monId], MON_DATA_LEVEL); - gender = GetMonGender(&gPlayerParty[monId]); - } - else - { - // Needed to match, feel free to remove. - boxId++;boxId--; - monId++;monId--; - - boxMon = GetBoxedMonPtr(boxId, monId); - gender = GetBoxMonGender(boxMon); - level = GetLevelFromBoxMonExp(boxMon); - } + // Needed to match, feel free to remove. + boxId++, boxId--; + monId++, monId--; - if ((species == SPECIES_NIDORAN_F || species == SPECIES_NIDORAN_M) && !StringCompare(dst, gSpeciesNames[species])) - gender = MON_GENDERLESS; + boxMon = GetBoxedMonPtr(boxId, monId); + gender = GetBoxMonGender(boxMon); + level = GetLevelFromBoxMonExp(boxMon); + } - for (str = dst; *str != EOS; str++) - ; + if ((species == SPECIES_NIDORAN_F || species == SPECIES_NIDORAN_M) && !StringCompare(dst, gSpeciesNames[species])) + gender = MON_GENDERLESS; - *(str++) = EXT_CTRL_CODE_BEGIN; - *(str++) = EXT_CTRL_CODE_SKIP; - *(str++) = 60; + for (str = dst; *str != EOS; str++) + ; - switch (gender) - { - default: - *(str++) = CHAR_SPACE; - break; - case MON_MALE: - *(str++) = EXT_CTRL_CODE_BEGIN; - *(str++) = EXT_CTRL_CODE_COLOR; - *(str++) = TEXT_COLOR_RED; - *(str++) = EXT_CTRL_CODE_BEGIN; - *(str++) = EXT_CTRL_CODE_SHADOW; - *(str++) = TEXT_COLOR_LIGHT_RED; - *(str++) = CHAR_MALE; - break; - case MON_FEMALE: - *(str++) = EXT_CTRL_CODE_BEGIN; - *(str++) = EXT_CTRL_CODE_COLOR; - *(str++) = TEXT_COLOR_GREEN; - *(str++) = EXT_CTRL_CODE_BEGIN; - *(str++) = EXT_CTRL_CODE_SHADOW; - *(str++) = TEXT_COLOR_LIGHT_GREEN; - *(str++) = CHAR_FEMALE; - break; - } + *(str++) = EXT_CTRL_CODE_BEGIN; + *(str++) = EXT_CTRL_CODE_SKIP; + *(str++) = 60; - *(str++) = EXT_CTRL_CODE_BEGIN; - *(str++) = EXT_CTRL_CODE_COLOR_HIGHLIGHT_SHADOW; - *(str++) = TEXT_COLOR_BLUE; - *(str++) = TEXT_COLOR_TRANSPARENT; - *(str++) = TEXT_COLOR_LIGHT_BLUE; - *(str++) = CHAR_SLASH; - *(str++) = CHAR_EXTRA_SYMBOL; - *(str++) = CHAR_LV_2; - str = ConvertIntToDecimalStringN(str, level, STR_CONV_MODE_LEFT_ALIGN, 3); + switch (gender) + { + default: *(str++) = CHAR_SPACE; - *str = EOS; - - return str; + break; + case MON_MALE: + *(str++) = EXT_CTRL_CODE_BEGIN; + *(str++) = EXT_CTRL_CODE_COLOR; + *(str++) = TEXT_COLOR_RED; + *(str++) = EXT_CTRL_CODE_BEGIN; + *(str++) = EXT_CTRL_CODE_SHADOW; + *(str++) = TEXT_COLOR_LIGHT_RED; + *(str++) = CHAR_MALE; + break; + case MON_FEMALE: + *(str++) = EXT_CTRL_CODE_BEGIN; + *(str++) = EXT_CTRL_CODE_COLOR; + *(str++) = TEXT_COLOR_GREEN; + *(str++) = EXT_CTRL_CODE_BEGIN; + *(str++) = EXT_CTRL_CODE_SHADOW; + *(str++) = TEXT_COLOR_LIGHT_GREEN; + *(str++) = CHAR_FEMALE; + break; } + + *(str++) = EXT_CTRL_CODE_BEGIN; + *(str++) = EXT_CTRL_CODE_COLOR_HIGHLIGHT_SHADOW; + *(str++) = TEXT_COLOR_BLUE; + *(str++) = TEXT_COLOR_TRANSPARENT; + *(str++) = TEXT_COLOR_LIGHT_BLUE; + *(str++) = CHAR_SLASH; + *(str++) = CHAR_EXTRA_SYMBOL; + *(str++) = CHAR_LV_2; + str = ConvertIntToDecimalStringN(str, level, STR_CONV_MODE_LEFT_ALIGN, 3); + *(str++) = CHAR_SPACE; + *str = EOS; + + return str; } // Buffers the string in src to dest up to n chars. If src is less than n chars, fill with spaces diff --git a/src/pokemon.c b/src/pokemon.c index 75b5a03f2..7cde8e0a6 100644 --- a/src/pokemon.c +++ b/src/pokemon.c @@ -1898,22 +1898,22 @@ static const u16 sDeoxysBaseStats[] = const u16 gLinkPlayerFacilityClasses[NUM_MALE_LINK_FACILITY_CLASSES + NUM_FEMALE_LINK_FACILITY_CLASSES] = { // Male classes - FACILITY_CLASS_COOLTRAINER_M, - FACILITY_CLASS_BLACK_BELT, + FACILITY_CLASS_COOLTRAINER_M, + FACILITY_CLASS_BLACK_BELT, FACILITY_CLASS_CAMPER, - FACILITY_CLASS_YOUNGSTER, - FACILITY_CLASS_PSYCHIC_M, + FACILITY_CLASS_YOUNGSTER, + FACILITY_CLASS_PSYCHIC_M, FACILITY_CLASS_BUG_CATCHER, - FACILITY_CLASS_PKMN_BREEDER_M, + FACILITY_CLASS_PKMN_BREEDER_M, FACILITY_CLASS_GUITARIST, // Female Classes - FACILITY_CLASS_COOLTRAINER_F, - FACILITY_CLASS_HEX_MANIAC, + FACILITY_CLASS_COOLTRAINER_F, + FACILITY_CLASS_HEX_MANIAC, FACILITY_CLASS_PICNICKER, - FACILITY_CLASS_LASS, - FACILITY_CLASS_PSYCHIC_F, + FACILITY_CLASS_LASS, + FACILITY_CLASS_PSYCHIC_F, FACILITY_CLASS_BATTLE_GIRL, - FACILITY_CLASS_PKMN_BREEDER_F, + FACILITY_CLASS_PKMN_BREEDER_F, FACILITY_CLASS_BEAUTY }; @@ -5806,7 +5806,7 @@ void AdjustFriendship(struct Pokemon *mon, u8 event) if (friendship > 199) friendshipLevel++; - if ((event != FRIENDSHIP_EVENT_WALKING || !(Random() & 1)) + if ((event != FRIENDSHIP_EVENT_WALKING || !(Random() & 1)) && (event != FRIENDSHIP_EVENT_LEAGUE_BATTLE || IS_LEAGUE_BATTLE)) { s8 mod = sFriendshipEventModifiers[event][friendshipLevel]; @@ -5848,7 +5848,7 @@ void MonGainEVs(struct Pokemon *mon, u16 defeatedSpecies) { if (totalEVs >= MAX_TOTAL_EVS) break; - + if (CheckPartyHasHadPokerus(mon, 0)) multiplier = 2; else @@ -5895,9 +5895,9 @@ void MonGainEVs(struct Pokemon *mon, u16 defeatedSpecies) if (totalEVs + (s16)evIncrease > MAX_TOTAL_EVS) evIncrease = ((s16)evIncrease + MAX_TOTAL_EVS) - (totalEVs + evIncrease); - if (evs[i] + (s16)evIncrease > 255) + if (evs[i] + (s16)evIncrease > MAX_PER_STAT_EVS) { - int val1 = (s16)evIncrease + 255; + int val1 = (s16)evIncrease + MAX_PER_STAT_EVS; int val2 = evs[i] + evIncrease; evIncrease = val1 - val2; } @@ -6814,7 +6814,9 @@ static void sub_806F160(struct Unknown_806F160_Struct* structPtr) structPtr->templates[i] = gUnknown_08329D98[i]; for (j = 0; j < structPtr->field_1; j++) { - asm(""); + #ifndef NONMATCHING + asm(""); + #endif structPtr->frameImages[i * structPtr->field_1 + j].data = &structPtr->byteArrays[i][j * 0x800]; } structPtr->templates[i].images = &structPtr->frameImages[i * structPtr->field_1]; diff --git a/src/pokemon_animation.c b/src/pokemon_animation.c index a388be39a..37abb90e9 100644 --- a/src/pokemon_animation.c +++ b/src/pokemon_animation.c @@ -2884,7 +2884,11 @@ static void sub_8181C2C(struct Sprite *sprite) } else { - register s32 var asm("r4") = sUnknown_03001240[sprite->data[0]].field_8; + #ifndef NONMATCHING + register s32 var asm("r4") = sUnknown_03001240[sprite->data[0]].field_8; + #else + s32 var = sUnknown_03001240[sprite->data[0]].field_8; + #endif sprite->pos2.x = (var << 3) * (counter % 128) / 128 - (sUnknown_03001240[sprite->data[0]].field_8 * 8); sprite->pos2.y = -(Sin(counter % 128, 8)); diff --git a/src/record_mixing.c b/src/record_mixing.c index b214701c2..6c0a02d8c 100644 --- a/src/record_mixing.c +++ b/src/record_mixing.c @@ -872,8 +872,12 @@ static void ReceiveDaycareMailData(struct RecordMixingDayCareMail *src, size_t r var2 = sub_80E7A9C(&_src->mail[1]); if (!var1 && var2) { - register u8 one asm("r0") = 1; // boo, a fakematch - sp24[j][1] = one; + #ifndef NONMATCHING + register u8 one asm("r0") = 1; // boo, a fakematch + sp24[j][1] = one; + #else + sp24[j][1] = 1; + #endif } else if ((var1 && var2) || (!var1 && !var2)) { diff --git a/src/script.c b/src/script.c index 9ba1a7429..889c25765 100644 --- a/src/script.c +++ b/src/script.c @@ -26,9 +26,9 @@ void InitScriptContext(struct ScriptContext *ctx, void *cmdTable, void *cmdTable s32 i; ctx->mode = 0; - ctx->scriptPtr = 0; + ctx->scriptPtr = NULL; ctx->stackDepth = 0; - ctx->nativePtr = 0; + ctx->nativePtr = NULL; ctx->cmdTable = cmdTable; ctx->cmdTableEnd = cmdTableEnd; @@ -55,7 +55,7 @@ void SetupNativeScript(struct ScriptContext *ctx, bool8 (*ptr)(void)) void StopScript(struct ScriptContext *ctx) { ctx->mode = 0; - ctx->scriptPtr = 0; + ctx->scriptPtr = NULL; } bool8 RunScriptCommand(struct ScriptContext *ctx) diff --git a/src/trainer_hill.c b/src/trainer_hill.c index c5aea14d9..bed8df2e0 100644 --- a/src/trainer_hill.c +++ b/src/trainer_hill.c @@ -356,7 +356,7 @@ static void SetUpDataStruct(void) { if (sHillData == NULL) { - sHillData = AllocZeroed(sizeof(*sHillData)); + sHillData = AllocZeroed(sizeof(struct TrHillStruct2)); sHillData->floorId = gMapHeader.mapLayoutId - LAYOUT_TRAINER_HILL_1F; CpuCopy32(sDataPerTag[gSaveBlock1Ptr->trainerHill.tag], &sHillData->tag, sizeof(sHillData->tag) + 4 * sizeof(struct TrHillFloor)); nullsub_2(); @@ -672,70 +672,23 @@ bool32 LoadTrainerHillFloorObjectEventScripts(void) return TRUE; } -// Functionally equivalent. -#ifdef NONMATCHING static u32 sub_81D5F58(u8 floorId, u32 bit, u32 arg2, u32 arg3) { - u32 var0, var1, var2, var3; + u16 var0, var1; + #ifndef NONMATCHING + register u16 var2 asm("r3"); //compiler keeps wanting to "mov r3, 0x80" instead of "mov r2 0x80" and then later "add r3, r2, 0" + #else + u16 var2; + #endif + u16 var3; - var0 = (sHillData->floors[floorId].display.unk3A0[arg2] >> (15 - bit)) & 1; - var1 = sHillData->floors[floorId].display.data[arg2 * arg3 + bit]; - var3 = 0x200; - var2 = 0x3000; + var0 = (sHillData->floors[floorId].display.unk3A0[arg2] >> (15 - bit) & 1); + var1 = sHillData->floors[floorId].display.data[arg3 * arg2 + bit]; + var2 = 0x200; + var3 = 0x3000; - return ((var0 << 10) | var2) | (var1 | var3); + return ((var0 << 10) | var3) | (var1 | var2); } -#else -NAKED -static u32 sub_81D5F58(u8 floorId, u32 bit, u32 arg2, u32 arg3) -{ - asm_unified("\n\ - push {r4,r5,lr}\n\ - lsls r0, 24\n\ - lsrs r0, 24\n\ - ldr r4, =sHillData\n\ - ldr r4, [r4]\n\ - mov r12, r4\n\ - lsls r4, r2, 1\n\ - lsls r5, r0, 4\n\ - subs r5, r0\n\ - lsls r5, 3\n\ - subs r5, r0\n\ - lsls r5, 3\n\ - adds r4, r5\n\ - movs r0, 0xE8\n\ - lsls r0, 2\n\ - add r0, r12\n\ - adds r0, r4\n\ - ldrh r0, [r0]\n\ - movs r4, 0xF\n\ - subs r4, r1\n\ - asrs r0, r4\n\ - movs r4, 0x1\n\ - ands r0, r4\n\ - muls r2, r3\n\ - adds r2, r1\n\ - adds r2, r5\n\ - movs r1, 0xA8\n\ - lsls r1, 2\n\ - add r1, r12\n\ - adds r1, r2\n\ - ldrb r1, [r1]\n\ - movs r2, 0x80\n\ - lsls r2, 2\n\ - adds r3, r2, 0\n\ - movs r2, 0xC0\n\ - lsls r2, 6\n\ - lsls r0, 10\n\ - orrs r0, r2\n\ - orrs r1, r3\n\ - orrs r0, r1\n\ - pop {r4,r5}\n\ - pop {r1}\n\ - bx r1\n\ - .pool"); -} -#endif // NONMATCHING void GenerateTrainerHillFloorLayout(u16 *mapArg) { |