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

(public
	Room55 0
)
(synonyms
	(path ledge)
)

(local
	local0
	newAct
	local2
	newAct_2
	newAct_3
	local5
	newAct_4
	local7
	newAct_5
	local9
	newProp
	newProp_2
	newProp_3
	newProp_4
)
(instance Room55 of Rm
	(properties
		picture 55
		style $0010
		east 56
	)
	
	(method (init)
		(Load rsSCRIPT 991)
		(Load rsVIEW 4)
		(Load rsVIEW 44)
		(Load rsVIEW 41)
		(Load rsVIEW 518)
		(Load rsVIEW 18)
		(self setRegions: 600)
		(super init:)
		(= local0 0)
		(= global101 1)
		(if (or (== gPrevRoomNum 28) (== gPrevRoomNum 0))
			(gEgo
				posn: 100 82
				view: 4
				loop: 0
				xStep: 4
				yStep: 2
				ignoreActors: 0
				illegalBits: -32768
				init:
			)
		else
			(gEgo
				posn: 290 149
				view: 4
				xStep: 4
				yStep: 2
				ignoreActors: 0
				illegalBits: -32768
				init:
			)
		)
		(if global223
			((= newProp (Prop new:))
				view: 518
				posn: 60 67
				setPri: 5
				cel: 2
				cycleSpeed: 1
				setLoop: 3
				init:
				stopUpd:
			)
			((= newProp_2 (Prop new:))
				view: 518
				posn: 95 120
				setPri: 10
				cel: 1
				setLoop: 3
				init:
				stopUpd:
			)
			((= newProp_3 (Prop new:))
				view: 518
				posn: 220 89
				cycleSpeed: 1
				setLoop: 3
				init:
				stopUpd:
			)
			((= newProp_4 (Prop new:))
				view: 518
				posn: 245 48
				cel: 3
				setLoop: 3
				init:
				stopUpd:
			)
			(newProp setScript: sparkle)
		)
		(if (== global102 1)
			(Load rsVIEW 284)
			(Load rsVIEW 285)
			(Load rsVIEW 282)
			((= newAct (Act new:))
				view: 282
				illegalBits: 0
				posn: 219 153
				setLoop: 0
				init:
				setScript: Watch
			)
			((= newAct_2 (Act new:))
				isExtra: 1
				view: 284
				illegalBits: 0
				posn: 188 128
				setCycle: Fwd
				init:
			)
			((= newAct_3 (Act new:))
				isExtra: 1
				view: 285
				illegalBits: 0
				posn: 200 74
				setLoop: 1
				setCycle: Fwd
				init:
			)
		else
			(Load rsVIEW 289)
			(Load rsVIEW 286)
			(Load rsVIEW 287)
			(gEgo illegalBits: -32764)
			((View new:)
				view: 287
				loop: 2
				cel: 0
				posn: 213 129
				addToPic:
			)
			((View new:)
				view: 286
				loop: 5
				cel: 0
				posn: 233 129
				addToPic:
			)
			((= newAct_4 (Act new:))
				view: 287
				illegalBits: 0
				posn: 213 113
				setPri: 11
				setLoop: 0
				setCycle: Fwd
				cycleSpeed: 1
				ignoreActors: 1
				init:
			)
			((= newAct_5 (Act new:))
				view: 286
				illegalBits: 0
				posn: 233 113
				setPri: 11
				setLoop: 3
				setCycle: Fwd
				cycleSpeed: 2
				ignoreActors: 1
				init:
			)
			((= newAct (Act new:))
				view: 289
				illegalBits: 0
				posn: 60 107
				setCycle: Walk
				init:
				ignoreActors: 1
			)
			(newAct setScript: SendOut)
		)
	)
	
	(method (doit)
		(if (== (gEgo script?) 0) (gEgo setPri: -1))
		(if
			(and
				(& (gEgo onControl: 0) $0040)
				(!= (gEgo script?) Tripped)
			)
			(gRoom newRoom: 28)
		)
		(if
			(and
				(& (gEgo onControl: 1) $1000)
				(== local0 0)
				(== (gEgo script?) 0)
			)
			(gEgo setScript: WalkPath)
		)
		(if
			(and
				(or
					(& (gEgo onControl:) $0002)
					(& (gEgo onControl:) $1000)
				)
				(== local0 0)
				(== (gEgo script?) 0)
			)
			(gEgo setScript: WalkPath)
		)
		(if
			(and
				(& (gEgo onControl: 1) $0004)
				(== global102 1)
				(!= (gEgo script?) Tripped)
			)
			(gEgo setScript: Tripped)
		)
		(if
			(and
				(& (gEgo onControl:) $0010)
				(== (gEgo script?) 0)
			)
			(gEgo setPri: 12)
			(if
			(or (>= (gEgo heading?) 180) (== (gEgo heading?) 0))
				(= local0 0)
				(gEgo illegalBits: -32768)
			else
				(= local0 1)
				(gEgo illegalBits: -28672)
			)
			(if (> (gEgo x?) 121) (gEgo setPri: -1))
		)
		(super doit:)
	)
	
	(method (dispose)
		(DisposeScript 991)
		(super dispose:)
	)
	
	(method (handleEvent pEvent)
		(return
			(cond 
				((pEvent claimed?) (return 1))
				(
				(and (== (pEvent type?) evSAID) (Said 'look>'))
					(cond 
						((Said '/door') (Print 55 0))
						((Said '<out[/(mine[<diamond]),(door[<mine])]') (Print 55 1))
						((Said '[<around][/!*]') (Print 55 2))
						(
							(or
								(Said '<around')
								(Said '[<around]/room,mine<[diamond]')
							)
							(Print 55 2)
						)
					)
				)
			)
		)
	)
	
	(method (newRoom newRoomNumber)
		(gEgo ignoreActors: 0)
		(if (== newRoomNumber 28) ((ScriptID 600) keep: 0))
		(super newRoom: newRoomNumber)
	)
)

(instance SendOut of Script
	(properties)
	
	(method (changeState newState)
		(switch (= state newState)
			(0 (= seconds 3))
			(1
				(proc0_8)
				(Print 55 3)
				(newAct setPri: -1 setMotion: MoveTo 92 89)
				(gEgo
					illegalBits: 0
					ignoreActors: 1
					setMotion: MoveTo 101 81 self
				)
			)
			(2
				(gEgo setMotion: MoveTo 74 81 self)
			)
			(3
				(gEgo illegalBits: -32768)
				(= global205 1)
				(= global204 0)
				(gRoom newRoom: 28)
			)
		)
	)
)

(instance Tripped of Script
	(properties)
	
	(method (changeState newState &tmp [temp0 40])
		(switch (= state newState)
			(0
				(proc0_8)
				(gEgo
					illegalBits: 0
					setPri: (if (> (gEgo y?) 115) 11 else 10)
					ignoreActors: 1
					view: 44
					setStep: 10 20
					setLoop: 2
					setCycle: Fwd
					setMotion:
						JumpTo
						(if (< (gEgo x?) 100) 100 else (+ (gEgo x?) 20))
						149
						self
				)
			)
			(1
				(gEgo view: 18 setLoop: 1 cel: 0 setCycle: Fwd)
				(= seconds 5)
			)
			(2
				(gEgo view: 41 setLoop: 0 cel: 255 setCycle: End self)
			)
			(3
				(= local0 1)
				(gEgo
					view: 4
					setStep: 4 2
					setCycle: Walk
					setLoop: -1
					setPri: -1
					illegalBits: -28672
					ignoreActors: 0
				)
				(= state 0)
				(client setScript: 0)
				(proc0_9)
			)
		)
	)
)

(instance WalkPath of Script
	(properties)
	
	(method (doit)
		(cond 
			(
				(and
					(or
						(& (gEgo onControl:) $0002)
						(& (gEgo onControl:) $1000)
					)
					(== local0 0)
				)
				(gEgo setPri: 13)
				(if (& (gEgo onControl: 0) $0008)
					(gEgo setScript: Tripped)
				)
			)
			((not (& (gEgo onControl: 1) $0010))
				(gEgo setPri: -1)
				(if (== (gEgo script?) WalkPath) (gEgo setScript: 0))
			)
		)
	)
)

(instance Watch of Script
	(properties)
	
	(method (changeState newState)
		(switch (= state newState)
			(0 (newAct setCycle: End self))
			(1 (= seconds 5))
			(2
				(newAct setCel: 0)
				(= seconds 10)
				(= state -1)
			)
		)
	)
)

(instance sparkle of Script
	(properties)
	
	(method (changeState newState)
		(switch (= state newState)
			(0
				(switch (Random 1 4)
					(1 (newProp setCycle: End self))
					(2
						(newProp_2 setCycle: End self)
					)
					(3
						(newProp_3 setCycle: End self)
					)
					(4
						(newProp_4 setCycle: End self)
					)
				)
			)
			(1
				(newProp stopUpd:)
				(newProp_2 stopUpd:)
				(newProp_3 stopUpd:)
				(newProp_4 stopUpd:)
				(= state -1)
				(self cue:)
			)
		)
	)
)
