Mirage Engine
My Race System - Printable Version

+- Mirage Engine (https://mirage-engine.uk/forums)
+-- Forum: Mirage Source (Nostalgia) (https://mirage-engine.uk/forums/forumdisplay.php?fid=61)
+--- Forum: Archive (2006-2011) (https://mirage-engine.uk/forums/forumdisplay.php?fid=18)
+---- Forum: General (https://mirage-engine.uk/forums/forumdisplay.php?fid=17)
+---- Thread: My Race System (/showthread.php?tid=2092)

Pages: 1 2


My Race System - Mattyw - 14-09-2008

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)


Re: My Race System - Doomy - 14-09-2008

its also the 2 lines below that one \=


Re: My Race System - Mattyw - 14-09-2008

Anyone? :S


Re: My Race System - Robin - 14-09-2008

Surprisingly, people aren't going to keep refreshing the page.

Ask once, don't bump your topic. This forum isn't active enough for that.


Re: My Race System - Mattyw - 14-09-2008

Robin Wrote:Surprisingly, people aren't going to keep refreshing the page.

Ask once, don't bump your topic. This forum isn't active enough for that.

Sorry. :S It's just annoying not being able to login.


Re: My Race System - Devilen - 18-09-2008

I know I am new here but I think I know how to fix this one.

I will test this when I get home right now I am at work Should be posting what I find hope you dont mind waiting little bit longer for me to test it. I am also adding in a Race Selection into my Version.


Re: My Race System - Mattyw - 18-09-2008

Well due to the compiling issue in Bugs forum, can't compile it anyway. :S


Re: My Race System - Devilen - 18-09-2008

I have a question.

The race box did you get that to populate Normal or did you have to do addItem to get the Information in there.

If I think of more I will edit this post here.


Re: My Race System - Mattyw - 18-09-2008

Well Class one is "cmbClass" as Text, Race is "cmbRace".

:S Still also got compiling issues due to Key 2 Heaven. >.>


Re: My Race System - Mattyw - 18-09-2008

I'd start it, problem is K2H screwed my VB6 over. Re-registered all the files, but still issues. >.>


Re: My Race System - Rian - 18-09-2008

How does K2H have anything to do with your VB6 screwing up?


Re: My Race System - Mattyw - 18-09-2008

Sonire Wrote:How does K2H have anything to do with your VB6 screwing up?


Downloaded K2H, registered files, VB6 screwed, re-registered with old files, still won't work.


Re: My Race System - Rian - 18-09-2008

Just reinstall VB6. I've had to do it recently because CodeSmart fucked it up.


Re: My Race System - Mattyw - 18-09-2008

Ok. :S

EDIT: Still same issues after re-installing...


Re: My Race System - Devilen - 20-09-2008

Code:
Sub SendChars(ByVal Index As Long)
Dim Packet As String
Dim i As Long
    
    Packet = "allchars"
    For i = 1 To MAX_CHARS                                                                                                                          ' Race System Addition
        Packet = Packet & SEP_CHAR & Trim$(Player(Index).Char(i).Name) & SEP_CHAR & Trim$(Class(Player(Index).Char(i).Class).Name) & SEP_CHAR & Player(Index).Char(i).Race & SEP_CHAR & Player(Index).Char(i).Level ' Error in Code
    Next i
    
    Packet = Packet & END_CHAR
    
    Call SendDataTo(Index, Packet)
End Sub



The Packet Part when you look it up in the debugger it shows the Trim$(Player(Index).Char(i).Name) as dmin and spaces then the SEP_CHAR so I am trying to track down where it removes the Starting a in the admin.

After that it doesnt have the Class Name it says it is out of bounds and it pulls up the Race/Level As numbs 4 and 0.

Note - I did rewrite the code and changed it around little bit then what you have here. Now I can create a new user and you get another issues.

The issue is with this you can make a new account but when you log into it you get a Run Time Error 13

It is under the Case mark of AllChars
Code:
Level = CLng(Parse(n + 2))
This Comes out to being Knight but gives an error called Missmatch. Any help would be welcomed till then Looks like I am going to be having some fun Figuring out where the Issues with the Parsing is located.


Re: My Race System - Robin - 20-09-2008

Sounds like William uses some shitty .dll hi-jacking.

Just download all your library files again, copy them into System32 and register them.

William, if you're registering people's .dll files, don't. If you aren't, then sorry please dont ban me or ill have no where to go thanks. ;-;


Re: My Race System - William - 20-09-2008

Whaat? :twisted: Why did my name pop up here? xD

I'm not reading the whole topic...


Re: My Race System - William - 20-09-2008

Haha, his blaming k2h for screwing with his compiling problems.. Nice Mattyw, you obviously have no idea what your talking about. Wouldn't surprise me if you have virus program running on your computer, and when you detected 10troyans, you pressed DELETE 10 dlls...


Re: My Race System - Robin - 20-09-2008

He's blaming it on K2H changing his registered .dll files.

Do you automatically register them in K2H?

If you do, and someone deletes your game, it'll fuck up their dependencies and make it so they can't compile. Most Eclipse games do it to me xD


Re: My Race System - William - 20-09-2008

I'm not using anything like that, and it's not my fault. Just write regsvr32 in Start->Run->filename.crap

Just download the files that they are saying your missing.


Re: My Race System - Robin - 20-09-2008

Right, was just checking.

One more post and you have 2500 Big Grin


Re: My Race System - William - 20-09-2008

Argh, I need to be first at 5000 somehow.


Re: My Race System - Robin - 20-09-2008

Admin abuse tbh?


Re: My Race System - William - 20-09-2008

We are going off-topic now, and I was joking about 5000posts.


Re: My Race System - Mattyw - 20-09-2008

>.>

It's fixed now anyway. But:

[Image: K2HReg.png]

Top half anyone.