/******************************************************************************/
(include "sci.sh")
(include "game.sh")
/******************************************************************************/
(script 6)
/******************************************************************************/
(use "Controls")
(use "Cycle")
(use "Door")
(use "Feature")
(use "Game")
(use "Inv")
(use "Main")
(use "Obj")
(use "dpath")
/******************************************************************************/
(local
	pollenresetR
	pollenresetL
	pollenrandR
	pollenrandL
	popper
)
(instance public rm006 of Rm
	(properties
		picture scriptNumber
		north 0
		east 0
		south 0
		west 0
	)
	(method (init)
		(super:init())
		(self:setScript(RoomScript))
		
		(switch(gPreviousRoomNumber)
			(case 3
			(send gEgo:
      posn(202 136)
      loop(2)
			)
		)
			(default
				(send gEgo:
					posn(150 130)
					loop(1)
				)
			)
		)
		
		SetUpEgo()
		(send gEgo:init())
		(if(== maskon 1)
			(send gEgo:view(6))
		)
		(send (View:new()):view((Backntime:view))loop(0)cel(0)posn((Backntime:x) (Backntime:y))setPri(13)ignoreActors()addToPic())
		(send (View:new()):view((FloursL:view))loop(0)cel(0)posn((FloursL:x) (FloursL:y))setPri(15)ignoreActors()addToPic())
		(send (View:new()):view((FloursR:view))loop(0)cel(0)posn((FloursR:x) (FloursR:y))setPri(15)ignoreActors()addToPic())
		
		(PollenL:
  init()
  setCycle(Walk)
  setMotion(DPath 60 90 150 80 220 95 325 82)
		)
		(PollenR:
  init()

  
  setCycle(Walk)
  setMotion(
     DPath
     40 55
     100 38
     210 60
     325 50
  )
		)
	)
)
/******************************************************************************/
(instance RoomScript of Script
	(properties)

	(method (doit)
		(var dyingScript)
		(super: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((Backntime:view))loop(0)cel(0)posn((Backntime:x) (Backntime:y))setPri(13)ignoreActors()addToPic())
		(send (View:new()):view((FloursL:view))loop(0)cel(0)posn((FloursL:x) (FloursL:y))setPri(15)ignoreActors()addToPic())
		(send (View:new()):view((FloursR:view))loop(0)cel(0)posn((FloursR:x) (FloursR:y))setPri(15)ignoreActors()addToPic())
		
				)
		(if(== click 1)
			Print("Click!")
				= picspot Display("                                                                                        "
                    dsCOORD clickx clicky
                    dsALIGN alCENTER
                    dsCOLOUR clCYAN
                    dsBACKGROUND -1
                    dsWIDTH 80
                    dsSAVEPIXELS
								 )


								 = click 2
					)
		
		(if(== popper 1)
			(if(== (send gEgo:view) 6)
				Print("The second-hand surgical mask saves you from certain anaphylactic shock, which is some consolation in light of the hepatitis you've contracted.")
			= popper 0
			)
			(else
			= popper 0
			(send gEgo:hide())
		(Pop:posn((send gEgo:x) (send gEgo:y)))
 (Pop:init())
  (Pop:setCycle(End))
  	= dyingScript ScriptID(DYING_SCRIPT)
  Print("The copious springtime pollen incites a violent overreaction from your immune system. The influx of T-cells soon exceeds the maximum capcity of your head.")
Print("You wonder if maybe a braclet would help you to remember your allergy.")  
  
  (send dyingScript:
    caller(103)
    register("You've never done well under pressure.")
    
 )
			
		
		
  (send gGame:setScript(dyingScript))
			)
		)
		
		(if(== pollenresetR 1)
			= pollenrandR Random(1 100)
			(if(> pollenrandR 91)
				= pollenresetR 0
					(PollenR:
  posn(1 50)
  show()

  
  setCycle(Walk)
  setMotion(
     DPath
     40 55
     100 38
     210 60
     325 50
  )
		)
			)
		)
		(if(== pollenresetL 1)
			= pollenrandL Random(1 100)
			(if(> pollenrandL 91)
				= pollenresetL 0
					(PollenL:
  posn(1 80)
  show()

  
  setCycle(Walk)
  setMotion(DPath 60 90 150 80 220 95 325 82)
		)
			)
		)
				
		(if(== (PollenR:x) 318)
			(PollenR:hide())
			= pollenresetR 1
			
					)
		(if(== (PollenL:x) 319)
			(PollenL:hide())
			= pollenresetL 1
		)
		// 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((PollenL:view))loop((PollenL:loop))cel((PollenL:cel))posn((PollenL:x) (PollenL:y))setPri((PollenL:priority))ignoreActors()addToPic())
				(send (View:new()):view((PollenR:view))loop((PollenR:loop))cel((PollenR:cel))posn((PollenR:x) (PollenR:y))setPri((PollenR:priority))ignoreActors()addToPic())
				
				
				
				(send (View:new()):view((Backntime:view))loop((Backntime:loop))cel((Backntime:cel))posn((Backntime:x) (Backntime:y))setPri((Backntime: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('die'))
		(send gEgo:hide())
		(Pop:posn((send gEgo:x) (send gEgo:y)))
 (Pop:init())
  (Pop:setCycle(End))
	)
	(if(Said('open/door'))
		Print("Locked out. Ya done it again!")
	)
	(if((Said('mail/envelope')) and (== $0004 OnControl(ocSPECIAL (send gEgo:x) (send gEgo:y))) and (send gEgo:has(INV_ENVELOPE)) )
      (send gEgo:put(INV_ENVELOPE))
      Print("You show good citizenship for the first time in your life. It's not the thrill you expected it would be.")
	)
	(if((Said('open/car')) and (== $2000 OnControl(ocSPECIAL (send gEgo:x) (send gEgo:y))))
      (if((send gEgo:has(INV_SRISRI)))
      	
      	Print(
  "You were expected at the department many heartbeats ago, Eugenia. No worries, I will set you on the right path."
  #title "SriSri"
  #font DEFAULT_FONT
  #icon 97 0 0
) 
      
      (send gRoom:newRoom(10))
	  )
	  (else
	  	Print("Your class F license requires, by law, that you be guided by a GPS-capable device at all times driving.")
	  )
	)
	
	(if(Said('look >'))
        	        	(if(Said('/ plant'))
        	        		Print("The nighborhood is lousy with foliage.")
						)(else
							
						(if(Said('/ dots,yellow,pollen'))
				
							Print("Clouds of pollen waft gently by, propositioning the eyes and lungs of all in their path.")
						)
						(else
							(if(Said('/ car'))
								Print("The 1987 DeLorean in your driveway means you're still one step ahead of the Libyans. You've grown so tired of running for so long.")
							)
					(else
							(if(Said('/ mailbox'))
								Print("Four settings on this model: open/closed and with/without mail. It is your gateway to your first passion of couponing.")
							)
						 
						 (else
						(if(Said('[ /* , !* ]'))
							Print("The buccolic spring day strikes terror in your heart.")
								
												)
						 )
						)
						 )
	   
						 )
		
		
            
	)
		
		
		
		
		
		
		// handle Said's, etc...
	)

	(method (changeState newState)
		(= state newState)
		(switch (newState)
			(case 0
				= seconds 7
				// Handle state changes
			)
			(case 1
				= seconds 7
			= popper 1
			
			)
		)
	)
)
/******************************************************************************/
(instance Backntime of Prop
	(properties
		x 24
		y 188
		view 61
		loop 0
	)
		
)
(instance FloursL of Prop
	(properties
		x 56
		y 189
		view 120
		loop 0
	)
		
)
(instance FloursR of Prop
	(properties
		x 200
		y 189
		view 121
		loop 0
	)
		
)
(instance PollenR of Act
	(properties
		x 1
		y 50
		view 122
		loop 0
	)
		
)
(instance PollenL of Act
	(properties
		x 25
		y 80
		view 123
		loop 0
	)
		
)
(instance Pop of Prop
	(properties
		x 200
		y 189
		view 99
		loop 0
	)
		
)