TrainStationScript::
	sif false, then
		closetext
		end
	sendif
	addvar -1
	sif >, 3, then
		closetext
		end
	sendif
	sif >, 1, then
		pushvar
		checkitem MAGNET_PASS
		sif false, then
			popvar
			jumptext .need_pass_text
		sendif
		popvar
	sendif
	writetext .enter_train_text
	closetext
	applymovement 2, .employee_enter_train
	applymovement 0, .player_enter_train
	playmusic MUSIC_MAGNET_TRAIN
	scall .location_based_script
	applymovement 2, .employee_exit_train
	applymovement 0, .player_exit_train
	applymovement 2, .employee_walk_back
	jumptext -1

.location_based_script
	anonjumptable
	dw .naljo
	dw .rijon
	dw .johto
	dw .kanto

.naljo
	writebyte 1
	special Special_MagnetTrain
	wait 14
	warp TORENIA_MAGNET_TRAIN, 11, 6
	writehalfword .arrived_in_naljo_text
	end

.rijon
	checkcode VAR_MAPGROUP
	sif =, GROUP_TORENIA_MAGNET_TRAIN, then
		writebyte 0
	selse
		writebyte 1
	sendif
	special Special_MagnetTrain
	wait 14
	warp BOTAN_MAGNET_TRAIN, 11, 6
	writehalfword .arrived_in_rijon_text
	end

.johto
	checkcode VAR_MAPGROUP
	sif =, GROUP_SAFFRON_MAGNET_TRAIN, then
		writebyte 1
	selse
		writebyte 0
	sendif
	special Special_MagnetTrain
	wait 14
	warp GOLDENROD_MAGNET_TRAIN, 11, 6
	writehalfword .arrived_in_johto_text
	end

.kanto
	writebyte 0
	special Special_MagnetTrain
	wait 14
	warp SAFFRON_MAGNET_TRAIN, 11, 6
	writehalfword .arrived_in_kanto_text
	end

.employee_enter_train
	step_up
	step_up
	step_left
	step_end

.player_enter_train
	step_up
	step_up
	step_up
	step_up
	step_left
	step_left
	step_left
	step_up
	step_end

.employee_exit_train
	step_down
	step_left
	step_end

.player_exit_train
	step_left
	step_left
	step_down
	step_down
	step_down
	step_down
	step_down
	turn_head_up
	step_end

.employee_walk_back
	step_right
	step_up
	turn_head_down
	step_end

.enter_train_text
	db TX_COMPRESSED, $76, $26, $3f, $04, $74, $f5, $07, $0c, $96, $6b
	db $7a, $d2, $71, $fd, $e4, $87, $72, $d7, $a3, $27
	db $a9, $e2

.need_pass_text
	db TX_COMPRESSED, $72, $85, $a8, $43, $3c, $cd, $82, $bb, $c9, $0e
	db $de, $e1, $d4, $22, $58, $67, $21, $96, $93, $59
	db $fa, $9a

.arrived_in_naljo_text
	db TX_COMPRESSED, $6e, $7d, $64, $2f, $9c, $b0
	db $bc, $50, $56, $64, $1e, $c6, $d1, $d8, $2f
	db $aa, $07, $ef, $69, $c0
	db $fa, $9a

.arrived_in_rijon_text
	db TX_COMPRESSED, $6e, $7d, $64, $2f, $9c, $b0, $c1, $20, $de
	db $91, $e6, $d1, $d8, $2f, $c7, $20, $e9, $c0, $93
	db $d4, $d0

.arrived_in_johto_text
	db TX_COMPRESSED, $6e, $7d, $64, $2f, $9c, $b0
	db $bc, $c2, $0f, $72, $64, $58, $73, $1b, $47, $60
	db $be, $a8, $4c, $85, $36, $1f
	db $53, $40

.arrived_in_kanto_text
	db TX_COMPRESSED, $6e, $7d, $64, $2f, $9c, $b0
	db $bc, $a3, $70, $c1, $61, $24, $6d, $1d, $82
	db $fa, $a1, $31, $a4, $b0
	db $fa, $9a

