Advertisement
Guest User

Untitled

a guest
Nov 19th, 2019
219
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Option Explicit
  2.  
  3. Public MAX_VIAJES As Byte
  4.  
  5. Private Type tViajes
  6.     Nombre As String
  7.     Nivel As Byte
  8.     Costo As Long
  9.     Tiempo As Integer
  10.     Pos As WorldPos
  11.     SkillNavegacion As Byte
  12. End Type
  13.  
  14. Public Viajes() As tViajes
  15.  
  16. Public Sub CargarViajes()
  17.  
  18.     Dim Leer As clsIniManager
  19.     Set Leer = New clsIniManager
  20.  
  21.     Call Leer.Initialize(DatPath & "Viajes.dat")
  22.  
  23.     MAX_VIAJES = Val(Leer.GetValue("INIT", "MAX_VIAJES"))
  24.  
  25.     If MAX_VIAJES > 0 Then
  26.  
  27.         Dim LoopC As Long, Cadena As String
  28.         ReDim Viajes(1 To MAX_VIAJES) As tViajes
  29.  
  30.         For LoopC = 1 To MAX_VIAJES
  31.  
  32.             '++ Funciona 10 pts xD
  33.            With Viajes(LoopC)
  34.  
  35.                 .Nombre = CStr(Leer.GetValue("VIAJE#" & LoopC, "Nombre"))
  36.                 .Nivel = Val(Leer.GetValue("VIAJE#" & LoopC, "Nivel"))
  37.  
  38.                 If .Nivel < 1 Then
  39.                     .Nivel = 1
  40.                     Call MsgBox("El viaje n° " & LoopC & " estaba dateado con un nivel menor a (1) revisar el VIAJES.DAT" & vbNewLine & "Se ha seteado el nivel minimo en respectivo viaje.")
  41.                 End If
  42.  
  43.                 If .Nivel > STAT_MAXELV Then
  44.                     .Nivel = STAT_MAXELV
  45.                     Call MsgBox("Exediste el limite de nivel (" & STAT_MAXELV & ") en el viaje n° " & LoopC & " revisar el VIAJES.DAT" & vbNewLine & "Se ha seteado el nivel maximo en respectivo viaje.")
  46.                 End If
  47.  
  48.                 .Costo = Val(Leer.GetValue("VIAJE#" & LoopC, "Costo"))
  49.                 .Tiempo = Val(Leer.GetValue("VIAJE#" & LoopC, "Tiempo"))
  50.                 .SkillNavegacion = Val(Leer.GetValue("VIAJE#" & LoopC, "SkillReq"))
  51.  
  52.                 If .SkillNavegacion > MAXSKILLPOINTS Then
  53.                     .SkillNavegacion = MAXSKILLPOINTS
  54.                     Call MsgBox("Exediste el limite skill de navegacion en el viaje n° " & LoopC & " revisar el VIAJES.DAT" & vbNewLine & "Se ha seteado el skill en 100 en respectivo viaje.")
  55.                 End If
  56.  
  57.                 Cadena = CStr(Leer.GetValue("VIAJE#" & LoopC, "Pos"))
  58.  
  59.                 If LenB(Cadena) > 5 Then
  60.                     .Pos.map = Val(ReadField(1, Cadena, 45))
  61.  
  62.                     If .Pos.map < 1 Then
  63.                         .Pos.map = 1
  64.                         Call MsgBox("El viaje n° " & LoopC & " estaba dateado con un num de mapa menor a (1) revisar el VIAJES.DAT" & vbNewLine & "Se ha seteado el mapa minimo en respectivo viaje.")
  65.                     End If
  66.  
  67.                     If .Pos.map > NumMaps Then
  68.                         .Pos.map = NumMaps
  69.                         Call MsgBox("Exediste el limite de mapas en el viaje n° " & LoopC & " revisar el VIAJES.DAT" & vbNewLine & "Se ha seteado el mapa maximo en respectivo viaje.")
  70.                     End If
  71.  
  72.                     .Pos.X = Val(ReadField(2, Cadena, 45))
  73.                     .Pos.Y = Val(ReadField(3, Cadena, 45))
  74.  
  75.                 End If
  76.  
  77.             End With
  78.  
  79.         Next LoopC
  80.  
  81.     End If
  82.  
  83.     Set Leer = Nothing
  84.  
  85. End Sub
  86.  
  87. Private Function PuedeViajar(ByVal UserIndex As Integer) As Boolean
  88.  
  89.     PuedeViajar = False
  90.  
  91.     With UserList(UserIndex)
  92.  
  93.         If .flags.Muerto > 0 Then
  94.             Call WriteConsoleMsg(UserIndex, "No puedes viajar estando muerto.", FontTypeNames.FONTTYPE_INFO)
  95.             Exit Function
  96.         End If
  97.  
  98.         If .flags.Comerciando > 0 Then
  99.             Call WriteConsoleMsg(UserIndex, "No puedes viajar estando comerciando.", FontTypeNames.FONTTYPE_INFO)
  100.             Exit Function
  101.         End If
  102.  
  103.         If .flags.invisible > 0 Then
  104.             Call WriteConsoleMsg(UserIndex, "No puedes viajar estando invisible.", FontTypeNames.FONTTYPE_INFO)
  105.             Exit Function
  106.         End If
  107.  
  108.         If .flags.Navegando > 0 Then
  109.             Call WriteConsoleMsg(UserIndex, "No puedes viajar estando navegando.", FontTypeNames.FONTTYPE_INFO)
  110.             Exit Function
  111.         End If
  112.  
  113.         If .flags.Mimetizado > 0 Then
  114.             Call WriteConsoleMsg(UserIndex, "No puedes viajar estando trasformado.", FontTypeNames.FONTTYPE_INFO)
  115.             Exit Function
  116.         End If
  117.  
  118.     End With
  119.  
  120.     PuedeViajar = True
  121.  
  122. End Function
  123.  
  124. Public Sub Viajar(ByVal UserIndex As Integer, ByVal ID As Byte)
  125.  
  126.     If Not PuedeViajar(UserIndex) Then Exit Sub
  127.  
  128.     ' ++ Anti salchichas
  129.    If ID < 0 Then ID = 0
  130.     If ID > MAX_VIAJES Then ID = MAX_VIAJES
  131.  
  132.     With Viajes(ID)
  133.  
  134.         ' ++ Requisito de nivel
  135.        If UserList(UserIndex).Stats.ELV < .Nivel Then
  136.             Call WriteConsoleMsg(UserIndex, "Debes ser nivel " & .Nivel & " para viajar.", FontTypeNames.FONTTYPE_INFO)
  137.             Exit Sub
  138.         End If
  139.  
  140.         ' ++ Requisito de oro
  141.        If UserList(UserIndex).Stats.GLD < .Costo Then
  142.             Call WriteConsoleMsg(UserIndex, "Debes tener " & .Costo & " monedas de oro para viajar.", FontTypeNames.FONTTYPE_INFO)
  143.             Exit Sub
  144.         End If
  145.  
  146.         ' ++ Requisito de oro
  147.        If UserList(UserIndex).Stats.UserSkills(eSkill.Navegacion) < .SkillNavegacion Then
  148.             Call WriteConsoleMsg(UserIndex, "Debes tener " & .SkillNavegacion & " skills de navegacion.", FontTypeNames.FONTTYPE_INFO)
  149.             Exit Sub
  150.         End If
  151.  
  152.         If UserList(UserIndex).Counters.Viaje > 0 Then
  153.             Call WriteConsoleMsg(UserIndex, "Ya te encuentras viajando. Intente mas tarde.", FontTypeNames.FONTTYPE_INFO)
  154.             Exit Sub
  155.         End If
  156.  
  157.         ' ++ Pense que lo habia puesto xdxd
  158.        UserList(UserIndex).Stats.GLD = UserList(UserIndex).Stats.GLD - .Costo
  159.         Call WriteUpdateGold(UserIndex)
  160.  
  161.         ' ++ Si el viaje es con tiempo no lo warpeamos enseguida.
  162.        If .Tiempo > 0 Then
  163.             UserList(UserIndex).Counters.Viaje = .Tiempo
  164.             UserList(UserIndex).PosViaje = .Pos
  165.             Call WriteConsoleMsg(UserIndex, "Has emprendido tu viaje hacia " & .Nombre & " llegaras en " & .Tiempo & " segundos.", FontTypeNames.FONTTYPE_INFO)
  166.             Exit Sub
  167.         End If
  168.  
  169.         ' ++ Era sin tiempo de retardo
  170.        Call WarpUserCharX(UserIndex, .Pos.map, .Pos.X, .Pos.Y, True)
  171.         Call WriteConsoleMsg(UserIndex, "Has llegado a tu destino." & vbNewLine & "Fue un largo viaje, aliméntate y bebe algo para recuperarte", FontTypeNames.FONTTYPE_INFO)
  172.         Call UpdateStatsViaje(UserIndex)
  173.  
  174.     End With
  175.  
  176. End Sub
  177.  
  178. Public Sub UpdateStatsViaje(ByVal UserIndex As Integer)
  179.  
  180.     With UserList(UserIndex)
  181.         .Stats.MinAGU = 0
  182.         .Stats.MinHam = 0
  183.         .Stats.MinSta = 0
  184.     End With
  185.  
  186.     Call WriteUpdateHungerAndThirst(UserIndex)
  187.     Call WriteUpdateSta(UserIndex)
  188.  
  189. End Sub
  190.  
  191. Public Sub WarpUserCharX(ByVal UserIndex As Integer, ByVal Mapa As Integer, ByVal X As Integer, ByVal Y As Integer, Optional ByVal FX As Boolean = False)
  192.  
  193.     If MapData(Mapa, X, Y).UserIndex = UserIndex Then
  194.         Exit Sub
  195.     End If
  196.  
  197.     Dim NuevaPos As WorldPos
  198.     Dim FuturePos As WorldPos
  199.  
  200.     FuturePos.map = Mapa
  201.     FuturePos.X = X
  202.     FuturePos.Y = Y
  203.  
  204.     Call ClosestLegalPos(FuturePos, NuevaPos, True)
  205.  
  206.     If NuevaPos.X <> 0 And NuevaPos.Y <> 0 Then
  207.         Call WarpUserChar(UserIndex, NuevaPos.map, NuevaPos.X, NuevaPos.Y, FX)
  208.     End If
  209.  
  210. End Sub
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement