Advertisement
Luciano_fuentes

Event

Sep 11th, 2016
167
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.    
  40. End Type
  41.  
  42. Private Const MAP_EVENT As Integer = 1
  43. Private EventDelegate As tEventDelegate
  44.  
  45. Public Sub Load_Coordinates()
  46.  
  47.     '@@ Cargamos las coordenas de los equipos y la del delegado.
  48.    
  49.     With EventDelegate
  50.    
  51.         '@@ EQUIPOS:
  52.        .Teams(1).X = 50
  53.         .Teams(1).Y = 60
  54.        
  55.         .Teams(2).X = 50
  56.         .Teams(2).Y = 60
  57.        
  58.         '@@ DELEGADOS:
  59.        .Teams(1).Delegate_X = 80
  60.         .Teams(1).Delegate_Y = 80
  61.        
  62.         .Teams(2).Delegate_X = 60
  63.         .Teams(2).Delegate_Y = 60
  64.        
  65.     End With
  66. End Sub
  67.  
  68. Public Sub Start_Event(ByVal UserIndex As Integer, _
  69.                        ByVal Quotas As Byte, _
  70.                        ByVal Prize As Long, _
  71.                        ByVal Requirement_Gold As Long, _
  72.                        ByVal Rounds As Byte, _
  73.                        ByVal Points As Byte, _
  74.                        ByVal Level As Byte)
  75.                        
  76.     '@@ Inicio el evento.
  77.    '@@ Paso requerimientos
  78.    '@@ Compruebo si se puede armar torneo.
  79.    '@@ Aviso por consola
  80.  
  81.     With EventDelegate
  82.        
  83.         If Can_Event(UserIndex) = False Then Exit Sub
  84.        
  85.         .Quotas = Quotas * 2
  86.         .Prize = Prize
  87.         .Points = Points
  88.        
  89.         .Requirement = Requirement_Gold
  90.         .Rounds = Rounds
  91.         .EventDelegate = True
  92.        
  93.         .Level = Level
  94.         .UsersEvent = 0
  95.        
  96.         ReDim .Teams(1).UsersInTeam(1 To Quotas) As Integer
  97.         ReDim .Teams(2).UsersInTeam(1 To Quotas) As Integer
  98.        
  99.         ReDim .UserIndex(1 To .Quotas) As Integer
  100.        
  101.         Call SendData(SendTarget.ToAll, 0, PrepareMessageConsoleMsg("Evento Delegado> Iniciado", FontTypeNames.FONTTYPE_SERVER))
  102.  
  103.     End With
  104.  
  105. End Sub
  106.  
  107. Public Sub Enter_Event(ByVal UserIndex As Integer)
  108.  
  109.     '@@ Participan al evento
  110.    '@@ Los llevo a la sala de espera
  111.    '@@ Sumo la cantidad de usuarios en evento.
  112.    '@@ Guardo la ID del usuario.
  113.    '@@ Guardo la posición del usuario.
  114.    '@@ Le sacoa el oro.
  115.  
  116.     If Can_EnterEvent(UserIndex) = False Then Exit Sub
  117.  
  118.     With EventDelegate
  119.        
  120.         .UsersEvent = .UsersEvent + 1
  121.    
  122.         .UserIndex(.UsersEvent).ID = UserIndex
  123.        
  124.         .UserIndex(.UsersEvent).LastPosition = UserList(UserIndex).Pos
  125.    
  126.         UserList(UserIndex).Stats.GLD = UserList(UserIndex).Stats.GLD - .Requirement
  127.    
  128.         Call Enter_Wait(UserIndex)
  129.         Call WriteUpdateGold(UserIndex)
  130.        
  131.         If .UsersEvent = .Quotas Then _
  132.             Call Enter_Fight
  133.    
  134.     End With
  135.  
  136. End Sub
  137.  
  138. Private Sub Enter_Fight()
  139.  
  140.  
  141.     Dim Blue As Long
  142.     Dim Red As Long
  143.    
  144.     With EventDelegate
  145.    
  146.         Call SendData(SendTarget.ToAll, 0, PrepareMessageConsoleMsg("El cupo ha sido completado.", FontTypeNames.FONTTYPE_INFOBOLD))
  147.    
  148.         For Blue = 1 To .Quotas / 2 Step 2
  149.        
  150.             .Teams(1).UsersInTeam(Blue) = .UserIndex(Blue).ID
  151.             Call WriteConsoleMsg(.UserIndex(Blue).ID, "Ahora perteneces al equipo azul.", FontTypeNames.FONTTYPE_INFOBOLD)
  152.             Call WarpUserChar(.UserIndex(Blue).ID, MAP_EVENT, .Teams(1).X, .Teams(1).Y, True)
  153.            
  154.         Next Blue
  155.        
  156.         For Red = 1 To .Quotas / 2 Step 2
  157.        
  158.             .Teams(2).UsersInTeam(Red) = .UserIndex(Red).ID
  159.             Call WriteConsoleMsg(.UserIndex(Red).ID, "Ahora perteneces al equipo rojo.", FontTypeNames.FONTTYPE_INFOBOLD)
  160.             Call WarpUserChar(.UserIndex(Red).ID, MAP_EVENT, .Teams(2).X, .Teams(2).Y, True)
  161.            
  162.         Next Red
  163.        
  164.         .Delegates(1) = .Teams(1).UsersInTeam(RandomNumber(1, UBound(.Teams(1).UsersInTeam)))
  165.         .Delegates(2) = .Teams(2).UsersInTeam(RandomNumber(1, UBound(.Teams(2).UsersInTeam)))
  166.        
  167.         Call WarpUserChar(.Delegates(1), MAP_EVENT, .Teams(1).Delegate_X, .Teams(1).Delegate_X, False)
  168.         Call WarpUserChar(.Delegates(2), MAP_EVENT, .Teams(2).Delegate_X, .Teams(2).Delegate_X, False)
  169.        
  170.     End With
  171.  
  172. End Sub
  173.  
  174. Private Sub Enter_Wait(ByVal ID As Integer)
  175.  
  176.     '@@ Los mando a la sala de espera.
  177.    '@@ Les marco que están en evento.
  178.  
  179.     Call WarpUserChar(ID, 1, 50, 50, True)
  180.     UserList(ID).flags.Delegate = 1
  181.     Call WriteConsoleMsg(ID, "Has ingresado al evento, eres el participante Nº" & EventDelegate.UsersEvent, FontTypeNames.FONTTYPE_INFOBOLD)
  182.  
  183. End Sub
  184.  
  185. Private Function Can_Event(ByVal ID As Integer) As Boolean
  186.  
  187.     '@@ Compruebo si se puede armar evento.
  188.  
  189.     Can_Event = False
  190.  
  191.     If Not EsGM(ID) Then
  192.         Call WriteConsoleMsg(ID, "Tienes que ser GM para realizar el evento.", FontTypeNames.FONTTYPE_INFOBOLD)
  193.         Exit Function
  194.     End If
  195.    
  196.     With EventDelegate
  197.    
  198.         If .EventDelegate = True Then
  199.             Call WriteConsoleMsg(ID, "Ya hay un torneo en curso. Espera a que ese termine.", FontTypeNames.FONTTYPE_INFOBOLD)
  200.             Exit Function
  201.         End If
  202.        
  203.         If .Quotas < 3 Then Exit Function
  204.    
  205.     End With
  206.    
  207.     Can_Event = True
  208.    
  209. End Function
  210.  
  211. Private Function Can_EnterEvent(ByVal ID As Integer) As Boolean
  212.  
  213.     '@@ Compruebo si puede entrar al evento
  214.    
  215.     Can_EnterEvent = False
  216.  
  217.     With UserList(ID)
  218.  
  219.         If .Stats.ELV < EventDelegate.Level Then Exit Function
  220.         If EventDelegate.EventDelegate = False Then Exit Function
  221.         If .flags.Delegate = 1 Then Exit Function
  222.         If .Stats.GLD < EventDelegate.Requirement Then Exit Function
  223.         If EventDelegate.UsersEvent = EventDelegate.Quotas Then Exit Function
  224.         If .flags.Muerto = 1 Then Exit Function
  225.        
  226.     End With
  227.    
  228.      Can_EnterEvent = True
  229.  
  230. End Function
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement