Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Option Explicit
- Private Type tUsers
- UI As Integer
- AnteriorPos As WorldPos
- End Type
- Private Type tClan
- GuildName As String
- Users(1 To 5) As tUsers
- QuedanVivos As Byte
- End Type
- Private Ingresaron As Byte
- Private Modalidad As Byte
- Private Esperando As Byte
- Private TorneoClan(1 To 2) As tClan
- Public Sub EntrarCvC(ByVal UserIndex As Integer, ByVal Cupos As Byte)
- If Cupos < 2 Or Cupos > 6 Then Cupos = Modalidad
- With UserList(UserIndex)
- If .GuildIndex < 1 Then
- Call WriteConsoleMsg(UserIndex, "No perteneces a ningún clan.", FontTypeNames.FONTTYPE_INFO)
- Exit Sub
- End If
- If guilds(.GuildIndex).PuntosClan < 4000 Then
- Call WriteConsoleMsg(UserIndex, "No tienes suficiente rango de clan.", FontTypeNames.FONTTYPE_INFO)
- Exit Sub
- End If
- Dim GuildName As String, SlotLibre As Integer
- GuildName = guilds(.GuildIndex).GuildName
- If LenB(GuildName) < 1 Then Exit Sub
- Select Case Esperando
- Case 0
- Call LimpiarCvC
- Modalidad = Cupos
- Ingresaron = 1
- Esperando = 1
- TorneoClan(1).Users(1).UI = UserIndex
- TorneoClan(1).Users(1).AnteriorPos = .pos
- TorneoClan(1).QuedanVivos = Modalidad
- TorneoClan(1).GuildName = GuildName
- Call WriteConsoleMsg(UserIndex, "Has creado un torneo clan vs clan.", FontTypeNames.FONTTYPE_INFO)
- 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))
- Case 1
- If Cupos <> Modalidad Then
- Call WriteConsoleMsg(UserIndex, "El duelo es de " & Modalidad & " participantes. Debes escribir /DUELOCLAN " & Modalidad, FontTypeNames.FONTTYPE_INFO)
- Exit Sub
- End If
- Dim ID As Byte
- ID = IIf(TorneoClan(1).GuildName <> GuildName, 2, 1)
- '++ Para que no entre 2 veces
- If DameSlotUserIndex(ID, UserIndex) > 0 Then
- Call WriteConsoleMsg(UserIndex, "Ya estás apuntado.", FontTypeNames.FONTTYPE_INFO)
- Exit Sub
- End If
- '++ Si el que entra es distinto del primero del clan 2
- If ID > 1 Then
- If TorneoClan(ID).Users(1).UI > 0 Then
- If guilds(UserList(TorneoClan(ID).Users(1).UI).GuildIndex).GuildName <> GuildName Then
- Call WriteConsoleMsg(UserIndex, "Tu clan no aceptó el desafio.", FontTypeNames.FONTTYPE_INFO)
- Exit Sub
- End If
- End If
- End If
- SlotLibre = DameSlotLibre(ID)
- If SlotLibre < 1 Then Exit Sub
- TorneoClan(ID).Users(SlotLibre).UI = UserIndex
- TorneoClan(ID).Users(SlotLibre).AnteriorPos = .pos
- Ingresaron = Ingresaron + 1
- Call WriteConsoleMsg(UserIndex, "Has ingresado al torneo clan vs clan.", FontTypeNames.FONTTYPE_INFO)
- If Ingresaron >= (Modalidad * 2) Then
- TorneoClan(2).GuildName = GuildName
- TorneoClan(2).QuedanVivos = Modalidad
- Call SendData(SendTarget.ToAll, 0, PrepareMessageConsoleMsg("El clan " & GuildName & " ha aceptado el desafío.", FontTypeNames.FONTTYPE_GUILD))
- Call IniciarCvC
- End If
- Case 2
- Call WriteConsoleMsg(UserIndex, "Ya hay un duelo disputandose: " & TorneoClan(1).GuildName & " vs " & TorneoClan(2).GuildName, FontTypeNames.FONTTYPE_INFO)
- End Select
- End With
- End Sub
- Private Sub IniciarCvC()
- Dim LoopC As Long
- For LoopC = 1 To Modalidad
- Call WarpUserCharX(TorneoClan(1).Users(LoopC).UI, 292, 53, 50 + LoopC, False)
- Call WarpUserCharX(TorneoClan(2).Users(LoopC).UI, 292, 70, 50 + LoopC, False)
- Next LoopC
- Esperando = 2
- End Sub
- Private Function DameSlotLibre(ByVal Index As Byte) As Byte
- Dim LoopC As Long
- For LoopC = 1 To Modalidad
- If TorneoClan(Index).Users(LoopC).UI < 1 Then
- DameSlotLibre = LoopC
- Exit Function
- End If
- Next LoopC
- End Function
- Private Function DameSlotUserIndex(ByVal Index As Byte, ByVal UserIndex As Integer) As Byte
- Dim LoopC As Long
- For LoopC = 1 To Modalidad
- If TorneoClan(Index).Users(LoopC).UI = UserIndex Then
- DameSlotUserIndex = LoopC
- Exit Function
- End If
- Next LoopC
- End Function
- Public Sub Desconecta_Muere_CvC(ByVal UserIndex As Integer)
- If Esperando < 1 Then Exit Sub
- With UserList(UserIndex)
- If .GuildIndex < 1 Then Exit Sub
- If Ingresaron < 2 Then
- If TorneoClan(1).Users(1).UI = UserIndex Then
- Call SendData(SendTarget.ToAll, 0, PrepareMessageConsoleMsg("El duelo clan de " & .Name & " se ha cancelado!", FontTypeNames.FONTTYPE_GUILD))
- Call LimpiarCvC
- End If
- Else
- Dim LoopC As Long, LoopX As Long
- For LoopX = 1 To 2
- For LoopC = 1 To Modalidad
- If TorneoClan(LoopX).Users(LoopC).UI = UserIndex Then
- If Esperando = 2 Then
- TorneoClan(LoopX).QuedanVivos = TorneoClan(LoopX).QuedanVivos - 1
- If TorneoClan(LoopX).QuedanVivos < 1 Then
- Dim WinnerIndex As Byte, Msj As String
- WinnerIndex = IIf(LoopC > 1, 2, 1)
- Select Case TorneoClan(WinnerIndex).QuedanVivos
- Case Is <= 1
- Msj = "ganado un duelo muy igualado contra el clan "
- Case 2
- Msj = "obtenido una gran victoria en su duelo contra el clan "
- Case 3
- Msj = "arrasado en su duelo contra el clan "
- Case 4
- Msj = "dado una tremenda paliza en su duelo al clan "
- Case 5
- Msj = "destrozado sin esfuerzo al clan "
- Case 6
- Msj = "aniquilado y humillado al clan "
- End Select
- Call SendData(SendTarget.ToAll, 0, PrepareMessageConsoleMsg("El clan " & TorneoClan(WinnerIndex).GuildName & " ha " & Msj & TorneoClan(LoopX).GuildName & "!!", FontTypeNames.FONTTYPE_GUILD))
- Call WinnersCvC
- Exit Sub
- Else
- Call SendData(SendTarget.toMap, 296, PrepareMessageConsoleMsg(.Name & " ha caido en el clan vs clan!!", FontTypeNames.FONTTYPE_GUILD))
- Exit Sub
- End If
- Else
- Ingresaron = Ingresaron - 1
- TorneoClan(LoopX).Users(LoopC).UI = 0
- End If
- End If
- Next LoopC
- Next LoopX
- End If
- End With
- End Sub
- Private Sub LimpiarCvC()
- Erase TorneoClan()
- Modalidad = 0
- Ingresaron = 0
- Esperando = 0
- End Sub
- Private Sub WinnersCvC()
- Dim LoopC As Long, LoopX As Long, N As Integer
- For LoopX = 1 To 2
- For LoopC = 1 To Modalidad
- N = TorneoClan(LoopX).Users(LoopC).UI
- If N > 0 Then
- With UserList(N)
- 'Conexion activa?
- If .ConnID <> -1 Then
- '¿User valido?
- If .ConnIDValida And .flags.UserLogged Then
- If .flags.Muerto Then Call RevivirUsuario(N)
- With TorneoClan(LoopX).Users(LoopC).AnteriorPos
- Call WarpUserCharX(N, .Map, .X, .Y, False)
- End With
- End If
- End If
- End With
- End If
- Next LoopC
- Next LoopX
- Call LimpiarCvC
- End Sub
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement