/******************************************************************************/
(include "sci.sh")
(include "game.sh")
/******************************************************************************/
(script 3)
/******************************************************************************/
(use "Controls")
(use "Cycle")
(use "Door")
(use "Feature")
(use "Game")
(use "Inv")
(use "Main")
(use "Obj")
(use "dpath")
/******************************************************************************/
(instance public rm003 of Rm
	(properties
		picture scriptNumber
		north 0
		east 0
		south 0
		west 0
	)
	(method (init)
		(super:init())
		(self:setScript(RoomScript))

		(switch(gPreviousRoomNumber)

		(case 2
			(send gEgo:
      posn(295 165)
      loop(1)
			)
		)
			(case 4
			(send gEgo:
      posn(45 165)
      loop(0)
			)
		)
			(default
				(send gEgo:
					posn(150 130)
					loop(1)
				)
			)
		)

		SetUpEgo()
		(send gEgo:init())
		(Frontdoor:init())
		(send (View:new()):view((Skelsmoke:view))loop(0)cel(0)posn((Skelsmoke:x) (Skelsmoke:y))setPri(9)ignoreActors()addToPic())
		
(if(== maskon 1)
			(send gEgo:view(6))
		)

			(if(== clotheson 0)
			(send gEgo:view(3))
		)
	)
)
/******************************************************************************/
(instance RoomScript of Script
	(properties)

	(method (doit)
			--satancount
		(if((== satancount 45) and (== praisetwo 0) and (== Praiseone 1))
			Print("You feel the hair raise on the back of your neck and hear the faint approach of cloven hooves.")


		)
			(if((== satancount 0) and (== praisetwo 0) and (== Praiseone 1))

		(send gEgo:setMotion(
     DPath
     80 155
     100 38
     210 160
     325 50
  )
		)


					(if(== (send gEgo:view) 3)
						(send gEgo:view(117))
					)
					(if(== (send gEgo:view) 0)
						(send gEgo:view(118))
					)
					(if(== (send gEgo:view) 6)
						(send gEgo:view(119))
					)
				(send gEgo:setCycle(Fwd))
					(send gTheMusic:
			prevSignal(0)
			stop()
			number(41) 
			loop(-1)
			play()
		)

					Print("You can imagine your chagrin as the hellspawn takes your body for a joy ride. You're going to have a heck of a stiff neck when and if you come out of this.")
			= gProgramControl TRUE


	)
		(if((== satancount 0) and (== praisetwo 1))
			= praisetwo 0
			= satancount 550
		)
		
			(if(== click 2)
			Print("Cheese!")
					DrawPic(gRoomNumber dpOPEN_INSTANTLY dpCLEAR )
					= click 0
						(send (View:new()):view((Skelsmoke:view))loop(0)cel(0)posn((Skelsmoke:x) (Skelsmoke:y))setPri(9)ignoreActors()addToPic())
				)
		(if(== click 1)
			Print("Click!")
				= picspot Display("                                                                                        "
                    dsCOORD clickx clicky
                    dsALIGN alCENTER
                    dsCOLOUR clCYAN
                    dsBACKGROUND -1
                    dsWIDTH 80
                    dsSAVEPIXELS
								 )


								 = click 2
					)
		
			(if((== $0004 OnControl(ocSPECIAL (send gEgo:x) (send gEgo:y))))
      (send gRoom:newRoom(2))
			)
			(if((== $0002 OnControl(ocSPECIAL (send gEgo:x) (send gEgo:y))))
      (send gRoom:newRoom(4))
			)
		(super:doit())
		// code executed each game cycle
	)

	(method (handleEvent pEvent)
		(super:handleEvent(pEvent))

		(if ((== evMOUSEBUTTON (send pEvent:type)) and (== takepic 1))

				(send (View:new()):view((send gEgo:view))loop((send gEgo:loop))cel((send gEgo:cel))posn((send gEgo:x) (send gEgo:y))setPri((send gEgo:priority))ignoreActors()addToPic())
				(send (View:new()):view((Skelsmoke:view))loop((Skelsmoke:loop))cel((Skelsmoke:cel))posn((Skelsmoke:x) (Skelsmoke:y))setPri((Skelsmoke:priority))ignoreActors()addToPic())

				(send (View:new()):view((Frontdoor:view))loop((Frontdoor:loop))cel((Frontdoor:cel))posn((Frontdoor:x) (Frontdoor:y))setPri((Frontdoor:priority))ignoreActors()addToPic())
				= clickx (- (send pEvent:x) 22)
				= clicky (- (send pEvent:y) 8)

			= takepic 0
			= click 1
			= gNormalCursor 152
			(send gGame:setCursor(gNormalCursor SET_CURSOR_VISIBLE 304 174))
			(send pEvent:claimed(TRUE))


		)

		(if(Said('open / door'))
		(if(== clotheson 1)
			(Frontdoor:open())
			)
			(else
				Print("I wouldn't; you're not decent.")
				Print("(also, you're not dressed to go outside.)")
			)
		)


		(if( (Said('wear/contacts')) and (send gEgo:has(INV_CONTACTS)) and (== contactsin 0))
			Print("Gingerly, you sucker the lenses to your eyes, and the world appears in a hawk-like 320 x 200 resolution.")
			= contactsin 1
			(send gEgo:put(INV_CONTACTS))
			(send gEgo:get(INV_CONTACTSEMPTY))

		)

			(if( (Said('wear/contacts')) and not(send gEgo:has(INV_CONTACTS)))
			Print("Impossible, for one reason or another.")
		)

        (if( (Said('remove/contacts')) and (== contactsin 1))
        	Print("You pluck the lenses from your eyes and stow them in their case.")
        	(send gEgo:put(INV_CONTACTSEMPTY))
        	(send gEgo:get(INV_CONTACTS))
        	= contactsin 0
		)

        	(if( Said('remove/contacts') and (== contactsin 0))
        	Print("Impossible, for one reason or another.")
		)

		(if(Said('look >'))
        	(if(== contactsin 1)
        	        	(if(Said('/ painting,skeleton'))
        	        		Print("An original reproduction of what was apparently a Van Gogh PSA.")
        	        		Print("Doing a good job of covering the hole you put in the drywall during your last party.")
						)(else

						(if(Said('/ rug'))

							Print("It really ties the room together.")
						)
						(else
							(if(Said('/ nightstand'))
								Print("One nightstand supports a potted plant. The other contains your adventurer's clothes.")
							)


								(else


						(if(Said('[ /* , !* ]'))
							Print("This is the hallway, the central hub of your home. To the east is your room. To the west, the kitchen. And north leads outside.")

												)
								)
							)
						 )


			)


		)




		// handle Said's, etc...
	)

	(method (changeState newState)
		(= state newState)
		(switch (newState)
			(case 0
				// Handle state changes
			)
		)
	)
)
(instance Skelsmoke of Prop
	(properties
		x 237
		y 112
		view 159
		loop 0
	)

)
(instance Frontdoor of Door
	(properties
		x 144
		y 128
		view 161
		entranceTo 6
		locked FALSE
		doorCtrl $0800
		roomCtrl $0400
		doorBlock $1000
		priority 1
	)
)
/******************************************************************************/

