(include "sci.sh")
(include "game.sh")
/******************************************************************************/
(script 80)
/******************************************************************************/
(use "main")
(use "controls")
(use "cycle")
(use "game")
(use "feature")
(use "obj")
(use "inv")
(use "door")
(use "jump")
(use "dpath")
/******************************************************************************/
(local

	sleepist = 1
	hWnd
	oldPort
	sleepum[20]
	happy
	mbPesult
	savecel
	saveloop
	knotup  = 1
	lookmuch
	Nope = 50
	sleeptime

	katx
	katy

)


(instance public rm080 of Rm
	(properties
		picture scriptNumber
		// Set up the rooms to go to/come from here
		north 0
		east 2
		south 0
		west 0
	)
 		(method (init)
		// same in every script, starts things up
  		(super:init())
  		(self:setScript(RoomScript))

  		// Check which room ego came from and position it
  		(switch(gPreviousRoomNumber)
            /******************************************************
             * Put the cases here for the rooms ego can come from *
             ******************************************************/ /*
            (case north
  				(send gEgo:
  					posn(210 110)
  					loop(2)
  				)
  			)*/
            // Set up ego's position if it hasn't come from any room

            (case east
            	(send gEgo:
            		posn(220 185)
            		loop(1)
				)
			)

  			(default
  				(send gEgo:
  					posn(155 155)
  					loop(0)
  				)
  			)
  		)

		// Set up the ego
		SetUpEgo()
		(if(== clotheson 0)
			(send gEgo:view(3))
		)
		(if(== maskon 1)
			(send gEgo:view(6))
		)

		(if(== sliphav 0)
		(Slippers:init())
		(Slippers:ignoreActors())
		(Slippers:setPri(6))
		)
		(if(not (send gEgo:has(INV_CONTACTS)) and not (send gEgo:has(INV_CONTACTSEMPTY)))
		(Kontacts:init())
		(Kontacts:setPri(3))
		)

		(send (View:new()):view((Plant:view))loop(0)cel(0)posn((Plant:x) (Plant:y))setPri(12)ignoreActors()addToPic())



		(if(== standyn 0)
			(SleepKat:setLoop(1))
			(SleepKat:init())
(SleepKat:setCycle(Fwd))
(SleepKat:setPri(15))

		)
		(else
			(send gEgo:init())
		)
		
        /****************************************
         * Set up the room's music to play here *
         ****************************************/ /*
		(send gTheMusic:
			prevSignal(0)
			stop()
			number(scriptNumber)
			loop(-1)
			play()
		)*/

        /**************************************************
         * Add the rest of your initialization stuff here *
         **************************************************/
		)
)
/******************************************************************************/
(instance RoomScript of Script
	(properties)
	(method (doit)
		(var dyingScript)

		--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))
					)
				(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((== $0100 OnControl(ocSPECIAL (send gEgo:x) (send gEgo:y))) and (== pandafeet 0))

        	= katx (send gEgo:x)
  = katy (send gEgo:y)
  (send gEgo:hide())


  (Frozekat:posn(katx katy))
 (Frozekat:init())
  (Frozekat:setCycle(End))


  	= dyingScript ScriptID(DYING_SCRIPT)
  Print("A chill wicks up your spine through your bare feet as you foolhardedly make your way across the room. You are not 10 paces before your insensitive limbs lock up, and you succumb to the arctic 72 F Blairville spring.")


  (send dyingScript:
    caller(87)
    register("That was cold-blooded, nigga. Cold-blooded.")

 )

  (send gGame:setScript(dyingScript))
		)


		(if(== click 2)
			Print("Cheese!")
					DrawPic(gRoomNumber dpOPEN_INSTANTLY dpCLEAR )
					= click 0
				)
		(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))
				)


		(super:doit())
	)


	(method (handleEvent pEvent)
		(var dyingScript)
        (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(23)loop(0)cel(0)posn(250 85)setPri(1)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('(wake < up), awaken'))

        		Print("You pinch yourself hard enough to draw blood. No dice.")
		)



	   (if(Said('stand,get / slowly'))
	   							   	(send gEgo:init())
	   	(send gEgo:loop(1))
        	(SleepKat:hide())
        	= standyn 1
        	(send gEgo:view(2))
        	(send gTheMusic:
			prevSignal(0)
			stop()
			number(46) 
			loop(-1)
			play()
		)


	   )



	   (if(Said('remember / dream'))


		(if(== sleeper 0)
			Print("You dimly recall a row of baffled ape-like faces lit by a large campfire, and find yourself humming the melody to Return to Innocence without quite knowing why.")
			(send gGame:changeScore(1))
			)
			(else
				Print("The dream has faded from mind.")
			)
	   )
	(if((Said('get,stand < up')) and (== standyn 0))

 		= dyingScript ScriptID(DYING_SCRIPT)
  Print("You bolt upright, then lunge from the edge of the bed, only to be met with a muffled 'pop' from inside your skull, as the clot you've thrown lodges in your delicate frontal cortex.")
  (SleepKat:hide())
  (Strokebody:init())
  Wait(2)
  Print("As the stroke takes hold, your last words, slurred out the good side of your mouth, are: 'Gofsh, thiff floor iff weely cohwd.'")

  (send dyingScript:
    caller(101)
    register("Hope you halved yourself a good time!")

 )
  (send gGame:setScript(dyingScript))
	)


        	(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('/window'))
								Print("Sometimes you feel like...somebody's watching you.")
								Print("And that you have no privacy.")
							)

						 (else
						 	(if(Said('/drawer') and (== opendrawer 1))
						 		Print("At the bottom of the drawer are your anthro-adventurer's clothes.")
							)
							(else
								(if(Said('/drawer') and (== opendrawer 1) and (== clotheson 1))
									Print("The drawer is empty.")
								)
								(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(== standyn 1)

        	 (if(Said('get / slippers'))

  (if((<  GetDistance((send gEgo:x) (send gEgo:y) 145 172) 50) and not (send gEgo:has(INV_SLIPPERS)) and (== sliphav 0))
        	= sliphav 1
        	(send gEgo:get(INV_SLIPPERS))
        	(Slippers:hide())
 )
        	(else
        		Print("One of the following: A. You are too far away. B. You possess them already. C. They have served their purpose. D. You're out of your element.")
        		Print("Donnie.")
			)
			 )
 (if(Said('wear / slippers') and (send gEgo:has(INV_SLIPPERS)))
 	Print("You squeeze your dainty size 13's into the slippers. The eyes of the Mellow Panda graphic at the toes bulge like a Koi's.")
 	= pandafeet 1
 	(send gEgo:view(3))
 	(send gGame:changeScore(1))
)

        (if(Said('take/contacts'))
  (if((send gEgo:has(INV_CONTACTS)) and (== standyn 1))
    Print("You already have it!")
  )(else
    (if(<  GetDistance((send gEgo:x) (send gEgo:y) 106 117) 50)
      Print("O.K.")
      (send gGame:changeScore(1))

      (send gEgo:get(INV_CONTACTS))
      = contactsin 0
      (Kontacts:hide())
    )(else
      Print("You're not close enough!")
    )
  )
		)
		(if(Said('take,wear/clothes') and (== opendrawer 1) and (send gEgo:has(INV_CORALSNAKE)) and (<> (send gEgo:view) 4))
			Print("You slip into something a little less cofortable.")
			(send gEgo:view(0))
			= clotheson 1
			(send gGame:changeScore(1))
		)
		(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('open/drawer/mitts') and (send gEgo:has(INV_MITTS)) and (== opendrawer 0))
			(if(<  GetDistance((send gEgo:x) (send gEgo:y) 110 135) 30)
				(Opendrawer:init())
				(Opendrawer:setLoop(1))
					(Opendrawer:setCycle(End))

				Print("Oven mitts donned, you pull at the drawer. It's barely a crack open before a coral snake darts from the blackness to stab futilely at your thickly swaddled wrist.")
				Print("You take him by his scaly scruff and stuff him into your possession.")
				(send gEgo:get(INV_CORALSNAKE))
				= opendrawer 1
				(send gGame:changeScore(5))
			)
		)



		(if(Said('open / drawer') and (== opendrawer 0))
		(if((<  GetDistance((send gEgo:x) (send gEgo:y) 110 135) 30) and (== wearmitts 0))
			(Opendrawer:setLoop(0))
			(Opendrawer:init())

			(Opendrawer:setCycle(End))
				= dyingScript ScriptID(DYING_SCRIPT)

			Print("You yank open the drawer, and a jolt of adrenaline allows you a slow-motion vision of Hisses, the coral snake you rescued from the side of the road, as it sinks its fangs deep into your wrist meat.")
			Print("Said adrenaline also speeds the venom to a none-too-pleased heart n' brain.")
			(send dyingScript:
    caller(34)
    register("Red on black, you're okay, Jack. Red on yellow, and you just got bit by a poisonous fucking snake.")

			)
  (send gGame:setScript(dyingScript))
		)


		(else
			Print("Get closer, it's not going to bite.")
		)
		)
			)
			(else
			(if(Said('get,take,wear,open,walk/'))
				Print("That's better accomplished from an upright position.")
				(send pEvent:claimed(TRUE))
			)





			)
	)


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

				// Handle state changes
			)
			(case 1
				= seconds 10

				= sleeper 1
			)


		)
)
	)




(instance SleepKat of Prop
	(properties
		x 203
		y 145
		view 5
		loop 0
	)

)
(instance Slippers of Prop
	(properties
		x 145
		y 172
		view 13
		loop 0
	)

)
(instance Kontacts of Prop
	(properties
		x 106
		y 117
		view 19
		loop 0
	)

)
(instance Plant of Prop
	(properties
		x 250
		y 85
		view 23
		loop 0
	)

)

(instance Frozekat of Prop
	(properties
		x 105
		y 107
		view 24
		loop 0
	)

)
(instance Opendrawer of Prop
	(properties
		x 112
		y 138
		view 111
		loop 0
	)

)
(instance Strokebody of Prop
	(properties
		x 130

		y 171
		view 101
		loop 0
	)

)
/******************************************************************************/

