Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
My Race System
#1
Well I basically copied the Class system & modified it so it's Races instead. But I don't know how to make it so it says the Race on the Character Selection Screen. & For some reason I am now unable to login.(Should be too do with the Race system?)

Here's the whole Race script:

CLIENTSIDE
Code:
--- modClientTCP ---
Sub SendAddChar(ByVal Name As String, ByVal Sex As Long, ByVal ClassNum As Long, ByVal Slot As Long) ' ByVal RaceNum As Long) Unblock this & I get errors
Dim Packet As String

    Packet = CAddChar & SEP_CHAR & Trim$(Name) & SEP_CHAR & Sex & SEP_CHAR & ClassNum & SEP_CHAR & Slot & END_CHAR ' & SEP_CHAR & RaceNum & END_CHAR Unblock this & I get errors
    Call SendData(Packet)
End Sub

Sub SendGetRaces()
Dim Packet As String

    Packet = CGetRaces & END_CHAR
    Call SendData(Packet)
End Sub

Public Sub SendSaveSpell(ByVal SpellNum As Long)
Dim Packet As String

    With Spell(SpellNum)
        Packet = CSaveSpell & SEP_CHAR & SpellNum & SEP_CHAR & Trim$(.Name) & SEP_CHAR & .ClassReq & SEP_CHAR & .RaceReq & SEP_CHAR & .LevelReq & SEP_CHAR & .Type & SEP_CHAR & .Data1 & SEP_CHAR & .Data2 & SEP_CHAR & .Data3 & END_CHAR
    End With
    
    Call SendData(Packet)
End Sub

Code:
--- modDatabase ---
Function GetPlayerRace(ByVal Index As Long) As Long
    GetPlayerRace = Player(Index).Race
End Function

Sub SetPlayerRace(ByVal Index As Long, ByVal RaceNum As Long)
    Player(Index).Race = RaceNum
End Sub

Code:
--- modEnumerations ---
CGetRaces

Code:
--- modGameEditors ---
Public Sub SpellEditorInit()
Dim i As Long

    frmSpellEditor.cmbClassReq.AddItem "All Classes"
    For i = 1 To Max_Classes
        frmSpellEditor.cmbClassReq.AddItem Trim$(Class(i).Name)
    Next i
    
    frmSpellEditor.cmbRaceReq.AddItem "All Races"
    For i = 1 To Max_Races
        frmSpellEditor.cmbRaceReq.AddItem Trim$(Race(i).Name)
    Next i
    
    frmSpellEditor.txtName.Text = Trim$(Spell(EditorIndex).Name)
    frmSpellEditor.cmbClassReq.ListIndex = Spell(EditorIndex).ClassReq
    frmSpellEditor.cmbRaceReq.ListIndex = Spell(EditorIndex).RaceReq
    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.Show vbModal
End Sub

Public Sub SpellEditorOk()
    Spell(EditorIndex).Name = frmSpellEditor.txtName.Text
    Spell(EditorIndex).ClassReq = frmSpellEditor.cmbClassReq.ListIndex
    Spell(EditorIndex).RaceReq = frmSpellEditor.cmbRaceReq.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
    
    Call SendSaveSpell(EditorIndex)
    InSpellEditor = False
    Unload frmSpellEditor
End Sub

Code:
--- modGlobals ---
' Maximum races
Public Max_Races As Byte

Code:
--- modHandleData ---
        ' :::::::::::::::::::::::::::::::::::::::
        ' ::  New character races data packet  ::
        ' :::::::::::::::::::::::::::::::::::::::
        Case "newcharraces"
            n = 1
            
            ' Max races
            Max_Races = Val(Parse(n))
            ReDim Race(1 To Max_Races) As RaceRec

            n = n + 1

            For i = 1 To Max_Races
                Race(i).Name = Parse(n)
                
                n = n + 1
            Next i
            
            ' Used for if the player is creating a new character
            frmNewChar.Visible = True
            frmSendGetData.Visible = False
    
            frmNewChar.cmbRace.Clear
    
            For i = 1 To Max_Races
                frmNewChar.cmbRace.AddItem Trim$(Race(i).Name)
            Next i
                

            frmNewChar.cmbRace.ListIndex = 0
            
            n = frmNewChar.cmbRace.ListIndex + 1
            
            Exit Sub
        
        ' :::::::::::::::::::::::::
        ' ::  Races data packet  ::
        ' :::::::::::::::::::::::::
        Case "racesdata"
            n = 1
            
            ' Max races
            Max_Races = Val(Parse(n))
            ReDim Race(1 To Max_Races) As RaceRec
            
            n = n + 1
            
            For i = 1 To Max_Races
                Race(i).Name = Parse(n)
                
                n = n + 1
            Next i
            Exit Sub

        Case "editspell"
            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).RaceReq = Val(Parse(9))
                            
            ' Initialize the spell editor
            Call SpellEditorInit
    
            Exit Sub

Code:
--- modTypes---
Public Race() As RaceRec

Type PlayerRec
    ' General
    Name As String * NAME_LENGTH
    Class As Byte
    Race As Byte
    Sprite As Integer
    Level As Byte
    Exp As Long
    Access As Byte
    PK As Byte

Type RaceRec
    Name As String * NAME_LENGTH
End Type

Type SpellRec
    Name As String * NAME_LENGTH
    ClassReq As Byte
    RaceReq As Byte
    LevelReq As Byte
    Type As Byte
    Data1 As Integer
    Data2 As Integer
    Data3 As Integer
End Type

SERVERSIDE

Code:
--- modDatabase ---
Sub AddChar(ByVal Index As Long, ByVal Name As String, ByVal Sex As Byte, ByVal ClassNum As Byte, ByVal CharNum As Long, ByVal RaceNum As Byte)
Dim f As Long
Dim n As Long

    If LenB(Trim$(Player(Index).Char(CharNum).Name)) = 0 Then
        TempPlayer(Index).CharNum = CharNum
        
        Player(Index).Char(CharNum).Name = Name
        Player(Index).Char(CharNum).Sex = Sex
        Player(Index).Char(CharNum).Class = ClassNum
        Player(Index).Char(CharNum).Race = RaceNum
        
        If Player(Index).Char(CharNum).Sex = SEX_MALE Then
            Player(Index).Char(CharNum).Sprite = Class(ClassNum).Sprite
        Else
            Player(Index).Char(CharNum).Sprite = Class(ClassNum).Sprite
        End If
        
        Player(Index).Char(CharNum).Level = 1

        For n = 1 To Stats.Stat_Count - 1
            Player(Index).Char(CharNum).Stat(n) = Class(ClassNum).Stat(n)
        Next n
        
        Player(Index).Char(CharNum).Map = START_MAP
        Player(Index).Char(CharNum).x = START_X
        Player(Index).Char(CharNum).y = START_Y
            
        Player(Index).Char(CharNum).Vital(Vitals.HP) = GetPlayerMaxVital(Index, Vitals.HP)
        Player(Index).Char(CharNum).Vital(Vitals.MP) = GetPlayerMaxVital(Index, Vitals.MP)
        Player(Index).Char(CharNum).Vital(Vitals.SP) = GetPlayerMaxVital(Index, Vitals.SP)
                
        ' Append name to file
        f = FreeFile
        Open App.Path & "\accounts\charlist.txt" For Append As #f
            Print #f, Name
        Close #f
        
        Call SavePlayer(Index)
            
        Exit Sub
    End If
End Sub

' *************
' **  Races  **
' *************

Public Sub CreateRacesINI()
Dim FileName As String
Dim File As String

    FileName = App.Path & "\data\races.ini"
    
    Max_Races = 4
    
    If Not FileExist(FileName, True) Then
        File = FreeFile
    
        Open FileName For Output As File
            Print #File, "[INIT]"
            Print #File, "MaxRaces=" & Max_Races
        Close File
    End If

End Sub

Sub LoadRaces()
Dim FileName As String
Dim i As Long

    If CheckRaces Then
        ReDim Race(1 To Max_Races) As RaceRec
        Call SaveRaces
    Else
        FileName = App.Path & "\data\races.ini"
        Max_Races = Val(GetVar(FileName, "INIT", "MaxRaces"))
        ReDim Race(1 To Max_Races) As RaceRec
        
    End If
    
    Call ClearRaces
    
    For i = 1 To Max_Races
        Race(i).Name = GetVar(FileName, "RACE" & i, "Name")
    Next i
End Sub

Sub SaveRaces()
Dim FileName As String
Dim i As Long

    FileName = App.Path & "\data\races.ini"
    
    For i = 1 To Max_Races
        Call PutVar(FileName, "RACE" & i, "Name", Trim$(Race(i).Name))
    Next i
End Sub

Function CheckRaces() As Boolean
Dim FileName As String

    FileName = App.Path & "\data\races.ini"

    CheckRaces = False

    If Not FileExist(FileName, True) Then
        Call CreateRacesINI
        CheckRaces = True
    End If

End Function

Code:
--- modEnumerations ---
CGetRaces

[code]--- modGameLogic ---
Sub JoinGame(ByVal Index As Long)
Dim i As Long

' Set the flag so we know the person is in the game
TempPlayer(Index).InGame = True

' Send a global message that he/she joined
If GetPlayerAccess(Index)
Reply


Messages In This Thread

Forum Jump:


Users browsing this thread: 1 Guest(s)