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

(public
	Room59 0
)
(synonyms
	(ghost baby)
)

(local
	newProp
)
(instance babySound of Sound
	(properties)
)

(instance Room59 of Rm
	(properties
		picture 59
		style $0010
	)
	
	(method (init)
		(self setRegions: 603)
		(Load rsVIEW 527)
		(Load rsVIEW 648)
		(Load rsVIEW 510)
		(Load rsVIEW 536)
		(super init:)
		((View new:)
			view: 510
			loop: 1
			cel: 0
			posn: 80 103
			setPri: 10
			addToPic:
		)
		(if global100
			((View new:)
				view: 648
				loop: 0
				cel: 0
				posn: 51 103
				setPri: 6
				addToPic:
			)
			((Prop new:)
				view: 536
				loop: 2
				cel: 1
				posn: 80 97
				init:
				setPri: 11
				setCycle: Fwd
			)
		)
		((= newProp (Prop new:))
			view: 527
			loop: 1
			posn: 147 117
			setPri: 1
			init:
			stopUpd:
		)
		(gEgo posn: 270 129 view: 4 xStep: 4 yStep: 2 init:)
		(self setScript: rm59Script)
		(if (and (== global133 59) (== global134 1))
			(rockAgain cue:)
			(rm59Script changeState: 1)
		)
	)
	
	(method (doit)
		(if (& (gEgo onControl: 0) $0040)
			(gRoom newRoom: 62)
		)
		(super doit:)
	)
	
	(method (handleEvent pEvent &tmp gInvSaidMe)
		(return
			(if (pEvent claimed?)
				(return 1)
			else
				(if (== (pEvent type?) evSAID)
					(cond 
						((Said 'look>')
							(cond 
								((Said '[<around][/room,bedroom,nursery]') (Print 59 0))
								((Said '<in/chest,dresser,drawer') (Print 59 1))
								((Said '/chest,dresser') (Print 59 2))
								((Said '/chair,rocker') (Print 59 3))
								((Said '/window')
									(if (gEgo inRect: 76 125 109 147)
										(Print 59 4)
									else
										(Print 800 1)
									)
								)
								(
								(or (Said '<in/cradle') (Said 'ghost[<ghost]'))
									(if (< (gEgo distanceTo: newProp) 15)
										(if (!= global134 1)
											(Print 59 5)
										else
											(Print 59 6)
										)
									else
										(Print 800 1)
									)
								)
								((Said '/cradle')
									(if (!= global134 1)
										(Print 59 7)
									else
										(Print 59 8)
									)
								)
								((Said '/wall') (Print 59 9))
								((or (Said '/dirt') (Said '<down')) (Print 59 10))
								((Said '/horse,toy') (Print 59 11))
								((Said '/carpet') (Print 59 12))
								(else (pEvent claimed: 0))
							)
						)
						((Said 'open/chest,dresser,drawer') (Print 59 1))
						((Said 'sit') (Print 59 13))
						((Said 'boulder[/cradle]')
							(cond 
								((== global134 1) (Print 59 14))
								((< (gEgo distanceTo: newProp) 10) (rockAgain changeState: 0) (pEvent claimed: 1))
								(else (Print 800 1))
							)
						)
						((Said '(get<on),mount,play/horse,toy') (Print 59 15))
						((Said 'get/horse,toy') (Print 59 16))
					)
				)
				(if
					(or
						(pEvent claimed?)
						(!= (pEvent type?) evSAID)
						(!= global134 1)
					)
					(return (!= global134 1))
				)
				(cond 
					(
						(or
							(Said 'look<in/cradle')
							(Said
								'look,(feel[<in,around]),find/cradle,(ghost[<ghost])'
							)
						)
						(if (< (gEgo distanceTo: newProp) 15)
							(if (!= global134 1)
								(Print 59 5)
							else
								(Print 59 6)
							)
						else
							(Print 800 1)
						)
					)
					((Said 'converse,calm,calm') (Print 59 17))
					((Said 'kiss') (Print 59 18))
					((Said '/ghost[<ghost]>')
						(cond 
							((Said 'get,hold,capture,(get<up)') (Print 59 19))
							((Said 'kill') (Print 59 20))
							((Said 'help,save') (Print 59 21))
							((Said 'feed') (Print 59 22))
						)
					)
					((Said 'hum[/ghost,lullaby]') (Print 59 23))
					((Said 'deliver,fling,place,drop>')
						(cond 
							(
								(or
									(not (= gInvSaidMe (gInv saidMe:)))
									(not (gEgo has: (gInv indexOf: gInvSaidMe)))
								)
								(pEvent claimed: 0)
							)
							((>= (gEgo distanceTo: newProp) 17) (proc0_13))
							((!= (gInv indexOf: gInvSaidMe) 12) (Print 59 24))
							(else
								(Print 59 25)
								(gEgo put: 12 59)
								(gGame changeScore: 2)
								(proc0_10 603 2)
							)
						)
					)
				)
			)
		)
	)
)

(instance rockMeBaby of Script
	(properties)
	
	(method (changeState newState)
		(switch (= state newState)
			(0
				(newProp
					cycleSpeed: 1
					setCycle: Fwd
					brTop: (- (newProp y?) 2)
				)
			)
			(1
				(newProp stopUpd: brTop: (- (newProp y?) 2) setCel: 0)
				(= state -1)
			)
		)
	)
)

(instance rockAgain of Script
	(properties)
	
	(method (init param1)
		(super init: param1)
	)
	
	(method (changeState newState)
		(switch (= state newState)
			(0
				(rockMeBaby changeState: 0)
				(babySound number: 22 play: self)
			)
			(1
				(rockMeBaby cue:)
				(if (== global134 1) (self changeState: 0))
			)
		)
	)
)

(instance rm59Script of Script
	(properties)
	
	(method (changeState newState &tmp [temp0 102])
		(switch (= state newState)
			(1 (= seconds 5))
			(2 (Print 59 26))
		)
	)
)
