LaurelLab_MapScriptHeader;trigger count
	db 0
 ;callback count
	db 0

LaurelLabFossilCaseNPC:
	faceplayer
	opentext
	checkitem FOSSIL_CASE
	sif false, then
		checkiteminbox FOSSIL_CASE
		sif false, then
			writetext .give_fossil_case_text
			verbosegiveitem FOSSIL_CASE
		sendif
	sendif
	jumptext .case_given_text

.give_fossil_case_text
	db TX_COMPRESSED, $75, $14, $88, $1a, $a6, $ab, $0b, $57, $30, $0b, $4b
	db $78, $1c, $af, $84, $93, $00, $a1, $03, $ea

	db $3c, $02, $b2, $05, $63, $b4, $c6, $42, $f9, $a2, $60, $b0
	db $be, $f6, $c6, $de, $ed, $51, $4c, $28, $40, $fb

	db $e0, $18, $e3, $e9, $98, $88, $c8, $5f, $34, $4c, $16, $17
	db $de, $d8, $e4, $08, $6e, $29, $85, $08, $1f

	db $7c, $01, $b5, $7a, $41, $e4, $28, $8c, $85, $f3
	db $43, $d8, $2c, $2f, $cd, $8a, $14, $9a, $ef
	db $55, $29, $85, $08, $1f

	db $7c, $01, $42, $46, $7d, $c8, $49, $19, $0b, $e6
	db $87, $b0, $58, $5f, $9a, $49, $5a, $df, $0a
	db $d5, $29, $85, $08, $1f

	db $7c, $01, $ca, $16, $a3, $3a, $49, $80, $c9
	db $97, $b0, $0a, $10, $3e, $a2, $2b, $05, $1f, $19, $06, $4e
	db $7e, $a9, $01, $9c, $84, $39, $9d, $69, $95, $2e

	db $20, $1d, $a7, $f1, $5b, $57, $01, $05, $a8, $43, $3c
	db $bc, $80, $be, $75, $24, $d6, $71, $1b, $81, $cb
	db $0a, $a6, $75, $6b, $05, $2d, $26, $ff

	db $80, $31, $35, $9f, $e5, $ac, $14, $b4, $8d, $1e
	db $a7, $88

.case_given_text
	db TX_COMPRESSED, $75, $84, $04, $16, $a3, $e3, $21, $c6, $84, $4d
	db $7b, $00, $a1, $03, $ef, $e0, $86, $ae, $0e, $e0

	db $c8, $02, $d3, $b7, $14, $c2, $84, $0f, $b1, $b7, $50
	db $6f, $69, $33, $15, $ac, $64, $e6, $0e, $e2, $4d, $67
	db $c6, $9a

LaurelLabRevivalScientist:
	faceplayer
	opentext
	writetext .introduction_text
	yesorno
	sif false
		jumptext .rejected_text
	checkitem FOSSIL_CASE
	sif false
.no_fossil
		jumptext .no_fossil_text
	copybytetovar wFossilCaseCount
	iffalse .no_fossil
	checkcode VAR_PARTYCOUNT
	if_less_than 6, .go
	checkcode VAR_BOXSPACE
	sif false
		jumptext .no_room_text
.go
	copybytetovar wFossilCase
	pushvar
	addhalfwordtovar .fossils
	copyvarbytetovar
	scall .appraise
	pullvar
	special Special_FossilPuzzle
	sif false, then
		faceperson PLAYER, LEFT
		popvar
		jumptextfaceplayer .aborted_puzzle_text
	sendif
	callasm .take_fossil_increment_count
	faceplayer
	faceperson PLAYER, LEFT
	opentext
	writetext .here_is_your_mon_text
	playwaitsfx SFX_DEX_FANFARE_140_169
	popvar
	addhalfwordtovar .fossils
	copyvarbytetovar
	givepoke 0, 10
	closetextend

.fossils
	db LILEEP, ANORITH, CRANIDOS, SHIELDON

.take_fossil_increment_count
	ld hl, wFossilCaseCount
	dec [hl]
	inc hl
.loop
	inc hl
	ld a, [hld]
	ld [hli], a
	inc a
	jr nz, .loop
	ld hl, wFossilsRevived
	inc [hl]
	ret nz
	inc hl
	inc [hl]
	ret nz
	ld a, $ff
	ld [hld], a
	ld [hl], a
	ret

.appraise
	pokenamemem 0, 0
	writetext .this_is_a_mon_text
	writetext .help_me_text
	closetext
	spriteface 2, UP
	checkcode VAR_FACING
	anonjumptable
	dw .end
	dw .step_left_and_up
	dw .end
	dw .look_up

.step_left_and_up
	applymovement 0, .step_left_and_up_movement
.end
	end

.step_left_and_up_movement
	step_left
	step_up
	step_end

.look_up
	applymovement 0, .look_up_movement
	end

.look_up_movement
	turn_head_up
	step_end

.this_is_a_mon_text
	db TX_COMPRESSED, $ad, $3c

	db $40, $14, $91, $a2, $0d, $13
	db $5e, $07, $23
	db $8d, $3c, $40

.help_me_text
	db TX_COMPRESSED, $75, $08, $67, $98, $08, $2d, $4b
	db $0b, $c9, $3e, $88, $8f, $9c, $64, $2f, $88, $e9, $d9
	db $aa, $b4, $9c, $10, $b0, $b2, $68, $47, $e3, $21, $7c
	db $fc, $0e, $60

.introduction_text
	db TX_COMPRESSED, $75, $35, $f9, $b1, $0c, $8c, $c9, $63, $45

	db $f8, $01, $49, $db, $c5, $16, $3e, $53, $7f
	db $9a, $f2, $86, $d7, $42, $e0, $79, $4e, $94, $15

	db $c4, $03, $a8, $32, $03, $19, $2c, $f3
	db $35, $e7, $f5, $94, $8c, $87, $2c, $31, $66, $0c, $30, $63
	db $54, $0e, $57, $c2, $49, $80, $50, $81, $f5, $1e

	db $00, $df, $49, $71, $f3, $96, $19, $6b
	db $04, $f5, $a4, $e3, $fa, $ca, $46, $43, $81
	db $22, $a0, $41, $69, $68, $a5
	db $a6, $80

.rejected_text
	db TX_COMPRESSED, $6e, $9d, $bf, $c0, $41, $6a, $64, $24, $a6
	db $3d, $6b, $69, $17, $4f

	db $00, $0a, $e2, $86, $d7, $42, $e0, $79, $4e, $94, $15, $4b
	db $c6, $9a

.no_fossil_text
	db TX_COMPRESSED, $72, $85, $a8, $ce, $92, $99, $30, $08, $7b
	db $35, $e4, $32, $33, $25, $8d, $17, $f8, $08, $2d
	db $00, $c8, $49, $4c, $89, $d0, $63
	db $9a, $f6, $01, $42, $07, $de
	db $34, $d0

.aborted_puzzle_text
	db TX_COMPRESSED, $6e, $9d, $ba, $58, $e5, $0b, $52, $ad, $25, $cb
	db $0b, $c8, $b0, $88, $a5

	db $01, $5f, $56, $3e, $53, $7f, $8c, $85, $f3, $8a, $f5, $95
	db $27, $bb, $b6, $6b, $96, $93, $24, $1e, $10, $10, $5a
	db $01, $56, $92, $e5, $86, $2c, $c1, $86, $0c, $73
	db $5e, $c0, $28, $40, $fb
	db $ea, $68

.here_is_your_mon_text
	db TX_COMPRESSED, $75, $2a, $d4, $44, $34, $cb, $26, $84, $60, $d7, $78

	db $80, $62, $6b, $38, $34, $40, $41, $69
	db $6f, $03, $91
	db $c6, $9a

.no_room_text
	db TX_COMPRESSED, $72, $85, $a9, $90, $92, $99, $13, $a0, $c7, $16, $10
	db $be, $f0, $c9, $01, $05, $a5, $c1, $1a, $bb, $05, $02
	db $b0, $0a, $c3, $4e, $cc, $02, $b9, $a4, $0d, $a4
	db $d6, $f0, $39, $5f, $09, $38
	
	db $80, $6e, $6b, $38, $08, $2d, $43, $a7, $44, $1b, $36, $32
	db $72, $f3, $e7, $2c, $33, $0d, $1f, $69, $78
	db $d3, $40

LaurelLab_MapEventHeader:: db 0, 0

.Warps
	db 2
	warp_def $b, $4, 5, LAUREL_CITY
	warp_def $b, $5, 5, LAUREL_CITY

.CoordEvents
	db 0

.BGEvents
	db 2
	signpost 1, 0, SIGNPOST_JUMPSTD, magazinebookshelf
	signpost 1, 1, SIGNPOST_JUMPSTD, difficultbookshelf

.ObjectEvents
	db 2
	person_event SPRITE_SCIENTIST, 7, 9, SPRITEMOVEDATA_WALK_UP_DOWN, 1, 1, -1, -1, 8 + PAL_OW_GREEN, PERSONTYPE_SCRIPT, 0, LaurelLabRevivalScientist, -1
	person_event SPRITE_SCIENTIST, 6, 1, SPRITEMOVEDATA_STANDING_LEFT, 0, 0, -1, -1, PAL_OW_RED, PERSONTYPE_SCRIPT, 0, LaurelLabFossilCaseNPC, -1

