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

(public
	Room69 0
)

(local
	newProp_2
	newView
	newProp
	newAct
	newAct_2
	local5
	local6
	local7
	local8
)
(instance fallMusic of Sound
	(properties
		number 51
	)
)

(instance mummyMusic of Sound
	(properties
		number 27
	)
)

(instance mummyBlock of Blk
	(properties
		top 110
		left 140
		bottom 122
		right 182
	)
)

(instance ladderSpace of Blk
	(properties
		top 146
		left 90
		bottom 152
		right 96
	)
)

(instance Room69 of Rm
	(properties
		picture 69
		style $0010
	)
	
	(method (init)
		(Load rsVIEW 520)
		(Load rsVIEW 522)
		(Load rsVIEW 195)
		(Load rsVIEW 196)
		(Load rsVIEW 197)
		(Load rsVIEW 4)
		(Load rsVIEW 38)
		(Load rsVIEW 519)
		(Load rsVIEW 683)
		(Load rsVIEW 44)
		(Load rsVIEW 41)
		(Load rsVIEW 40)
		(Load rsVIEW 42)
		(Load rsVIEW 37)
		(Load rsVIEW 39)
		(super init:)
		(= local7 0)
		(= local6 0)
		(= global101 1)
		((View new:)
			view: 522
			loop: 3
			cel: 0
			posn: 253 71
			addToPic:
		)
		((Prop new:)
			view: 522
			loop: 2
			cel: 0
			posn: 252 57
			init:
			setCycle: Fwd
		)
		((= newView (View new:))
			view: 520
			loop: 2
			cel: 0
			setPri: 7
			posn: 160 112
			init:
			stopUpd:
		)
		((= newProp (Prop new:))
			view: 520
			ignoreActors: 1
			setPri: 8
			loop: 0
			cel: 0
			posn: (- (newView x?) 4) (newView y?)
			init:
			stopUpd:
		)
		((= newProp_2 (Prop new:))
			view: 522
			setCel: (if global170 255 else 0)
			setPri: 11
			ignoreActors: 1
			posn: 98 87
			init:
		)
		((= newAct (Act new:))
			view: 195
			illegalBits: 0
			setPri: 7
			posn: (newView x?) (newView y?)
			init:
		)
		(if ((Inv at: 4) ownedBy: 69)
			((= newAct_2 (Act new:))
				view: 519
				illegalBits: 0
				ignoreActors: 0
				posn: 260 171
				init:
			)
		)
		(gEgo
			posn: 41 86
			view: 4
			loop: 0
			ignoreActors: 1
			setStep: 4 1
			illegalBits: -32768
			setPri: 11
			init:
		)
	)
	
	(method (doit)
		(super doit:)
		(if (& (gEgo onControl: 0) $0040)
			(User canControl: 1 canInput: 1)
			(gEgo setPri: -1)
			(gRoom newRoom: 18)
		)
		(if
			(and
				(& (gEgo onControl: 1) $0004)
				(== (gEgo script?) 0)
			)
			(User canControl: 0 canInput: 0)
			(gEgo setScript: cryptFall)
		)
	)
	
	(method (handleEvent pEvent)
		(return
			(cond 
				((pEvent claimed?) (return 1))
				((== (pEvent type?) evSAID)
					(cond 
						(
							(or
								(Said 'look[<around][/!*]')
								(Said 'look/room,crypt')
							)
							(Print
								(Format
									@global228
									69
									0
									(if (== global170 0)
										{A pile of rope is at the edge of the upper platform.}
									else
										{_}
									)
									(if (== ((Inv at: 4) owner?) 69)
										{You see an odd-looking, little chest here. It must be Pandora's Box.}
									else
										{_}
									)
								)
							)
						)
						((Said 'look>')
							(cond 
								((Said '/epitaph') (Print 69 1))
								(
									(and
										(Said '<in/casket[<elderly]')
										(< (gEgo distanceTo: newView) 25)
									)
									(Print 69 2)
								)
								((Said '/casket') (Print 69 3))
								(
								(or (Said '/hemp,ladder') (Said '/hemp[<heap]'))
									(if (== global170 0)
										(Print 69 4)
									else
										(Print 69 5)
									)
								)
								((Said '/platform')
									(if (== global170 0)
										(Print 69 4)
									else
										(Print 69 6)
									)
								)
								((Said '/wall') (Print 69 7))
								((or (Said '/dirt') (Said '<down'))
									(if (== ((Inv at: 4) owner?) 69)
										(Print 69 8)
									else
										(Print 69 9)
									)
								)
								((Said '/mummy') (if local8 (Print 69 10) else (Print 69 11)))
								((Said '/box[<pandora]')
									(cond 
										((== ((Inv at: 4) owner?) 69) (Print 69 8))
										((gEgo has: 4) (pEvent claimed: 0))
										(else (Print 69 12))
									)
								)
								(else (pEvent claimed: 0))
							)
						)
						((Said 'get,move,lower/hemp,ladder,heap')
							(cond 
								(global170 (Print 69 13))
								((> (gEgo distanceTo: newProp_2) 25) (Print 800 1))
								(else
									(Print 69 14)
									(gGame changeScore: 2)
									(User canControl: 0 canInput: 0)
									(gEgo setMotion: 0)
									(= local6 1)
									(newProp_2 setScript: DropRope)
								)
							)
						)
						((Said 'climb[/(hemp,ladder)]>')
							(cond 
								((not global170) (pEvent claimed: 1) (Print 800 3))
								((or (Said '<down') (not local7))
									(pEvent claimed: 1)
									(if (> (gEgo distanceTo: newProp_2) 20)
										(Print 800 1)
									else
										(gEgo setScript: DownLadder)
									)
								)
								((or (Said '<up') local7)
									(pEvent claimed: 1)
									(if (not (gEgo inRect: 99 142 120 158))
										(Print 800 1)
									else
										(gEgo ignoreBlocks: ladderSpace)
										(DownLadder changeState: 14)
									)
								)
							)
						)
						((Said 'get/box')
							(cond 
								((not local7) (Print 69 15))
								((gEgo has: 4) (Print 69 16))
								((!= ((Inv at: 4) owner?) 69) (Print 69 17))
								((> (gEgo distanceTo: newAct_2) 20) (Print 800 1))
								(else (gEgo setScript: stoop))
							)
						)
						((Said 'place,drop,return/box')
							(cond 
								((not (gEgo has: 4)) (Print 69 18))
								((not local7) (Print 69 15))
								(else (gEgo setScript: putBack))
							)
						)
						((Said 'open/box')
							(cond 
								((not (gEgo has: 4)) (Print 69 18))
								((not local7) (Print 69 19))
								(else (pEvent claimed: 0))
							)
						)
						((Said 'read/(epitaph,wall,casket,lid)') (Print 69 1))
						((Said 'get,rob,get,move/casket') (Print 69 20))
						((Said 'bang[<on]/casket')
							(if (< (gEgo distanceTo: newView) 15)
								(Print 69 21)
							else
								(Print 69 22 67 -1 10)
							)
						)
						((Said 'open/casket,lid')
							(cond 
								((not local7) (proc0_13))
								((newProp cel?) (Print 69 23 67 -1 10))
								(else (Print 69 2))
							)
						)
						((Said 'get,move/casket') (if local7 (Print 69 24) else (proc0_13)))
						((Said 'converse') (if local8 (Print 69 25) else (Print 69 26)))
						((Said '/mummy>')
							(cond 
								((not local8) (pEvent claimed: 1) (Print 69 11))
								((Said 'kill') (Print 69 27))
								((Said 'get,capture') (Print 69 28))
								((Said 'kiss') (Print 69 29))
								((Said 'help,save') (Print 69 30))
							)
						)
						((Said 'deliver/*/mummy') (if local8 (Print 69 31) else (Print 69 11)))
					)
				)
			)
		)
	)
	
	(method (newRoom newRoomNumber)
		(proc0_7)
		(super newRoom: newRoomNumber)
	)
)

(instance doMummy of Script
	(properties)
	
	(method (doit)
		(if
			(and
				(== (self state?) 2)
				(< (gEgo distanceTo: newAct) 25)
			)
			(newAct setMotion: 0)
			(self changeState: 3)
			(super doit:)
		)
	)
	
	(method (changeState newState)
		(switch (= state newState)
			(0
				(if (not (gEgo inRect: 138 110 192 125))
					(Print 69 32 67 -1 10 25 3)
					(gEgo observeBlocks: mummyBlock)
					(newProp priority: 8)
					(= local8 1)
					(newAct show:)
					(newProp setCycle: End self)
				else
					(-- state)
					(= seconds 5)
				)
			)
			(1 (newAct setCycle: End self))
			(2
				(newAct
					view: 196
					setCycle: Walk
					illegalBits: 0
					cycleSpeed: 0
					moveSpeed: 0
					setPri: 9
					setStep: 3 2
					setMotion: MoveTo 145 135 self
				)
				(mummyMusic play:)
			)
			(3
				(newProp ignoreActors: 0 stopUpd:)
				(if (gEgo has: 7)
					(Print 69 33 67 -1 10 25 4)
					(self changeState: 5)
				else
					(Print 69 34 67 -1 10 25 5)
					(self changeState: 20)
				)
			)
			(5
				(newAct
					setPri: 9
					ignoreActors: 1
					setMotion: MoveTo (newView x?) (newView y?) self
				)
			)
			(6
				(newAct view: 195 setPri: 7 loop: 0 setCycle: Beg self)
			)
			(7
				(newProp ignoreActors: 1 setCycle: Beg self)
			)
			(8
				(newAct hide:)
				(= local8 0)
				(mummyMusic dispose:)
				(newProp setPri: 7 stopUpd:)
				(= state -1)
				(client setScript: 0)
				(gEgo ignoreBlocks: mummyBlock)
			)
			(20
				(newAct moveSpeed: 0 setMotion: Chase gEgo 15 self)
			)
			(21
				(Print 69 35)
				(= global127 1)
			)
		)
	)
)

(instance DownLadder of Script
	(properties)
	
	(method (changeState newState)
		(switch (= state newState)
			(0
				(User canControl: 0 canInput: 0)
				(gEgo setMotion: 0)
				(self cue:)
			)
			(1
				(gEgo
					view: 38
					setLoop: 0
					illegalBits: 0
					posn: 98 87
					setPri: 14
					setCycle: End self
				)
			)
			(2
				(gEgo setLoop: 1 setCycle: End self)
			)
			(3
				(gEgo
					view: 39
					x: 98
					y: (+ (gEgo y?) 35)
					setLoop: 1
					cel: 0
					cycleSpeed: 0
					moveSpeed: 0
					setCycle: Rev
					setMotion: MoveTo 98 150 self
				)
			)
			(4
				(gEgo loop: 0 posn: 104 149 setCycle: Beg self)
			)
			(5
				(gEgo
					view: 4
					posn: 107 149
					setLoop: -1
					cycleSpeed: 0
					moveSpeed: 0
					loop: 1
					setPri: -1
					setCycle: Walk
					illegalBits: -32768
					ignoreActors: 0
				)
				(self cue:)
			)
			(6
				(= local7 1)
				(= local6 0)
				(gEgo observeBlocks: ladderSpace)
				(User canControl: 1 canInput: 1)
				(self cue:)
			)
			(7
				(if (== (newAct script?) 0)
					(newAct setScript: doMummy)
				)
			)
			(14
				(User canControl: 0 canInput: 0)
				(gEgo
					view: 39
					setLoop: 0
					setMotion: 0
					illegalBits: 0
					posn: 107 151
					script: DownLadder
					setCycle: End self
					forceUpd:
				)
			)
			(15
				(gEgo
					view: 39
					x: 98
					setPri: 11
					setLoop: 1
					cel: 0
					cycleSpeed: 0
					moveSpeed: 0
					ignoreActors: 1
					setCycle: Walk
					setMotion: MoveTo (+ (newProp_2 x?) 0) (+ (newProp_2 y?) 35) self
				)
			)
			(16
				(gEgo
					view: 38
					posn: 96 (newProp_2 y?)
					cycleSpeed: 0
					moveSpeed: 0
					setLoop: 1
					setCycle: Beg self
				)
			)
			(17 (self cue:))
			(18
				(gEgo
					view: 4
					posn: 80 87
					setLoop: -1
					setCycle: Walk
					illegalBits: -32768
				)
				(User canControl: 1 canInput: 1)
				(= state -1)
				(= local6 0)
				(= local7 0)
				(gEgo setScript: 0)
			)
		)
	)
)

(instance DropRope of Script
	(properties)
	
	(method (changeState newState)
		(switch (= state newState)
			(0
				(gEgo setMotion: MoveTo 70 88 self)
			)
			(1
				(gEgo view: 37 setLoop: 0 setCycle: End self)
			)
			(2
				(newProp_2 cycleSpeed: 1 setCycle: End self)
			)
			(3
				(newProp_2 stopUpd:)
				(= global170 1)
				(gEgo view: 41 loop: 0 cel: 255 setCycle: End self)
			)
			(4
				(gEgo view: 4 setLoop: -1 setCycle: Walk)
				(User canControl: 1 canInput: 1)
				(client setScript: 0)
			)
		)
	)
)

(instance cryptFall of Script
	(properties)
	
	(method (changeState newState)
		(switch (= state newState)
			(0
				(gEgo
					ignoreActors: 1
					illegalBits: 0
					setPri: (if (< (gEgo y?) 84) -1 else 12)
				)
				(self cue:)
			)
			(1
				(fallMusic play:)
				(gEgo view: 44 moveSpeed: 0 setLoop: 0 setCycle: End self)
			)
			(2
				(gEgo setLoop: 2 xStep: 10 yStep: 10 setCycle: Fwd)
				(if (< (gEgo y?) 84)
					(gEgo
						setMotion: MoveTo (+ (gEgo x?) 10) (+ (gEgo y?) 60) self
					)
				else
					(gEgo
						setMotion: MoveTo (+ (gEgo x?) 10) (+ (gEgo y?) 70) self
					)
				)
			)
			(3
				(gEgo view: 42 setLoop: 0 setCel: 0 setPri: -1)
				(proc0_18)
				(fallMusic dispose:)
				(ShakeScreen 5)
				(= seconds 1)
			)
			(4
				(Print 69 36 70 100 67 -1 10)
				(= seconds 4)
			)
			(5
				(client setScript: 0)
				(= global127 1)
			)
		)
	)
)

(instance stoop of Script
	(properties)
	
	(method (init param1)
		(super init: param1)
	)
	
	(method (changeState newState)
		(switch (= state newState)
			(0
				(proc0_8)
				(gEgo view: 40 cel: 255 setCycle: End self)
				(if (> (gEgo x?) (newAct_2 x?))
					(gEgo loop: 1)
				else
					(gEgo loop: 0)
				)
			)
			(1
				(gEgo get: 4)
				(newAct_2 dispose:)
				(if (not global218)
					(= global218 1)
					(= global182 1)
					(gGame changeScore: 4)
				)
				(if (== global169 0) (gGame changeScore: -2))
				(gEgo setCycle: Beg self)
			)
			(2
				(gEgo view: 4 setCycle: Walk)
				(proc0_9)
				(client setScript: 0)
			)
		)
	)
)

(instance putBack of Script
	(properties)
	
	(method (changeState newState)
		(switch (= state newState)
			(0
				(proc0_8)
				(gEgo view: 40 cel: 255 setCycle: End self)
				(if (> (gEgo x?) 160)
					(gEgo loop: 1)
				else
					(gEgo loop: 0)
				)
			)
			(1
				(gEgo put: 4 69)
				(if (== global169 0)
					(gSounds eachElementDo: #stop 0)
					((Sound new:) number: 50 play:)
					(gGame changeScore: 2)
				)
				((= newAct_2 (Act new:))
					view: 519
					posn:
						(if (> (gEgo x?) 160)
							(- (gEgo x?) 20)
						else
							(+ (gEgo x?) 20)
						)
						(gEgo y?)
					init:
				)
				(gEgo setCycle: Beg self)
			)
			(2
				(gEgo view: 4 setCycle: Walk)
				(proc0_9)
				(client setScript: 0)
			)
		)
	)
)
