;;; Sierra Script 1.0 - (do not remove this comment)
(script# 76)
(include sci.sh)
(use Main)
(use Class_255_0)
(use Sound)
(use Cycle)
(use Game)
(use Obj)

(public
	Room76 0
)

(local
	local0
	gEgoY
)
(instance fallSound of Sound
	(properties
		number 52
	)
)

(instance Room76 of Rm
	(properties
		picture 76
		style $0010
		horizon 99
		north 73
	)
	
	(method (init)
		(Load rsVIEW 936)
		(Load rsSOUND 52)
		(self setRegions: 605)
		(super init:)
		(= global101 1)
		(= west 75)
		(gEgo view: 904 xStep: 4 yStep: 1)
		(if (== gPrevRoomNum 73)
			(gEgo posn: 189 118 init:)
		else
			(gEgo posn: 20 161 init:)
		)
		(gEgo priority: (CoordPri (gEgo y?)))
		(proc0_10 605 1)
	)
	
	(method (doit)
		(super doit:)
		(if (& (gEgo onControl: 0) $0040)
			(= gNewRoomNumber_2 73)
		)
		(if
			(and
				(& (gEgo onControl: 1) $0004)
				(not local0)
				(!= (gRoom script?) fallChasm)
			)
			(self setScript: fallChasm)
		)
	)
	
	(method (handleEvent pEvent)
		(if (pEvent claimed?) (return 1))
		(return
			(if (== (pEvent type?) evSAID)
				(cond 
					((Said 'look[<around][/room]') (Print 76 0) (Print 76 1))
					((Said 'find,look/abyss')
						(if (& (gEgo onControl: 0) $1000)
							(Print 76 2)
						else
							(Print 76 3)
						)
					)
					((Said 'look/exit,hole') (Print 76 4))
					((Said '(place,lay)[<down]/board')
						(cond 
							((not (gEgo has: 22)) (Print 76 5 67 -1 10 25 5))
							(
							(or local0 (not (& (gEgo onControl: 0) $1000))) (proc0_13))
							(else (self setScript: layBoard))
						)
					)
				)
			else
				0
			)
		)
	)
)

(instance fallChasm of Script
	(properties)
	
	(method (init param1)
		(proc0_8)
		(proc0_10 605 4)
		(gEgo view: 936 setPri: 10 setCycle: Fwd)
		(super init: param1)
	)
	
	(method (changeState newState)
		(switch (= state newState)
			(0
				(gEgo
					illegalBits: 0
					yStep: 10
					setMotion: MoveTo (+ (gEgo x?) 5) 300 self
				)
				(= cycles 2)
			)
			(1 (fallSound play: self))
			(2
				((gInv at: 3) loop: 0)
				(Print 76 6 83 30 1 88)
				(= seconds 3)
			)
			(3
				(proc0_21)
				(Print 76 7 83 30 1 88)
			)
			(4
				(proc0_21)
				(ShakeScreen 10)
				(= seconds 2)
			)
			(5 (= global127 1))
		)
	)
)

(instance layBoard of Script
	(properties)
	
	(method (init param1)
		(= gEgoY (gEgo y?))
		(if (< (/ global192 10) 2)
			(gGame changeScore: 2)
			(= global192 (+ global192 10))
		)
		(super init: param1)
	)
	
	(method (doit)
		(if
			(and
				(& (gEgo onControl: 1) $0004)
				(or
					(> (gEgo y?) (+ gEgoY 3))
					(< (gEgo y?) (- gEgoY 3))
				)
			)
			(= local0 0)
			(client setScript: fallChasm)
		)
		(if
			(and
				(& (gEgo onControl: 1) $0004)
				(== local0 1)
				(== global132 0)
			)
			(= global132 1)
		)
		(if
			(and
				(& (gEgo onControl: 1) $1000)
				(== global132 1)
				(== local0 1)
			)
			(= global132 0)
			(= local0 0)
			(self changeState: 1)
		)
	)
	
	(method (changeState newState)
		(switch (= state newState)
			(0
				(Print 76 8)
				(= local0 1)
				((gInv at: 22) moveTo: 76)
			)
			(1
				(gRoom setScript: 0)
				(Print 76 9 83)
				(gEgo get: 22)
			)
		)
	)
)
