Advertisement
Guest User

Untitled

a guest
Apr 7th, 2020
284
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  
  2. Option Explicit
  3.  
  4. Public Enum tEventos
  5.     DeathMatch = 1
  6. End Enum
  7.  
  8. Private MAX_EVENTS As Byte
  9.  
  10. Private Type tUsers
  11.     UI As Integer
  12.     WinnerID As Integer
  13.     PreviousPos As WorldPos
  14. End Type
  15.  
  16. Private Type tEvent
  17.     Active As Boolean
  18.     Quotas As Byte
  19.     Entered As Byte
  20.     Inscription As Long
  21.     Prize As Long
  22.     EventStarted As Boolean
  23.     Users() As tUsers
  24.     EventName As String
  25.     MapEvent As Integer
  26. End Type
  27.  
  28. Private Events() As tEvent
  29.  
  30. Private Sub LoadEvents()
  31.  
  32.     Dim Leer As clsIniManager, LoopC As Long
  33.     Set Leer = New clsIniManager
  34.     Call Leer.Initialize(DatPath & "EVENTOS.DAT")
  35.  
  36.     MAX_EVENTS = CInt(Leer.GetValue("INIT", "EVENTOS"))
  37.  
  38.     If MAX_EVENTS > 0 Then
  39.         ReDim Events(1 To MAX_EVENTS) As tEvent
  40.  
  41.         For LoopC = 1 To MAX_EVENTS
  42.             With Events(LoopC)
  43.                 .EventName = CStr(Leer.GetValue("INIT", "EVENTO" & LoopC))
  44.                 .MapEvent = CInt(Leer.GetValue("INIT", "MAPA" & LoopC))
  45.             End With
  46.         Next LoopC
  47.     End If
  48.  
  49.     Set Leer = Nothing
  50.  
  51. End Sub
  52.  
  53. Public Sub CreateEvent(ByVal UI As Integer, ByVal NumEvent As Byte, ByVal Quotas As Byte, ByVal Inscription As Long, ByVal Prize As Long)
  54.  
  55.     If NumEvent < 1 Or NumEvent > MAX_EVENTS Then Exit Sub
  56.  
  57.     If Quotas > 60 Then Quotas = 60
  58.     If Quotas < 2 Then Quotas = 2
  59.     If Prize < 0 Then Prize = 0
  60.     If Inscription < 0 Then Inscription = 0
  61.  
  62.     With Events(NumEvent)
  63.         If .Active Then
  64.             Call WriteConsoleMsg(UI, "El evento " & .EventName & " ya esta en curso.", FontTypeNames.FONTTYPE_INFO)
  65.             Exit Sub
  66.         End If
  67.  
  68.         .Active = True
  69.         .Quotas = Quotas
  70.         .Inscription = Inscription
  71.         .Prize = Prize
  72.        
  73.         ReDim .Users(1 To .Quotas) As tUsers
  74.         Call SendData(SendTarget.ToAll, 0, PrepareMessageConsoleMsg(.EventName & Quotas & " Cupos, Inscripción" & IIf(.Inscription > 0, " de: " & Inscription & " monedas de oro, ", " Gratis, ") & IIf(.Prize > 0, "Premio de: " & Prize & " monedas de oro.", " No hay premio.") & " Si desean participar manden /PARTICIPAR", FontTypeNames.FONTTYPE_DIOS))
  75.     End With
  76.  
  77. End Sub
  78.  
  79. Public Sub CancelEvent(ByVal UI As Integer, ByVal NumEvent As Byte)
  80.  
  81.     If NumEvent < 1 Or NumEvent > MAX_EVENTS Then Exit Sub
  82.  
  83.     Dim LoopC As Long, N As Integer
  84.  
  85.     With Events(NumEvent)
  86.         If Not .Active Then
  87.             Call WriteConsoleMsg(UI, "El evento " & .EventName & " no esta en curso.", FontTypeNames.FONTTYPE_INFO)
  88.             Exit Sub
  89.         End If
  90.  
  91.         For LoopC = 1 To .Quotas
  92.             N = .Users(LoopC).UI
  93.  
  94.             If N > 0 Then
  95.            
  96.                 Call WarpUserCharX(N, .Users(LoopC).PreviousPos.Map, .Users(LoopC).PreviousPos.X, .Users(LoopC).PreviousPos.Y, True)
  97.  
  98.                 If .Inscription > 0 Then
  99.                     UserList(N).Stats.GLD = UserList(N).Stats.GLD + .Inscription
  100.                     Call WriteUpdateGold(N)
  101.                     Call WriteConsoleMsg(N, "El evento ha sido cancelado, se te ha devuelto el costo de la inscripción.", FontTypeNames.FONTTYPE_INFO)
  102.                 End If
  103.                
  104.                 UserList(N).Slot_ID = 0
  105.                 UserList(N).Event_ID = 0
  106.                
  107.             End If
  108.            
  109.         Next LoopC
  110.  
  111.         .Active = False
  112.         .Quotas = 0
  113.         .Inscription = 0
  114.         .Prize = 0
  115.  
  116.         Erase .Users()
  117.         Call SendData(SendTarget.ToAll, 0, PrepareMessageConsoleMsg(.EventName & "El evento ha sido cancelado.", FontTypeNames.FONTTYPE_DIOS))
  118.     End With
  119.  
  120. End Sub
  121.  
  122. Private Function FindFreeSlot(ByVal NumEvent As Byte) As Byte
  123.  
  124.     Dim LoopC As Long
  125.  
  126.     With Events(NumEvent)
  127.         For LoopC = 1 To .Quotas
  128.             If .Users(LoopC).UI < 1 Then
  129.                 FindFreeSlot = LoopC
  130.                 Exit Function
  131.             End If
  132.         Next LoopC
  133.     End With
  134.  
  135.     FindFreeSlot = 0
  136.  
  137. End Function
  138.  
  139. Public Sub EnterEvent(ByVal UI As Integer, ByVal NumEvent As Byte)
  140.  
  141.     If NumEvent < 1 Or NumEvent > MAX_EVENTS Then Exit Sub
  142.  
  143.     If Not CanEnterEvent(UI, NumEvent) Then Exit Sub
  144.  
  145.     Dim FreeSlot As Byte
  146.     FreeSlot = FindFreeSlot(NumEvent)
  147.    
  148.     If FreeSlot < 1 Then Exit Sub
  149.  
  150.     If FreeSlot Mod 2 = 0 Then
  151.         Call WriteConsoleMsg(UI, "Has ingresado para el equipo rojo.", FontTypeNames.FONTTYPE_INFO)
  152.     Else
  153.         Call WriteConsoleMsg(UI, "Has ingresado para el equipo azul.", FontTypeNames.FONTTYPE_INFO)
  154.     End If
  155.  
  156.     UserList(UI).Slot_ID = FreeSlot
  157.     UserList(UI).Event_ID = NumEvent
  158.  
  159.     Call WarpUserCharX(UI, 1, 50, 50)
  160.  
  161.     With Events(NumEvent)
  162.         .Entered = .Entered + 1
  163.         .Users(FreeSlot).UI = UI
  164.  
  165.         If .Entered >= .Quotas Then
  166.             Call SendData(SendTarget.ToAll, 0, PrepareMessageConsoleMsg(.EventName & "El cupo ha sido completado!.", FontTypeNames.FONTTYPE_DIOS))
  167.             Exit Sub
  168.         End If
  169.     End With
  170.  
  171. End Sub
  172.  
  173. Private Function CanEnterEvent(ByVal UI As Integer, ByVal NumEvent As Byte) As Boolean
  174.  
  175.     CanEnterEvent = False
  176.    
  177.     With UserList(UI)
  178.  
  179.         If .Slot_ID > 0 Then
  180.             Call WriteConsoleMsg(UI, "Ya te encuentras en un evento.", FontTypeNames.FONTTYPE_INFO)
  181.             Exit Function
  182.         End If
  183.  
  184.         If .Event_ID > 0 Then
  185.             Call WriteConsoleMsg(UI, "Ya estas en otro evento.", FontTypeNames.FONTTYPE_INFO)
  186.             Exit Function
  187.         End If
  188.        
  189.         If Not Events(NumEvent).Active Then
  190.             Call WriteConsoleMsg(UI, "El evento no está en curso.", FontTypeNames.FONTTYPE_DIOS)
  191.             Exit Function
  192.         End If
  193.  
  194.         If Events(NumEvent).Entered >= Events(NumEvent).Quotas Then
  195.             Call WriteConsoleMsg(UI, "El evento ya no tiene cupos disponibles.", FontTypeNames.FONTTYPE_DIOS)
  196.             Exit Function
  197.         End If
  198.        
  199.         If .Stats.GLD < Events(NumEvent).Inscription Then
  200.             Call WriteConsoleMsg(UI, "No tienes el oro suficiente.", FontTypeNames.FONTTYPE_DIOS)
  201.             Exit Function
  202.         End If
  203.  
  204.     End With
  205.  
  206.     CanEnterEvent = True
  207.  
  208. End Function
  209.  
  210. Private Sub EventDie(ByVal UI As Integer)
  211.  
  212.     Dim NumEvent As Byte
  213.  
  214.     With UserList(UI)
  215.  
  216.         If .Slot_ID < 1 Then Exit Sub
  217.         NumEvent = .Event_ID
  218.  
  219.         If NumEvent < 1 Or NumEvent > MAX_EVENTS Then Exit Sub
  220.         Events(NumEvent).Users(.Slot_ID).UI = 0
  221.  
  222.         If .Slot_ID Mod 2 = 0 Then
  223.             Call SendData(SendTarget.ToAll, 0, PrepareMessageConsoleMsg(Events(NumEvent).EventName & .Name & " ha sido derrotado.", FontTypeNames.FONTTYPE_DIOS))
  224.         Else
  225.             Call SendData(SendTarget.ToAll, 0, PrepareMessageConsoleMsg(Events(NumEvent).EventName & .Name & " ha sido derrotado.", FontTypeNames.FONTTYPE_DIOS))
  226.         End If
  227.  
  228.         .Slot_ID = 0
  229.         .Event_ID = 0
  230.  
  231.     End With
  232.  
  233. End Sub
  234.  
  235. Private Sub EventDisconnect(ByVal UI As Integer)
  236.  
  237.     Dim NumEvent As Byte
  238.  
  239.     With UserList(UI)
  240.  
  241.         If .Slot_ID < 1 Then Exit Sub
  242.         NumEvent = .Event_ID
  243.  
  244.         If NumEvent < 1 Or NumEvent > MAX_EVENTS Then Exit Sub
  245.         Events(NumEvent).Users(.Slot_ID).UI = 0
  246.  
  247.         If .Slot_ID Mod 2 = 0 Then
  248.             Call SendData(SendTarget.ToAll, 0, PrepareMessageConsoleMsg(Events(NumEvent).EventName & .Name & " abandona el equipo rojo.", FontTypeNames.FONTTYPE_DIOS))
  249.         Else
  250.             Call SendData(SendTarget.ToAll, 0, PrepareMessageConsoleMsg(Events(NumEvent).EventName & .Name & " abandona el equipo azul.", FontTypeNames.FONTTYPE_DIOS))
  251.         End If
  252.        
  253.         .Slot_ID = 0
  254.         .Event_ID = 0
  255.  
  256.     End With
  257.  
  258. End Sub
  259.  
  260. Public Sub WarpUserCharX(ByVal UI As Integer, ByVal Map As Integer, ByVal X As Integer, ByVal Y As Integer, Optional ByVal FX As Boolean = False)
  261.  
  262.     If InMapBounds(Map, X, Y) Then
  263.  
  264.         If MapData(Map, X, Y).UserIndex <> UI Then
  265.  
  266.             Dim NuevaPos As WorldPos
  267.             Dim FuturePos As WorldPos
  268.  
  269.             FuturePos.Map = Map
  270.             FuturePos.X = X
  271.             FuturePos.Y = Y
  272.  
  273.             Call ClosestLegalPos(FuturePos, NuevaPos, True)
  274.  
  275.             If NuevaPos.X <> 0 And NuevaPos.Y <> 0 Then
  276.                 Call WarpUserChar(UI, NuevaPos.Map, NuevaPos.X, NuevaPos.Y, FX)
  277.             End If
  278.  
  279.         End If
  280.  
  281.     End If
  282.  
  283. End Sub
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement