Aldeia RPG

Gostaria de reagir a esta mensagem? Crie uma conta em poucos cliques ou inicie sessão para continuar.

Suporte ao desenvolvimento de jogos


2 participantes

    [EO] Sistema de Dash 1.0

    Itukakitu
    Itukakitu
    Novato
    Novato


    Mensagens : 4
    Créditos : 2

    [EO] Sistema de Dash 1.0 Empty [EO] Sistema de Dash 1.0

    Mensagem por Itukakitu Dom Ago 05, 2018 4:17 pm

    Um sistema simples de dash :)

    Ja aviso que tem alguns bugs, então se alguém tiver disponível a consertar pra deixar esse sistema perfeito eu agradeço.
    Os bugs sao: Atravessar tiles type blocked, algumas vezes se usar o dash perto da parede pd dar subscript out of range no server.

    Client-Side

    no modEnumerations, procure por:


    Código:
    Public Enum ClientPackets


    Antes do End Enum Adicione:


    Código:
    CSendDash


    No final do modClientTCP adicione

    Código:
    Sub SendDash()
        Dim Buffer As clsBuffer

        ' If debug mode, handle error then exit out
        If Options.Debug = 1 Then On Error GoTo errorhandler

        Set Buffer = New clsBuffer
        Buffer.WriteLong CSendDash
        SendData Buffer.ToArray()
        Set Buffer = Nothing

        ' Error handler
        Exit Sub
    errorhandler:
        HandleError "SendDash", "modClientTCP", Err.Number, Err.Description, Err.Source, Err.HelpContext
        Err.Clear
        Exit Sub
    End Sub



    Na frmMain na Sub Form_KeyPress procure por:


    Código:
        ' prevents textbox on error ding sound
        If KeyAscii = vbKeyReturn Or KeyAscii = vbKeyEscape Then
            KeyAscii = 0
        End If



    Abaixo adicione: 

    Código:
        ' Troque o vkKeyS por outra tecla de sua preferencia
        If KeyAscii = vbKeyS Then
            Call SendDash
        End If



    Client Finalizado, vamos ao server

    Server-Side


    no modEnumerations, procure por:


    Código:
    Public Enum ClientPackets


    Antes do End Enum Adicione:


    Código:
    CSendDash

    No modHandleData na sub InitMessages, antes do end sub adicione:


    Código:
    HandleDataSub(CSendDash) = GetAddress(AddressOf HandleUseDash)


    Ainda no modHandleData, no final do mod adicione:

    Código:
    Sub HandleUseDash(ByVal Index As Long)
        Dim i As Long
        Dim x As Long, y As Long
        Dim xt As Long
        Dim yt As Long
        Dim xtt As Long
        Dim ytt As Long
        Dim n As Long
        
        ' see if cooldown has finished
        If TempPlayer(Index).DashCD > GetTickCount Then
            'PlayerMsg Index, "Aguarde para usar o Dash novamente.", BrightRed
        Exit Sub
        End If
        
        ' Tempo até o proximo uso do dash (2000 = 2 Segundos)
        TempPlayer(Index).DashCD = GetTickCount * 2000
        
             If Player(Index).Dir = 0 Then
             xt = Player(Index).x
             yt = Player(Index).y - 4 + 0
             If xt > Map(Index).MaxX Then xt = Map(Index).MaxX
             If yt > Map(Index).MaxY Then yt = Map(Index).MaxY
             If xt < 1 Then xt = 1
             If yt < 1 Then yt = 1
             If Map(Index).Tile(xt, yt).Type = TILE_TYPE_WALKABLE Then
                 SetPlayerX Index, xt
                 SetPlayerY Index, yt
                 SendPlayerXYToMap Index
             Else
                 If yt < Player(Index).y Then
                     Do Until Map(Index).Tile(xt, yt).Type = TILE_TYPE_WALKABLE
                     yt = yt + 1
                     Loop
                     If yt < Player(Index).y Then
                     SetPlayerX Index, xt
                     SetPlayerY Index, yt
                     SendPlayerXYToMap Index
                     End If
                 Else
                 If yt > Player(Index).y Then
                     Do Until Map(mapnum).Tile(xt, yt).Type = TILE_TYPE_WALKABLE
                     yt = yt - 1
                     Loop
                     If yt > Player(Index).y Then
                     SetPlayerX Index, xt
                     SetPlayerY Index, yt
                     SendPlayerXYToMap Index
                     End If
                 End If
                 End If
             End If
             End If
             If Player(Index).Dir = 1 Then
             xt = Player(Index).x
             yt = Player(Index).y + 4 - 0
             If xt > Map(Index).MaxX Then xt = Map(Index).MaxX
             If yt > Map(Index).MaxY Then yt = Map(Index).MaxY
             If xt < 1 Then xt = 1
             If yt < 1 Then yt = 1
             If Map(Index).Tile(xt, yt).Type = TILE_TYPE_WALKABLE Then
             SetPlayerX Index, xt
             SetPlayerY Index, yt
                     SendPlayerXYToMap Index
             Else
                 If yt < Player(Index).y Then
                     Do Until Map(mapnum).Tile(xt, yt).Type = TILE_TYPE_WALKABLE
                     yt = yt + 1
                     Loop
                     If yt < Player(Index).y Then
                     SetPlayerX Index, xt
                     SetPlayerY Index, yt
                     SendPlayerXYToMap Index
                     End If
                 Else
                 If yt > Player(Index).y Then
                     Do Until Map(Index).Tile(xt, yt).Type = TILE_TYPE_WALKABLE
                     yt = yt - 1
                     Loop
                     If yt > Player(Index).y Then
                     SetPlayerX Index, xt
                     SetPlayerY Index, yt
                     SendPlayerXYToMap Index
                     End If
                 End If
                 End If
             End If
             End If
             If Player(Index).Dir = 2 Then
             xt = Player(Index).x - 4 + 0
             yt = Player(Index).y
             If xt > Map(Index).MaxX Then xt = Map(Index).MaxX
             If yt > Map(Index).MaxY Then yt = Map(Index).MaxY
             If xt < 1 Then xt = 1
             If yt < 1 Then yt = 1
             If Map(Index).Tile(xt, yt).Type = TILE_TYPE_WALKABLE Then
             Call SendAnimation(GetPlayerMap(Index), 6, GetPlayerX(Index), GetPlayerY(Index), 0, 0)
             SetPlayerX Index, xt
             SetPlayerY Index, yt
                     SendPlayerXYToMap Index
             Else
                 If xt < Player(Index).x Then
                     Do Until Map(Index).Tile(xt, yt).Type = TILE_TYPE_WALKABLE
                     xt = xt + 1
                     Loop
                     If xt < Player(Index).x Then
                     SetPlayerX Index, xt
                     SetPlayerY Index, yt
                     SendPlayerXYToMap Index
                     End If
                 Else
                 If xt > Player(Index).x Then
                     Do Until Map(mapnum).Tile(xt, yt).Type = TILE_TYPE_WALKABLE
                     xt = xt - 1
                     Loop
                     If xt > Player(Index).x Then
                     SetPlayerX Index, xt
                     SetPlayerY Index, yt
                     SendPlayerXYToMap Index
                     End If
                 End If
                 End If
             End If
             End If
             If Player(Index).Dir = 3 Then
             xt = Player(Index).x + 4 - 0
             yt = Player(Index).y
             If xt > Map(Index).MaxX Then xt = Map(Index).MaxX
             If yt > Map(Index).MaxY Then yt = Map(Index).MaxY
             If xt < 1 Then xt = 1
             If yt < 1 Then yt = 1
             If Map(Index).Tile(xt, yt).Type = TILE_TYPE_WALKABLE Then
             Call SendAnimation(GetPlayerMap(Index), 7, GetPlayerX(Index), GetPlayerY(Index), 0, 0)
             SetPlayerX Index, xt
             SetPlayerY Index, yt
                     SendPlayerXYToMap Index
             Else

                 If xt < Player(Index).x Then
                     Do Until Map(Index).Tile(xt, yt).Type = TILE_TYPE_WALKABLE
                     xt = xt + 1
                     Loop
                     If xt < Player(Index).x Then
                     SetPlayerX Index, xt
                     SetPlayerY Index, yt
                     SendPlayerXYToMap Index
                     End If
                 Else

                If Not Player(Index).Map <= 0 Then
                 If xt > Player(Index).x Then
                     Do Until Map(mapnum).Tile(xt, yt).Type = TILE_TYPE_WALKABLE
                     xt = xt - 1
                     Loop
                     If xt > Player(Index).x Then
                     SetPlayerX Index, xt
                     SetPlayerY Index, yt
                     SendPlayerXYToMap Index
                     End If
                 End If
                 End If
                 End If
             End If
             End If
    End Sub


    Última edição por Itukakitu em Dom Ago 05, 2018 4:31 pm, editado 1 vez(es)
    Profane ~
    Profane ~
    Colaborador
    Colaborador


    Mensagens : 818
    Créditos : 130

    [EO] Sistema de Dash 1.0 Empty Re: [EO] Sistema de Dash 1.0

    Mensagem por Profane ~ Dom Ago 05, 2018 4:27 pm

    Não testado mas excelente ;3

    Vejo que usou até do Until ;3 coisa de gente grande *-*


    _________________
    "Mistress of shattered hopes and forever broken dreams"

      Data/hora atual: Sex Abr 26, 2024 7:29 pm