HauntedForest_MapScriptHeader;trigger count
	db 0
 ;callback count
 	db 1
	dbw MAPCALLBACK_NEWMAP, .reset_var

.reset_var
	seteventvar EVAR_TEMP, 0
	return

HauntedForest_Item:
	db STARDUST, 1

HauntedForest_Trainer_1:
	trainer EVENT_HAUNTED_FOREST_TRAINER_1, SAGE, 2, .before_battle_text, .battle_won_text, $0000, .Script

.Script
	end_if_just_battled
	jumptext .after_battle_text

.before_battle_text
	db TX_COMPRESSED, $ac, $90, $64, $40, $c8, $c9, $ac, $e6, $93
	db $2f, $18, $30, $fb, $30, $58, $cc, $99, $83
	db $40, $07, $c2, $b3, $96, $18, $ac, $e6, $07, $ab, $3c
	db $bd, $69, $d2, $4d, $95, $0f, $b9, $8a, $cf, $51, $7e

	db $01, $5c, $a8, $7d, $cc, $56, $7a, $8b, $8f, $e8
	db $27, $aa, $0b, $44, $cc, $04, $16, $97, $15, $87, $20

	db $be, $01, $5b, $57, $34, $90, $c1, $87, $d9, $82, $c6, $64
	db $cb, $c0, $62, $4e, $54, $3e, $f6, $54, $16, $89
	db $95, $40, $82, $d2, $e0, $31, $ac, $14, $7c, $64, $cf
	db $a9, $a0

.battle_won_text
	db TX_COMPRESSED, $ad, $f5, $63, $b1, $84, $90, $68, $9d, $1a, $91
	db $bd, $d0, $83, $1f, $e0, $df, $11, $b6, $33, $25
	db $80, $56, $1b, $4c, $0e, $13, $27, $dd, $04
	db $87, $b4, $99, $8b, $18, $36, $f5, $1e
	db $a6, $80

.after_battle_text
	db TX_COMPRESSED, $ae, $53, $8d, $73, $30, $1f, $7a, $89, $95, $84
	db $43, $ca, $c1, $4c, $ac, $22
	db $3d, $4d

HauntedForest_Trainer_2:
	trainer EVENT_HAUNTED_FOREST_TRAINER_2, SAGE, 1, .before_battle_text, .battle_won_text, $0000, .Script

.Script
	end_if_just_battled
	jumptext .after_battle_text

.before_battle_text
	db TX_COMPRESSED, $53, $0a, $e5, $a4, $28, $39, $52, $43, $3a, $30, $63
	db $7a, $a1, $a0, $fa, $0a, $0c, $93, $a3, $c0

	db $fe, $00, $c1, $8c, $93, $27, $b6, $98, $3b, $41, $f7
	db $07, $86, $82, $53, $25, $86, $2b, $39, $81, $ea, $cf, $3e
	db $a6, $80

.battle_won_text
	db TX_COMPRESSED, $62, $70, $68, $9a, $af, $a7, $2a, $48
	db $5e, $b4, $8c, $8a, $48, $89, $38, $34, $4d, $57, $d3
	db $f5, $34

.after_battle_text
	db TX_COMPRESSED, $63, $b6, $b3, $cc, $c8, $4d, $10, $81
	db $b7, $99, $3d, $41, $c5, $60, $a2, $76, $d6, $79
	db $fa, $a5, $6d, $5c, $09, $3a, $0a, $2b, $05, $3a, $10, $63

	db $f0, $02, $92, $34, $41, $a2, $5a, $4e, $5a, $da
	db $37, $8e, $cd, $64, $de, $c5, $b5, $d3
	db $f5, $34

HauntedForest_Trainer_3:
	trainer EVENT_HAUNTED_FOREST_TRAINER_3, MEDIUM, 1, .before_battle_text, .battle_won_text, $0000, .Script

.Script
	end_if_just_battled
	jumptext .after_battle_text

.before_battle_text
	db TX_COMPRESSED, $12, $3e, $8c, $c1, $8e, $10, $36, $91, $93, $9f
	db $bc, $40, $c7, $f6, $ec, $d7, $2a, $49, $ac
	db $c0, $02, $0b, $51, $67, $b9, $83, $bf, $c0
	db $ad, $ea, $92, $18, $8d, $1e, $60, $ef, $f0, $81
	db $00, $fe, $dd, $9a, $e0, $f0, $8e, $a2, $74, $18
	db $de, $46, $8f, $30, $77, $00, $c6, $89, $d3, $42
	db $00, $0e, $e6, $f2, $b3, $34, $4a, $87, $69
	db $78, $10, $5a, $5c, $0d, $44, $8b, $3d, $40
	db $48, $03, $49, $98, $08, $2d, $2e, $06, $a2
	db $3c, $c8, $5f, $7c, $24, $88, $32, $20
	db $fd, $4d

.battle_won_text
	db TX_COMPRESSED, $63, $a0, $c7, $19, $0b, $e2, $35, $08, $18
	db $48, $f6, $01, $5c, $de, $f6, $2b, $31, $93, $94
	db $7c, $02, $c6, $ca, $66, $93, $30, $40, $42
	db $b7, $b7, $a3, $52, $3f, $41, $76, $b2, $98, $9d
	db $42, $ab, $49, $8d, $71, $0d, $61, $81, $ac, $64, $e7

	db $c0, $14, $05, $f3, $88, $6b, $0c, $0d, $72, $c2
	db $17, $9f, $69, $94, $fe, $06, $d2, $6b, $44, $c3
	db $56, $aa, $c2, $19, $d1, $dd, $f4
	db $fd, $4d

.after_battle_text
	db TX_COMPRESSED, $12, $3b, $b3, $5c, $b4, $e9, $26
	db $bd, $69, $0b, $48, $d2, $66, $24, $3d, $e8, $6a
	db $01, $50, $57, $94, $7e, $0d, $10, $24, $39, $50, $57
	db $97, $ad, $3b, $71, $5a, $c6, $4e, $51, $04, $1e, $b2, $7e
	db $a6, $80

HauntedForestRedGravestone:
	writehalfword HauntedForestRedGravestoneText
	switch 0
HauntedForestGreyGravestone:
	writehalfword HauntedForestGreyGravestoneText
	switch 1
HauntedForestBlueGravestone:
	writehalfword HauntedForestBlueGravestoneText
	switch 2
HauntedForestYellowGravestone:
	writehalfword HauntedForestYellowGravestoneText
	switch 3
HauntedForestBrownGravestone:
	writehalfword HauntedForestBrownGravestoneText
	switch 4
HauntedForestTealGravestone:
	writehalfword HauntedForestTealGravestoneText
	writebyte 5
	sendif

	pushvar
	opentext
	writetext -1
	checkevent EVENT_HAUNTED_MANSION_KEY
	sif false, then
		writetext .touch_it_text
		yesorno
		sif true, then
			pullvar
			compareeventvar EVAR_TEMP
			sif true, then
				waitsfx
				playsound SFX_WRONG
				writetext .wrong_text
				waitsfx
				seteventvar EVAR_TEMP, 0
			selse
				pullvar
				addvar 1
				writeeventvar EVAR_TEMP
				sif =, 6, then
					writetext .got_key_text
					verbosegiveitem MANSION_KEY, 1
					waitbutton
					setevent EVENT_HAUNTED_MANSION_KEY
				selse
					waitsfx
					playsound SFX_GLASS_TING
					writetext .right_text
					waitsfx
				sendif
			sendif
		sendif
	sendif
	popvar
	closetext
	end

.touch_it_text
	db TX_COMPRESSED, $28, $2d, $32, $98, $3b, $a5
	db $a6, $80

.right_text
	db TX_COMPRESSED, $29, $3b, $71, $01, $68, $99, $83
	db $43, $cb, $3d, $42, $1a, $58, $c9, $cf
	db $1a, $78, $80

.wrong_text
	db TX_COMPRESSED, $29, $3b, $73, $21, $34, $12, $99, $10, $16, $89
	db $97, $96, $3e, $53, $7e
	db $a7, $88

.got_key_text
	db TX_COMPRESSED, $ae, $27, $49, $98, $b3, $d6, $52, $68, $81, $6a
	db $de, $0e, $12, $d2, $73, $95, $85, $a2, $66, $69
	db $32, $a9, $3a, $4c, $a2, $02, $0b, $53, $62, $91, $82
	db $e3, $4f, $10

HauntedForestRedGravestoneText:
	db TX_COMPRESSED, $75, $78, $a6, $c5, $9e
	db $5e, $e5, $7a, $0c, $68, $b0, $90
	db $fd, $4f, $10

HauntedForestGreyGravestoneText:
	db TX_COMPRESSED, $75, $78, $a6, $ce, $56, $60
	db $9e, $e5, $7a, $0c, $68, $b0, $90
	db $fd, $4f, $10

HauntedForestBlueGravestoneText:
	db TX_COMPRESSED, $75, $78, $a6, $c5, $7d, $68
	db $de, $e5, $7a, $0c, $68, $b0, $90
	db $fd, $4f, $10

HauntedForestYellowGravestoneText:
	db TX_COMPRESSED, $75, $78, $a6, $c0, $47, $de, $86
	db $a7, $b9, $5e, $83, $1a, $2c, $24, $3f
	db $53, $c4

HauntedForestBrownGravestoneText:
	db TX_COMPRESSED, $75, $78, $a6, $c5, $6b, $0d, $44
	db $7b, $95, $e8, $31, $a2, $c2, $43
	db $f5, $3c, $40

HauntedForestTealGravestoneText:
	db TX_COMPRESSED, $75, $78, $a6, $cb, $3d
	db $eb, $dc, $af, $41, $8d, $16, $12, $1f
	db $a9, $e2

HauntedForest_MapEventHeader ;filler
	db 0, 0

;warps
	db 3
	warp_def $26, $d, 1, HAUNTED_FOREST_GATE
	warp_def $27, $d, 2, HAUNTED_FOREST_GATE
	warp_def $5, $6, 1, HAUNTED_MANSION

	;xy triggers
	db 0

	;signposts
	db 6
	signpost $14, $06, SIGNPOST_READ, HauntedForestRedGravestone
	signpost $02, $21, SIGNPOST_READ, HauntedForestTealGravestone
	signpost $06, $26, SIGNPOST_READ, HauntedForestGreyGravestone
	signpost $06, $09, SIGNPOST_READ, HauntedForestYellowGravestone
	signpost $16, $23, SIGNPOST_READ, HauntedForestBrownGravestone
	signpost $18, $25, SIGNPOST_READ, HauntedForestBlueGravestone

	;people-events
	db 5
	person_event SPRITE_POKE_BALL, 38, 29, SPRITEMOVEDATA_ITEM_TREE, 0, 0, -1, -1, PAL_OW_YELLOW, PERSONTYPE_TMHMBALL, TM_NIGHT_SHADE, 0, EVENT_GOT_TM05
	person_event SPRITE_POKE_BALL, 19, 1, SPRITEMOVEDATA_ITEM_TREE, 0, 0, -1, -1, PAL_OW_RED, PERSONTYPE_ITEMBALL, 0, HauntedForest_Item, EVENT_HAUNTED_FOREST_ITEM_1
	person_event SPRITE_SAGE, 11, 14, SPRITEMOVEDATA_STANDING_DOWN, 0, 0, -1, -1, PAL_OW_BLUE, PERSONTYPE_TRAINER, 3, HauntedForest_Trainer_1, -1
	person_event SPRITE_SAGE, 29, 15, SPRITEMOVEDATA_STANDING_DOWN, 0, 0, -1, -1, PAL_OW_BLUE, PERSONTYPE_TRAINER, 3, HauntedForest_Trainer_2, -1
	person_event SPRITE_GRANNY, 10, 36, SPRITEMOVEDATA_STANDING_RIGHT, 0, 0, -1, -1, PAL_OW_BROWN, PERSONTYPE_TRAINER, 3, HauntedForest_Trainer_3, -1

