DevClub


Você não está conectado. Conecte-se ou registre-se

Photo

Sistema de Defesa com novo frame

Ver o tópico anterior Ver o tópico seguinte Ir para baixo  Mensagem [Página 1 de 1]

Renanr

Renanr
Novato
Explicando:
Segurando a tecla "C" do teclado, o personagem irá ficar em forma de defesa, assim tendo novos frames nas sprites. Enquanto defende, todo dano recebido é reduzido pela sua proteção.

Se quiser trocar a tecla C por outra qualquer, será preciso alterações no sistema, então se quiser comente a tecla que quiser em baixo que farei as alterações pra você!

Lembrem-se de fazer um backup antes de implantar um sistema.

Cliente Side~

Procure por:
Código:
' The Guild Creator
    If KeyCode = vbKeyF4 Then
        If Player(MyIndex).Access > 0 Then
            frmGuild.Show vbModeless, frmMirage
        End If
    End If

Abaixo adicione:
Código:
If KeyCode = vbKeyC Then
        If Player(MyIndex).Attacking = 0 Then
            Player(MyIndex).Defendendo = 1
        Else
            Call AddText("Impossível defender e atacar ao mesmo tempo!", Red)
            Player(MyIndex).Defendendo = 0
        End If
    End If

Procure:
Código:
If KeyCode = vbKeyControl Then
                ControlDown = True
            End If

Abaixo adicione:
Código:
If KeyCode = vbKeyC Then
                Defender = True
            End If

Procure:
Código:
If KeyCode = vbKeyControl Then ControlDown = False

Abaixo coloque:
Código:
If KeyCode = vbKeyC Then Defender = False

Procure:
Código:
Public ControlDown As Boolean

Abaixo ponha:
Código:
Public Defender As Boolean

Procure:
Código:
If GetAsyncKeyState(VK_SHIFT) >= 0 And ShiftDown = True Then ShiftDown = False

Abaixo coloque:
Código:
If GetAsyncKeyState(VK_CKEY) >= 0 And Defender = True Then Defender = False

Procure na sub BltPlayer:
Código:
If Player(Index).AttackTimer + Int(AttackSpeed / 2) > GetTickCount Then
            Anim = 2
        End If
    End If

Abaixo ponha:
Código:
If Player(Index).Defendendo = 1 Then
        Select Case GetPlayerDir(Index)
            Case DIR_UP
                Anim = 12
            Case DIR_DOWN
                Anim = 10
            Case DIR_LEFT
                Anim = 8
            Case DIR_RIGHT
                Anim = 6
        End Select
    End If

Ainda na sub BltPlayer procure:
Código:
' Check to see if we want to stop making him attack
    If Player(Index).AttackTimer + AttackSpeed < GetTickCount Then
        Player(Index).Attacking = 0
        Player(Index).AttackTimer = 0
    End If

Abaixo coloque:
Código:
If Defender = False Then
        Player(Index).Defendendo = 0
    End If

Procure por:
Código:
Sub CheckAttack()

Mude a sub toda para:
Código:
Sub CheckAttack()
Dim AttackSpeed As Long
Dim I As Long
    If GetPlayerWeaponSlot(MyIndex) > 0 Then
        AttackSpeed = Item(GetPlayerInvItemNum(MyIndex, GetPlayerWeaponSlot(MyIndex))).AttackSpeed
    Else
        AttackSpeed = 1000
    End If
    
    If ControlDown = True And Defender = False And Player(MyIndex).AttackTimer + AttackSpeed < GetTickCount And Player(MyIndex).Attacking = 0 Then
        Player(MyIndex).Attacking = 1
        Player(MyIndex).AttackTimer = GetTickCount
        Call SendData("attack" & END_CHAR)
    End If
    
    If Defender = True And ControlDown = False And Player(MyIndex).Defendendo = 0 Then
        Player(MyIndex).Defendendo = 1
    End If
End Sub

Procure:
Código:
If GetKeyState(VK_CONTROL) < 0 Then
            ControlDown = True
        Else
            ControlDown = False
        End If

Abaixo ponha:
Código:
If GetKeyState(VK_CKEY) < 0 Then
            Defender = True
        Else
            Defender = False
        End If

Procure:
Código:
Public Const VK_CONTROL = &H11

Abaixo ponha:
Código:
Public Const VK_CKEY = &H43

Procure por:
Código:
' Check if we are getting a map, and if we are tell them so
        If GettingMap = True Then
            Call DrawText(TexthDC, 36, 36, "Recebendo mapa...", QBColor(BrightCyan))
        End If

Em cima ponha:
Código:
For I = 1 To MAX_PLAYERS
            Select Case Player(I).Defendendo
                Case 0
                Call SendData("defendendo" & SEP_CHAR & I & SEP_CHAR & 0 & END_CHAR)
                Case 1
                Call SendData("defendendo" & SEP_CHAR & I & SEP_CHAR & 1 & END_CHAR)
            End Select
        Next

Na Type PlayerRec procure:
Código:
CastedSpell As Byte

Abaixo coloca:
Código:
Defendendo As Byte

SERVER SIDE~
Procure:
Código:
' Online e Jogando
    If IsPlaying(Index) = False Then Exit Sub
    If IsConnected(Index) = False Then Exit Sub

    Select Case LCase$(Parse(0))

Abaixo coloque:
Código:
Case "defendendo"
        If Parse(2) = 0 Then
            Player(Parse(1)).Defendendo = False
        ElseIf Parse(2) = 1 Then
            Player(Parse(1)).Defendendo = True
        End If
        Exit Sub

Na Type AccountRec abaixo de:
Código:
Pet As PetRec

Coloque:
Código:
Defendendo As Boolean

Na sub AttackPlayer abaixo de:
Código:
' Checar por arma
    If GetPlayerWeaponSlot(Attacker) > 0 Then
        N = GetPlayerInvItemNum(Attacker, GetPlayerWeaponSlot(Attacker))
    Else
        N = 0
    End If

Coloque:
Código:
' Diminuir damage no caso do jogador estar defendendo.
    If Player(Victim).Defendendo = True Then
        Damage = Damage - GetPlayerProtection(Victim) / 2
    End If
    
    ' Verificar se com a defesa o dano foi a 0
    If Damage <= 0 Then
        Call BattleMsg(Victim, GetPlayerName(Attacker) & " não pôde ferir-lo!!", BrightBlue, 1)
        Call BattleMsg(Attacker, GetPlayerName(Victim) & " defendeu seu ataque!", BrightRed, 0)
        Exit Sub
    End If

Na Sub NpcAttackPlayer abaixo de :
Código:
' Checar por subscript out of range
    If MapNpc(GetPlayerMap(Victim), MapNpcNum).num <= 0 Then
        Exit Sub
    End If

Coloque:
Código:
' Diminuir damage no caso do jogador estar defendendo.
    If Player(Victim).Defendendo = True Then
        Damage = Damage - GetPlayerProtection(Victim) / 2
    End If
    
    ' Verificar se com a defesa o dano foi a 0
    If Damage <= 0 Then
        Call BattleMsg(Victim, Trim$(Npc(MapNpc(MapNum, MapNpcNum).num).Name) & " não pôde ferir-lo!!", BrightBlue, 1)
        Exit Sub
    End If

Agora serão preciso novos estilos de sprites na sua engine. Segue abaixo um exemplo de uma sprite!
Sistema de Defesa com novo frame OplYlAF

Foram adicionados 4 frames no final, essas foram as frames adicionadas:
Sistema de Defesa com novo frame UxZgACF

Fim!
Se não esqueci de nada, claro, deve dar certo. kk.


Créditos:

Renan

Ver o tópico anterior Ver o tópico seguinte Ir para o topo  Mensagem [Página 1 de 1]

Permissões neste sub-fórum
Não podes responder a tópicos