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
	ctxt "OK, please enter"
	line "the magnet train."
	sdone

.need_pass_text
	ctxt "You need a Magnet"
	line "Pass to go there."
	done

.arrived_in_naljo_text
	ctxt "Welcome to"
	line "Torenia City,"
	cont "Naljo."
	done

.arrived_in_rijon_text
	ctxt "Welcome to Botan"
	line "City, Rijon."
	done

.arrived_in_johto_text
	ctxt "Welcome to"
	line "Goldenrod City,"
	cont "Johto."
	done

.arrived_in_kanto_text
	ctxt "Welcome to"
	line "Saffron City,"
	cont "Kanto."
	done
