MoundB2F_MapScriptHeader;trigger count
MoundB2FDark_MapScriptHeader::
	db 0
 ;callback count
	db 1
	dbw MAPCALLBACK_NEWMAP, MoundCave_ResetFlash

MoundCave_ResetFlash:
	callasm .TryResetFlash
	return

.TryResetFlash
	ld a, [wPrevMapGroup]
	cp GROUP_MOUND_F1
	jr nz, .set_flash
	ld a, [wPrevMapNumber]
	cp MAP_MOUND_B1F
	jr z, .reset_flash
	cp MAP_MOUND_B2F
	jr z, .b2f_check
	cp MAP_MOUND_B3F
	jr z, .b3f_check
.set_flash
	SetEngine ENGINE_FLASH
	ret

.b2f_check
	ld a, [wPrevWarp]
	cp 59
	jr z, .set_flash
	jr .reset_flash

.b3f_check
	ld a, [wPrevWarp]
	cp 67
	jr z, .set_flash
	cp 69
	jr z, .set_flash
.reset_flash
	ResetEngine ENGINE_FLASH
	ret

MoundB2F_Item_Dynamite:
	db DYNAMITE, 1

MoundB2F_Item_EscapeRope:
	db ESCAPE_ROPE, 1

MoundLightSwitch:
	checkflag ENGINE_FLASH
	sif true
		jumptext .already_on_text
	opentext
	writetext .description_text
	findpokemontype ELECTRIC
	sif false, then
		closetext
		end
	sendif
	writetext .use_mon_text
	addvar -1
	copyvartobyte wCurPartyMon
	yesorno
	closetext
	sif false
		end
	fieldmovepokepic
	playwaitsfx SFX_FLASH
	callasm BlindingFlash
	end

.already_on_text
	db TX_COMPRESSED, $29, $27, $3a, $3e, $53, $68, $83
	db $23, $d6, $93, $8b, $08, $5f, $9a, $b3
	db $55, $bd, $59, $ee, $41, $40, $93
	db $d4, $d0

.description_text
	db TX_COMPRESSED, $ac, $90, $5d, $d3, $66, $d6, $36
	db $5e, $07, $2b, $e1, $24, $0a, $e3, $e1, $06
	db $30, $0c, $85, $ae, $e6, $22, $f5, $77, $2d, $23
	db $43, $dd, $1f, $29, $b9, $c9, $90, $d7, $b6, $15
	db $fa, $9e, $20

.use_mon_text
	start_asm
	push bc
	ld hl, wPartyMonNicknames - PKMN_NAME_LENGTH
	ld bc, PKMN_NAME_LENGTH
	ld a, [hScriptVar]
	rst AddNTimes
	ld d, h
	ld e, l
	call CopyName1
	pop bc
	ld hl, .text
	ret
.text
	db TX_COMPRESSED, $73, $a0, $e0, $39, $32
	db $c2, $f2, $2f, $57, $72, $d2, $73, $a3, $e5
	db $36, $ab, $93, $21, $af, $6c, $2b, $a5
	db $a6, $80

MoundB2F_PaletteBlack:
	trainer EVENT_MOUND_B2F_TRAINER_1, PATROLLER, 1, .before_battle_text, .battle_won_text, $0000, .Script

.Script
	end_if_just_battled
	jumptextfaceplayer .after_battle_text

.before_battle_text
	db TX_COMPRESSED, $75, $29, $c6, $91, $73, $21, $95, $27
	db $6d, $eb, $49, $c5, $61, $42, $22, $34, $12

	db $3c, $01, $d6, $11, $d4, $e4, $ee, $08, $d1, $e7
	db $ef, $3a, $95, $04, $94, $c8, $c8, $5f, $11, $dd, $19
	db $3d, $4d

.battle_won_text
	text "<...>"
	done

.after_battle_text
	db TX_COMPRESSED, $75, $32, $12, $53, $22, $91, $03, $54, $a9, $3b
	db $6f, $54, $65, $c7, $32, $11, $93, $9f, $cd, $ef
	db $40, $3a, $8c, $ea, $ce, $6a, $b0, $b5, $70, $68
	db $7a, $d2, $71, $f0, $90, $c1
	db $7a, $9a

MoundB2F_PaletteYellow:
	trainer EVENT_MOUND_B2F_TRAINER_2, PATROLLER, 3, .before_battle_text, .battle_won_text, $0000, .Script

.Script
	end_if_just_battled
	jumptextfaceplayer .after_battle_text

.before_battle_text
	db TX_COMPRESSED, $74, $59, $36, $21, $a1, $06, $b8, $93, $58, $78
	db $d3, $40

.battle_won_text
	db TX_COMPRESSED, $07, $86, $61, $a3, $5f
	db $1a, $68

.after_battle_text
	db TX_COMPRESSED, $15, $05, $15, $84, $16, $0b, $19, $93, $3f
	db $7b, $87, $7a, $77, $67, $18, $4b, $33, $27
	db $c0, $54, $12, $53, $22, $b3, $89, $d1, $02, $01
	db $3d, $aa, $c2, $d5, $cb, $48, $d1
	db $c6, $9a

MoundB2F_MapEventHeader
MoundB2FDark_MapEventHeader
db 0, 0

.Warps: db 66
	warp_def 3, 37, 2, MOUND_B1F
	warp_def 3, 15, 2, MOUND_B3F
	warp_def 43, 7, 3, MOUND_B3F
	warp_def 2, 13, 4, MOUND_B3F
	warp_def 3, 13, 5, MOUND_B3F
	warp_def 4, 14, 6, MOUND_B3F
	warp_def 4, 15, 7, MOUND_B3F
	warp_def 4, 16, 8, MOUND_B3F
	warp_def 4, 17, 9, MOUND_B3F
	warp_def 5, 17, 10, MOUND_B3F
	warp_def 5, 16, 11, MOUND_B3F
	warp_def 5, 15, 12, MOUND_B3F
	warp_def 5, 14, 13, MOUND_B3F
	warp_def 6, 13, 14, MOUND_B3F
	warp_def 7, 13, 15, MOUND_B3F
	warp_def 14, 12, 16, MOUND_B3F
	warp_def 14, 13, 17, MOUND_B3F
	warp_def 14, 14, 18, MOUND_B3F
	warp_def 14, 15, 19, MOUND_B3F
	warp_def 14, 16, 20, MOUND_B3F
	warp_def 14, 17, 21, MOUND_B3F
	warp_def 15, 19, 22, MOUND_B3F
	warp_def 16, 19, 23, MOUND_B3F
	warp_def 17, 19, 24, MOUND_B3F
	warp_def 18, 19, 25, MOUND_B3F
	warp_def 19, 19, 26, MOUND_B3F
	warp_def 20, 19, 27, MOUND_B3F
	warp_def 21, 17, 28, MOUND_B3F
	warp_def 21, 16, 29, MOUND_B3F
	warp_def 21, 15, 30, MOUND_B3F
	warp_def 21, 14, 31, MOUND_B3F
	warp_def 21, 13, 32, MOUND_B3F
	warp_def 21, 12, 33, MOUND_B3F
	warp_def 20, 10, 34, MOUND_B3F
	warp_def 19, 10, 35, MOUND_B3F
	warp_def 18, 10, 36, MOUND_B3F
	warp_def 17, 10, 37, MOUND_B3F
	warp_def 16, 10, 38, MOUND_B3F
	warp_def 15, 10, 39, MOUND_B3F
	warp_def 28, 18, 40, MOUND_B3F
	warp_def 29, 18, 41, MOUND_B3F
	warp_def 14, 10, 42, MOUND_B3F
	warp_def 14, 19, 43, MOUND_B3F
	warp_def 21, 10, 44, MOUND_B3F
	warp_def 21, 19, 45, MOUND_B3F
	warp_def 36, 5, 46, MOUND_B3F
	warp_def 36, 4, 47, MOUND_B3F
	warp_def 37, 4, 48, MOUND_B3F
	warp_def 38, 4, 49, MOUND_B3F
	warp_def 39, 4, 50, MOUND_B3F
	warp_def 40, 4, 51, MOUND_B3F
	warp_def 41, 4, 52, MOUND_B3F
	warp_def 41, 5, 53, MOUND_B3F
	warp_def 41, 6, 54, MOUND_B3F
	warp_def 41, 7, 55, MOUND_B3F
	warp_def 40, 8, 56, MOUND_B3F
	warp_def 40, 8, 57, MOUND_B3F
	warp_def 4, 13, 1, MOUND_B3F
	warp_def 5, 13, 59, MOUND_B3F
	warp_def 14, 11, 60, MOUND_B3F
	warp_def 14, 18, 61, MOUND_B3F
	warp_def 21, 11, 62, MOUND_B3F
	warp_def 21, 18, 63, MOUND_B3F
	warp_def 32, 19, 64, MOUND_B3F
	warp_def 40, 8, 65, MOUND_B3F
	warp_def 41, 27, 66, MOUND_B3F

.CoordEvents: db 0

.BGEvents: db 5
	signpost 11, 11, SIGNPOST_READ, MoundLightSwitch
	signpost 1, 19, SIGNPOST_READ, MoundLightSwitch
	signpost 1, 33, SIGNPOST_READ, MoundLightSwitch
	signpost 37, 27, SIGNPOST_READ, MoundLightSwitch
	signpost 41, 11, SIGNPOST_READ, MoundLightSwitch

.ObjectEvents: db 6
	person_event SPRITE_POKE_BALL, 39, 26, SPRITEMOVEDATA_ITEM_TREE, 0, 0, -1, -1, PAL_OW_PURPLE, PERSONTYPE_ITEMBALL, 0, MoundB2F_Item_Dynamite, EVENT_MOUND_B2F_ITEM_1
	person_event SPRITE_POKE_BALL, 4, 33, SPRITEMOVEDATA_ITEM_TREE, 0, 0, -1, -1, PAL_OW_RED, PERSONTYPE_ITEMBALL, 0, MoundB2F_Item_EscapeRope, EVENT_MOUND_B2F_ITEM_2
	person_event SPRITE_PALETTE_PATROLLER, 23, 26, SPRITEMOVEDATA_STANDING_UP, 0, 0, -1, -1, PAL_OW_SILVER, PERSONTYPE_TRAINER, 2, MoundB2F_PaletteBlack, EVENT_MOUND_B2F_TRAINER_1
	person_event SPRITE_POKE_BALL, 21, 32, SPRITEMOVEDATA_ITEM_TREE, 0, 0, -1, -1, PAL_OW_PURPLE, PERSONTYPE_ITEMBALL, 0, MoundB2F_Item_Dynamite, EVENT_MOUND_B2F_ITEM_3
	person_event SPRITE_POKE_BALL, 3, 2, SPRITEMOVEDATA_ITEM_TREE, 0, 0, -1, -1, PAL_OW_PURPLE, PERSONTYPE_ITEMBALL, 0, MoundB2F_Item_Dynamite, EVENT_MOUND_B2F_ITEM_4
	person_event SPRITE_PALETTE_PATROLLER, 8, 3, SPRITEMOVEDATA_STANDING_LEFT, 0, 0, -1, -1, PAL_OW_YELLOW, PERSONTYPE_TRAINER, 2, MoundB2F_PaletteYellow, EVENT_MOUND_B2F_TRAINER_2

