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


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

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

1Npc Usando Magia Empty Npc Usando Magia Dom Jun 03, 2012 6:40 pm

Renan
Renan
Administrador
Administrador

PARA QUE SERVE ISSO?

Bom Esta lista de códigos fará com que os NPC's do seu jogo utilizem também spell's.
Tanto Spell's de ataque como Spell's de cura. Bom vamos ao que interessa

Lado do SEVER

Abra o seu SERVER.VBP

Em modConstants

Procure por :

Código:
    Public Const MAX_PARTY_MEMBERS As Long = 4

Embaixo dele você adciona

Código:
Public Const MAX_NPC_SPELLS As Long = 5

Isso diz quantas spells seu npc terá, no caso 5 mas pode ter mais ou menos.

Agora vá para modTypes

Lá procure por Private Type NpcRec

Adcione isso entre Private Type NpcRec e End Type

Código:
    Spell(1 To MAX_NPC_SPELLS) As Long

Ainda em modTypes

Procure Private Type MapNpcRec

(Fica logo abaixo de Private Type NpcRec.)

Entre Private Type MapNpcRec e End Type adcione:

Código:
SpellTimer(1 To MAX_NPC_SPELLS) As Long
        Heals As Integer

Vamos para modCombat

Procure por Sub NpcAttackPlayer

No final desse Sub após até do End Sub adcione isto

Código:
Sub NpcSpellPlayer(ByVal MapNpcNum As Long, ByVal Victim As Long, SpellSlotNum As Long)
        Dim mapnum As Long
        Dim i As Long
        Dim n As Long
        Dim SpellNum As Long
        Dim Buffer As clsBuffer
        Dim InitDamage As Long
        Dim Damage As Long
        Dim MaxHeals As Long

        ' Check for subscript out of range
        If MapNpcNum <= 0 Or MapNpcNum > MAX_MAP_NPCS Or IsPlaying(Victim) = False Then
            Exit Sub
        End If

        ' Check for subscript out of range
        If MapNpc(GetPlayerMap(Victim)).Npc(MapNpcNum).Num <= 0 Then
            Exit Sub
        End If
     
        If SpellSlotNum <= 0 Or SpellSlotNum > MAX_NPC_SPELLS Then Exit Sub

        ' The Variables
        mapnum = GetPlayerMap(Victim)
        SpellNum = Npc(MapNpc(mapnum).Npc(MapNpcNum).Num).Spell(SpellSlotNum)
     
        ' Send this packet so they can see the person attacking
        Set Buffer = New clsBuffer
        Buffer.WriteLong SNpcAttack
        Buffer.WriteLong MapNpcNum
        SendDataToMap mapnum, Buffer.ToArray()
        Set Buffer = Nothing
     
        ' CoolDown Time
        If MapNpc(mapnum).Npc(MapNpcNum).SpellTimer(SpellSlotNum) > GetTickCount Then Exit Sub
     
        ' Spell Types
            Select Case Spell(SpellNum).Type
                ' AOE Healing Spells
                Case SPELL_TYPE_HEALHP
                ' Make sure an npc waits for the spell to cooldown
                MaxHeals = 1  Npc(MapNpc(mapnum).Npc(MapNpcNum).Num).Stat(Stats.intelligence) \ 25
                If MapNpc(mapnum).Npc(MapNpcNum).Heals >= MaxHeals Then Exit Sub
                    If MapNpc(mapnum).Npc(MapNpcNum).Vital(Vitals.HP) <= Npc(MapNpc(mapnum).Npc(MapNpcNum).Num).HP * 0.3 Then
                        If Spell(SpellNum).IsAoE Then
                            For i = 1 To MAX_MAP_NPCS
                                If MapNpc(mapnum).Npc(i).Num > 0 Then
                                    If MapNpc(mapnum).Npc(i).Vital(Vitals.HP) > 0 Then
                                        If isInRange(Spell(SpellNum).AoE, MapNpc(mapnum).Npc(MapNpcNum).x, MapNpc(mapnum).Npc(MapNpcNum).y, MapNpc(mapnum).Npc(i).x, MapNpc(mapnum).Npc(i).y) Then
                                            InitDamage = Spell(SpellNum).Vital  (Npc(MapNpc(mapnum).Npc(MapNpcNum).Num).Stat(Stats.intelligence) / 2)
                     
                                            MapNpc(mapnum).Npc(i).Vital(Vitals.HP) = MapNpc(mapnum).Npc(i).Vital(Vitals.HP)  InitDamage
                                            SendActionMsg mapnum, " " & InitDamage, BrightGreen, 1, (MapNpc(mapnum).Npc(i).x * 32), (MapNpc(mapnum).Npc(i).y * 32)
                                            Call SendAnimation(mapnum, Spell(SpellNum).SpellAnim, 0, 0, TARGET_TYPE_NPC, MapNpcNum)
                     
                                            If MapNpc(mapnum).Npc(i).Vital(Vitals.HP) > Npc(MapNpc(mapnum).Npc(i).Num).HP Then
                                                MapNpc(mapnum).Npc(i).Vital(Vitals.HP) = Npc(MapNpc(mapnum).Npc(i).Num).HP
                                            End If
                     
                                            MapNpc(mapnum).Npc(MapNpcNum).Heals = MapNpc(mapnum).Npc(MapNpcNum).Heals  1
                     
                                            MapNpc(mapnum).Npc(MapNpcNum).SpellTimer(SpellSlotNum) = GetTickCount  Spell(SpellNum).CDTime * 1000
                                            Exit Sub
                                        End If
                                    End If
                                End If
                            Next
                        Else
                        ' Non AOE Healing Spells
                            InitDamage = Spell(SpellNum).Vital  (Npc(MapNpc(mapnum).Npc(MapNpcNum).Num).Stat(Stats.intelligence) / 2)
                     
                            MapNpc(mapnum).Npc(MapNpcNum).Vital(Vitals.HP) = MapNpc(mapnum).Npc(MapNpcNum).Vital(Vitals.HP)  InitDamage
                            SendActionMsg mapnum, " " & InitDamage, BrightGreen, 1, (MapNpc(mapnum).Npc(MapNpcNum).x * 32), (MapNpc(mapnum).Npc(MapNpcNum).y * 32)
                            Call SendAnimation(mapnum, Spell(SpellNum).SpellAnim, 0, 0, TARGET_TYPE_NPC, MapNpcNum)
                     
                            If MapNpc(mapnum).Npc(MapNpcNum).Vital(Vitals.HP) > Npc(MapNpc(mapnum).Npc(MapNpcNum).Num).HP Then
                                MapNpc(mapnum).Npc(MapNpcNum).Vital(Vitals.HP) = Npc(MapNpc(mapnum).Npc(MapNpcNum).Num).HP
                            End If
                     
                            MapNpc(mapnum).Npc(MapNpcNum).Heals = MapNpc(mapnum).Npc(MapNpcNum).Heals  1
                     
                            MapNpc(mapnum).Npc(MapNpcNum).SpellTimer(SpellSlotNum) = GetTickCount  Spell(SpellNum).CDTime * 1000
                            Exit Sub
                        End If
                    End If
                 
                ' AOE Damaging Spells
                Case SPELL_TYPE_DAMAGEHP
                ' Make sure an npc waits for the spell to cooldown
                    If Spell(SpellNum).IsAoE Then
                        For i = 1 To Player_HighIndex
                            If IsPlaying(i) Then
                                If GetPlayerMap(i) = mapnum Then
                                    If isInRange(Spell(SpellNum).AoE, MapNpc(mapnum).Npc(MapNpcNum).x, MapNpc(mapnum).Npc(MapNpcNum).y, GetPlayerX(i), GetPlayerY(i)) Then
                                        InitDamage = Spell(SpellNum).Vital  (Npc(MapNpc(mapnum).Npc(MapNpcNum).Num).Stat(Stats.intelligence) / 2)
                                        Damage = InitDamage - Player(i).Stat(Stats.willpower)
                                            If Damage <= 0 Then
                                                SendActionMsg GetPlayerMap(i), "RESIST!", Pink, 1, (GetPlayerX(i) * 32), (GetPlayerY(i) * 32)
                                                Exit Sub
                                            Else
                                                NpcAttackPlayer MapNpcNum, i, Damage
                                                SendAnimation mapnum, Spell(SpellNum).SpellAnim, 0, 0, TARGET_TYPE_PLAYER, MapNpcNum
                                                MapNpc(mapnum).Npc(MapNpcNum).SpellTimer(SpellSlotNum) = GetTickCount  Spell(SpellNum).CDTime * 1000
                                                Exit Sub
                                            End If
                                    End If
                                End If
                            End If
                        Next
                    ' Non AoE Damaging Spells
                    Else
                        If isInRange(Spell(SpellNum).Range, MapNpc(mapnum).Npc(MapNpcNum).x, MapNpc(mapnum).Npc(MapNpcNum).y, GetPlayerX(Victim), GetPlayerY(Victim)) Then
                        InitDamage = Spell(SpellNum).Vital  (Npc(MapNpc(mapnum).Npc(MapNpcNum).Num).Stat(Stats.intelligence) / 2)
                        Damage = InitDamage - Player(Victim).Stat(Stats.willpower)
                            If Damage <= 0 Then
                                SendActionMsg GetPlayerMap(Victim), "RESIST!", Pink, 1, (GetPlayerX(Victim) * 32), (GetPlayerY(Victim) * 32)
                                Exit Sub
                            Else
                                NpcAttackPlayer MapNpcNum, Victim, Damage
                                SendAnimation mapnum, Spell(SpellNum).SpellAnim, 0, 0, TARGET_TYPE_PLAYER, Victim
                                MapNpc(mapnum).Npc(MapNpcNum).SpellTimer(SpellSlotNum) = GetTickCount  Spell(SpellNum).CDTime * 1000
                                Exit Sub
                            End If
                        End If
                    End If
                End Select
    End Sub

No modServerLoop

Procure por isso e delete:

Código:
Else
                                ' lol no npc combat [img]/users/2015/17/56/91/smiles/881399.gif[/img]
                            End If

Agora Procure no mesmo mod:

Código:
' ////////////////////////////////////////////
                    ' // This is used for regenerating NPC's HP //
                    ' ////////////////////////////////////////////

Acima disso adcione:

Código:
' Spell Casting
                                    For i = 1 To MAX_NPC_SPELLS
                                        If Npc(npcNum).Spell(i) > 0 Then
                                            If MapNpc(mapnum).Npc(x).SpellTimer(i)  (Spell(Npc(npcNum).Spell(i)).CastTime * 1000) < GetTickCount Then
                                                NpcSpellPlayer x, target, i
                                            End If
                                        End If
                                    Next
                                End If

Acabou o Lado do Servidor salve e compile ^.^

Vamos para o Client agora.
Abra o seu CLIENT.VBP

Vá em modConstants

Procure por:

Código:
    Public Const MAX_PARTY_MEMBERS As Long = 4

Logo abaixo adcione:

Código:
    Public Const MAX_NPC_SPELLS As Long = 5

Agora vamos para o modTypes

Procure por Private Type NpcRec

Entre o Private Type NpcRec e o End Type Adcione:

Código:
    Spell(1 To MAX_NPC_SPELLS) As Long

Vá para modGameEditors

Procure por Public Sub NpcEditorInit

Ache esta linha:

Código:
    .txtDamage.text = Npc(EditorIndex).Damage

Logo abaixo disso adcione:

Código:
.scrlSpellNum.Max = MAX_NPC_SPELLS
            .scrlSpellNum.Value = 1

agora baixe esses 2 arquivos e os adcione no seu projeto:

http://www.touchofdeathforums.com/smf/index.php?action=dlattach;topic=59564.0;attach=18160
http://www.touchofdeathforums.com/smf/index.php?action=dlattach;topic=59564.0;attach=18161

Ai é só vc salvar e compilar.

Creditos : Desconhecido

2Npc Usando Magia Empty Re: Npc Usando Magia Dom Jun 03, 2012 6:48 pm

Ricardo Henrique
Ricardo Henrique
Administrador
Administrador

Bem legal. ;o'

Obrigado por compartilhar !

https://legendarymakers.forumeiros.com

3Npc Usando Magia Empty Re: Npc Usando Magia Dom Jun 03, 2012 7:46 pm

Dяagon™
Dяagon™
Membro
Membro

Valeu por compartilhar com a galera manin se eu tivese dava mas 1 cred (:

Metas: Moderador Local

https://legendarymakers.forumeiros.com

4Npc Usando Magia Empty Re: Npc Usando Magia Dom Jun 03, 2012 8:05 pm

Renan
Renan
Administrador
Administrador

De nada, e não precisa de credito para dar credito! Basta clicar no botão Crédito do lado do meu post. Em > ^


Conteúdo patrocinado

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