code:
#include "constants/battle.h"
#include "constants/battle_script_commands.h"
#include "constants/battle_anim.h"
#include "constants/battle_string_ids.h"
#include "constants/items.h"
#include "constants/songs.h"
#include "constants/game_stat.h"
	.include "asm/macros.inc"
	.include "asm/macros/battle_script.inc"
	.include "constants/constants.inc"

	.section script_data, "aw", %progbits

	.align 2
gBattlescriptsForBallThrow:: @ 82DBD08
	.4byte BattleScript_BallThrow        @ ITEM_NONE
	.4byte BattleScript_BallThrow        @ ITEM_MASTER_BALL
	.4byte BattleScript_BallThrow        @ ITEM_ULTRA_BALL
	.4byte BattleScript_BallThrow        @ ITEM_GREAT_BALL
	.4byte BattleScript_BallThrow        @ ITEM_POKE_BALL
	.4byte BattleScript_SafariBallThrow  @ ITEM_SAFARI_BALL
	.4byte BattleScript_BallThrow        @ ITEM_NET_BALL
	.4byte BattleScript_BallThrow        @ ITEM_DIVE_BALL
	.4byte BattleScript_BallThrow        @ ITEM_NEST_BALL
	.4byte BattleScript_BallThrow        @ ITEM_REPEAT_BALL
	.4byte BattleScript_BallThrow        @ ITEM_TIMER_BALL
	.4byte BattleScript_BallThrow        @ ITEM_LUXURY_BALL
	.4byte BattleScript_BallThrow        @ ITEM_PREMIER_BALL

	.align 2
gBattlescriptsForUsingItem:: @ 82DBD3C
	.4byte BattleScript_PlayerUsesItem
	.4byte BattleScript_OpponentUsesHealItem        @ AI_ITEM_FULL_RESTORE
	.4byte BattleScript_OpponentUsesHealItem        @ AI_ITEM_HEAL_HP
	.4byte BattleScript_OpponentUsesStatusCureItem  @ AI_ITEM_CURE_CONDITION
	.4byte BattleScript_OpponentUsesXItem           @ AI_ITEM_X_STAT
	.4byte BattleScript_OpponentUsesGuardSpecs      @ AI_ITEM_GUARD_SPECS

	.align 2
gBattlescriptsForRunningByItem:: @ 82DBD54
	.4byte BattleScript_RunByUsingItem

	.align 2
gBattlescriptsForSafariActions:: @ 82DBD58
	.4byte BattleScript_ActionWatchesCarefully
	.4byte BattleScript_ActionGetNear
	.4byte BattleScript_ActionThrowPokeblock
	.4byte BattleScript_ActionWallyThrow

BattleScript_BallThrow::
	jumpifword CMP_COMMON_BITS, gBattleTypeFlags, BATTLE_TYPE_WALLY_TUTORIAL, BattleScript_BallThrowByWally
	printstring STRINGID_PLAYERUSEDITEM
	handleballthrow

BattleScript_BallThrowByWally::
	printstring STRINGID_WALLYUSEDITEM
	handleballthrow

BattleScript_SafariBallThrow::
	printstring STRINGID_PLAYERUSEDITEM
	updatestatusicon BS_ATTACKER
	handleballthrow

BattleScript_SuccessBallThrow::
	jumpifhalfword CMP_EQUAL, gLastUsedItem, ITEM_SAFARI_BALL, BattleScript_PrintCaughtMonInfo
	incrementgamestat GAME_STAT_POKEMON_CAPTURES
BattleScript_PrintCaughtMonInfo::
	printstring STRINGID_GOTCHAPKMNCAUGHT
	trysetcaughtmondexflags BattleScript_TryNicknameCaughtMon
	printstring STRINGID_PKMNDATAADDEDTODEX
	waitstate
	setbyte gBattleCommunication, 0x0
	displaydexinfo
BattleScript_TryNicknameCaughtMon::
	printstring STRINGID_GIVENICKNAMECAPTURED
	waitstate
	setbyte gBattleCommunication, 0x0
	trygivecaughtmonnick BattleScript_GiveCaughtMonEnd
	givecaughtmon
	printfromtable gCaughtMonStringIds
	waitmessage 0x40
	goto BattleScript_SuccessBallThrowEnd
BattleScript_GiveCaughtMonEnd::
	givecaughtmon
BattleScript_SuccessBallThrowEnd::
	setbyte gBattleOutcome, B_OUTCOME_CAUGHT
	finishturn

BattleScript_WallyBallThrow::
	printstring STRINGID_GOTCHAPKMNCAUGHT2
	setbyte gBattleOutcome, B_OUTCOME_CAUGHT
	finishturn

BattleScript_ShakeBallThrow::
	printfromtable gBallEscapeStringIds
	waitmessage 0x40
	jumpifword CMP_NO_COMMON_BITS, gBattleTypeFlags, BATTLE_TYPE_SAFARI, BattleScript_ShakeBallThrowEnd
	jumpifbyte CMP_NOT_EQUAL, gNumSafariBalls, 0x0, BattleScript_ShakeBallThrowEnd
	printstring STRINGID_OUTOFSAFARIBALLS
	waitmessage 0x40
	setbyte gBattleOutcome, B_OUTCOME_NO_SAFARI_BALLS
BattleScript_ShakeBallThrowEnd::
	finishaction

BattleScript_TrainerBallBlock::
	waitmessage 0x40
	printstring STRINGID_TRAINERBLOCKEDBALL
	waitmessage 0x40
	printstring STRINGID_DONTBEATHIEF
	waitmessage 0x40
	finishaction

BattleScript_PlayerUsesItem::
	setbyte sMOVEEND_STATE, 0xF
	moveend 0x1, 0x0
	end

BattleScript_OpponentUsesHealItem::
	printstring STRINGID_EMPTYSTRING3
	pause 0x30
	playse SE_USE_ITEM
	printstring STRINGID_TRAINER1USEDITEM
	waitmessage 0x40
	useitemonopponent
	orword gHitMarker, HITMARKER_IGNORE_SUBSTITUTE
	healthbarupdate BS_ATTACKER
	datahpupdate BS_ATTACKER
	printstring STRINGID_PKMNSITEMRESTOREDHEALTH
	waitmessage 0x40
	updatestatusicon BS_ATTACKER
	setbyte sMOVEEND_STATE, 0xF
	moveend 0x1, 0x0
	finishaction

BattleScript_OpponentUsesStatusCureItem::
	printstring STRINGID_EMPTYSTRING3
	pause 0x30
	playse SE_USE_ITEM
	printstring STRINGID_TRAINER1USEDITEM
	waitmessage 0x40
	useitemonopponent
	printfromtable gTrainerItemCuredStatusStringIds
	waitmessage 0x40
	updatestatusicon BS_ATTACKER
	setbyte sMOVEEND_STATE, 0xF
	moveend 0x1, 0x0
	finishaction

BattleScript_OpponentUsesXItem::
	printstring STRINGID_EMPTYSTRING3
	pause 0x30
	playse SE_USE_ITEM
	printstring STRINGID_TRAINER1USEDITEM
	waitmessage 0x40
	useitemonopponent
	printfromtable gStatUpStringIds
	waitmessage 0x40
	setbyte sMOVEEND_STATE, 0xF
	moveend 0x1, 0x0
	finishaction

BattleScript_OpponentUsesGuardSpecs::
	printstring STRINGID_EMPTYSTRING3
	pause 0x30
	playse SE_USE_ITEM
	printstring STRINGID_TRAINER1USEDITEM
	waitmessage 0x40
	useitemonopponent
	printfromtable gMistUsedStringIds
	waitmessage 0x40
	setbyte sMOVEEND_STATE, 0xF
	moveend 0x1, 0x0
	finishaction

BattleScript_RunByUsingItem::
	playse SE_FLEE
	setbyte gBattleOutcome, B_OUTCOME_RAN
	finishturn

BattleScript_ActionWatchesCarefully:
	printstring STRINGID_PKMNWATCHINGCAREFULLY
	waitmessage 0x40
	end2

BattleScript_ActionGetNear:
	printfromtable gSafariGetNearStringIds
	waitmessage 0x40
	end2

BattleScript_ActionThrowPokeblock:
	printstring STRINGID_THREWPOKEBLOCKATPKMN
	waitmessage 0x40
	playanimation BS_ATTACKER, B_ANIM_POKEBLOCK_THROW, NULL
	printfromtable gSafariPokeblockResultStringIds
	waitmessage 0x40
	end2

BattleScript_ActionWallyThrow:
	printstring STRINGID_RETURNMON
	waitmessage 0x40
	returnatktoball
	waitstate
	trainerslidein BS_TARGET
	waitstate
	printstring STRINGID_YOUTHROWABALLNOWRIGHT
	waitmessage 0x40
	end2

repo_name: Lunos/pokeemerald

license: mit


code:
#include "constants/global.h"
#include "constants/contest.h"
	.include "asm/macros.inc"
	.include "asm/macros/contest_ai_script.inc"
	.include "constants/constants.inc"

	.section script_data, "aw", %progbits

	enum_start
	enum MON_1
	enum MON_2
	enum MON_3
	enum MON_4

	.align 2
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_CheckGoodMove     @ CONTEST_AI_CHECK_GOOD_MOVE
	.4byte AI_Erratic           @ CONTEST_AI_ERRATIC
	.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
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

@ Unused
AI_PreferMostAppealingMove:
	if_most_appealing_move AI_PreferMostAppealingMove_Encourage
	end
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_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_1stRepeat:
	score -5
	end
AI_CheckBoring_2ndRepeat:
	score -15
	end
AI_CheckBoring_3rdRepeat:
	score -20
	end
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_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_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_CheckExcitement_Negative_1AwayFromMax_Not1stUp:
	if_random_less_than 127, AI_CheckExcitement_End
	score -10
	end
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_CheckExcitement_Negative_2AwayFromMax_LastAppeal:
	score +15
	end
AI_CheckExcitement_Negative_2AwayFromMax_Not1stUp:
	if_random_less_than 127, AI_CheckExcitement_End
	score +10
	end
AI_CheckExcitement_Neutral:
	if_random_less_than 127, AI_CheckExcitement_End
	score +10
	end
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_CheckExcitement_Positive_Not1stUpForMax:
	if_random_less_than 100, AI_CheckExcitement_End
	score +10
	end
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_CheckExcitement_End:
	end

@ 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_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_CheckCombo_CheckFinisherWithoutStarter:
	if_not_combo_finisher AI_CheckCombo_End
	score -10
	end
AI_CheckCombo_WouldFinish:
	score +25
	end
AI_CheckCombo_Starter1stUp:
	if_last_appeal AI_CheckCombo_StarterOnLastAppeal
	if_random_less_than 150, AI_CheckCombo_End
	score +10
	end
AI_CheckCombo_Starter2ndUp:
	if_last_appeal AI_CheckCombo_StarterOnLastAppeal
	if_random_less_than 125, AI_CheckCombo_End
	score +10
	end
AI_CheckCombo_Starter3rdUp:
	if_last_appeal AI_CheckCombo_StarterOnLastAppeal
	if_random_less_than 50, AI_CheckCombo_End
	score +10
	end
AI_CheckCombo_StarterLast:
	if_last_appeal AI_CheckCombo_StarterOnLastAppeal
	score +10
	end
AI_CheckCombo_StarterOnLastAppeal:
	if_random_less_than 125, AI_CheckCombo_End
	score -15
	end
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
AI_CGM_BetterWithGoodCondition_2:
	if_random_less_than 125, AI_CGM_End
	score +15
	end
AI_CGM_BetterWithGoodCondition_1:
	if_random_less_than 125, AI_CGM_End
	score +5
	end
AI_CGM_BetterWithGoodCondition_0:
	score -20
	end

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

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

AI_CGM_RepetitionNotBoring:
	if_user_order_not_eq MON_4, AI_CGM_End
	if_random_less_than 50, AI_CGM_End
	score +15
	end

AI_CGM_Unused:
	if_last_appeal AI_CGM_Unused_LastAppeal
	if_random_less_than 220, AI_CGM_Unused_Discourage
	score +10
	end
AI_CGM_Unused_LastAppeal:
	if_random_less_than 20, AI_CGM_End
	score +15
	end
AI_CGM_Unused_Discourage:
	score -20
	end

@ 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
AI_CGM_ImproveCondition_AtMax:
	score -10
	end
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
AI_CGM_ImproveCondition_FirstAppeal:
	if_random_less_than 100, AI_CGM_End
	score +10
	end
AI_CGM_ImproveCondition_LastAppeal:
	score -10
	end

@ 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
AI_CGM_DontExciteAudience_EarlyTurn:
	if_random_less_than 127, AI_CGM_End
	score +10
	end

@ 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
AI_CGM_AppealAsGoodAsPrevOnes_2ndUp:
	score +5
	end
AI_CGM_AppealAsGoodAsPrevOnes_3rdUp:
	score +15
	end
AI_CGM_AppealAsGoodAsPrevOnes_Last:
	score +20
	end

@ 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
AI_CGM_AppealAsGoodAsPrevOne_1stUp:
	score -10
	end
AI_CGM_AppealAsGoodAsPrevOne_2ndUp:
	if_cannot_participate MON_1, AI_CGM_End
	score +5
	end
AI_CGM_AppealAsGoodAsPrevOne_3rdUp:
	if_cannot_participate MON_1, AI_CGM_AppealAsGoodAsPrevOne_3rdUp_CheckMon2
	score +5
	goto AI_CGM_AppealAsGoodAsPrevOne_3rdUp_CheckMon2
	end
AI_CGM_AppealAsGoodAsPrevOne_3rdUp_CheckMon2:
	if_cannot_participate MON_2, AI_CGM_End
	score +5
	end
AI_CGM_AppealAsGoodAsPrevOne_Last:
	if_cannot_participate MON_1, AI_CGM_AppealAsGoodAsPrevOne_Last_CheckMon2
	score +5
	goto AI_CGM_AppealAsGoodAsPrevOne_Last_CheckMon2
	end
AI_CGM_AppealAsGoodAsPrevOne_Last_CheckMon2:
	if_cannot_participate MON_2, AI_CGM_AppealAsGoodAsPrevOne_Last_CheckMon3
	score +5
	goto AI_CGM_AppealAsGoodAsPrevOne_Last_CheckMon3
	end
AI_CGM_AppealAsGoodAsPrevOne_Last_CheckMon3:
	if_cannot_participate MON_3, AI_CGM_End
	score +5
	end

@ 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
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
AI_CGM_BetterWhenAudienceExcited_Not1stAppeal:
	if_random_less_than 125, AI_CGM_End
	score -15
	end
AI_CGM_BetterWhenAudienceExcited_1AwayFromMax:
	if_random_less_than 125, AI_CGM_End
	score +20
	end
AI_CGM_BetterWhenAudienceExcited_2AwayFromMax:
	if_random_less_than 125, AI_CGM_End
	score +15
	end
AI_CGM_BetterWhenAudienceExcited_Not1stUp:
	if_random_less_than 178, AI_CGM_End
	score +10
	end

@ 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
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
AI_CGM_WorsenConditionOfPrevMons_Mon1Has1Star:
	if_random_less_than 125, AI_CGM_WorsenConditionOfPrevMons_CheckMon2
	score +5
	if_user_order_more_than MON_2, AI_CGM_WorsenConditionOfPrevMons_CheckMon2
	end
AI_CGM_WorsenConditionOfPrevMons_Mon1Has2Stars:
	if_random_less_than 125, AI_CGM_WorsenConditionOfPrevMons_CheckMon2
	score +10
	if_user_order_more_than MON_2, AI_CGM_WorsenConditionOfPrevMons_CheckMon2
	end
AI_CGM_WorsenConditionOfPrevMons_Mon1Has3Stars:
	if_random_less_than 125, AI_CGM_WorsenConditionOfPrevMons_CheckMon2
	score +15
	if_user_order_more_than MON_2, AI_CGM_WorsenConditionOfPrevMons_CheckMon2
	end
AI_CGM_WorsenConditionOfPrevMons_TryCheckMon2:
	if_user_order_more_than MON_2, AI_CGM_WorsenConditionOfPrevMons_CheckMon2
	end
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
AI_CGM_WorsenConditionOfPrevMons_Mon2Has1Star:
	if_random_less_than 125, AI_CGM_WorsenConditionOfPrevMons_CheckMon3
	score +5
	if_user_order_more_than MON_3, AI_CGM_WorsenConditionOfPrevMons_CheckMon3
	end
AI_CGM_WorsenConditionOfPrevMons_Mon2Has2Stars:
	if_random_less_than 125, AI_CGM_WorsenConditionOfPrevMons_CheckMon3
	score +10
	if_user_order_more_than MON_3, AI_CGM_WorsenConditionOfPrevMons_CheckMon3
	end
AI_CGM_WorsenConditionOfPrevMons_Mon2Has3Stars:
	if_random_less_than 125, AI_CGM_WorsenConditionOfPrevMons_CheckMon3
	score +15
	if_user_order_more_than MON_3, AI_CGM_WorsenConditionOfPrevMons_CheckMon3
	end
AI_CGM_WorsenConditionOfPrevMons_TryCheckMon3:
	if_user_order_more_than MON_3, AI_CGM_WorsenConditionOfPrevMons_CheckMon3
	end
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
AI_CGM_WorsenConditionOfPrevMons_Mon3Has1Star:
	if_random_less_than 125, AI_CGM_End
	score +5
	end
AI_CGM_WorsenConditionOfPrevMons_Mon3Has2Stars:
	if_random_less_than 125, AI_CGM_End
	score +10
	end
AI_CGM_WorsenConditionOfPrevMons_Mon3Has3Stars:
	if_random_less_than 125, AI_CGM_End
	score +15
	end
AI_CGM_WorsenConditionOfPrevMons_end:
	end

@ 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
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
	if_not_completed_combo MON_1, AI_CGM_TargetMonWithJudgesAttention_CheckMon2
	score +8
	end
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
	if_not_completed_combo MON_2, AI_CGM_TargetMonWithJudgesAttention_CheckMon3
	score +8
	end
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
	if_not_completed_combo MON_3, AI_CGM_End
	score +8
	end

@ 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
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_less_than 125, AI_CGM_TargetMonWithJudgesAttention_CheckMon2
	score +5
	end
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_less_than 125, AI_CGM_TargetMonWithJudgesAttention_CheckMon3
	score +5
	end
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_less_than 125, AI_CGM_End
	score +5
	end

@ 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
AI_CGM_JamsOthersButMissOneTurn_LastAppeal:
	score +5
	goto AI_CGM_JamsOthersButMissOneTurn_TurnOrder
	end
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
AI_CGM_JamsOthersButMissOneTurn_1stUp:
	score -15
	end
AI_CGM_JamsOthersButMissOneTurn_2ndUp:
	if_random_less_than 125, AI_CGM_End
	score -10
	end
AI_CGM_JamsOthersButMissOneTurn_3rdUp:
	if_random_less_than 125, AI_CGM_End
	score +5
	end
AI_CGM_JamsOthersButMissOneTurn_Last:
	if_random_less_than 125, AI_CGM_End
	score +15
	end

AI_CGM_End:
	end

@ Randomly encourage moves in Cute, Smart, and Tough contests.
AI_Erratic:
	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
AI_Erratic_CuteSmartTough:
	if_random_less_than 125, AI_Erratic_End
	score +10
	end
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
AI_CBM_DependsOnPrevMon_2ndUp:
	if_can_participate MON_1, AI_CBM_End
	score -10
	end
AI_CBM_DependsOnPrevMon_3rdUp:
	if_can_participate MON_2, AI_CBM_End
	score -10
	end
AI_CBM_DependsOnPrevMon_Last:
	if_can_participate MON_3, AI_CBM_End
	score -10
	end

@ 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
AI_CBM_DependsOnPrevMons_1stUp:
	score -20
	end
AI_CBM_DependsOnPrevMons_2ndUp:
	if_can_participate MON_1, AI_CBM_End
	score -15
	end
AI_CBM_DependsOnPrevMons_3rdUp:
	if_can_participate MON_1, AI_CBM_End
	if_can_participate MON_2, AI_CBM_End
	score -15
	end
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

@ 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
AI_CBM_DependsOnNextMon_1stUp:
	if_can_participate MON_2, AI_CBM_End
	score -10
	end
AI_CBM_DependsOnNextMon_2ndUp:
	if_can_participate MON_3, AI_CBM_End
	score -10
	end
AI_CBM_DependsOnNextMon_3rdUp:
	if_can_participate MON_4, AI_CBM_End
	score -10
	end

@ 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
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
AI_CBM_DependsOnNextMons_2ndUp:
	if_can_participate MON_3, AI_CBM_End
	if_can_participate MON_4, AI_CBM_End
	score -10
	end
AI_CBM_DependsOnNextMons_3rdUp:
	if_can_participate MON_4, AI_CBM_End
	score -10
	end

@ If at max condition, discourage move
AI_CBM_ImproveCondition:
	if_user_condition_less_than 3, AI_CBM_End
	score -20
	end

@ 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
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
AI_CBM_AvoidStartle_2ndUp:
	if_can_participate MON_3, AI_CBM_End
	if_can_participate MON_4, AI_CBM_End
	score -10
	end
AI_CBM_AvoidStartle_3rdUp:
	if_can_participate MON_4, AI_CBM_End
	score -10
	end

@ 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
AI_CBM_NoMoreMoves_1stAppeal:
	if_random_less_than 20, AI_CBM_End
	score -15
	end
AI_CBM_NoMoreMoves_2ndAppeal:
	if_random_less_than 40, AI_CBM_End
	score -15
	end
AI_CBM_NoMoreMoves_3rdAppeal:
	if_random_less_than 60, AI_CBM_End
	score -15
	end
AI_CBM_NoMoreMoves_4thAppeal:
	if_random_less_than 80, AI_CBM_End
	score -15
	end
AI_CBM_NoMoreMoves_LastAppeal:
	if_random_less_than 20, AI_CBM_End
	score +20
	end

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_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_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_CheckOrder_1stUp_Encourage:
	score +15
	end
AI_CheckOrder_1stUp_Discourage:
	score -15
	end
AI_CheckOrder_1stUp_RandomEncourage:
	if_random_less_than 100, AI_CBM_End
	score +10
	end
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_CheckOrder_2ndUp_Discourage:
	score -5
	end
AI_CheckOrder_2ndUp_RandomEncourage:
	if_random_less_than 125, AI_CBM_End
	score +10
	end
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_CheckOrder_3rdUp_Encourage:
	score +5
	end
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_CheckOrder_Last_StronglyEncourage:
	score +15
	end
AI_CheckOrder_Last_Discourage:
	score -10
	end
AI_CheckOrder_Last_RandomEncourage:
	if_random_less_than 125, AI_CBM_End
	score +10
	end
AI_CheckOrder_Last_Encourage:
	score +5
	end

AI_Nothing:
	end


code:
#include "constants/global.h"
#include "constants/apprentice.h"
#include "constants/battle.h"
#include "constants/battle_arena.h"
#include "constants/battle_dome.h"
#include "constants/battle_factory.h"
#include "constants/battle_frontier.h"
#include "constants/battle_palace.h"
#include "constants/battle_pike.h"
#include "constants/battle_pyramid.h"
#include "constants/battle_setup.h"
#include "constants/battle_tent.h"
#include "constants/battle_tower.h"
#include "constants/berry.h"
#include "constants/cable_club.h"
#include "constants/coins.h"
#include "constants/contest.h"
#include "constants/daycare.h"
#include "constants/decorations.h"
#include "constants/easy_chat.h"
#include "constants/event_objects.h"
#include "constants/event_object_movement.h"
#include "constants/field_effects.h"
#include "constants/field_poison.h"
#include "constants/field_specials.h"
#include "constants/field_tasks.h"
#include "constants/field_weather.h"
#include "constants/flags.h"
#include "constants/frontier_util.h"
#include "constants/game_stat.h"
#include "constants/item.h"
#include "constants/items.h"
#include "constants/heal_locations.h"
#include "constants/layouts.h"
#include "constants/lilycove_lady.h"
#include "constants/map_scripts.h"
#include "constants/maps.h"
#include "constants/mauville_old_man.h"
#include "constants/metatile_labels.h"
#include "constants/moves.h"
#include "constants/party_menu.h"
#include "constants/pokemon.h"
#include "constants/roulette.h"
#include "constants/script_menu.h"
#include "constants/secret_bases.h"
#include "constants/songs.h"
#include "constants/species.h"
#include "constants/trade.h"
#include "constants/trainer_hill.h"
#include "constants/trainers.h"
#include "constants/tv.h"
#include "constants/union_room.h"
#include "constants/vars.h"
#include "constants/weather.h"
	.include "asm/macros.inc"
	.include "asm/macros/event.inc"
	.include "constants/constants.inc"

	.section script_data, "aw", %progbits

@ 81DB67C
	.include "data/script_cmd_table.inc"

gSpecialVars:: @ 81DBA0C
	.4byte gSpecialVar_0x8000
	.4byte gSpecialVar_0x8001
	.4byte gSpecialVar_0x8002
	.4byte gSpecialVar_0x8003
	.4byte gSpecialVar_0x8004
	.4byte gSpecialVar_0x8005
	.4byte gSpecialVar_0x8006
	.4byte gSpecialVar_0x8007
	.4byte gSpecialVar_0x8008
	.4byte gSpecialVar_0x8009
	.4byte gSpecialVar_0x800A
	.4byte gSpecialVar_0x800B
	.4byte gSpecialVar_Facing
	.4byte gSpecialVar_Result
	.4byte gSpecialVar_ItemId
	.4byte gSpecialVar_LastTalked
	.4byte gSpecialVar_ContestRank
	.4byte gSpecialVar_ContestCategory
	.4byte gSpecialVar_MonBoxId
	.4byte gSpecialVar_MonBoxPos
	.4byte gSpecialVar_Unused_0x8014
	.4byte gTrainerBattleOpponent_A

	.include "data/specials.inc"

gStdScripts:: @ 81DC2A0
	.4byte Std_ObtainItem              @ STD_OBTAIN_ITEM
	.4byte Std_FindItem                @ STD_FIND_ITEM
	.4byte Std_MsgboxNPC               @ MSGBOX_NPC
	.4byte Std_MsgboxSign              @ MSGBOX_SIGN
	.4byte Std_MsgboxDefault           @ MSGBOX_DEFAULT
	.4byte Std_MsgboxYesNo             @ MSGBOX_YESNO
	.4byte Std_MsgboxAutoclose         @ MSGBOX_AUTOCLOSE
	.4byte Std_ObtainDecoration        @ STD_OBTAIN_DECORATION
	.4byte Std_RegisteredInMatchCall   @ STD_REGISTER_MATCH_CALL
	.4byte Std_MsgboxGetPoints         @ MSGBOX_GETPOINTS
	.4byte Std_10
gStdScripts_End:: @ 81DC2CC

	.include "data/maps/PetalburgCity/scripts.inc"
	.include "data/maps/SlateportCity/scripts.inc"
	.include "data/maps/MauvilleCity/scripts.inc"
	.include "data/maps/RustboroCity/scripts.inc"
	.include "data/maps/FortreeCity/scripts.inc"
	.include "data/maps/LilycoveCity/scripts.inc"
	.include "data/maps/MossdeepCity/scripts.inc"
	.include "data/maps/SootopolisCity/scripts.inc"
	.include "data/maps/EverGrandeCity/scripts.inc"
	.include "data/maps/LittlerootTown/scripts.inc"
	.include "data/maps/OldaleTown/scripts.inc"
	.include "data/maps/DewfordTown/scripts.inc"
	.include "data/maps/LavaridgeTown/scripts.inc"
	.include "data/maps/FallarborTown/scripts.inc"
	.include "data/maps/VerdanturfTown/scripts.inc"
	.include "data/maps/PacifidlogTown/scripts.inc"
	.include "data/maps/Route101/scripts.inc"
	.include "data/maps/Route102/scripts.inc"
	.include "data/maps/Route103/scripts.inc"
	.include "data/maps/Route104/scripts.inc"
	.include "data/maps/Route105/scripts.inc"
	.include "data/maps/Route106/scripts.inc"
	.include "data/maps/Route107/scripts.inc"
	.include "data/maps/Route108/scripts.inc"
	.include "data/maps/Route109/scripts.inc"
	.include "data/maps/Route110/scripts.inc"
	.include "data/maps/Route111/scripts.inc"
	.include "data/maps/Route112/scripts.inc"
	.include "data/maps/Route113/scripts.inc"
	.include "data/maps/Route114/scripts.inc"
	.include "data/maps/Route115/scripts.inc"
	.include "data/maps/Route116/scripts.inc"
	.include "data/maps/Route117/scripts.inc"
	.include "data/maps/Route118/scripts.inc"
	.include "data/maps/Route119/scripts.inc"
	.include "data/maps/Route120/scripts.inc"
	.include "data/maps/Route121/scripts.inc"
	.include "data/maps/Route122/scripts.inc"
	.include "data/maps/Route123/scripts.inc"
	.include "data/maps/Route124/scripts.inc"
	.include "data/maps/Route125/scripts.inc"
	.include "data/maps/Route126/scripts.inc"
	.include "data/maps/Route127/scripts.inc"
	.include "data/maps/Route128/scripts.inc"
	.include "data/maps/Route129/scripts.inc"
	.include "data/maps/Route130/scripts.inc"
	.include "data/maps/Route131/scripts.inc"
	.include "data/maps/Route132/scripts.inc"
	.include "data/maps/Route133/scripts.inc"
	.include "data/maps/Route134/scripts.inc"
	.include "data/maps/Underwater_Route124/scripts.inc"
	.include "data/maps/Underwater_Route126/scripts.inc"
	.include "data/maps/Underwater_Route127/scripts.inc"
	.include "data/maps/Underwater_Route128/scripts.inc"
	.include "data/maps/Underwater_Route129/scripts.inc"
	.include "data/maps/Underwater_Route105/scripts.inc"
	.include "data/maps/Underwater_Route125/scripts.inc"
	.include "data/maps/LittlerootTown_BrendansHouse_1F/scripts.inc"
	.include "data/maps/LittlerootTown_BrendansHouse_2F/scripts.inc"
	.include "data/maps/LittlerootTown_MaysHouse_1F/scripts.inc"
	.include "data/maps/LittlerootTown_MaysHouse_2F/scripts.inc"
	.include "data/maps/LittlerootTown_ProfessorBirchsLab/scripts.inc"
	.include "data/maps/OldaleTown_House1/scripts.inc"
	.include "data/maps/OldaleTown_House2/scripts.inc"
	.include "data/maps/OldaleTown_PokemonCenter_1F/scripts.inc"
	.include "data/maps/OldaleTown_PokemonCenter_2F/scripts.inc"
	.include "data/maps/OldaleTown_Mart/scripts.inc"
	.include "data/maps/DewfordTown_House1/scripts.inc"
	.include "data/maps/DewfordTown_PokemonCenter_1F/scripts.inc"
	.include "data/maps/DewfordTown_PokemonCenter_2F/scripts.inc"
	.include "data/maps/DewfordTown_Gym/scripts.inc"
	.include "data/maps/DewfordTown_Hall/scripts.inc"
	.include "data/maps/DewfordTown_House2/scripts.inc"
	.include "data/maps/LavaridgeTown_HerbShop/scripts.inc"
	.include "data/maps/LavaridgeTown_Gym_1F/scripts.inc"
	.include "data/maps/LavaridgeTown_Gym_B1F/scripts.inc"
	.include "data/maps/LavaridgeTown_House/scripts.inc"
	.include "data/maps/LavaridgeTown_Mart/scripts.inc"
	.include "data/maps/LavaridgeTown_PokemonCenter_1F/scripts.inc"
	.include "data/maps/LavaridgeTown_PokemonCenter_2F/scripts.inc"
	.include "data/maps/FallarborTown_Mart/scripts.inc"
	.include "data/maps/FallarborTown_BattleTentLobby/scripts.inc"
	.include "data/maps/FallarborTown_BattleTentCorridor/scripts.inc"
	.include "data/maps/FallarborTown_BattleTentBattleRoom/scripts.inc"
	.include "data/maps/FallarborTown_PokemonCenter_1F/scripts.inc"
	.include "data/maps/FallarborTown_PokemonCenter_2F/scripts.inc"
	.include "data/maps/FallarborTown_CozmosHouse/scripts.inc"
	.include "data/maps/FallarborTown_MoveRelearnersHouse/scripts.inc"
	.include "data/maps/VerdanturfTown_BattleTentLobby/scripts.inc"
	.include "data/maps/VerdanturfTown_BattleTentCorridor/scripts.inc"
	.include "data/maps/VerdanturfTown_BattleTentBattleRoom/scripts.inc"
	.include "data/maps/VerdanturfTown_Mart/scripts.inc"
	.include "data/maps/VerdanturfTown_PokemonCenter_1F/scripts.inc"
	.include "data/maps/VerdanturfTown_PokemonCenter_2F/scripts.inc"
	.include "data/maps/VerdanturfTown_WandasHouse/scripts.inc"
	.include "data/maps/VerdanturfTown_FriendshipRatersHouse/scripts.inc"
	.include "data/maps/VerdanturfTown_House/scripts.inc"
	.include "data/maps/PacifidlogTown_PokemonCenter_1F/scripts.inc"
	.include "data/maps/PacifidlogTown_PokemonCenter_2F/scripts.inc"
	.include "data/maps/PacifidlogTown_House1/scripts.inc"
	.include "data/maps/PacifidlogTown_House2/scripts.inc"
	.include "data/maps/PacifidlogTown_House3/scripts.inc"
	.include "data/maps/PacifidlogTown_House4/scripts.inc"
	.include "data/maps/PacifidlogTown_House5/scripts.inc"
	.include "data/maps/PetalburgCity_WallysHouse/scripts.inc"
	.include "data/maps/PetalburgCity_Gym/scripts.inc"
	.include "data/maps/PetalburgCity_House1/scripts.inc"
	.include "data/maps/PetalburgCity_House2/scripts.inc"
	.include "data/maps/PetalburgCity_PokemonCenter_1F/scripts.inc"
	.include "data/maps/PetalburgCity_PokemonCenter_2F/scripts.inc"
	.include "data/maps/PetalburgCity_Mart/scripts.inc"
	.include "data/maps/SlateportCity_SternsShipyard_1F/scripts.inc"
	.include "data/maps/SlateportCity_SternsShipyard_2F/scripts.inc"
	.include "data/maps/SlateportCity_BattleTentLobby/scripts.inc"
	.include "data/maps/SlateportCity_BattleTentCorridor/scripts.inc"
	.include "data/maps/SlateportCity_BattleTentBattleRoom/scripts.inc"
	.include "data/maps/SlateportCity_NameRatersHouse/scripts.inc"
	.include "data/maps/SlateportCity_PokemonFanClub/scripts.inc"
	.include "data/maps/SlateportCity_OceanicMuseum_1F/scripts.inc"
	.include "data/maps/SlateportCity_OceanicMuseum_2F/scripts.inc"
	.include "data/maps/SlateportCity_Harbor/scripts.inc"
	.include "data/maps/SlateportCity_House/scripts.inc"
	.include "data/maps/SlateportCity_PokemonCenter_1F/scripts.inc"
	.include "data/maps/SlateportCity_PokemonCenter_2F/scripts.inc"
	.include "data/maps/SlateportCity_Mart/scripts.inc"
	.include "data/maps/MauvilleCity_Gym/scripts.inc"
	.include "data/maps/MauvilleCity_BikeShop/scripts.inc"
	.include "data/maps/MauvilleCity_House1/scripts.inc"
	.include "data/maps/MauvilleCity_GameCorner/scripts.inc"
	.include "data/maps/MauvilleCity_House2/scripts.inc"
	.include "data/maps/MauvilleCity_PokemonCenter_1F/scripts.inc"
	.include "data/maps/MauvilleCity_PokemonCenter_2F/scripts.inc"
	.include "data/maps/MauvilleCity_Mart/scripts.inc"
	.include "data/maps/RustboroCity_DevonCorp_1F/scripts.inc"
	.include "data/maps/RustboroCity_DevonCorp_2F/scripts.inc"
	.include "data/maps/RustboroCity_DevonCorp_3F/scripts.inc"
	.include "data/maps/RustboroCity_Gym/scripts.inc"
	.include "data/maps/RustboroCity_PokemonSchool/scripts.inc"
	.include "data/maps/RustboroCity_PokemonCenter_1F/scripts.inc"
	.include "data/maps/RustboroCity_PokemonCenter_2F/scripts.inc"
	.include "data/maps/RustboroCity_Mart/scripts.inc"
	.include "data/maps/RustboroCity_Flat1_1F/scripts.inc"
	.include "data/maps/RustboroCity_Flat1_2F/scripts.inc"
	.include "data/maps/RustboroCity_House1/scripts.inc"
	.include "data/maps/RustboroCity_CuttersHouse/scripts.inc"
	.include "data/maps/RustboroCity_House2/scripts.inc"
	.include "data/maps/RustboroCity_Flat2_1F/scripts.inc"
	.include "data/maps/RustboroCity_Flat2_2F/scripts.inc"
	.include "data/maps/RustboroCity_Flat2_3F/scripts.inc"
	.include "data/maps/RustboroCity_House3/scripts.inc"
	.include "data/maps/FortreeCity_House1/scripts.inc"
	.include "data/maps/FortreeCity_Gym/scripts.inc"
	.include "data/maps/FortreeCity_PokemonCenter_1F/scripts.inc"
	.include "data/maps/FortreeCity_PokemonCenter_2F/scripts.inc"
	.include "data/maps/FortreeCity_Mart/scripts.inc"
	.include "data/maps/FortreeCity_House2/scripts.inc"
	.include "data/maps/FortreeCity_House3/scripts.inc"
	.include "data/maps/FortreeCity_House4/scripts.inc"
	.include "data/maps/FortreeCity_House5/scripts.inc"
	.include "data/maps/FortreeCity_DecorationShop/scripts.inc"
	.include "data/maps/LilycoveCity_CoveLilyMotel_1F/scripts.inc"
	.include "data/maps/LilycoveCity_CoveLilyMotel_2F/scripts.inc"
	.include "data/maps/LilycoveCity_LilycoveMuseum_1F/scripts.inc"
	.include "data/maps/LilycoveCity_LilycoveMuseum_2F/scripts.inc"
	.include "data/maps/LilycoveCity_ContestLobby/scripts.inc"
	.include "data/maps/LilycoveCity_ContestHall/scripts.inc"
	.include "data/maps/LilycoveCity_PokemonCenter_1F/scripts.inc"
	.include "data/maps/LilycoveCity_PokemonCenter_2F/scripts.inc"
	.include "data/maps/LilycoveCity_UnusedMart/scripts.inc"
	.include "data/maps/LilycoveCity_PokemonTrainerFanClub/scripts.inc"
	.include "data/maps/LilycoveCity_Harbor/scripts.inc"
	.include "data/maps/LilycoveCity_MoveDeletersHouse/scripts.inc"
	.include "data/maps/LilycoveCity_House1/scripts.inc"
	.include "data/maps/LilycoveCity_House2/scripts.inc"
	.include "data/maps/LilycoveCity_House3/scripts.inc"
	.include "data/maps/LilycoveCity_House4/scripts.inc"
	.include "data/maps/LilycoveCity_DepartmentStore_1F/scripts.inc"
	.include "data/maps/LilycoveCity_DepartmentStore_2F/scripts.inc"
	.include "data/maps/LilycoveCity_DepartmentStore_3F/scripts.inc"
	.include "data/maps/LilycoveCity_DepartmentStore_4F/scripts.inc"
	.include "data/maps/LilycoveCity_DepartmentStore_5F/scripts.inc"
	.include "data/maps/LilycoveCity_DepartmentStoreRooftop/scripts.inc"
	.include "data/maps/LilycoveCity_DepartmentStoreElevator/scripts.inc"
	.include "data/maps/MossdeepCity_Gym/scripts.inc"
	.include "data/maps/MossdeepCity_House1/scripts.inc"
	.include "data/maps/MossdeepCity_House2/scripts.inc"
	.include "data/maps/MossdeepCity_PokemonCenter_1F/scripts.inc"
	.include "data/maps/MossdeepCity_PokemonCenter_2F/scripts.inc"
	.include "data/maps/MossdeepCity_Mart/scripts.inc"
	.include "data/maps/MossdeepCity_House3/scripts.inc"
	.include "data/maps/MossdeepCity_StevensHouse/scripts.inc"
	.include "data/maps/MossdeepCity_House4/scripts.inc"
	.include "data/maps/MossdeepCity_SpaceCenter_1F/scripts.inc"
	.include "data/maps/MossdeepCity_SpaceCenter_2F/scripts.inc"
	.include "data/maps/MossdeepCity_GameCorner_1F/scripts.inc"
	.include "data/maps/MossdeepCity_GameCorner_B1F/scripts.inc"
	.include "data/maps/SootopolisCity_Gym_1F/scripts.inc"
	.include "data/maps/SootopolisCity_Gym_B1F/scripts.inc"
	.include "data/maps/SootopolisCity_PokemonCenter_1F/scripts.inc"
	.include "data/maps/SootopolisCity_PokemonCenter_2F/scripts.inc"
	.include "data/maps/SootopolisCity_Mart/scripts.inc"
	.include "data/maps/SootopolisCity_House1/scripts.inc"
	.include "data/maps/SootopolisCity_House2/scripts.inc"
	.include "data/maps/SootopolisCity_House3/scripts.inc"
	.include "data/maps/SootopolisCity_House4/scripts.inc"
	.include "data/maps/SootopolisCity_House5/scripts.inc"
	.include "data/maps/SootopolisCity_House6/scripts.inc"
	.include "data/maps/SootopolisCity_House7/scripts.inc"
	.include "data/maps/SootopolisCity_LotadAndSeedotHouse/scripts.inc"
	.include "data/maps/SootopolisCity_MysteryEventsHouse_1F/scripts.inc"
	.include "data/maps/SootopolisCity_MysteryEventsHouse_B1F/scripts.inc"
	.include "data/maps/EverGrandeCity_SidneysRoom/scripts.inc"
	.include "data/maps/EverGrandeCity_PhoebesRoom/scripts.inc"
	.include "data/maps/EverGrandeCity_GlaciasRoom/scripts.inc"
	.include "data/maps/EverGrandeCity_DrakesRoom/scripts.inc"
	.include "data/maps/EverGrandeCity_ChampionsRoom/scripts.inc"
	.include "data/maps/EverGrandeCity_Hall1/scripts.inc"
	.include "data/maps/EverGrandeCity_Hall2/scripts.inc"
	.include "data/maps/EverGrandeCity_Hall3/scripts.inc"
	.include "data/maps/EverGrandeCity_Hall4/scripts.inc"
	.include "data/maps/EverGrandeCity_Hall5/scripts.inc"
	.include "data/maps/EverGrandeCity_PokemonLeague_1F/scripts.inc"
	.include "data/maps/EverGrandeCity_HallOfFame/scripts.inc"
	.include "data/maps/EverGrandeCity_PokemonCenter_1F/scripts.inc"
	.include "data/maps/EverGrandeCity_PokemonCenter_2F/scripts.inc"
	.include "data/maps/EverGrandeCity_PokemonLeague_2F/scripts.inc"
	.include "data/maps/Route104_MrBrineysHouse/scripts.inc"
	.include "data/maps/Route104_PrettyPetalFlowerShop/scripts.inc"
	.include "data/maps/Route111_WinstrateFamilysHouse/scripts.inc"
	.include "data/maps/Route111_OldLadysRestStop/scripts.inc"
	.include "data/maps/Route112_CableCarStation/scripts.inc"
	.include "data/maps/MtChimney_CableCarStation/scripts.inc"
	.include "data/maps/Route114_FossilManiacsHouse/scripts.inc"
	.include "data/maps/Route114_FossilManiacsTunnel/scripts.inc"
	.include "data/maps/Route114_LanettesHouse/scripts.inc"
	.include "data/maps/Route116_TunnelersRestHouse/scripts.inc"
	.include "data/maps/Route117_PokemonDayCare/scripts.inc"
	.include "data/maps/Route121_SafariZoneEntrance/scripts.inc"
	.include "data/maps/MeteorFalls_1F_1R/scripts.inc"
	.include "data/maps/MeteorFalls_1F_2R/scripts.inc"
	.include "data/maps/MeteorFalls_B1F_1R/scripts.inc"
	.include "data/maps/MeteorFalls_B1F_2R/scripts.inc"
	.include "data/maps/RusturfTunnel/scripts.inc"
	.include "data/maps/Underwater_SootopolisCity/scripts.inc"
	.include "data/maps/DesertRuins/scripts.inc"
	.include "data/maps/GraniteCave_1F/scripts.inc"
	.include "data/maps/GraniteCave_B1F/scripts.inc"
	.include "data/maps/GraniteCave_B2F/scripts.inc"
	.include "data/maps/GraniteCave_StevensRoom/scripts.inc"
	.include "data/maps/PetalburgWoods/scripts.inc"
	.include "data/maps/MtChimney/scripts.inc"
	.include "data/maps/JaggedPass/scripts.inc"
	.include "data/maps/FieryPath/scripts.inc"
	.include "data/maps/MtPyre_1F/scripts.inc"
	.include "data/maps/MtPyre_2F/scripts.inc"
	.include "data/maps/MtPyre_3F/scripts.inc"
	.include "data/maps/MtPyre_4F/scripts.inc"
	.include "data/maps/MtPyre_5F/scripts.inc"
	.include "data/maps/MtPyre_6F/scripts.inc"
	.include "data/maps/MtPyre_Exterior/scripts.inc"
	.include "data/maps/MtPyre_Summit/scripts.inc"
	.include "data/maps/AquaHideout_1F/scripts.inc"
	.include "data/maps/AquaHideout_B1F/scripts.inc"
	.include "data/maps/AquaHideout_B2F/scripts.inc"
	.include "data/maps/Underwater_SeafloorCavern/scripts.inc"
	.include "data/maps/SeafloorCavern_Entrance/scripts.inc"
	.include "data/maps/SeafloorCavern_Room1/scripts.inc"
	.include "data/maps/SeafloorCavern_Room2/scripts.inc"
	.include "data/maps/SeafloorCavern_Room3/scripts.inc"
	.include "data/maps/SeafloorCavern_Room4/scripts.inc"
	.include "data/maps/SeafloorCavern_Room5/scripts.inc"
	.include "data/maps/SeafloorCavern_Room6/scripts.inc"
	.include "data/maps/SeafloorCavern_Room7/scripts.inc"
	.include "data/maps/SeafloorCavern_Room8/scripts.inc"
	.include "data/maps/SeafloorCavern_Room9/scripts.inc"
	.include "data/maps/CaveOfOrigin_Entrance/scripts.inc"
	.include "data/maps/CaveOfOrigin_1F/scripts.inc"
	.include "data/maps/CaveOfOrigin_UnusedRubySapphireMap1/scripts.inc"
	.include "data/maps/CaveOfOrigin_UnusedRubySapphireMap2/scripts.inc"
	.include "data/maps/CaveOfOrigin_UnusedRubySapphireMap3/scripts.inc"
	.include "data/maps/CaveOfOrigin_B1F/scripts.inc"
	.include "data/maps/VictoryRoad_1F/scripts.inc"
	.include "data/maps/VictoryRoad_B1F/scripts.inc"
	.include "data/maps/VictoryRoad_B2F/scripts.inc"
	.include "data/maps/ShoalCave_LowTideEntranceRoom/scripts.inc"
	.include "data/maps/ShoalCave_LowTideInnerRoom/scripts.inc"
	.include "data/maps/ShoalCave_LowTideStairsRoom/scripts.inc"
	.include "data/maps/ShoalCave_LowTideLowerRoom/scripts.inc"
	.include "data/maps/ShoalCave_HighTideEntranceRoom/scripts.inc"
	.include "data/maps/ShoalCave_HighTideInnerRoom/scripts.inc"
	.include "data/maps/NewMauville_Entrance/scripts.inc"
	.include "data/maps/NewMauville_Inside/scripts.inc"
	.include "data/maps/AbandonedShip_Deck/scripts.inc"
	.include "data/maps/AbandonedShip_Corridors_1F/scripts.inc"
	.include "data/maps/AbandonedShip_Rooms_1F/scripts.inc"
	.include "data/maps/AbandonedShip_Corridors_B1F/scripts.inc"
	.include "data/maps/AbandonedShip_Rooms_B1F/scripts.inc"
	.include "data/maps/AbandonedShip_Rooms2_B1F/scripts.inc"
	.include "data/maps/AbandonedShip_Underwater1/scripts.inc"
	.include "data/maps/AbandonedShip_Room_B1F/scripts.inc"
	.include "data/maps/AbandonedShip_Rooms2_1F/scripts.inc"
	.include "data/maps/AbandonedShip_CaptainsOffice/scripts.inc"
	.include "data/maps/AbandonedShip_Underwater2/scripts.inc"
	.include "data/maps/AbandonedShip_HiddenFloorCorridors/scripts.inc"
	.include "data/maps/AbandonedShip_HiddenFloorRooms/scripts.inc"
	.include "data/maps/IslandCave/scripts.inc"
	.include "data/maps/AncientTomb/scripts.inc"
	.include "data/maps/Underwater_Route134/scripts.inc"
	.include "data/maps/Underwater_SealedChamber/scripts.inc"
	.include "data/maps/SealedChamber_OuterRoom/scripts.inc"
	.include "data/maps/SealedChamber_InnerRoom/scripts.inc"
	.include "data/maps/ScorchedSlab/scripts.inc"
	.include "data/maps/AquaHideout_UnusedRubyMap1/scripts.inc"
	.include "data/maps/AquaHideout_UnusedRubyMap2/scripts.inc"
	.include "data/maps/AquaHideout_UnusedRubyMap3/scripts.inc"
	.include "data/maps/SkyPillar_Entrance/scripts.inc"
	.include "data/maps/SkyPillar_Outside/scripts.inc"
	.include "data/maps/SkyPillar_1F/scripts.inc"
	.include "data/maps/SkyPillar_2F/scripts.inc"
	.include "data/maps/SkyPillar_3F/scripts.inc"
	.include "data/maps/SkyPillar_4F/scripts.inc"
	.include "data/maps/ShoalCave_LowTideIceRoom/scripts.inc"
	.include "data/maps/SkyPillar_5F/scripts.inc"
	.include "data/maps/SkyPillar_Top/scripts.inc"
	.include "data/maps/MagmaHideout_1F/scripts.inc"
	.include "data/maps/MagmaHideout_2F_1R/scripts.inc"
	.include "data/maps/MagmaHideout_2F_2R/scripts.inc"
	.include "data/maps/MagmaHideout_3F_1R/scripts.inc"
	.include "data/maps/MagmaHideout_3F_2R/scripts.inc"
	.include "data/maps/MagmaHideout_4F/scripts.inc"
	.include "data/maps/MagmaHideout_3F_3R/scripts.inc"
	.include "data/maps/MagmaHideout_2F_3R/scripts.inc"
	.include "data/maps/MirageTower_1F/scripts.inc"
	.include "data/maps/MirageTower_2F/scripts.inc"
	.include "data/maps/MirageTower_3F/scripts.inc"
	.include "data/maps/MirageTower_4F/scripts.inc"
	.include "data/maps/DesertUnderpass/scripts.inc"
	.include "data/maps/ArtisanCave_B1F/scripts.inc"
	.include "data/maps/ArtisanCave_1F/scripts.inc"
	.include "data/maps/Underwater_MarineCave/scripts.inc"
	.include "data/maps/MarineCave_Entrance/scripts.inc"
	.include "data/maps/MarineCave_End/scripts.inc"
	.include "data/maps/TerraCave_Entrance/scripts.inc"
	.include "data/maps/TerraCave_End/scripts.inc"
	.include "data/maps/AlteringCave/scripts.inc"
	.include "data/maps/MeteorFalls_StevensCave/scripts.inc"
	.include "data/scripts/shared_secret_base.inc"
	.include "data/maps/BattleColosseum_2P/scripts.inc"
	.include "data/maps/TradeCenter/scripts.inc"
	.include "data/maps/RecordCorner/scripts.inc"
	.include "data/maps/BattleColosseum_4P/scripts.inc"
	.include "data/maps/ContestHall/scripts.inc"
	.include "data/maps/InsideOfTruck/scripts.inc"
	.include "data/maps/SSTidalCorridor/scripts.inc"
	.include "data/maps/SSTidalLowerDeck/scripts.inc"
	.include "data/maps/SSTidalRooms/scripts.inc"
	.include "data/maps/BattlePyramidSquare01/scripts.inc"
	.include "data/maps/UnionRoom/scripts.inc"
	.include "data/maps/SafariZone_Northwest/scripts.inc"
	.include "data/maps/SafariZone_North/scripts.inc"
	.include "data/maps/SafariZone_Southwest/scripts.inc"
	.include "data/maps/SafariZone_South/scripts.inc"
	.include "data/maps/BattleFrontier_OutsideWest/scripts.inc"
	.include "data/maps/BattleFrontier_BattleTowerLobby/scripts.inc"
	.include "data/maps/BattleFrontier_BattleTowerElevator/scripts.inc"
	.include "data/maps/BattleFrontier_BattleTowerCorridor/scripts.inc"
	.include "data/maps/BattleFrontier_BattleTowerBattleRoom/scripts.inc"
	.include "data/maps/SouthernIsland_Exterior/scripts.inc"
	.include "data/maps/SouthernIsland_Interior/scripts.inc"
	.include "data/maps/SafariZone_RestHouse/scripts.inc"
	.include "data/maps/SafariZone_Northeast/scripts.inc"
	.include "data/maps/SafariZone_Southeast/scripts.inc"
	.include "data/maps/BattleFrontier_OutsideEast/scripts.inc"
	.include "data/maps/BattleFrontier_BattleTowerMultiPartnerRoom/scripts.inc"
	.include "data/maps/BattleFrontier_BattleTowerMultiCorridor/scripts.inc"
	.include "data/maps/BattleFrontier_BattleTowerMultiBattleRoom/scripts.inc"
	.include "data/maps/BattleFrontier_BattleDomeLobby/scripts.inc"
	.include "data/maps/BattleFrontier_BattleDomeCorridor/scripts.inc"
	.include "data/maps/BattleFrontier_BattleDomePreBattleRoom/scripts.inc"
	.include "data/maps/BattleFrontier_BattleDomeBattleRoom/scripts.inc"
	.include "data/maps/BattleFrontier_BattlePalaceLobby/scripts.inc"
	.include "data/maps/BattleFrontier_BattlePalaceCorridor/scripts.inc"
	.include "data/maps/BattleFrontier_BattlePalaceBattleRoom/scripts.inc"
	.include "data/maps/BattleFrontier_BattlePyramidLobby/scripts.inc"
	.include "data/maps/BattleFrontier_BattlePyramidFloor/scripts.inc"
	.include "data/maps/BattleFrontier_BattlePyramidTop/scripts.inc"
	.include "data/maps/BattleFrontier_BattleArenaLobby/scripts.inc"
	.include "data/maps/BattleFrontier_BattleArenaCorridor/scripts.inc"
	.include "data/maps/BattleFrontier_BattleArenaBattleRoom/scripts.inc"
	.include "data/maps/BattleFrontier_BattleFactoryLobby/scripts.inc"
	.include "data/maps/BattleFrontier_BattleFactoryPreBattleRoom/scripts.inc"
	.include "data/maps/BattleFrontier_BattleFactoryBattleRoom/scripts.inc"
	.include "data/maps/BattleFrontier_BattlePikeLobby/scripts.inc"
	.include "data/maps/BattleFrontier_BattlePikeCorridor/scripts.inc"
	.include "data/maps/BattleFrontier_BattlePikeThreePathRoom/scripts.inc"
	.include "data/maps/BattleFrontier_BattlePikeRoomNormal/scripts.inc"
	.include "data/maps/BattleFrontier_BattlePikeRoomFinal/scripts.inc"
	.include "data/maps/BattleFrontier_BattlePikeRoomWildMons/scripts.inc"
	.include "data/maps/BattleFrontier_RankingHall/scripts.inc"
	.include "data/maps/BattleFrontier_Lounge1/scripts.inc"
	.include "data/maps/BattleFrontier_ExchangeServiceCorner/scripts.inc"
	.include "data/maps/BattleFrontier_Lounge2/scripts.inc"
	.include "data/maps/BattleFrontier_Lounge3/scripts.inc"
	.include "data/maps/BattleFrontier_Lounge4/scripts.inc"
	.include "data/maps/BattleFrontier_ScottsHouse/scripts.inc"
	.include "data/maps/BattleFrontier_Lounge5/scripts.inc"
	.include "data/maps/BattleFrontier_Lounge6/scripts.inc"
	.include "data/maps/BattleFrontier_Lounge7/scripts.inc"
	.include "data/maps/BattleFrontier_ReceptionGate/scripts.inc"
	.include "data/maps/BattleFrontier_Lounge8/scripts.inc"
	.include "data/maps/BattleFrontier_Lounge9/scripts.inc"
	.include "data/maps/BattleFrontier_PokemonCenter_1F/scripts.inc"
	.include "data/maps/BattleFrontier_PokemonCenter_2F/scripts.inc"
	.include "data/maps/BattleFrontier_Mart/scripts.inc"
	.include "data/maps/FarawayIsland_Entrance/scripts.inc"
	.include "data/maps/FarawayIsland_Interior/scripts.inc"
	.include "data/maps/BirthIsland_Exterior/scripts.inc"
	.include "data/maps/BirthIsland_Harbor/scripts.inc"
	.include "data/maps/TrainerHill_Entrance/scripts.inc"
	.include "data/maps/TrainerHill_1F/scripts.inc"
	.include "data/maps/TrainerHill_2F/scripts.inc"
	.include "data/maps/TrainerHill_3F/scripts.inc"
	.include "data/maps/TrainerHill_4F/scripts.inc"
	.include "data/maps/TrainerHill_Roof/scripts.inc"
	.include "data/maps/NavelRock_Exterior/scripts.inc"
	.include "data/maps/NavelRock_Harbor/scripts.inc"
	.include "data/maps/NavelRock_Entrance/scripts.inc"
	.include "data/maps/NavelRock_B1F/scripts.inc"
	.include "data/maps/NavelRock_Fork/scripts.inc"
	.include "data/maps/NavelRock_Up1/scripts.inc"
	.include "data/maps/NavelRock_Up2/scripts.inc"
	.include "data/maps/NavelRock_Up3/scripts.inc"
	.include "data/maps/NavelRock_Up4/scripts.inc"
	.include "data/maps/NavelRock_Top/scripts.inc"
	.include "data/maps/NavelRock_Down01/scripts.inc"
	.include "data/maps/NavelRock_Down02/scripts.inc"
	.include "data/maps/NavelRock_Down03/scripts.inc"
	.include "data/maps/NavelRock_Down04/scripts.inc"
	.include "data/maps/NavelRock_Down05/scripts.inc"
	.include "data/maps/NavelRock_Down06/scripts.inc"
	.include "data/maps/NavelRock_Down07/scripts.inc"
	.include "data/maps/NavelRock_Down08/scripts.inc"
	.include "data/maps/NavelRock_Down09/scripts.inc"
	.include "data/maps/NavelRock_Down10/scripts.inc"
	.include "data/maps/NavelRock_Down11/scripts.inc"
	.include "data/maps/NavelRock_Bottom/scripts.inc"
	.include "data/maps/TrainerHill_Elevator/scripts.inc"
	.include "data/maps/Route104_Prototype/scripts.inc"
	.include "data/maps/Route104_PrototypePrettyPetalFlowerShop/scripts.inc"
	.include "data/maps/Route109_SeashoreHouse/scripts.inc"
	.include "data/maps/Route110_TrickHouseEntrance/scripts.inc"
	.include "data/maps/Route110_TrickHouseEnd/scripts.inc"
	.include "data/maps/Route110_TrickHouseCorridor/scripts.inc"
	.include "data/maps/Route110_TrickHousePuzzle1/scripts.inc"
	.include "data/maps/Route110_TrickHousePuzzle2/scripts.inc"
	.include "data/maps/Route110_TrickHousePuzzle3/scripts.inc"
	.include "data/maps/Route110_TrickHousePuzzle4/scripts.inc"
	.include "data/maps/Route110_TrickHousePuzzle5/scripts.inc"
	.include "data/maps/Route110_TrickHousePuzzle6/scripts.inc"
	.include "data/maps/Route110_TrickHousePuzzle7/scripts.inc"
	.include "data/maps/Route110_TrickHousePuzzle8/scripts.inc"
	.include "data/maps/Route110_SeasideCyclingRoadNorthEntrance/scripts.inc"
	.include "data/maps/Route110_SeasideCyclingRoadSouthEntrance/scripts.inc"
	.include "data/maps/Route113_GlassWorkshop/scripts.inc"
	.include "data/maps/Route123_BerryMastersHouse/scripts.inc"
	.include "data/maps/Route119_WeatherInstitute_1F/scripts.inc"
	.include "data/maps/Route119_WeatherInstitute_2F/scripts.inc"
	.include "data/maps/Route119_House/scripts.inc"
	.include "data/maps/Route124_DivingTreasureHuntersHouse/scripts.inc"

	.include "data/scripts/std_msgbox.inc"
	.include "data/scripts/trainer_battle.inc"
	.include "data/scripts/new_game.inc"
	.include "data/scripts/hall_of_fame.inc"

EventScript_WhiteOut:: @ 8271857
	call EverGrandeCity_HallOfFame_EventScript_ResetEliteFour
	goto EventScript_ResetMrBriney
	end

EventScript_ResetMrBriney:: @ 8271862
	compare VAR_BRINEY_LOCATION, 1
	goto_if_eq EventScript_MoveMrBrineyToHouse
	compare VAR_BRINEY_LOCATION, 2
	goto_if_eq EventScript_MoveMrBrineyToDewford
	compare VAR_BRINEY_LOCATION, 3
	goto_if_eq EventScript_MoveMrBrineyToRoute109
	end

EventScript_MoveMrBrineyToHouse:: @ 8271884
	setflag FLAG_HIDE_MR_BRINEY_DEWFORD_TOWN
	setflag FLAG_HIDE_MR_BRINEY_BOAT_DEWFORD_TOWN
	setflag FLAG_HIDE_ROUTE_109_MR_BRINEY
	setflag FLAG_HIDE_ROUTE_109_MR_BRINEY_BOAT
	clearflag FLAG_HIDE_ROUTE_104_MR_BRINEY_BOAT
	clearflag FLAG_HIDE_BRINEYS_HOUSE_MR_BRINEY
	clearflag FLAG_HIDE_BRINEYS_HOUSE_PEEKO
	end

EventScript_MoveMrBrineyToDewford:: @ 827189A
	setflag FLAG_HIDE_ROUTE_109_MR_BRINEY
	setflag FLAG_HIDE_ROUTE_109_MR_BRINEY_BOAT
	setflag FLAG_HIDE_ROUTE_104_MR_BRINEY
	setflag FLAG_HIDE_ROUTE_104_MR_BRINEY_BOAT
	setflag FLAG_HIDE_BRINEYS_HOUSE_MR_BRINEY
	setflag FLAG_HIDE_BRINEYS_HOUSE_PEEKO
	clearflag FLAG_HIDE_MR_BRINEY_DEWFORD_TOWN
	clearflag FLAG_HIDE_MR_BRINEY_BOAT_DEWFORD_TOWN
	end

EventScript_MoveMrBrineyToRoute109:: @ 82718B3
	setflag FLAG_HIDE_ROUTE_104_MR_BRINEY
	setflag FLAG_HIDE_ROUTE_104_MR_BRINEY_BOAT
	setflag FLAG_HIDE_BRINEYS_HOUSE_MR_BRINEY
	setflag FLAG_HIDE_BRINEYS_HOUSE_PEEKO
	setflag FLAG_HIDE_MR_BRINEY_DEWFORD_TOWN
	setflag FLAG_HIDE_MR_BRINEY_BOAT_DEWFORD_TOWN
	clearflag FLAG_HIDE_ROUTE_109_MR_BRINEY
	clearflag FLAG_HIDE_ROUTE_109_MR_BRINEY_BOAT
	end

EverGrandeCity_HallOfFame_EventScript_ResetEliteFour:: @ 82718CC
	clearflag FLAG_DEFEATED_ELITE_4_SIDNEY
	clearflag FLAG_DEFEATED_ELITE_4_PHOEBE
	clearflag FLAG_DEFEATED_ELITE_4_GLACIA
	clearflag FLAG_DEFEATED_ELITE_4_DRAKE
	setvar VAR_ELITE_4_STATE, 0
	return

Common_EventScript_UpdateBrineyLocation:: @ 82718DE
	goto_if_unset FLAG_RECEIVED_POKENAV, Common_EventScript_NopReturn
	goto_if_set FLAG_DEFEATED_PETALBURG_GYM, Common_EventScript_NopReturn
	goto_if_unset FLAG_HIDE_ROUTE_104_MR_BRINEY_BOAT, EventScript_SetBrineyLocation_House
	goto_if_unset FLAG_HIDE_MR_BRINEY_DEWFORD_TOWN, EventScript_SetBrineyLocation_Dewford
	goto_if_unset FLAG_HIDE_ROUTE_109_MR_BRINEY, EventScript_SetBrineyLocation_Route109
	return

EventScript_SetBrineyLocation_House:: @ 827190C
	setvar VAR_BRINEY_LOCATION, 1
	return

EventScript_SetBrineyLocation_Dewford:: @ 8271912
	setvar VAR_BRINEY_LOCATION, 2
	return

EventScript_SetBrineyLocation_Route109:: @ 8271918
	setvar VAR_BRINEY_LOCATION, 3
	return

	.include "data/scripts/pkmn_center_nurse.inc"
	.include "data/scripts/obtain_item.inc"
	.include "data/scripts/record_mix.inc"
	.include "data/scripts/pc.inc"

@ scripts/notices.inc? signs.inc? See comment about text/notices.inc
Common_EventScript_ShowPokemartSign:: @ 8271E6A
	msgbox gText_PokemartSign, MSGBOX_SIGN
	end

Common_EventScript_ShowPokemonCenterSign:: @ 8271E73
	msgbox gText_PokemonCenterSign, MSGBOX_SIGN
	end

Common_ShowEasyChatScreen:: @ 8271E7C
	fadescreen FADE_TO_BLACK
	special ShowEasyChatScreen
	fadescreen FADE_FROM_BLACK
	return

Common_EventScript_ReadyPetalburgGymForBattle:: @ 8271E84
	clearflag FLAG_HIDE_PETALBURG_GYM_GREETER
	setflag FLAG_PETALBURG_MART_EXPANDED_ITEMS
	return

Common_EventScript_BufferTrendyPhrase:: @ 8271E8B
	dotimebasedevents
	setvar VAR_0x8004, 0
	special BufferTrendyPhraseString
	return

EventScript_BackupMrBrineyLocation:: @ 8271E95
	copyvar VAR_0x8008, VAR_BRINEY_LOCATION
	setvar VAR_BRINEY_LOCATION, 0
	return

	.include "data/scripts/surf.inc"
	.include "data/scripts/rival_graphics.inc"
	.include "data/scripts/set_gym_trainers.inc"

Common_EventScript_ShowBagIsFull:: @ 8272054
	msgbox gText_TooBadBagIsFull, MSGBOX_DEFAULT
	release
	end

Common_EventScript_BagIsFull:: @ 827205E
	msgbox gText_TooBadBagIsFull, MSGBOX_DEFAULT
	return

Common_EventScript_ShowNoRoomForDecor:: @ 8272067
	msgbox gText_NoRoomLeftForAnother, MSGBOX_DEFAULT
	release
	end

Common_EventScript_NoRoomForDecor:: @ 8272071
	msgbox gText_NoRoomLeftForAnother, MSGBOX_DEFAULT
	return

Common_EventScript_SetAbnormalWeather:: @ 827207A
	setweather WEATHER_ABNORMAL
	return

Common_EventScript_PlayGymBadgeFanfare:: @ 827207E
	playfanfare MUS_OBTAIN_BADGE
	waitfanfare
	return

Common_EventScript_OutOfCenterPartyHeal:: @ 8272083
	fadescreen FADE_TO_BLACK
	playfanfare MUS_HEAL
	waitfanfare
	special HealPlayerParty
	fadescreen FADE_FROM_BLACK
	return

EventScript_RegionMap:: @ 827208F
	lockall
	msgbox Common_Text_LookCloserAtMap, MSGBOX_DEFAULT
	fadescreen FADE_TO_BLACK
	special FieldShowRegionMap
	waitstate
	releaseall
	end

Common_EventScript_PlayBrineysBoatMusic:: @ 82720A0
	setflag FLAG_DONT_TRANSITION_MUSIC
	playbgm MUS_SAILING, 0
	return

Common_EventScript_StopBrineysBoatMusic:: @ 82720A8
	clearflag FLAG_DONT_TRANSITION_MUSIC
	fadedefaultbgm
	return

	.include "data/scripts/prof_birch.inc"

@ Below could be split as ferry.inc aside from the Rusturf tunnel script
Common_EventScript_FerryDepart:: @ 82721E2
	delay 60
	applymovement VAR_0x8004, Movement_FerryDepart
	waitmovement 0
	return

Movement_FerryDepart: @ 82721F0
	walk_slow_right
	walk_slow_right
	walk_slow_right
	walk_right
	walk_right
	walk_right
	walk_right
	step_end

EventScript_HideMrBriney:: @ 82721F8
	setflag FLAG_HIDE_MR_BRINEY_DEWFORD_TOWN
	setflag FLAG_HIDE_MR_BRINEY_BOAT_DEWFORD_TOWN
	setflag FLAG_HIDE_ROUTE_109_MR_BRINEY
	setflag FLAG_HIDE_ROUTE_109_MR_BRINEY_BOAT
	setflag FLAG_HIDE_ROUTE_104_MR_BRINEY
	setflag FLAG_HIDE_ROUTE_104_MR_BRINEY_BOAT
	setflag FLAG_HIDE_BRINEYS_HOUSE_MR_BRINEY
	setflag FLAG_HIDE_BRINEYS_HOUSE_PEEKO
	setvar VAR_BRINEY_LOCATION, 0
	return

RusturfTunnel_EventScript_SetRusturfTunnelOpen:: @ 8272216
	removeobject LOCALID_WANDAS_BF
	removeobject LOCALID_WANDA
	clearflag FLAG_HIDE_VERDANTURF_TOWN_WANDAS_HOUSE_WANDAS_BOYFRIEND
	clearflag FLAG_HIDE_VERDANTURF_TOWN_WANDAS_HOUSE_WANDA
	setvar VAR_RUSTURF_TUNNEL_STATE, 6
	setflag FLAG_RUSTURF_TUNNEL_OPENED
	return

EventScript_UnusedBoardFerry:: @ 827222B
	delay 30
	applymovement OBJ_EVENT_ID_PLAYER, Common_Movement_WalkInPlaceFastestUp
	waitmovement 0
	showobjectat OBJ_EVENT_ID_PLAYER, 0
	delay 30
	applymovement OBJ_EVENT_ID_PLAYER, Movement_UnusedBoardFerry
	waitmovement 0
	delay 30
	return

Movement_UnusedBoardFerry: @ 827224E
	walk_up
	step_end

Common_EventScript_FerryDepartIsland:: @ 8272250
	compare VAR_FACING, DIR_SOUTH
	call_if_eq Ferry_EventScript_DepartIslandSouth
	compare VAR_FACING, DIR_WEST
	call_if_eq Ferry_EventScript_DepartIslandWest
	delay 30
	hideobjectat OBJ_EVENT_ID_PLAYER, 0
	call Common_EventScript_FerryDepart
	return

	.include "data/scripts/cave_of_origin.inc"
	.include "data/scripts/kecleon.inc"

Common_EventScript_NameReceivedPartyMon:: @ 82723DD
	fadescreen FADE_TO_BLACK
	special ChangePokemonNickname
	waitstate
	return

Common_EventScript_PlayerHandedOverTheItem:: @ 82723E4
	bufferitemname 0, VAR_0x8004
	playfanfare MUS_OBTAIN_TMHM
	message gText_PlayerHandedOverTheItem
	waitmessage
	waitfanfare
	removeitem VAR_0x8004
	return

	.include "data/scripts/elite_four.inc"
	.include "data/scripts/movement.inc"
	.include "data/scripts/check_furniture.inc"
	.include "data/text/record_mix.inc"
	.include "data/text/pc.inc"
	.include "data/text/pkmn_center_nurse.inc"
	.include "data/text/mart_clerk.inc"
	.include "data/text/obtain_item.inc"

@ The below and surf.inc could be split into some text/notices.inc
gText_PokemartSign:: @ 8272B6A
	.string "“Selected items for your convenience!”\n"
	.string "POKéMON MART$"

gText_PokemonCenterSign:: @ 8272B9E
	.string "“Rejuvenate your tired partners!”\n"
	.string "POKéMON CENTER$"

gText_MomOrDadMightLikeThisProgram:: @ 8272BCF
	.string "{STR_VAR_1} might like this program.\n"
	.string "… … … … … … … … … … … … … … … …\p"
	.string "Better get going!$"

gText_WhichFloorWouldYouLike:: @ 8272C1D
	.string "Welcome to LILYCOVE DEPARTMENT STORE.\p"
	.string "Which floor would you like?$"

gText_SandstormIsVicious:: @ 8272C5F
	.string "The sandstorm is vicious.\n"
	.string "It's impossible to keep going.$"

gText_SelectWithoutRegisteredItem:: @ 8272C98
	.string "An item in the BAG can be\n"
	.string "registered to SELECT for easy use.$"

gText_PokemonTrainerSchoolEmail:: @ 8272CD5
	.string "There's an e-mail from POKéMON TRAINER\n"
	.string "SCHOOL.\p"
	.string "… … … … … …\p"
	.string "A POKéMON may learn up to four moves.\p"
	.string "A TRAINER's expertise is tested on the\n"
	.string "move sets chosen for POKéMON.\p"
	.string "… … … … … …$"

gText_PlayerHouseBootPC:: @ 8272D87
	.string "{PLAYER} booted up the PC.$"

gText_PokeblockLinkCanceled:: @ 8272D9C
	.string "The link was canceled.$"

gText_UnusedNicknameReceivedPokemon:: @ 8272DB3
	.string "Want to give a nickname to\n"
	.string "the {STR_VAR_2} you received?$"

gText_PlayerWhitedOut:: @ 8272DE3
	.string "{PLAYER} is out of usable\n"
	.string "POKéMON!\p{PLAYER} whited out!$"

gText_RegisteredTrainerinPokeNav:: @ 8272E0F
	.string "Registered {STR_VAR_1} {STR_VAR_2}\n"
	.string "in the POKéNAV.$"

gText_ComeBackWithSecretPower:: @ 8272E30
	.string "Do you know the TM SECRET POWER?\p"
	.string "Our group, we love the TM SECRET\n"
	.string "POWER.\p"
	.string "One of our members will give it to you.\n"
	.string "Come back and show me if you get it.\p"
	.string "We'll accept you as a member and sell\n"
	.string "you good stuff in secrecy.$"

gText_PokerusExplanation:: @ 8272F07
	.string "Your POKéMON may be infected with\n"
	.string "POKéRUS.\p"
	.string "Little is known about the POKéRUS\n"
	.string "except that they are microscopic life-\l"
	.string "forms that attach to POKéMON.\p"
	.string "While infected, POKéMON are said to\n"
	.string "grow exceptionally well.$"

	.include "data/text/surf.inc"

gText_DoorOpenedFarAway:: @ 827301B
	.string "It sounded as if a door opened\n"
	.string "somewhere far away.$"

gText_BigHoleInTheWall:: @ 827304E
	.string "There is a big hole in the wall.$"

gText_SorryWirelessClubAdjustments:: @ 827306F
	.string "I'm terribly sorry.\n"
	.string "The POKéMON WIRELESS CLUB is\l"
	.string "undergoing adjustments now.$"

gText_UndergoingAdjustments:: @ 82730BC
	.string "It appears to be undergoing\n"
	.string "adjustments…$"

@ Unused
gText_SorryTradeCenterInspections:: @ 82730E5
	.string "I'm terribly sorry. The TRADE CENTER\n"
	.string "is undergoing inspections.$"

@ Unused
gText_SorryRecordCornerPreparation:: @ 8273125
	.string "I'm terribly sorry. The RECORD CORNER\n"
	.string "is under preparation.$"

gText_PlayerHandedOverTheItem:: @ 8273161
	.string "{PLAYER} handed over the\n"
	.string "{STR_VAR_1}.$"

gText_ThankYouForAccessingMysteryGift:: @ 8273178
	.string "Thank you for accessing the\n"
	.string "MYSTERY GIFT System.$"

gText_PlayerFoundOneTMHM:: @ 82731A9
	.string "{PLAYER} found one {STR_VAR_1}\n"
	.string "{STR_VAR_2}!$"

gText_Sudowoodo_Attacked:: @ 82731BD
	.string "The weird tree doesn't like the\n"
	.string "WAILMER PAIL!\p"
	.string "The weird tree attacked!$"

gText_LegendaryFlewAway:: @ 8273204
	.string "The {STR_VAR_1} flew away!$"

	.include "data/text/pc_transfer.inc"
	.include "data/text/mevent.inc"
	.include "data/text/abnormal_weather.inc"

EventScript_SelectWithoutRegisteredItem:: @ 82736B3
	msgbox gText_SelectWithoutRegisteredItem, MSGBOX_SIGN
	end

	.include "data/scripts/field_poison.inc"

Common_EventScript_NopReturn:: @ 827374E
	return

@ Unused
EventScript_CableClub_SetVarResult1:: @ 827374F
	setvar VAR_RESULT, 1
	return

EventScript_CableClub_SetVarResult0:: @ 8273755
	setvar VAR_RESULT, 0
	return

Common_EventScript_UnionRoomAttendant:: @ 827375B
	call CableClub_EventScript_UnionRoomAttendant
	end

Common_EventScript_WirelessClubAttendant:: @ 8273761
	call CableClub_EventScript_WirelessClubAttendant
	end

Common_EventScript_DirectCornerAttendant:: @ 8273767
	call CableClub_EventScript_DirectCornerAttendant
	end

Common_EventScript_RemoveStaticPokemon:: @ 827376D
	fadescreenswapbuffers FADE_TO_BLACK
	removeobject VAR_LAST_TALKED
	fadescreenswapbuffers FADE_FROM_BLACK
	release
	end

Common_EventScript_LegendaryFlewAway:: @ 8273776
	fadescreenswapbuffers FADE_TO_BLACK
	removeobject VAR_LAST_TALKED
	fadescreenswapbuffers FADE_FROM_BLACK
	bufferspeciesname 0, VAR_0x8004
	msgbox gText_LegendaryFlewAway, MSGBOX_DEFAULT
	release
	end

	.include "data/scripts/pc_transfer.inc"
	.include "data/scripts/mevent.inc"
	.include "data/scripts/abnormal_weather.inc"
	.include "data/scripts/trainer_script.inc"
	.include "data/scripts/berry_tree.inc"
	.include "data/scripts/secret_base.inc"
	.include "data/scripts/cable_club.inc"
	.include "data/text/cable_club.inc"
	.include "data/scripts/contest_hall.inc"
	.include "data/text/contest_strings.inc"
	.include "data/text/contest_link.inc"
	.include "data/text/contest_painting.inc"
	.include "data/text/trick_house_mechadolls.inc"
	.include "data/scripts/tv.inc"
	.include "data/text/tv.inc"
	.include "data/scripts/interview.inc"
	.include "data/scripts/gabby_and_ty.inc"
	.include "data/text/pokemon_news.inc"
	.include "data/scripts/mauville_man.inc"
	.include "data/scripts/field_move_scripts.inc"
	.include "data/scripts/item_ball_scripts.inc"
	.include "data/scripts/mystery_event_club.inc"
	.include "data/scripts/day_care.inc"
	.include "data/scripts/flash.inc"
	.include "data/scripts/players_house.inc"
	.include "data/scripts/berry_blender.inc"
	.include "data/text/mauville_man.inc"
	.include "data/text/trainers.inc"
	.include "data/scripts/repel.inc"
	.include "data/scripts/safari_zone.inc"
	.include "data/scripts/roulette.inc"
	.include "data/text/pokedex_rating.inc"
	.include "data/text/lottery_corner.inc"
	.include "data/text/event_ticket_1.inc"
	.include "data/text/braille.inc"
	.include "data/text/berries.inc"
	.include "data/text/shoal_cave.inc"
	.include "data/text/check_furniture.inc"
	.include "data/scripts/cave_hole.inc"
	.include "data/scripts/lilycove_lady.inc"
	.include "data/text/match_call.inc"
	.include "data/scripts/apprentice.inc"
	.include "data/text/apprentice.inc"
	.include "data/text/battle_dome.inc"
	.include "data/scripts/battle_pike.inc"
	.include "data/text/blend_master.inc"
	.include "data/text/battle_tent.inc"
	.include "data/text/event_ticket_2.inc"
	.include "data/text/move_tutors.inc"
	.include "data/scripts/move_tutors.inc"
	.include "data/scripts/trainer_hill.inc"
	.include "data/scripts/test_signpost.inc"
	.include "data/text/frontier_brain.inc"
	.include "data/text/save.inc"
	.include "data/text/birch_speech.inc"


code:
	.include "asm/macros.inc"
	.include "constants/constants.inc"

	.section script_data, "aw", %progbits

	.align 2
gFieldEffectScriptPointers:: @ 82DB9D4
	.4byte gFieldEffectScript_ExclamationMarkIcon1      @ FLDEFF_EXCLAMATION_MARK_ICON
	.4byte gFieldEffectScript_UseCutOnTallGrass         @ FLDEFF_USE_CUT_ON_GRASS
	.4byte gFieldEffectScript_UseCutOnTree              @ FLDEFF_USE_CUT_ON_TREE
	.4byte gFieldEffectScript_Shadow                    @ FLDEFF_SHADOW
	.4byte gFieldEffectScript_TallGrass                 @ FLDEFF_TALL_GRASS
	.4byte gFieldEffectScript_Ripple                    @ FLDEFF_RIPPLE
	.4byte gFieldEffectScript_FieldMoveShowMon          @ FLDEFF_FIELD_MOVE_SHOW_MON
	.4byte gFieldEffectScript_Ash                       @ FLDEFF_ASH
	.4byte gFieldEffectScript_SurfBlob                  @ FLDEFF_SURF_BLOB
	.4byte gFieldEffectScript_UseSurf                   @ FLDEFF_USE_SURF
	.4byte gFieldEffectScript_GroundImpactDust          @ FLDEFF_DUST
	.4byte gFieldEffectScript_UseSecretPowerCave        @ FLDEFF_USE_SECRET_POWER_CAVE
	.4byte gFieldEffectScript_JumpTallGrass             @ FLDEFF_JUMP_TALL_GRASS
	.4byte gFieldEffectScript_SandFootprints            @ FLDEFF_SAND_FOOTPRINTS
	.4byte gFieldEffectScript_JumpBigSplash             @ FLDEFF_JUMP_BIG_SPLASH
	.4byte gFieldEffectScript_Splash                    @ FLDEFF_SPLASH
	.4byte gFieldEffectScript_JumpSmallSplash           @ FLDEFF_JUMP_SMALL_SPLASH
	.4byte gFieldEffectScript_LongGrass                 @ FLDEFF_LONG_GRASS
	.4byte gFieldEffectScript_JumpLongGrass             @ FLDEFF_JUMP_LONG_GRASS
	.4byte gFieldEffectScript_UnusedGrass               @ FLDEFF_UNUSED_GRASS
	.4byte gFieldEffectScript_UnusedGrass2              @ FLDEFF_UNUSED_GRASS_2
	.4byte gFieldEffectScript_UnusedSand                @ FLDEFF_UNUSED_SAND
	.4byte gFieldEffectScript_WaterSurfacing            @ FLDEFF_WATER_SURFACING
	.4byte gFieldEffectScript_BerryTreeGrowthSparkle    @ FLDEFF_BERRY_TREE_GROWTH_SPARKLE
	.4byte gFieldEffectScript_DeepSandFootprints        @ FLDEFF_DEEP_SAND_FOOTPRINTS
	.4byte gFieldEffectScript_PokeCenterHeal            @ FLDEFF_POKECENTER_HEAL
	.4byte gFieldEffectScript_UseSecretPowerTree        @ FLDEFF_USE_SECRET_POWER_TREE
	.4byte gFieldEffectScript_UseSecretPowerShrub       @ FLDEFF_USE_SECRET_POWER_SHRUB
	.4byte gFieldEffectScript_TreeDisguise              @ FLDEFF_TREE_DISGUISE
	.4byte gFieldEffectScript_MountainDisguise          @ FLDEFF_MOUNTAIN_DISGUISE
	.4byte gFieldEffectScript_NPCUseFly                 @ FLDEFF_NPCFLY_OUT
	.4byte gFieldEffectScript_UseFly                    @ FLDEFF_USE_FLY
	.4byte gFieldEffectScript_FlyIn                     @ FLDEFF_FLY_IN
	.4byte gFieldEffectScript_QuestionMarkIcon          @ FLDEFF_QUESTION_MARK_ICON
	.4byte gFieldEffectScript_FeetInFlowingWater        @ FLDEFF_FEET_IN_FLOWING_WATER
	.4byte gFieldEffectScript_BikeTireTracks            @ FLDEFF_BIKE_TIRE_TRACKS
	.4byte gFieldEffectScript_SandDisguisePlaceholder   @ FLDEFF_SAND_DISGUISE
	.4byte gFieldEffectScript_UseRockSmash              @ FLDEFF_USE_ROCK_SMASH
	.4byte gFieldEffectScript_UseDig                    @ FLDEFF_USE_DIG
	.4byte gFieldEffectScript_SandPile                  @ FLDEFF_SAND_PILE
	.4byte gFieldEffectScript_UseStrength               @ FLDEFF_USE_STRENGTH
	.4byte gFieldEffectScript_ShortGrass                @ FLDEFF_SHORT_GRASS
	.4byte gFieldEffectScript_HotSpringsWater           @ FLDEFF_HOT_SPRINGS_WATER
	.4byte gFieldEffectScript_UseWaterfall              @ FLDEFF_USE_WATERFALL
	.4byte gFieldEffectScript_UseDive                   @ FLDEFF_USE_DIVE
	.4byte gFieldEffectScript_Pokeball                  @ FLDEFF_POKEBALL
	.4byte gFieldEffectScript_HeartIcon                 @ FLDEFF_HEART_ICON
	.4byte gFieldEffectScript_Nop47                     @ FLDEFF_NOP_47
	.4byte gFieldEffectScript_Nop48                     @ FLDEFF_NOP_48
	.4byte gFieldEffectScript_AshPuff                   @ FLDEFF_ASH_PUFF
	.4byte gFieldEffectScript_AshLaunch                 @ FLDEFF_ASH_LAUNCH
	.4byte gFieldEffectScript_SweetScent                @ FLDEFF_SWEET_SCENT
	.4byte gFieldEffectScript_SandPillar                @ FLDEFF_SAND_PILLAR
	.4byte gFieldEffectScript_Bubbles                   @ FLDEFF_BUBBLES
	.4byte gFieldEffectScript_Sparkle                   @ FLDEFF_SPARKLE
	.4byte gFieldEffectScript_ShowSecretPowerCave       @ FLDEFF_SECRET_POWER_CAVE
	.4byte gFieldEffectScript_ShowSecretPowerTree       @ FLDEFF_SECRET_POWER_TREE
	.4byte gFieldEffectScript_ShowSecretPowerShrub      @ FLDEFF_SECRET_POWER_SHRUB
	.4byte gFieldEffectScript_ShowCutGrass              @ FLDEFF_CUT_GRASS
	.4byte gFieldEffectScript_FieldMoveShowMonInit      @ FLDEFF_FIELD_MOVE_SHOW_MON_INIT
	.4byte gFieldEffectScript_UsePuzzleEffect           @ FLDEFF_USE_TOMB_PUZZLE_EFFECT
	.4byte gFieldEffectScript_SecretBaseBootPC          @ FLDEFF_PCTURN_ON
	.4byte gFieldEffectScript_HallOfFameRecord          @ FLDEFF_HALL_OF_FAME_RECORD
	.4byte gFieldEffectScript_UseTeleport               @ FLDEFF_USE_TELEPORT
	.4byte gFieldEffectScript_RayquazaSpotlight         @ FLDEFF_RAYQUAZA_SPOTLIGHT
	.4byte gFieldEffectScript_DestroyDeoxysRock         @ FLDEFF_DESTROY_DEOXYS_ROCK
	.4byte gFieldEffectScript_MoveDeoxysRock            @ FLDEFF_MOVE_DEOXYS_ROCK

gFieldEffectScript_ExclamationMarkIcon1:: @ 82DBAE0
	field_eff_callnative FldEff_ExclamationMarkIcon
	field_eff_end

gFieldEffectScript_UseCutOnTallGrass:: @ 82DBAE6
	field_eff_callnative FldEff_UseCutOnGrass
	field_eff_end

gFieldEffectScript_UseCutOnTree:: @ 82DBAEC
	field_eff_callnative FldEff_UseCutOnTree
	field_eff_end

gFieldEffectScript_Shadow:: @ 82DBAF2
	field_eff_callnative FldEff_Shadow
	field_eff_end

gFieldEffectScript_TallGrass:: @ 82DBAF8
	field_eff_loadfadedpal_callnative gSpritePalette_GeneralFieldEffect1, FldEff_TallGrass
	field_eff_end

gFieldEffectScript_Ripple:: @ 82DBB02
	field_eff_loadfadedpal_callnative gSpritePalette_GeneralFieldEffect1, FldEff_Ripple
	field_eff_end

gFieldEffectScript_FieldMoveShowMon:: @ 82DBB0C
	field_eff_callnative FldEff_FieldMoveShowMon
	field_eff_end

gFieldEffectScript_Ash:: @ 82DBB12
	field_eff_loadfadedpal_callnative gSpritePalette_GeneralFieldEffect1, FldEff_Ash
	field_eff_end

gFieldEffectScript_SurfBlob:: @ 82DBB1C
	field_eff_callnative FldEff_SurfBlob
	field_eff_end

gFieldEffectScript_UseSurf:: @ 82DBB22
	field_eff_callnative FldEff_UseSurf
	field_eff_end

gFieldEffectScript_GroundImpactDust:: @ 82DBB28
	field_eff_loadfadedpal_callnative gSpritePalette_GeneralFieldEffect0, FldEff_Dust
	field_eff_end

gFieldEffectScript_UseSecretPowerCave:: @ 82DBB32
	field_eff_callnative FldEff_UseSecretPowerCave
	field_eff_end

gFieldEffectScript_JumpTallGrass:: @ 82DBB38
	field_eff_loadfadedpal_callnative gSpritePalette_GeneralFieldEffect1, FldEff_JumpTallGrass
	field_eff_end

gFieldEffectScript_SandFootprints:: @ 82DBB42
	field_eff_loadfadedpal_callnative gSpritePalette_GeneralFieldEffect0, FldEff_SandFootprints
	field_eff_end

gFieldEffectScript_JumpBigSplash:: @ 82DBB4C
	field_eff_loadfadedpal_callnative gSpritePalette_GeneralFieldEffect0, FldEff_JumpBigSplash
	field_eff_end

gFieldEffectScript_Splash:: @ 82DBB56
	field_eff_loadfadedpal_callnative gSpritePalette_GeneralFieldEffect0, FldEff_Splash
	field_eff_end

gFieldEffectScript_JumpSmallSplash:: @ 82DBB60
	field_eff_loadfadedpal_callnative gSpritePalette_GeneralFieldEffect0, FldEff_JumpSmallSplash
	field_eff_end

gFieldEffectScript_LongGrass:: @ 82DBB6A
	field_eff_loadfadedpal_callnative gSpritePalette_GeneralFieldEffect1, FldEff_LongGrass
	field_eff_end

gFieldEffectScript_JumpLongGrass:: @ 82DBB74
	field_eff_loadfadedpal_callnative gSpritePalette_GeneralFieldEffect1, FldEff_JumpLongGrass
	field_eff_end

gFieldEffectScript_UnusedGrass:: @ 82DBB7E
	field_eff_loadfadedpal_callnative gSpritePalette_GeneralFieldEffect1, FldEff_UnusedGrass
	field_eff_end

gFieldEffectScript_UnusedGrass2:: @ 82DBB88
	field_eff_loadfadedpal_callnative gSpritePalette_GeneralFieldEffect1, FldEff_UnusedGrass2
	field_eff_end

gFieldEffectScript_UnusedSand:: @ 82DBB92
	field_eff_loadfadedpal_callnative gSpritePalette_GeneralFieldEffect0, FldEff_UnusedSand
	field_eff_end

gFieldEffectScript_WaterSurfacing:: @ 82DBB9C
	field_eff_loadfadedpal_callnative gSpritePalette_GeneralFieldEffect0, FldEff_WaterSurfacing
	field_eff_end

gFieldEffectScript_BerryTreeGrowthSparkle:: @ 82DBBA6
	field_eff_callnative FldEff_BerryTreeGrowthSparkle
	field_eff_end

gFieldEffectScript_DeepSandFootprints:: @ 82DBBAC
	field_eff_loadfadedpal_callnative gSpritePalette_GeneralFieldEffect0, FldEff_DeepSandFootprints
	field_eff_end

gFieldEffectScript_PokeCenterHeal:: @ 82DBBB6
	field_eff_loadfadedpal gSpritePalette_PokeballGlow
	field_eff_loadfadedpal_callnative gSpritePalette_GeneralFieldEffect0, FldEff_PokecenterHeal
	field_eff_end

gFieldEffectScript_UseSecretPowerTree:: @ 82DBBC5
	field_eff_callnative FldEff_UseSecretPowerTree
	field_eff_end

gFieldEffectScript_UseSecretPowerShrub:: @ 82DBBCB
	field_eff_callnative FldEff_UseSecretPowerShrub
	field_eff_end

gFieldEffectScript_TreeDisguise:: @ 82DBBD1
	field_eff_callnative ShowTreeDisguiseFieldEffect
	field_eff_end

gFieldEffectScript_MountainDisguise:: @ 82DBBD7
	field_eff_callnative ShowMountainDisguiseFieldEffect
	field_eff_end

gFieldEffectScript_NPCUseFly:: @ 82DBBDD
	field_eff_callnative FldEff_NPCFlyOut
	field_eff_end

gFieldEffectScript_UseFly:: @ 82DBBE3
	field_eff_callnative FldEff_UseFly
	field_eff_end

gFieldEffectScript_FlyIn:: @ 82DBBE9
	field_eff_callnative FldEff_FlyIn
	field_eff_end

gFieldEffectScript_QuestionMarkIcon:: @ 82DBBEF
	field_eff_callnative FldEff_QuestionMarkIcon
	field_eff_end

gFieldEffectScript_FeetInFlowingWater:: @ 82DBBF5
	field_eff_loadfadedpal_callnative gSpritePalette_GeneralFieldEffect0, FldEff_FeetInFlowingWater
	field_eff_end

gFieldEffectScript_BikeTireTracks:: @ 82DBBFF
	field_eff_loadfadedpal_callnative gSpritePalette_GeneralFieldEffect0, FldEff_BikeTireTracks
	field_eff_end

gFieldEffectScript_SandDisguisePlaceholder:: @ 82DBC09
	field_eff_callnative ShowSandDisguiseFieldEffect
	field_eff_end

gFieldEffectScript_UseRockSmash:: @ 82DBC0F
	field_eff_callnative FldEff_UseRockSmash
	field_eff_end

gFieldEffectScript_UseStrength:: @ 82DBC15
	field_eff_callnative FldEff_UseStrength
	field_eff_end

gFieldEffectScript_UseDig:: @ 82DBC1B
	field_eff_callnative FldEff_UseDig
	field_eff_end

gFieldEffectScript_SandPile:: @ 82DBC21
	field_eff_loadfadedpal_callnative gSpritePalette_GeneralFieldEffect0, FldEff_SandPile
	field_eff_end

gFieldEffectScript_ShortGrass:: @ 82DBC2B
	field_eff_loadfadedpal_callnative gSpritePalette_GeneralFieldEffect1, FldEff_ShortGrass
	field_eff_end

gFieldEffectScript_HotSpringsWater:: @ 82DBC35
	field_eff_loadfadedpal_callnative gSpritePalette_GeneralFieldEffect1, FldEff_HotSpringsWater
	field_eff_end

gFieldEffectScript_UseWaterfall:: @ 82DBC3F
	field_eff_callnative FldEff_UseWaterfall
	field_eff_end

gFieldEffectScript_UseDive:: @ 82DBC45
	field_eff_callnative FldEff_UseDive
	field_eff_end

gFieldEffectScript_Pokeball:: @ 82DBC4B
	field_eff_loadpal gSpritePalette_Pokeball
	field_eff_callnative FldEff_Pokeball
	field_eff_end

gFieldEffectScript_HeartIcon:: @ 82DBC56
	field_eff_loadfadedpal_callnative gSpritePalette_GeneralFieldEffect0, FldEff_HeartIcon
	field_eff_end

gFieldEffectScript_Nop47:: @ 82DBC60
	field_eff_callnative FldEff_Nop47
	field_eff_end

gFieldEffectScript_Nop48:: @ 82DBC66
	field_eff_callnative FldEff_Nop48
	field_eff_end

gFieldEffectScript_AshPuff:: @ 82DBC6C
	field_eff_loadfadedpal_callnative gSpritePalette_Ash, FldEff_AshPuff
	field_eff_end

gFieldEffectScript_AshLaunch:: @ 82DBC76
	field_eff_loadfadedpal_callnative gSpritePalette_Ash, FldEff_AshLaunch
	field_eff_end

gFieldEffectScript_SweetScent:: @ 82DBC80
	field_eff_callnative FldEff_SweetScent
	field_eff_end

gFieldEffectScript_SandPillar:: @ 82DBC86
	field_eff_loadfadedpal_callnative gSpritePalette_SandPillar, FldEff_SandPillar
	field_eff_end

gFieldEffectScript_Bubbles:: @ 82DBC90
	field_eff_loadfadedpal_callnative gSpritePalette_GeneralFieldEffect0, FldEff_Bubbles
	field_eff_end

gFieldEffectScript_Sparkle:: @ 82DBC9A
	field_eff_loadfadedpal_callnative gSpritePalette_SmallSparkle, FldEff_Sparkle
	field_eff_end

gFieldEffectScript_ShowSecretPowerCave:: @ 82DBCA4
	field_eff_loadfadedpal_callnative gSpritePalette_SecretPower_Cave, FldEff_SecretPowerCave
	field_eff_end

gFieldEffectScript_ShowSecretPowerTree:: @ 82DBCAE
	field_eff_loadfadedpal_callnative gSpritePalette_SecretPower_Plant, FldEff_SecretPowerTree
	field_eff_end

gFieldEffectScript_ShowSecretPowerShrub:: @ 82DBCB8
	field_eff_loadfadedpal_callnative gSpritePalette_SecretPower_Plant, FldEff_SecretPowerShrub
	field_eff_end

gFieldEffectScript_ShowCutGrass:: @ 82DBCC2
	field_eff_loadfadedpal_callnative gSpritePalette_CutGrass, FldEff_CutGrass
	field_eff_end

gFieldEffectScript_FieldMoveShowMonInit:: @ 82DBCCC
	field_eff_callnative FldEff_FieldMoveShowMonInit
	field_eff_end

gFieldEffectScript_UsePuzzleEffect:: @ 82DBCD2
	field_eff_callnative FldEff_UsePuzzleEffect
	field_eff_end

gFieldEffectScript_SecretBaseBootPC:: @ 82DBCD8
	field_eff_callnative FldEff_SecretBasePCTurnOn
	field_eff_end

gFieldEffectScript_HallOfFameRecord:: @ 82DBCDE
	field_eff_loadfadedpal gSpritePalette_PokeballGlow
	field_eff_loadfadedpal_callnative gSpritePalette_HofMonitor, FldEff_HallOfFameRecord
	field_eff_end

gFieldEffectScript_UseTeleport:: @ 82DBCED
	field_eff_callnative FldEff_UseTeleport
	field_eff_end

gFieldEffectScript_RayquazaSpotlight:: @ 82DBCF3
	field_eff_callnative FldEff_RayquazaSpotlight
	field_eff_end

gFieldEffectScript_DestroyDeoxysRock:: @ 82DBCF9
	field_eff_callnative FldEff_DestroyDeoxysRock
	field_eff_end

gFieldEffectScript_MoveDeoxysRock:: @ 82DBCFF
	field_eff_callnative FldEff_MoveDeoxysRock
	field_eff_end


code:
	.include "asm/macros.inc"
	.include "constants/constants.inc"

	.section .rodata

	.align 2
gFont8LatinGlyphs:: @ 862BAE4
	.incbin "graphics/fonts/font8.latfont"

	.align 2
gFont8LatinGlyphWidths:: @ 8633AE4
	.include "graphics/fonts/font8_latin_widths.inc"

	.align 2
gFont0LatinGlyphs:: @ 8633CE4
	.incbin "graphics/fonts/font0.latfont"

	.align 2
gFont0LatinGlyphWidths:: @ 863BCE4
	.include "graphics/fonts/font0_latin_widths.inc"

	.align 2
gFont7LatinGlyphs:: @ 863BEE4
	.incbin "graphics/fonts/font7.latfont"

	.align 2
gFont7LatinGlyphWidths:: @ 8643EE4
	.include "graphics/fonts/font7_latin_widths.inc"

	.align 2
gFont2LatinGlyphs:: @ 86440E4
	.incbin "graphics/fonts/font2.latfont"

	.align 2
gFont2LatinGlyphWidths:: @ 864C0E4
	.include "graphics/fonts/font2_latin_widths.inc"

	.align 2
gFont1LatinGlyphs:: @ 864C2E4
	.incbin "graphics/fonts/font1.latfont"

	.align 2
gFont1LatinGlyphWidths:: @ 86542E4
	.include "graphics/fonts/font1_latin_widths.inc"

	.align 2
gFont0JapaneseGlyphs:: @ 86544E4
	.incbin "graphics/fonts/font0.hwjpnfont"

	.align 2
gFont1JapaneseGlyphs:: @ 86584E4
	.incbin "graphics/fonts/font1.hwjpnfont"

	.align 2
gUnusedJapaneseFireRedLeafGreenMaleFontGlyphs:: @ 865C4E4
	.incbin "graphics/fonts/unused_frlg_male.fwjpnfont"

	.align 2
gUnusedJapaneseFireRedLeafGreenMaleFontGlyphWidths:: @ 86644E4
	.include "graphics/fonts/unused_japanese_frlg_male_font_widths.inc"

	.align 2
gUnusedJapaneseFireRedLeafGreenFemaleFontGlyphs:: @ 86646E4
	.incbin "graphics/fonts/unused_frlg_female.fwjpnfont"

	.align 2
gUnusedJapaneseFireRedLeafGreenFemaleFontGlyphWidths:: @ 866C6E4
	.include "graphics/fonts/unused_japanese_frlg_female_font_widths.inc"

	.align 2
gFont2JapaneseGlyphs:: @ 866C8E4
	.incbin "graphics/fonts/font2.fwjpnfont"

	.align 2
gFont2JapaneseGlyphWidths:: @ 86748E4
	.include "graphics/fonts/font2_japanese_widths.inc"


code:
layouts.inc
layouts_table.inc


code: (((`(`(((((b`(((((((((((`(''`(eif(b`((�(((((((`('/`(((((b`('�(�(ef(`(/'hiiiiij`(''�('�((((`(*/������`(//�(/�((((`(�* ]]]��2�hiiiiiiii(((`(((33�*2*2�2*2�2��������ef(hiiiiif(2(2ei ��������(((�������0�0�����������((( ]]]��2��0�0��2�]]]]]]]](((33*2*2��2*2�2*2��2*2�2�*2*2*2*2*2*2*2((((�((�(2(2(2(2�(2(2(2�(2�(2(2(2(2iiiiiiiiiiiif(2(2eiiiiiii�������������0�0������������������� �0�0 ������������������� �2�2 �������������������4��4����������������������������������������������������������������������������pppppppp���������������


code: �����������������2�2�2�2�2�2�2�2�2�2�2�2�2�2�2�2�2�2�2�2�2�2�2�2�2�2�2�2�2�2�2�2�2�2�2�2�2�2�2�2�2�2�2�2�2�2�2�2