02-06-2006, 07:21 PM
Author: grimsk8ter11
Difficulty: 1/5
:: SERVER SIDE ::
In modTypes, fin:
Beneath, add:
Find Sub ClearNPC(ByVal Index As Long), replace it with:
In modGameLogic, find:Change it to:
In modHandleData, find:Replace with:
Find:Replace with:
Find "Sub SaveNpc(ByVal NpcNum As Long)" in modDatabase. Replace it with:
Find:
Replace with:
Find:
Replace with:
:: CLIENT SIDE ::
In frmNpcEditor, delete the labels next to Start HP and EXP Given (the ones that show their values). Next, open the code and find these:
Make them look like this:In modTypes, find:
Add these somewhere in there:In modGameLogic, find:Repalce with:
Find:Replace with:
In modClientTCP, find:
Replace with:
Find
partial code)
Repalce with:
Find
partial code)[code] ' :::::::::::::::::::::
' :: Edit npc packet ::
Difficulty: 1/5
:: SERVER SIDE ::
In modTypes, fin:
Code:
Type NpcRec
Beneath, add:
Code:
MaxHP As Long
GiveEXP As Long
Find Sub ClearNPC(ByVal Index As Long), replace it with:
Code:
Sub ClearNpc(ByVal Index As Long)
Npc(Index).Name = ""
Npc(Index).AttackSay = ""
Npc(Index).Sprite = 0
Npc(Index).SpawnSecs = 0
Npc(Index).Behavior = 0
Npc(Index).Range = 0
Npc(Index).DropChance = 0
Npc(Index).DropItem = 0
Npc(Index).DropItemValue = 0
Npc(Index).STR = 0
Npc(Index).DEF = 0
Npc(Index).SPEED = 0
Npc(Index).MAGI = 0
Npc(Index).MaxHP = 0
Npc(Index).GiveEXP = 0
End Sub
In modGameLogic, find:
Code:
' Calculate exp to give attacker
Code:
' Calculate exp to give attacker
Exp = Npc(NpcNum).GiveEXP
In modHandleData, find:
Code:
Save NPC Packet
Code:
' :::::::::::::::::::::
' :: Save npc packet ::
' :::::::::::::::::::::
If LCase(Parse(0)) = "savenpc" Then
' Prevent hacking
If GetPlayerAccess(Index) < ADMIN_DEVELOPER Then
Call HackingAttempt(Index, "Admin Cloning")
Exit Sub
End If
N = Val(Parse(1))
' Prevent hacking
If N < 0 Or N > MAX_NPCS Then
Call HackingAttempt(Index, "Invalid NPC Index")
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).DropChance = Val(Parse(8))
Npc(N).DropItem = Val(Parse(9))
Npc(N).DropItemValue = Val(Parse(10))
Npc(N).STR = Val(Parse(11))
Npc(N).DEF = Val(Parse(12))
Npc(N).SPEED = Val(Parse(13))
Npc(N).MAGI = Val(Parse(14))
Npc(N).MaxHP = Val(Parse(15))
Npc(N).GiveEXP = Val(Parse(16))
' Save it
Call SendUpdateNpcToAll(N)
Call SaveNpc(N)
Call AddLog(GetPlayerName(Index) & " saved npc #" & N & ".", ADMIN_LOG)
Exit Sub
End If
Find:
Code:
Sub SendEditNpcTo(ByVal Index As Long, ByVal NpcNum As Long)
Code:
Sub SendEditNpcTo(ByVal Index As Long, ByVal NpcNum As Long)
Dim Packet As String
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).MaxHP & SEP_CHAR & Npc(NpcNum).GiveEXP & SEP_CHAR & Npc(NpcNum).Behavior & SEP_CHAR & Npc(NpcNum).Range & SEP_CHAR & 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 & END_CHAR
Call SendDataTo(Index, Packet)
End Sub
Find "Sub SaveNpc(ByVal NpcNum As Long)" in modDatabase. Replace it with:
Code:
Sub SaveNpc(ByVal NpcNum As Long)
Dim FileName As String
FileName = App.Path & "\npcs.ini"
Call PutVar(FileName, "NPC" & NpcNum, "Name", Trim(Npc(NpcNum).Name))
Call PutVar(FileName, "NPC" & NpcNum, "AttackSay", Trim(Npc(NpcNum).AttackSay))
Call PutVar(FileName, "NPC" & NpcNum, "Sprite", Trim(Npc(NpcNum).Sprite))
Call PutVar(FileName, "NPC" & NpcNum, "SpawnSecs", Trim(Npc(NpcNum).SpawnSecs))
Call PutVar(FileName, "NPC" & NpcNum, "Behavior", Trim(Npc(NpcNum).Behavior))
Call PutVar(FileName, "NPC" & NpcNum, "MaxHP", Trim(Npc(NpcNum).MaxHP))
Call PutVar(FileName, "NPC" & NpcNum, "GiveEXP", Trim(Npc(NpcNum).GiveEXP))
Call PutVar(FileName, "NPC" & NpcNum, "Range", Trim(Npc(NpcNum).Range))
Call PutVar(FileName, "NPC" & NpcNum, "DropChance", Trim(Npc(NpcNum).DropChance))
Call PutVar(FileName, "NPC" & NpcNum, "DropItem", Trim(Npc(NpcNum).DropItem))
Call PutVar(FileName, "NPC" & NpcNum, "DropItemValue", Trim(Npc(NpcNum).DropItemValue))
Call PutVar(FileName, "NPC" & NpcNum, "STR", Trim(Npc(NpcNum).STR))
Call PutVar(FileName, "NPC" & NpcNum, "DEF", Trim(Npc(NpcNum).DEF))
Call PutVar(FileName, "NPC" & NpcNum, "SPEED", Trim(Npc(NpcNum).SPEED))
Call PutVar(FileName, "NPC" & NpcNum, "MAGI", Trim(Npc(NpcNum).MAGI))
End Sub
Find:
Code:
Sub LoadNpcs()
Replace with:
Code:
Sub LoadNpcs()
On Error Resume Next
Dim FileName As String
Dim I As Long
Call CheckNpcs
FileName = App.Path & "\npcs.ini"
For I = 1 To MAX_NPCS
Call SetStatus("Loading NPCs " & I & "/" & MAX_NPCS & " : " & (I / MAX_NPCS) * 100 & "%")
frmLoad.pbarLoad.Min = I
frmLoad.pbarLoad.Max = MAX_NPCS
Npc(I).Name = GetVar(FileName, "NPC" & I, "Name")
Npc(I).AttackSay = GetVar(FileName, "NPC" & I, "AttackSay")
Npc(I).Sprite = GetVar(FileName, "NPC" & I, "Sprite")
Npc(I).SpawnSecs = GetVar(FileName, "NPC" & I, "SpawnSecs")
Npc(I).Behavior = GetVar(FileName, "NPC" & I, "Behavior")
Npc(I).Range = GetVar(FileName, "NPC" & I, "Range")
Npc(I).DropChance = GetVar(FileName, "NPC" & I, "DropChance")
Npc(I).DropItem = GetVar(FileName, "NPC" & I, "DropItem")
Npc(I).DropItemValue = GetVar(FileName, "NPC" & I, "DropItemValue")
Npc(I).STR = GetVar(FileName, "NPC" & I, "STR")
Npc(I).DEF = GetVar(FileName, "NPC" & I, "DEF")
Npc(I).SPEED = GetVar(FileName, "NPC" & I, "SPEED")
Npc(I).MAGI = GetVar(FileName, "NPC" & I, "MAGI")
Npc(I).MaxHP = GetVar(FileName, "NPC" & I, "MaxHP")
Npc(I).GiveEXP = GetVar(FileName, "NPC" & I, "GiveEXP")
DoEvents
Next I
End Sub
Find:
Code:
Function GetNpcMaxHP(ByVal NpcNum As Long)
Replace with:
Code:
Function GetNpcMaxHP(ByVal NpcNum As Long)
' Prevent subscript out of range
If NpcNum MAX_NPCS Then
GetNpcMaxHP = 0
Exit Function
End If
GetNpcMaxHP = Npc(NpcNum).MaxHP
End Function
:: CLIENT SIDE ::
In frmNpcEditor, delete the labels next to Start HP and EXP Given (the ones that show their values). Next, open the code and find these:
Code:
Private Sub scrlSTR_Change()
Code:
Private Sub scrlDEF_Change()
Make them look like this:
Code:
Private Sub scrlSTR_Change()
lblSTR.Caption = STR(scrlSTR.Value)
End Sub
Private Sub scrlDEF_Change()
lblDEF.Caption = STR(scrlDEF.Value)
End Sub
Code:
Type NpcRec
Add these somewhere in there:
Code:
MaxHP As Long
GiveEXP As Long
Code:
Public Sub NpcEditorInit()
Code:
Public Sub NpcEditorInit()
On Error Resume Next
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
frmNpcEditor.scrlRange.Value = Npc(EditorIndex).Range
frmNpcEditor.txtChance.Text = STR(Npc(EditorIndex).DropChance)
frmNpcEditor.scrlNum.Value = Npc(EditorIndex).DropItem
frmNpcEditor.scrlValue.Value = Npc(EditorIndex).DropItemValue
frmNpcEditor.scrlSTR.Value = Npc(EditorIndex).STR
frmNpcEditor.scrlDEF.Value = Npc(EditorIndex).DEF
frmNpcEditor.scrlSPEED.Value = Npc(EditorIndex).SPEED
frmNpcEditor.scrlMAGI.Value = Npc(EditorIndex).MAGI
frmNpcEditor.txtMaxHP.Text = Trim(Npc(EditorIndex).MaxHP)
frmNpcEditor.txtGiveEXP.Text = Trim(Npc(EditorIndex).GiveEXP)
frmNpcEditor.Show vbModal
End Sub
Find:
Code:
Public Sub NpcEditorOk()
Code:
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).DropChance = Val(frmNpcEditor.txtChance.Text)
Npc(EditorIndex).DropItem = frmNpcEditor.scrlNum.Value
Npc(EditorIndex).DropItemValue = frmNpcEditor.scrlValue.Value
Npc(EditorIndex).STR = frmNpcEditor.scrlSTR.Value
Npc(EditorIndex).DEF = frmNpcEditor.scrlDEF.Value
Npc(EditorIndex).SPEED = frmNpcEditor.scrlSPEED.Value
Npc(EditorIndex).MAGI = frmNpcEditor.scrlMAGI.Value
Npc(EditorIndex).MaxHP = frmNpcEditor.txtMaxHP.Text
Npc(EditorIndex).GiveEXP = frmNpcEditor.txtGiveEXP.Text
Call SendSaveNpc(EditorIndex)
InNpcEditor = False
Unload frmNpcEditor
End Sub
In modClientTCP, find:
Code:
Sub SendSaveNpc(ByVal NpcNum As Long)
Replace with:
Code:
Sub SendSaveNpc(ByVal NpcNum As Long)
Dim Packet As String
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).MaxHP & SEP_CHAR & Npc(NpcNum).GiveEXP & SEPCHAR & Npc(NpcNum).Behavior & SEP_CHAR & Npc(NpcNum).Range & SEP_CHAR & 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 & END_CHAR
Call SendData(Packet)
End Sub
Find

Code:
' :::::::::::::::::::::::
' :: Update npc packet ::
' :::::::::::::::::::::::
Repalce with:
Code:
' :::::::::::::::::::::::
' :: Update npc packet ::
' :::::::::::::::::::::::
If (LCase(Parse(0)) = "updatenpc") Then
n = Val(Parse(1))
' Update the item
Npc(n).Name = Parse(2)
Npc(n).AttackSay = ""
Npc(n).Sprite = Val(Parse(3))
Npc(n).SpawnSecs = 0
Npc(n).Behavior = 0
Npc(n).Range = 0
Npc(n).DropChance = 0
Npc(n).DropItem = 0
Npc(n).DropItemValue = 0
Npc(n).STR = 0
Npc(n).DEF = 0
Npc(n).SPEED = 0
Npc(n).MAGI = 0
Npc(n).MaxHP = 0
Npc(n).GiveEXP = 0
Exit Sub
End If
Find

' :: Edit npc packet ::