RuinsF2_MapScriptHeader;trigger count
	db 0
 ;callback count
	db 1
	dbw MAPCALLBACK_TILES, RuinsF2_TriggeredTrap

RuinsF2Blocks:
	clearevent EVENT_6
	jump RuinsF2_TriggeredTrap

RuinsF2Trap1:
	setevent EVENT_RUINS_F2_TRAP_1
	setevent EVENT_1
	jump RuinsF2_TriggeredTrap

RuinsF2Trap2:
	setevent EVENT_RUINS_F2_TRAP_2
	setevent EVENT_2
	jump RuinsF2_TriggeredTrap

RuinsF2Trap3:
	setevent EVENT_RUINS_F2_TRAP_3
	setevent EVENT_3
	jump RuinsF2_TriggeredTrap

RuinsF2Trap4:
	setevent EVENT_RUINS_F2_TRAP_4
	setevent EVENT_4
	jump RuinsF2_TriggeredTrap

RuinsF2Trap6:
	checkevent EVENT_TELUM_SWITCH
	sif true
		end
	checkevent EVENT_0
	sif false
		end
	playsound SFX_VICEGRIP
	appear $4
	clearevent EVENT_0
	applymovement 4, .movement
	end
.movement
	fast_slide_step_right
	fast_slide_step_right
	step_end

RuinsF2Trap5:
	disappear 4
	setevent EVENT_0
	end

RuinsF2_Item_1:
	db GAS_MASK, 1

RuinsF2_Item_2:
	db BLUE_JEWEL, 1

RuinsF2Arrow:
	jumptext .text

.text
	ctxt "This arrow smells"
	line "poisonous."

	para "Better not touch"
	line "it."
	done

RuinsF2_TriggeredTrap:
	checkevent EVENT_RUINS_F2_TRAP_1
	sif false, then
		changeblock 2, 4, $1
	selse
		changeblock 2, 4, $33
	sendif
	changeblock 26, 4, $1
	checkevent EVENT_RUINS_F2_TRAP_3
	sif false, then
		changeblock 24, 16, $1
		checkevent EVENT_RUINS_F2_TRAP_2
		sif true
			changeblock 24, 16, $35
	selse
		checkevent EVENT_RUINS_F2_TRAP_4
		sif false, then
			changeblock 24, 16, $33
		selse
			changeblock 24, 16, $38
		sendif
	sendif
	checkevent EVENT_RUINS_F2_TRAP_2
	sif false, then
		changeblock 12, 14, $1
	selse
		changeblock 12, 14, $35
	sendif
	checkevent EVENT_6
	sif true, then
		changeblock 12, 14, $35
		checkevent EVENT_1
		sif true, then
			clearevent EVENT_1
			scall RuinsPrepareFall
			warp RUINS_F1, 3, 3
			jump RuinsF2Fall
		sendif
		checkevent EVENT_2
		sif true, then
			clearevent EVENT_2
			scall RuinsPrepareFall
			warp RUINS_F1, 23, 14
			jump RuinsF2Fall
		sendif
		checkevent EVENT_3
		sif true, then
			clearevent EVENT_3
			scall RuinsPrepareFall
			warp RUINS_F1, 36, 17
			jump RuinsF2Fall
		sendif
		checkevent EVENT_4
		sif true, then
			clearevent EVENT_4
			scall RuinsPrepareFall
			warp RUINS_F1, 36, 18
			jump RuinsF2Fall
		sendif
	selse
		setevent EVENT_6
	sendif
	return

RuinsPrepareFall:
	playsound SFX_ENTER_DOOR
	callasm AnchorBGMap
	callasm BGMapAnchorTopLeft
	showemote 0, 0, 32
	applymovement 0, .movement
	end
.movement
	hide_person
	step_end

RuinsF2Fall:
	playsound SFX_BALL_POOF
	applymovement 0, .movement
	playsound SFX_STRENGTH
	earthquake 24
	closetext
	end
.movement
	show_person
	skyfall
	step_end

RuinsF2_TryJump1:
	checkevent EVENT_RUINS_F2_TRAP_3
RuinsF2_AfterTryJump:
	sif false
		end
	farjump RuinsF3_JumpHole

RuinsF2_TryJump2:
	checkevent EVENT_RUINS_F2_TRAP_4
	jump RuinsF2_AfterTryJump

RuinsF2_MapEventHeader ;filler
	db 0, 0

;warps
	db 2
	warp_def $b, $13, 4, RUINS_F1
	warp_def $13, $5, 1, RUINS_F3

	;xy triggers
	db 6
	xy_trigger 0, $4, $2, $0, RuinsF2Trap1, $0, $0
	xy_trigger 0, $f, $c, $0, RuinsF2Trap2, $0, $0
	xy_trigger 0, $10, $18, $0, RuinsF2Trap3, $0, $0
	xy_trigger 0, $11, $18, $0, RuinsF2Trap4, $0, $0
	xy_trigger 0, $a, $5, $0, RuinsF2Trap5, $0, $0
	xy_trigger 0, $6, $3, $0, RuinsF2Trap6, $0, $0

	;signposts
	db 2
	signpost 16, 24, SIGNPOST_READ, RuinsF2_TryJump1
	signpost 17, 24, SIGNPOST_READ, RuinsF2_TryJump2

	;people-events
	db 3
	person_event SPRITE_POKE_BALL, 17, 29, SPRITEMOVEDATA_ITEM_TREE, 0, 0, -1, -1, PAL_OW_PURPLE, PERSONTYPE_ITEMBALL, 0, RuinsF2_Item_1, EVENT_RUINS_F2_ITEM_1
	person_event SPRITE_POKE_BALL, 9, 27, SPRITEMOVEDATA_ITEM_TREE, 0, 0, -1, -1, PAL_OW_RED, PERSONTYPE_ITEMBALL, 0, RuinsF2_Item_2, EVENT_RUINS_F2_ITEM_2
	person_event SPRITE_SNES, 5, 1, SPRITEMOVEDATA_ITEM_TREE, 0, 0, -1, -1, PAL_OW_GREEN, PERSONTYPE_SCRIPT, 0, RuinsF2Arrow, EVENT_0
