/******************************************************************************/
(include "sci.sh")
(include "game.sh")
/******************************************************************************/
(script 4)
/******************************************************************************/
(use "main")
(use "controls")
(use "cycle")
(use "game")
(use "feature")
(use "obj")
(use "inv")
(use "door")
(use "jump")
(use "dpath")
/******************************************************************************/
(local
	kurb
)
(instance public rm004 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(295 150)
      loop(1)
			)
			)
				(case 8
			(send gEgo:
      posn(295 150)
      loop(1)
			)
			
			)
			(default
				(send gEgo:
					posn(110 170)
					loop(1)
				)
			)
		)
		
		SetUpEgo()
		(send (View:new()):view((Webur:view))loop(0)cel(0)posn((Webur:x) (Webur:y))setPri(15)ignoreActors()addToPic())
				(send (View:new()):view((Webul:view))loop(0)cel(0)posn((Webul:x) (Webul:y))setPri(15)ignoreActors()addToPic())
		
	(send (View:new()):view((Webll:view))loop(0)cel(0)posn((Webll:x) (Webll:y))setPri(15)ignoreActors()addToPic())
				(send (View:new()):view((Weblr:view))loop(0)cel(0)posn((Weblr:x) (Weblr:y))setPri(15)ignoreActors()addToPic())

	(if(not (send gEgo:has(INV_MITTS)) )
	(Mitts:init())
	(Mitts:setPri(12))
	)

(if(== maskon 1)
			(send gEgo:view(6))
		)
		(if(not (send gEgo:has(INV_ENVELOPE)))
			(Paper:init())
			(Paper:setPri(2))
		)

	(if(== opencab 1)
		(Waste:init())
		(Waste:setLoop(1))
		(Waste:ignoreActors())
		(Waste:setPri(8))
	)
	
		(send gEgo:init())
		(if(== clotheson 0)
			(send gEgo:view(3))
		)
	)
)
/******************************************************************************/
(instance RoomScript of Script
	(properties)

	(method (doit)
		(var dyingScript)
		(if(== cancer 1)
				= dyingScript ScriptID(DYING_SCRIPT)
  Print(1 13)
  
  
  (send dyingScript:
    caller(114)
    register(1 14)
    
 )
			
			
		
  (send gGame:setScript(dyingScript))
		)
		--satancount
		(if((== satancount 45) and (== praisetwo 0) and (== Praiseone 1))
			Print(1 15)
		
			
		)
			(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(1 16)
			= gProgramControl TRUE
		
			
	)
		(if((== satancount 0) and (== praisetwo 1))
			= praisetwo 0
			= satancount 550
		)
		(if((== $0004 OnControl(ocSPECIAL (send gEgo:x) (send gEgo:y))))
      (send gRoom:newRoom(3))
			)
			(if((== kurb 0) and (== $0800 OnControl(ocSPECIAL (send gEgo:x) (send gEgo:y)))  and (<> (send gEgo:view) 3))
				Print(1 17)
				Print(1 18)
			= kurb 1
			
			)
				(if(== click 2)
			Print("Cheese!")
					DrawPic(gRoomNumber dpOPEN_INSTANTLY dpCLEAR )
					= click 0
					(send (View:new()):view((Webur:view))loop(0)cel(0)posn((Webur:x) (Webur:y))setPri(15)ignoreActors()addToPic())
				(send (View:new()):view((Webul:view))loop(0)cel(0)posn((Webul:x) (Webul:y))setPri(15)ignoreActors()addToPic())
		
	(send (View:new()):view((Webll:view))loop(0)cel(0)posn((Webll:x) (Webll:y))setPri(15)ignoreActors()addToPic())
				(send (View:new()):view((Weblr:view))loop(0)cel(0)posn((Weblr:x) (Weblr: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((== $0800 OnControl(ocSPECIAL (send gEgo:x) (send gEgo:y)))  and (== (send gEgo:view) 3))
				= gProgramControl TRUE
			(send gTheMusic:
			prevSignal(0)
			stop()
			number(43) 
			loop(-1)
			play()
		)
				(send gEgo:hide())
				(Slipnfall:init())
	(Slipnfall:setCycle(End))
	(Slipnfall:setPri(8))
	
	
			)
			(if(== (Slipnfall:cel) 7)
			
					ShakeScreen(5 ssFULL_SHAKE)
				(Slipnfall:hide())
				(Blood:init())
	(Blood:setCycle(End))
	(Blood:setPri(8))
	(Slipnfall:setLoop(1))
	= dyingScript ScriptID(DYING_SCRIPT)
  
  (send dyingScript:
    caller(158)
    register("It must have slipped your mind.")
    
 )
	  Print(1 19)
	  Print(1 20)	
  (send gGame:setScript(dyingScript))
			)
				
		(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((Webur:view))loop((Webur:loop))cel((Webur:cel))posn((Webur:x) (Webur:y))setPri((Webur:priority))ignoreActors()addToPic())
				(send (View:new()):view((Webul:view))loop((Webul:loop))cel((Webul:cel))posn((Webul:x) (Webul:y))setPri((Webul:priority))ignoreActors()addToPic())
				
				(if(not (send gEgo:has(INV_MITTS)))
				(send (View:new()):view((Mitts:view))loop((Mitts:loop))cel((Mitts:cel))posn((Mitts:x) (Mitts:y))setPri((Mitts:priority))ignoreActors()addToPic())
				)
				(if(not (send gEgo:has(INV_ENVELOPE)))
				(send (View:new()):view((Paper:view))loop((Paper:loop))cel((Paper:cel))posn((Paper:x) (Paper:y))setPri((Paper:priority))ignoreActors()addToPic())
				)
				(if(== opencab 1)
				(send (View:new()):view((Waste:view))loop((Waste:loop))cel((Waste:cel))posn((Waste:x) (Waste:y))setPri((Waste:priority))ignoreActors()addToPic())
				)
				(send (View:new()):view((Webll:view))loop((Webll:loop))cel((Webll:cel))posn((Webll:x) (Webll:y))setPri((Webll:priority))ignoreActors()addToPic())
				(send (View:new()):view((Weblr:view))loop((Weblr:loop))cel((Weblr:cel))posn((Weblr:x) (Weblr:y))setPri((Weblr: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('do / taxes')) and (<  GetDistance((send gEgo:x) (send gEgo:y) 176 90) 42) and not (send gEgo:has(INV_ENVELOPE)))
			= gNormalCursor 999
			(send gGame:setCursor(gNormalCursor SET_CURSOR_VISIBLE 304 174))
			
			(send gRoom:newRoom(8))
		)
		(if(Said('open/cabinet') and (<  GetDistance((send gEgo:x) (send gEgo:y) 98 160) 25) and (== opencab 0))
			(Waste:init())
			(Waste:ignoreActors())
			(Waste:setPri(8))
			(Waste:setCycle(End))
			= opencab 1
			Print(1 21)
			
		)
		(if((Said('open,tear/bag')) and (== opencab 1) and (<  GetDistance((send gEgo:x) (send gEgo:y) 98 160) 25))
			Print(1 22)
			Print(1 23)
			(send gEgo:get(INV_CATHETER))
			(send gEgo:get(INV_MASK))
			= opencab 2
			(Waste:hide())
			(send gGame:changeScore(3))
		)
			
		(if(Said('roll'))
			(send gRoom:newRoom(10))
		)
		// handle Said's, etc...
		 (if(Said('get / mitts'))
  	
  (if((<  GetDistance((send gEgo:x) (send gEgo:y) 134 128) 35) and not (send gEgo:has(INV_MITTS)))
        	(send gGame:changeScore(1))
        	(send gEgo:get(INV_MITTS))
        	(Mitts:hide())
 )
        	
				(else
					Print(1 24)
        		Print(1 25)
				)
		 )
		 	(if( (Said('wear/contacts')) and (send gEgo:has(INV_CONTACTS)) and (== contactsin 0))
			Print(1 26)
			= contactsin 1
			(send gEgo:put(INV_CONTACTS))
			(send gEgo:get(INV_CONTACTSEMPTY))
			
		)
		
			(if( (Said('wear/contacts')) and not(send gEgo:has(INV_CONTACTS)))
			Print(1 27)
		)
				
        (if( (Said('remove/contacts')) and (== contactsin 1))
        	Print(1 28)
        	(send gEgo:put(INV_CONTACTSEMPTY))
        	(send gEgo:get(INV_CONTACTS))
        	= contactsin 0
		)
        
        	(if( Said('remove/contacts') and (== contactsin 0))
        	Print(1 27)
		)
			
	(if(Said('look >'))
        	(if(== contactsin 1)
        	        	(if((Said('/ paper,taxes,document')) and not (send gEgo:has(INV_ENVELOPE)))
        	        		Print(1 29)
						)(else
							
						(if((Said('/ mitts,glove')) and not (send gEgo:has(INV_MITTS)))
				
							Print(1 30)
						)
						(else
							(if(Said('/ cabinet'))
								Print(1 31)
								Print(1 32)
							)
					
						 
						 (else
						 	(if(Said('/bag') and (== opencab 1))
						 		Print(1 33)
							)
							(else
								(if(Said('/web,spiderweb'))
									Print(1 34)
								)
								(else
						 	
						 	
						(if(Said('[ /* , !* ]'))
							Print(1 35)
								
												)
								)
							)
						 )
						)
						 )
			)
						 	
        	        	
			)
	
	
	
	)
	

	(method (changeState newState)
		(= state newState)
		(switch (newState)
			(case 0
				= cycles 1
				// Handle state changes

			)
			(case 1
			)
			
	
			
			
			
		)
	)
)

/******************************************************************************/
(instance Bio of Prop
	(properties
		x 122
		y 152
		view 119
		loop 0
	)
		
)
(instance Weblr of Prop
	(properties
	x 116
		y 85
		view 140
		loop 0
	)
		
)
(instance Webll of Prop
	(properties
	x 116
		y 85
		view 141
		loop 0
	)
		
)
(instance Webur of Prop
	(properties
		x 116
		y 85
		view 142
		loop 0
	)
		
)
(instance Webul of Prop
	(properties
		x 116
		y 85
		view 143
		loop 0
	)
		
)
(instance Mitts of Prop
	(properties
		x 134
		y 128
		view 155
		loop 0
	)
		
)

(instance Slipnfall of Prop
	(properties
		x 168
		y 151
		view 156
		loop 0
	)
	
		
)

(instance Blood of Prop
	(properties
		x 113
		y 155
		view 45
		loop 0
	)
		
)
(instance Waste of Prop
	(properties
		x 98
		y 160
		view 85
		loop 0
	)
		
)
(instance Paper of Prop
	(properties
		x 176
		y 90
		
		view 116
		loop 0
		priority 2
	)
		
)