	const_def 2 ; object constants
        const DAWN_TOWN_GENGAR
        const DAWN_TOWN_CAVE_ITEMBALL3

DawnTownCave0F_MapScripts:
	db 3 ; scene scripts
	scene_script .DummyScene ; SCENE_DAWN_TOWN_CAVE_0F_DEFAULT
	scene_script .ConfusePlayer ; SCENE_DAWN_TOWN_CAVE_0F_GENGAR_CONFUSE
	scene_script .DummyScene ; SCENE_DAWN_TOWN_CAVE_0F_GENGAR_BATTLE

        db 1 ; callbacks
	callback MAPCALLBACK_OBJECTS, .HideGengar

.DummyScene:
	end

; Hide Gengar by default
.HideGengar:
	disappear DAWN_TOWN_GENGAR
	end

.ConfusePlayer:
	moveobject DAWN_TOWN_GENGAR, 9, 11
	appear DAWN_TOWN_GENGAR
	applymovement DAWN_TOWN_GENGAR, .SurprisePlayer
	cry GENGAR
	pause 15
	reloadmappart
	playsound SFX_KINESIS
	turnobject PLAYER, UP
	waitsfx
	pause 20
	special FadeOutPalettes
	warp DAWN_TOWN_GRAVEYARD, 28, 10
	end

.SurprisePlayer:
	fast_jump_step DOWN
	fast_jump_step LEFT
	fast_jump_step DOWN
	step_end

DawnTownCaveBattleGengar:
	moveobject DAWN_TOWN_GENGAR, 9, 6
	appear DAWN_TOWN_GENGAR
	applymovement DAWN_TOWN_GENGAR, .GengarMove
	opentext
	writetext .GengarText
	cry GENGAR
	pause 15
	closetext
	loadwildmon GENGAR, 35
	;loadvar VAR_BATTLETYPE, BATTLETYPE_SHINY
	loadvar wBattleType, BATTLETYPE_SHINY
	startbattle
	ifequal LOSE, .NotBeaten
	disappear DAWN_TOWN_GENGAR
	setscene SCENE_DAWN_TOWN_CAVE_0F_DEFAULT
	setmapscene DAWN_TOWN_CAVE_1F, SCENE_FINISHED
	setmapscene DAWN_TOWN_GRAVEYARD, SCENE_FINISHED
	setevent EVENT_BEAT_GENGAR

.NotBeaten:
	reloadmapafterbattle
	end

.GengarMove:
	fast_jump_step LEFT
	fast_jump_step LEFT
	fast_jump_step UP
	fast_jump_step LEFT
	turn_step DOWN
	turn_head DOWN
	step_end

.GengarText:
	text "GAAAAAAAR!!"
	done

DawnTownCave0FItemball3:
	itemball POKE_BALL, 10
	end

DawnTownCave0F_MapEvents:
	db 0, 0 ; filler

	db 3 ; warp events
	warp_event  3, 17, DAWN_TOWN_CAVE_1F, 2
	warp_event  9,  5, DAWN_TOWN_CAVE_ROOM, 1
	warp_event  7, 16, DAWN_TOWN_GRAVEYARD, 1

	db 1 ; coord events
	coord_event 3, 5, SCENE_DAWN_TOWN_CAVE_0F_GENGAR_BATTLE, DawnTownCaveBattleGengar

	db 0 ; bg events
	db 2 ; object events
	object_event 9, 7, SPRITE_GENGAR2, SPRITEMOVEDATA_STANDING_DOWN, 0, 0, -1, -1, PAL_NPC_RED, OBJECTTYPE_SCRIPT, 0, 0, 0
	object_event 11, 10, SPRITE_POKE_BALL, SPRITEMOVEDATA_STILL, 0, 0, -1, -1, 0, OBJECTTYPE_ITEMBALL, 0, DawnTownCave0FItemball3, EVENT_DAWNTOWN_CAVE_POKE_BALL
