Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Option Explicit
- '@@@ AUTOR: LUCIANO
- '@@@ EVENTO: DELEGADO
- Private Type tTeams
- Delegate As Integer
- UsersInTeam() As Integer
- WinPoints As Byte
- DeathTeam As Byte
- WinRounds As Byte
- Delegate_X As Byte
- Delegate_Y As Byte
- X As Byte
- Y As Byte
- End Type
- Private Type tUserEvent
- ID As Integer
- LastPosition As WorldPos
- End Type
- Private Type tEventDelegate
- Teams(1 To 2) As tTeams
- UsersEvent As Byte
- UserIndex() As tUserEvent
- EventDelegate As Boolean
- Points As Byte
- Rounds As Byte
- Requirement As Long
- Prize As Long
- Quotas As Byte
- Level As Byte
- Countdown As Byte
- End Type
- Private Const MAP_EVENT As Integer = 1
- Private Const POS_DEATH_X As Byte = 60
- Private Const POS_DEATH_Y As Byte = 60
- Private EventDelegate As tEventDelegate
- '_
- ''
- '
- Public Sub Load_Coordinates()
- '@@ Cargamos las coordenas de los equipos y la del delegado.
- '@@ Cargado desde el sub main()
- With EventDelegate
- '@@ EQUIPOS:
- .Teams(1).X = 57
- .Teams(1).Y = 46
- .Teams(2).X = 59
- .Teams(2).Y = 46
- '@@ DELEGADOS:
- .Teams(1).Delegate_X = 61
- .Teams(1).Delegate_Y = 46
- .Teams(2).Delegate_X = 55
- .Teams(2).Delegate_Y = 46
- End With
- End Sub
- ''
- '
- Public Sub Start_Event(ByVal UserIndex As Integer, _
- ByVal Quotas As Byte, _
- ByVal Prize As Long, _
- ByVal Requirement_Gold As Long, _
- ByVal Rounds As Byte, _
- ByVal Points As Byte, _
- ByVal Level As Byte)
- '@@ Inicio el evento.
- '@@ Paso requerimientos
- '@@ Compruebo si se puede armar torneo.
- '@@ Aviso por consola
- With EventDelegate
- If Can_Event(UserIndex) = False Then Exit Sub
- If Quotas < 3 Then Quotas = 3
- ReDim .Teams(1).UsersInTeam(1 To Quotas) As Integer
- ReDim .Teams(2).UsersInTeam(1 To Quotas) As Integer
- .Quotas = Quotas * 2
- .Prize = Prize
- .Points = Points
- .Requirement = Requirement_Gold
- .Rounds = Rounds
- .EventDelegate = True
- .Level = Level
- .UsersEvent = 0
- ReDim .UserIndex(1 To .Quotas) As tUserEvent
- Call SendData(SendTarget.ToAll, 0, PrepareMessageConsoleMsg("Evento Delegado> Iniciado", FontTypeNames.FONTTYPE_GUILD))
- End With
- End Sub
- ''
- '
- Public Sub Enter_Event(ByVal UserIndex As Integer)
- '@@ Participan al evento
- '@@ Los llevo a la sala de espera
- '@@ Sumo la cantidad de usuarios en evento.
- '@@ Guardo la ID del usuario.
- '@@ Guardo la posición del usuario.
- '@@ Le saco el oro.
- If Can_EnterEvent(UserIndex) = False Then Exit Sub
- With EventDelegate
- .UsersEvent = .UsersEvent + 1
- .UserIndex(.UsersEvent).ID = UserIndex
- .UserIndex(.UsersEvent).LastPosition = UserList(UserIndex).Pos
- UserList(UserIndex).Stats.GLD = UserList(UserIndex).Stats.GLD - .Requirement
- Call Enter_Wait(UserIndex)
- Call WriteUpdateGold(UserIndex)
- If .UsersEvent = .Quotas Then _
- Call Enter_Fight
- End With
- End Sub
- ''
- '
- Private Sub Enter_Fight()
- '@@ Aviso que se completa el cupo.
- '@@ Inicio la cuenta regresiva.
- With EventDelegate
- Call SendData(SendTarget.ToAll, 0, PrepareMessageConsoleMsg("El cupo ha sido completado.", FontTypeNames.FONTTYPE_INFOBOLD))
- '@@ Defino los equipos.
- '@@ También se define el delegado.
- Call DefineTeam(1)
- Call DefineTeam(2)
- '@@ Los llevo a la arena.
- '@@ También llevo al lugar correspondiente al delegado.
- Call WarpTeam(1, True)
- Call WarpTeam(2, True)
- '@@ Para iniciar la cuenta regresiva.
- .Countdown = 15
- End With
- End Sub
- ''
- '
- Private Sub Enter_Wait(ByVal ID As Integer)
- '@@ Los mando a la sala de espera.
- '@@ Les marco que están en evento.
- '@@ Les pongo el flag de evento.
- Call WarpUserChar(ID, 1, 50, 50, True)
- UserList(ID).flags.EventDelegate = 1
- Call WriteConsoleMsg(ID, "Has ingresado al evento, eres el participante Nº" & EventDelegate.UsersEvent, FontTypeNames.FONTTYPE_INFOBOLD)
- End Sub
- ''
- '
- Private Function Can_Event(ByVal ID As Integer) As Boolean
- '@@ Compruebo si se puede armar evento.
- Can_Event = False
- If Not EsGM(ID) Then
- Call WriteConsoleMsg(ID, "Tienes que ser GM para realizar el evento.", FontTypeNames.FONTTYPE_INFOBOLD)
- Exit Function
- End If
- With EventDelegate
- If .EventDelegate = True Then
- Call WriteConsoleMsg(ID, "Ya hay un torneo en curso. Espera a que ese termine.", FontTypeNames.FONTTYPE_INFOBOLD)
- Exit Function
- End If
- ' If .Quotas < 3 * 2 Then Exit Function
- End With
- Can_Event = True
- End Function
- ''
- '
- Private Function Can_EnterEvent(ByVal ID As Integer) As Boolean
- '@@ Compruebo si puede entrar al evento
- Can_EnterEvent = False
- With UserList(ID)
- If .Stats.ELV < EventDelegate.Level Then Exit Function
- If EventDelegate.EventDelegate = False Then Exit Function
- If .flags.Delegate = 1 Then Exit Function
- If .Stats.GLD < EventDelegate.Requirement Then Exit Function
- If EventDelegate.UsersEvent = EventDelegate.Quotas Then Exit Function
- If .flags.Muerto = 1 Then Exit Function
- End With
- Can_EnterEvent = True
- End Function
- ''
- '
- Public Sub Countdown_Event()
- '@@ Cuenta regresiva.
- '@@ Manejada desde el pasarsegundo()
- With EventDelegate
- If .Countdown > 0 Then
- .Countdown = .Countdown - 1
- Select Case .Countdown
- Case 15
- Call SendData(SendTarget.ToAll, 0, PrepareMessageConsoleMsg("Delegado» CONTEO» " & .Countdown, FontTypeNames.FONTTYPE_INFOBOLD))
- Case 10
- Call SendData(SendTarget.ToAll, 0, PrepareMessageConsoleMsg("Delegado» CONTEO» " & .Countdown, FontTypeNames.FONTTYPE_INFOBOLD))
- Case 5
- Call SendData(SendTarget.ToAll, 0, PrepareMessageConsoleMsg("Delegado» CONTEO» " & .Countdown, FontTypeNames.FONTTYPE_INFOBOLD))
- Case 4
- Call SendData(SendTarget.ToAll, 0, PrepareMessageConsoleMsg("Delegado» CONTEO» " & .Countdown, FontTypeNames.FONTTYPE_INFOBOLD))
- Case 3
- Call SendData(SendTarget.ToAll, 0, PrepareMessageConsoleMsg("Delegado» CONTEO» " & .Countdown, FontTypeNames.FONTTYPE_INFOBOLD))
- Case 2
- Call SendData(SendTarget.ToAll, 0, PrepareMessageConsoleMsg("Delegado» CONTEO» " & .Countdown, FontTypeNames.FONTTYPE_INFOBOLD))
- Case 1
- Call SendData(SendTarget.ToAll, 0, PrepareMessageConsoleMsg("Delegado» CONTEO» " & .Countdown, FontTypeNames.FONTTYPE_INFOBOLD))
- Case 0
- Call SendData(SendTarget.ToAll, 0, PrepareMessageConsoleMsg("Delegado» PELEEN!", FontTypeNames.FONTTYPE_FIGHT))
- End Select
- End If
- End With
- End Sub
- ''
- '
- Public Function All_Death(ByVal Team As Byte) As Boolean
- '@@ Chequeo si todos murieron.
- All_Death = False
- If EventDelegate.Teams(Team).DeathTeam >= UBound(EventDelegate.Teams(Team).UsersInTeam()) Then Exit Function
- All_Death = True
- End Function
- ''
- '
- Public Function Return_Team(ByVal UserID As Integer) As Byte
- '@@ Retorna en que equipo está el usuario pasado por parametro.
- Dim LoopC As Long
- Dim LoopX As Long
- For LoopC = 1 To 2
- For LoopX = 1 To EventDelegate.UsersEvent / 2
- If EventDelegate.Teams(LoopC).UsersInTeam(LoopX) = UserID Then
- Return_Team = LoopC
- Exit Function
- End If
- Next LoopX
- Next LoopC
- End Function
- ''
- '
- Public Sub Death_User(ByVal ID As Integer)
- '@@ Si muere un usuario lo mando hacia arriba de la arena para que no estorbe.
- '@@ Veo en que equipo está y chequeo si ya murieron todos.
- '@@ Si mueren todos veo quien ganó el round y se los sumo.
- Dim Team As Byte
- Dim TeamW As Byte
- Call WarpUserChar(ID, MAP_EVENT, POS_DEATH_X, POS_DEATH_Y, True)
- Team = Return_Team(ID)
- If All_Death(Team) = True Then
- If Team = 1 Then
- TeamW = 2
- Else
- TeamW = 1
- End If
- Call WinRound(TeamW)
- End If
- End Sub
- ''
- '
- Private Sub WinRound(ByVal Team As Byte)
- '@@ Les subo un round ganado al team ganador.
- '@@ Si ganaron lo suficiente le sumo un punto.
- With EventDelegate
- .Teams(Team).WinRounds = .Teams(Team).WinRounds + 1
- If .Teams(Team).WinRounds = .Rounds Then _
- Call WinPoint(Team)
- End With
- End Sub
- ''
- '
- Private Sub WinPoint(ByVal Team As Byte)
- '@@ Les subo un punto.
- '@@ Llevo al equipo que perdió el combate a su antigua posición.
- '@@ Si ganaron lo suficiente ganan el evento :D
- Dim TeamL As Byte
- With EventDelegate
- If Team = 1 Then
- TeamL = 2
- Else
- TeamL = 1
- End If
- Call WarpTeam(TeamL, False)
- .Teams(Team).WinPoints = .Teams(Team).WinPoints + 1
- If .Teams(Team).WinPoints = .Points Then _
- Call WinEvent(Team)
- End With
- End Sub
- ''
- '
- Private Sub WinEvent(ByVal Team As Byte)
- '@@ Si ganaron el evento reparto el premio.
- '@@ Los llevo a ullathorpe.
- '@@ Aviso quién ganó el evento.
- Dim LoopC As Long
- With EventDelegate
- For LoopC = 1 To .Quotas / 2
- UserList(.Teams(Team).UsersInTeam(LoopC)).Stats.GLD = UserList(.Teams(Team).UsersInTeam(LoopC)).Stats.GLD + .Prize
- Call WriteUpdateGold(.Teams(Team).UsersInTeam(LoopC))
- Next LoopC
- Call WarpTeam(Team, False)
- Call SendData(SendTarget.ToAll, 0, PrepareMessageConsoleMsg("Delegado» Ganador del evento el equipo del delegado " & UserList(.Teams(Team).Delegate).name, FontTypeNames.FONTTYPE_FIGHT))
- End With
- End Sub
- ''
- '
- Private Sub DefineTeam(ByVal Team As Byte)
- '@@ Defino el equipo azul.
- '@@ Defino al delegado con azar.
- '@@ Le asigno el flag al delegado.
- '@@ Le aviso que se convirtió en delegado.
- '@@ Les informo a que equipo pertenecen.
- Dim LoopC As Long
- Dim TeamColor As String
- If Team = 1 Then
- TeamColor = "Azul!"
- Else
- TeamColor = "Rojo!"
- End If
- With EventDelegate
- For LoopC = 1 To .Quotas / 2
- .Teams(Team).UsersInTeam(LoopC) = .UserIndex(Users).ID
- Call WriteConsoleMsg(.Teams(Team).UsersInTeam(LoopC), "Ahora perteneces al equipo " & TeamColor, FontTypeNames.FONTTYPE_INFOBOLD)
- Next LoopC
- .Teams(Team).Delegate = .Teams(Team).UsersInTeam(RandomNumber(1, UBound(.Teams(Team).UsersInTeam)))
- UserList(.Teams(Team).Delegate).flags.EventDelegate = 1
- Call WriteConsoleMsg(.Teams(Team).Delegate, "Eres delegado del equipo " & TeamColor, FontTypeNames.FONTTYPE_INFOBOLD)
- End With
- End Sub
- ''
- '
- Private Sub WarpTeam(ByVal Team As Byte, ByVal toEvent As Boolean)
- ' Si es al evento mando el team a las arenas.
- ' Si no es al evento los mando a su antigua posición.
- ' Mando al delegado al área correspondiente.
- Dim LoopC As Long
- With EventDelegate
- For LoopC = 1 To .Quotas / 2
- If toEvent = False Then
- 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)
- Else
- Call WarpUserChar(.Teams(Team).UsersInTeam(LoopC), MAP_EVENT, .Teams(Team).X, .Teams(Team).Y, True)
- Call WarpUserChar(.Teams(Team).Delegate, MAP_EVENT, .Teams(Team).Delegate_X, .Teams(Team).Delegate_Y, True)
- End If
- Next LoopC
- End With
- End Sub
- ''
- '
- Private Sub Remove_Team(ByVal Team As Byte)
- Dim LoopC As Long
- With EventDelegate
- For LoopC = 1 To .Quotas / 2
- '@@ Sacamos al delegado.
- UserList(.UserIndex(LoopC).ID).flags.Delegate = 0
- '@@ Sacamos del evento.
- UserList(.UserIndex(LoopC).ID).flags.EventDelegate = 0
- '@@ Lo sacamos del mapa.
- Call WarpTeam(Team, False)
- '@@ Sacamos a los usuarios del team.
- .Teams(Team).UsersInTeam(LoopC) = 0
- Next LoopC
- End With
- With EventDelegate.Teams(Team)
- .DeathTeam = 0
- .Delegate = 0
- .WinPoints = 0
- .WinRounds = 0
- End With
- End Sub
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement