Advertisement
Guest User

Untitled

a guest
Oct 1st, 2019
121
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Option Explicit
  2.  
  3. Private Type tUsers
  4.     UI As Integer
  5.     AnteriorPos As WorldPos
  6. End Type
  7.  
  8. Private Type tClan
  9.     GuildName As String
  10.     Users(1 To 5) As tUsers
  11.     QuedanVivos As Byte
  12. End Type
  13.  
  14. Private Ingresaron As Byte
  15. Private Modalidad As Byte
  16. Private Esperando As Byte
  17.  
  18. Private TorneoClan(1 To 2) As tClan
  19.  
  20. Public Sub EntrarCvC(ByVal UserIndex As Integer, ByVal Cupos As Byte)
  21.  
  22.     If Cupos < 2 Or Cupos > 6 Then Cupos = Modalidad
  23.  
  24.     With UserList(UserIndex)
  25.  
  26.         If .GuildIndex < 1 Then
  27.             Call WriteConsoleMsg(UserIndex, "No perteneces a ningún clan.", FontTypeNames.FONTTYPE_INFO)
  28.             Exit Sub
  29.         End If
  30.  
  31.         If guilds(.GuildIndex).PuntosClan < 4000 Then
  32.             Call WriteConsoleMsg(UserIndex, "No tienes suficiente rango de clan.", FontTypeNames.FONTTYPE_INFO)
  33.             Exit Sub
  34.         End If
  35.  
  36.         Dim GuildName As String, SlotLibre As Integer
  37.         GuildName = guilds(.GuildIndex).GuildName
  38.  
  39.         If LenB(GuildName) < 1 Then Exit Sub
  40.  
  41.         Select Case Esperando
  42.  
  43.             Case 0
  44.  
  45.                 Call LimpiarCvC
  46.  
  47.                 Modalidad = Cupos
  48.                 Ingresaron = 1
  49.                 Esperando = 1
  50.  
  51.                 TorneoClan(1).Users(1).UI = UserIndex
  52.                 TorneoClan(1).Users(1).AnteriorPos = .pos
  53.  
  54.                 TorneoClan(1).QuedanVivos = Modalidad
  55.                 TorneoClan(1).GuildName = GuildName
  56.  
  57.                 Call WriteConsoleMsg(UserIndex, "Has creado un torneo clan vs clan.", FontTypeNames.FONTTYPE_INFO)
  58.                 Call SendData(SendTarget.ToAll, 0, PrepareMessageConsoleMsg("El clan " & GuildName & " busca rival. Duelo de " & Modalidad & " participantes. Si tu clan quiere aceptar el desafío escribe /DUELOCLAN " & Modalidad, FontTypeNames.FONTTYPE_GUILD))
  59.  
  60.             Case 1
  61.  
  62.                 If Cupos <> Modalidad Then
  63.                     Call WriteConsoleMsg(UserIndex, "El duelo es de " & Modalidad & " participantes. Debes escribir /DUELOCLAN " & Modalidad, FontTypeNames.FONTTYPE_INFO)
  64.                     Exit Sub
  65.                 End If
  66.  
  67.                 Dim ID As Byte
  68.                 ID = IIf(TorneoClan(1).GuildName <> GuildName, 2, 1)
  69.  
  70.                 '++ Para que no entre 2 veces
  71.                If DameSlotUserIndex(ID, UserIndex) > 0 Then
  72.                     Call WriteConsoleMsg(UserIndex, "Ya estás apuntado.", FontTypeNames.FONTTYPE_INFO)
  73.                     Exit Sub
  74.                 End If
  75.  
  76.                 '++ Si el que entra es distinto del primero del clan 2
  77.                If ID > 1 Then
  78.                     If TorneoClan(ID).Users(1).UI > 0 Then
  79.                         If guilds(UserList(TorneoClan(ID).Users(1).UI).GuildIndex).GuildName <> GuildName Then
  80.                             Call WriteConsoleMsg(UserIndex, "Tu clan no aceptó el desafio.", FontTypeNames.FONTTYPE_INFO)
  81.                             Exit Sub
  82.                         End If
  83.                     End If
  84.                 End If
  85.  
  86.                 SlotLibre = DameSlotLibre(ID)
  87.                 If SlotLibre < 1 Then Exit Sub
  88.  
  89.                 TorneoClan(ID).Users(SlotLibre).UI = UserIndex
  90.                 TorneoClan(ID).Users(SlotLibre).AnteriorPos = .pos
  91.  
  92.                 Ingresaron = Ingresaron + 1
  93.                 Call WriteConsoleMsg(UserIndex, "Has ingresado al torneo clan vs clan.", FontTypeNames.FONTTYPE_INFO)
  94.  
  95.                 If Ingresaron >= (Modalidad * 2) Then
  96.                     TorneoClan(2).GuildName = GuildName
  97.                     TorneoClan(2).QuedanVivos = Modalidad
  98.                     Call SendData(SendTarget.ToAll, 0, PrepareMessageConsoleMsg("El clan " & GuildName & " ha aceptado el desafío.", FontTypeNames.FONTTYPE_GUILD))
  99.                     Call IniciarCvC
  100.                 End If
  101.  
  102.             Case 2
  103.  
  104.                 Call WriteConsoleMsg(UserIndex, "Ya hay un duelo disputandose: " & TorneoClan(1).GuildName & " vs " & TorneoClan(2).GuildName, FontTypeNames.FONTTYPE_INFO)
  105.  
  106.         End Select
  107.  
  108.     End With
  109.  
  110. End Sub
  111.  
  112. Private Sub IniciarCvC()
  113.  
  114.     Dim LoopC As Long
  115.  
  116.     For LoopC = 1 To Modalidad
  117.         Call WarpUserCharX(TorneoClan(1).Users(LoopC).UI, 292, 53, 50 + LoopC, False)
  118.         Call WarpUserCharX(TorneoClan(2).Users(LoopC).UI, 292, 70, 50 + LoopC, False)
  119.     Next LoopC
  120.  
  121.     Esperando = 2
  122.  
  123. End Sub
  124.  
  125. Private Function DameSlotLibre(ByVal Index As Byte) As Byte
  126.  
  127.     Dim LoopC As Long
  128.  
  129.     For LoopC = 1 To Modalidad
  130.         If TorneoClan(Index).Users(LoopC).UI < 1 Then
  131.             DameSlotLibre = LoopC
  132.             Exit Function
  133.         End If
  134.     Next LoopC
  135.  
  136. End Function
  137.  
  138. Private Function DameSlotUserIndex(ByVal Index As Byte, ByVal UserIndex As Integer) As Byte
  139.  
  140.     Dim LoopC As Long
  141.  
  142.     For LoopC = 1 To Modalidad
  143.         If TorneoClan(Index).Users(LoopC).UI = UserIndex Then
  144.             DameSlotUserIndex = LoopC
  145.             Exit Function
  146.         End If
  147.     Next LoopC
  148.  
  149. End Function
  150.  
  151. Public Sub Desconecta_Muere_CvC(ByVal UserIndex As Integer)
  152.  
  153.     If Esperando < 1 Then Exit Sub
  154.  
  155.     With UserList(UserIndex)
  156.         If .GuildIndex < 1 Then Exit Sub
  157.  
  158.         If Ingresaron < 2 Then
  159.             If TorneoClan(1).Users(1).UI = UserIndex Then
  160.                 Call SendData(SendTarget.ToAll, 0, PrepareMessageConsoleMsg("El duelo clan de " & .Name & " se ha cancelado!", FontTypeNames.FONTTYPE_GUILD))
  161.                 Call LimpiarCvC
  162.             End If
  163.         Else
  164.  
  165.             Dim LoopC As Long, LoopX As Long
  166.  
  167.             For LoopX = 1 To 2
  168.                 For LoopC = 1 To Modalidad
  169.                     If TorneoClan(LoopX).Users(LoopC).UI = UserIndex Then
  170.                         If Esperando = 2 Then
  171.                             TorneoClan(LoopX).QuedanVivos = TorneoClan(LoopX).QuedanVivos - 1
  172.  
  173.                             If TorneoClan(LoopX).QuedanVivos < 1 Then
  174.                                 Dim WinnerIndex As Byte, Msj As String
  175.                                 WinnerIndex = IIf(LoopC > 1, 2, 1)
  176.  
  177.                                 Select Case TorneoClan(WinnerIndex).QuedanVivos
  178.                                     Case Is <= 1
  179.                                         Msj = "ganado un duelo muy igualado contra el clan "
  180.                                     Case 2
  181.                                         Msj = "obtenido una gran victoria en su duelo contra el clan "
  182.                                     Case 3
  183.                                         Msj = "arrasado en su duelo contra el clan "
  184.                                     Case 4
  185.                                         Msj = "dado una tremenda paliza en su duelo al clan "
  186.                                     Case 5
  187.                                         Msj = "destrozado sin esfuerzo al clan "
  188.                                     Case 6
  189.                                         Msj = "aniquilado y humillado al clan "
  190.                                 End Select
  191.  
  192.                                 Call SendData(SendTarget.ToAll, 0, PrepareMessageConsoleMsg("El clan " & TorneoClan(WinnerIndex).GuildName & " ha " & Msj & TorneoClan(LoopX).GuildName & "!!", FontTypeNames.FONTTYPE_GUILD))
  193.                                 Call WinnersCvC
  194.                                 Exit Sub
  195.                             Else
  196.                                 Call SendData(SendTarget.toMap, 296, PrepareMessageConsoleMsg(.Name & " ha caido en el clan vs clan!!", FontTypeNames.FONTTYPE_GUILD))
  197.                                 Exit Sub
  198.                             End If
  199.                         Else
  200.                             Ingresaron = Ingresaron - 1
  201.                             TorneoClan(LoopX).Users(LoopC).UI = 0
  202.                         End If
  203.                     End If
  204.                 Next LoopC
  205.             Next LoopX
  206.  
  207.         End If
  208.  
  209.     End With
  210.  
  211. End Sub
  212.  
  213. Private Sub LimpiarCvC()
  214.  
  215.     Erase TorneoClan()
  216.  
  217.     Modalidad = 0
  218.     Ingresaron = 0
  219.     Esperando = 0
  220.  
  221. End Sub
  222.  
  223. Private Sub WinnersCvC()
  224.  
  225.     Dim LoopC As Long, LoopX As Long, N As Integer
  226.  
  227.     For LoopX = 1 To 2
  228.         For LoopC = 1 To Modalidad
  229.             N = TorneoClan(LoopX).Users(LoopC).UI
  230.             If N > 0 Then
  231.                 With UserList(N)
  232.                     'Conexion activa?
  233.                    If .ConnID <> -1 Then
  234.                         '¿User valido?
  235.                        If .ConnIDValida And .flags.UserLogged Then
  236.                             If .flags.Muerto Then Call RevivirUsuario(N)
  237.  
  238.                             With TorneoClan(LoopX).Users(LoopC).AnteriorPos
  239.                                 Call WarpUserCharX(N, .Map, .X, .Y, False)
  240.                             End With
  241.                         End If
  242.                     End If
  243.                 End With
  244.             End If
  245.         Next LoopC
  246.     Next LoopX
  247.  
  248.     Call LimpiarCvC
  249.  
  250. End Sub
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement