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

(public
	regPan 0
)
(synonyms
	(kiss kiss embrace)
	(pan pan pan man pan pan person animal pan)
)

(local
	local0
	local1
	local2
	newProp_2
	newProp
	local5
)
(instance panCage of Cage
	(properties)
)

(instance panTheme of Sound
	(properties)
)

(instance luteMusic of Sound
	(properties
		number 54
	)
)

(instance regPan of Rgn
	(properties)
	
	(method (init)
		(super init:)
		(if ((Inv at: 0) ownedBy: 201)
			(= local0 157)
			(= local5
				(+
					(* (- global160 global211) 60)
					(- global159 global212)
				)
			)
			(if (and (<= (Random 1 100) 40) (>= local5 2))
				(panCage
					left: 0
					right: 319
					bottom: 189
					top: (gRoom horizon?)
					init:
				)
				(Load rsVIEW 157)
				(if (gEgo has: 9) (Load rsVIEW 54) (Load rsVIEW 150))
				(= gNewAct_5 (Act new:))
				(gNewAct_5
					posn: (Random 10 300) (Random (+ (gRoom horizon?) 20) 169)
					xStep: 2
					yStep: 1
					setCycle: Fwd
					observeBlocks: panCage
					setScript: panActions
					setMotion: Wander 1500
					view: local0
					init:
					yourself:
				)
				(= newProp (Prop new:))
				(newProp
					view: 888
					cycleSpeed: 1
					ignoreActors:
					setCycle: Fwd
					init:
				)
				(panTheme number: 7 loop: -1 play:)
			else
				(= gNewAct_5 0)
			)
		else
			(= gNewAct_5 0)
		)
	)
	
	(method (doit)
		(super doit:)
		(if (gCast contains: gNewAct_5)
			(if
				(or
					(== (gNewAct_5 view?) 158)
					(== (gNewAct_5 view?) 157)
				)
				(newProp
					setPri: (gNewAct_5 priority?)
					x: (+ (gNewAct_5 x?) 8)
					y: (- (gNewAct_5 y?) 22)
				)
			)
			(if (not (gNewAct_5 inRect: 0 0 319 219))
				(gNewAct_5 dispose:)
				(if (IsObject newProp) (newProp dispose:))
				(panTheme loop: 1 changeState:)
			)
		)
	)
	
	(method (dispose)
		((ScriptID 0 4) dispose: delete:)
		(super dispose:)
	)
	
	(method (handleEvent pEvent &tmp gInvSaidMe)
		(if (pEvent claimed?) (return 1))
		(return
			(if
				(and
					(== (pEvent type?) evSAID)
					(gCast contains: gNewAct_5)
				)
				(cond 
					((Said 'play/lute')
						(if (gEgo has: 9)
							(if (== (gNewAct_5 view?) 157)
								(gEgo setScript: playLute)
								(playLute changeState: 1)
							else
								(Print 514 0)
							)
						else
							(Print 800 2)
						)
					)
					((Said 'play/flute')
						(if (gEgo has: 0)
							(if (== (panTheme state?) 3)
								(Print 514 1)
							else
								(pEvent claimed: 0)
							)
						else
							(Print 800 2)
						)
					)
					((Said 'hum') (Print 514 2))
					((Said 'kill/pan') (Print 514 3))
					((Said 'play<with/pan') (Print 514 4))
					((Said 'dance') (Print 514 5))
					((Said 'get/pan') (Print 514 6))
					((Said 'capture/pan') (Print 514 7))
					((Said 'deliver/lute')
						(if (gEgo has: 9)
							(if local2
								(if (< (gEgo distanceTo: gNewAct_5) 22)
									((Inv at: 9) moveTo: 201)
									(Print 514 8)
									((Inv at: 0) moveTo: gEgo)
									(gGame changeScore: 3)
									(gEgo setMotion: 0)
									(gNewAct_5 view: 158 setMotion: Wander 3000)
									(= local0 158)
									(panTheme number: 8 loop: -1 play:)
									(newProp show:)
								else
									(Print 800 1)
								)
							else
								(Print 514 9)
							)
						else
							(Print 800 2)
						)
					)
					((Said 'deliver>')
						(if (= gInvSaidMe (gInv saidMe:))
							(if (gEgo has: (gInv indexOf: gInvSaidMe))
								(Print 514 10)
							else
								(proc0_17)
							)
						else
							(Print 514 11)
							(pEvent claimed: 1)
						)
					)
					((Said 'kiss') (Print 514 12))
					((== (gNewAct_5 view?) 157)
						(cond 
							((Said 'look/pan') (Print 514 13))
							((Said 'converse[/pan]') (Print 514 14))
							((Said 'get/flute') (Print 514 15))
							((Said 'rob/flute') (Print 514 16))
						)
					)
					((== (gNewAct_5 view?) 158)
						(cond 
							((Said 'get,rob/lute') (Print 514 17))
							((Said 'look/pan') (Print 514 18))
							((Said 'converse[/pan]') (Print 514 19))
						)
					)
					((== (gNewAct_5 view?) 150)
						(cond 
							((Said 'converse[/pan]') (Print 514 20))
							((Said 'look/pan') (Print 514 21))
							((Said 'get/flute') (Print 514 15))
						)
					)
				)
			else
				0
			)
		)
	)
)

(instance playLute of Script
	(properties)
	
	(method (changeState newState)
		(switch (= state newState)
			(1
				(proc0_8)
				(panTheme client: 0 stop:)
				(luteMusic play: self)
				(gEgo view: 54 setLoop: 0 setCycle: Fwd)
				(= newProp_2 (Prop new:))
				(newProp_2
					view: 888
					setPri: (gEgo priority?)
					cycleSpeed: 1
					setCycle: Fwd
					posn: (+ (gEgo x?) 15) (- (gEgo y?) 25)
					init:
				)
				(gNewAct_5
					view: 150
					setAvoider: Avoid
					setCycle: Walk
					setMotion: Follow gEgo 55
				)
				(newProp hide:)
			)
			(2
				(Print 514 21 67 -1 10 83)
				(gEgo view: 2 setLoop: -1 setCycle: Walk)
				(if (IsObject newProp_2) (newProp_2 dispose:))
				(proc0_3 gEgo gNewAct_5)
				(= local2 1)
				(proc0_9)
			)
		)
	)
)

(instance panActions of Script
	(properties)
	
	(method (changeState newState)
		(switch (= state newState)
			(0 (= seconds 25))
			(1
				(gNewAct_5 ignoreBlocks: panCage)
			)
		)
	)
)
