 Rem File: Cmd113.bas
 Rem Sub: Ride.Vehicle
 Rem $Include: 'dndbbs.inc'
 On Error Goto Main.Error
 If Chained<>-2 Then
    Color 15,0
    Print "DNDBBS Command 113 -- Ride.Vehicle."
    Color 7,0
    End
 Endif
 Call Ride.Vehicle
Main.Resume:
 Chain DND.Path+"DNDBBS.EXE"
 End
Main.Error:
 Resume Main.Resume

Sub Ride.Vehicle
 On Local Error Goto Error.Trap13
 If Vehicle1=SFalse Then
    Strng="You're not using a vehicle!"
    Call IO.O
    Exit Sub
 Endif
 Call Read.Record(RoomInvFile,Vehicle1)
 If MessWorkRecord6.User<>User.Index Then
    Strng="You're not the vehicle owner!"
    Call IO.O
    Exit Sub
 Endif
 Call Read.Record(TreasureFile,Vehicle3)
 Var2$=TreasureRecord.ShortName
 Var2$=Rtrim$(Var2$)
 Var2$=Lcase$(Var2$)
 User.Command=Parsed.Command1
 Call Get.Direction
 If TempA Then
    If Parse.Temp<=False Then
       Var3=1
    Else
       Var3=Parse.Temp
    Endif
    If Var3>16 Then
       Var3=16
    Endif
    Var1=TempA
    For Var2=1 To Var3
       TempA=Var1
       Next.Room=RoomRecord.Direct(TempA)
       If Next.Room=SFalse Then
          Strng="You can't travel in that direction!"
          Call IO.O
          Exit Sub
       Endif
       Call Vehicle.Type
       If Next.Room=SFalse Then
          Strng="You can't travel in that direction!"
          Call IO.O
          Exit Sub
       Endif
       Var$=Direction(TempA)
       Var$=Rtrim$(Var$)
       Graphics.Off=False
       Strng="You "+Lcase$(Temp.Command)+" "+Var$+"."
       Call IO.O
       If Node>False Then
          Out2=UserRecord.CodeName
          Out2=Rtrim$(Out2)
          Out2=Lcase$(Out2)
          Out2=Out2+" just left on a "+Var2$+" going "+Var$+"."
          Call Send.Mess(8,SFalse,Room,Out2)
       Endif
       Last.Command.Number=RideVehicle
       Action.Recurse=0
       Call Enter.Room
       If New.Room Then
          Call Enter.New.Room
       Else
          Exit For
       Endif
    Next
    Exit Sub
 Endif
 Call Check.Room.Items
 If Temp7!>=SFalse Then
    Strng="You can't travel in that direction!"
    Call IO.O
    Exit Sub
 Endif
 If ObjectRecord.JailTrap Then
    Strng="Trapped portal!"
    Call IO.O
    Exit Sub
 Endif
 Call Return.Room(Var!)
 If Var!=SFalse Then
    Strng="You can't travel there!"
    Call IO.O
    Exit Sub
 Endif
 If ObjectRecord.Closed Then
    If Pass.Door=False Then
       Strng="You can't, it's closed!"
       Call IO.O
       Exit Sub
    Endif
 Endif
 Strng2=ObjectRecord.PortalPassword
 Strng2=Rtrim$(Strng2)
 If Len(Strng2) Then
    Strng="Enter portal password: "
    Call IO.I
    Out2=Ucase$(Out2)
    Out2=Rtrim$(Out2)
    Out2=Ltrim$(Out2)
    Call Crypto(Strng2)
    Strng2=Rtrim$(Strng2)
    If Strng2<>Out2 Then
       Strng="Incorrect portal password.."
       Call IO.O
       Exit Sub
    Endif
 Endif
 If ObjectRecord.Relocks Then
    ObjectRecord.DoorLock=2
    ObjectRecord.Closed=True
    Call Write.Record(ObjectFile,Temp7!)
 Endif
 Strng=Rtrim$(ObjectRecord.ShortDesc)
 Var=True
 If Strng=String$(40,0) Then
    Var=False
 Endif
 If Strng=String$(80,0) Then
    Var=False
 Endif
 If Var Then
    Strng=Rtrim$(Strng)
    If Strng<>Nul Then
       Call Convert.ANSI(True,VarQ,VarR)
       Graphics.On=True
       Call IO.O
       Graphics.On=False
    Endif
 Endif
 Pass.Door=False
 Next.Room=Var!
 Call Vehicle.Type
 If Next.Room=SFalse Then
    Strng="You can't travel in that direction!"
    Call IO.O
    Exit Sub
 Endif
 Var$=ObjectRecord.ShortName
 Var$=Rtrim$(Var$)
 Var$=Lcase$(Var$)
 Strng="You "+Lcase$(Temp.Command)+" to the "+Var$+"."
 Call IO.O
 If Node>False Then
    Out2=UserRecord.CodeName
    Out2=Lcase$(Out2)
    Out2=Rtrim$(Out2)
    Out2=Out2+" just left on a "+Var2$+" to the "+Var$+"."
    Call Send.Mess(8,SFalse,Room,Out2)
 Endif
 Action.Recurse=0
 Call Enter.Room
Error.Resume13:
 Exit Sub
Error.Trap13:
 Resume Error.Resume13
End Sub

Sub Vehicle.Type
 On Local Error Goto Error.Trap15
 If Next.Room<=False Or Next.Room>Lof(RoomFile)/RoomRecLen Then
    Next.Room=SFalse
    Exit Sub
 Endif
 Call Read.Record(RoomFile,Next.Room)
 If Vehicle4<>AllTerrain Then
    Var2!=RoomRecord.Action
    If Var2!>SFalse And Var2!<=Lof(ActionFile)/ActionRecLen Then
       Call Read.Record(ActionFile,Var2!)
       If ActionRecord.Attribute2<>Vehicle4 Then
          Next.Room=SFalse
       Endif
    Endif
 Endif
 Call Read.Record(RoomFile,Room)
Error.Resume15:
 Exit Sub
Error.Trap15:
 Resume Error.Resume15
End Sub
