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

(public
	regUnicorn 0
)
(synonyms
	(kiss kiss embrace)
	(unicorn horse)
)

(local
	newProp
	local1
)
(instance uniTheme of Sound
	(properties
		number 32
	)
)

(instance regUnicorn of Rgn
	(properties)
	
	(method (init)
		(super init:)
		(if (== 0 global124)
			(switch (Random 1 3)
				(1 (= global124 20))
				(2 (= global124 26))
				(3 (= global124 27))
			)
		)
		(if (== gCurRoomNum global124)
			(Load rsVIEW 388)
			(if (gEgo has: 21) (Load rsVIEW 389) (Load rsVIEW 381))
			(if (or (== global123 0) (== global123 999))
				(Load rsVIEW 382)
				(Load rsVIEW 383)
				(Load rsVIEW 380)
			)
			(if (gEgo has: 14) (Load rsVIEW 31) (Load rsVIEW 681))
			(= gNewAct_3 (Act new:))
			(gNewAct_3
				view: 388
				xStep: 4
				yStep: 1
				setCycle: Fwd
				cycleSpeed: 2
				setAvoider: Avoid 1
				init:
			)
			(switch gCurRoomNum
				(20 (gNewAct_3 x: 145 y: 110))
				(26
					(gNewAct_3 loop: 0 posn: 226 97)
				)
				(27
					(gNewAct_3
						x: 177
						y: 139
						loop: (if (< (gEgo x?) (gNewAct_3 x?)) 0 else 1)
					)
				)
			)
			(if (< (gEgo x?) (gNewAct_3 x?))
				(gNewAct_3 loop: 0)
			else
				(gNewAct_3 loop: 1)
			)
			(gNewAct_3 setScript: uniActions)
		)
	)
	
	(method (dispose)
		(gTimers eachElementDo: #dispose)
		(super dispose:)
	)
	
	(method (handleEvent pEvent &tmp gInvSaidMe)
		(if (pEvent claimed?) (return 1))
		(return
			(if
				(and
					(== (pEvent type?) evSAID)
					(!= (uniActions state?) 3)
					(gCast contains: gNewAct_3)
					(!= (gNewAct_3 script?) 0)
				)
				(cond 
					((and (== global123 999) (Said '/unicorn')) (Print 518 0))
					((Said 'launch/arrow,unicorn,arrow')
						(if
						(and (gEgo has: 14) (< ((Inv at: 14) loop?) 2))
							(if (!= global123 0) (return (Print 518 1)))
							(cond 
								((!= (gEgo view?) 2) (Print 518 2))
								((gNewAct_3 inRect: 0 0 319 189)
									(proc0_3 gEgo gNewAct_3)
									(uniActions changeState: 10)
									(if (not global191)
										(= global191 1)
										(gGame changeScore: 4)
									)
									((Inv at: 14) loop: (+ ((Inv at: 14) loop?) 1))
								)
								(else (Print 518 3))
							)
						else
							(Print 518 4)
						)
					)
					(
					(or (Said 'converse[/!*]') (Said 'converse/unicorn'))
						(if (gCast contains: gNewAct_3)
							(switch global123
								(0 (Print 518 5))
								(1 (Print 518 6))
								(2 (Print 518 7))
							)
						else
							(Print 518 8)
						)
					)
					((Said 'look/horn')
						(if (gCast contains: gNewAct_3)
							(Print 518 9)
						else
							(pEvent claimed: 0)
						)
					)
					((or (Said 'bit/unicorn') (Said 'place/bit'))
						(switch global123
							(0 (Print 518 10))
							(1
								(if (gEgo has: 21)
									(if
										(or
											(and
												(== (gNewAct_3 loop?) 0)
												(gEgo
													inRect:
														(+ (gNewAct_3 x?) 20)
														(- (gNewAct_3 y?) 5)
														(+ (gNewAct_3 x?) 40)
														(+ (gNewAct_3 y?) 5)
												)
											)
											(gEgo
												inRect:
													(- (gNewAct_3 x?) 40)
													(- (gNewAct_3 y?) 5)
													(- (gNewAct_3 x?) 20)
													(+ (gNewAct_3 y?) 5)
											)
										)
										(Print 518 11)
										(gGame changeScore: 3)
										((Inv at: 21) moveTo: 205)
										(uniActions changeState: 20)
									else
										(Print 800 1)
									)
								else
									(Print 518 12)
								)
							)
							(2 (Print 518 13))
						)
					)
					((or (Said 'kiss[/!*]') (Said 'kiss/unicorn'))
						(if (gCast contains: gNewAct_3)
							(cond 
								((== global123 0) (Print 518 14))
								(
									(or
										(and
											(== (gNewAct_3 loop?) 0)
											(gEgo
												inRect:
													(+ (gNewAct_3 x?) 20)
													(- (gNewAct_3 y?) 5)
													(+ (gNewAct_3 x?) 40)
													(+ (gNewAct_3 y?) 5)
											)
										)
										(gEgo
											inRect:
												(- (gNewAct_3 x?) 40)
												(- (gNewAct_3 y?) 5)
												(- (gNewAct_3 x?) 20)
												(+ (gNewAct_3 y?) 5)
										)
									)
									(Print 518 15)
								)
								(else (Print 800 1))
							)
						else
							(pEvent claimed: 0)
						)
					)
					((Said '/unicorn>')
						(if (gCast contains: gNewAct_3)
							(cond 
								((Said 'look')
									(switch global123
										(0 (Print 518 16))
										(1 (Print 518 17))
										(2 (Print 518 18))
									)
								)
								(
								(or (Said 'mount') (Said 'get<on') (Said 'climb<on'))
									(switch global123
										(0 (Print 518 19))
										(1 (Print 518 20))
										(2
											(if (< (gEgo distanceTo: gNewAct_3) 10)
												(if (> (gEgo y?) (gNewAct_3 y?))
													(gEgo
														view: 389
														setAvoider: (Avoid new:)
														ignoreActors:
														setMotion: 0
														posn: (gNewAct_3 x?) (gNewAct_3 y?)
														cel: 0 71
													)
													(if (== (gNewAct_3 loop?) 0)
														(gEgo loop: 0)
													else
														(gEgo loop: 1)
													)
													(= global123 3)
													(= global124 333)
													(= gNewRoomNumber_2 333)
												else
													(Print 518 21)
												)
											else
												(Print 800 1)
											)
										)
									)
								)
								((Said 'get,capture')
									(switch global123
										(0 (Print 518 19))
										(1 (Print 518 22))
										(2 (Print 518 23))
									)
								)
								((Said 'pat')
									(cond 
										((== global123 0) (Print 518 19))
										(
											(or
												(and
													(== (gNewAct_3 loop?) 0)
													(gEgo
														inRect:
															(+ (gNewAct_3 x?) 20)
															(- (gNewAct_3 y?) 5)
															(+ (gNewAct_3 x?) 40)
															(+ (gNewAct_3 y?) 5)
													)
												)
												(gEgo
													inRect:
														(- (gNewAct_3 x?) 40)
														(- (gNewAct_3 y?) 5)
														(- (gNewAct_3 x?) 20)
														(+ (gNewAct_3 y?) 5)
												)
											)
											(Print 518 24)
										)
										(else (Print 800 1))
									)
								)
								((Said 'feed') (Print 518 25))
								((Said 'guide')
									(switch global123
										(0 (Print 518 14))
										(1 (Print 518 26))
										(2 (Print 518 23))
									)
								)
							)
						else
							(Print 518 27)
						)
					)
					((Said 'deliver>')
						(if (= gInvSaidMe (gInv saidMe:))
							(if (gEgo has: (gInv indexOf: gInvSaidMe))
								(Print 518 28)
							else
								(Print 800 2)
							)
						else
							(Print 518 29)
							(pEvent claimed: 1)
						)
					)
				)
			else
				0
			)
		)
	)
)

(instance uniActions of Script
	(properties)
	
	(method (changeState newState)
		(switch (= state newState)
			(0
				(uniTheme play:)
				(= seconds 4)
			)
			(1
				(switch global123
					(0
						(gNewAct_3
							view: 382
							cel: 0
							cycleSpeed: 1
							setCycle: End self
						)
					)
					(1 (self changeState: 13))
					(2
						(gNewAct_3 view: 381 cycleSpeed: 1 setCycle: Fwd)
					)
					(999
						(gNewAct_3
							view: 382
							cel: 0
							cycleSpeed: 1
							setCycle: End self
						)
					)
				)
			)
			(2
				(switch gCurRoomNum
					(20
						(gNewAct_3 view: 383 cycleSpeed: 0 setCycle: Walk)
						(if (< (gEgo x?) (gNewAct_3 x?))
							(gNewAct_3 setMotion: MoveTo 350 95 self)
						else
							(gNewAct_3 setMotion: MoveTo -50 91 self)
						)
					)
					(26
						(gNewAct_3 view: 383 cycleSpeed: 0 setCycle: Walk)
						(gNewAct_3 setMotion: MoveTo 350 94 self)
					)
					(27
						(gNewAct_3 view: 383 cycleSpeed: 0 setCycle: Walk)
						(if (< (gEgo x?) (gNewAct_3 x?))
							(gNewAct_3 setMotion: MoveTo 350 139 self)
						else
							(gNewAct_3 setMotion: MoveTo -50 139 self)
						)
					)
				)
			)
			(3
				(uniTheme dispose:)
				(gNewAct_3 dispose:)
				(switch gCurRoomNum
					(20 (= global124 27))
					(26 (= global124 27))
					(27
						(if (< (gNewAct_3 x?) 0)
							(= global124 26)
						else
							(= global124 20)
						)
					)
				)
			)
			(10
				(proc0_8)
				(proc0_3 gEgo gNewAct_3)
				(gEgo view: 31 cel: 0 setCycle: End self)
			)
			(11
				(gEgo setCycle: Beg)
				(= global123 1)
				(= newProp (Prop new:))
				(gNewAct_3 setMotion: 0 setCycle: 0)
				(newProp
					view: 681
					cel: 0
					loop: 0
					setPri: 15
					posn: (gNewAct_3 x?) (- (gNewAct_3 y?) 15)
					setCycle: End self
					init:
				)
			)
			(12
				(newProp dispose:)
				(Print 518 30 67 -1 10)
				(gNewAct_3 view: 383 cycleSpeed: 0 setCycle: Walk)
				(gEgo view: 2 setCycle: Walk)
				(proc0_9)
				(Print 518 31 67 -1 10)
				(switch gCurRoomNum
					(20
						(gNewAct_3 setMotion: MoveTo 160 110 self)
					)
					(21
						(gNewAct_3 setMotion: MoveTo 142 91 self)
					)
					(26
						(gNewAct_3 setMotion: MoveTo 226 99 self)
					)
					(27
						(gNewAct_3 setMotion: MoveTo 177 139 self)
					)
				)
			)
			(13
				(switch (++ local1)
					(1
						(gNewAct_3 view: 380 cycleSpeed: 2 setCycle: Fwd)
						((ScriptID 0 4) setReal: self 3)
					)
					(2
						(gNewAct_3 view: 388 cycleSpeed: 2 setCycle: Fwd)
						((ScriptID 0 4) setReal: self 5)
					)
					(3
						(gNewAct_3 view: 388 cel: 0 setCycle: 0)
						((ScriptID 0 4) setReal: self 7)
					)
				)
			)
			(14
				(if (== local1 3) (= local1 0))
				(self changeState: 13)
			)
			(20
				(gNewAct_3 view: 381 setCycle: Fwd)
				((Inv at: 21) moveTo: 205)
				(= global123 2)
			)
		)
	)
)
