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

(public
	Room30 0
)

(local
	gEgoOnControl
	theGEgoOnControl
	newAct
	newAct_2
	local4
	local5
)
(instance hTheme of Sound
	(properties
		number 29
	)
)

(instance fallSound of Sound
	(properties
		number 51
	)
)

(instance cuckooSound of Sound
	(properties
		number 80
	)
)

(instance Room30 of Rm
	(properties
		picture 30
	)
	
	(method (init)
		(= north 24)
		(= east 79)
		(= west 29)
		(= horizon 85)
		(= global101 0)
		(gEgo edgeHit: 0)
		(super init:)
		(if global100 (gRoom overlay: 130))
		(self setRegions: 508 511)
		(Load rsVIEW 17)
		(Load rsVIEW 18)
		(Load rsVIEW 21)
		(Load rsVIEW 33)
		(Load rsSOUND 80)
		(switch gPrevRoomNum
			(west (gEgo x: 2))
			(24
				(gEgo posn: 112 (+ horizon 2))
			)
			(0 (gEgo x: 183 y: 123))
			(92
				(gEgo view: 80 setCycle: Fwd setScript: henchFlyIn)
				(= horizon -1000)
				(henchFlyIn changeState: 1)
			)
			(79
				(if (== (gEgo view?) 80)
					(= horizon -1000)
					(gEgo ignoreHorizon: setScript: henchFlyIn)
					(henchFlyIn changeState: 1)
				else
					(gEgo x: 318 y: 100)
				)
			)
			(else  (gEgo x: 183 y: 123))
		)
		(if (== (gEgo script?) 0)
			(gEgo view: 2 xStep: 3 yStep: 2 init:)
		)
	)
	
	(method (doit)
		(super doit:)
		(if
			(and
				(!=
					(= gEgoOnControl (gEgo onControl:))
					theGEgoOnControl
				)
				(== (gRoom script?) 0)
			)
			(= theGEgoOnControl gEgoOnControl)
			(cond 
				((& gEgoOnControl $0010) (self setScript: shortFall))
				((& gEgoOnControl $0004) (self setScript: deadFall))
				((& gEgoOnControl $0020) (self setScript: deadMagenta))
			)
		)
	)
	
	(method (handleEvent pEvent)
		(if (pEvent claimed?) (return 1))
		(return
			(if (== (pEvent type?) evSAID)
				(cond 
					((Said 'climb/boulder') (Print 30 0))
					((Said 'look>')
						(cond 
							((Said '/path') (Print 30 1))
							((Said '/boulder') (Print 30 2))
							((Said '/goon,man,person')
								(if (gCast contains: newAct)
									(Print 30 3)
								else
									(Print 30 4)
								)
							)
							((Said '[<around][/room]') (Print 30 5))
						)
					)
				)
			else
				0
			)
		)
	)
	
	(method (newRoom newRoomNumber)
		(if (!= (gEgo view?) 80)
			(super newRoom: newRoomNumber)
		)
	)
)

(instance shortFall of Script
	(properties)
	
	(method (changeState newState)
		(switch (= state newState)
			(0
				(fallSound play:)
				(proc0_8)
				(cond 
					((< (gEgo x?) 183) (= local5 146))
					((> (gEgo x?) 195) (= local5 165))
					(else (= local5 154))
				)
				(gEgo
					yStep: 6
					yStep: 6
					illegalBits: 0
					loop: (& (gEgo loop?) $0001)
					setCel: 0
					view: 17
					setCycle: Fwd
					setMotion: MoveTo (gEgo x?) local5 self
				)
			)
			(1
				(gEgo xStep: 3 yStep: 2 view: 18 loop: 0 setCycle: Fwd)
				(Timer setReal: self 5)
				(cuckooSound play:)
			)
			(2
				(gEgo view: 21 loop: 2 cel: 4 setCycle: Beg self)
			)
			(3
				(gEgo setCycle: Walk view: 2 illegalBits: -32768)
				(proc0_9)
				(gRoom setScript: 0)
			)
		)
	)
)

(instance deadFall of Script
	(properties)
	
	(method (changeState newState)
		(switch (= state newState)
			(0
				(fallSound play:)
				(proc0_8)
				(gEgo
					yStep: 10
					illegalBits: 0
					loop: (& (gEgo loop?) $0001)
					setCel: 0
					view: 17
					setCycle: Fwd
					setMotion: MoveTo (gEgo x?) 175 self
				)
			)
			(1
				(gEgo view: 33 loop: 0)
				(Animate (gCast elements?) 0)
				(ShakeScreen 10 1)
				(Timer setReal: self 3)
			)
			(2
				(Print 30 6)
				(Timer setReal: self 5)
			)
			(3 (proc0_9) (= global127 1))
		)
	)
)

(instance deadMagenta of Script
	(properties)
	
	(method (changeState newState)
		(switch (= state newState)
			(0
				(fallSound play:)
				(proc0_8)
				(gEgo
					yStep: 10
					illegalBits: 0
					loop: (& (gEgo loop?) $0001)
					setCel: 0
					view: 17
					setCycle: Fwd
					setMotion: MoveTo (gEgo x?) 175 self
				)
			)
			(1
				(gEgo view: 33 loop: 0)
				(Timer setReal: self 3)
				(Animate (gCast elements?) 0)
				(ShakeScreen 10 1)
			)
			(2
				(Print 30 6)
				(Timer setReal: self 5)
			)
			(3 (= global127 1) (proc0_9))
		)
	)
)

(instance henchFlyIn of Script
	(properties)
	
	(method (changeState newState)
		(switch (= state newState)
			(1
				(Load rsVIEW 144)
				(Load rsVIEW 60)
				(Load rsVIEW 143)
				(proc0_8)
				(hTheme play:)
				(gEgo
					view: 80
					setLoop: 4
					ignoreHorizon:
					yStep: 2
					illegalBits: 0
					setPri: 12
					setCycle: Fwd
					posn: 168 -30
					init:
					setMotion: MoveTo 160 121 self
				)
			)
			(2
				(gEgo
					view: 60
					setLoop: 3
					cel: 255
					cycleSpeed: 1
					setCycle: End self
				)
				(= newAct (Act new:))
				(= newAct_2 (Act new:))
				(newAct
					view: 144
					posn: (- (gEgo x?) 15) (gEgo y?)
					xStep: 6
					yStep: 3
					cycleSpeed: 0
					setCycle: Fwd
					setScript: h1Actions
				)
				(newAct_2
					view: 144
					posn: (+ (gEgo x?) 15) (gEgo y?)
					xStep: 6
					yStep: 3
					cycleSpeed: 0
					setCycle: Fwd
					setScript: h2Actions
				)
			)
			(3
				(gEgo
					view: 2
					ignoreActors: 0
					setLoop: -1
					loop: 1
					illegalBits: -32768
					setPri: -1
					cycleSpeed: 0
					setCycle: Walk
				)
				(gEgo xStep: 3 yStep: 2)
				(proc0_9)
			)
		)
	)
)

(instance h1Actions of Script
	(properties)
	
	(method (changeState newState)
		(switch (= state newState)
			(0
				(newAct
					init:
					ignoreHorizon:
					illegalBits: 0
					setPri: 12
					setCycle: Walk
					setMotion: MoveTo 145 40 self
				)
			)
			(1
				(newAct view: 143 setMotion: MoveTo 145 -30 self)
				(= local4 1)
			)
			(2
				(gRoom horizon: 85)
				(newAct dispose:)
			)
		)
	)
)

(instance h2Actions of Script
	(properties)
	
	(method (changeState newState)
		(switch (= state newState)
			(0
				(newAct_2
					init:
					ignoreHorizon:
					illegalBits: 0
					setPri: 12
					setCycle: Walk
					setMotion: MoveTo 175 40 self
				)
			)
			(1
				(newAct_2 view: 143 setMotion: MoveTo 175 -30 self)
			)
			(2 (newAct_2 dispose:))
		)
	)
)
