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

(public
	regBFCastle 0
)

(local
	newAct_2
	newProp
	newAct
	local3
)
(instance henchCatchMusic of Sound
	(properties
		number 42
	)
)

(instance henchChaseMusic of Sound
	(properties
		number 41
	)
)

(instance regBFCastle of Rgn
	(properties)
	
	(method (init)
		(= keep 1)
		(Load rsVIEW 355)
		(Load rsVIEW 356)
		(Load rsVIEW 358)
		(= global189 1)
		(if (< global109 5) (= local3 92))
		(if (not global223) (= local3 0))
		(super init:)
	)
	
	(method (doit)
		(if
			(and
				(!= global105 16)
				global169
				(== (gEgo script?) 0)
				(gCast contains: newAct)
				(== (newAct script?) 0)
				(or
					(and
						(or (== gCurRoomNum 92) (== gCurRoomNum 91))
						(< (gEgo y?) 140)
						(< (gEgo distanceTo: newAct) 45)
						(> (Random 1 1000) 996)
					)
					(< (gEgo distanceTo: newAct) 20)
				)
			)
			(newAct setScript: henchChaseReg)
		)
		(super doit:)
	)
	
	(method (dispose)
		(if (gCast contains: newAct)
			(newAct setMotion: 0 setCycle: 0)
		)
		(if (== keep 0) (= global189 0) (super dispose:))
	)
	
	(method (handleEvent pEvent &tmp temp0)
		(super handleEvent: pEvent)
		(return
			(cond 
				((pEvent claimed?) (return 1))
				((== (pEvent type?) evSAID)
					(cond 
						((Said 'blow/whistle') (if (gEgo has: 27) (Print 604 0) else (proc0_17)))
						((Said 'look/wall') (Print 604 1))
						(
							(and
								(gCast contains: newAct)
								(Said 'converse[/goon,man]')
							)
							(if (and global169 (not global175))
								(if (< (gEgo distanceTo: newAct) 40)
									(newAct setScript: henchChaseReg)
								else
									(Print 604 2)
								)
							else
								(Print 604 3 67 -1 10)
							)
						)
						((Said '/goon,man>')
							(cond 
								((not (gCast contains: newAct)) (Print 604 4) (pEvent claimed: 1))
								((Said 'look')
									(if (and global169 (not global175))
										(Print 604 5)
									else
										(Print 604 6 67 -1 10)
									)
								)
								((Said 'awaken')
									(if (and global169 (not global175))
										(if (< (gEgo distanceTo: newAct) 40)
											(newAct setScript: henchChaseReg)
										else
											(Print 604 2)
										)
									else
										(Print 604 7)
									)
								)
								((Said 'get,capture') (Print 604 8))
								((Said 'kiss') (Print 604 9))
								((Said 'deliver') (Print 604 10) (pEvent claimed: 1))
							)
						)
						((Said '/bird,crow>')
							(cond 
								((not (gCast contains: newAct_2)) (Print 604 11) (pEvent claimed: 1))
								((Said 'look') (Print 604 12))
								((Said 'converse') (Print 604 13))
								((Said 'get,capture') (Print 604 14))
								((Said 'kiss') (Print 604 15))
								((Said 'deliver') (Print 604 16) (pEvent claimed: 1))
							)
						)
					)
				)
			)
		)
	)
	
	(method (newRoom newRoomNumber)
		(henchChaseReg seconds: 0)
		(super newRoom: newRoomNumber)
	)
	
	(method (notify param1)
		(initializeRoom changeState: param1)
	)
)

(instance initializeRoom of Script
	(properties)
	
	(method (changeState newState)
		(switch (= state newState)
			(0
				(henchChaseReg state: 0)
				(if
					(and
						(or (== gCurRoomNum 91) (== gCurRoomNum 92))
						global223
					)
					((= newProp (Prop new:))
						view: 358
						loop: 0
						cel: 0
						posn:
							(switch gCurRoomNum
								(91 258)
								(92 275)
							)
							(switch gCurRoomNum
								(91 136)
								(92 156)
							)
						init:
						stopUpd:
						setScript: ravenStuff
					)
				)
				(if
					(and
						(> global109 3)
						global169
						(or
							(== gCurRoomNum 90)
							(== gCurRoomNum 91)
							(== gCurRoomNum 92)
							(== gCurRoomNum 93)
						)
					)
					((= newAct (Act new:))
						view: 145
						loop: 4
						cel: (if (== gCurRoomNum 90) 1 else 0)
						posn:
							(switch gCurRoomNum
								(90 188)
								(91 210)
								(92 200)
								(93 124)
							)
							(switch gCurRoomNum
								(90 128)
								(91 119)
								(92 128)
								(93 129)
							)
						init:
						setAvoider: Avoid
						stopUpd:
					)
				)
			)
		)
	)
)

(instance ravenStuff of Script
	(properties)
	
	(method (doit)
		(if
			(and
				(== gCurRoomNum local3)
				(not (gCast contains: newAct_2))
			)
			(self changeState: 0)
		)
		(if
			(and
				(gCast contains: newAct_2)
				(!= (newAct_2 priority?) (newProp priority?))
			)
			(newAct_2 setPri: (CoordPri (newProp y?)))
		)
		(super doit:)
	)
	
	(method (changeState newState)
		(switch (= state newState)
			(0
				(if
					(and
						(not (gCast contains: newAct_2))
						(== gCurRoomNum local3)
						(or (== gCurRoomNum 91) (== gCurRoomNum 92))
					)
					((= newAct_2 (Act new:))
						view: 356
						ignoreActors: 1
						illegalBits: 0
						xStep: 6
						yStep: 2
						posn:
							(switch gCurRoomNum
								(91 316)
								(92 51)
							)
							(switch gCurRoomNum
								(91 90)
								(92 81)
							)
						init:
					)
					(newAct_2
						setPri: (+ (newProp priority?) 1)
						setCycle: Fwd
						setMotion: MoveTo (newProp x?) (- (newProp y?) 60) self
					)
				else
					(self changeState: 5)
				)
			)
			(1
				(newAct_2
					setPri: (newProp priority?)
					setMotion: MoveTo (newProp x?) (- (newProp y?) 40) self
				)
			)
			(2
				(newAct_2
					view: 355
					loop: 3
					setMotion: 0
					setScript: preenShit
				)
				(= seconds 30)
			)
			(3
				(newAct_2 setScript: 0 setCycle: 0)
				(newAct_2 cel: 0 loop: 2 setCycle: End self)
			)
			(4
				(newAct_2
					setScript: 0
					view: 356
					setPri: 11
					setLoop: -1
					setCycle: Fwd
					setMotion:
						MoveTo
						(switch gCurRoomNum
							(91 316)
							(92 53)
						)
						(switch gCurRoomNum
							(91 103)
							(92 81)
						)
						self
				)
			)
			(5
				(if (gCast contains: newAct_2) (newAct_2 dispose:))
				(cond 
					((== local3 92) (= local3 91))
					(global223 (= local3 92))
				)
				(self cue:)
			)
			(6 (= state -1) (= seconds 30))
		)
	)
)

(instance preenShit of Script
	(properties)
	
	(method (init param1)
		(super init: param1)
	)
	
	(method (changeState newState)
		(switch (= state newState)
			(0
				(switch (/ (Random 0 59) 10)
					(1
						(newAct_2 loop: 0 setCycle: End self)
					)
					(2
						(newAct_2 loop: 1 setCycle: End self)
					)
					(else  (self cue:))
				)
			)
			(1
				(newAct_2 loop: 3)
				(= seconds 4)
			)
			(2 (= state -1) (self cue:))
		)
	)
)

(instance henchChaseReg of Script
	(properties)
	
	(method (changeState newState)
		(switch (= state newState)
			(0
				(newAct loop: 2 setCycle: End self)
			)
			(1
				(newAct loop: 0 setCycle: End self)
			)
			(2
				(= global175 1)
				(if (not (gCast contains: newAct))
					(newAct
						setStep: 6 3
						posn:
							(switch gCurRoomNum
								(93 (- (gEgo x?) 30))
								(91 (+ (gEgo x?) 30))
							)
							(gEgo y?)
						init:
					)
				)
				(newAct
					view: 141
					ignoreActors: 1
					setStep: 6 3
					setCycle: Walk
					setMotion: Chase gEgo 15 self
				)
				(henchChaseMusic play:)
			)
			(3
				(User canControl: 0 canInput: 0)
				(gEgo moveSpeed: 0 setMotion: 0)
				(henchChaseMusic dispose:)
				(henchCatchMusic play:)
				(= seconds 4)
			)
			(4
				(henchCatchMusic dispose:)
				(if (== gCurRoomNum gNewRoomNumber_2)
					(= global205 1)
					(gRoom newRoom: 81)
				else
					(User canControl: 1 canInput: 1)
				)
			)
		)
	)
)
