Advertisement
Luciano_fuentes

ff

Sep 12th, 2016
198
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.     Delegate            As Integer
  9.     UsersInTeam()       As Integer
  10.     WinPoints           As Byte
  11.     DeathTeam           As Byte
  12.     WinRounds           As Byte
  13.     Delegate_X          As Byte
  14.     Delegate_Y          As Byte
  15.     X                   As Byte
  16.     Y                   As Byte
  17.    
  18. End Type
  19.  
  20. Private Type tUserEvent
  21.  
  22.     ID                  As Integer
  23.     LastPosition        As WorldPos
  24.  
  25. End Type
  26.  
  27. Private Type tEventDelegate
  28.  
  29.     Teams(1 To 2)       As tTeams
  30.     UsersEvent          As Byte
  31.     UserIndex()         As tUserEvent
  32.     EventDelegate       As Boolean
  33.     Points              As Byte
  34.     Rounds              As Byte
  35.     Requirement         As Long
  36.     Prize               As Long
  37.     Quotas              As Byte
  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.  
  51. ''
  52. '
  53. Public Sub Load_Coordinates()
  54.  
  55.     '@@ Cargamos las coordenas de los equipos y la del delegado.
  56.    '@@ Cargado desde el sub main()
  57.    
  58.     With EventDelegate
  59.    
  60.         '@@ EQUIPOS:
  61.        .Teams(1).X = 57
  62.         .Teams(1).Y = 46
  63.        
  64.         .Teams(2).X = 59
  65.         .Teams(2).Y = 46
  66.        
  67.         '@@ DELEGADOS:
  68.        .Teams(1).Delegate_X = 61
  69.         .Teams(1).Delegate_Y = 46
  70.        
  71.         .Teams(2).Delegate_X = 55
  72.         .Teams(2).Delegate_Y = 46
  73.        
  74.     End With
  75. End Sub
  76. ''
  77. '
  78. Public Sub Start_Event(ByVal UserIndex As Integer, _
  79.                        ByVal Quotas As Byte, _
  80.                        ByVal Prize As Long, _
  81.                        ByVal Requirement_Gold As Long, _
  82.                        ByVal Rounds As Byte, _
  83.                        ByVal Points As Byte, _
  84.                        ByVal Level As Byte)
  85.                        
  86.     '@@ Inicio el evento.
  87.    '@@ Paso requerimientos
  88.    '@@ Compruebo si se puede armar torneo.
  89.    '@@ Aviso por consola
  90.  
  91.     With EventDelegate
  92.        
  93.         If Can_Event(UserIndex) = False Then Exit Sub
  94.        
  95.         If Quotas < 3 Then Quotas = 3
  96.        
  97.         ReDim .Teams(1).UsersInTeam(1 To Quotas) As Integer
  98.         ReDim .Teams(2).UsersInTeam(1 To Quotas) As Integer
  99.        
  100.         .Quotas = Quotas * 2
  101.         .Prize = Prize
  102.         .Points = Points
  103.        
  104.         .Requirement = Requirement_Gold
  105.         .Rounds = Rounds
  106.         .EventDelegate = True
  107.        
  108.         .Level = Level
  109.         .UsersEvent = 0
  110.        
  111.         ReDim .UserIndex(1 To .Quotas) As tUserEvent
  112.        
  113.         Call SendData(SendTarget.ToAll, 0, PrepareMessageConsoleMsg("Evento Delegado> Iniciado", FontTypeNames.FONTTYPE_GUILD))
  114.  
  115.     End With
  116.  
  117. End Sub
  118. ''
  119. '
  120. Public Sub Enter_Event(ByVal UserIndex As Integer)
  121.  
  122.     '@@ Participan al evento
  123.    '@@ Los llevo a la sala de espera
  124.    '@@ Sumo la cantidad de usuarios en evento.
  125.    '@@ Guardo la ID del usuario.
  126.    '@@ Guardo la posición del usuario.
  127.    '@@ Le saco el oro.
  128.  
  129.     If Can_EnterEvent(UserIndex) = False Then Exit Sub
  130.  
  131.     With EventDelegate
  132.        
  133.         .UsersEvent = .UsersEvent + 1
  134.    
  135.         .UserIndex(.UsersEvent).ID = UserIndex
  136.        
  137.         .UserIndex(.UsersEvent).LastPosition = UserList(UserIndex).Pos
  138.    
  139.         UserList(UserIndex).Stats.GLD = UserList(UserIndex).Stats.GLD - .Requirement
  140.    
  141.         Call Enter_Wait(UserIndex)
  142.         Call WriteUpdateGold(UserIndex)
  143.        
  144.         If .UsersEvent = .Quotas Then _
  145.             Call Enter_Fight
  146.    
  147.     End With
  148.  
  149. End Sub
  150. ''
  151. '
  152. Private Sub Enter_Fight()
  153.  
  154.     '@@ Aviso que se completa el cupo.
  155.    '@@ Inicio la cuenta regresiva.
  156.    
  157.     With EventDelegate
  158.    
  159.         Call SendData(SendTarget.ToAll, 0, PrepareMessageConsoleMsg("El cupo ha sido completado.", FontTypeNames.FONTTYPE_INFOBOLD))
  160.        
  161.         '@@ Defino los equipos.
  162.        '@@ También se define el delegado.
  163.        Call DefineTeam(1)
  164.         Call DefineTeam(2)
  165.        
  166.         '@@ Los llevo a la arena.
  167.        '@@ También llevo al lugar correspondiente al delegado.
  168.        Call WarpTeam(1, True)
  169.         Call WarpTeam(2, True)
  170.        
  171.         '@@ Para iniciar la cuenta regresiva.
  172.        .Countdown = 15
  173.        
  174.     End With
  175.  
  176. End Sub
  177. ''
  178. '
  179. Private Sub Enter_Wait(ByVal ID As Integer)
  180.  
  181.     '@@ Los mando a la sala de espera.
  182.    '@@ Les marco que están en evento.
  183.    '@@ Les pongo el flag de evento.
  184.    
  185.     Call WarpUserChar(ID, 1, 50, 50, True)
  186.    
  187.     UserList(ID).flags.EventDelegate = 1
  188.    
  189.     Call WriteConsoleMsg(ID, "Has ingresado al evento, eres el participante Nº" & EventDelegate.UsersEvent, FontTypeNames.FONTTYPE_INFOBOLD)
  190.  
  191. End Sub
  192. ''
  193. '
  194. Private Function Can_Event(ByVal ID As Integer) As Boolean
  195.  
  196.     '@@ Compruebo si se puede armar evento.
  197.  
  198.     Can_Event = False
  199.  
  200.     If Not EsGM(ID) Then
  201.         Call WriteConsoleMsg(ID, "Tienes que ser GM para realizar el evento.", FontTypeNames.FONTTYPE_INFOBOLD)
  202.         Exit Function
  203.     End If
  204.    
  205.     With EventDelegate
  206.    
  207.         If .EventDelegate = True Then
  208.             Call WriteConsoleMsg(ID, "Ya hay un torneo en curso. Espera a que ese termine.", FontTypeNames.FONTTYPE_INFOBOLD)
  209.             Exit Function
  210.         End If
  211.        
  212.        ' If .Quotas < 3 * 2 Then Exit Function
  213.    
  214.     End With
  215.    
  216.     Can_Event = True
  217.    
  218. End Function
  219. ''
  220. '
  221. Private Function Can_EnterEvent(ByVal ID As Integer) As Boolean
  222.  
  223.     '@@ Compruebo si puede entrar al evento
  224.    
  225.     Can_EnterEvent = False
  226.  
  227.     With UserList(ID)
  228.  
  229.         If .Stats.ELV < EventDelegate.Level Then Exit Function
  230.         If EventDelegate.EventDelegate = False Then Exit Function
  231.         If .flags.Delegate = 1 Then Exit Function
  232.         If .Stats.GLD < EventDelegate.Requirement Then Exit Function
  233.         If EventDelegate.UsersEvent = EventDelegate.Quotas Then Exit Function
  234.         If .flags.Muerto = 1 Then Exit Function
  235.        
  236.     End With
  237.    
  238.      Can_EnterEvent = True
  239.  
  240. End Function
  241. ''
  242. '
  243. Public Sub Countdown_Event()
  244.  
  245.     '@@ Cuenta regresiva.
  246.    '@@ Manejada desde el pasarsegundo()
  247.  
  248.     With EventDelegate
  249.  
  250.         If .Countdown > 0 Then
  251.    
  252.             .Countdown = .Countdown - 1
  253.    
  254.             Select Case .Countdown
  255.        
  256.                 Case 15
  257.                     Call SendData(SendTarget.ToAll, 0, PrepareMessageConsoleMsg("Delegado» CONTEO» " & .Countdown, FontTypeNames.FONTTYPE_INFOBOLD))
  258.        
  259.                 Case 10
  260.                     Call SendData(SendTarget.ToAll, 0, PrepareMessageConsoleMsg("Delegado» CONTEO» " & .Countdown, FontTypeNames.FONTTYPE_INFOBOLD))
  261.                
  262.                 Case 5
  263.                     Call SendData(SendTarget.ToAll, 0, PrepareMessageConsoleMsg("Delegado» CONTEO» " & .Countdown, FontTypeNames.FONTTYPE_INFOBOLD))
  264.                
  265.                 Case 4
  266.                     Call SendData(SendTarget.ToAll, 0, PrepareMessageConsoleMsg("Delegado» CONTEO» " & .Countdown, FontTypeNames.FONTTYPE_INFOBOLD))
  267.                
  268.                 Case 3
  269.                     Call SendData(SendTarget.ToAll, 0, PrepareMessageConsoleMsg("Delegado» CONTEO» " & .Countdown, FontTypeNames.FONTTYPE_INFOBOLD))
  270.                
  271.                 Case 2
  272.                     Call SendData(SendTarget.ToAll, 0, PrepareMessageConsoleMsg("Delegado» CONTEO» " & .Countdown, FontTypeNames.FONTTYPE_INFOBOLD))
  273.                
  274.                 Case 1
  275.                     Call SendData(SendTarget.ToAll, 0, PrepareMessageConsoleMsg("Delegado» CONTEO» " & .Countdown, FontTypeNames.FONTTYPE_INFOBOLD))
  276.                
  277.                 Case 0
  278.                     Call SendData(SendTarget.ToAll, 0, PrepareMessageConsoleMsg("Delegado» PELEEN!", FontTypeNames.FONTTYPE_FIGHT))
  279.        
  280.             End Select
  281.            
  282.         End If
  283.        
  284.     End With
  285.    
  286. End Sub
  287. ''
  288. '
  289. Public Function All_Death(ByVal Team As Byte) As Boolean
  290.  
  291.     '@@ Chequeo si todos murieron.
  292.  
  293.     All_Death = False
  294.    
  295.     If EventDelegate.Teams(Team).DeathTeam >= UBound(EventDelegate.Teams(Team).UsersInTeam()) Then Exit Function
  296.    
  297.     All_Death = True
  298.  
  299. End Function
  300. ''
  301. '
  302. Public Function Return_Team(ByVal UserID As Integer) As Byte
  303.  
  304.     '@@ Retorna en que equipo está el usuario pasado por parametro.
  305.  
  306.     Dim LoopC As Long
  307.     Dim LoopX As Long
  308.    
  309.     For LoopC = 1 To 2
  310.    
  311.         For LoopX = 1 To EventDelegate.UsersEvent / 2
  312.        
  313.             If EventDelegate.Teams(LoopC).UsersInTeam(LoopX) = UserID Then
  314.            
  315.                 Return_Team = LoopC
  316.                 Exit Function
  317.                
  318.             End If
  319.        
  320.         Next LoopX
  321.        
  322.     Next LoopC
  323.  
  324. End Function
  325. ''
  326. '
  327. Public Sub Death_User(ByVal ID As Integer)
  328.  
  329.     '@@ Si muere un usuario lo mando hacia arriba de la arena para que no estorbe.
  330.    '@@ Veo en que equipo está y chequeo si ya murieron todos.
  331.    '@@ Si mueren todos veo quien ganó el round y se los sumo.
  332.  
  333.     Dim Team As Byte
  334.     Dim TeamW As Byte
  335.  
  336.     Call WarpUserChar(ID, MAP_EVENT, POS_DEATH_X, POS_DEATH_Y, True)
  337.  
  338.     Team = Return_Team(ID)
  339.  
  340.     If All_Death(Team) = True Then
  341.    
  342.         If Team = 1 Then
  343.        
  344.             TeamW = 2
  345.            
  346.         Else
  347.        
  348.             TeamW = 1
  349.            
  350.         End If
  351.        
  352.         Call WinRound(TeamW)
  353.        
  354.     End If
  355.        
  356. End Sub
  357. ''
  358. '
  359. Private Sub WinRound(ByVal Team As Byte)
  360.  
  361.     '@@ Les subo un round ganado al team ganador.
  362.    '@@ Si ganaron lo suficiente le sumo un punto.
  363.  
  364.     With EventDelegate
  365.  
  366.         .Teams(Team).WinRounds = .Teams(Team).WinRounds + 1
  367.        
  368.         If .Teams(Team).WinRounds = .Rounds Then _
  369.             Call WinPoint(Team)
  370.    
  371.     End With
  372.    
  373. End Sub
  374. ''
  375. '
  376. Private Sub WinPoint(ByVal Team As Byte)
  377.  
  378.     '@@ Les subo un punto.
  379.    '@@ Llevo al equipo que perdió el combate a su antigua posición.
  380.    '@@ Si ganaron lo suficiente ganan el evento :D
  381.  
  382.         Dim TeamL As Byte
  383.  
  384.     With EventDelegate
  385.  
  386.         If Team = 1 Then
  387.             TeamL = 2
  388.         Else
  389.             TeamL = 1
  390.         End If
  391.        
  392.         Call WarpTeam(TeamL, False)
  393.        
  394.         .Teams(Team).WinPoints = .Teams(Team).WinPoints + 1
  395.        
  396.         If .Teams(Team).WinPoints = .Points Then _
  397.             Call WinEvent(Team)
  398.    
  399.     End With
  400.    
  401. End Sub
  402. ''
  403. '
  404. Private Sub WinEvent(ByVal Team As Byte)
  405.  
  406.     '@@ Si ganaron el evento reparto el premio.
  407.    '@@ Los llevo a ullathorpe.
  408.    '@@ Aviso quién ganó el evento.
  409.  
  410.     Dim LoopC As Long
  411.  
  412.     With EventDelegate
  413.    
  414.         For LoopC = 1 To .Quotas / 2
  415.    
  416.             UserList(.Teams(Team).UsersInTeam(LoopC)).Stats.GLD = UserList(.Teams(Team).UsersInTeam(LoopC)).Stats.GLD + .Prize
  417.    
  418.             Call WriteUpdateGold(.Teams(Team).UsersInTeam(LoopC))
  419.        
  420.         Next LoopC
  421.  
  422.         Call WarpTeam(Team, False)
  423.        
  424.         Call SendData(SendTarget.ToAll, 0, PrepareMessageConsoleMsg("Delegado» Ganador del evento el equipo del delegado " & UserList(.Teams(Team).Delegate).name, FontTypeNames.FONTTYPE_FIGHT))
  425.        
  426.     End With
  427.  
  428. End Sub
  429. ''
  430. '
  431. Private Sub DefineTeam(ByVal Team As Byte)
  432.    
  433.     '@@ Defino el equipo azul.
  434.    '@@ Defino al delegado con azar.
  435.    '@@ Le asigno el flag al delegado.
  436.    '@@ Le aviso que se convirtió en delegado.
  437.    '@@ Les informo a que equipo pertenecen.
  438.    
  439.     Dim LoopC As Long
  440.     Dim TeamColor As String
  441.    
  442.     If Team = 1 Then
  443.    
  444.         TeamColor = "Azul!"
  445.        
  446.     Else
  447.    
  448.         TeamColor = "Rojo!"
  449.        
  450.     End If
  451.  
  452.  
  453.     With EventDelegate
  454.  
  455.         For LoopC = 1 To .Quotas / 2
  456.            
  457.             .Teams(Team).UsersInTeam(LoopC) = .UserIndex(Users).ID
  458.             Call WriteConsoleMsg(.Teams(Team).UsersInTeam(LoopC), "Ahora perteneces al equipo " & TeamColor, FontTypeNames.FONTTYPE_INFOBOLD)
  459.            
  460.         Next LoopC
  461.    
  462.             .Teams(Team).Delegate = .Teams(Team).UsersInTeam(RandomNumber(1, UBound(.Teams(Team).UsersInTeam)))
  463.             UserList(.Teams(Team).Delegate).flags.EventDelegate = 1
  464.             Call WriteConsoleMsg(.Teams(Team).Delegate, "Eres delegado del equipo " & TeamColor, FontTypeNames.FONTTYPE_INFOBOLD)
  465.            
  466.     End With
  467.    
  468. End Sub
  469.  
  470. ''
  471. '
  472. Private Sub WarpTeam(ByVal Team As Byte, ByVal toEvent As Boolean)
  473.  
  474.     ' Si es al evento mando el team a las arenas.
  475.    ' Si no es al evento los mando a su antigua posición.
  476.    ' Mando al delegado al área correspondiente.
  477.  
  478.     Dim LoopC As Long
  479.  
  480.     With EventDelegate
  481.  
  482.         For LoopC = 1 To .Quotas / 2
  483.  
  484.             If toEvent = False Then
  485.    
  486.                 Call WarpUserChar(.Teams(Team).UsersInTeam(LoopC), .UserIndex(.Teams(Team).UsersInTeam(LoopC)).LastPosition.Map, .UserIndex(.Teams(Team).UsersInTeam(LoopC)).LastPosition.X, .UserIndex(.Teams(Team).UsersInTeam(LoopC)).LastPosition.Y, True)
  487.            
  488.             Else
  489.            
  490.                 Call WarpUserChar(.Teams(Team).UsersInTeam(LoopC), MAP_EVENT, .Teams(Team).X, .Teams(Team).Y, True)
  491.                
  492.                 Call WarpUserChar(.Teams(Team).Delegate, MAP_EVENT, .Teams(Team).Delegate_X, .Teams(Team).Delegate_Y, True)
  493.            
  494.             End If
  495.            
  496.         Next LoopC
  497.  
  498.     End With
  499.  
  500. End Sub
  501.  
  502. ''
  503. '
  504. Private Sub Remove_Team(ByVal Team As Byte)
  505.  
  506.     Dim LoopC As Long
  507.    
  508.     With EventDelegate
  509.  
  510.         For LoopC = 1 To .Quotas / 2
  511.        
  512.             '@@ Sacamos al delegado.
  513.            UserList(.UserIndex(LoopC).ID).flags.Delegate = 0
  514.             '@@ Sacamos del evento.
  515.            UserList(.UserIndex(LoopC).ID).flags.EventDelegate = 0
  516.             '@@ Lo sacamos del mapa.
  517.            Call WarpTeam(Team, False)
  518.             '@@ Sacamos a los usuarios del team.
  519.            .Teams(Team).UsersInTeam(LoopC) = 0
  520.  
  521.         Next LoopC
  522.  
  523.     End With
  524.    
  525.     With EventDelegate.Teams(Team)
  526.    
  527.         .DeathTeam = 0
  528.         .Delegate = 0
  529.         .WinPoints = 0
  530.         .WinRounds = 0
  531.    
  532.     End With
  533.  
  534. End Sub
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement