/******************************************************************************/
(include "sci.sh")
(include "game.sh")
/******************************************************************************/
(script 84)
/******************************************************************************/
(use "controls")
(use "cycle")
(use "door")
(use "feature")
(use "game")
(use "inv")
(use "main")
(use "obj")
(local
onRed2
dyingScript
rmNum
busComing
car_
)
/******************************************************************************/
(instance public rm084 of Rm
	(properties
		picture scriptNumber
		north 0
		east 0
		south 0
		west 0
	)
	(method (init)
		(super:init())
		(self:setScript(RoomScript))

		(switch(gPreviousRoomNumber)

			(case 83
   = BusIs FALSE
      = gTimeSeconds2 Random(9 14)
				(send gEgo:
					posn(150 130)
					loop(2)
				)
			)
   (default
         = gTimeSeconds2 Random(10 14)
				(send gEgo:
					posn(48 164)
					loop(0)
				)
			)
		)

		SetUpEgo()
		(send gEgo:init())
  (aSign: init())
	)
)
/******************************************************************************/
(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
 (send gEgo: view(129) posn(Xposn 189))
  (aBus:  setMotion(MoveTo 0 189 End4))
 ))))
 (instance End4 of Script
	(properties)
 (method(changeState newState)
 = newState 0
 = state newState
 (switch(state)
 (case 0
 (aBus: dispose())
       = 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('look>'))
(if(Said('/grass'))
Print("The grass is even cut. Wow!")
)
(if(Said('/bus'))
Print("This is where the bus parks. The buses go here very often, just wait a bit.")
)
(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('/sign,marking,name'))
Print("Hotel. Does the star mean it's one star hotel? Hope not.")
)
(if(Said('/window'))
Print("You can't see trough the windows. The light is reflecting..")
)
(if(Said('/roof'))
Print("Regular green roof. Did they copy that from Earth?")
)
(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('/'))
Print("You're outside the hotel. A bus stop is to the right. The entryway is protected with a roof.")
        )
        )
        
        (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 84)
        Print("You're are already at the hotel.")
        return
        )
        (if(< money 25)
        Print("You don't have enough money to buy a ticket.")
        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
        )
        )
 (method(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()) ctlYELLOW)
  (if(not(BusIs))
  (if(not(onRed2))
  = onRed2 TRUE
  ProgramControl()
  (send gGame:setSpeed(0))
  (send gEgo: posn(Xposn 182))
 (aBus: init() setMotion(MoveTo Xposn 189 End3))
  )
  )
  )
 (if(==(send gEgo: onControl()) ctlRED)
 (send gRoom: newRoom(83))
 )
  (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 70 189 End1))
 )
 (if(== gTimeSeconds2 45) //bus leaves #1
  += gTimeSeconds2 1
  (aBus: init() setMotion(MoveTo 0 189 End2))
 )
 )
)
(instance aBus of Act
(properties
view 122
x 320
y 189
))
(instance aSign of Prop
(properties
view 145
x 40
y 170
))
(instance aCar1 of Act
(properties
view 708
x 320
y 186
cel 0
))
/******************************************************************************/
