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

(public
	Room654 0
)
(synonyms
	(soup gruel food)
)

(local
	newProp
	[local1 49]
	newView_2
	[newView 7]
	local58
	newView_3
	local60
	[local61 2]
	local63
	local64
)
(instance dwarfMusic of Sound
	(properties
		number 31
		loop -1
	)
)

(instance Room654 of Rm
	(properties
		picture 54
		style $0008
	)
	
	(method (init)
		(= global101 1)
		(Load rsVIEW 630)
		(Load rsVIEW 677)
		(Load rsVIEW 678)
		(Load rsVIEW 500)
		(Load rsVIEW 76)
		(Load rsVIEW 533)
		(super init:)
		((View new:)
			view: 533
			loop: 1
			cel: 0
			posn: 295 106
			setPri: 9
			addToPic:
		)
		(= local63 0)
		(gEgo
			posn: 150 125
			view: 4
			xStep: 4
			yStep: 2
			init:
			setCycle: Walk
		)
		((= [newView 0] (View new:))
			view: 677
			posn: 78 102
			loop: 3
			cel: 0
			init:
			stopUpd:
		)
		(= global176 0)
		((= newProp (Prop new:))
			view: 630
			posn: 83 124
			cycleSpeed: 0
			setCycle: Fwd
			init:
		)
		(if (not global223) (newProp addToPic:))
		(Print 654 0 67 -1 20 25 5)
		(self setScript: dwarfsInToEat)
	)
	
	(method (handleEvent pEvent)
		(super handleEvent: pEvent)
		(return
			(cond 
				((pEvent claimed?) (return 1))
				((== (pEvent type?) evSAID)
					(cond 
						(
						(or (Said 'look[<around][/!*]') (Said 'look/room')) (Print 654 1))
						((Said 'look>')
							(cond 
								((Said '/window') (Print 654 2))
								((Said '/table')
									(if (not global102) (Print 654 3))
									(if (and global102 global176) (Print 654 4))
								)
								((Said '<under/table') (Print 654 5))
								((Said '/stair') (Print 654 6))
								((Said '/cabinet') (Print 654 7))
								((Said '/wall') (Print 654 8))
								((or (Said '/dirt') (Said '<down')) (Print 654 9))
								((Said '/caldron') (Print 654 10))
								((Said '/fire,fireplace') (Print 654 11))
								((Said '/carpet') (Print 654 12))
								((Said '/clock') (Print 654 13))
								((Said '/bowl') (Print 654 14))
							)
						)
					)
				)
			)
		)
	)
)

(instance dwarfsInToEat of Script
	(properties)
	
	(method (init param1)
		(Load rsVIEW 290)
		(Load rsVIEW 291)
		(Load rsVIEW 292)
		(Load rsVIEW 293)
		(Load rsVIEW 294)
		(Load rsVIEW 295)
		(Load rsVIEW 296)
		(Load rsVIEW 297)
		(Load rsVIEW 298)
		(Load rsVIEW 299)
		(Load rsVIEW 275)
		(Load rsVIEW 276)
		(Load rsVIEW 277)
		(Load rsVIEW 278)
		(= [local1 1] 296)
		(= [local1 2] 278)
		(= [local1 3] 0)
		(= [local1 4] 218)
		(= [local1 5] 138)
		(= [local1 8] 295)
		(= [local1 9] 277)
		(= [local1 10] 1)
		(= [local1 11] 295)
		(= [local1 12] 160)
		(= [local1 15] 294)
		(= [local1 16] 276)
		(= [local1 17] 1)
		(= [local1 18] 262)
		(= [local1 19] 160)
		(= [local1 22] 293)
		(= [local1 23] 275)
		(= [local1 24] 0)
		(= [local1 25] 194)
		(= [local1 26] 138)
		(= [local1 29] 292)
		(= [local1 30] 299)
		(= [local1 31] 1)
		(= [local1 32] 228)
		(= [local1 33] 160)
		(= [local1 36] 291)
		(= [local1 37] 298)
		(= [local1 38] 1)
		(= [local1 39] 190)
		(= [local1 40] 160)
		(= [local1 43] 290)
		(= [local1 44] 297)
		(= [local1 45] 0)
		(= [local1 46] 240)
		(= [local1 47] 137)
		(super init: param1)
	)
	
	(method (doit)
		(super doit:)
	)
	
	(method (changeState newState)
		(switch (= state newState)
			(0
				(User canControl: 0 canInput: 0)
				(= local58 0)
				(= local60
					(Print 654 15 33 gSmallFont 67 200 10 70 110 88)
				)
				(dwarfMusic play:)
				(gEgo
					loop: 2
					setCycle: Walk
					setMotion: MoveTo 116 122 self
				)
			)
			(1
				(gEgo loop: 2 cel: 0 stopUpd:)
				(= [local1 local58]
					((Act new:)
						view: [local1 (+ local58 1)]
						posn: 155 185
						illegalBits: 0
						setStep: 4 3
						cycleSpeed: 0
						init:
						yourself:
					)
				)
				([local1 local58]
					setCycle: Walk
					setMotion: MoveTo 135 140 self
				)
			)
			(2
				([local1 local58]
					setCycle: Walk
					setMotion: MoveTo 83 134 self
				)
			)
			(3
				([newView 0] cel: (+ ([newView 0] cel?) 1) forceUpd:)
				([local1 local58]
					view: [local1 (+ local58 2)]
					loop: 1
					setCycle: Fwd
				)
				(= seconds 5)
			)
			(4
				([newView 0] stopUpd:)
				(if (== ([newView 0] cel?) 7)
					(proc0_21)
					(= state 2)
					(= local60 (Print 654 16 33 gSmallFont 67 -1 10 88))
					(= seconds 1)
				else
					([local1 local58] loop: 2 cel: 0 setCycle: End self)
				)
			)
			(5
				([local1 local58]
					loop: 0
					cel: 0
					setCycle: Walk
					setMotion: MoveTo 135 130 self
				)
			)
			(6
				(if (== [local1 (+ local58 3)] 1)
					([local1 local58]
						setLoop: 7
						setMotion: MoveTo 135 160 self
					)
				else
					(++ state)
					([local1 local58]
						setMotion: MoveTo [local1 (+ local58 4)] [local1 (+ local58 5)] self
					)
				)
			)
			(7
				([local1 local58]
					setLoop: -1
					setMotion: MoveTo [local1 (+ local58 4)] [local1 (+ local58 5)] self
				)
			)
			(8
				(= [local1 (+ local58 6)]
					((View new:)
						view: [local1 (+ local58 2)]
						loop: 6
						posn: [local1 (+ local58 4)] (- [local1 (+ local58 5)] 3)
						init:
						ignoreActors: 1
						stopUpd:
						yourself:
					)
				)
				([local1 local58]
					loop: 3
					cel: 0
					setPri: (if (== [local1 (+ local58 3)] 1) 13 else 12)
					posn:
						[local1 (+ local58 4)]
						(if (== [local1 (+ local58 3)] 1)
							(- [local1 (+ local58 5)] 12)
						else
							(- [local1 (+ local58 5)] 6)
						)
					setCycle: End self
				)
			)
			(9
				([local1 local58] loop: 4 cel: 0 ignoreActors: 1 stopUpd:)
				(if (< (= local58 (+ local58 7)) 48)
					(= state 0)
					(self cue:)
				else
					([newView 0] dispose:)
				)
				(gEgo startUpd:)
				(if (> local58 48)
					(proc0_21)
					(= local60
						(Print 654 17 33 gSmallFont 67 7 5 70 290 83 88)
					)
				)
				(= seconds 15)
			)
			(10
				(gEgo
					illegalBits: 0
					ignoreActors: 1
					setMotion: MoveTo 270 136 self
				)
			)
			(11
				(User canInput: 1)
				(proc0_21)
				(= local60 (Print 654 18 33 gSmallFont 67 -1 10 88))
				(gEgo view: 76 loop: 5)
				(dwarfMusic dispose:)
				(= global176 1)
				(gEgo setScript: eatOut)
				(= seconds 60)
			)
			(12 (= local63 1))
			(13
				(proc0_21)
				(= local60 (Print 654 19 33 gSmallFont 67 -1 10 88))
				(= global176 2)
				(User canInput: 0)
				(= local58 0)
				(while (< local58 7)
					([local1 (* local58 7)] cel: 0)
					(++ local58)
				)
				(gEgo cel: 0)
				(= local58 49)
				(= seconds 5)
			)
			(14
				(dwarfMusic play:)
				(proc0_21)
				(= local60 (Print 654 20 33 gSmallFont 67 -1 10 88))
				(self cue:)
			)
			(15
				(= local58 (- local58 7))
				([local1 local58] loop: 5 cel: 0 setCycle: End self)
				((= newView_2 (View new:))
					view: 500
					loop: 1
					cel: 2
					setPri: 12
					ignoreActors: 1
					posn: ([local1 local58] x?) (if [local1 (+ local58 3)] 136 else 133)
					addToPic:
				)
				(if (== local58 28)
					((= newView_3 (View new:))
						view: 500
						loop: 0
						cel: 0
						posn: (+ (newView_2 x?) 8) (- (newView_2 y?) 1)
						ignoreActors: 1
						setPri: 12
						init:
						stopUpd:
					)
					((gInv at: 1) moveTo: 54)
				)
			)
			(16
				([local1 local58]
					view: [local1 (+ local58 1)]
					setPri: -1
					cel: 0
					loop: 1
					posn: ([local1 (+ local58 6)] x?) (+ ([local1 (+ local58 6)] y?) 2)
					cycleSpeed: 0
					moveSpeed: 0
					setCycle: Walk
					setMotion: MoveTo 140 (+ ([local1 (+ local58 6)] y?) 2) self
				)
				([local1 (+ local58 6)] dispose:)
			)
			(17
				([local1 local58]
					setPri: ([local1 local58] priority?)
					setMotion: MoveTo 150 207 self
				)
			)
			(18
				([local1 local58] dispose:)
				(if local58 (= state 14))
				(self cue:)
			)
			(19
				(dwarfMusic loop: 1 changeState:)
				(proc0_21)
				(Print 654 21 33 gSmallFont 67 -1 20)
				(= newView_2 (View new:))
				(newView_2
					view: 500
					loop: 1
					cel: 2
					posn: (gEgo x?) 132
					setPri: 12
					ignoreActors:
					init:
				)
				(newView_2 addToPic:)
				(proc0_18)
				(gEgo
					ignoreActors: 0
					illegalBits: -32768
					posn: 270 135
					view: 4
					loop: 2
					setCycle: Walk
				)
				(self cue:)
			)
			(20
				(dwarfMusic dispose:)
				(User canControl: 1 canInput: 1)
				(= global205 0)
				(gRoom newRoom: 54)
			)
		)
	)
	
	(method (handleEvent pEvent &tmp gInvSaidMe)
		(return
			(cond 
				((pEvent claimed?) (return 1))
				((== (pEvent type?) evSAID)
					(cond 
						((Said 'look/dwarf,man') (Print 654 22))
						((Said 'look/table') (Print 654 23))
						((Said 'look/soup') (Print 654 24))
						((Said 'converse[/dwarf,man]') (tacodoco1 cue:))
						((or (Said 'get/soup') (Said 'get/bowl'))
							(cond 
								((== global176 0) (Print 654 25))
								((== global176 1) (Print 654 26))
								(else (Print 654 27))
							)
						)
						((Said 'kill/dwarf,man') (Print 654 28))
						((Said 'get/dwarf,man') (Print 654 29))
						(
						(or (Said 'kiss[/!*]') (Said 'kiss/dwarf,man')) (Print 654 30))
						((Said 'deliver>')
							(if
								(and
									(= gInvSaidMe (gInv saidMe:))
									(gEgo has: (gInv indexOf: gInvSaidMe))
								)
								(Print 654 31)
							else
								(pEvent claimed: 0)
							)
						)
						((or (Said 'chew/soup') (Said 'chew'))
							(switch global176
								(0
									(Print 654 32)
									(= global176 1)
								)
								(1 (Print 654 33))
								(2 (Print 654 27))
							)
						)
						((Said '(stand<up),(get<up),exit/table,chair') (Print 654 34))
					)
				)
			)
		)
	)
)

(instance tacodoco1 of Script
	(properties)
	
	(method (changeState newState)
		(switch (= state newState)
			(0 (Print 654 35))
			(1
				(Print 654 36)
				(Print 654 37)
			)
			(2 (Print 654 38))
			(3
				(Print 654 39)
				(= state 2)
			)
		)
	)
)

(instance eatOut of Script
	(properties)
	
	(method (changeState newState)
		(switch (= state newState)
			(0
				(gEgo
					posn: (gEgo x?) (- (gEgo y?) 8)
					setLoop: 0
					setCycle: End
				)
				(= seconds 7)
			)
			(1
				(proc0_21)
				(gEgo setLoop: 1 stopUpd:)
				(= local58 (* (Random 0 6) 7))
				(if (< (Random 1 10) 3) (gEgo setCycle: End))
				([local1 local58] setCycle: End self)
			)
			(2
				(if (> (gEgo cel?) 0) (gEgo setCycle: CT 0 1))
				([local1 local58] setCycle: CT 0 1 self)
			)
			(3
				([local1 local58] stopUpd:)
				(if (not local63)
					(= state 0)
					(self cue:)
				else
					(dwarfsInToEat cue:)
				)
			)
		)
	)
)
