1 NPC Level 10/4/2012, 01:52
RenanR
Membro Honorário I
Hi hi amigos =D, eu fiz esse sistema otem a noite, eu acho que vai servi muito para alguns, ele funciona da seguinte maneira:
Quando você configura seu NPC, você pode escolher seu tipo(Normal,Mini-Boss,Boss) e o seu Level, dependendo do tipo o nome level muda a cor =], vamos para o que interessa:
~~Client Side~~
Obs: Não esqueça de fazer um backup!.
Abra a source e procure por "Sub BltMapNPCName(ByVal Index As Long)" e troque ela por essa:
Agora procure por "Type NpcRec" e troque ela por essa:
Depois vá no seu "frmNpcEditor" e adicione o seguinte:
* 2 HScroll
* 2 Label
renomeio o "(Name)" de 1 label para "lblLevel" e o outro de "lblTipo", no Hscroll1 bote o seguinte código:
Agora procure por "Public Sub NpcEditorInit()" e troque por essa:
Agora procure por "If (Parse(0) = "updatenpc") Then" e troque ele por esse:
Agora procure por "If (Parse(0) = "editnpc") Then" e troque por esse:
Agora va e procure por "Sub SendSaveNpc(ByVal NpcNum As Long)" e troque por essa:
Bom a parte do Client-Side termino(eu acho ), agora vamos para o ServerSide.
~~ServerSide~~
Vá e procure por "Type NpcRec" e troque ele por esse:
Continuando(ta chato t.t) procure por "Case "savenpc" " e troque por esse:
Agora vá e ache "Sub SendEditNpcTo(ByVal Index As Long, ByVal NpcNum As Long)" e troque por esse:
Também ache : "Sub SendUpdateNpcTo(ByVal Index As Long, ByVal NpcNum As Long)" e troque por esse:
em baixo tem "
Sub SendUpdateNpcToAll(ByVal NpcNum As Long)" e troque por esse:
Pronto, seu level npc está pronto(eu acho), lembrando que essa é a Rev 0.1b, então se ouver algum erro ou coisa do tipo avise ai, que eu irei concerta...
Obs:
1º Não venha dizer que não funciona se você não fez até o final.
2º Só vó responder dúvidas(deu esse erro aqui) se tiver imagem.
3º Créditos: OmegaZero(Mythos)
Perdão pelos erros de Português ~~
Quando você configura seu NPC, você pode escolher seu tipo(Normal,Mini-Boss,Boss) e o seu Level, dependendo do tipo o nome level muda a cor =], vamos para o que interessa:
~~Client Side~~
Obs: Não esqueça de fazer um backup!.
Abra a source e procure por "Sub BltMapNPCName(ByVal Index As Long)" e troque ela por essa:
- Código:
Sub BltMapNPCName(ByVal Index As Long)
Dim TextX As Long
Dim TextY As Long
If Npc(MapNpc(Index).Num).Big = 0 Then
With Npc(MapNpc(Index).Num)
'Draw name
TextX = MapNpc(Index).x * PIC_X + sx + MapNpc(Index).XOffset + CLng(PIC_X / 2) - ((Len(Trim$(.Name)) / 2) * 8)
TextY = MapNpc(Index).y * PIC_Y + sx + MapNpc(Index).YOffset - CLng(PIC_Y / 2) - 4 - (SIZE_Y - PIC_Y)
DrawPlayerNameText TexthDC, TextX - (NewPlayerX * PIC_X) - NewXOffset, TextY - (NewPlayerY * PIC_Y) - NewYOffset - 15, Trim$(.Name), vbWhite
If Npc(MapNpc(Index).Num).Boss = 1 Then
DrawPlayerNameText TexthDC, TextX - (NewPlayerX * PIC_X) - NewXOffset, TextY - (NewPlayerY * PIC_Y) - NewYOffset, Trim$("Level: " & .Level), vbCyan
ElseIf Npc(MapNpc(Index).Num).Boss = 2 Then
DrawPlayerNameText TexthDC, TextX - (NewPlayerX * PIC_X) - NewXOffset, TextY - (NewPlayerY * PIC_Y) - NewYOffset, Trim$("Level: " & .Level), RGB(227, 118, 27)
ElseIf Npc(MapNpc(Index).Num).Boss = 3 Then
DrawPlayerNameText TexthDC, TextX - (NewPlayerX * PIC_X) - NewXOffset, TextY - (NewPlayerY * PIC_Y) - NewYOffset, Trim$("Level: " & .Level), vbRed
End If
End With
Else
With Npc(MapNpc(Index).Num)
'Draw name
TextX = MapNpc(Index).x * PIC_X + sx + MapNpc(Index).XOffset + CLng(PIC_X / 2) - ((Len(Trim$(.Name)) / 2) * 8)
TextY = MapNpc(Index).y * PIC_Y + sx + MapNpc(Index).YOffset - CLng(PIC_Y / 2) - 32
DrawPlayerNameText TexthDC, TextX - (NewPlayerX * PIC_X) - NewXOffset, TextY - (NewPlayerY * PIC_Y) - NewYOffset - 15, Trim$(.Name), vbWhite
If Npc(MapNpc(Index).Num).Boss = 1 Then
DrawPlayerNameText TexthDC, TextX - (NewPlayerX * PIC_X) - NewXOffset, TextY - (NewPlayerY * PIC_Y) - NewYOffset, Trim$("Level: " & .Level), vbCyan
ElseIf Npc(MapNpc(Index).Num).Boss = 2 Then
DrawPlayerNameText TexthDC, TextX - (NewPlayerX * PIC_X) - NewXOffset, TextY - (NewPlayerY * PIC_Y) - NewYOffset, Trim$("Level: " & .Level), RGB(227, 118, 27)
ElseIf Npc(MapNpc(Index).Num).Boss = 3 Then
DrawPlayerNameText TexthDC, TextX - (NewPlayerX * PIC_X) - NewXOffset, TextY - (NewPlayerY * PIC_Y) - NewYOffset, Trim$("Level: " & .Level), vbRed
End If
End With
End If
End Sub
Agora procure por "Type NpcRec" e troque ela por essa:
- Código:
Type NpcRec
Name As String * NAME_LENGTH
AttackSay As String * 100
Sprite As Long
SpawnSecs As Long
Behavior As Byte
Range As Byte
Level As Integer
Boss As Byte
STR As Long
DEF As Long
Speed As Long
MAGI As Long
Big As Long
MaxHP As Long
EXP As Long
SpawnTime As Long
Speech As Long
ItemNPC(1 To MAX_NPC_DROPS) As NPCEditorRec
End Type
Depois vá no seu "frmNpcEditor" e adicione o seguinte:
* 2 HScroll
* 2 Label
renomeio o "(Name)" de 1 label para "lblLevel" e o outro de "lblTipo", no Hscroll1 bote o seguinte código:
- Código:
lblLevel.Caption = HScroll1.Value
- Código:
If HScroll2.Value = 1 Then
lblTipo.Caption = "Normal"
ElseIf HScroll2.Value = 2 Then
lblTipo.Caption = "Mini-Boss"
ElseIf HScroll2.Value = 3 Then
lblTipo.Caption = "Boss"
End If
- Código:
Public Sub NpcEditorOk()
Npc(EditorIndex).Name = frmNpcEditor.txtName.Text
Npc(EditorIndex).AttackSay = frmNpcEditor.txtAttackSay.Text
Npc(EditorIndex).Sprite = frmNpcEditor.scrlSprite.Value
Npc(EditorIndex).SpawnSecs = Val(frmNpcEditor.txtSpawnSecs.Text)
Npc(EditorIndex).Behavior = frmNpcEditor.cmbBehavior.ListIndex
Npc(EditorIndex).Range = frmNpcEditor.scrlRange.Value
Npc(EditorIndex).STR = frmNpcEditor.txtfor.Text
Npc(EditorIndex).DEF = frmNpcEditor.txtdef.Text
Npc(EditorIndex).Speed = frmNpcEditor.txtagi.Text
Npc(EditorIndex).MAGI = frmNpcEditor.txtmagi.Text
Npc(EditorIndex).Big = frmNpcEditor.BigNpc.Value
Npc(EditorIndex).MaxHP = frmNpcEditor.txthp.Text
Npc(EditorIndex).EXP = frmNpcEditor.txtexp.Text
Npc(EditorIndex).Speech = frmNpcEditor.scrlSpeech.Value
Npc(EditorIndex).Boss = frmNpcEditor.HScroll2.Value
Npc(EditorIndex).Level = frmNpcEditor.HScroll1.Value
If frmNpcEditor.chkDay.Value = Checked And frmNpcEditor.chkNight.Value = Checked Then
Npc(EditorIndex).SpawnTime = 0
ElseIf frmNpcEditor.chkDay.Value = Checked And frmNpcEditor.chkNight.Value = Unchecked Then
Npc(EditorIndex).SpawnTime = 1
ElseIf frmNpcEditor.chkDay.Value = Unchecked And frmNpcEditor.chkNight.Value = Checked Then
Npc(EditorIndex).SpawnTime = 2
End If
Call SendSaveNpc(EditorIndex)
InNpcEditor = False
Unload frmNpcEditor
End Sub
Agora procure por "Public Sub NpcEditorInit()" e troque por essa:
- Código:
Public Sub NpcEditorInit()
frmNpcEditor.Picsprites.Picture = LoadPicture(App.Path & "\GFX\sprites.bmp")
frmNpcEditor.txtName.Text = Trim(Npc(EditorIndex).Name)
frmNpcEditor.txtAttackSay.Text = Trim(Npc(EditorIndex).AttackSay)
frmNpcEditor.scrlSprite.Value = Npc(EditorIndex).Sprite
frmNpcEditor.txtSpawnSecs.Text = STR(Npc(EditorIndex).SpawnSecs)
frmNpcEditor.cmbBehavior.ListIndex = Npc(EditorIndex).Behavior
If Npc(EditorIndex).Range = 0 Then Npc(EditorIndex).Range = 1
frmNpcEditor.scrlRange.Value = Npc(EditorIndex).Range
frmNpcEditor.txtfor.Text = Npc(EditorIndex).STR
frmNpcEditor.txtdef.Text = Npc(EditorIndex).DEF
frmNpcEditor.txtagi.Text = Npc(EditorIndex).Speed
frmNpcEditor.txtmagi.Text = Npc(EditorIndex).MAGI
frmNpcEditor.BigNpc.Value = Npc(EditorIndex).Big
frmNpcEditor.HScroll1.Value = Npc(EditorIndex).Level
frmNpcEditor.HScroll2.Value = Npc(EditorIndex).Boss
If Npc(EditorIndex).MaxHP = 0 Then
frmNpcEditor.txthp.Text = 1
Else
frmNpcEditor.txthp.Text = Npc(EditorIndex).MaxHP
End If
frmNpcEditor.txtexp.Text = Npc(EditorIndex).EXP
frmNpcEditor.txtChance.Text = STR(Npc(EditorIndex).ItemNPC(1).Chance)
frmNpcEditor.scrlNum.Value = Npc(EditorIndex).ItemNPC(1).ItemNum
frmNpcEditor.scrlValue.Value = Npc(EditorIndex).ItemNPC(1).ItemValue
frmNpcEditor.scrlSpeech.Value = Npc(EditorIndex).Speech
If Npc(EditorIndex).Speech > 0 Then
frmNpcEditor.lblSpeechName.Caption = Speech(Npc(EditorIndex).Speech).Name
Else
frmNpcEditor.lblSpeechName.Caption = vbNullString
End If
If Npc(EditorIndex).SpawnTime = 0 Then
frmNpcEditor.chkDay.Value = Checked
frmNpcEditor.chkNight.Value = Checked
ElseIf Npc(EditorIndex).SpawnTime = 1 Then
frmNpcEditor.chkDay.Value = Checked
frmNpcEditor.chkNight.Value = Unchecked
ElseIf Npc(EditorIndex).SpawnTime = 2 Then
frmNpcEditor.chkDay.Value = Unchecked
frmNpcEditor.chkNight.Value = Checked
End If
frmNpcEditor.Show vbModal
End Sub
Agora procure por "If (Parse(0) = "updatenpc") Then" e troque ele por esse:
- Código:
' :::::::::::::::::::::::
' :: Update npc packet ::
' :::::::::::::::::::::::
If (Parse(0) = "updatenpc") Then
n = Val(Parse(1))
' Update the npc
Npc(n).Name = Parse(2)
Npc(n).AttackSay = vbNullString
Npc(n).Sprite = Val(Parse(3))
Npc(n).SpawnSecs = 0
Npc(n).Behavior = 0
Npc(n).Range = 0
For I = 1 To MAX_NPC_DROPS
Npc(n).ItemNPC(I).Chance = 0
Npc(n).ItemNPC(I).ItemNum = 0
Npc(n).ItemNPC(I).ItemValue = 0
Next I
Npc(n).STR = 0
Npc(n).DEF = 0
Npc(n).Speed = 0
Npc(n).MAGI = 0
Npc(n).Big = Val(Parse(4))
Npc(n).MaxHP = Val(Parse(5))
Npc(n).EXP = 0
Npc(n).Speech = Val(Parse(6))
Npc(n).Level = Val(Parse(7))
Npc(n).Boss = Val(Parse(8))
Exit Sub
End If
Agora procure por "If (Parse(0) = "editnpc") Then" e troque por esse:
- Código:
If (Parse(0) = "editnpc") Then
n = Val(Parse(1))
' Update the npc
Npc(n).Name = Parse(2)
Npc(n).AttackSay = Parse(3)
Npc(n).Sprite = Val(Parse(4))
Npc(n).SpawnSecs = Val(Parse(5))
Npc(n).Behavior = Val(Parse(6))
Npc(n).Range = Val(Parse(7))
Npc(n).STR = Val(Parse(8))
Npc(n).DEF = Val(Parse(9))
Npc(n).Speed = Val(Parse(10))
Npc(n).MAGI = Val(Parse(11))
Npc(n).Big = Val(Parse(12))
Npc(n).MaxHP = Val(Parse(13))
Npc(n).EXP = Val(Parse(14))
Npc(n).SpawnTime = Val(Parse(15))
Npc(n).Speech = Val(Parse(16))
Npc(n).Level = Val(Parse(17))
Npc(n).Boss = Val(Parse(18))
z = 19
For I = 1 To MAX_NPC_DROPS
Npc(n).ItemNPC(I).Chance = Val(Parse(z))
Npc(n).ItemNPC(I).ItemNum = Val(Parse(z + 1))
Npc(n).ItemNPC(I).ItemValue = Val(Parse(z + 2))
z = z + 3
Next I
' Initialize the npc editor
Call NpcEditorInit
Exit Sub
End If
Agora va e procure por "Sub SendSaveNpc(ByVal NpcNum As Long)" e troque por essa:
- Código:
Sub SendSaveNpc(ByVal NpcNum As Long)
Dim Packet As String
Dim I As Long
Packet = "SAVENPC" & SEP_CHAR & NpcNum & SEP_CHAR & Trim(Npc(NpcNum).Name) & SEP_CHAR & Trim(Npc(NpcNum).AttackSay) & SEP_CHAR & Npc(NpcNum).Sprite & SEP_CHAR & Npc(NpcNum).SpawnSecs & SEP_CHAR & Npc(NpcNum).Behavior & SEP_CHAR & Npc(NpcNum).Range & SEP_CHAR & Npc(NpcNum).STR & SEP_CHAR & Npc(NpcNum).DEF & SEP_CHAR & Npc(NpcNum).Speed & SEP_CHAR & Npc(NpcNum).MAGI & SEP_CHAR & Npc(NpcNum).Big & SEP_CHAR & Npc(NpcNum).MaxHP & SEP_CHAR & Npc(NpcNum).EXP & SEP_CHAR & Npc(NpcNum).SpawnTime & SEP_CHAR & Npc(NpcNum).Speech & SEP_CHAR & Npc(NpcNum).Level & SEP_CHAR & Npc(NpcNum).Boss & SEP_CHAR
For I = 1 To MAX_NPC_DROPS
Packet = Packet & Npc(NpcNum).ItemNPC(I).Chance
Packet = Packet & SEP_CHAR & Npc(NpcNum).ItemNPC(I).ItemNum
Packet = Packet & SEP_CHAR & Npc(NpcNum).ItemNPC(I).ItemValue & SEP_CHAR
Next I
Packet = Packet & END_CHAR
Call SendData(Packet)
End Sub
Bom a parte do Client-Side termino(eu acho ), agora vamos para o ServerSide.
~~ServerSide~~
Vá e procure por "Type NpcRec" e troque ele por esse:
- Código:
Type NpcRec
Name As String * NAME_LENGTH
AttackSay As String * 100
Sprite As Long
SpawnSecs As Long
Behavior As Byte
Level As Integer
Boss As Byte
Range As Byte
STR As Long
DEF As Long
Speed As Long
Magi As Long
Big As Long
MaxHp As Long
Exp As Long
SpawnTime As Long
Speech As Long
ItemNPC(1 To MAX_NPC_DROPS) As NPCEditorRec
End Type
Continuando(ta chato t.t) procure por "Case "savenpc" " e troque por esse:
- Código:
Case "savenpc"
' Proteção
If GetPlayerAccess(Index) < ADMIN_DEVELOPER Then
Call HackingAttempt(Index, "Admin Cloning")
Exit Sub
End If
N = Val(Parse(1))
' Proteção
If N < 0 Or N > MAX_NPCS Then
Call HackingAttempt(Index, "NPC Inválido")
Exit Sub
End If
' Update the npc
Npc(N).Name = Parse(2)
Npc(N).AttackSay = Parse(3)
Npc(N).Sprite = Val(Parse(4))
Npc(N).SpawnSecs = Val(Parse(5))
Npc(N).Behavior = Val(Parse(6))
Npc(N).Range = Val(Parse(7))
Npc(N).STR = Val(Parse(8))
Npc(N).DEF = Val(Parse(9))
Npc(N).Speed = Val(Parse(10))
Npc(N).Magi = Val(Parse(11))
Npc(N).Big = Val(Parse(12))
Npc(N).MaxHp = Val(Parse(13))
Npc(N).Exp = Val(Parse(14))
Npc(N).SpawnTime = Val(Parse(15))
Npc(N).Speech = Val(Parse(16))
Npc(N).Level = Val(Parse(17))
Npc(N).Boss = Val(Parse(18))
z = 19
For i = 1 To MAX_NPC_DROPS
Npc(N).ItemNPC(i).Chance = Val(Parse(z))
Npc(N).ItemNPC(i).ItemNum = Val(Parse(z + 1))
Npc(N).ItemNPC(i).ItemValue = Val(Parse(z + 2))
z = z + 3
Next
' Salvar
Call SendUpdateNpcToAll(N)
Call SaveNpc(N)
Call AddLog(GetPlayerName(Index) & " salvou NPC #" & N & ".", ADMIN_LOG)
Exit Sub
Agora vá e ache "Sub SendEditNpcTo(ByVal Index As Long, ByVal NpcNum As Long)" e troque por esse:
- Código:
Sub SendEditNpcTo(ByVal Index As Long, ByVal NpcNum As Long)
Dim Packet As String
Dim i As Long
'Packet = "EDITNPC" & SEP_CHAR & NpcNum & SEP_CHAR & Trim$(Npc(NpcNum).Name) & SEP_CHAR & Trim$(Npc(NpcNum).AttackSay) & SEP_CHAR & Npc(NpcNum).Sprite & SEP_CHAR & Npc(NpcNum).SpawnSecs & SEP_CHAR & Npc(NpcNum).Behavior & SEP_CHAR & Npc(NpcNum).Range & SEP_CHAR
'Packet = Packet & Npc(NpcNum).DropChance & SEP_CHAR & Npc(NpcNum).DropItem & SEP_CHAR & Npc(NpcNum).DropItemValue & SEP_CHAR & Npc(NpcNum).str & SEP_CHAR & Npc(NpcNum).DEF & SEP_CHAR & Npc(NpcNum).SPEED & SEP_CHAR & Npc(NpcNum).MAGI & SEP_CHAR & Npc(NpcNum).Big & SEP_CHAR & Npc(NpcNum).MaxHp & SEP_CHAR & Npc(NpcNum).Exp & END_CHAR
Packet = "EDITNPC" & SEP_CHAR & NpcNum & SEP_CHAR & Trim$(Npc(NpcNum).Name) & SEP_CHAR & Trim$(Npc(NpcNum).AttackSay) & SEP_CHAR & Npc(NpcNum).Sprite & SEP_CHAR & Npc(NpcNum).SpawnSecs & SEP_CHAR & Npc(NpcNum).Behavior & SEP_CHAR & Npc(NpcNum).Range & SEP_CHAR & Npc(NpcNum).STR & SEP_CHAR & Npc(NpcNum).DEF & SEP_CHAR & Npc(NpcNum).Speed & SEP_CHAR & Npc(NpcNum).Magi & SEP_CHAR & Npc(NpcNum).Big & SEP_CHAR & Npc(NpcNum).MaxHp & SEP_CHAR & Npc(NpcNum).Exp & SEP_CHAR & Npc(NpcNum).SpawnTime & SEP_CHAR & Npc(NpcNum).Speech & SEP_CHAR & Npc(NpcNum).Level & SEP_CHAR & Npc(NpcNum).Boss & SEP_CHAR
For i = 1 To MAX_NPC_DROPS
Packet = Packet & Npc(NpcNum).ItemNPC(i).Chance
Packet = Packet & SEP_CHAR & Npc(NpcNum).ItemNPC(i).ItemNum
Packet = Packet & SEP_CHAR & Npc(NpcNum).ItemNPC(i).ItemValue & SEP_CHAR
Next
Packet = Packet & END_CHAR
Call SendDataTo(Index, Packet)
End Sub
Também ache : "Sub SendUpdateNpcTo(ByVal Index As Long, ByVal NpcNum As Long)" e troque por esse:
- Código:
Sub SendUpdateNpcTo(ByVal Index As Long, ByVal NpcNum As Long)
Dim Packet As String
Packet = "UPDATENPC" & SEP_CHAR & NpcNum & SEP_CHAR & Trim$(Npc(NpcNum).Name) & SEP_CHAR & Npc(NpcNum).Sprite & SEP_CHAR & Npc(NpcNum).Big & SEP_CHAR & Npc(NpcNum).MaxHp & SEP_CHAR & Npc(NpcNum).Speech & SEP_CHAR & Npc(NpcNum).Level & SEP_CHAR & Npc(NpcNum).Boss & END_CHAR
Call SendDataTo(Index, Packet)
End Sub
em baixo tem "
Sub SendUpdateNpcToAll(ByVal NpcNum As Long)" e troque por esse:
- Código:
Sub SendUpdateNpcToAll(ByVal NpcNum As Long)
Dim Packet As String
Packet = "UPDATENPC" & SEP_CHAR & NpcNum & SEP_CHAR & Trim$(Npc(NpcNum).Name) & SEP_CHAR & Npc(NpcNum).Sprite & SEP_CHAR & Npc(NpcNum).Big & SEP_CHAR & Npc(NpcNum).MaxHp & SEP_CHAR & Npc(NpcNum).Speech & SEP_CHAR & Npc(NpcNum).Level & SEP_CHAR & Npc(NpcNum).Boss & END_CHAR
Call SendDataToAll(Packet)
End Sub
Pronto, seu level npc está pronto(eu acho), lembrando que essa é a Rev 0.1b, então se ouver algum erro ou coisa do tipo avise ai, que eu irei concerta...
Obs:
1º Não venha dizer que não funciona se você não fez até o final.
2º Só vó responder dúvidas(deu esse erro aqui) se tiver imagem.
3º Créditos: OmegaZero(Mythos)
Perdão pelos erros de Português ~~