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

(public
	Room50 0
)

(local
	newAct
	local1
	newProp
	newProp_2
	newProp_3
)
(instance theSelection of Sound
	(properties)
)

(instance Room50 of Rm
	(properties
		picture 50
		style $0010
	)
	
	(method (init)
		(ogressChaseMusic init:)
		(ogressCatchMusic init:)
		(Load rsVIEW 247)
		(Load rsVIEW 245)
		(Load rsVIEW 48)
		(Load rsVIEW 540)
		(Load rsVIEW 647)
		(self setRegions: 602)
		(super init:)
		(if global100
			((View new:) view: 647 loop: 2 posn: 244 95 addToPic:)
		)
		((= newProp (Prop new:))
			view: 540
			loop: 0
			cel: 1
			posn: 160 86
			init:
			cycleSpeed: 2
			setCycle: Fwd
		)
		((= newProp_2 (Prop new:))
			view: 540
			loop: 2
			posn: 227 82
			init:
			setCycle: Fwd
		)
		((= newProp_3 (Prop new:))
			view: 540
			loop: 2
			posn: 266 89
			init:
			setCycle: Fwd
		)
		((= newAct (Act new:)) setScript: ogressChase)
		(gEgo posn: 77 132 view: 2 setStep: 3 2 init:)
	)
	
	(method (doit)
		(super doit:)
		(if (& (gEgo onControl: 0) $0040) (self newRoom: 49))
	)
	
	(method (handleEvent pEvent &tmp gInvSaidMe)
		(if (pEvent claimed?) (return 1))
		(return
			(if (== (pEvent type?) evSAID)
				(cond 
					((Said 'look>')
						(cond 
							((Said '<under/table') (Print 50 0))
							((Said '/table') (Print 50 1))
							((Said '/stove') (Print 50 2))
							((Said '/window') (Print 50 3))
							((Said '/buck') (Print 50 4))
							((Said '/caldron') (Print 50 5))
							((Said '/wall') (Print 50 6))
							((or (Said '/dirt') (Said '<down')) (Print 50 7))
							((Said '/giantess') (Print 50 8))
							((Said '[<around,at][/room,cottage,kitchen]') (Print 50 9))
						)
					)
					(
					(or (Said 'converse/giantess') (Said 'converse[/!*]'))
						(if (== (ogressChase state?) 0)
							(Print 50 10)
							(ogressChase seconds: 0 changeState: 2)
						else
							(Print 50 11)
						)
					)
					((Said 'get,rob/buck') (Print 50 12))
					((Said 'kill/giantess') (Print 50 13))
					((Said 'get,capture/giantess') (Print 50 14))
					((Said 'help,save/buck') (Print 50 15))
					(
					(and (Said 'deliver>') (= gInvSaidMe (gInv saidMe:)))
						(if (gInvSaidMe ownedBy: gEgo)
							(Print 50 16)
						else
							(pEvent claimed: 1)
							(Print 50 17)
						)
					)
				)
			else
				0
			)
		)
	)
)

(instance ogressChase of Script
	(properties)
	
	(method (doit)
		(super doit:)
		(if
		(and (< (gEgo distanceTo: client) 25) (== state 0))
			(= seconds 0)
			(self cue:)
		)
	)
	
	(method (changeState newState)
		(switch (= state newState)
			(0
				(client
					view: 247
					loop: 0
					posn: 173 121
					cycleSpeed: 3
					setCycle: Fwd
					init:
				)
				(= seconds 5)
			)
			(1
				(Print 50 18)
				(self cue:)
			)
			(2
				(theSelection number: 10 loop: 1 play:)
				(= global167 1)
				(newAct
					view: 245
					cycleSpeed: 0
					illegalBits: 0
					setCycle: Walk
					setAvoider: Avoid
					setMotion: Chase gEgo 15 self
				)
			)
			(3
				(theSelection number: 11 loop: 1 play:)
				(gEgo hide:)
				(newAct
					view: 48
					setCycle: Walk
					setMotion: MoveTo 173 125 self
				)
			)
			(4
				(Print 50 19 67 -1 10)
				(= seconds 5)
			)
			(5 (= global127 1))
		)
	)
)

(instance ogressChaseMusic of Sound
	(properties
		number 10
	)
)

(instance ogressCatchMusic of Sound
	(properties
		number 11
	)
)

(instance playMusic of Script
	(properties)
	
	(method (changeState newState)
		(switch (= state newState)
			(0
				(switch theSelection
					(10
						(ogressChaseMusic play: self)
					)
					(11
						(ogressCatchMusic play: self)
					)
				)
			)
			(1
				(if (!= theSelection 11) (= state -1) (self cue:))
			)
		)
	)
)
