Set MP Required (Mana Points need to use the spell)
Difficultly: 1/5
*UPDATED* Fixed the bug, where it adds on the spell level, it was an easy fix, but i thought i'd update the tut as well..
Ok, this is my first tutorial, and i was looking around in the wishes forum, and saw some guy wanting this, im assuming he cant do it himself because he was wishing it, so here is a tut i made to help those who want this function. Oh yeah, i added this in and wrote this tutorial on the fly, i thought it would have been much easier. :D so it is probably really buggy.. but if you have any problems, just post here..
::Client Side::
First, go into frmSpellEditor and make a new text box anywhere you want and name it:
txtMPReq
Second, go into modTypes and find:
Type SpellRec
And add this:
MPReq As Long
Underneath:
Data3 As Integer
Third, go into modGameLogic and find:
Public Sub SpellEditorInit()
And make it look like this:
Public Sub SpellEditorInit() On Error Resume Next
Dim i As Long
frmSpellEditor.cmbClassReq.AddItem "All Classes" For i = 0 To Max_Classes frmSpellEditor.cmbClassReq.AddItem Trim(Class(i).Name) Next i frmSpellEditor.txtName.Text = Trim(Spell(EditorIndex).Name) frmSpellEditor.cmbClassReq.ListIndex = Spell(EditorIndex).ClassReq frmSpellEditor.scrlLevelReq.Value = Spell(EditorIndex).LevelReq frmSpellEditor.cmbType.ListIndex = Spell(EditorIndex).Type If Spell(EditorIndex).Type <> SPELL_TYPE_GIVEITEM Then frmSpellEditor.fraVitals.Visible = True frmSpellEditor.fraGiveItem.Visible = False frmSpellEditor.scrlVitalMod.Value = Spell(EditorIndex).Data1 Else frmSpellEditor.fraVitals.Visible = False frmSpellEditor.fraGiveItem.Visible = True frmSpellEditor.scrlItemNum.Value = Spell(EditorIndex).Data1 frmSpellEditor.scrlItemValue.Value = Spell(EditorIndex).Data2 End If frmSpellEditor.txtMPReq.Text = Spell(EditorIndex).MPReq frmSpellEditor.Show vbModal End Sub
Now find:
Public Sub SpellEditorOk()
And make it look like this:
Public Sub SpellEditorOk() Spell(EditorIndex).Name = frmSpellEditor.txtName.Text Spell(EditorIndex).ClassReq = frmSpellEditor.cmbClassReq.ListIndex Spell(EditorIndex).LevelReq = frmSpellEditor.scrlLevelReq.Value Spell(EditorIndex).Type = frmSpellEditor.cmbType.ListIndex If Spell(EditorIndex).Type <> SPELL_TYPE_GIVEITEM Then Spell(EditorIndex).Data1 = frmSpellEditor.scrlVitalMod.Value Else Spell(EditorIndex).Data1 = frmSpellEditor.scrlItemNum.Value Spell(EditorIndex).Data2 = frmSpellEditor.scrlItemValue.Value End If Spell(EditorIndex).Data3 = 0 Spell(EditorIndex).MPReq = frmSpellEditor.txtMPReq.Text Call SendSaveSpell(EditorIndex) InSpellEditor = False Unload frmSpellEditor End Sub
Open up modClientTCP, and find:
' ::::::::::::::::::::::: ' :: Edit spell packet :: <- Used for spell editor admins only ' :::::::::::::::::::::::
And add:
Spell(n).MPReq = Val(Parse(9))
Underneath:
Spell(n).Data3 = Val(Parse(8))
So it looks like:
' ::::::::::::::::::::::: ' :: Edit spell packet :: <- Used for spell editor admins only ' ::::::::::::::::::::::: If (LCase(Parse(0)) = "editspell") Then n = Val(Parse(1)) ' Update the spell Spell(n).Name = Parse(2) Spell(n).ClassReq = Val(Parse(3)) Spell(n).LevelReq = Val(Parse(4)) Spell(n).Type = Val(Parse(5)) Spell(n).Data1 = Val(Parse(6)) Spell(n).Data2 = Val(Parse(7)) Spell(n).Data3 = Val(Parse(8)) Spell(n).MPReq = Val(Parse(9)) ' Initialize the spell editor Call SpellEditorInit
Exit Sub End If
Now find:
Sub SendSaveSpell(ByVal SpellNum As Long)
And make it looks like this:
Sub SendSaveSpell(ByVal SpellNum As Long) Dim Packet As String
Packet = "SAVESPELL" & SEP_CHAR & SpellNum & SEP_CHAR & Trim(Spell(SpellNum).Name) & SEP_CHAR & Spell(SpellNum).ClassReq & SEP_CHAR & Spell(SpellNum).LevelReq & SEP_CHAR & Spell(SpellNum).Type & SEP_CHAR & Spell(SpellNum).Data1 & SEP_CHAR & Spell(SpellNum).Data2 & SEP_CHAR & Spell(SpellNum).Data3 & SEP_CHAR & Spell(SpellNum).MPReq & SEP_CHAR & END_CHAR Call SendData(Packet) End Sub
Now, that is all for the Client Side of things.. hehe.. :P On too Server Side :D
Open modTypes (Remember Server Side) and find:
Type SpellRec
Then make it look like this:
Type SpellRec Name As String * NAME_LENGTH ClassReq As Byte LevelReq As Byte Type As Byte Data1 As Integer Data2 As Integer Data3 As Integer MPReq As Long End Type
Now find:
Sub ClearSpell(ByVal Index As Long)
And make it look like this:
Sub ClearSpell(ByVal Index As Long) Spell(Index).Name = "" Spell(Index).ClassReq = 0 Spell(Index).LevelReq = 0 Spell(Index).Type = 0 Spell(Index).Data1 = 0 Spell(Index).Data2 = 0 Spell(Index).Data3 = 0 Spell(Index).MPReq = 0 End Sub
Now go into modGameLogic, and find:
i = GetSpellReqLevel(Index, SpellNum)
And make that line of code look like this:
' amount of mp taken away from max mp after using a spell i = GetSpellReqLevel(Index, SpellNum) MPReq = (Spell(SpellNum).MPReq)
Now go into modServerTCP, and find:
Sub SendEditSpellTo(ByVal Index As Long, ByVal SpellNum As Long)
And make that whole section look like this:
Sub SendEditSpellTo(ByVal Index As Long, ByVal SpellNum As Long) Dim Packet As String
Packet = "EDITSPELL" & SEP_CHAR & SpellNum & SEP_CHAR & Trim(Spell(SpellNum).Name) & SEP_CHAR & Spell(SpellNum).ClassReq & SEP_CHAR & Spell(SpellNum).LevelReq & SEP_CHAR & Spell(SpellNum).Type & SEP_CHAR & Spell(SpellNum).Data1 & SEP_CHAR & Spell(SpellNum).Data2 & SEP_CHAR & Spell(SpellNum).Data3 & SEP_CHAR & Spell(SpellNum).MPReq & SEP_CHAR & END_CHAR Call SendDataTo(Index, Packet) End Sub
Now go into modDatabase, and find:
Sub SaveSpell(ByVal SpellNum As Long)
And make that look like this:
Sub SaveSpell(ByVal SpellNum As Long) Dim FileName As String Dim i As Long
FileName = App.Path & "\spells.ini" Call PutVar(FileName, "SPELL" & SpellNum, "Name", Trim(Spell(SpellNum).Name)) Call PutVar(FileName, "SPELL" & SpellNum, "ClassReq", Trim(Spell(SpellNum).ClassReq)) Call PutVar(FileName, "SPELL" & SpellNum, "Type", Trim(Spell(SpellNum).Type)) Call PutVar(FileName, "SPELL" & SpellNum, "Data1", Trim(Spell(SpellNum).Data1)) Call PutVar(FileName, "SPELL" & SpellNum, "Data2", Trim(Spell(SpellNum).Data2)) Call PutVar(FileName, "SPELL" & SpellNum, "Data3", Trim(Spell(SpellNum).Data3)) Call PutVar(FileName, "SPELL" & SpellNum, "MPReq", Trim(Spell(SpellNum).MPReq)) End Sub
Now find:
Sub LoadSpells()
And make it look like this:
Sub LoadSpells() Dim FileName As String Dim i As Long
Call CheckSpells FileName = App.Path & "\spells.ini" For i = 1 To MAX_SPELLS Spell(i).Name = GetVar(FileName, "SPELL" & i, "Name") Spell(i).ClassReq = Val(GetVar(FileName, "SPELL" & i, "ClassReq")) Spell(i).Type = Val(GetVar(FileName, "SPELL" & i, "Type")) Spell(i).Data1 = Val(GetVar(FileName, "SPELL" & i, "Data1")) Spell(i).Data2 = Val(GetVar(FileName, "SPELL" & i, "Data2")) Spell(i).Data3 = Val(GetVar(FileName, "SPELL" & i, "Data3")) Spell(i).MPReq = Val(GetVar(FileName, "SPELL" & i, "MPReq")) DoEvents Next i End Sub
AND THAT IS IT!!! WOAH, that took me ages.. and i dont even know why.. haha.. well its hell easy, but
that is just for those who dont know how to do it.. hope there arent too many bugs.. tell me how my
first tutorial was.. :P
|