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

(public
	Room48 0
)

(local
	newProp
	[local1 3]
	newAct
	local5
)
(instance Room48 of Rm
	(properties
		picture 48
		style $0010
	)
	
	(method (init)
		(super init:)
		(if ((Inv at: 16) ownedBy: 48) (Load rsVIEW 501))
		(Load rsVIEW 2)
		(Load rsVIEW 647)
		(Load rsVIEW 245)
		(Load rsVIEW 48)
		(ogressChaseMusic init:)
		(ogressCatchMusic init:)
		(switch gPrevRoomNum
			(49
				(proc0_7 0)
				(gEgo posn: 130 123 view: 2 loop: 0 setStep: 3 2 init:)
			)
			(else 
				(proc0_7 0)
				(gEgo posn: 135 134 view: 2 loop: 0 setStep: 3 2 init:)
			)
		)
		(self setRegions: 602)
		(if global100
			((View new:) view: 647 loop: 0 posn: 158 93 addToPic:)
			((View new:) view: 647 loop: 1 posn: 263 96 addToPic:)
			((Prop new:)
				view: 501
				loop: 1
				posn: 221 140
				setPri: 15
				init:
				setCycle: Fwd
			)
			((Prop new:)
				view: 501
				loop: 1
				posn: 101 140
				setPri: 15
				init:
				setCycle: Fwd
			)
		else
			((View new:)
				view: 501
				loop: 0
				cel: 2
				posn: 221 140
				setPri: 15
				ignoreActors: 1
				addToPic:
			)
			((View new:)
				view: 501
				loop: 0
				cel: 2
				posn: 101 140
				setPri: 15
				ignoreActors: 1
				addToPic:
			)
		)
		((View new:)
			view: 501
			loop: 0
			cel: 1
			posn: 267 128
			setPri: 11
			ignoreActors: 1
			addToPic:
		)
		(if (== ((gInv at: 16) owner?) 48)
			((= newProp (Prop new:))
				view: 501
				loop: 0
				cel: 0
				posn: 243 124
				init:
				stopUpd:
			)
		)
		((= newAct (Act new:)) setScript: ogressChase)
	)
	
	(method (doit)
		(super doit:)
		(if (& (gEgo onControl: 0) $0040)
			(gRoom newRoom: 49)
		)
	)
	
	(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 '<under/bed') (Print 48 0))
							((Said '/bed') (Print 48 1))
							((Said '<in/chest,dresser,drawer') (Print 48 2))
							((Said '/chest,dresser,drawer') (Print 48 3))
							((Said '/carpet') (Print 48 4))
							((Said '/window')
								(if
									(or
										(gEgo inRect: 143 119 178 126)
										(gEgo inRect: 232 126 275 132)
									)
									(Print 48 5)
								else
									(Print 800 1)
								)
							)
							((Said '/stair') (Print 48 6))
							((Said '/barrel') (Print 48 7))
							((Said '/mirror')
								(if (gEgo inRect: 201 143 282 170)
									(Print 48 8)
								else
									(Print 800 1)
								)
							)
							((Said '/door')
								(if (== ((gInv at: 33) owner?) 48)
									(Print 48 9)
								else
									(Print 48 10)
								)
							)
							((Said '/wall') (Print 48 11))
							((or (Said '/dirt') (Said '<down')) (Print 48 12))
							((Said '[<around,at][/room,bedroom,cottage]')
								(Print
									(Format
										@global228
										48
										13
										(if (== ((gInv at: 16) owner?) 48)
											{Against the right wall, leans the ogre's axe.}
										else
											{}
										)
									)
								)
							)
						)
					)
					((Said 'get/ax')
						(if (== ((gInv at: 16) owner?) 48)
							(if (< (gEgo distanceTo: newProp) 20)
								(gEgo get: 16)
								(= global182 1)
								(gGame changeScore: 2)
								(newProp dispose:)
							else
								(Print 800 1)
							)
						else
							(Print 48 14)
						)
					)
					(
						(or
							(Said 'sleep')
							(Said '(lay[<in,on,down]),(get[<in,in])[/bed]')
						)
						(Print 48 15)
					)
					((Said 'open/chest,dresser,drawer') (Print 48 2))
					((Said 'open/window')
						(if
							(or
								(gEgo inRect: 143 119 178 126)
								(gEgo inRect: 232 126 275 132)
							)
							(Print 48 16)
						else
							(Print 800 1)
						)
					)
					((Said 'open/door')
						(if (gEgo inRect: 25 137 60 154)
							(Print 48 17)
						else
							(Print 800 1)
						)
					)
					((Said 'unlatch/door')
						(if (gEgo inRect: 25 137 60 154)
							(Print 48 18)
						else
							(Print 800 1)
						)
					)
					((Said 'break/door')
						(if (gEgo inRect: 25 137 60 154)
							(Print 48 19)
						else
							(Print 800 1)
						)
					)
					((Said 'bang/door')
						(if (gEgo inRect: 25 137 60 154)
							(if (== ((gInv at: 33) owner?) 48)
								(Print 48 20)
							else
								(Print 48 21)
							)
						else
							(Print 800 1)
						)
					)
				)
				(if
					(and
						(not (pEvent claimed?))
						(> (ogressChase state?) 0)
					)
					(cond 
						((Said 'look/giantess') (Print 48 22))
						((Said 'converse[/giantess]') (Print 48 23))
						((Said 'kill[/giantess]') (Print 48 24))
						((Said 'get,capture/giantess') (Print 48 25))
						((Said 'deliver') (Print 48 26))
					)
				)
			else
				0
			)
		)
	)
)

(instance ogressChase of Script
	(properties)
	
	(method (doit)
		(super doit:)
	)
	
	(method (changeState newState)
		(switch (= state newState)
			(0
				(client
					view: 245
					posn: 0 0
					illegalBits: 0
					ignoreActors: 1
					setPri: 8
					setCycle: Walk
					init:
					hide:
				)
				(if (!= global14 0) (= seconds 10) else (= seconds 60))
			)
			(1
				(= local5 10)
				(= global204 1)
				(User canInput: 0)
				(playMusic cue:)
				(client
					posn: 64 138
					show:
					setAvoider: Avoid
					setMotion: MoveTo 135 123 self
				)
			)
			(2
				(if (and (< (gEgo x?) 135) (> (gEgo y?) 128))
					(newAct setAvoider: Avoid setMotion: MoveTo 145 135 self)
				else
					(self cue:)
				)
			)
			(3
				(Print 48 27)
				(client
					illegalBits: -32768
					setPri: -1
					setAvoider: Avoid
					setMotion: Chase gEgo 15 self
				)
			)
			(4
				(proc0_8)
				(= local5 11)
				(playMusic cue:)
				(gEgo hide:)
				(gEgo hide:)
				(client
					view: 48
					cycleSpeed: 2
					cel: 255
					setCycle: End self
				)
			)
			(5
				(Print 48 28 67 -1 10)
				(= seconds 4)
			)
			(6 (= global127 1))
		)
	)
)

(instance ogressChaseMusic of Sound
	(properties
		number 10
	)
)

(instance ogressCatchMusic of Sound
	(properties
		number 11
	)
)

(instance playMusic of Script
	(properties)
	
	(method (changeState newState)
		(switch (= state newState)
			(0
				(switch local5
					(10
						(ogressChaseMusic play: self)
					)
					(11
						(ogressCatchMusic play: self)
					)
				)
			)
			(1
				(if (!= local5 11) (= state -1) (self cue:))
			)
		)
	)
)
