/******************************************************************************/
(include "sci.sh")
(include "game.sh")
/******************************************************************************/
(script 92)
/******************************************************************************/
(use "controls")
(use "cycle")
(use "door")
(use "feature")
(use "game")
(use "inv")
(use "main")
(use "obj")
(local
onRed2
dyingScript
rmNum
busComing
teext1
car_
)
/******************************************************************************/
(instance public rm092 of Rm
	(properties
		picture 92
		north 0
		east 0
		south 0
		west 0
	)
	(method (init)
		(super:init())
		(self:setScript(RoomScript))
     (send gEgo: put(INV_WATER))
       (send gEgo: put(INV_EMPTY_BOTTLE))
		(switch(gPreviousRoomNumber)

			(case 93
     (send gTheMusic:
			prevSignal(0)
			stop()
			number(395)
			loop(-1)
			play()

		)
				(send gEgo:
					posn(55 160)
					loop(0)
				)
			)
   		(case 976
     (send gTheMusic:
			prevSignal(0)
			stop()
			number(395)
			loop(-1)
			play()

		)
				(send gEgo:
					posn(55 160)
					loop(0)
				)
			)
   (case 91
   = BusIs FALSE
   (send gEgo:
					posn(164 147)
					loop(2)
				)

   )
		)
         (aSign: init())
		SetUpEgo()
		(send gEgo:init())
  PlayerControl()
  = gTimeSeconds2 Random(10 13)
	)
)
/******************************************************************************/
(instance End1 of Script
	(properties)
(method(changeState newState)
 = newState 0
 = state newState
 (switch(state)
 (case 0
 = BusIs TRUE
 = busComing FALSE
 ))))
 (instance End2 of Script
	(properties)
 (method(changeState newState)
 = newState 0
 = state newState
 (switch(state)
 (case 0
  (if(== car_ 0)
 = BusIs FALSE
 (aBus: dispose())
 = gTimeSeconds2 Random(10 13)
 )
 (if(== car_ 1)
 (aCar1: dispose())
 = car_ 0
 )
 ))))
  (instance End3 of Script
	(properties)
 (method(changeState newState)
 = newState 0
 = state newState
 (switch(state)
 (case 0
Wait(5)
   (aBus: dispose())
 (send gEgo: view(129) posn(Xposn 189))
       = dyingScript ScriptID(DYING_SCRIPT)
  (send dyingScript:
    caller(3)
    register("The streets can be dangerous. Too darn dangereous.")
  )
  (send gGame:setScript(dyingScript))

) )))


(instance RoomScript of Script
	(properties)
  	(method (handleEvent pEvent)
        (super:handleEvent(pEvent))
        (if(Said('enter,board,ride,(get,go<on)/bus') or (if(Said('open/door') or (if(Said('(get,go<in,on)'))))))
                (if(BusIs)
        (if(< (send gEgo:distanceTo(aBus)) 35)
        (if(talkedSaler)
= rmNum Print("Select your destination. Ticket fee is 25 dakos.\n\n" #button "Casino" 89 #button "Hotel" 84 #button "Tool Store" 126 #button "Store" 92)
    (if(== rmNum 92)
        Print("You're are already at the store.")
        return
        )(if(< money 25)
        Print("You don't have enough money to buy a ticket.")
        //Print("But if you want to cheat and lose 10 points, type in 'cheat money' to get an extra 25 bucks so you could go to the casino to eran more. But it only works once.")
        return
        )
        (if(busComing)
          Print("The bus is moving.")
        return
        )
        -= cash 25
        (send gRoom: newRoom(rmNum))
        return
        )
        Print("You have no idea where to go.")
        return
        )
        Print("You're too far away from the bus door. (It's in the middle)")
        return
        )
        Print("There is no bus.")

        return
        )
        (if(Said('look>'))
        (if(Said('/bus'))
        (if(BusIs)
      Print("This is the local public people transport vehicle - a bus.")
        return
        )
Print("This is where the bus parks. The buses go here very often, just wait a bit.")
)
(if(Said('/stop'))Print("This is were buses park while people get on and off the bus."))
(if(Said('/pavement,sidewalk'))Print("The sidewalks look very clean. They must be using some special equipment."))
(if(Said('/road'))Print("The traffic sure is heavy around here."))
(if(Said('/traffic'))Print("It moves by so fast, that it's not very easy to look at it."))

(if(Said('/door'))
Print("This door leads into the store.")
)
(if(Said('/fence'))
Print("The boards of the fence are parrallel with the store wall.")
)
(if(Said('/window,(display<window)'))
Print("You can see inside the store. Isn't it cool!!?")
)
(if(Said('/sign'))
(if(BusIs)
Print("This is where the bus parks. The buses go here very often.")
return
)
Print("This is where the bus parks. The buses go here very often, just wait a bit.")
)
        (if(Said('/store,building'))
        Print("It's a store thats open 56 hours a day. Is that the whole day?")
        )
       (if(Said('/wall'))
        Print("You see a store wall. There's a bus-schedule on the wall.")
        )
        (if(Said('/schedule,(bus<schedule)'))
        (if(==(send gEgo: onControl()) ctlYELLOW)
        Print("According to this, buses go every 20 seconds here.")
        return
        )
        Print("The schedule is in fine print, so get closer.")
)
(if(Said('/'))
Print("You're outide the local store - The city center. A bus stop sign is near the road. A bus schedule is on the wall, next to the store door.")
        )
        )
        )
 (method(doit)
 (super: doit())
 (if(> (send gEgo: x) 312)
 Print("You shouldn't go off wondering through this city. Take the bus instead.")
  (send gEgo: setMotion(MoveTo 310 (send gEgo: y)))
  )
 (if(< (send gEgo: x) 6)
 Print("You shouldn't go off wondering through this city. Take the bus instead.")
  (send gEgo: setMotion(MoveTo 9 (send gEgo: y)))
  )
 (if(==(send gEgo: onControl()) ctlRED)
  (if(not(BusIs))
  (if(not(onRed2))
  = onRed2 TRUE
  ProgramControl()
  (send gGame:setSpeed(0))
  (send gEgo: posn(Xposn 182))
 (aBus: init() posn(320 189)setMotion(MoveTo Xposn 189 End3))
 return
  )
  )
  (send gEgo: setMotion(MoveTo (send gEgo: x) 169))
  )
 (if(==(send gEgo: onControl()) ctlNAVY)
 (send gRoom: newRoom(91))
 )
 (if(== gTimeSeconds2 13)
  (if(== car_ 0)
  = car_ 1
 (aCar1: init() cel(Random(2))  moveSpeed(0) xStep(28) posn(320 188) setMotion(MoveTo 0 186 End2)))
 )
 (if(== gTimeSeconds2 28)
 (if(== car_ 0)
  = car_ 1
 (aCar1: init() cel(Random(2))  moveSpeed(0) xStep(28) posn(320 188) setMotion(MoveTo 0 186 End2)))
 )
 (if(== gTimeSeconds2 20)
  (if(== car_ 0)
  = car_ 1
 (aCar1: init()  cel(Random(2))  moveSpeed(0) xStep(28) posn(320 188) setMotion(MoveTo 0 186 End2)))
 )
 (if(== gTimeSeconds2 23) //bus arrives #1
 += gTimeSeconds2 1
= busComing TRUE
= BusIs TRUE
 (aBus: init() posn(320 189) setMotion(MoveTo 150 189 End1))
 )
 (if(== gTimeSeconds2 45) //bus leaves #1
  += gTimeSeconds2 1
  (aBus: setMotion(MoveTo 0 189 End2))
 )
 )
)
(instance aBus of Act
(properties
view 122
x 320
y 189
))
(instance aCar1 of Act
(properties
view 708
x 320
y 186
cel 0
))
(instance aSign of Prop
(properties
view 145
x 152
y 175
))
(instance aRadio of Prop
(properties
view 821
x 30
y 48
))
(instance aE of Act
 (properties
 view 300
 x 1
 y 180
 ))
/******************************************************************************/
