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

(public
	gfReg 0
)
(synonyms
	(ocean seawater ocean)
)

(local
	local0
	local1
	local2
	newView
	newAct
)
(instance gfReg of Rgn
	(properties)
	
	(method (init)
		(super init:)
		(switch gCurRoomNum
			(33
				(= local1 198)
				(= local0 155)
			)
			(34
				(= local1 172)
				(= local0 133)
			)
			(35
				(= local1 126)
				(= local0 144)
			)
			(39
				(= local1 224)
				(= local0 113)
			)
			(40
				(= local1 241)
				(= local0 117)
			)
			(41
				(= local1 102)
				(= local0 109)
			)
		)
		(if (< (Random 1 100) 75)
			(= local2 (+ (Random 1 3) 32))
		else
			(= local2 (+ (Random 1 3) 38))
		)
		(if ((Inv at: 8) ownedBy: 888)
			((Inv at: 8) moveTo: local2)
		)
		(if ((Inv at: 8) ownedBy: gCurRoomNum)
			((= newView (View new:))
				view: 514
				posn: local1 local0
				loop: 0
				cel: 0
				init:
				stopUpd:
			)
		)
		(if (and (<= (Random 1 100) 40) (> local1 0))
			(Load rsVIEW 337)
			(= newAct (Act new:))
			(newAct
				view: 336
				moveSpeed: 1
				cycleSpeed: 1
				setCycle: Walk
				setMotion: Wander 30000
				illegalBits: -2
				posn: local1 (- local0 4)
				init:
				setScript: peacockActions
				setStep: 1 1
			)
		)
	)
	
	(method (doit)
		(if
			(and
				(gCast contains: newAct)
				(not (newAct inRect: -10 50 329 199))
			)
			(newAct dispose:)
		)
	)
	
	(method (dispose)
		(gTimers eachElementDo: #dispose 84)
		(super dispose:)
	)
	
	(method (handleEvent pEvent)
		(if (pEvent claimed?) (return 1))
		(return
			(if (== (pEvent type?) evSAID)
				(cond 
					((Said 'look>')
						(cond 
							((Said '/beach,beach')
								(if ((Inv at: 8) ownedBy: gCurRoomNum)
									(Print 505 0)
								else
									(Print 505 1)
								)
							)
							((Said '/feather')
								(cond 
									((gCast contains: newView) (Print 505 2))
									((gEgo has: 8) ((Inv at: 8) showSelf:))
									(else (Print 505 3))
								)
							)
							((Said '/tamir') (Print 505 4))
							((Said '<in,under/ocean,water')
								(if (!= (gEgo view?) 2)
									(Print 505 5)
								else
									(Print 505 6)
								)
							)
							((Said '/ocean,water') (Print 505 7))
							((or (Said '/dirt') (Said '<down'))
								(cond 
									(((Inv at: 8) ownedBy: gCurRoomNum) (Print 505 0))
									((and (>= gCurRoomNum 36) (<= gCurRoomNum 38)) (Print 505 8))
									(else (Print 505 9))
								)
							)
							((Said '/boulder') (Print 505 10))
							((Said '/forest') (Print 505 11))
							((Said '/grass') (Print 505 12))
							((Said '/bush') (Print 505 13))
							((Said '/flora') (Print 505 14))
							((Said '/blossom') (Print 505 15))
							((Said '/garden') (Print 505 16))
							((Said '/castle') (Print 505 17))
							((Said '/peacock')
								(if (gCast contains: newAct)
									(Print 505 18)
								else
									(Print 505 19)
								)
							)
							((Said '/bird')
								(if (gCast contains: newAct)
									(Print 505 18)
								else
									(pEvent claimed: 0)
								)
							)
						)
					)
					((Said 'climb/forest') (Print 505 20))
					((Said 'converse>')
						(cond 
							((Said '/peacock')
								(if (gCast contains: newAct)
									(Print 505 21)
								else
									(Print 505 19)
								)
							)
							((Said '/bird')
								(if (gCast contains: newAct)
									(Print 505 21)
								else
									(pEvent claimed: 0)
								)
							)
						)
					)
					((Said 'get/feather')
						(cond 
							(((Inv at: 8) ownedBy: gCurRoomNum)
								(if (< (gEgo distanceTo: newView) 15)
									(gEgo get: 8)
									(gGame changeScore: 2)
									(gEgo setScript: getFeather)
								else
									(Print 800 1)
								)
							)
							((gEgo has: 8) (pEvent claimed: 0))
							(else (Print 505 22))
						)
					)
					((Said 'get/blossom') (Print 505 23))
					((Said 'get,capture/peacock')
						(if (gCast contains: newAct)
							(Print 505 24)
						else
							(Print 505 3)
						)
					)
					((Said 'get,capture/bird,parrot') (Print 505 25))
					((Said 'kiss')
						(if (gCast contains: newAct)
							(Print 505 26)
						else
							(pEvent claimed: 0)
						)
					)
				)
			else
				0
			)
		)
	)
)

(instance getFeather of Script
	(properties)
	
	(method (changeState newState)
		(switch (= state newState)
			(0
				(proc0_8)
				(gEgo view: 21)
				(proc0_3 gEgo newView)
				(gEgo setCycle: End self)
			)
			(1
				(gEgo setCycle: Beg self)
				(= global182 1)
				(newView dispose:)
			)
			(2
				(gEgo view: 2 setScript: 0 setCycle: Walk)
				(proc0_9)
			)
		)
	)
)

(instance peacockActions of Script
	(properties)
	
	(method (changeState newState)
		(switch (= state newState)
			(0
				((ScriptID 0 4) setReal: self (Random 10 40))
			)
			(1
				(newAct
					view: 337
					setLoop: 0
					setMotion: 0
					cel: 0
					setCycle: End self
				)
			)
			(2
				((ScriptID 0 4) setReal: self 4)
			)
			(3 (newAct setCycle: Beg self))
			(4
				(newAct
					view: 336
					setLoop: -1
					setCycle: Walk
					setMotion: Wander 30000
				)
				(self changeState: 0)
			)
		)
	)
)
