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

(public
	swampReg 0
)
(synonyms
	(water water marsh)
)

(local
	local0
	local1
	newProp
	newAct
	local4
	gEgoViewer
)
(instance poofSound of Sound
	(properties
		number 59
	)
)

(instance swampReg of Rgn
	(properties)
	
	(method (init)
		(Load rsVIEW 5)
		(Load rsVIEW 6)
		(Load rsVIEW 7)
		(Load rsVIEW 10)
		(Load rsVIEW 372)
		(Load rsVIEW 377)
		(Load rsVIEW 193)
		(Load rsVIEW 680)
		(Load rsVIEW 370)
		(= local0 0)
		(gEgo viewer: swamp)
		(super init:)
	)
	
	(method (handleEvent pEvent)
		(if (pEvent claimed?) (return 1))
		(return
			(if (== (pEvent type?) evSAID)
				(cond 
					((Said 'bathe,dive,wade[<enter][/ocean]') (Print 513 0))
					(
						(or
							(Said 'enter/fish')
							(Said 'fish[/!*]')
							(Said 'capture/fish')
							(Said 'cast/pole')
						)
						(Print 513 1)
					)
					((Said 'get/water') (Print 513 2))
					((or (Said 'drink') (Said 'get/drink'))
						(if (== (gEgo view?) 2)
							(if
								(or
									(& (= local4 (proc0_2 gEgo 12)) $0008)
									(& local4 $0800)
									(& local4 $0002)
									(& local4 $0200)
								)
								(= gGEgoScript (gEgo script?))
								(gEgo setScript: drinking)
							else
								(Print 800 1)
							)
						else
							(Print 513 3)
						)
					)
					((Said 'look<in/water') (Print 513 4))
					((Said 'look,climb/boulder<[gray]') (Print 513 5))
					((Said 'look>')
						(cond 
							((Said '/water') (Print 513 6))
							((Said '/cliff') (Print 513 7))
							((Said '/dirt') (Print 513 8))
							((Said '/tuft') (Print 513 9))
							((Said '/grass') (Print 513 10))
							((Said '/bush') (Print 513 11))
							((Said '/flora') (Print 513 12))
							((Said '/blossom') (Print 513 13))
							((Said '/forest') (Print 513 14))
						)
					)
					((Said 'climb,cross/cliff') (Print 513 15))
					((Said 'get/blossom') (Print 513 13))
					(
					(or (Said 'dennis/crown') (Said 'place/crown'))
						(cond 
							(
							(and (gEgo inRect: 115 149 274 181) (== gCurRoomNum 78)) (Print 513 16))
							((!= (gEgo view?) 2) (Print 513 17))
							((gEgo has: 10) (swamp changeState: 20))
							(else (Print 800 2))
						)
					)
					(
					(or (Said 'detach/crown') (Said 'get<off/crown'))
						(if (== global105 13)
							(swamp changeState: 30)
						else
							(Print 513 18)
						)
					)
				)
			else
				0
			)
		)
	)
)

(instance swamp of Script
	(properties)
	
	(method (doit)
		(super doit:)
		(= local0 (= local1 (gEgo onControl: 1)))
		(cond 
			((and (== global105 12) (== global132 0))
				(switch local1
					(1
						(gEgo illegalBits: -32768 view: 2)
					)
					(2048
						(gEgo illegalBits: -31744 view: 5)
					)
					(512
						(gEgo illegalBits: -31744 view: 6)
					)
					(8
						(gEgo illegalBits: -31744 view: 7)
					)
					(2 (self changeState: 1))
				)
			)
			((== global105 13)
				(if (== (gEgo mover?) 0) (gEgo cel: 0))
				(switch local1
					(1
						(gEgo illegalBits: -16384 view: 372)
					)
					(2048
						(gEgo illegalBits: -32768 view: 377)
					)
					(512
						(gEgo illegalBits: -32768 view: 377)
					)
					(8
						(gEgo view: 377 illegalBits: -32768)
					)
					(2 (self changeState: 10))
					(1024
						(gEgo illegalBits: -32768 view: 372)
					)
					(else 
						(gEgo illegalBits: -15360 view: 377)
					)
				)
			)
		)
	)
	
	(method (changeState newState)
		(switch (= state newState)
			(1
				(proc0_8)
				(= global105 0)
				(gEgo
					illegalBits: 1
					view: 73
					cel: 0
					loop: (& (gEgo loop?) $0001)
					cycleSpeed: 2
					setCycle: End self
				)
			)
			(2
				(gEgo hide:)
				(Print 513 19)
				(Print 513 20)
				(Timer setReal: self 5)
			)
			(3 (= global127 1))
			(10
				(proc0_8)
				(= global105 0)
				(= newAct (Act new:))
				(newAct
					view: 193
					posn: (gEgo x?) (- (gEgo y?) 5)
					loop: 0
					cel: 0
					ignoreActors:
					setCycle: End self
					init:
				)
				((Sound new:) number: 47 play:)
			)
			(11
				(gEgo hide:)
				(= global105 0)
				(newAct loop: 1 cel: 0 setCycle: End self)
			)
			(12
				(newAct loop: 2 cel: 0 setCycle: Fwd)
				(Timer setReal: self 4)
			)
			(13
				(Print 513 21 67 -1 10)
				(newAct cel: 0 loop: 3 setCycle: End self)
			)
			(14
				(newAct dispose:)
				(Timer setReal: self 5)
			)
			(15 (= global127 1))
			(20
				(proc0_8)
				(gSounds eachElementDo: #stop 0)
				(poofSound play:)
				(= newProp (Prop new:))
				(newProp
					posn: (gEgo x?) (gEgo y?)
					setPri: (+ (gEgo priority?) 1)
					view: 680
					cel: 0
					loop: 0
					ignoreActors:
					setCycle: CT 5 1 self
					init:
				)
			)
			(21
				(newProp setCycle: End self)
				(= global105 13)
				(gEgo observeControl: 16384)
				(gEgo view: 370)
			)
			(22
				(Timer setReal: self 3)
				(newProp dispose:)
			)
			(23
				(gEgo view: 372 setCycle: Walk)
				(proc0_9)
			)
			(30
				(proc0_8)
				(gSounds eachElementDo: #stop 0)
				(poofSound play:)
				(= newProp (Prop new:))
				(newProp
					posn: (gEgo x?) (gEgo y?)
					setPri: (+ (gEgo priority?) 1)
					view: 680
					cel: 0
					loop: 0
					ignoreActors:
					setCycle: CT 5 1 self
					init:
				)
			)
			(31
				(newProp setCycle: End self)
				(= global105 12)
				(gEgo view: 2 ignoreControl: 16384 setCycle: Walk)
				(proc0_9)
			)
			(32 (newProp dispose:))
		)
	)
)

(instance drinking of Script
	(properties)
	
	(method (changeState newState)
		(switch (= state newState)
			(0
				(proc0_8)
				(= gEgoViewer (gEgo viewer?))
				(gEgo viewer: 0 view: 21 cel: 0 setCycle: End self)
			)
			(1
				(= global120 (Print 513 22 67 -1 10 88))
				(Timer setReal: self 4)
			)
			(2 (gEgo setCycle: Beg self))
			(3
				(proc0_21)
				(gEgo view: 2 setCycle: Walk)
				(gEgo viewer: gEgoViewer script: gGEgoScript)
				(proc0_9)
			)
		)
	)
)
