Advertisement
Luciano_fuentes

Deathmatch para Enzo.

Mar 16th, 2017
244
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Option Explicit
  2. '***************
  3. 'AUTOR: Toyz - Luciano
  4. 'FECHA: 11/12/16 - 23:00
  5. '***************
  6. Private Const Tiempo_Cancelamiento As Integer = 180
  7. Private Const Banquero As Byte = 24
  8. Private Const MaxCupos As Byte = 40
  9. Private Const MinCupos As Byte = 2
  10.  
  11. Private Type tUsuario
  12.     ID As Integer
  13.     Posicion As WorldPos
  14. End Type
  15.  
  16. Private Type tDeathmatch
  17.     Activo As Boolean
  18.     Usuarios() As tUsuario
  19.     Objetos As Boolean
  20.     Conteo As Integer
  21.     Cupos As Byte
  22.     Coordenadas As WorldPos
  23.     Premio As Long
  24.     Inscripcion As Long
  25.     Total As Byte
  26.     Restantes As Byte
  27.     Pos_Banquero As WorldPos
  28.     EsperaPelear As Boolean
  29.     TorneoFinalizado As Boolean
  30.     EsperandoParticipantes As Boolean
  31. End Type
  32.  
  33. Private Deathmatch As tDeathmatch
  34.  
  35. Public Sub Carga_Death()
  36.     Dim Leer As clsIniManager
  37.     Set Leer = New clsIniManager
  38.     Call Leer.Initialize(App.Path & "\Dat\DeathMatch.dat")
  39.     With Deathmatch.Coordenadas
  40.         .Map = CInt(Leer.GetValue("EVENTO", "Mapa"))
  41.         .X = CByte(Leer.GetValue("EVENTO", "X"))
  42.         .Y = CByte(Leer.GetValue("EVENTO", "Y"))
  43.     End With
  44. End Sub
  45.  
  46. Public Sub Armar_Death(ByVal ID As Integer, ByVal Cupos As Byte, ByVal Objetos As Boolean, ByVal Premio As Long, ByVal Inscripcion As Long)
  47.     With Deathmatch
  48.         If .Activo = True Then
  49.             Call WriteConsoleMsg(ID, "Deathmatch> El evento ya está en curso.", FontTypeNames.FONTTYPE_GUILD)
  50.             Exit Sub
  51.         End If
  52.         If Cupos > MaxCupos Then Cupos = MaxCupos
  53.         If Cupos < MinCupos Then Cupos = MinCupos
  54.         .Cupos = Cupos
  55.         .Inscripcion = Inscripcion
  56.         .Objetos = Objetos
  57.         .Premio = Premio
  58.         .Total = .Cupos
  59.         .Restantes = .Total
  60.         .Activo = True
  61.         .Conteo = Tiempo_Cancelamiento
  62.         .EsperandoParticipantes = True
  63.         ReDim .Usuarios(1 To .Cupos) As tUsuario
  64.         Call SendData(SendTarget.ToAll, 0, PrepareMessageConsoleMsg("Deathmatch> " & .Cupos & " Cupos, Incripción" & IIf(.Inscripcion > 0, " de: " & .Inscripcion & " Monedas de oro, ", " Gratis, ") & IIf(Objetos = True, "Caen items, ", "No caen items, ") & IIf(.Premio > 0, "Premio de: " & .Premio & " Monedas de oro.", " No hay premio.") & " Manden/DEATHMATCH si desean participar.", FontTypeNames.FONTTYPE_GUILD))
  65.     End With
  66. End Sub
  67.  
  68. Public Sub Entrar_Death(ByVal ID As Integer)
  69.     Dim ID_Death As Byte
  70.     Dim nuevaPos As WorldPos
  71.     With Deathmatch
  72.         If Puede_Entrar(ID) = False Then Exit Sub
  73.         Call WriteConsoleMsg(ID, "Has ingresado al evento" & IIf(.Inscripcion > 0, ", se te han descontado " & .Inscripcion & " monedas de oro.", vbNullString) & ". Espera a que el cupo se complete. ¡Suerte en el campo de batalla!", FontTypeNames.FONTTYPE_GUILD)
  74.         UserList(ID).Stats.GLD = UserList(ID).Stats.GLD - .Inscripcion
  75.         .Cupos = .Cupos - 1
  76.         ID_Death = Death_ID
  77.         UserList(ID).flags.EnDeathMatch = ID_Death
  78.         .Usuarios(ID_Death).ID = ID
  79.         .Usuarios(ID_Death).Posicion = UserList(ID).Pos
  80.         Call ClosestLegalPos(Deathmatch.Coordenadas, nuevaPos, False, True, True)
  81.         WarpUserChar ID, nuevaPos.Map, nuevaPos.X, nuevaPos.Y, False
  82.     'WritePauseToggle ID '<--- No  pausamos, hacemos que se muevan.
  83.    WriteUpdateGold ID
  84.     If .Cupos = 0 Then
  85.         Call SendData(SendTarget.ToAll, 0, PrepareMessageConsoleMsg("Deathmatch> El cupo ha sido completado!", FontTypeNames.FONTTYPE_GUILD))
  86.         .Conteo = 10
  87.         AsignarFlagEspera
  88.         .EsperaPelear = True
  89.         .EsperandoParticipantes = False
  90.     End If
  91. End With
  92. End Sub
  93.  
  94. Private Function Death_ID() As Byte
  95.     Dim LoopC As Long
  96.     With Deathmatch
  97.         For LoopC = 1 To .Total
  98.             If .Usuarios(LoopC).ID = 0 Then
  99.                 Death_ID = LoopC
  100.                 Exit Function
  101.             End If
  102.         Next LoopC
  103.     End With
  104. End Function
  105.  
  106. Private Function Puede_Entrar(ByVal ID As Integer) As Boolean
  107.     Puede_Entrar = False
  108.     If EsGm(ID) = True Then
  109.         Call WriteConsoleMsg(ID, "No puedes entrar a un evento si eres miembro del staff", FontTypeNames.FONTTYPE_GUILD)
  110.         Exit Function
  111.     End If
  112.     If UserList(ID).flags.Muerto > 0 Then
  113.         Call WriteConsoleMsg(ID, "Estás muerto.", FontTypeNames.FONTTYPE_GUILD)
  114.         Exit Function
  115.     End If
  116.     If UserList(ID).flags.EnJDH > 0 Then
  117.         Call WriteConsoleMsg(ID, "Estás en los Juegos del Hambre.", FontTypeNames.FONTTYPE_GUILD)
  118.         Exit Function
  119.     End If
  120.     If UserList(ID).flags.EnDeathMatch > 0 Then
  121.         Call WriteConsoleMsg(ID, "Ya estás en el Deathmatch.", FontTypeNames.FONTTYPE_GUILD)
  122.         Exit Function
  123.     End If
  124.     If Deathmatch.Activo = False Then
  125.         Call WriteConsoleMsg(ID, "El evento no está en curso.", FontTypeNames.FONTTYPE_GUILD)
  126.         Exit Function
  127.     End If
  128.     If Deathmatch.Cupos = 0 Then
  129.         Call WriteConsoleMsg(ID, "El evento ya no tiene cupos disponibles.", FontTypeNames.FONTTYPE_GUILD)
  130.         Exit Function
  131.     End If
  132.     If UserList(ID).Stats.GLD < Deathmatch.Inscripcion Then
  133.         Call WriteConsoleMsg(ID, "No tienes el oro suficiente.", FontTypeNames.FONTTYPE_GUILD)
  134.         Exit Function
  135.     End If
  136.     If Not UserList(ID).Pos.Map = 1 Then
  137.         Call WriteConsoleMsg(ID, "Tienes que estar en Ullathorpe para poder ingresar al evento", FontTypeNames.FONTTYPE_GUILD)
  138.         Exit Function
  139.     End If
  140.     Puede_Entrar = True
  141. End Function
  142.  
  143. Public Sub Contar_Death()
  144.     Dim LoopC As Long
  145.     Dim LoopX As Long
  146.     Dim ID_Death As Byte
  147.     With Deathmatch
  148.         If .Conteo = 0 Then
  149.             .Conteo = -1
  150.             If .Activo = True Then
  151.                 If .EsperaPelear = True Then
  152.                     Call AsignarFlagEspera
  153.                     SendData SendTarget.ToAll, 0, PrepareMessageConsoleMsg("Deathmatch> Ya!", FontTypeNames.FONTTYPE_FIGHT)
  154.                     .EsperaPelear = False
  155.                 ElseIf .EsperandoParticipantes = True Then
  156.                     SendData SendTarget.ToAll, 0, PrepareMessageConsoleMsg("Deathmatch> Evento cancelado por falta de participantes, se ha devuelto el oro por la inscripción.", FontTypeNames.FONTTYPE_GUILD)
  157.                     Cancelar_Death
  158.                 End If
  159.                 If .TorneoFinalizado = True Then
  160.                     ID_Death = ID_Usuario
  161.                     WarpUserChar .Usuarios(ID_Death).ID, .Usuarios(ID_Death).Posicion.Map, .Usuarios(ID_Death).Posicion.X, .Usuarios(ID_Death).Posicion.Y, False
  162.                     QuitarNPC (MapData(.Pos_Banquero.Map, .Pos_Banquero.X, .Pos_Banquero.Y).NpcIndex)
  163.                     Limpiar
  164.                     m_Limpieza.CleanWorld_Clear
  165.                 End If
  166.             End If
  167.         End If
  168.         If .Conteo > 0 Then
  169.             If .EsperaPelear = True Then _
  170.                SendData SendTarget.ToAll, 0, PrepareMessageConsoleMsg("Deathmatch> " & .Conteo, FontTypeNames.FONTTYPE_GUILD)
  171.             .Conteo = .Conteo - 1
  172.         End If
  173.     End With
  174. End Sub
  175.  
  176. Private Function ID_Usuario() As Byte
  177.     Dim LoopC As Long
  178.     For LoopC = 1 To Deathmatch.Total
  179.         If Deathmatch.Usuarios(LoopC).ID > 0 Then
  180.             ID_Usuario = LoopC
  181.             Exit For
  182.         End If
  183.     Next LoopC
  184. End Function
  185.  
  186. Public Sub Muere_Death(ByVal ID As Integer)
  187.     Dim ID_Death As Byte
  188.     ID_Death = UserList(ID).flags.EnDeathMatch
  189.     If ID_Death = 0 Then Exit Sub
  190.     RestarUsuario ID
  191.     UserList(ID).flags.EnDeathMatch = 0
  192.     UserList(ID).flags.EnEspera = False
  193. End Sub
  194.  
  195. Public Sub RestarUsuario(ByVal ID As Integer)
  196.     Dim ID_Death As Byte
  197.     ID_Death = UserList(ID).flags.EnDeathMatch
  198.     With Deathmatch
  199.         .Restantes = .Restantes - 1
  200.          If .Restantes > 1 Then SendData SendTarget.ToAll, 0, PrepareMessageConsoleMsg("Deathmatch> Quedan " & .Restantes & " luchadores.", FontTypeNames.FONTTYPE_GUILD)
  201.         Call WriteConsoleMsg(ID, "Deathmatch> ¡Has perdido, has sido descalificado. ¡Suerte para la próxima!", FontTypeNames.FONTTYPE_GUILD)
  202.         WarpUserChar ID, .Usuarios(ID_Death).Posicion.Map, .Usuarios(ID_Death).Posicion.X, .Usuarios(ID_Death).Posicion.Y, False
  203.         .Usuarios(ID_Death).ID = 0
  204.         If .Restantes = 1 Then Finalizar
  205.     End With
  206. End Sub
  207.  
  208. Private Sub Finalizar()
  209.     Dim LoopC As Long
  210.     Dim Dame_ID As Byte
  211.     Dim ID As Integer
  212.     With Deathmatch
  213.         Dame_ID = ID_Usuario
  214.         ID = .Usuarios(Dame_ID).ID
  215.         .Pos_Banquero = UserList(ID).Pos
  216.         '.Pos_Banquero.Y = .Pos_Banquero.Y
  217.        SendData SendTarget.ToAll, 0, PrepareMessageConsoleMsg("Deathmatch> Ganador del evento: " & UserList(ID).Name & " se lleva una cantidad de " & .Premio & " monedas de oro" & IIf(.Objetos = True, " y los items recaudados.", vbNullString) & ", felicitaciones!", FontTypeNames.FONTTYPE_GUILD)
  218.         UserList(ID).Stats.GLD = UserList(ID).Stats.GLD + .Premio
  219.  
  220.         WriteUpdateGold ID
  221.         UserList(ID).flags.EnDeathMatch = 0
  222.         UserList(ID).flags.EnEspera = 0
  223.         .Premio = 0
  224.         If .Objetos = True Then
  225.             .Conteo = 60
  226.             .TorneoFinalizado = True
  227.     'Call WriteConsoleMsg(ID, "Tienes 60 segundos para recoger los items del piso.", FontTypeNames.FONTTYPE_GUILD)
  228.            WarpUserChar ID, .Pos_Banquero.Map, .Pos_Banquero.X, .Pos_Banquero.Y + 1, False
  229.             Call SpawnNpc(Banquero, .Pos_Banquero, True, False)
  230.             Call SendData(SendTarget.ToPCArea, ID, PrepareMessageChatOverHead("Tienes 60 segundos para recoger los items del piso.", MapData(.Pos_Banquero.Map, .Pos_Banquero.X, .Pos_Banquero.Y).NpcIndex, vbWhite))
  231.         Else
  232.             WarpUserChar ID, .Usuarios(Dame_ID).Posicion.Map, .Usuarios(Dame_ID).Posicion.X, .Usuarios(Dame_ID).Posicion.Y, False
  233.             Limpiar
  234.         End If
  235.     End With
  236. End Sub
  237.  
  238. Public Sub Cancelar_Death()
  239.     Dim LoopC As Long
  240.     With Deathmatch
  241.         If .Activo = False Then Exit Sub
  242.         For LoopC = 1 To .Total
  243.             If .Usuarios(LoopC).ID > 0 Then
  244.                 WarpUserChar .Usuarios(LoopC).ID, .Usuarios(LoopC).Posicion.Map, .Usuarios(LoopC).Posicion.X, .Usuarios(LoopC).Posicion.Y, False
  245.                 UserList(.Usuarios(LoopC).ID).flags.EnDeathMatch = 0
  246.                 UserList(.Usuarios(LoopC).ID).flags.EnEspera = False
  247.                 UserList(.Usuarios(LoopC).ID).Stats.GLD = UserList(.Usuarios(LoopC).ID).Stats.GLD + .Inscripcion
  248.  
  249.                 WriteConsoleMsg .Usuarios(LoopC).ID, "El evento ha sido cancelado, se te ha devuelto el costo de la inscripción.", FontTypeNames.FONTTYPE_GUILD
  250.                 WriteUpdateGold .Usuarios(LoopC).ID
  251.             End If
  252.         Next LoopC
  253.     End With
  254.     SendData SendTarget.ToAll, 0, PrepareMessageConsoleMsg("Deathmatch> Evento fue cancelado por un Game Master.", FontTypeNames.FONTTYPE_GUILD)
  255.     Limpiar
  256. End Sub
  257.  
  258. Public Sub Desconexion_Death(ByVal ID As Integer)
  259.     If UserList(ID).flags.EnDeathMatch = 0 Then Exit Sub
  260.     With Deathmatch
  261.         If UserList(ID).flags.EnEspera = True Then
  262.             WarpUserChar ID, .Usuarios(UserList(ID).flags.EnDeathMatch).Posicion.Map, .Usuarios(UserList(ID).flags.EnDeathMatch).Posicion.X, .Usuarios(UserList(ID).flags.EnDeathMatch).Posicion.Y, True
  263.             '.Usuarios(UserList(ID).flags.EnDeathMatch).ID = 0
  264.            'UserList(ID).flags.EnDeathMatch = 0
  265.            UserList(ID).flags.EnEspera = False
  266.             .Cupos = .Cupos + 1
  267.            ' WritePauseToggle ID
  268.        Else
  269.             RestarUsuario ID
  270.         End If
  271.        ' UserList(ID).flags.EnEspera = False
  272.        UserList(ID).flags.EnDeathMatch = 0
  273.     End With
  274. End Sub
  275.  
  276. Private Sub Limpiar()
  277.     With Deathmatch
  278.         .Activo = False
  279.         .Conteo = -1
  280.         .Cupos = 0
  281.         .Inscripcion = 0
  282.         .Objetos = False
  283.         .Premio = 0
  284.         .Restantes = 0
  285.         .Total = 0
  286.         Erase .Usuarios()
  287.     End With
  288. End Sub
  289.  
  290. Private Sub AsignarFlagEspera()
  291.  
  292.     With Deathmatch
  293.         Dim LoopC As Long
  294.         For LoopC = 1 To .Total
  295.             UserList(.Usuarios(LoopC).ID).flags.EnEspera = Not UserList(.Usuarios(LoopC).ID).flags.EnEspera
  296.         Next LoopC
  297.     End With
  298. End Sub
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement