Makers Brasil
Bem Vindos a Maker´s Brasil (um forum para criação de servidores 2D e 3D)Nos desejamos boa sorte no seu projeto!


Participe do fórum, é rápido e fácil

Makers Brasil
Bem Vindos a Maker´s Brasil (um forum para criação de servidores 2D e 3D)Nos desejamos boa sorte no seu projeto!
Makers Brasil
Gostaria de reagir a esta mensagem? Crie uma conta em poucos cliques ou inicie sessão para continuar.

[Tutorial]Sistema de buff

2 participantes

Ir para baixo

[Tutorial]Sistema de buff Empty [Tutorial]Sistema de buff

Mensagem por teteu Dom Jul 17, 2011 10:39 am

Olá galerinha, venho através desse tópico trazer o tão desejado sistema de buff que todos querem, bom esse é só um protótico do verdadeiro isso é só pra vocês tirarem como base de como fazer o sistema da forma de vocês.
Então vamos lá.

[size=14pt]Client ~ Side[/size]

Na frmMirage, crie um Timer com as seguintes propriedades:

Nome : bufftempo5
Interval : 1000
Enable : True

Dê dois clicks e adicione isso:

Código:
If buffTempo = 0 Then
Call SendData("debuff" & SEP_CHAR & END_CHAR)
bufftempo5.Enabled = False
Else
buffTempo = buffTempo - 1
End If

Vamos iniciar as Constantes procure por ' Spell constants e então adicione:

Código:
Public Const SPELL_TYPE_BUFF = 8

Na frmSpellEditor faça o seguinte:

Nas propriedades procure por List e adicione isso:

Código:
Buff de Força

Depois

Crie 1 label, 1 text:

Na Label dê a caption de : Tempo de Buff (em Segundos)
Na text dê o nome de : Text1

Então procure por Type SpellRec e abaixo de Range As Byte adicione:

buffTempo As Long

Após isso procure por, Sub SendSaveSpell(ByVal SpellNum As Long) e então depois de Spell(SpellNum).Element adicione :

Código:
& SEP_CHAR & Spell(SpellNum).buffTempo

No inicio do modGameLogic adicione :

Código:
Public buffTempo As Integer
Public BuffNome As String

Vamos procurar por:
Código:
' draw FPS

logo abaixo do código vamos adicionar:

Código:
If frmMirage.bufftempo5.Enabled = True Then
                        Call DrawText(TexthDC, 10 + sx, 460 + sx, "Tempo Restante: " & buffTempo & " Segundos", QBColor(WHITE))
                        Call DrawText(TexthDC, 10 + sx, 440 + sx, BuffNome, QBColor(WHITE))
                    End If

Procure agora por:

Código:
If casestring = "leaveparty211" Then

Abaixo adicione:

Código:
If casestring = "buff" Then
       
        buffTempo = parse(1)
        BuffNome = parse(2)
        frmMirage.bufftempo5.Enabled = True
        End If

Procure por Edit spell packet e abaixo de :

Código:
Spell(n).Element = Val(parse(17))

Adicione:

Código:
Spell(n).buffTempo = Val(parse(18))

Procure por Public Sub SpellEditorInit() e adicione:

Código:
frmSpellEditor.Text1.Text = Spell(EditorIndex).buffTempo

Depois procure por Public Sub SpellEditorOk() e então adicione:

Código:
Spell(EditorIndex).buffTempo = frmSpellEditor.Text1.Text

Dê dois clicks na Private Sub cmbType_Click() e então adicione no inicio:

Código:
If (cmbType.ListIndex = SPELL_TYPE_BUFF) Then
   
    Label11.Visible = True
    Text1.Visible = True   
Else

Acho que a parte do cliente está completa agora vamos para o servidor.

[size=14pt]Server ~ Side[/size]

Procure por ' Spell Constants e então adicione :

Código:
Public Const SPELL_TYPE_BUFF = 8

Depois procure por ' MENUS e então adicione :

Código:
BuffNum As Long
BuffAtiva As Boolean
BuffSlot As Byte

Procure por Public Sub LeftGame(ByVal Index As Long) e então adicione no final:

Código:
If Player(Index).BuffAtiva = True Then
    Call Packet_Debuff(Index)
    End If
       
    Call SavePlayer(Index)
    Call SendLeftGame(Index)
    Call ClearPlayer(Index)
    End If

Procure por Sub CastSpell(ByVal Index As Long, ByVal SpellSlot As Long) adicione:

Código:
Dim SpellDano As Long
Dim SpellDanoTirar As Long
Dim BuffTempo As Long

Procure por :

' Check if timer is ok
If GetTickCount < Player(Index).AttackTimer + 1000 Then
Exit Sub
End If

Abaixo adicione :

Código:
If Spell(SpellNum).Type = SPELL_TYPE_BUFF Then
      If Player(Index).BuffAtiva = True Then
      If Player(Index).BuffNum = SpellNum Then
      Call SendDataTo(Index, "buff" & SEP_CHAR & BuffTempo & SEP_CHAR & Spell(SpellNum).name & END_CHAR)
      Else
      Select Case Spell(Player(Index).BuffNum).Type
      Case 8
      Call SetPlayerSTR(Index, GetPlayerSTR(Index) - SpellDanoTirar)
      End Select
      Call SetPlayerSTR(Index, GetPlayerSTR(Index) + SpellDano)
      Call SendStats(Index)
      SendHP Index
      SendMP Index
      SendSP Index
      Player(Index).BuffNum = SpellNum
      Player(Index).BuffSlot = SpellSlot
      Call SendDataTo(Index, "buff" & SEP_CHAR & BuffTempo & SEP_CHAR & Spell(SpellNum).name & END_CHAR)
      End If
      Else
      Call SetPlayerSTR(Index, GetPlayerSTR(Index) + SpellDano)
      Call SendStats(Index)
      SendHP Index
      SendMP Index
      SendSP Index
      Player(Index).BuffNum = SpellNum
      Player(Index).BuffSlot = SpellSlot
      Player(Index).BuffAtiva = True
      Call SendDataTo(Index, "buff" & SEP_CHAR & BuffTempo & SEP_CHAR & Spell(SpellNum).name & END_CHAR)
      End If
      Call SendDataToMap(GetPlayerMap(Index), "sound" & SEP_CHAR & "Jutsu" & SEP_CHAR & Spell(SpellNum).Sound & END_CHAR)
    End If

Procure por Sub SendEditSpellTo(ByVal Index As Long, ByVal SpellNum As Long) e então adicione :

Código:
& SEP_CHAR & Spell(SpellNum).BuffTempo

Procure Sub HandleData(ByVal Index As Long, ByVal Data As String) e adicione :

Código:
Case "debuff"
    Call Packet_Debuff(Index)
    Exit Sub

Procure por Public Sub Packet_SaveSpell(ByVal Index As Long, ByRef SpellData() As String) e adicione :

Código:
Spell(SpellNum).BuffTempo = Val(SpellData(18))

No final da modHandleData adicione :

Código:
Public Sub Packet_Debuff(ByVal Index As Long)
Dim SpellDano As Long

SpellDano = Spell(Player(Index).BuffNum).Data1 + (Player(Index).Char(Player(Index).CharNum).Spell(Player(Index).BuffSlot).LEVEL)

      Select Case Spell(Player(Index).BuffNum).Type
      Case 8
      Call SetPlayerSTR(Index, GetPlayerSTR(Index) - SpellDano)
      End Select
     
    SendStats Index
    SendHP Index
    SendMP Index
    SendSP Index
   
    Player(Index).BuffAtiva = False
    Player(Index).BuffNum = 0
    Player(Index).BuffSlot = 0
End Sub

Pronto se não me esqueci de nada acho que é só isso '-' qualquer coisa me comuniquem.
Obs: Esse sistema eu fiz apenas para Força, se quiserem para outros status só fazerem igual.

Tem que ter spell level no seu cliente!

Créditos : Lucas Lôpo
Postar: Teteu(eu)
teteu
teteu
Modelador
Modelador

Mensagens : 4
Estrelas Makers : 8
Creditos : 2
Data de inscrição : 03/07/2011

Ir para o topo Ir para baixo

[Tutorial]Sistema de buff Empty Re: [Tutorial]Sistema de buff

Mensagem por spectrus Dom Jul 17, 2011 12:06 pm

Muito bom! + 1 CRED pelo TUtorial!
spectrus
spectrus
Administrador
Administrador

Mensagens : 299
Estrelas Makers : 1466
Creditos : 49
Data de inscrição : 01/01/2011
Idade : 30
Localização : V.da conquista bahia

Ir para o topo Ir para baixo

Ir para o topo

- Tópicos semelhantes

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