Advertisement
deD33

Untitled

Apr 23rd, 2021
1,402
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Option Explicit
  2.  
  3. ' INVOCACIONES CON USUARIOS
  4.  
  5. Public Type tInvocaciones
  6.    
  7.     Activo As Byte
  8.    
  9.    
  10.     'INFORMACION CARGADA
  11.    desc As String
  12.     NpcIndex As Integer
  13.     CantidadUsuarios As Byte
  14.     Mapa As Byte
  15.     X() As Byte
  16.     Y() As Byte
  17.    
  18.        
  19.    
  20.    
  21. End Type
  22.  
  23.  
  24. Public NumInvocaciones As Byte
  25. Public Invocaciones() As tInvocaciones
  26.  
  27. '[INIT]
  28. 'NumInvocaciones = 1
  29.  
  30. '[INVOCACION1] 'Mago del inframundo
  31. 'NpcIndex = 410
  32.  
  33. 'Mapa = 1
  34. 'CantidadUsuarios = 2
  35. 'Pos1 = 40 - 60
  36. 'Pos2 = 70 - 80
  37. Public Sub LoadInvocaciones()
  38.          
  39.           Dim i As Integer
  40.           Dim X As Integer
  41.           Dim ln As String
  42.          
  43. 10        NumInvocaciones = val(GetVar(DatPath & "Invocaciones.dat", "INIT", "NumInvocaciones"))
  44.          
  45. 20        ReDim Invocaciones(1 To NumInvocaciones) As tInvocaciones
  46. 30            For i = 1 To NumInvocaciones
  47. 40                With Invocaciones(i)
  48. 50                    .Activo = 0
  49. 60                    .CantidadUsuarios = val(GetVar(DatPath & "Invocaciones.dat", "INVOCACION" & i, "CantidadUsuarios"))
  50. 70                    .Mapa = val(GetVar(DatPath & "Invocaciones.dat", "INVOCACION" & i, "Mapa"))
  51. 80                    .NpcIndex = val(GetVar(DatPath & "Invocaciones.dat", "INVOCACION" & i, "NpcIndex"))
  52. 90                    .desc = GetVar(DatPath & "Invocaciones.dat", "INVOCACION" & i, "Desc")
  53.                      
  54. 100                   ReDim .X(1 To .CantidadUsuarios)
  55. 110                   ReDim .Y(1 To .CantidadUsuarios)
  56.                      
  57.                      
  58. 120                   For X = 1 To .CantidadUsuarios
  59. 130                       ln = GetVar(DatPath & "Invocaciones.dat", "INVOCACION" & i, "Pos" & X)
  60.                          
  61. 140                       .X(X) = val(ReadField(1, ln, 45))
  62. 150                       .Y(X) = val(ReadField(2, ln, 45))
  63. 160                   Next X
  64. 170               End With
  65. 180           Next i
  66.  
  67.          
  68. End Sub
  69.  
  70. Public Function InvocacionIndex(ByVal Mapa As Byte, ByVal X As Byte, ByVal Y As Byte) As Byte
  71.  
  72.           Dim i As Integer
  73.           Dim Z As Integer
  74.          
  75. 10        InvocacionIndex = 0
  76.          
  77.           '// Devuelve el Index del mapa de invocación en el que está
  78. 20        For i = 1 To NumInvocaciones
  79. 30            With Invocaciones(i)
  80. 40                For Z = 1 To .CantidadUsuarios
  81. 50                    If .Mapa = Mapa And (.X(Z) = X) And .Y(Z) = Y Then
  82. 60                        InvocacionIndex = i
  83. 70                        Exit For
  84. 80                    End If
  85. 90                Next Z
  86. 100           End With
  87. 110       Next i
  88.                  
  89.              
  90. End Function
  91.  
  92. ' if invocacacionindex = 0 then
  93. Public Function PuedeSpawn(ByVal Index As Byte) As Boolean
  94.          
  95.           Dim Contador As Byte
  96.           Dim i As Integer
  97.          
  98. 10        PuedeSpawn = False
  99. 20        For i = 1 To Invocaciones(Index).CantidadUsuarios
  100. 30            If MapData(Invocaciones(Index).Mapa, Invocaciones(Index).X(i), Invocaciones(Index).Y(i)).UserIndex Then
  101. 40                Contador = Contador + 1
  102.                  
  103. 50                If Contador = Invocaciones(Index).CantidadUsuarios Then
  104. 60                    PuedeSpawn = True
  105. 70                End If
  106. 80            End If
  107. 90        Next i
  108.          
  109. End Function
  110.  
  111. Public Function PuedeRealizarInvocacion(ByVal UserIndex As Integer) As Boolean
  112. 10        PuedeRealizarInvocacion = False
  113.          
  114. 20        With UserList(UserIndex)
  115. 30            If .flags.Muerto Then Exit Function
  116. 40            If .flags.Mimetizado Then Exit Function
  117.               If .flags.invisible Then Exit Function
  118.               If .flags.Oculto Then Exit Function
  119.               If .flags.EnConsulta Then Exit Function
  120.               If .flags.EnEvento Then Exit Function
  121.               If .flags.Montando Then Exit Function
  122.               If .flags.Navegando Then Exit Function
  123. 50        End With
  124.          
  125.          
  126. 60        PuedeRealizarInvocacion = True
  127. End Function
  128.  
  129. Public Sub RealizarInvocacion(ByVal UserIndex As Integer, ByVal Index As Byte)
  130.          
  131.           Dim Pos As WorldPos
  132.          
  133.           ' ¿Los usuarios están en las pos?
  134. 10        If PuedeSpawn(Index) Then
  135.              
  136.               Dim NpcIndex As Integer
  137. 20            Pos.map = Invocaciones(Index).Mapa
  138. 30            Pos.X = RandomNumber(Invocaciones(Index).X(1) - 5, Invocaciones(Index).X(1) + 5)
  139. 40            Pos.Y = RandomNumber(Invocaciones(Index).Y(1) - 5, Invocaciones(Index).Y(1) + 5)
  140.              
  141. 50            FindLegalPos UserIndex, Pos.map, Pos.X, Pos.Y
  142. 60            NpcIndex = SpawnNpc(Invocaciones(Index).NpcIndex, Pos, True, False)
  143.              
  144. 70            If Not NpcIndex = 0 Then
  145. 80                Invocaciones(Index).Activo = 1
  146. 90                Npclist(NpcIndex).flags.Invocacion = 1
  147. 100               Call SendData(SendTarget.ToAll, 0, PrepareMessageConsoleMsg(Invocaciones(Index).desc, FontTypeNames.FONTTYPE_GUILD))
  148.                     'El Dragón Legendario ha renacido..¡¡¡HAY QUE ACABAR CON EL!!!
  149. 110           End If
  150. 120       End If
  151.          
  152.          
  153. End Sub
  154.  
  155.  
  156.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement