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

(public
	Room84 0
)

(local
	newView
	newAct
)
(instance chickenMusic of Sound
	(properties
		number 79
		priority 1
		loop -1
	)
)

(instance Room84 of Rm
	(properties
		picture 84
		style $0010
	)
	
	(method (init)
		(self setRegions: 604)
		(Load rsVIEW 360)
		(Load rsVIEW 519)
		(Load rsVIEW 649)
		(Load rsVIEW 634)
		(Load rsVIEW 512)
		(Load rsVIEW 40)
		(Load rsSOUND 79)
		(super init:)
		((View new:)
			view: 634
			loop: 1
			cel: 0
			posn: 31 77
			setPri: 4
			init:
			addToPic:
		)
		((View new:)
			view: 634
			loop: 1
			cel: 0
			posn: 71 78
			setPri: 4
			init:
			addToPic:
		)
		(if global100
			((View new:)
				view: 649
				loop: 1
				posn: 102 66
				setPri: 3
				init:
				addToPic:
			)
			((View new:)
				view: 649
				loop: 1
				posn: 138 66
				setPri: 3
				init:
				addToPic:
			)
			((View new:)
				view: 649
				loop: 1
				posn: 177 66
				setPri: 3
				init:
				addToPic:
			)
			((View new:)
				view: 649
				loop: 1
				posn: 215 66
				setPri: 3
				init:
				addToPic:
			)
			((Prop new:)
				view: 512
				loop: 0
				posn: 33 65
				setPri: 3
				init:
				setCycle: Fwd
			)
			((Prop new:)
				view: 512
				loop: 0
				posn: 73 66
				setPri: 3
				init:
				setCycle: Fwd
			)
		)
		(if (== ((gInv at: 4) owner?) 84)
			((= newView (View new:))
				view: 519
				ignoreActors: 0
				posn: 200 135
				init:
			)
		)
		(if (== ((gInv at: 33) owner?) 84)
			((= newAct (Act new:))
				view: 360
				illegalBits: 0
				posn: 80 133
				init:
				setScript: henPacing
			)
			(chickenMusic play:)
		)
		(if (or (== gPrevRoomNum 87) (== gPrevRoomNum 0))
			(gEgo posn: 157 162 view: 4 xStep: 4 yStep: 2 init:)
			(if global175 (= global175 0))
		)
	)
	
	(method (doit)
		(super doit:)
		(if (& (gEgo onControl: 0) $0040)
			(gRoom newRoom: 87)
		)
	)
	
	(method (handleEvent pEvent &tmp [temp0 80])
		(return
			(cond 
				((pEvent claimed?) (return 1))
				((== (pEvent type?) evSAID)
					(cond 
						(
						(or (Said 'look[<around][/!*]') (Said 'look/room'))
							(Print 84 0)
							(cond 
								(
									(and
										(== ((gInv at: 4) owner?) 84)
										(== ((gInv at: 33) owner?) 84)
									)
									(Print 84 1)
								)
								((== ((gInv at: 33) owner?) 84) (Print 84 2))
								((== ((gInv at: 4) owner?) 84) (Print 84 3))
								(else (Print 84 4))
							)
						)
						((Said 'look>')
							(cond 
								((Said '/box') (Print 84 5))
								((Said '/barrel') (Print 84 6))
								((Said '/chest') (Print 84 7))
								((Said '/shelf') (Print 84 8))
								((Said '/bone') (Print 84 9))
								((Said '/window') (Print 84 10))
								((Said '/wall') (Print 84 11))
								((or (Said '/dirt') (Said '<down')) (Print 84 12))
								((Said '/chicken')
									(if (== ((gInv at: 33) owner?) 84)
										(Print 84 13)
									else
										(Print 84 14 67 -1 10)
									)
								)
							)
						)
						((Said 'get>')
							(cond 
								((Said '/box<pandora')
									(cond 
										((gEgo has: 4) (Print 800 0))
										((!= ((gInv at: 4) owner?) 84) (Print 84 15))
										((< (gEgo distanceTo: newView) 20)
											(gEgo get: 4)
											(gGame changeScore: 2)
											(egoPickUp changeState: 0)
											(newView dispose:)
										)
										(else (Print 800 1))
									)
								)
								((Said '/chicken')
									(cond 
										((gEgo has: 33) (Print 84 16))
										((!= ((gInv at: 33) owner?) 84) (Print 84 15))
										((< (gEgo distanceTo: newAct) 20)
											(chickenMusic dispose:)
											(gEgo get: 33)
											(gGame changeScore: 2)
											(egoPickUp changeState: 0)
											(newAct dispose:)
										)
										(else (Print 800 1))
									)
								)
								((Said '/box') (Print 84 5))
								((Said '/chest') (Print 84 7))
								((Said 'open/window') (Print 84 17))
								((Said 'break/window') (Print 84 18))
								((Said '/bone') (Print 84 9))
							)
						)
						((Said 'open>')
							(cond 
								((Said '/box<pandora') (pEvent claimed: 0))
								((Said '/box') (Print 84 5))
								((Said '/barrel') (Print 84 6))
								((Said '/chest') (Print 84 7))
							)
						)
					)
				)
			)
		)
	)
)

(instance egoPickUp of Script
	(properties)
	
	(method (changeState newState)
		(switch (= state newState)
			(0
				(= global182 1)
				(User canControl: 0 canInput: 0)
				(gEgo view: 40 cel: 255 setMotion: 0 setCycle: End self)
			)
			(1
				(gEgo view: 4 setCycle: Walk)
				(User canControl: 1 canInput: 1)
			)
		)
	)
)

(instance henPacing of Script
	(properties)
	
	(method (init param1)
		(super init: param1)
	)
	
	(method (changeState newState)
		(switch (= state newState)
			(0
				(if (gCast contains: newAct)
					(newAct loop: (+ (newAct loop?) 2) setCycle: End self)
				)
			)
			(1
				(if (gCast contains: newAct)
					(newAct
						setCycle: Walk
						setMotion:
							MoveTo
							(if (> (newAct x?) 87)
								(Random 67 85)
							else
								(Random 90 120)
							)
							134
							self
					)
				)
			)
			(2 (= state -1) (self cue:))
		)
	)
)
