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

(public
	Room79 0
)
(synonyms
	(goon goon goon man goon goon animal goon)
)

(local
	newAct
	newAct_2
	local2
)
(instance henchTheme of Sound
	(properties
		number 29
		loop -1
	)
)

(instance sFalling of Sound
	(properties
		number 51
		priority 3
	)
)

(instance Room79 of Rm
	(properties
		picture 79
		style $0008
	)
	
	(method (init)
		(= north (= east 80))
		(= south 30)
		(= global101 0)
		(Load rsVIEW 80)
		(Load rsVIEW 60)
		(Load rsVIEW 140)
		(Load rsVIEW 142)
		(Load rsVIEW 143)
		(Load rsVIEW 144)
		(if global100 (= picture 179))
		(super init:)
		(switch gPrevRoomNum
			(north
				(gEgo view: 2 posn: 232 91 loop: 1 init:)
			)
			(south
				(if global169
					(= newAct (Act new:))
					(= newAct_2 (Act new:))
					(newAct setScript: h1Actions)
					(newAct_2 setScript: h2Actions init: hide:)
				)
				(gEgo x: 63 y: 188)
				(gEgo init: view: 2)
			)
			(else 
				(gEgo x: 63 y: 188)
				(= newAct (Act new:))
				(= newAct_2 (Act new:))
				(newAct setScript: h1Actions)
				(newAct_2 setScript: h2Actions init: hide:)
				(gEgo x: 63 y: 188)
				(gEgo init: view: 2)
			)
		)
		(gEgo edgeHit: 0)
		(= global105 0)
		(= global189 1)
		(= global204 0)
	)
	
	(method (doit &tmp temp0)
		(super doit:)
		(if
		(and (== (gRoom script?) 0) (== global105 0))
			(cond 
				((& (= temp0 (gEgo onControl: 0)) $0040) (gRoom newRoom: 80))
				((& temp0 $0010)
					(if (< (gEgo heading?) 180)
						(gEgo baseSetter: 0)
					else
						(gEgo baseSetter: (ScriptID 0 1))
					)
				)
				((& temp0 $0f8e)
					(gSounds eachElementDo: #stop 0)
					(sFalling play:)
					(stopHench cue:)
					(gRoom
						setScript:
							(cond 
								((& temp0 $0002) fallBlue)
								((& temp0 $0008) fallCyan)
								((& temp0 $0004) fallGreen)
								((& temp0 $0080) fallLgrey)
								((& temp0 $0100) fallGrey)
								((& temp0 $0200) fallLblue)
								((& temp0 $0400) fallLgreen)
								((& temp0 $0800) fallLcyan)
							)
					)
				)
			)
		)
	)
	
	(method (handleEvent pEvent &tmp gInvSaidMe)
		(if (pEvent claimed?) (return 1))
		(return
			(if (== (pEvent type?) evSAID)
				(cond 
					((Said 'look>')
						(cond 
							(
							(or (Said '/room,cliff') (Said '[<around][/!*]')) (Print 79 0))
							((Said '/goon')
								(if (gCast contains: newAct)
									(Print 79 1)
								else
									(Print 79 2)
								)
							)
							((Said '/path') (Print 79 3))
							((Said '/castle') (Print 79 4))
							((Said '/boulder') (Print 79 5))
							((Said '/dirt,down') (Print 79 6))
							((Said '/forest') (Print 79 7))
						)
					)
					((Said 'climb/cliff') (Print 79 8))
					(
					(or (Said 'converse/goon') (Said 'converse[/!*]')) (Print 79 9))
					((Said 'get,capture/goon') (Print 79 10))
					((Said 'deliver>')
						(if (= gInvSaidMe (gInv saidMe:))
							(if (gEgo has: (gInv indexOf: gInvSaidMe))
								(Print 79 11)
							else
								(Print 800 2)
							)
						else
							(Print 79 12)
							(pEvent claimed: 1)
						)
					)
				)
			else
				0
			)
		)
	)
	
	(method (newRoom newRoomNumber)
		(proc0_21)
		(if (!= global105 10)
			(= global189 0)
			(gEgo illegalBits: -32768 setPri: -1)
			(super newRoom: newRoomNumber)
		)
	)
)

(instance fallBlue of Script
	(properties)
	
	(method (changeState newState)
		(switch (= state newState)
			(0
				(= global105 10)
				(proc0_8)
				(gEgo
					setPri: 8
					yStep: 10
					illegalBits: 0
					loop: (& (gEgo loop?) $0001)
					cel: 0
					view: 17
					setCycle: Fwd
					posn: (- (gEgo x?) 8) (gEgo y?)
					setMotion: MoveTo (gEgo x?) (+ (gEgo y?) 150) self
				)
			)
			(1 (gRoom setScript: egoDead))
		)
	)
)

(instance fallCyan of Script
	(properties)
	
	(method (changeState newState)
		(switch (= state newState)
			(0
				(proc0_8)
				(= global105 10)
				(gEgo
					setPri: 8
					yStep: 10
					illegalBits: 0
					loop: (& (gEgo loop?) $0001)
					cel: 0
					view: 17
					setCycle: Fwd
					posn: (gEgo x?) (+ (gEgo y?) 8)
					setMotion: MoveTo (gEgo x?) (+ (gEgo y?) 150) self
				)
			)
			(1 (gRoom setScript: egoDead))
		)
	)
)

(instance fallGreen of Script
	(properties)
	
	(method (changeState newState)
		(switch (= state newState)
			(0
				(proc0_8)
				(= global105 10)
				(gEgo
					setPri: 4
					yStep: 10
					illegalBits: 0
					loop: (& (gEgo loop?) $0001)
					cel: 0
					view: 17
					setCycle: Fwd
					posn: (gEgo x?) (- (gEgo y?) 8)
					setMotion: MoveTo (gEgo x?) (+ (gEgo y?) 150) self
				)
			)
			(1 (gRoom setScript: egoDead))
		)
	)
)

(instance fallLgrey of Script
	(properties)
	
	(method (changeState newState)
		(switch (= state newState)
			(0
				(proc0_8)
				(= global105 10)
				(gEgo
					setPri: 10
					yStep: 10
					illegalBits: 0
					loop: (& (gEgo loop?) $0001)
					cel: 0
					view: 17
					setCycle: Fwd
					posn: (+ (gEgo x?) 8) (+ (gEgo y?) 4)
					setMotion: MoveTo (gEgo x?) (+ (gEgo y?) 150) self
				)
			)
			(1 (gRoom setScript: egoDead))
		)
	)
)

(instance fallGrey of Script
	(properties)
	
	(method (changeState newState)
		(switch (= state newState)
			(0
				(proc0_8)
				(= global105 10)
				(gEgo
					setPri: 7
					yStep: 10
					illegalBits: 0
					loop: (& (gEgo loop?) $0001)
					cel: 0
					view: 17
					setCycle: Fwd
					posn: (gEgo x?) (+ (gEgo y?) 4)
					setMotion: MoveTo (gEgo x?) (+ (gEgo y?) 150) self
				)
			)
			(1 (gRoom setScript: egoDead))
		)
	)
)

(instance fallLblue of Script
	(properties)
	
	(method (changeState newState)
		(switch (= state newState)
			(0
				(proc0_8)
				(= global105 10)
				(gEgo
					setPri: 6
					yStep: 10
					illegalBits: 0
					loop: (& (gEgo loop?) $0001)
					cel: 0
					view: 17
					setCycle: Fwd
					posn: (gEgo x?) (+ (gEgo y?) 4)
					setMotion: MoveTo (gEgo x?) (+ (gEgo y?) 150) self
				)
			)
			(1 (gRoom setScript: egoDead))
		)
	)
)

(instance fallLgreen of Script
	(properties)
	
	(method (changeState newState)
		(switch (= state newState)
			(0
				(proc0_8)
				(= global105 10)
				(gEgo
					setPri: 0
					yStep: 10
					illegalBits: 0
					loop: (& (gEgo loop?) $0001)
					cel: 0
					view: 17
					setCycle: Fwd
					posn: (gEgo x?) (- (gEgo y?) 4)
					setMotion: MoveTo (gEgo x?) (+ (gEgo y?) 150) self
				)
			)
			(1 (gRoom setScript: egoDead))
		)
	)
)

(instance fallLcyan of Script
	(properties)
	
	(method (changeState newState)
		(switch (= state newState)
			(0
				(proc0_8)
				(= global105 10)
				(gEgo
					setPri: 0
					yStep: 10
					illegalBits: 0
					loop: (& (gEgo loop?) $0001)
					cel: 0
					view: 17
					setCycle: Fwd
					posn: (gEgo x?) (+ (gEgo y?) 4)
					setMotion: MoveTo (gEgo x?) (+ (gEgo y?) 150) self
				)
			)
			(1 (gRoom setScript: egoDead))
		)
	)
)

(instance h1Actions of Script
	(properties)
	
	(method (changeState newState)
		(switch (= state newState)
			(0
				(henchTheme play:)
				(newAct
					ignoreHorizon:
					posn: 57 6
					setStep: 4 3
					view: 142
					setCycle: Walk
					setMotion: MoveTo -10 22 self
					ignoreActors:
					illegalBits: 0
					setPri: 13
					init:
				)
				(Print 79 13 83 67 -1 10 88)
			)
			(1
				(newAct xStep: 4 yStep: 3 setMotion: MoveTo -10 50 self)
			)
			(2
				(proc0_21)
				(newAct
					view: 143
					xStep: 6
					yStep: 4
					setMotion: MoveTo 252 66 self
				)
			)
			(3
				(newAct
					view: 144
					xStep: 8
					yStep: 6
					setMotion: Chase gEgo 14 self
				)
				(h2Actions changeState: 1)
			)
			(4
				(newAct
					view: 140
					posn: (+ (gEgo x?) 14) (+ (gEgo y?) 5)
				)
				(proc0_3 newAct gEgo)
				(gEgo loop: 0 setMotion: 0)
				(proc0_8)
			)
		)
	)
)

(instance h2Actions of Script
	(properties)
	
	(method (changeState newState)
		(switch (= state newState)
			(1
				(newAct_2
					ignoreHorizon:
					posn: 57 6
					view: 142
					setCycle: Walk
					xStep: 4
					yStep: 3
					setMotion: MoveTo 26 65 self
					ignoreActors:
					illegalBits: 0
					setPri: 13
					show:
				)
			)
			(2
				(newAct_2
					view: 143
					xStep: 6
					yStep: 4
					setMotion: MoveTo 42 120 self
				)
			)
			(3
				(newAct_2
					view: 144
					xStep: 8
					yStep: 6
					setMotion: MoveTo (- (gEgo x?) 14) (gEgo y?) self
				)
			)
			(4
				(newAct_2 view: 140)
				(proc0_3 newAct_2 gEgo)
				((ScriptID 0 4) setReal: self 2)
			)
			(5
				(= global105 1)
				(newAct hide:)
				(newAct_2 hide:)
				(cond 
					((== global109 1) (self changeState: 20))
					((and (== global109 2) (not (gEgo has: 33))) (self changeState: 20))
					((and (== global109 3) (not (gEgo has: 4))) (self changeState: 20))
					(else
						(gEgo
							view: 60
							illegalBits: 0
							setPri: 15
							ignoreHorizon:
							setLoop: 1
							cel: 255
							setCycle: End self
						)
					)
				)
			)
			(6
				(gEgo
					view: 80
					setLoop: 5
					setCycle: Fwd
					setMotion: MoveTo 24 60 self
				)
			)
			(7
				(gEgo
					setLoop: 3
					posn: (gEgo x?) (- (gEgo y?) 5)
					setMotion: MoveTo 50 38
				)
				((ScriptID 0 4) setReal: self 2)
			)
			(8
				(gEgo setLoop: 1 setMotion: MoveTo 72 29)
				((ScriptID 0 4) setReal: self 3)
			)
			(9
				(gEgo
					illegalBits: 0
					setPri: 15
					setLoop: 0
					setMotion: MoveTo 72 29 self
				)
			)
			(10
				(gEgo setLoop: -1 setCel: -1)
				(User canControl: 1)
				(User canInput: 1)
				(gEgo dispose:)
				(proc0_9)
				(gRoom newRoom: 92)
			)
			(20
				(gEgo
					illegalBits: 0
					setPri: 15
					view: 60
					setLoop: 2
					cel: 255
					setCycle: End self
				)
			)
			(21
				(proc0_19 henchTheme 1)
				(gEgo
					view: 80
					setCycle: Fwd
					setLoop: 4
					setMotion: MoveTo -40 160 self
				)
			)
			(22
				(proc0_9)
				(gRoom newRoom: 30)
			)
		)
	)
)

(instance egoDead of Script
	(properties)
	
	(method (changeState newState)
		(switch (= state newState)
			(0
				(Animate (gCast elements?) 0)
				(ShakeScreen 10 1)
				(= seconds 3)
			)
			(1
				(Print 79 14)
				((ScriptID 0 4) setReal: self 4)
			)
			(2 (= global127 1))
		)
	)
)

(instance stopHench of Script
	(properties)
	
	(method (cue)
		(if (gCast contains: newAct)
			(newAct
				setLoop: -1
				setCycle: Walk
				setMotion: MoveTo -68 32
				setCycle: Fwd
			)
		)
		(if (gCast contains: newAct_2)
			(newAct_2
				setLoop: -1
				setCycle: Walk
				setMotion: MoveTo -68 32
				setCycle: Fwd
			)
		)
	)
)
