Advertisement
Luciano_fuentes

Eventos 1vs1 hasta 20vs20.

Mar 15th, 2017
215
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Option Explicit
  2.  
  3. '********************************
  4. '                               *
  5. '                               *
  6. '@@ ROUND-ROBIN                 *
  7. '@@ AUTOR: G Toyz - Luciano     *
  8. '@@ FECHA: 10/10/2016           *
  9. '@@ HORA: 02:04                 *
  10. '                               *
  11. '                               *
  12. '********************************
  13.  
  14. Private Const MAX_ARENAS       As Byte = 9  'Máxima cantidad de arenas.
  15. Private Const MAX_WAITROOM     As Byte = 18 'Máxima cantidad de salas de espera.
  16. Private Const MAX_SEND         As Byte = 50 'Máximo de personas que pueden enviar solicitud al evento.
  17. Private Const INDEX_POTION_RED As Byte = 1  'Número de la poción roja.
  18. Private Const MIN_LEVEL        As Byte = 1  'Nivel mínimo para entrar al evento.
  19.  
  20.  
  21. Private Type tUsers 'Usuarios
  22.    ID              As Integer  'ID del usuario.
  23.    Pos             As WorldPos 'Posiciones del usuario.
  24. End Type
  25.  
  26. Private Type Teams  'Equipos
  27.    Users()         As tUsers  'Usuarios del equipo.
  28.    Current_Deaths  As Integer 'Muertes actuales.
  29.    Current_Rounds  As Byte    'Rondas actuales.
  30.    Rounds_Earned   As Integer 'Rondas ganadas.
  31.    Points_Earned   As Byte    'Puntos ganados.
  32.    Rounds_Defeated As Integer 'Rondas perdidas.
  33.    Deaths          As Byte    'Muertes.
  34.    Killed          As Byte    'Matados.
  35.    Arena           As Byte    'Arena en la que está.
  36.    Wait_Room       As Byte    'Sala de espera en la que está.
  37.    Played()        As Integer 'Contra quienes jugó.
  38.    Played_Amount   As Byte    'Cantidad contra quienes jugó.
  39.    Team_Arena      As Byte    'ID Del equipo contra quien está jugando.
  40.    K€D             As Integer 'Promedio de Killed/Deaths
  41.    Rounds          As Integer 'Promedio de Rounds.
  42. End Type
  43.  
  44. Private Type pArenas
  45.     X_Corner      As Byte    'Esquina
  46.    Y_Corner      As Byte
  47.     X_Death       As Byte    'Posiciones al morir.
  48.    Y_Death       As Byte
  49. End Type
  50.  
  51. Private Type eArenas
  52.     Indexs(1 To 2)  As Byte
  53.     Pos(1 To 2)     As pArenas
  54.     Count           As Integer 'Conteo.
  55.    Occupied        As Boolean '¿Arena ocupada?
  56. End Type
  57.  
  58. Private Type eWaiting
  59.     X_Wait          As Byte    'Coordenadas de la sala de espera.
  60.    Y_Wait          As Byte
  61.     Occupied        As Boolean '¿Sala de espera ocupada?
  62. End Type
  63.  
  64. Private Type eEvent
  65.     Arenas(1 To MAX_ARENAS)        As eArenas       ' Arenas.
  66.    Waiting(1 To MAX_WAITROOM)     As eWaiting      ' Salas de espera.
  67.    Teams()                        As Teams         ' Equipos.
  68.    MAP_Arena                      As Byte          ' Mapa de las arenas.
  69.    MAP_Waiting                    As Byte          ' Mapa de las Salas de espera.
  70.    Active_Send                    As Boolean       ' ¿Activada la búsqueda de equipos?
  71.    Event_Course                   As Boolean       ' ¿Evento en curso?
  72.    Drop                           As Boolean       ' ¿Caen items?
  73.    Teams_Event                    As Byte          ' Equipos en evento.
  74.    Time_Cancel                    As Integer       ' Tiempo para el autocancelamiento.
  75.    Rounds                         As Byte          ' Rondas de enfretamientos.
  76.    message                        As String        ' Mensaje de evento: Ejemplo: 2vs2
  77.    Sends(1 To MAX_SEND)           As Integer       ' Usuarios que mandaron al evento.
  78.    Drop_Items                     As WorldPos      ' Lugar donde van a caer los items.
  79.    Team_PointLeader               As Byte          ' El número de puntos más alto.
  80.    Max_Potions                    As Integer       ' Máximo de pociones.
  81.    Prize                          As Long          ' Premio.
  82.    Inscription                    As Long          ' Inscripción.
  83.    Team_Win                       As Byte          ' Equipo ganador.
  84.    Best_K€D                       As Integer       ' Mejor número de rounds.
  85.    Best_Rounds                    As Integer       ' Mejor número de muertes/matados.
  86.    Time_Items                     As Integer       ' Tiempo que tienen para recoger los items.
  87. End Type
  88.  
  89. Private Events(2 To 10) As eEvent ' Eventos
  90. '_
  91.  
  92. Private Sub Load_Messages()
  93.  
  94.     '@@ AVISO: hacerlo vía .dat
  95.  
  96.     '@@ Cargamos los mensajes.
  97.    '@@ Mensajes: 2vs2, 3vs3, etc
  98.  
  99.     Events(2).message = "2vs2"
  100.     Events(3).message = "3vs3"
  101.     Events(4).message = "4vs4"
  102.     Events(5).message = "5vs5"
  103.     Events(6).message = "6vs6"
  104.     Events(7).message = "7vs7"
  105.     Events(8).message = "8vs8"
  106.     Events(9).message = "9vs9"
  107.     Events(10).message = "10vs10"
  108.  
  109. End Sub
  110.  
  111. Private Sub Load_POS(ByVal nEvent As Byte, _
  112.                        ByVal X_Items As Byte, _
  113.                        ByVal Y_Items As Byte, _
  114.                        ByVal MAP_Items As Byte, _
  115.                        ByVal Map_Arenas As Byte, _
  116.                        ByVal Map_RoomWait As Byte)
  117.  
  118.     '@@ Cargamos mapas, coordenadas de items.
  119.  
  120.     With Events(nEvent)
  121.         .Drop_Items.Map = MAP_Items
  122.         .Drop_Items.X = X_Items
  123.         .Drop_Items.Y = Y_Items
  124.         .MAP_Arena = Map_Arenas
  125.         .MAP_Waiting = Map_RoomWait
  126.     End With
  127.  
  128. End Sub
  129.  
  130. Private Sub Start_Arenas(ByVal nEvent As Byte, _
  131.                          ByVal nArena As Byte, _
  132.                          ByVal X_Arenas_Team1 As Byte, _
  133.                          ByVal Y_Arenas_Team1 As Byte, _
  134.                          ByVal X_Arenas_Team2 As Byte, _
  135.                          ByVal Y_Arenas_Team2 As Byte, _
  136.                          ByVal X_Death_Team1 As Byte, _
  137.                          ByVal Y_Death_Team1 As Byte, _
  138.                          ByVal X_Death_Team2 As Byte, _
  139.                          ByVal Y_Death_Team2 As Byte)
  140.  
  141.     '@@ Cargamos las arenas.
  142.    '@@ Hacerlo vía .dat
  143.  
  144.     With Events(nEvent).Arenas(nArena)
  145.         .Pos(1).X_Corner = X_Arenas_Team1
  146.         .Pos(1).Y_Corner = Y_Arenas_Team1
  147.         .Pos(1).X_Death = X_Death_Team1
  148.         .Pos(1).Y_Death = Y_Death_Team1
  149.         .Pos(2).X_Corner = Y_Arenas_Team2
  150.         .Pos(2).Y_Corner = Y_Arenas_Team2
  151.         .Pos(2).X_Death = X_Death_Team2
  152.         .Pos(2).Y_Death = Y_Death_Team2
  153.     End With
  154.  
  155. End Sub
  156.  
  157. Private Sub Start_RoomWait(ByVal nEvent As Byte, _
  158.                            ByVal nRoom As Byte, _
  159.                            ByVal X As Byte, _
  160.                            ByVal Y As Byte)
  161.                      
  162.     '@@ Cargamos las salas de espera.
  163.        
  164.     With Events(nEvent)
  165.         .Waiting(nRoom).X_Wait = X
  166.         .Waiting(nRoom).Y_Wait = Y
  167.     End With
  168.  
  169. End Sub
  170.  
  171. Public Sub Load_Events()
  172.  
  173.     '@@ START_ARENAS NÚMMERO DE EVENTO, NÚMERO DE ARENA, COORDENADAS.
  174.    '@@ START_ROOMWAIT NÚMERO DE EVENTO, NÚMERO DE SALA, COORDENADAS.
  175.    '@@ LOAD_POS NÚMERO DE EVENTO, COORDENADAS DONDE VAN A CAER LOS ITEMS, MAPAS.
  176.    '@@@@ AVISO!: _
  177.           YO SÓLO CARGUÉ 3 ARENAS Y 3 SALAS. _
  178.           HACERLO VÍA .DAT
  179.  
  180.     Call Load_Messages
  181.     Call Load_POS(2, 49, 65, 2, 3, 2)
  182.     Call Start_RoomWait(2, 1, 11, 13)
  183.     Call Start_RoomWait(2, 2, 17, 13)
  184.     Call Start_RoomWait(2, 3, 23, 13)
  185.     Call Start_Arenas(2, 1, 11, 26, 27, 11, 30, 17, 30, 20)
  186.     Call Start_Arenas(2, 2, 37, 26, 53, 11, 57, 17, 57, 20)
  187.     Call Start_Arenas(2, 3, 65, 26, 82, 11, 86, 17, 86, 20)
  188.  
  189. End Sub
  190.  
  191. Public Sub Do_Event(ByVal ID As Integer, _
  192.                     ByVal nEvent As Byte, _
  193.                     ByVal Teams As Byte, _
  194.                     ByVal Drop As Boolean, _
  195.                     ByVal Inscription_Prize As Boolean, _
  196.                     ByVal Max_Potions As Integer, _
  197.                     ByVal Gold_Inscription As Integer, _
  198.                     ByVal Gold_Prize As Integer)
  199.  
  200.     '@@ Método para armar el evento y ponerlo en curso.
  201.  
  202.     Dim LoopC As Long
  203.     Dim loopX As Long
  204.  
  205.     If Can_DoEvent(nEvent, Teams, ID) = False Then Exit Sub
  206.  
  207.     With Events(nEvent)
  208.  
  209.         ReDim .Teams(1 To Teams)
  210.  
  211.         .Active_Send = True
  212.         '.Inscription = Inscription
  213.        .Drop = Drop
  214.         '.Prize_Gold = Prize
  215.        .Inscription = Gold_Inscription
  216.         If Inscription_Prize = True Then
  217.             .Prize = (Gold_Prize + (Gold_Inscription * (Teams * nEvent)) / 5)
  218.         Else
  219.             .Prize = Gold_Prize
  220.         End If
  221.  
  222.         For LoopC = 1 To UBound(.Teams())
  223.             ReDim .Teams(LoopC).Users(1 To nEvent)
  224.             ReDim .Teams(LoopC).Played(1 To (UBound(.Teams()) - 1))
  225.         Next LoopC
  226.  
  227.         Call SendData(SendTarget.ToAll, 0, PrepareMessageConsoleMsg(.message & " Automático> Cupos: " & Teams & " equipos" & IIf(Drop = True, ", caen items.", vbNullString) & ", máxima cantidad de pociones: " & Max_Potions & ", inscripción: " & .Inscription & ". Para participar tipeá /PARTICIPAR", FontTypeNames.FONTTYPE_GUILD))
  228.  
  229.     End With
  230.  
  231. End Sub
  232.  
  233. Public Sub Send_Event(ByRef Players() As Integer, ByVal nEvent As Byte)
  234.  
  235.     '@@ Método para enviar solicitud a compareños para unirse al evento.
  236.  
  237.     Dim LoopC As Long
  238.     Dim loopX As Long
  239.     Dim Names As String
  240.     Dim Slot  As Byte
  241.  
  242.     If Can_EnterEventAll(Players(), nEvent, True) = False Then Exit Sub
  243.  
  244.     Slot = Slot_Send(nEvent)
  245.  
  246.     For loopX = 1 To nEvent
  247.         If Names = "" Then
  248.             Names = UserList(Players(loopX)).name
  249.         Else
  250.             Names = Names & "," & UserList(Players(loopX)).name
  251.         End If
  252.     Next loopX
  253.  
  254.     With UserList(Players(1)).Events
  255.         .accept = True
  256.         .Accepts = 1
  257.         'UserList(Players(1)).flags.ID_Event = nEvent
  258.        Events(nEvent).Sends(Slot) = Players(1)
  259.         .ID_ArraySend = Slot
  260.         ReDim .Players(1 To nEvent) As Integer
  261.         For LoopC = 1 To nEvent
  262.             .Players(LoopC) = Players(LoopC)
  263.             Call WriteConsoleMsg(Players(LoopC), "El usuario " & UserList(Players(1)).name & " los ha invitado a jugar el evento automático " & Events(nEvent).message & "EQUIPO: [" & Names & "]", FontTypeNames.FONTTYPE_INFOBOLD)
  264.         Next LoopC
  265.     End With
  266. End Sub
  267.  
  268. Private Function Slot_Send(ByVal nEvent As Byte) As Byte
  269.  
  270.     '@@ Función que busca una posición libre en el array de Send().
  271.  
  272.     Dim LoopC As Long
  273.  
  274.     Slot_Send = 0
  275.  
  276.     With Events(nEvent)
  277.         For LoopC = 1 To UBound(.Sends())
  278.             If .Sends(LoopC) = 0 Then
  279.                 Slot_Send = LoopC
  280.                 Exit For
  281.             End If
  282.         Next LoopC
  283.     End With
  284.  
  285. End Function
  286.  
  287. Public Sub Accept_Send(ByVal ID As Integer, ByVal ID_Send As Integer, ByVal nEvent As Byte)
  288.  
  289.     '@@ Método para aceptar una solicitud.
  290.  
  291.   ' If ID_Send <> UserList(ID).Events.ID_Send Then Exit Sub
  292.  
  293.     Dim LoopC As Long
  294.     Dim NoYes As Boolean
  295.  
  296.     NoYes = False
  297.  
  298.     For LoopC = 1 To nEvent
  299.         If ID = UserList(ID_Send).Events.Players(LoopC) Then Exit For
  300.     Next LoopC
  301.  
  302.     If Not LoopC = nEvent Then
  303.         Call WriteConsoleMsg(ID, "El usuario " & UserList(ID_Send).name & " no te ha enviado ninguna invitación.", FontTypeNames.FONTTYPE_INFOBOLD)
  304.         Exit Sub
  305.     End If
  306.  
  307.     If ID = ID_Send Then
  308.         Call WriteConsoleMsg(ID, "Ya has aceptado la solicitud", FontTypeNames.FONTTYPE_INFOBOLD)
  309.         Exit Sub
  310.     End If
  311.  
  312.     If Can_EnterEventAll(UserList(ID_Send).Events.Players(), nEvent) = False Then Exit Sub
  313.  
  314.     UserList(ID).Events.accept = True
  315.  
  316.     Call WriteConsoleMsg(ID, "Has aceptado, espera a que los demás también lo hagan", FontTypeNames.FONTTYPE_INFOBOLD)
  317.  
  318.     With UserList(ID_Send).Events
  319.         .Accepts = .Accepts + 1
  320.  
  321.         If .Accepts = nEvent Then
  322.             Call Enter_Event(.Players(), nEvent)
  323.             Call Clean_Send(ID_Send, nEvent)
  324.         End If
  325.     End With
  326.  
  327. End Sub
  328.  
  329. Private Sub Enter_Event(ByRef Players() As Integer, ByVal nEvent As Byte)
  330.  
  331.     '@@ Método para entrar al evento.
  332.  
  333.     If Can_EnterEventAll(Players(), nEvent) = False Then Exit Sub
  334.  
  335.     Dim LoopC As Long
  336.     Dim loopX As Long
  337.     Dim Wait_Room As Byte
  338.  
  339.     Wait_Room = There_RoomWait(nEvent)
  340.  
  341.  
  342.     With Events(nEvent)
  343.         .Teams_Event = .Teams_Event + 1
  344.         For LoopC = 1 To nEvent
  345.             WriteConsoleMsg Players(LoopC), "Tú y tu equipo han ingresado al evento! éxitos en batalla!", FontTypeNames.FONTTYPE_INFOBOLD
  346.             .Teams(.Teams_Event).Users(LoopC).ID = Players(LoopC)
  347.             .Teams(.Teams_Event).Users(LoopC).Pos = UserList(Players(LoopC)).Pos
  348.             WarpUserChar .Teams(.Teams_Event).Users(LoopC).ID, .MAP_Waiting, .Waiting(Wait_Room).X_Wait, .Waiting(Wait_Room).Y_Wait - LoopC, False
  349.             UserList(.Teams(.Teams_Event).Users(LoopC).ID).Events.ID_Enter = LoopC
  350.             UserList(.Teams(.Teams_Event).Users(LoopC).ID).Events.ID_Team = .Teams_Event
  351.             UserList(.Teams(.Teams_Event).Users(LoopC).ID).flags.ID_Event = nEvent
  352.      
  353.             If .Inscription > 0 Then
  354.                 UserList(.Teams(.Teams_Event).Users(LoopC).ID).Stats.GLD = UserList(.Teams(.Teams_Event).Users(LoopC).ID).Stats.GLD - .Inscription
  355.                 WriteUpdateGold (.Teams(.Teams_Event).Users(LoopC).ID)
  356.             End If
  357.         Next LoopC
  358.         .Teams(.Teams_Event).Wait_Room = Wait_Room
  359.  
  360.         If .Teams_Event = UBound(.Teams()) Then _
  361.             Call Start_Event(nEvent)
  362.  
  363.     End With
  364.  
  365. End Sub
  366.  
  367. Private Function Can_EnterEventAll(ByRef Players() As Integer, ByVal nEvent As Byte, Optional ByVal Send As Boolean) As Boolean
  368.  
  369.     '@@ Función que chequea a los usuarios para ver si pueden entrar o no al evento.
  370.  
  371.     '@@ Faltan algunas condicionales como:
  372.  
  373.     '**************************[Aportadas por MAB]**************************
  374.    'Si esta en cárcel
  375.    'Si es una posición inválida
  376.    'Si esta en bóveda
  377.    'Si esta comerciando
  378.    '**************************[Aportadas por MAB]**************************
  379.  
  380.     Can_EnterEventAll = False
  381.  
  382.     '@@ Condicionales
  383.    Dim LoopC As Long
  384.  
  385.     With Events(nEvent)
  386.         For LoopC = 1 To nEvent
  387.  
  388.             If Players(LoopC) = 0 Then
  389.                 Call WriteConsoleMsg(Players(1), "Uno de los usuarios no se encuentra online", FontTypeNames.FONTTYPE_INFOBOLD)
  390.                 Exit Function
  391.             End If
  392.      
  393.             If Events(nEvent).Active_Send = False Then
  394.                 Call WriteConsoleMsg(Players(1), "El evento no busca concursantes.", FontTypeNames.FONTTYPE_INFOBOLD)
  395.                 Exit Function
  396.             End If
  397.      
  398.             If UserList(Players(LoopC)).flags.ID_Event > 0 Then
  399.                 Call WriteConsoleMsg(Players(1), "Uno de los usuarios ya se encuentra en un evento", FontTypeNames.FONTTYPE_INFOBOLD)
  400.                 Exit Function
  401.             End If
  402.  
  403.             If Is_City(UserList(Players(LoopC)).Pos.Map) = False Then
  404.                 Call WriteConsoleMsg(Players(1), "Uno de los usuarios no se encuentra en zona segura.", FontTypeNames.FONTTYPE_INFOBOLD)
  405.                 If Send = False Then _
  406.                     Call WriteConsoleMsg(Players(LoopC), "Estás en zona insegura, ve a zona segura para poder aceptar la invitación", FontTypeNames.FONTTYPE_INFOBOLD)
  407.                 Exit Function
  408.             End If
  409.  
  410.             If UserList(Players(LoopC)).flags.Muerto = 1 Then
  411.                 Call WriteConsoleMsg(Players(1), "El usuario " & UserList(Players(LoopC)).name & " está muerto.", FontTypeNames.FONTTYPE_INFOBOLD)
  412.                 If Send = False Then _
  413.                     Call WriteConsoleMsg(Players(LoopC), "Estás muerto", FontTypeNames.FONTTYPE_INFOBOLD)
  414.                 Exit Function
  415.             End If
  416.      
  417.             If Potion_Red(Players(LoopC)) > .Max_Potions Then
  418.                 Call WriteConsoleMsg(Players(1), "El usuario " & UserList(Players(LoopC)).name & " tiene demasiadas pociones.", FontTypeNames.FONTTYPE_INFOBOLD)
  419.                 If Send = False Then _
  420.                     Call WriteConsoleMsg(Players(LoopC), "Tienes demasiadas pociones", FontTypeNames.FONTTYPE_INFOBOLD)
  421.                 Exit Function
  422.             End If
  423.      
  424.             If UserList(Players(LoopC)).Stats.GLD < .Inscription Then
  425.                 Call WriteConsoleMsg(Players(1), "El usuario " & UserList(Players(LoopC)).name & " tiene demasiadas pociones.", FontTypeNames.FONTTYPE_INFOBOLD)
  426.                 If Send = False Then _
  427.                     Call WriteConsoleMsg(Players(LoopC), "Tienes demasiadas pociones", FontTypeNames.FONTTYPE_INFOBOLD)
  428.                 Exit Function
  429.             End If
  430.      
  431.             If UserList(Players(LoopC)).Stats.ELV < MIN_LEVEL Then
  432.                 Call WriteConsoleMsg(Players(1), "El usuario " & UserList(Players(LoopC)).name & " no tiene suficiente nivel para ingresar al evento.", FontTypeNames.FONTTYPE_INFOBOLD)
  433.                 If Send = False Then _
  434.                     Call WriteConsoleMsg(Players(LoopC), "No tienes suficiente nivel para entrar al evento", FontTypeNames.FONTTYPE_INFOBOLD)
  435.                 Exit Function
  436.             End If
  437.      
  438.         Next LoopC
  439.     End With
  440.  
  441.     Can_EnterEventAll = True
  442.  
  443. End Function
  444.  
  445. Private Function Can_DoEvent(ByVal nEvent As Byte, _
  446.                              ByVal Teams As Byte, _
  447.                              ByVal ID As Integer) As Boolean
  448.  
  449.     '@@ Función que chequea si se puede hacer un evento en tales condiciones.
  450.  
  451.  
  452.     Can_DoEvent = False
  453.  
  454.     '@@ Condicionales
  455.  
  456.     If EsGM(ID) = False Then
  457.         Call WriteConsoleMsg(ID, "No tienes acceso para realizar esta acción.", FontTypeNames.FONTTYPE_INFOBOLD)
  458.         Exit Function
  459.     End If
  460.  
  461.     If Events(nEvent).Active_Send = True Or Events(nEvent).Event_Course = True Then
  462.         Call WriteConsoleMsg(ID, "El evento se está desarrollando", FontTypeNames.FONTTYPE_INFOBOLD)
  463.         Exit Function
  464.     End If
  465.  
  466.     If nEvent < 2 Or nEvent > 10 Then
  467.         Call WriteConsoleMsg(ID, "Tipo de evento no encontrado.", FontTypeNames.FONTTYPE_INFOBOLD)
  468.         Exit Function
  469.     End If
  470.     If Teams < 2 Or Teams > MAX_WAITROOM Then
  471.         Call WriteConsoleMsg(ID, "El máximo de equipos para el evento son de " & MAX_WAITROOM & ".", FontTypeNames.FONTTYPE_INFOBOLD)
  472.         Exit Function
  473.     End If
  474.  
  475.     Can_DoEvent = True
  476.  
  477.  
  478. End Function
  479.  
  480. Public Sub Cancel_User(ByVal ID As Integer, ByVal nEvent As Byte)
  481.  
  482.     '@@ Para cuando se desconecta un usuario, ya sea cuando entra al evento o cuando están en las arenas.
  483.  
  484.     With Events(UserList(ID).flags.ID_Event)
  485.         Call WarpUserChar(ID, .Teams(UserList(ID).Events.ID_Team).Users(UserList(ID).Events.ID_Enter).Pos.Map, _
  486.         .Teams(UserList(ID).Events.ID_Team).Users(UserList(ID).Events.ID_Enter).Pos.X, _
  487.         .Teams(UserList(ID).Events.ID_Team).Users(UserList(ID).Events.ID_Enter).Pos.Y, False)
  488.         .Teams(UserList(ID).Events.ID_Team).Users(UserList(ID).Events.ID_Enter).ID = 0
  489.     End With
  490.  
  491.     With UserList(ID).Events
  492.         .ID_Enter = 0
  493.         UserList(ID).flags.ID_Event = 0
  494.         .ID_Team = 0
  495.     End With
  496.  
  497. End Sub
  498.  
  499. Private Sub Clean_Send(ByVal ID As Integer, ByVal nEvent As Byte)
  500.  
  501.     Dim LoopC As Long
  502.  
  503.     With UserList(ID).Events
  504.         Events(UserList(ID).flags.ID_Event).Sends(.ID_ArraySend) = 0
  505.         .accept = False
  506.         .Accepts = 0
  507.         .ID_ArraySend = 0
  508.         .ID_Send = 0
  509.         For LoopC = 1 To UserList(ID).flags.ID_Event
  510.             With UserList(UserList(ID).Events.Players(LoopC)).Events
  511.                 .accept = False
  512.                 .ID_Send = 0
  513.             End With
  514.             .Players(LoopC) = 0
  515.         Next LoopC
  516.     End With
  517.  
  518. End Sub
  519.  
  520. Private Sub Cancel_Enter_All(ByVal ID_Event As Byte)
  521.  
  522.     Dim LoopC As Long
  523.     Dim loopX As Long
  524.     Dim LoopZ As Long
  525.     Dim X     As Long
  526.  
  527.     With Events(ID_Event)
  528.         For X = 1 To UBound(.Sends())
  529.             Call Clean_Send(.Sends(X), ID_Event)
  530.         Next X
  531.  
  532.         .Active_Send = False
  533.         .Drop = False
  534.         '.Inscription = 0
  535.        '.Prize_Gold = 0
  536.        .Inscription = 0
  537.         .Prize = 0
  538.         .Time_Cancel = 0
  539.         .Teams_Event = 0
  540.         For LoopC = 1 To UBound(.Teams())
  541.             .Waiting(LoopC).Occupied = False
  542.             For LoopZ = 1 To UBound(.Teams()) * ID_Event
  543.                 Call WarpUserChar(.Teams(LoopC).Users(LoopZ).ID, .Teams(LoopC).Users(LoopZ).Pos.Map, .Teams(LoopC).Users(LoopZ).Pos.X, .Teams(LoopC).Users(LoopZ).Pos.Y, False)
  544.                 Call Cancel_User(.Teams(LoopC).Users(LoopZ).ID, ID_Event)
  545.             Next LoopZ
  546.         Next LoopC
  547.  
  548.     End With
  549.  
  550. End Sub
  551.  
  552. Private Function There_RoomWait(ByVal nEvent As Byte) As Byte
  553.  
  554.     Dim LoopC As Long
  555.  
  556.     There_RoomWait = 0
  557.  
  558.     With Events(nEvent)
  559.         For LoopC = 1 To MAX_WAITROOM
  560.             If .Waiting(LoopC).Occupied = False Then
  561.                 There_RoomWait = LoopC
  562.                 Exit Function
  563.             End If
  564.         Next LoopC
  565.     End With
  566.  
  567. End Function
  568.  
  569. Private Sub Start_Event(ByVal nEvent As Byte)
  570.  
  571.     '@@ Inciamos el evento.
  572.  
  573.     Dim LoopC As Long
  574.     Dim Team  As Byte
  575.  
  576.     Call SendData(SendTarget.ToAll, 0, PrepareMessageConsoleMsg(Events(nEvent).message & "> Cupo completado.", FontTypeNames.FONTTYPE_SERVER))
  577.  
  578.     For LoopC = 1 To UBound(Events(nEvent).Teams())
  579.         Team = Not_Played(LoopC, nEvent)
  580.         If Team > 0 Then
  581.             Events(nEvent).Event_Course = True
  582.             Events(nEvent).Active_Send = False
  583.             Call Math(LoopC, Team, nEvent)
  584.         End If
  585.     Next LoopC
  586.  
  587. End Sub
  588.  
  589. Private Sub Math(ByVal ID_Team As Byte, ByVal Team As Byte, ByVal nEvent As Byte)
  590.  
  591.     '@@ Emparejamos equipos.
  592.  
  593.     Dim Arena As Byte
  594.     Dim LoopC As Long
  595.  
  596.     With Events(nEvent)
  597.             If .Teams(ID_Team).Arena = 0 Then
  598.                 If Team > 0 Then
  599.                     Arena = Slot_Arena(nEvent)
  600.                     If Arena > 0 Then
  601.                         .Waiting(.Teams(ID_Team).Wait_Room).Occupied = False
  602.                         .Waiting(.Teams(Team).Wait_Room).Occupied = False
  603.              
  604.                         With .Teams(ID_Team)
  605.                             .Arena = Arena
  606.                             .Played_Amount = .Played_Amount + 1
  607.                             .Played(.Played_Amount) = Team
  608.                             .Wait_Room = 0
  609.                             .Team_Arena = Team
  610.                         End With
  611.                  
  612.                         With .Teams(Team)
  613.                             .Arena = Arena
  614.                             .Played_Amount = .Played_Amount + 1
  615.                             .Played(.Played_Amount) = ID_Team
  616.                             .Wait_Room = 0
  617.                             .Team_Arena = ID_Team
  618.                         End With
  619.                  
  620.                         With .Arenas(Arena)
  621.                             .Count = 30
  622.                             .Occupied = True
  623.                             .Indexs(1) = ID_Team
  624.                             .Indexs(2) = Team
  625.                         End With
  626.                  
  627.                         For LoopC = 1 To nEvent
  628.                             Call WarpUserChar(.Teams(ID_Team).Users(LoopC).ID, .MAP_Arena, .Arenas(Arena).Pos(1).X_Corner, .Arenas(Arena).Pos(1).Y_Corner, False)
  629.                             Call WarpUserChar(.Teams(Team).Users(LoopC).ID, .MAP_Arena, .Arenas(Arena).Pos(2).X_Corner, .Arenas(Arena).Pos(2).Y_Corner, False)
  630.                             UserList(.Teams(ID_Team).Users(LoopC).ID).Events.ID_Team_Arena = ID_Team
  631.                             UserList(.Teams(Team).Users(LoopC).ID).Events.ID_Team_Arena = Team
  632.                         Next LoopC
  633.                  
  634.                     End If
  635.                 Else
  636.                     Finish_Event nEvent
  637.                 End If
  638.             End If
  639.     End With
  640.  
  641. End Sub
  642.  
  643. Private Sub Finish_Event(ByVal nEvent As Byte)
  644.  
  645.     '@@ Finalizamos el evento.
  646.  
  647.     Dim LoopC As Long
  648.     Dim loopX As Long
  649.     Dim LoopZ As Long
  650.     Dim LoopJ As Long
  651.     Dim Max_Loop As Byte
  652.     Dim Replaced As Byte
  653.  
  654.     With Events(nEvent)
  655.         Max_Loop = UBound(.Teams())
  656.          
  657.         For LoopC = 1 To Max_Loop
  658.             If .Teams(LoopC).Points_Earned = .Team_PointLeader Then
  659.                 .Teams(LoopC).Rounds = .Teams(LoopC).Rounds_Earned - .Teams(LoopC).Rounds_Defeated
  660.                 .Teams(LoopC).K€D = .Teams(LoopC).Killed - .Teams(LoopC).Deaths
  661.                 If .Teams(LoopC).Rounds > .Best_Rounds Then
  662.                     .Best_Rounds = .Teams(LoopC).Rounds
  663.                     .Best_K€D = .Teams(LoopC).K€D
  664.                     Replaced = .Team_Win
  665.                     .Team_Win = LoopC
  666.                 ElseIf .Teams(LoopC).Rounds = .Best_Rounds Then
  667.                     If .Teams(LoopC).K€D > .Best_K€D Then
  668.                         .Best_K€D = .Teams(LoopC).K€D
  669.                         Replaced = .Team_Win
  670.                         .Team_Win = LoopC
  671.                     ElseIf .Teams(LoopC).K€D = .Best_K€D Then
  672.                         .Team_Win = 0
  673.                     End If
  674.                 End If
  675.             End If
  676.  
  677.             For loopX = 1 To nEvent
  678.                 If LoopC <> .Team_Win Then
  679.                     If .Drop = True Then
  680.                         Call WarpUserChar(.Teams(LoopC).Users(loopX).ID, .Drop_Items.Map, .Drop_Items.X, .Drop_Items.Y, False)
  681.                         Call TirarTodosLosItems(.Teams(LoopC).Users(loopX).ID)
  682.                     End If
  683.                     Call WarpUserChar(.Teams(LoopC).Users(loopX).ID, .Teams(LoopC).Users(loopX).Pos.Map, .Teams(LoopC).Users(loopX).Pos.X, .Teams(LoopC).Users(loopX).Pos.Y, False)
  684.                     If Replaced > 0 Then
  685.                         Call WarpUserChar(.Teams(Replaced).Users(loopX).ID, .Teams(Replaced).Users(loopX).Pos.Map, .Teams(Replaced).Users(loopX).Pos.X, .Teams(Replaced).Users(loopX).Pos.Y, False)
  686.                     End If
  687.                 Else
  688.                     Call WarpUserChar(.Teams(LoopC).Users(loopX).ID, .Drop_Items.Map, .Drop_Items.X, .Drop_Items.Y + 30, False)
  689.                 End If
  690.             Next loopX
  691.      
  692.             If LoopC <> .Team_Win Then _
  693.                 Call Assign_Remove_Flags(.Teams(LoopC).Users())
  694.      
  695.         Next LoopC
  696.  
  697.         Call SendData(SendTarget.ToAll, 0, PrepareMessageConsoleMsg(Events(nEvent).message & "> Evento finalizado.", FontTypeNames.FONTTYPE_SERVER))
  698.  
  699.         For LoopZ = 1 To nEvent
  700.             If .Teams(.Team_Win).Users(LoopZ).ID > 0 Then
  701.                 UserList(.Teams(.Team_Win).Users(LoopZ).ID).Stats.GLD = UserList(.Teams(.Team_Win).Users(LoopZ).ID).Stats.GLD + .Prize
  702.                 Call WriteUpdateGold(.Teams(.Team_Win).Users(LoopZ).ID)
  703.                 Call WarpUserChar(.Teams(.Team_Win).Users(LoopZ).ID, .Drop_Items.Map, .Drop_Items.X, .Drop_Items.Y, False)
  704.             End If
  705.         Next LoopZ
  706.  
  707.  
  708.         .Time_Items = 12 '0
  709.        'Call Clean_Event(nEvent)
  710.    End With
  711.  
  712. End Sub
  713.  
  714. Public Sub Clean_Event(ByVal nEvent As Byte)
  715.  
  716.     Dim LoopC As Long
  717.     Dim loopX As Long
  718.     Dim LoopZ As Long
  719.  
  720.     With Events(nEvent)
  721.         .Best_K€D = 0
  722.         .Best_Rounds = 0
  723.         .Drop = False
  724.         .Event_Course = False
  725.         .Inscription = 0
  726.         .Max_Potions = 0
  727.         .Rounds = 0
  728.         .Team_PointLeader = 0
  729.         .Team_Win = 0
  730.         .Teams_Event = 0
  731.         For LoopC = 1 To UBound(.Teams())
  732.             For loopX = 1 To nEvent
  733.                 .Teams(LoopC).Users(loopX).ID = 0
  734.             Next loopX
  735.         Next LoopC
  736.     End With
  737.  
  738. End Sub
  739.  
  740. Public Sub Death(ByVal ID As Integer)
  741.  
  742.     With Events(UserList(ID).flags.ID_Event)
  743.         .Teams(UserList(ID).Events.ID_Team).Deaths = .Teams(UserList(ID).Events.ID_Team).Deaths + 1
  744.         .Teams(UserList(ID).Events.ID_Team).Current_Deaths = .Teams(UserList(ID).Events.ID_Team).Current_Deaths + 1
  745.         .Teams(.Teams(UserList(ID).Events.ID_Team).Team_Arena).Killed = .Teams(.Teams(UserList(ID).Events.ID_Team).Team_Arena).Killed + 1
  746.         WarpUserChar ID, .MAP_Arena, .Arenas(.Teams(UserList(ID).Events.ID_Team).Arena).Pos(UserList(ID).Events.ID_Team).X_Corner, .Arenas(.Teams(UserList(ID).Events.ID_Team).Arena).Pos(UserList(ID).Events.ID_Team).Y_Corner, False
  747.          If .Teams(UserList(ID).Events.ID_Team).Current_Deaths = UserList(ID).flags.ID_Event Then _
  748.             Round_Win .Teams(UserList(ID).Events.ID_Team).Team_Arena, UserList(ID).Events.ID_Team, UserList(ID).flags.ID_Event
  749.     End With
  750.  
  751. End Sub
  752.  
  753. Private Sub Round_Win(ByVal Team_Winner As Byte, ByVal Team_Loser As Byte, ByVal nEvent As Byte)
  754.  
  755.     Dim LoopC As Long
  756.  
  757.     With Events(nEvent)
  758.         .Teams(Team_Winner).Rounds_Earned = .Teams(Team_Winner).Rounds_Earned + 1
  759.         .Teams(Team_Winner).Current_Rounds = .Teams(Team_Winner).Current_Rounds + 1
  760.         .Teams(Team_Loser).Rounds_Defeated = .Teams(Team_Loser).Rounds_Defeated + 1
  761.         .Teams(Team_Winner).Current_Deaths = 0
  762.         .Teams(Team_Loser).Current_Deaths = 0
  763.         Call Assign_Remove_Flags(.Teams(Team_Winner).Users())
  764.         Call Assign_Remove_Flags(.Teams(Team_Loser).Users())
  765.  
  766.         If .Teams(Team_Winner).Rounds_Earned = 2 Then _
  767.             Call Point_Win(Team_Winner, Team_Loser, nEvent)
  768.  
  769.         .Arenas(.Teams(Team_Winner).Arena).Count = 20
  770.  
  771.         For LoopC = 1 To nEvent
  772.             Call WarpUserChar(.Teams(Team_Winner).Users(LoopC).ID, .MAP_Arena, .Arenas(.Teams(Team_Winner).Arena).Pos(Team_Winner).X_Corner, .Arenas(.Teams(Team_Winner).Arena).Pos(Team_Winner).Y_Corner, False)
  773.             Call WarpUserChar(.Teams(Team_Loser).Users(LoopC).ID, .MAP_Arena, .Arenas(.Teams(Team_Loser).Arena).Pos(Team_Loser).X_Corner, .Arenas(.Teams(Team_Loser).Arena).Pos(Team_Loser).Y_Corner, False)
  774.             Call WritePauseToggle(.Teams(Team_Winner).Users(LoopC).ID)
  775.             Call WritePauseToggle(.Teams(Team_Loser).Users(LoopC).ID)
  776.         Next LoopC
  777.     End With
  778.  
  779. End Sub
  780.  
  781. Private Sub Point_Win(ByVal Team_Winner As Byte, ByVal Team_Loser As Byte, ByVal nEvent As Byte)
  782.  
  783.     Dim Room_Wait As Byte
  784.     Dim NotPlayed As Byte
  785.  
  786.     With Events(nEvent)
  787.  
  788.         .Teams(Team_Winner).Points_Earned = .Teams(Team_Winner).Points_Earned + 1
  789.  
  790.         If .Teams(Team_Winner).Points_Earned > .Team_PointLeader Then _
  791.             .Team_PointLeader = .Teams(Team_Winner).Points_Earned
  792.  
  793.         .Arenas(.Teams(Team_Winner).Arena).Occupied = False
  794.         .Arenas(.Teams(Team_Winner).Arena).Count = 0
  795.  
  796.         NotPlayed = Not_Played(Team_Winner, nEvent)
  797.  
  798.         If NotPlayed = 0 Then
  799.             Room_Wait = There_RoomWait(nEvent)
  800.             .Teams(Team_Winner).Wait_Room = Room_Wait
  801.             .Waiting(Room_Wait).Occupied = True
  802.             .Teams(Team_Winner).Wait_Room = Room_Wait
  803.         Else
  804.             Math Team_Winner, NotPlayed, nEvent
  805.         End If
  806.  
  807.         NotPlayed = Not_Played(Team_Loser, nEvent)
  808.  
  809.         If NotPlayed = 0 Then
  810.             Room_Wait = There_RoomWait(nEvent)
  811.             .Teams(Team_Loser).Wait_Room = Room_Wait
  812.             .Waiting(Team_Loser).Occupied = True
  813.             .Teams(Team_Loser).Wait_Room = Room_Wait
  814.         Else
  815.             Math Team_Winner, NotPlayed, nEvent
  816.         End If
  817.  
  818.     End With
  819. End Sub
  820.  
  821. Private Sub Assign_Remove_Flags(ByRef Users() As tUsers)
  822.  
  823.     '@@ Método para actualizar la vida, mana, sacarle el paralizado, revivir al usuario, etc.
  824.  
  825.     Dim LoopC As Long
  826.  
  827.     For LoopC = 1 To UBound(Users())
  828.  
  829.        Call RevivirUsuario(Users(LoopC).ID)
  830.  
  831.        With UserList(Users(LoopC).ID).flags
  832.            .Paralizado = 0
  833.            .Envenenado = 0
  834.            .Escondido = 0
  835.            .invisible = 0
  836.            .Inmovilizado = 0
  837.        End With
  838.  
  839.        With UserList(Users(LoopC).ID).Stats
  840.            .MinMAN = .MaxMAN
  841.            .MinSta = .MaxSta
  842.        End With
  843.  
  844.        Call WriteUpdateUserStats(Users(LoopC).ID)
  845.  
  846.    Next LoopC
  847.  
  848. End Sub
  849.  
  850. Private Function Potion_Red(ByVal ID As Integer) As Long
  851.  
  852.     '@@ Función que devuelve las pociones rojas del usuario.
  853.  
  854.     Dim LoopC As Long
  855.     Dim Total As Long
  856.  
  857.     With UserList(ID)
  858.  
  859.         For LoopC = 1 To .CurrentInventorySlots
  860.             If .Invent.Object(LoopC).ObjIndex = INDEX_POTION_RED Then
  861.                 Total = Total + .Invent.Object(LoopC).Amount
  862.             End If
  863.         Next LoopC
  864.  
  865.         Potion_Red = Total
  866.  
  867.     End With
  868.  
  869. End Function
  870.  
  871. Private Function Is_City(ByVal Map As Integer) As Boolean
  872.  
  873.     '@@ Función que devuelve si el mapa es una ciudad.
  874.  
  875.     Dim LoopC As Long
  876.  
  877.     For LoopC = 1 To NUMCIUDADES
  878.         If Map = Ciudades(LoopC).Map Then
  879.             Is_City = True
  880.             Exit Function
  881.         End If
  882.     Next LoopC
  883.  
  884.     Is_City = False
  885.  
  886. End Function
  887. Private Function Slot_Arena(ByVal nEvent As Byte) As Byte
  888.  
  889.     Slot_Arena = 0
  890.  
  891.     Dim LoopC As Long
  892.  
  893.     With Events(nEvent)
  894.  
  895.         For LoopC = 1 To MAX_ARENAS
  896.             If .Arenas(LoopC).Occupied = False Then
  897.                 Slot_Arena = LoopC
  898.                 Exit For
  899.             End If
  900.         Next LoopC
  901.  
  902.     End With
  903.  
  904. End Function
  905.  
  906. Private Function Not_Played(ByVal ID_Team As Byte, ByVal nEvent As Byte) As Byte
  907.  
  908.     Dim LoopC As Long
  909.     Dim loopX As Long
  910.  
  911.     Not_Played = 0
  912.  
  913.     With Events(nEvent)
  914.         For LoopC = 1 To UBound(.Teams())
  915.             For loopX = 1 To UBound(.Teams())
  916.                 If .Teams(ID_Team).Played(loopX) <> LoopC Then _
  917.                     Exit For
  918.             Next loopX
  919.                 If ID_Team <> LoopC Then
  920.                     If .Teams(LoopC).Played_Amount <> UBound(.Teams()) Then
  921.                         If .Teams(LoopC).Arena = 0 Then
  922.                             Not_Played = LoopC
  923.                             Exit For
  924.                         End If
  925.                     End If
  926.                 End If
  927.         Next LoopC
  928.     End With
  929.  
  930. End Function
  931.  
  932. Public Sub Count_Event()
  933.  
  934.     '@@ Timer de un segundo.
  935.  
  936.     Dim LoopC As Long
  937.     Dim loopX As Long
  938.     Dim LoopZ As Long
  939.     Dim LoopJ As Long
  940.     Dim LoopT As Long
  941.  
  942.     For LoopC = 2 To 10
  943.         With Events(LoopC)
  944.      
  945.             '@@ Tiempo para que se vayan del mapa.
  946.            If .Time_Items = -1 Then
  947.                 .Time_Items = 0
  948.                 Clean_Event LoopC
  949.                 For LoopT = 1 To LoopC
  950.                     Call WarpUserChar(.Teams(.Team_Win).Users(LoopT).ID, .Drop_Items.Map, .Drop_Items.X, .Drop_Items.Y, False)
  951.                 Next LoopT
  952.             End If
  953.             If .Time_Items > -1 Then _
  954.                 .Time_Items = .Time_Items - 1
  955.      
  956.             '@@ Autocancelamiento.
  957.            If .Time_Cancel = -1 Then
  958.                 .Time_Cancel = 0
  959.                 Cancel_Enter_All LoopC
  960.             End If
  961.             If .Time_Cancel > -1 Then _
  962.                 .Time_Cancel = .Time_Cancel - 1
  963.      
  964.             '@@ Esto es para todo lo que es dentro de las arenas.
  965.            For loopX = 1 To MAX_ARENAS
  966.                 With .Arenas(loopX)
  967.                     If .Count = -1 Then
  968.                         .Count = 0
  969.                         For LoopZ = 1 To LoopC
  970.                             Call WriteConsoleMsg(Events(LoopC).Teams(.Indexs(1)).Users(LoopZ).ID, Events(LoopC).message & "> Ya!", FontTypeNames.FONTTYPE_FIGHT)
  971.                             Call WriteConsoleMsg(Events(LoopC).Teams(.Indexs(2)).Users(LoopZ).ID, Events(LoopC).message & "> Ya!", FontTypeNames.FONTTYPE_FIGHT)
  972.                         Next LoopZ
  973.                     End If
  974.                     If .Count > -1 Then
  975.                         .Count = .Count - 1
  976.                          For LoopJ = 1 To LoopC
  977.                             Call WriteConsoleMsg(Events(LoopC).Teams(.Indexs(1)).Users(LoopJ).ID, Events(LoopC).message & "> " & .Count, FontTypeNames.FONTTYPE_FIGHT)
  978.                             Call WriteConsoleMsg(Events(LoopC).Teams(.Indexs(2)).Users(LoopJ).ID, Events(LoopC).message & "> " & .Count, FontTypeNames.FONTTYPE_FIGHT)
  979.                          Next LoopJ
  980.                     End If
  981.                 End With
  982.             Next loopX
  983.         End With
  984.     Next LoopC
  985.  
  986. End Sub
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement