/******************************************************************************/
(include "sci.sh")
(include "game.sh")
/******************************************************************************/
(script 126)
/******************************************************************************/
(use "controls")
(use "cycle")
(use "door")
(use "feature")
(use "game")
(use "inv")
(use "main")
(use "obj")
(local
onRed2
dyingScript
rmNum
busComing
navy
car_
jo = 0
)
/******************************************************************************/
(instance public rm126 of Rm
	(properties
		picture scriptNumber
		north 0
		east 0
		south 0
		west 0
	)
	(method (init)
		(super:init())
		(self:setScript(RoomScript))
		(switch(gPreviousRoomNumber)
			(default
				(send gEgo:
					posn(46 150)
					loop(0)
				)
			)
   (case 129
				(send gEgo:
					posn(305 147)
					loop(1)
				)
			)
   			(case 128
       = navy TRUE
       (aDoor: ignoreControl(ctlWHITE) init() posn(185 112))
				(send gEgo:
					posn(142 116)
					loop(2)
				)
			)
		)
             = gTimeSeconds2 Random(7 10)
		SetUpEgo()
		(send gEgo:init())
   (aSign: init())
   (aDoor: init())

	)
)
/******************************************************************************/
(instance Jonny of Script
	(properties)
(method(changeState newState)
 = state newState
 (switch(state)
 (case 0
 Print("Psss! Come here!"#title"Man:")
 = jo 1
 (send gEgo: setMotion(MoveTo 280 155 Jonny))
 )
 (case 1
 Print("Yeah! What is it?"#title"Dr.Jummybummy:" #icon 777 0 0)
 Print("We can't speak here. Come along!"#title"Man:" #icon 777 0 6)
 (aJonny: setMotion(MoveTo 320 165 Jonny))
 (send gEgo: setMotion(MoveTo 320 155 Jonny))
 )
 (case 2
 (aJonny: hide())
 )
 (case 3
 (send gRoom: newRoom(129))
 )
 )
 )
 )
(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('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)) 40)
= 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 126)
        Print("You're are already at the tool store.")
        return
        )
        (if(< money 25)
        Print("You don't have enough money to buy a ticket. Too bad.")
        return
        )
        (if(busComing)
          Print("The bus hasn't stopped yet.")
        return
        )
        -= cash 25
        (send gRoom: newRoom(rmNum))
        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 what's known as 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('/door'))
Print("One of those automatic doors.")
)
(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('/window,(display<window)'))
Print("You can't see inside. What a pity!")
)
(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 seems to be the tool-store. Looks more like a tool-mall to me.")
        )
       (if(Said('/wall'))
        Print("You look at the wall, but stop beacuse the wall is static with no movement nor action(!).")
        )
        (if(Said('/schedule,(bus<schedule)'))
        Print("According to this, buses go every 20 seconds here.")
)
(if(Said('/'))
Print("You're at the tool-store. The paradise of the Jack-Of-All-Trades' or should I say Khjy-Ng-Ewxu-Ydknsw'?.")
Print("A bus stop is in front of the store.")
        )
         )
        )
 
(method(doit)
 (if(> (send gEgo: x) 312)
 (if(== jo 1)
 return
 )
 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(granz)
(if(not(jonny))
= jonny TRUE
ProgramControl()
(aJonny: init() setCycle(Walk) setMotion(MoveTo 295 165 Jonny))
)
)
  (if(==(send gEgo: onControl()) ctlNAVY)
  (if(not(navy))
  = navy TRUE
  (aDoor: ignoreControl(ctlWHITE) setMotion(MoveTo 185 112))
  ))
  (if(==(send gEgo: onControl()) ctlCYAN)
  (if(navy)
  = navy FALSE
  (aDoor: ignoreControl(ctlWHITE) setMotion(MoveTo 142 112))
  ))
  (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() setMotion(MoveTo Xposn 189 End3))
  )
  )
  )
 (if(==(send gEgo: onControl()) ctlYELLOW)
 (send gRoom: newRoom(128))
 )
  (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 aDoor of Act
(properties
view 157
x 142
y 112
))
(instance aSign of Prop
(properties
view 145
x 40
y 159
))
(instance aJonny of Act
(properties
view 155
x 320
y 165
))
(instance aCar1 of Act
(properties
view 708
x 320
y 186
cel 0
))
/******************************************************************************/
