Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dynamic Trainer Battle Script Building #5938

Draft
wants to merge 42 commits into
base: upcoming
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
6dd666f
consolidate trainerparam globals into struct
u8-Salem Jul 12, 2024
082a7c2
fix battle end script pointing at wrong address
u8-Salem Jul 13, 2024
b58ff6f
introduce macro for easier access to paramerter
u8-Salem Jul 13, 2024
3ea6ea8
update other battle types
u8-Salem Jul 18, 2024
56439e7
running script snippets by pushing them to the stack first
u8-Salem Jul 19, 2024
9b1170c
actually push script snippets on the stack
u8-Salem Jul 19, 2024
bc49435
set up some test trainers
u8-Salem Jul 20, 2024
4d7c713
add generic pointer stack
u8-Salem Jul 22, 2024
86b7d72
move to new stack, refactor trainer_see, split eventscripts
u8-Salem Jul 22, 2024
5789d76
fix stack not popping last element
u8-Salem Jul 25, 2024
1c33882
replace battle type with flags. first double and rematch integration
u8-Salem Jul 25, 2024
40938be
small fix
u8-Salem Jul 26, 2024
30c2b28
first support for missing battle types. (very WIP)
u8-Salem Jul 26, 2024
e696d35
fix incorrect offset
u8-Salem Aug 10, 2024
5df7298
rename trainbattleparams var to show its global
u8-Salem Aug 10, 2024
782f3cd
handle multiple approaching trainer
u8-Salem Dec 23, 2024
d01af63
rename eventscript snippets for better readability
u8-Salem Dec 23, 2024
0d447f1
integrate multi battle support in regular battles. (wip)
u8-Salem Dec 25, 2024
0c3f302
fix no selection multi battles
u8-Salem Dec 25, 2024
54acc56
wild multi battles
u8-Salem Dec 26, 2024
c92b4f3
Revert multi battle integration part 1
u8-Salem Dec 27, 2024
f4e57fd
detach multi battles from regular 'trainerbattle' macro
u8-Salem Dec 27, 2024
1f5ae4a
remove obsolete stuff
u8-Salem Dec 28, 2024
9b60fcc
detach pyramid battles from regular trainer battles
u8-Salem Dec 30, 2024
2081763
handle trainer hill
u8-Salem Jan 3, 2025
6cdc290
remove pyramid and trainer hill from trainerbattleparam struct
u8-Salem Jan 3, 2025
4a051ae
Revert "set up some test trainers"
u8-Salem Jan 3, 2025
634b112
cleanup
u8-Salem Jan 3, 2025
237aacb
temp fix
u8-Salem Jan 3, 2025
82d7251
correct comments
u8-Salem Jan 3, 2025
f0b7bb7
remove last cases of gTrainerBattleOpponent_A
u8-Salem Jan 3, 2025
9753c60
rename snippets (again)
u8-Salem Jan 3, 2025
912a21b
Merge branch 'upcoming' into trainerbattle_refactor
u8-Salem Jan 3, 2025
e431236
merge fixes
u8-Salem Jan 3, 2025
a400947
add explanation md
u8-Salem Jan 3, 2025
607c0bb
more docs
u8-Salem Jan 4, 2025
5756e93
revert test trainer changes
u8-Salem Jan 4, 2025
00d215c
fix rematches not triggering
u8-Salem Jan 4, 2025
3e3c030
fix rematches not triggering
u8-Salem Jan 4, 2025
3d34c5a
Merge branch 'trainerbattle_refactor' of github.com:u8-Salem/pokeemer…
u8-Salem Jan 4, 2025
4ac2edb
fix one vs two trainer battle
u8-Salem Jan 4, 2025
4811fb2
Merge branch 'upcoming' into trainerbattle_refactor
pkmnsnfrn Jan 5, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion asm/macros/battle_frontier/battle_dome.inc
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
special CallBattleDomeFunction
.endm

@ Sets gTrainerBattleOpponent_A to the trainer ID of the next opponent
@ Sets TRAINER_BATTLE_PARAM.battleOpponentA to the trainer ID of the next opponent
.macro dome_setopponent
setvar VAR_0x8004, BATTLE_DOME_FUNC_SET_OPPONENT_ID
special CallBattleDomeFunction
Expand Down
10 changes: 4 additions & 6 deletions asm/macros/battle_frontier/battle_tower.inc
Original file line number Diff line number Diff line change
Expand Up @@ -115,14 +115,13 @@

.macro multi_2_vs_2 trainer1Id:req, trainer1LoseText:req, trainer2Id:req, trainer2LoseText:req, partnerId:req
special SavePlayerParty
trainerbattle TRAINER_BATTLE_SET_TRAINER_A, \trainer1Id, 0, NULL, \trainer1LoseText @ set first trainer mons
trainerbattle TRAINER_BATTLE_SET_TRAINER_B, \trainer2Id, 0, NULL, \trainer2LoseText @ set second trainer mons
setmultitrainerbattle \trainer1Id, \trainer1LoseText, \trainer2Id, \trainer2LoseText
multi_do MULTI_BATTLE_2_VS_2, \partnerId
.endm

.macro multi_2_vs_1 trainer1Id:req, trainer1LoseText:req, partnerId:req
special SavePlayerParty
trainerbattle TRAINER_BATTLE_SET_TRAINER_A, \trainer1Id, 0, NULL, \trainer1LoseText @ set first trainer mons
setmultitrainerbattle \trainer1Id, \trainer1LoseText, TRAINER_NONE, NULL
multi_do MULTI_BATTLE_2_VS_1, \partnerId
.endm

Expand All @@ -145,14 +144,13 @@

.macro multi_fixed_2_vs_2 trainer1Id:req, trainer1LoseText:req, trainer2Id:req, trainer2LoseText:req, partnerId:req
special SavePlayerParty
trainerbattle TRAINER_BATTLE_SET_TRAINER_A, \trainer1Id, 0, NULL, \trainer1LoseText @ set first trainer mons
trainerbattle TRAINER_BATTLE_SET_TRAINER_B, \trainer2Id, 0, NULL, \trainer2LoseText @ set second trainer mons
setmultitrainerbattle \trainer1Id, \trainer1LoseText, \trainer2Id, \trainer2LoseText
multi_do_fixed MULTI_BATTLE_2_VS_2, \partnerId
.endm

.macro multi_fixed_2_vs_1 trainer1Id:req, trainer1LoseText:req, partnerId:req
special SavePlayerParty
trainerbattle TRAINER_BATTLE_SET_TRAINER_A, \trainer1Id, 0, NULL, \trainer1LoseText @ set first trainer mons
setmultitrainerbattle \trainer1Id, \trainer1LoseText, TRAINER_NONE, NULL
multi_do_fixed MULTI_BATTLE_2_VS_1, \partnerId
.endm

Expand Down
2 changes: 1 addition & 1 deletion asm/macros/battle_frontier/frontier_util.inc
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@
special CallFrontierUtilFunc
.endm

@ Buffer the name of gTrainerBattleOpponent_A in STR_VAR_1 (0) or STR_VAR_2 (1)
@ Buffer the name of TRAINER_BATTLE_PARAM.battleOpponentA in STR_VAR_1 (0) or STR_VAR_2 (1)
.macro frontier_gettrainername stringVar:req
setvar VAR_0x8004, FRONTIER_UTIL_FUNC_BUFFER_TRAINER_NAME
.if \stringVar == STR_VAR_1
Expand Down
117 changes: 44 additions & 73 deletions asm/macros/event.inc
Original file line number Diff line number Diff line change
Expand Up @@ -680,111 +680,69 @@
.byte \direction
.endm

NULL = 0
OBJ_ID_NONE = 0

@ Configures the arguments for a trainer battle, then jumps to the appropriate script in scripts/trainer_battle.inc
.macro trainerbattle type:req, trainer:req, local_id:req, pointer1:req, pointer2, pointer3, pointer4
.macro trainerbattle localIdA:req, trainer_a:req, intro_text_a:req, lose_text_a:req, event_script_a:req, localIdB:req, trainer_b:req, intro_text_b:req, lose_text_b:req, event_script_b:req, victory_text:req, cannot_battle:req, isDouble:req, playMusicA:req, playMusicB:req, isRematch:req
.byte 0x5c
.byte \type
.2byte \trainer
.2byte \local_id
.if \type == TRAINER_BATTLE_SINGLE
.4byte \pointer1 @ text
.4byte \pointer2 @ text
.elseif \type == TRAINER_BATTLE_CONTINUE_SCRIPT_NO_MUSIC
.4byte \pointer1 @ text
.4byte \pointer2 @ text
.4byte \pointer3 @ event script
.elseif \type == TRAINER_BATTLE_CONTINUE_SCRIPT
.4byte \pointer1 @ text
.4byte \pointer2 @ text
.4byte \pointer3 @ event script
.elseif \type == TRAINER_BATTLE_SINGLE_NO_INTRO_TEXT
.4byte \pointer1 @ text
.elseif \type == TRAINER_BATTLE_DOUBLE
.4byte \pointer1 @ text
.4byte \pointer2 @ text
.4byte \pointer3 @ text
.elseif \type == TRAINER_BATTLE_REMATCH
.4byte \pointer1 @ text
.4byte \pointer2 @ text
.elseif \type == TRAINER_BATTLE_CONTINUE_SCRIPT_DOUBLE
.4byte \pointer1 @ text
.4byte \pointer2 @ text
.4byte \pointer3 @ text
.4byte \pointer4 @ event script
.elseif \type == TRAINER_BATTLE_REMATCH_DOUBLE
.4byte \pointer1 @ text
.4byte \pointer2 @ text
.4byte \pointer3 @ text
.elseif \type == TRAINER_BATTLE_CONTINUE_SCRIPT_DOUBLE_NO_MUSIC
.4byte \pointer1 @ text
.4byte \pointer2 @ text
.4byte \pointer3 @ text
.4byte \pointer4 @ event script
.elseif \type == TRAINER_BATTLE_PYRAMID
.4byte \pointer1 @ text
.4byte \pointer2 @ text
.elseif \type == TRAINER_BATTLE_SET_TRAINER_A
.4byte \pointer1 @ text
.4byte \pointer2 @ text
.elseif \type == TRAINER_BATTLE_SET_TRAINER_B
.4byte \pointer1 @ text
.4byte \pointer2 @ text
.elseif \type == TRAINER_BATTLE_HILL
.4byte \pointer1 @ text
.4byte \pointer2 @ text
.endif
.set trainerbattle_flags, 0
.ifgt \isDouble; .set trainerbattle_flags, trainerbattle_flags | (1 << 0); .endif
.ifgt \isRematch; .set trainerbattle_flags, trainerbattle_flags | (1 << 1); .endif
.ifgt \playMusicA; .set trainerbattle_flags, trainerbattle_flags | (1 << 2); .endif
.ifgt \playMusicB; .set trainerBattle_flags, trainerbattle_flags | (1 << 3); .endif
.byte trainerbattle_flags
.byte \localIdA @ objEventLocalIdA
.2byte \trainer_a @ battleOpponentA
.4byte \intro_text_a @ introTextA
.4byte \lose_text_a @ defeatTextA
.4byte \event_script_a @ retAddrA
.byte \localIdB @ objEventLocalIdB
.2byte \trainer_b @ battleOpponentB
.4byte \intro_text_b @ introTextB
.4byte \lose_text_b @ defeatTextB
.4byte \event_script_b @ retAddrB
.4byte \victory_text @ victoryText
.4byte \cannot_battle @ cannotBattle
.endm

NO_MUSIC = FALSE

@ Starts a single trainer battle. Takes a trainer, intro text, loss text, and an optional event script.
@ When used with an event script, you can also pass in an optional flag to disable music
.macro trainerbattle_single trainer:req, intro_text:req, lose_text:req, event_script=FALSE, music=TRUE
.if \event_script == FALSE
trainerbattle TRAINER_BATTLE_SINGLE, \trainer, 0, \intro_text, \lose_text
trainerbattle OBJ_ID_NONE, \trainer, \intro_text, \lose_text, NULL, OBJ_ID_NONE, TRAINER_NONE, NULL, NULL, NULL, NULL, NULL, FALSE, TRUE, FALSE, FALSE
.elseif \music == TRUE
trainerbattle TRAINER_BATTLE_CONTINUE_SCRIPT, \trainer, 0, \intro_text, \lose_text, \event_script
trainerbattle OBJ_ID_NONE, \trainer, \intro_text, \lose_text, \event_script, OBJ_ID_NONE, TRAINER_NONE, NULL, NULL, NULL, NULL, NULL, FALSE, TRUE, FALSE, FALSE
.else
trainerbattle TRAINER_BATTLE_CONTINUE_SCRIPT_NO_MUSIC, \trainer, 0, \intro_text, \lose_text, \event_script
trainerbattle OBJ_ID_NONE, \trainer, \intro_text, \lose_text, \event_script, OBJ_ID_NONE, TRAINER_NONE, NULL, NULL, NULL, NULL, NULL, FALSE, FALSE, FALSE, FALSE
.endif
.endm

@ Starts a double trainer battle. Takes a trainer, intro text, loss text, text for when you have too few pokemon
@ and an optional event script. When used with an event script you can pass in an optional flag to disable music
.macro trainerbattle_double trainer:req, intro_text:req, lose_text:req, not_enough_pkmn_text:req, event_script=FALSE, music=TRUE
.if \event_script == FALSE
trainerbattle TRAINER_BATTLE_DOUBLE, \trainer, 0, \intro_text, \lose_text, \not_enough_pkmn_text
trainerbattle OBJ_ID_NONE, \trainer, \intro_text, \lose_text, NULL, OBJ_ID_NONE, TRAINER_NONE, NULL, NULL, NULL, NULL, \not_enough_pkmn_text, TRUE, TRUE, FALSE, FALSE
.elseif \music == TRUE
trainerbattle TRAINER_BATTLE_CONTINUE_SCRIPT_DOUBLE, \trainer, 0, \intro_text, \lose_text, \not_enough_pkmn_text, \event_script
trainerbattle OBJ_ID_NONE, \trainer, \intro_text, \lose_text, \event_script, OBJ_ID_NONE, TRAINER_NONE, NULL, NULL, NULL, NULL, \not_enough_pkmn_text, TRUE, TRUE, FALSE, FALSE
.else
trainerbattle TRAINER_BATTLE_CONTINUE_SCRIPT_DOUBLE_NO_MUSIC, \trainer, 0, \intro_text, \lose_text, \not_enough_pkmn_text, \event_script
trainerbattle OBJ_ID_NONE, \trainer, \intro_text, \lose_text, \event_script, OBJ_ID_NONE, TRAINER_NONE, NULL, NULL, NULL, NULL, \not_enough_pkmn_text, TRUE, FALSE, FALSE, FALSE
.endif
.endm

@ Starts a rematch battle. Takes a trainer, intro text and loss text
.macro trainerbattle_rematch trainer:req, intro_text:req, lose_text:req
trainerbattle TRAINER_BATTLE_REMATCH, \trainer, 0, \intro_text, \lose_text
trainerbattle OBJ_ID_NONE, \trainer, \intro_text, \lose_text, NULL, OBJ_ID_NONE, TRAINER_NONE, NULL, NULL, NULL, NULL, NULL, FALSE, TRUE, FALSE, TRUE
.endm

@ Starts a rematch double battle. Takes a trainer, intro text, loss text, and text for when you have too few pokemon
.macro trainerbattle_rematch_double trainer:req, intro_text:req, lose_text:req, not_enough_pkmn_text:req
trainerbattle TRAINER_BATTLE_REMATCH_DOUBLE, \trainer, 0, \intro_text, \lose_text, \not_enough_pkmn_text
trainerbattle OBJ_ID_NONE, \trainer, \intro_text, \lose_text, NULL, OBJ_ID_NONE, TRAINER_NONE, NULL, NULL, NULL, NULL, \not_enough_pkmn_text, FALSE, TRUE, FALSE, TRUE
.endm

@ Starts a trainer battle, skipping intro text. Takes a trainer and loss text
.macro trainerbattle_no_intro trainer:req, lose_text:req
trainerbattle TRAINER_BATTLE_SINGLE_NO_INTRO_TEXT, \trainer, 0, \lose_text
.endm

@ Starts a double battle with the player against two trainers
@ Takes two trainers and defeat text for each
.macro trainerbattle_two_trainers trainer_a:req, lose_text_a:req, trainer_b:req, lose_text_b:req
.byte 0x5c
.byte TRAINER_BATTLE_TWO_TRAINERS_NO_INTRO
.2byte \trainer_a
.4byte \lose_text_a
.2byte \trainer_b
.4byte \lose_text_b
trainerbattle OBJ_ID_NONE, \trainer, NULL, \lose_text, NULL, OBJ_ID_NONE, TRAINER_NONE, NULL, NULL, NULL, NULL, NULL, FALSE, TRUE, FALSE, FALSE
.endm

@ Starts a trainer battle using the battle information stored in RAM (usually by the scripts in trainer_battle.inc, which
Expand Down Expand Up @@ -1892,6 +1850,19 @@
_dynmultichoice \left, \top, \ignoreBPress, \maxBeforeScroll, \shouldSort, \initialSelected, \callbacks, NULL
.endm

.macro setmultitrainerbattle trainer_a:req, lose_text_a:req, trainer_b:req, lose_text_b:req
.byte 0xe5
.2byte \trainer_a
.4byte \lose_text_a
.2byte \trainer_b
.4byte \lose_text_b
.endm

.macro facilitytrainerbattle type:req
.byte 0xe6
.byte \type
.endm

@ Supplementary

.macro goto_if_unset flag:req, dest:req
Expand Down
2 changes: 1 addition & 1 deletion data/battle_scripts_1.s
Original file line number Diff line number Diff line change
Expand Up @@ -5597,7 +5597,7 @@ BattleScript_LocalBattleLost::
jumpifbattletype BATTLE_TYPE_FRONTIER, BattleScript_LocalBattleLostPrintTrainersWinText
jumpifbattletype BATTLE_TYPE_TRAINER_HILL, BattleScript_LocalBattleLostPrintTrainersWinText
jumpifbattletype BATTLE_TYPE_EREADER_TRAINER, BattleScript_LocalBattleLostEnd
jumpifhalfword CMP_EQUAL, gTrainerBattleOpponent_A, TRAINER_SECRET_BASE, BattleScript_LocalBattleLostEnd
jumpifhalfword CMP_EQUAL, gTrainerBattleParameter + 2, TRAINER_SECRET_BASE, BattleScript_LocalBattleLostEnd @ gTrainerBattleParameter + 2 is gTrainerBattleParameter.params.battleOpponentA
BattleScript_LocalBattleLostPrintWhiteOut::
.if B_WHITEOUT_MONEY >= GEN_4
jumpifbattletype BATTLE_TYPE_TRAINER, BattleScript_LocalBattleLostEnd
Expand Down
2 changes: 1 addition & 1 deletion data/event_scripts.s
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ gSpecialVars::
.4byte gSpecialVar_MonBoxId
.4byte gSpecialVar_MonBoxPos
.4byte gSpecialVar_Unused_0x8014
.4byte gTrainerBattleOpponent_A
.4byte gTrainerBattleParameter + 2 // gTrainerBattleParameter.params.battleOpponentA

.include "data/specials.inc"

Expand Down
2 changes: 1 addition & 1 deletion data/maps/BattleFrontier_BattlePyramidFloor/scripts.inc
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ BattlePyramid_WarpToTop::

@ TRAINER_PHILLIP is used as a placeholder
BattlePyramid_TrainerBattle::
trainerbattle TRAINER_BATTLE_PYRAMID, TRAINER_PHILLIP, 0, BattleFacility_TrainerBattle_PlaceholderText, BattleFacility_TrainerBattle_PlaceholderText
facilitytrainerbattle TRAINER_BATTLE_PYRAMID
pyramid_showhint
waitmessage
waitbuttonpress
Expand Down
16 changes: 8 additions & 8 deletions data/maps/LavaridgeTown_Gym_1F/scripts.inc
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ LavaridgeTown_Gym_1F_EventScript_FlanneryRematch::
end

LavaridgeTown_Gym_1F_EventScript_Cole::
trainerbattle TRAINER_BATTLE_CONTINUE_SCRIPT, TRAINER_COLE, LOCALID_COLE, LavaridgeTown_Gym_1F_Text_ColeIntro, LavaridgeTown_Gym_1F_Text_ColeDefeat, LavaridgeTown_Gym_EventScript_CheckTrainerScript
trainerbattle LOCALID_COLE, TRAINER_COLE, LavaridgeTown_Gym_1F_Text_ColeIntro, LavaridgeTown_Gym_1F_Text_ColeDefeat, LavaridgeTown_Gym_EventScript_CheckTrainerScript, OBJ_ID_NONE, 0, 0, 0, 0, 0, 0, FALSE, TRUE, FALSE, FALSE
msgbox LavaridgeTown_Gym_1F_Text_ColePostBattle, MSGBOX_AUTOCLOSE
end

Expand All @@ -116,37 +116,37 @@ LavaridgeTown_Gym_EventScript_CheckTrainerScript::
end

LavaridgeTown_Gym_1F_EventScript_Axle::
trainerbattle TRAINER_BATTLE_CONTINUE_SCRIPT, TRAINER_AXLE, LOCALID_AXLE, LavaridgeTown_Gym_1F_Text_AxleIntro, LavaridgeTown_Gym_1F_Text_AxleDefeat, LavaridgeTown_Gym_EventScript_CheckTrainerScript
trainerbattle LOCALID_AXLE, TRAINER_AXLE, LavaridgeTown_Gym_1F_Text_AxleIntro, LavaridgeTown_Gym_1F_Text_AxleDefeat, LavaridgeTown_Gym_EventScript_CheckTrainerScript, OBJ_ID_NONE, 0, 0, 0, 0, 0, 0, FALSE, TRUE, FALSE, FALSE
msgbox LavaridgeTown_Gym_1F_Text_AxlePostBattle, MSGBOX_AUTOCLOSE
end

LavaridgeTown_Gym_B1F_EventScript_Keegan::
trainerbattle TRAINER_BATTLE_CONTINUE_SCRIPT, TRAINER_KEEGAN, LOCALID_KEEGAN, LavaridgeTown_Gym_B1F_Text_KeeganIntro, LavaridgeTown_Gym_B1F_Text_KeeganDefeat, LavaridgeTown_Gym_EventScript_CheckTrainerScript
trainerbattle LOCALID_KEEGAN, TRAINER_KEEGAN, LavaridgeTown_Gym_B1F_Text_KeeganIntro, LavaridgeTown_Gym_B1F_Text_KeeganDefeat, LavaridgeTown_Gym_EventScript_CheckTrainerScript, OBJ_ID_NONE, 0, 0, 0, 0, 0, 0, FALSE, TRUE, FALSE, FALSE
msgbox LavaridgeTown_Gym_B1F_Text_KeeganPostBattle, MSGBOX_AUTOCLOSE
end

LavaridgeTown_Gym_1F_EventScript_Danielle::
trainerbattle TRAINER_BATTLE_CONTINUE_SCRIPT, TRAINER_DANIELLE, LOCALID_DANIELLE, LavaridgeTown_Gym_1F_Text_DanielleIntro, LavaridgeTown_Gym_1F_Text_DanielleDefeat, LavaridgeTown_Gym_EventScript_CheckTrainerScript
trainerbattle LOCALID_DANIELLE, TRAINER_DANIELLE, LavaridgeTown_Gym_1F_Text_DanielleIntro, LavaridgeTown_Gym_1F_Text_DanielleDefeat, LavaridgeTown_Gym_EventScript_CheckTrainerScript, OBJ_ID_NONE, 0, 0, 0, 0, 0, 0, FALSE, TRUE, FALSE, FALSE
msgbox LavaridgeTown_Gym_1F_Text_DaniellePostBattle, MSGBOX_AUTOCLOSE
end

LavaridgeTown_Gym_1F_EventScript_Gerald::
trainerbattle TRAINER_BATTLE_CONTINUE_SCRIPT, TRAINER_GERALD, LOCALID_GERALD, LavaridgeTown_Gym_1F_Text_GeraldIntro, LavaridgeTown_Gym_1F_Text_GeraldDefeat, LavaridgeTown_Gym_EventScript_CheckTrainerScript
trainerbattle LOCALID_GERALD, TRAINER_GERALD, LavaridgeTown_Gym_1F_Text_GeraldIntro, LavaridgeTown_Gym_1F_Text_GeraldDefeat, LavaridgeTown_Gym_EventScript_CheckTrainerScript, OBJ_ID_NONE, 0, 0, 0, 0, 0, 0, FALSE, TRUE, FALSE, FALSE
msgbox LavaridgeTown_Gym_1F_Text_GeraldPostBattle, MSGBOX_AUTOCLOSE
end

LavaridgeTown_Gym_B1F_EventScript_Jace::
trainerbattle TRAINER_BATTLE_CONTINUE_SCRIPT, TRAINER_JACE, LOCALID_JACE, LavaridgeTown_Gym_B1F_Text_JaceIntro, LavaridgeTown_Gym_B1F_Text_JaceDefeat, LavaridgeTown_Gym_EventScript_CheckTrainerScript
trainerbattle LOCALID_JACE, TRAINER_JACE, LavaridgeTown_Gym_B1F_Text_JaceIntro, LavaridgeTown_Gym_B1F_Text_JaceDefeat, LavaridgeTown_Gym_EventScript_CheckTrainerScript, OBJ_ID_NONE, 0, 0, 0, 0, 0, 0, FALSE, TRUE, FALSE, FALSE
msgbox LavaridgeTown_Gym_B1F_Text_JacePostBattle, MSGBOX_AUTOCLOSE
end

LavaridgeTown_Gym_B1F_EventScript_Jeff::
trainerbattle TRAINER_BATTLE_CONTINUE_SCRIPT, TRAINER_JEFF, LOCALID_JEFF, LavaridgeTown_Gym_B1F_Text_JeffIntro, LavaridgeTown_Gym_B1F_Text_JeffDefeat, LavaridgeTown_Gym_EventScript_CheckTrainerScript
trainerbattle LOCALID_JEFF, TRAINER_JEFF, LavaridgeTown_Gym_B1F_Text_JeffIntro, LavaridgeTown_Gym_B1F_Text_JeffDefeat, LavaridgeTown_Gym_EventScript_CheckTrainerScript, OBJ_ID_NONE, 0, 0, 0, 0, 0, 0, FALSE, TRUE, FALSE, FALSE
msgbox LavaridgeTown_Gym_B1F_Text_JeffPostBattle, MSGBOX_AUTOCLOSE
end

LavaridgeTown_Gym_B1F_EventScript_Eli::
trainerbattle TRAINER_BATTLE_CONTINUE_SCRIPT, TRAINER_ELI, LOCALID_ELI, LavaridgeTown_Gym_B1F_Text_EliIntro, LavaridgeTown_Gym_B1F_Text_EliDefeat, LavaridgeTown_Gym_EventScript_CheckTrainerScript
trainerbattle LOCALID_ELI, TRAINER_ELI, LavaridgeTown_Gym_B1F_Text_EliIntro, LavaridgeTown_Gym_B1F_Text_EliDefeat, LavaridgeTown_Gym_EventScript_CheckTrainerScript, OBJ_ID_NONE, 0, 0, 0, 0, 0, 0, FALSE, TRUE, FALSE, FALSE
msgbox LavaridgeTown_Gym_B1F_Text_EliPostBattle, MSGBOX_AUTOCLOSE
end

Expand Down
2 changes: 2 additions & 0 deletions data/script_cmd_table.inc
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,8 @@ gScriptCmdTable::
.4byte ScrCmd_bufferitemnameplural @ 0xe2
.4byte ScrCmd_dynmultichoice @ 0xe3
.4byte ScrCmd_dynmultipush @ 0xe4
.4byte ScrCmd_setmultitrainerbattle @ 0xe5
.4byte ScrCmd_facilitytrainerbattle @ 0xe6

gScriptCmdTableEnd::
.4byte ScrCmd_nop
70 changes: 63 additions & 7 deletions data/scripts/trainer_battle.inc
Original file line number Diff line number Diff line change
Expand Up @@ -117,13 +117,6 @@ EventScript_ShowTrainerIntroMsg::

EventScript_DoTrainerBattle::
dotrainerbattle
@ Below battle mode check only needed in FRLG
specialvar VAR_RESULT, GetTrainerBattleMode
goto_if_eq VAR_RESULT, TRAINER_BATTLE_SINGLE, EventScript_EndTrainerBattle
goto_if_eq VAR_RESULT, TRAINER_BATTLE_CONTINUE_SCRIPT, EventScript_EndTrainerBattle
goto_if_eq VAR_RESULT, TRAINER_BATTLE_CONTINUE_SCRIPT_NO_MUSIC, EventScript_EndTrainerBattle
goto_if_eq VAR_RESULT, TRAINER_BATTLE_CONTINUE_SCRIPT_DOUBLE, EventScript_EndTrainerBattle
goto_if_eq VAR_RESULT, TRAINER_BATTLE_CONTINUE_SCRIPT_DOUBLE_NO_MUSIC, EventScript_EndTrainerBattle
EventScript_EndTrainerBattle::
gotobeatenscript
releaseall
Expand All @@ -135,3 +128,66 @@ Std_MsgboxAutoclose::
waitbuttonpress
release
return

EventSnippet_Lock::
lock
faceplayer
setflag FLAG_SAFE_FOLLOWER_MOVEMENT
return

EventSnippet_StartTrainerApproach::
selectapproachingtrainer
lockfortrainer
return

EventSnippet_TrainerApproach::
special DoTrainerApproach
waitstate
return

EventSnippet_RevealTrainer::
applymovement VAR_LAST_TALKED, Movement_RevealTrainer
waitmovement 0
clearflag FLAG_SAFE_FOLLOWER_MOVEMENT
return

EventScript_IsTrainerFlagSet::
specialvar VAR_RESULT, GetTrainerFlag
goto_if_ne VAR_RESULT, FALSE, EventScript_NoNormalTrainerBattle
return

EventSnippet_PlayTrainerEncounterMusic::
special PlayTrainerEncounterMusic
return

EventSnippet_SetTrainerFacingDirection::
special SetTrainerFacingDirection
return

EventSnippet_ShowTrainerIntroMsg::
special ShowTrainerIntroSpeech
waitmessage
waitbuttonpress
return

EventSnippet_PrepareSecondTrainerApproach::
special PrepareSecondApproachingTrainer
return

EventSnippet_GotoPostBattleScript::
gotopostbattlescript
return

EventSnippet_DoTrainerBattle::
dotrainerbattle
return

EventSnippet_DoRematchTrainerBattle::
special BattleSetup_StartRematchBattle
waitstate
return

EventSnippet_EndTrainerBattle::
gotobeatenscript
releaseall
end
2 changes: 1 addition & 1 deletion data/scripts/trainer_hill.inc
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ TrainerHill_1F_Movement_SetInvisible::

@ TRAINER_PHILLIP is an actual Trainer on the SS Tidal, but is used as a placeholder here
TrainerHill_EventScript_TrainerBattle::
trainerbattle TRAINER_BATTLE_HILL, TRAINER_PHILLIP, 0, BattleFacility_TrainerBattle_PlaceholderText, BattleFacility_TrainerBattle_PlaceholderText
facilitytrainerbattle TRAINER_BATTLE_HILL
trainerhill_postbattletext
waitmessage
waitbuttonpress
Expand Down
Loading
Loading