/******************************************************************************/
(include "sci.sh")
(include "game.sh")
/******************************************************************************/
(script 2)
/******************************************************************************/
(use "Controls")
(use "Cycle")
(use "Door")
(use "Feature")
(use "Game")
(use "Inv")
(use "Main")
(use "Obj")
(use "dpath")
/******************************************************************************/
(local
	spinhead
	demo
	satantic = 6
	satantictwo = 7

)

(instance public rm002 of Rm
	(properties
		picture scriptNumber
		north 0
		east 0
		south 0
		west 0
	)
	(method (init)
		(super:init())
		(self:setScript(RoomScript))

		(switch(gPreviousRoomNumber)
		(case 80
			(send gEgo:
      posn(95 165)
      loop(0)
			)
		)
		(case 3
			(send gEgo:
      posn(277 164)
      loop(3)
			)
		)
			(default
				(send gEgo:
					posn(150 130)
					loop(1)
				)
			)
		)


		SetUpEgo()
		(send gEgo:init())
			(if(== clotheson 0)
			(send gEgo:view(3))
		)


		(if(== maskon 1)
			(send gEgo:view(6))
		)
		(if((not (send gEgo:has(INV_SRISRI))) and (not (send gEgo:has(INV_SRISRIOFF))))
			(Charger:init())
			(Charger:ignoreActors())
		)
		(send (View:new()):view((Plant:view))loop(0)cel(0)posn((Plant:x) (Plant:y))setPri(6)ignoreActors()addToPic())
		(send (View:new()):view((Cello:view))loop(0)cel(0)posn((Cello:x) (Cello:y))setPri(6)ignoreActors()addToPic())
	
		(Mirrorkat:init())
		(Mirrorkat:setPri(1))
		(Mirrorkat:ignoreActors())
		(Mirrorkat:ignoreControl(ctlWHITE))
	= satantic 0

	)
)
/******************************************************************************/
(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((Plant:view))loop(0)cel(0)posn((Plant:x) (Plant:y))setPri(6)ignoreActors()addToPic())
		(send (View:new()):view((Cello:view))loop(0)cel(0)posn((Cello:x) (Cello:y))setPri(6)ignoreActors()addToPic())
				)
		(if(== click 1)
			Print("Click!")
				= picspot Display("                                                                                        "
                    dsCOORD clickx clicky
                    dsALIGN alCENTER
                    dsCOLOUR clCYAN
                    dsBACKGROUND -1
                    dsWIDTH 80
                    dsSAVEPIXELS
								 )


								 = click 2
					)

		(if((== (Zap:cel) 8 ) )

			Print("The tremendous static charge built up by your shuffling wooly slippers explodes out of your fingertips into the Dronefone.")
				Print("You unplug the Dronefone from its charger. In the air: a wisp of smoke, the scent of ozone.")


			(send gEgo:get(INV_SRISRIOFF))
        	(Charger:hide())

        	(Zap:hide())
		)
			(if((== $0004 OnControl(ocSPECIAL (send gEgo:x) (send gEgo:y))))
      (send gRoom:newRoom(80))
			)
			(if((== $0002 OnControl(ocSPECIAL (send gEgo:x) (send gEgo:y)) ) and (== Praiseone 1) )
				(send gRoom:newRoom(3))
			)
    (if((== (Demonmove:y) (send gEgo:y)) and (== demo 1))
    	(Demonmove:hide())
    	= demo 0
    	(send gEgo:setMotion(MoveTo 125 175 2))
					(send gEgo:view(117))
				(send gEgo:setCycle(Fwd))
				(send gTheMusic:fade())
				(send gTheMusic:
			prevSignal(0)
			stop()
			number(87) 
			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.")

	)



	(if(== (Demonspawn:cel) 7)
		(Demonspawn:dispose())
		(Demonmove:init())
		(Demonmove:setCycle(Walk))
		(Demonmove:ignoreActors())
		(Demonmove:ignoreControl(ctlWHITE))
		(Demonmove:setMotion(MoveTo (send gEgo:x) (send gEgo:y) 2))

	)
			(if((== $0002 OnControl(ocSPECIAL (send gEgo:x) (send gEgo:y))) and == Praiseone 0 and (== spinhead 0))
				(send gTheMusic:
			prevSignal(0)
			stop()
			number(607) 
			loop(-1)
			play()
		)
				Print("As you turn to leave, you are overcome by a feeling of dropping air pressure. Your ears pop and ring. The hairs on the back of your neck and at the end of your chin stand on end")
				Print("The old gypsy woman did not lie.")

			= demo 1
		= spinhead 1

				= gProgramControl TRUE
				(Demonspawn:init())
				(Demonspawn:setCycle(End))


			)


		(super:doit())

		(Mirrorkat:view((send gEgo:view)))
		(Mirrorkat:setCycle(Walk))
		(Mirrorkat:setPri(1))


		(if(== (send gEgo:loop) 3)
			(Mirrorkat:setLoop(2))
		)

	(if(== (send gEgo:loop) 2)
			(Mirrorkat:setLoop(3))
		)
			(if(== (send gEgo:loop) 0)
			(Mirrorkat:setLoop(0))
		)
			(if(== (send gEgo:loop) 1)
			(Mirrorkat:setLoop(1))
		)

		(Mirrorkat:setMotion(MoveTo (send gEgo:x) (- (send gEgo:y) 30) 2))

		// 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((Mirrorkat:view))loop((Mirrorkat:loop))cel((Mirrorkat:cel))posn((Mirrorkat:x) (Mirrorkat:y))setPri((Mirrorkat:priority))ignoreActors()addToPic())
				(send (View:new()):view((Cello:view))loop((Cello:loop))cel((Cello:cel))posn((Cello:x) (Cello:y))setPri((Cello:priority))ignoreActors()addToPic())

				(if(not (send gEgo:has(INV_SRISRI)))
				(send (View:new()):view((Charger:view))loop((Charger:loop))cel((Charger:cel))posn((Charger:x) (Charger:y))setPri((Charger:priority))ignoreActors()addToPic())
				)
				(send (View:new()):view((Plant:view))loop((Plant:loop))cel((Plant:cel))posn((Plant:x) (Plant:y))setPri((Plant: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('praise / satan') and == demonone 0)
			= Praiseone 1
			= satancount 200
		Print("Oh, Lordy.")
		(send gGame:changeScore(5))
		)
	(if(Said('get / smartphone,charger,phone'))

  (if((< GetDistance((send gEgo:x) (send gEgo:y) 284 128) 35) and (not (send gEgo:has(INV_SRISRI))) and (not (send gEgo:has(INV_SRISRIOFF))))

			(Zap:posn((send gEgo:x) (send gEgo:y)))
			(Zap:init())
			(Zap:setPri(14))
			(Zap:ignoreActors())
			(Zap:setCycle(End))
			(send gGame:changeScore(3))

 )
(else
	Print("One of the following: A. You are too far away. B. You possess them/it already. C. They/it have/has served their/its purpose. D. You're out of your element.")
        		Print("Donnie.")
)
	)

			(if(Said('look >'))
        	(if(== contactsin 1)
        	        	(if(Said('/ plant'))
        	        		Print("The Chinese War Orchid is said to feed from the violent, depraved energies of its environment. It has quadrupled in size during its week by your bedside.")
						)(else

						(if(Said('/ bed'))
							Print("Looking over its dimensions, you compliment yourself on opting for the demigogue-sized model from supine-the-spine. It is flanked by two nightstands. Its normal occupants are yourself and your husband, who is currently shooting a techno-thriller on location in Tasmania.")
						)
						(else
							(if(Said('/ nightstand'))
								Print("One nightstand supports a potted plant. The other contains your adventurer's clothes.")
							)
								(else
							(if((Said('/ charger,smartphone,phone')) and not (send gEgo:has(INV_SRISRI)))
								Print("Your second-hand DroneFone lies suckling from the lifesblood of the grid.")
							)
							(else
					(if(Said('/ mirror'))
						(if((== $2000 OnControl(ocSPECIAL (send gEgo:x) (send gEgo:y))) and (== (send gEgo:loop) 3))
				Print("A young lass cacthes your eye in the mirror. Who is this vision, this veritable seraphim on Earth? You smile, which produces an audible creaking in the mirror.")
				Print("You note what seems to be a large mole under your chin that had escaped notice.")
						)
				(else
				Print("Just as soon as youve worked up the courage to stand in front of it.")
				)
					)
					(else
			(if(Said('/ mole') and (== $2000 OnControl(ocSPECIAL (send gEgo:x) (send gEgo:y))) and (== (send gEgo:loop) 3))
					Print("It's a tattoo, actually.")
			)
			(else

			(if(Said('[look, read] / tattoo') and (== $2000 OnControl(ocSPECIAL (send gEgo:x) (send gEgo:y))) and (== (send gEgo:loop) 3))
				Print("'natas esiarp'")
				
			)

						 (else
						(if(Said('[ /* , !* ]'))
							Print("The clean, rosey walls of your room surround you. You feel incredibly safe here, like being tucked deep in mama's fat belly. Which is all the more impressive, considering it was bought with drug money.")

												)
						 )
						 )
						 )
			)
						)
						 )
			)


			)


			)
		(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.")
			)



		// handle Said's, etc...

	)

	(method (changeState newState)
		(= state newState)
		(switch (newState)
			(case 0


				// Handle state changes
			)




		)
	)
)
/******************************************************************************/
(instance Plant of Prop
	(properties
		x 206
		y 76
		view 23
		loop 0

	)

)
(instance Mirrorkat of Act
	(properties
		x 95
		y 135
		view 2
		loop 0
		priority 1
	)
)
(instance Charger of Prop
	(properties
		x 284
		y 128
		view 84
		loop 0
		priority 9
	)

)
(instance Zap of Prop
	(properties
		x 284
		y 128
		view 88
		loop 0
		priority 14
	)

)
(instance Demonspawn of Prop
	(properties
		x 250
		y 120
		view 66
		loop 0
		priority 9
	)

)
(instance Cello of Prop
	(properties
		x 273
		y 97
		view 102
		loop 0
		priority 6
	)

)
(instance Demonmove of Act
	(properties
		x 250
		y 121
		view 68
		loop 0
		priority 10
	)
)
