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

(public
	regMinstrel 0
	notes 1
)
(synonyms
	(man man man man boy person bard)
	(kiss kiss embrace)
)

(local
	local0
	local1
)
(instance thisSong of Sound
	(properties)
)

(instance notes of Prop
	(properties)
	
	(method (cue)
		(notes dispose:)
	)
)

(instance regMinstrel of Rgn
	(properties)
	
	(method (init)
		(super init:)
		(if
			(or
				(and (== gCurRoomNum 13) (== global118 1))
				(and (== gCurRoomNum 14) (== global118 2))
				(and (== gCurRoomNum 19) (== global118 3))
			)
			(gNewAct_2 setScript: minstrelActions)
			(notes
				view: 888
				ignoreActors:
				cycleSpeed: 1
				setCycle: Fwd
				posn: (+ (gNewAct_2 x?) 16) (- (gNewAct_2 y?) 20)
				init:
			)
			(thisSong number: 19 play: minstrelActions)
			(minstrelActions changeState: 1)
		)
		(= global189 1)
	)
	
	(method (dispose)
		(= global189 0)
		(thisSong dispose:)
		(super dispose:)
	)
	
	(method (handleEvent pEvent &tmp gInvSaidMe)
		(super handleEvent: pEvent)
		(if (pEvent claimed?) (return 1))
		(return
			(if
				(and
					(== (pEvent type?) evSAID)
					(gCast contains: gNewAct_2)
				)
				(cond 
					((Said 'get/man') (Print 516 0))
					((Said 'kiss') (Print 516 1))
					((Said 'deliver>')
						(cond 
							((Said '/book')
								(if (gEgo has: 18)
									(if (>= (gEgo distanceTo: gNewAct_2) 25)
										(Print 516 2)
									else
										(gSounds eachElementDo: #stop 0)
										(minstrelActions changeState: 10)
									)
								else
									(proc0_17)
								)
							)
							(
								(and
									(= gInvSaidMe (gInv saidMe:))
									(gEgo has: (gInv indexOf: gInvSaidMe))
								)
								(Print 516 3)
							)
							(else (pEvent claimed: 0))
						)
					)
					((Said 'rob/lute') (Print 516 4))
					((Said 'look/man')
						(if ((Inv at: 18) ownedBy: 203)
							(if (gCast contains: gNewAct_2)
								(Print 516 5)
							else
								(Print 516 6)
							)
						else
							(Print 516 7)
						)
					)
					((Said 'converse[/man]')
						(cond 
							(((Inv at: 9) ownedBy: 203)
								(++ global184)
								(gSounds eachElementDo: #stop 0)
								(if (> global184 4)
									(= local1 (Random 2 4))
								else
									(= local1 global184)
								)
								(switch local1
									(1
										(Print 516 8)
										(Print 516 9)
										(thisSong number: 17 play: minstrelActions)
									)
									(2
										(Print 516 10)
										(thisSong number: 16 play: minstrelActions)
									)
									(3
										(Print 516 11)
										(thisSong number: 15 play: minstrelActions)
									)
									(4
										(Print 516 12)
										(thisSong number: 18 play: minstrelActions)
									)
								)
								(minstrelActions changeState: 1)
							)
							((gCast contains: gNewAct_2) (Print 516 13))
							(else (pEvent claimed: 0))
						)
					)
					((Said 'get/lute')
						(if ((Inv at: 9) ownedBy: 203)
							(Print 516 14)
						else
							(Print 516 15)
						)
					)
					((Said 'hum/') (Print 516 16))
				)
			else
				0
			)
		)
	)
)

(instance minstrelActions of Script
	(properties)
	
	(method (changeState newState)
		(switch (= state newState)
			(1
				(notes show: setPri: (gNewAct_2 priority?))
				(gNewAct_2 cycleSpeed: 1 setCycle: Fwd)
			)
			(2
				(gNewAct_2 setCycle: 0 cel: 0)
				(notes hide:)
			)
			(10
				(notes hide:)
				(proc0_8)
				(Print 516 17)
				(gNewAct_2
					view: 173
					cel: 0
					loop: 0
					cycleSpeed: 2
					setCycle: Fwd
				)
				(= global118 -1)
				(= seconds 4)
			)
			(11
				(Print 516 18)
				(= global182 1)
				((Inv at: 18) moveTo: 203)
				((Inv at: 9) moveTo: gEgo)
				(gGame changeScore: 3)
				(proc0_9)
				(gNewAct_2
					view: 171
					cel: 0
					loop: 2
					xStep: 2
					cycleSpeed: 0
					yStep: 1
					setAvoider: Avoid
					setCycle: Walk
				)
				(switch gCurRoomNum
					(13
						(gNewAct_2 setMotion: MoveTo 329 125 self)
					)
					(14
						(gNewAct_2 setMotion: MoveTo 329 136 self)
					)
					(19
						(gNewAct_2 setMotion: MoveTo 329 125 self)
					)
				)
			)
			(12
				(gNewAct_2 setScript: 0)
				(gNewAct_2 dispose:)
			)
		)
	)
)
