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

(public
	Room10 0
)

(local
	[local0 2]
	local2
	local3
	newProp
	newProp_2
	newProp_3
)
(instance ogreTheme of Sound
	(properties
		number 5
		loop -1
	)
)

(instance Room10 of Rm
	(properties
		picture 10
	)
	
	(method (init)
		(= north 4)
		(= south 16)
		(= east 11)
		(= west 9)
		(= horizon 72)
		(= global101 0)
		(= global189 1)
		(super init:)
		(if global100 (gRoom overlay: 110))
		(self setRegions: 508 517)
		(switch gPrevRoomNum
			(16
				(if (< (gEgo x?) 63)
					(gEgo posn: 63 187)
				else
					(gEgo posn: (gEgo x?) 187)
				)
			)
			(4
				(if (< (gEgo x?) 200)
					(gEgo posn: 205 (+ horizon 2))
				else
					(gEgo posn: (gEgo x?) (+ horizon 2))
				)
			)
		)
		(= newProp (Prop new:))
		(newProp
			isExtra: 1
			view: 626
			loop: 0
			cel: 0
			posn: 233 25
			setPri: 0
			setCycle: Fwd
			cycleSpeed: 3
			init:
		)
		(cond 
			(
			(and (== gPrevRoomNum 4) gNewAct (not (gEgo has: 33)))
				(= gNewAct (Act new:))
				(Load rsVIEW 78)
				(Load rsVIEW 79)
				(gNewAct
					posn: 202 84
					view: 250
					xStep: 6
					yStep: 2
					setCycle: Walk
					ignoreActors:
					init:
				)
				(= local2 0)
				(self setScript: ogreActions)
				(ogreActions changeState: 1)
			)
			(
				(and
					(<= (Random 1 100) 40)
					(not gNewAct)
					(!= global165 4)
				)
				(Load rsVIEW 78)
				(Load rsVIEW 79)
				(= gNewAct (Act new:))
				(gNewAct
					posn: 19 181
					view: 250
					xStep: 6
					yStep: 2
					setCycle: Walk
					ignoreActors:
					init:
				)
				(self setScript: ogreActions)
			)
			(else (= gNewAct 0))
		)
		(if (== global165 4) (= global165 5))
		(gEgo view: 2 init:)
		(if (not global100)
			(if (< (Random 1 100) 50)
				(= newProp_2 (Prop new:))
				(newProp_2
					view: 342
					loop: 5
					cel: 1
					posn: 146 10
					setPri: 14
					setScript: bird1Actions
					init:
				)
			)
			(if (< (Random 1 100) 50)
				(= newProp_3 (Prop new:))
				(newProp_3
					view: 342
					loop: 4
					cel: 1
					posn: 65 54
					setPri: 14
					setScript: bird2Actions
					init:
				)
			)
		)
	)
	
	(method (handleEvent pEvent)
		(if (pEvent claimed?) (return 1))
		(return
			(if
			(and (== (pEvent type?) evSAID) (Said 'look>'))
				(cond 
					((Said '/cottage') (Print 10 0))
					((Said '[<around][/room]') (Print 10 1))
				)
			else
				0
			)
		)
	)
	
	(method (newRoom newRoomNumber)
		(= global189 0)
		(gTimers eachElementDo: #dispose 84)
		(if (gCast contains: gNewAct)
			(= gGNewActY (gNewAct y?))
		)
		(super newRoom: newRoomNumber)
	)
)

(instance ogreActions of Script
	(properties)
	
	(method (changeState newState)
		(switch (= state newState)
			(0 (= seconds (Random 1 6)))
			(1
				(if (== local2 0)
					(= local2 1)
					(ogreTheme play:)
					(gNewAct
						setAvoider: (Avoid new:)
						ignoreActors:
						setMotion: Chase gEgo 6 self
					)
					(= global189 1)
				)
			)
			(2
				(proc0_8)
				(gEgo hide:)
				(gNewAct view: 78 cel: 255 setCycle: End self)
			)
			(3
				(ogreTheme dispose:)
				(ogreTheme number: 6 loop: 1 play: self)
				(Print 10 2)
				(gNewAct view: 79 setCycle: Walk setMotion: MoveTo 200 80)
			)
			(4 (= global127 1))
		)
	)
)

(instance bird1Actions of Script
	(properties)
	
	(method (changeState newState)
		(switch (= state newState)
			(0
				(newProp_2 setCycle: Fwd)
				(= seconds (Random 1 12))
			)
			(1
				(newProp_2 setCycle: 0 cel: 0)
				(= seconds (Random 1 8))
			)
			(2 (self changeState: 0))
		)
	)
)

(instance bird2Actions of Script
	(properties)
	
	(method (changeState newState)
		(switch (= state newState)
			(0
				(newProp_3 setCycle: Fwd)
				(= seconds (Random 1 12))
			)
			(1
				(newProp_3 cel: 0 setCycle: 0)
				(= seconds (Random 1 8))
			)
			(2 (self changeState: 0))
		)
	)
)
