Advertisement
Luciano_fuentes

EVENTO

Sep 11th, 2016
208
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Option Explicit
  2.  
  3. '@@@ AUTOR: LUCIANO
  4. '@@@ EVENTO: DELEGADO
  5.  
  6. Private Type tTeams
  7.  
  8.     UsersInTeam()       As Integer
  9.     WinPoints           As Byte
  10.     DeathTeam           As Byte
  11.     WinRounds           As Byte
  12.     Delegate_X          As Byte
  13.     Delegate_Y          As Byte
  14.     X                   As Byte
  15.     Y                   As Byte
  16.    
  17. End Type
  18.  
  19. Private Type tUserEvent
  20.  
  21.     ID                  As Integer
  22.     LastPosition        As WorldPos
  23.  
  24. End Type
  25.  
  26. Private Type tEventDelegate
  27.  
  28.     Teams(1 To 2)       As tTeams
  29.     UsersEvent          As Byte
  30.     UserIndex()         As tUserEvent
  31.     EventDelegate       As Boolean
  32.     Points              As Byte
  33.     Rounds              As Byte
  34.     Requirement         As Long
  35.     Prize               As Long
  36.     Quotas              As Byte
  37.     Delegates(1 To 2)   As Integer
  38.     Level               As Byte
  39.     Countdown           As Byte
  40.    
  41. End Type
  42.  
  43. Private Const MAP_EVENT As Integer = 1
  44.  
  45. Private Const POS_DEATH_X As Byte = 60
  46. Private Const POS_DEATH_Y As Byte = 60
  47.  
  48. Private EventDelegate As tEventDelegate
  49.  
  50. Public Sub Load_Coordinates()
  51.  
  52.     '@@ Cargamos las coordenas de los equipos y la del delegado.
  53.    
  54.     With EventDelegate
  55.    
  56.         '@@ EQUIPOS:
  57.        .Teams(1).X = 57
  58.         .Teams(1).Y = 46
  59.        
  60.         .Teams(2).X = 59
  61.         .Teams(2).Y = 46
  62.        
  63.         '@@ DELEGADOS:
  64.        .Teams(1).Delegate_X = 61
  65.         .Teams(1).Delegate_Y = 46
  66.        
  67.         .Teams(2).Delegate_X = 55
  68.         .Teams(2).Delegate_Y = 46
  69.        
  70.     End With
  71. End Sub
  72.  
  73. Public Sub Start_Event(ByVal UserIndex As Integer, _
  74.                        ByVal Quotas As Byte, _
  75.                        ByVal Prize As Long, _
  76.                        ByVal Requirement_Gold As Long, _
  77.                        ByVal Rounds As Byte, _
  78.                        ByVal Points As Byte, _
  79.                        ByVal Level As Byte)
  80.                        
  81.     '@@ Inicio el evento.
  82.    '@@ Paso requerimientos
  83.    '@@ Compruebo si se puede armar torneo.
  84.    '@@ Aviso por consola
  85.  
  86.     With EventDelegate
  87.        
  88.         If Can_Event(UserIndex) = False Then Exit Sub
  89.        
  90.         If Quotas < 2 Then Quotas = 2
  91.        
  92.         ReDim .Teams(1).UsersInTeam(1 To Quotas) As Integer
  93.         ReDim .Teams(2).UsersInTeam(1 To Quotas) As Integer
  94.        
  95.         .Quotas = Quotas * 2
  96.         .Prize = Prize
  97.         .Points = Points
  98.        
  99.         .Requirement = Requirement_Gold
  100.         .Rounds = Rounds
  101.         .EventDelegate = True
  102.        
  103.         .Level = Level
  104.         .UsersEvent = 0
  105.        
  106.         ReDim .UserIndex(1 To .Quotas) As tUserEvent
  107.        
  108.         Call SendData(SendTarget.ToAll, 0, PrepareMessageConsoleMsg("Evento Delegado> Iniciado", FontTypeNames.FONTTYPE_GUILD))
  109.  
  110.     End With
  111.  
  112. End Sub
  113.  
  114. Public Sub Enter_Event(ByVal UserIndex As Integer)
  115.  
  116.     '@@ Participan al evento
  117.    '@@ Los llevo a la sala de espera
  118.    '@@ Sumo la cantidad de usuarios en evento.
  119.    '@@ Guardo la ID del usuario.
  120.    '@@ Guardo la posición del usuario.
  121.    '@@ Le saco el oro.
  122.  
  123.     If Can_EnterEvent(UserIndex) = False Then Exit Sub
  124.  
  125.     With EventDelegate
  126.        
  127.         .UsersEvent = .UsersEvent + 1
  128.    
  129.         .UserIndex(.UsersEvent).ID = UserIndex
  130.        
  131.         .UserIndex(.UsersEvent).LastPosition = UserList(UserIndex).Pos
  132.    
  133.         UserList(UserIndex).Stats.GLD = UserList(UserIndex).Stats.GLD - .Requirement
  134.    
  135.         Call Enter_Wait(UserIndex)
  136.         Call WriteUpdateGold(UserIndex)
  137.        
  138.         If .UsersEvent = .Quotas Then _
  139.             Call Enter_Fight
  140.    
  141.     End With
  142.  
  143. End Sub
  144.  
  145. Private Sub Enter_Fight()
  146.  
  147.     '@@ Aviso que se completa el cupo.
  148.    '@@ Divido los participantes y pongo a cada uno en los equipos.
  149.    '@@ Elijo los delegados al azar.
  150.    '@@ Llevo a todos a la arena.
  151.    '@@ Pongo los delegados en donde deben ir.
  152.    '@@ Inicio la cuenta regresiva.
  153.    '@@ Les aviso a que equipo pertenecen.
  154.  
  155.     Dim Blue As Long
  156.     Dim Red As Long
  157.    
  158.     With EventDelegate
  159.    
  160.         Call SendData(SendTarget.ToAll, 0, PrepareMessageConsoleMsg("El cupo ha sido completado.", FontTypeNames.FONTTYPE_INFOBOLD))
  161.    
  162.         For Blue = 1 To .Quotas Step 2
  163.        
  164.             '@@ Mete los in pares al equipo azul
  165.            .Teams(1).UsersInTeam(Blue) = .UserIndex(Blue).ID
  166.             Call WriteConsoleMsg(.UserIndex(Blue).ID, "Ahora perteneces al equipo azul.", FontTypeNames.FONTTYPE_INFOBOLD)
  167.             Call WarpUserChar(.UserIndex(Blue).ID, MAP_EVENT, .Teams(1).X, .Teams(1).Y, True)
  168.            
  169.         Next Blue
  170.        
  171.         For Red = 2 To .Quotas Step 2
  172.        
  173.             '@@ Los pares al rojo.
  174.            .Teams(2).UsersInTeam(Red) = .UserIndex(Red).ID
  175.             Call WriteConsoleMsg(.UserIndex(Red).ID, "Ahora perteneces al equipo rojo.", FontTypeNames.FONTTYPE_INFOBOLD)
  176.             Call WarpUserChar(.UserIndex(Red).ID, MAP_EVENT, .Teams(2).X, .Teams(2).Y, True)
  177.            
  178.         Next Red
  179.        
  180.         '@@ Elige los delegados al azar.
  181.        .Delegates(1) = .Teams(1).UsersInTeam(RandomNumber(1, UBound(.Teams(1).UsersInTeam)))
  182.         .Delegates(2) = .Teams(2).UsersInTeam(RandomNumber(1, UBound(.Teams(2).UsersInTeam)))
  183.        
  184.         '@@ Le marco que es delegado.
  185.        UserList(.Delegates(1)).flags.EventDelegate = 1
  186.         UserList(.Delegates(2)).flags.EventDelegate = 1
  187.        
  188.         '@@ Llevamos a los delegados.
  189.        Call WarpUserChar(.Delegates(1), MAP_EVENT, .Teams(1).Delegate_X, .Teams(1).Delegate_X, False)
  190.         Call WarpUserChar(.Delegates(2), MAP_EVENT, .Teams(2).Delegate_X, .Teams(2).Delegate_X, False)
  191.  
  192.         '@@ Mensaje para los delegados.
  193.        Call WriteConsoleMsg(.Delegates(1), "Eres delegado del equipo rojo.", FontTypeNames.FONTTYPE_INFOBOLD)
  194.         Call WriteConsoleMsg(.Delegates(2), "Eres delegado del equipo azul.", FontTypeNames.FONTTYPE_INFOBOLD)
  195.  
  196.         '@@ Para iniciar la cuenta regresiva.
  197.        .Countdown = 15
  198.        
  199.     End With
  200.  
  201. End Sub
  202.  
  203. Private Sub Enter_Wait(ByVal ID As Integer)
  204.  
  205.     '@@ Los mando a la sala de espera.
  206.    '@@ Les marco que están en evento.
  207.    
  208.     Call WarpUserChar(ID, 1, 50, 50, True)
  209.     UserList(ID).flags.EventDelegate = 1
  210.     Call WriteConsoleMsg(ID, "Has ingresado al evento, eres el participante Nº" & EventDelegate.UsersEvent, FontTypeNames.FONTTYPE_INFOBOLD)
  211.  
  212. End Sub
  213.  
  214. Private Function Can_Event(ByVal ID As Integer) As Boolean
  215.  
  216.     '@@ Compruebo si se puede armar evento.
  217.  
  218.     Can_Event = False
  219.  
  220.     If Not EsGM(ID) Then
  221.         Call WriteConsoleMsg(ID, "Tienes que ser GM para realizar el evento.", FontTypeNames.FONTTYPE_INFOBOLD)
  222.         Exit Function
  223.     End If
  224.    
  225.     With EventDelegate
  226.    
  227.         If .EventDelegate = True Then
  228.             Call WriteConsoleMsg(ID, "Ya hay un torneo en curso. Espera a que ese termine.", FontTypeNames.FONTTYPE_INFOBOLD)
  229.             Exit Function
  230.         End If
  231.        
  232.        ' If .Quotas < 3 * 2 Then Exit Function
  233.    
  234.     End With
  235.    
  236.     Can_Event = True
  237.    
  238. End Function
  239.  
  240. Private Function Can_EnterEvent(ByVal ID As Integer) As Boolean
  241.  
  242.     '@@ Compruebo si puede entrar al evento
  243.    
  244.     Can_EnterEvent = False
  245.  
  246.     With UserList(ID)
  247.  
  248.         If .Stats.ELV < EventDelegate.Level Then Exit Function
  249.         If EventDelegate.EventDelegate = False Then Exit Function
  250.         If .flags.Delegate = 1 Then Exit Function
  251.         If .Stats.GLD < EventDelegate.Requirement Then Exit Function
  252.         If EventDelegate.UsersEvent = EventDelegate.Quotas Then Exit Function
  253.         If .flags.Muerto = 1 Then Exit Function
  254.        
  255.     End With
  256.    
  257.      Can_EnterEvent = True
  258.  
  259. End Function
  260.  
  261. Public Sub Countdown_Event()
  262.  
  263.     '@@ Cuenta regresiva.
  264.  
  265.     With EventDelegate
  266.  
  267.         If .Countdown > 0 Then
  268.    
  269.             .Countdown = .Countdown - 1
  270.    
  271.             Select Case EventDelegate.Countdown
  272.        
  273.                 Case 15
  274.                     Call SendData(SendTarget.toMap, 0, PrepareMessageConsoleMsg("Delegado» CONTEO» " & .Countdown, FontTypeNames.FONTTYPE_INFOBOLD))
  275.        
  276.                 Case 10
  277.                     Call SendData(SendTarget.toMap, 0, PrepareMessageConsoleMsg("Delegado» CONTEO» " & .Countdown, FontTypeNames.FONTTYPE_INFOBOLD))
  278.                
  279.                 Case 5
  280.                     Call SendData(SendTarget.toMap, 0, PrepareMessageConsoleMsg("Delegado» CONTEO» " & .Countdown, FontTypeNames.FONTTYPE_INFOBOLD))
  281.                
  282.                 Case 4
  283.                     Call SendData(SendTarget.toMap, 0, PrepareMessageConsoleMsg("Delegado» CONTEO» " & .Countdown, FontTypeNames.FONTTYPE_INFOBOLD))
  284.                
  285.                 Case 3
  286.                     Call SendData(SendTarget.toMap, 0, PrepareMessageConsoleMsg("Delegado» CONTEO» " & .Countdown, FontTypeNames.FONTTYPE_INFOBOLD))
  287.                
  288.                 Case 2
  289.                     Call SendData(SendTarget.toMap, 0, PrepareMessageConsoleMsg("Delegado» CONTEO» " & .Countdown, FontTypeNames.FONTTYPE_INFOBOLD))
  290.                
  291.                 Case 1
  292.                     Call SendData(SendTarget.toMap, 0, PrepareMessageConsoleMsg("Delegado» CONTEO» " & .Countdown, FontTypeNames.FONTTYPE_INFOBOLD))
  293.                
  294.                 Case 0
  295.                     Call SendData(SendTarget.toMap, 0, PrepareMessageConsoleMsg("Delegado» PELEEN!", FontTypeNames.FONTTYPE_FIGHT))
  296.        
  297.             End Select
  298.            
  299.         End If
  300.        
  301.     End With
  302.    
  303. End Sub
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement