Advertisement
Luciano_fuentes

Untitled

Sep 11th, 2016
190
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) As Integer
  93.         ReDim .Teams(2).UsersInTeam(1) As Integer
  94.        
  95.         .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.     Dim Users As Byte
  158.    
  159.     With EventDelegate
  160.    
  161.         Call SendData(SendTarget.toall, 0, PrepareMessageConsoleMsg("El cupo ha sido completado.", FontTypeNames.FONTTYPE_INFOBOLD))
  162.    
  163.         For Blue = 1 To .Quotas / 2
  164.        
  165.             Users = Users + 1
  166.        
  167.             .Teams(1).UsersInTeam(Blue) = .UserIndex(Users).ID
  168.             Call WriteConsoleMsg(.Teams(1).UsersInTeam(Blue), "Ahora perteneces al equipo azul.", FontTypeNames.FONTTYPE_INFOBOLD)
  169.             Call WarpUserChar(.Teams(1).UsersInTeam(Blue), MAP_EVENT, .Teams(1).X, .Teams(1).Y, True)
  170.            
  171.         Next Blue
  172.        
  173.         For Red = 1 To .Quotas / 2
  174.        
  175.             Users = Users + 1
  176.            
  177.             .Teams(2).UsersInTeam(Red) = .UserIndex(Users).ID
  178.             Call WriteConsoleMsg(.Teams(2).UsersInTeam(Red), "Ahora perteneces al equipo rojo.", FontTypeNames.FONTTYPE_INFOBOLD)
  179.             Call WarpUserChar(.Teams(2).UsersInTeam(Red), MAP_EVENT, .Teams(2).X, .Teams(2).Y, True)
  180.            
  181.         Next Red
  182.        
  183.         '@@ Elige los delegados al azar.
  184.        .Delegates(1) = .Teams(1).UsersInTeam(RandomNumber(1, UBound(.Teams(1).UsersInTeam)))
  185.         .Delegates(2) = .Teams(2).UsersInTeam(RandomNumber(1, UBound(.Teams(2).UsersInTeam)))
  186.        
  187.         '@@ Le marco que es delegado.
  188.        UserList(.Delegates(1)).flags.EventDelegate = 1
  189.         UserList(.Delegates(2)).flags.EventDelegate = 1
  190.        
  191.         '@@ Llevamos a los delegados.
  192.        Call WarpUserChar(.Delegates(1), MAP_EVENT, .Teams(1).Delegate_X, .Teams(1).Delegate_Y, False)
  193.         Call WarpUserChar(.Delegates(2), MAP_EVENT, .Teams(2).Delegate_X, .Teams(2).Delegate_Y, False)
  194.  
  195.         '@@ Mensaje para los delegados.
  196.        Call WriteConsoleMsg(.Delegates(1), "Eres delegado del equipo azul.", FontTypeNames.FONTTYPE_INFOBOLD)
  197.         Call WriteConsoleMsg(.Delegates(2), "Eres delegado del equipo rojo.", FontTypeNames.FONTTYPE_INFOBOLD)
  198.  
  199.         '@@ Para iniciar la cuenta regresiva.
  200.        .Countdown = 15
  201.        
  202.     End With
  203.  
  204. End Sub
  205.  
  206. Private Sub Enter_Wait(ByVal ID As Integer)
  207.  
  208.     '@@ Los mando a la sala de espera.
  209.    '@@ Les marco que están en evento.
  210.    
  211.     Call WarpUserChar(ID, 1, 50, 50, True)
  212.     UserList(ID).flags.EventDelegate = 1
  213.     Call WriteConsoleMsg(ID, "Has ingresado al evento, eres el participante Nº" & EventDelegate.UsersEvent, FontTypeNames.FONTTYPE_INFOBOLD)
  214.  
  215. End Sub
  216.  
  217. Private Function Can_Event(ByVal ID As Integer) As Boolean
  218.  
  219.     '@@ Compruebo si se puede armar evento.
  220.  
  221.     Can_Event = False
  222.  
  223.     If Not EsGM(ID) Then
  224.         Call WriteConsoleMsg(ID, "Tienes que ser GM para realizar el evento.", FontTypeNames.FONTTYPE_INFOBOLD)
  225.         Exit Function
  226.     End If
  227.    
  228.     With EventDelegate
  229.    
  230.         If .EventDelegate = True Then
  231.             Call WriteConsoleMsg(ID, "Ya hay un torneo en curso. Espera a que ese termine.", FontTypeNames.FONTTYPE_INFOBOLD)
  232.             Exit Function
  233.         End If
  234.        
  235.        ' If .Quotas < 3 * 2 Then Exit Function
  236.    
  237.     End With
  238.    
  239.     Can_Event = True
  240.    
  241. End Function
  242.  
  243. Private Function Can_EnterEvent(ByVal ID As Integer) As Boolean
  244.  
  245.     '@@ Compruebo si puede entrar al evento
  246.    
  247.     Can_EnterEvent = False
  248.  
  249.     With UserList(ID)
  250.  
  251.         If .Stats.ELV < EventDelegate.Level Then Exit Function
  252.         If EventDelegate.EventDelegate = False Then Exit Function
  253.         If .flags.Delegate = 1 Then Exit Function
  254.         If .Stats.GLD < EventDelegate.Requirement Then Exit Function
  255.         If EventDelegate.UsersEvent = EventDelegate.Quotas Then Exit Function
  256.         If .flags.Muerto = 1 Then Exit Function
  257.        
  258.     End With
  259.    
  260.      Can_EnterEvent = True
  261.  
  262. End Function
  263.  
  264. Public Sub Countdown_Event()
  265.  
  266.     '@@ Cuenta regresiva.
  267.  
  268.     With EventDelegate
  269.  
  270.         If .Countdown > 0 Then
  271.    
  272.             .Countdown = .Countdown - 1
  273.    
  274.             Select Case .Countdown
  275.        
  276.                 Case 15
  277.                     Call SendData(SendTarget.toall, 0, PrepareMessageConsoleMsg("Delegado» CONTEO» " & .Countdown, FontTypeNames.FONTTYPE_INFOBOLD))
  278.        
  279.                 Case 10
  280.                     Call SendData(SendTarget.toall, 0, PrepareMessageConsoleMsg("Delegado» CONTEO» " & .Countdown, FontTypeNames.FONTTYPE_INFOBOLD))
  281.                
  282.                 Case 5
  283.                     Call SendData(SendTarget.toall, 0, PrepareMessageConsoleMsg("Delegado» CONTEO» " & .Countdown, FontTypeNames.FONTTYPE_INFOBOLD))
  284.                
  285.                 Case 4
  286.                     Call SendData(SendTarget.toall, 0, PrepareMessageConsoleMsg("Delegado» CONTEO» " & .Countdown, FontTypeNames.FONTTYPE_INFOBOLD))
  287.                
  288.                 Case 3
  289.                     Call SendData(SendTarget.toall, 0, PrepareMessageConsoleMsg("Delegado» CONTEO» " & .Countdown, FontTypeNames.FONTTYPE_INFOBOLD))
  290.                
  291.                 Case 2
  292.                     Call SendData(SendTarget.toall, 0, PrepareMessageConsoleMsg("Delegado» CONTEO» " & .Countdown, FontTypeNames.FONTTYPE_INFOBOLD))
  293.                
  294.                 Case 1
  295.                     Call SendData(SendTarget.toall, 0, PrepareMessageConsoleMsg("Delegado» CONTEO» " & .Countdown, FontTypeNames.FONTTYPE_INFOBOLD))
  296.                
  297.                 Case 0
  298.                     Call SendData(SendTarget.toall, 0, PrepareMessageConsoleMsg("Delegado» PELEEN!", FontTypeNames.FONTTYPE_FIGHT))
  299.        
  300.             End Select
  301.            
  302.         End If
  303.        
  304.     End With
  305.    
  306. End Sub
  307.  
  308. Public Function Check_Death(ByVal Team As Integer) As Boolean
  309.  
  310.     Check_Death = False
  311.    
  312.     If EventDelegate.Teams(Team).DeathTeam >= UBound(EventDelegate.Teams.UsersInTeam()) Then Exit Function
  313.    
  314.     Check_Death = True
  315.  
  316. End Function
  317.  
  318. Public Function Return_Team(ByVal UserID As Integer) As Byte
  319.  
  320.     Dim LoopC As Long
  321.     Dim LoopX As Long
  322.    
  323.     For LoopC = 1 To 2
  324.    
  325.         For LoopX = 1 To EventDelegate.UsersEvent / 2
  326.        
  327.             If EventDelegate.Teams(LoopC).UsersInTeam(LoopX) = UserID Then
  328.            
  329.                 Return_Team = LoopC
  330.                 Exit Function
  331.                
  332.             End If
  333.        
  334.         Next LoopX
  335.        
  336.     Next LoopC
  337.  
  338. End Function
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement