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

(public
	Room3 0
)
(synonyms
	(cupid cupid cupid cupid man cupid cupid animal cupid boy baby)
	(kiss kiss embrace)
)

(local
	local0
	local1
	local2
	local3
	local4
	local5
	local6
	newView
	newProp
	newAct
)
(instance fallSound of Sound
	(properties)
)

(instance cupidCage of Cage
	(properties)
)

(instance theme of Sound
	(properties
		number 9
	)
)

(instance Room3 of Rm
	(properties
		picture 3
	)
	
	(method (init)
		(= north 27)
		(= south 9)
		(= east 4)
		(= west 2)
		(= horizon 75)
		(= global101 0)
		(self setRegions: 507)
		(super init:)
		(gEgo view: 2 init:)
		(gEgo edgeHit: 0 setScript: fall)
		(if global100 (gRoom overlay: 103))
		(gRoom setScript: egoActions)
		(Load rsVIEW 7)
		(Load rsVIEW 5)
		(Load rsVIEW 6)
		(Load rsVIEW 19)
		(Load rsVIEW 17)
		(Load rsVIEW 21)
		(Load rsSOUND 51)
		(Load rsSOUND 9)
		(cupidCage
			top: 118
			left: 118
			bottom: 135
			right: 235
			init:
		)
		(= newProp (Prop new:))
		(newProp
			isExtra: 1
			view: 650
			loop: 0
			cel: 1
			posn: 209 132
			setCycle: Fwd
			cycleSpeed: 0
			ignoreActors:
			init:
		)
		(if
			(and
				(<= (Random 1 100) 33)
				((Inv at: 14) ownedBy: 202)
			)
			(= newAct (Act new:))
			(newAct
				view: 160
				posn: 5 71
				illegalBits: 0
				setPri: 7
				ignoreHorizon:
				setCycle: Fwd
				xStep: 4
				yStep: 2
				init:
			)
			(newAct setScript: doCupid)
		)
		(if ((Inv at: 14) ownedBy: 3)
			((Inv at: 14) moveTo: 202)
		)
		(switch gPrevRoomNum
			(2
				(if (<= (gEgo y?) horizon)
					(gEgo x: 1 y: (+ horizon (gEgo yStep?) 1))
				else
					(gEgo x: 1)
				)
			)
			(4
				(if (< (gEgo y?) horizon)
					(gEgo posn: 318 (+ horizon (gEgo yStep?) 1))
				else
					(gEgo posn: 318 (gEgo y?))
				)
			)
			(9 (gEgo y: 187))
			(27
				(gEgo posn: (gEgo x?) (+ horizon 2))
			)
			(0 (gEgo x: 98 y: 176))
		)
	)
	
	(method (handleEvent pEvent)
		(if (pEvent claimed?) (return 1))
		(return
			(if (== (pEvent type?) evSAID)
				(cond 
					((Said 'look<under,in/water') (Print 3 0))
					((or (Said 'look/pool') (Said 'look/water'))
						(if (== (gEgo view?) 2)
							(Print 3 1)
						else
							(Print 3 2)
						)
					)
					(
						(or
							(Said 'look/room')
							(Said 'look/around')
							(Said 'look[<around][/!*]')
						)
						(if (== (gEgo view?) 2)
							(Print 3 3)
						else
							(Print 3 4)
						)
					)
					(
						(or
							(Said 'fish<enter')
							(Said 'capture/fish')
							(Said 'cast/pole')
						)
						(Print 3 5)
					)
					((Said 'look/column') (Print 3 6))
					((Said 'get/water') (Print 3 7))
					(
						(or
							(Said 'enter/bathe')
							(Said 'bathe,dive')
							(Said 'enter/bathe')
						)
						(if (== (gEgo view?) 2)
							(Print 3 8)
						else
							(Print 3 9)
						)
					)
					((Said 'look/stair') (Print 3 10))
					((Said 'exit,(climb,get<out)')
						(if (!= (gEgo view?) 2)
							(Print 3 10)
						else
							(Print 3 11)
						)
					)
					((Said 'hop,dive/pool,water') (Print 3 12))
					((or (Said 'drink') (Said 'get/drink'))
						(cond 
							((!= (gEgo view?) 2) (Print 3 13))
							((& (= local0 (proc0_2 gEgo 20)) $0008) (= local4 1) (egoActions changeState: 10))
							(else (Print 800 1))
						)
					)
					((Said 'get/arrow,arrow')
						(cond 
							(
								(and
									((Inv at: 14) ownedBy: 3)
									(or (== local1 2) (== local1 1) (== local1 7))
								)
								(if (< (gEgo distanceTo: newView) 10)
									((Inv at: 14) moveTo: gEgo)
									(gGame changeScore: 2)
									(egoActions changeState: 1)
								else
									(Print 800 1)
								)
							)
							((gEgo has: 14) (Print 3 14))
							(
								(and
									(not (gCast contains: newAct))
									(not ((Inv at: 14) ownedBy: 3))
								)
								(Print 3 15)
							)
							((!= local1 2) (Print 3 16))
							((gEgo has: 14) (Print 3 17))
							(else (Print 3 18))
						)
					)
					((Said 'rob/arrow') (Print 3 19))
					((Said 'look/dirt')
						(if ((Inv at: 14) ownedBy: 3)
							(Print 3 20)
						else
							(Print 3 21)
						)
					)
				)
			else
				0
			)
		)
	)
	
	(method (newRoom newRoomNumber)
		(if ((Inv at: 14) ownedBy: 3)
			((Inv at: 14) moveTo: 202)
		)
		(super newRoom: newRoomNumber)
	)
)

(instance fall of Script
	(properties)
	
	(method (doit)
		(super doit:)
		(cond 
			((and (== local3 0) (== local4 0))
				(cond 
					(
						(and
							(& (gEgo onControl: 0) $0004)
							(== (gEgo view?) 2)
						)
						(= local3 1)
						(fall changeState: 1)
					)
					(
					(and (== (gEgo onControl: 1) 1) (!= (gEgo view?) 21)) (gEgo view: 2))
					((& (gEgo onControl: 1) $0800) (gEgo view: 5))
					((& $0200 (gEgo onControl: 1)) (gEgo view: 6))
					((& $0008 (gEgo onControl: 1)) (gEgo view: 7))
					((& $0010 (gEgo onControl: 0)) (gEgo view: 2))
				)
			)
			(
				(and
					(== (gEgo onControl: 1) 4096)
					(< (fall state?) 2)
				)
				(gEgo setMotion: 0)
				(self changeState: 2)
				(if (gTimers contains: local5)
					(local5 dispose: delete:)
				)
			)
		)
	)
	
	(method (changeState newState)
		(switch (= state newState)
			(1
				(gSounds eachElementDo: #stop 1)
				(fallSound number: 51 play:)
				(proc0_8)
				(gEgo
					view: 17
					loop: (+ (& (gEgo loop?) $0001) 2)
					illegalBits: 0
					setCycle: Fwd
				)
				(= local5 (Timer setCycle: self 20))
				(gEgo xStep: 8 yStep: 4 setMotion: MoveTo 170 122)
			)
			(2
				(gEgo
					view: 19
					setMotion: 0
					loop: (& (gEgo loop?) $0001)
					cel: 255
					setCycle: End self
				)
				(gEgo setStep: 3 2)
			)
			(3
				(= local3 0)
				(gEgo view: 7)
				(gEgo
					illegalBits: -1
					ignoreControl: 8 4096
					setCycle: Walk
				)
				(= seconds 2)
			)
			(4
				(gEgo illegalBits: -32768)
				(proc0_9)
				(self changeState: 0)
			)
		)
	)
)

(instance doCupid of Script
	(properties)
	
	(method (init param1)
		(Load rsVIEW 160)
		(Load rsVIEW 161)
		(Load rsVIEW 162)
		(Load rsVIEW 163)
		(Load rsVIEW 165)
		(Load rsVIEW 166)
		(Load rsVIEW 167)
		(Load rsVIEW 509)
		(super init: param1)
	)
	
	(method (doit)
		(super doit:)
		(if
			(and
				(== state 5)
				(or
					(gEgo inRect: 220 100 305 140)
					(< (gEgo distanceTo: newAct) 48)
				)
			)
			(if (and (> (gEgo x?) 210) (< (gEgo y?) 140))
				(self changeState: 30)
			else
				(self changeState: 20)
			)
		)
	)
	
	(method (changeState newState)
		(switch (= state newState)
			(0
				(= local1 0)
				(theme play:)
				(newAct ignoreActors: setMotion: MoveTo 164 70 self)
			)
			(1
				(if (gEgo inRect: 171 101 317 183)
					(self changeState: 10)
				else
					(newAct setPri: -1 setMotion: MoveTo 250 119 self)
				)
			)
			(2
				(= local1 3)
				(newAct
					view: 162
					ignoreActors: 0
					setLoop: 0
					cel: 255
					setCycle: End self
				)
			)
			(3
				(newAct setLoop: 2 cel: 255 setCycle: End self)
			)
			(4
				(newAct
					ignoreActors: 1
					view: 165
					xStep: 6
					setLoop: 1
					setCycle: End
				)
				(= newView (View new:))
				((Inv at: 14) moveTo: 3)
				(newView
					ignoreActors:
					view: 509
					x: (+ (newAct x?) 10)
					y: (newAct y?)
					stopUpd:
					init:
				)
				(newAct setMotion: MoveTo 206 126 self)
			)
			(5
				(= local1 4)
				(newAct
					view: 167
					setLoop: -1
					observeControl: 1
					xStep: 1
					yStep: 1
					loop: 1
					cycleSpeed: 1
					setCycle: Fwd
					setMotion: Wander 6
					moveSpeed: 1
				)
				(newAct observeBlocks: cupidCage)
				(= local6 (Timer setReal: self 15))
			)
			(6
				(= local1 5)
				(self changeState: 40)
			)
			(10
				(newAct setMotion: MoveTo 61 83 self)
				(if (gTimers contains: local6)
					(local6 dispose: delete:)
				)
			)
			(11
				(newAct setMotion: MoveTo 4 72 self)
			)
			(12 (newAct dispose:))
			(20
				(Print 3 35)
				(if (gTimers contains: local6)
					(local6 dispose: delete:)
				)
				(newAct ignoreBlocks: cupidCage)
				(newAct
					ignoreControl: 1
					setLoop: 0
					xStep: 3
					yStep: 2
					moveSpeed: 0
					setMotion: MoveTo 230 129 self
				)
				(= local1 2)
			)
			(21
				(newAct view: 166 setCel: 0)
				(newAct setMotion: MoveTo 240 129)
				(newAct cycleSpeed: 0 setCycle: End self)
			)
			(22
				(newAct view: 164 cel: 255 setLoop: 1 setCycle: End self)
			)
			(23
				(newAct
					view: 161
					xStep: 4
					yStep: 3
					setPri: 7
					setLoop: 1
					setCycle: Fwd
					setMotion: MoveTo 168 70 self
				)
			)
			(24
				(newAct setMotion: MoveTo 41 70 self)
			)
			(25 (newAct dispose:))
			(30
				(Print 3 35)
				(if (gTimers contains: local6)
					(local6 dispose: delete:)
				)
				(newAct
					ignoreBlocks: cupidCage
					ignoreControl: 1
					xStep: 6
					yStep: 2
					setLoop: 1
					moveSpeed: 0
					setMotion: MoveTo 100 129 self
				)
				(= local1 2)
			)
			(31
				(newAct xStep: 3 setMotion: MoveTo 85 129)
				(newAct view: 166 setLoop: 1 cel: 255 setCycle: End self)
			)
			(32
				(newAct posn: 80 124 loop: 3 setCycle: End self)
			)
			(33
				(newAct view: 164 cel: 255 setLoop: 1 setCycle: End self)
			)
			(34
				(= local1 1)
				(newAct
					view: 161
					xStep: 4
					yStep: 3
					setPri: 7
					setLoop: 1
					setCycle: Fwd
					setMotion: MoveTo 41 70 self
				)
			)
			(35 (self changeState: 11))
			(40
				(newAct ignoreBlocks: cupidCage)
				(newAct
					ignoreControl: 1
					setLoop: 0
					xStep: 3
					yStep: 2
					moveSpeed: 0
					setMotion: MoveTo 230 129 self
				)
				((Inv at: 14) moveTo: 202)
			)
			(41
				(newAct view: 166 setCel: 0)
				(newAct setMotion: MoveTo 240 129)
				(newAct cycleSpeed: 0 setCycle: End self)
			)
			(42
				(newAct
					ignoreActors:
					posn: (- (newView x?) 10) (- (newView y?) 4)
				)
				(newAct view: 163 loop: 0 cel: 255 setCycle: CT 5 1 self)
			)
			(43
				(newView dispose:)
				(newAct cel: 6 setCycle: End self)
			)
			(44
				(= local1 0)
				(newAct view: 160 setLoop: 1 setCel: 0 setCycle: Fwd)
				(newAct setPri: 7 setMotion: MoveTo 171 80 self)
			)
			(45 (self changeState: 10))
		)
	)
	
	(method (handleEvent pEvent &tmp gInvSaidMe)
		(if (pEvent claimed?) (return 1))
		(return
			(if (== (pEvent type?) evSAID)
				(cond 
					((Said 'look/cupid')
						(cond 
							((== local1 0) (Print 3 22))
							((== local1 4) (Print 3 23))
							((== local1 1) (Print 3 24))
							((== local1 2) (Print 3 25))
							((== local1 3) (Print 3 26))
							((== local1 5) (Print 3 27))
						)
					)
					((Said 'play/cupid') (Print 3 28))
					((Said 'get/cupid') (Print 3 29))
					((Said 'kiss') (Print 3 30))
					((Said 'converse')
						(cond 
							((not (gCast contains: newAct)) (pEvent claimed: 0))
							((== local1 0) (Print 3 31))
							((== local1 2) (Print 3 32))
							((== local1 4)
								(if (< (gEgo distanceTo: newAct) 40)
									(Print 3 33)
									(if (and (> (gEgo x?) 210) (< (gEgo y?) 140))
										(self changeState: 30)
									else
										(self changeState: 20)
									)
								else
									(Print 3 31)
								)
							)
							(else (Print 3 31))
						)
					)
					(
					(and (Said 'deliver>') (= gInvSaidMe (gInv saidMe:)))
						(if (gEgo has: (gInv indexOf: gInvSaidMe))
							(Print 3 34)
						else
							(proc0_17)
						)
					)
				)
			else
				0
			)
		)
	)
)

(instance egoActions of Script
	(properties)
	
	(method (changeState newState)
		(switch (= state newState)
			(1
				(proc0_8)
				(proc0_3 gEgo newView)
				(gEgo view: 21 setMotion: 0 cel: 255 setCycle: End self)
			)
			(2
				(= global182 1)
				(newView dispose:)
				(gEgo setCycle: Beg self)
			)
			(3
				(gEgo view: 2 setCycle: Walk)
				(proc0_9)
			)
			(10
				(proc0_8)
				(gEgo view: 21 cel: 255 setCycle: End self)
			)
			(11
				(= seconds 5)
				(= global120 (Print 3 36 67 -1 10 88))
			)
			(12 (gEgo setCycle: Beg self))
			(13
				(proc0_21)
				(proc0_9)
				(gEgo view: 2 setCycle: Walk)
				(= local4 0)
			)
		)
	)
)
