Advertisement
Luciano_fuentes

Events

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