22-08-2009, 08:13 PM
So what this tutorial will basically do is let you choose a sprite for the male version of a race and the female version of a race!
This is all server side too. I use MS 3.07 for this tut.
Go look for the following lines, in modTypes :
Code:
Type ClassRec
Name As String * NAME_LENGTH
Sprite As Integer
Stat(1 To Stats.Stat_Count - 1) As Byte
End Type
and remove the Sprite as Integer.
Next I add a new Rec called RaceRec
Type RaceRec
Name As String * NAME_LENGTH
MSprite as Integer
FSprite as Integer
Stat(1 To Stats.Stat_Count - 1) As Byte
End Type
Next I copy the LoadClasses(modDatabase) as a new sub and renamed it to LoadRaces. I also change all Class() to Race().
Now, in the LoadClasses (modDatabase), look for the line :
Code:
Class(i).Sprite = Val(GetVar(FileName, "CLASS" & i, "Sprite"))
and remove it.
Now, in the LoadRaces (modDatabase), look for the line :
Code:
Race(i).Sprite = Val(GetVar(FileName, "Race" & i, "Sprite"))
and replace it with:
Code:
Race(i).MSprite = Val(GetVar(FileName, "RACE" & i, "MSprite"))
Race(i).FSprite = Val(GetVar(FileName, "RACE" & i, "FSprite"))
Next I copy the SaveClasses(modDatabase) to make a new sub called SaveRaces. I rename the Class() to Race().
In sub SaveClasses (modDatabase), look for :
Code:
Call PutVar(FileName, "CLASS" & i, "Sprite", CStr(Class(i).Sprite))
and remove it
In sub SaveRaces (modDatabase), look for :
Code:
Call PutVar(FileName, "RACE" & i, "Sprite", CStr(Race(i).Sprite))
and replace it with :
Code:
Call PutVar(FileName, "RACE" & i, "MSprite", CStr(Race(i).MSprite))
Call PutVar(FileName, "RACE" & i, "FSprite", CStr(Race(i).FSprite))
So far so good. It's all pretty self explanatory, you're just changing the single sprite variable to two variables, one that holds the female sprite and one that holds the male sprite, and you're properly loading/saving it
Make sure you remove (in your classes.ini) :
Quote:
Sprite=###
And that you make a new ini file called races.ini that basically have same stuff as classes.ini before the remove, but that the follow change:
Quote:
MSprite=Male Sprite ###
FSprite=Female Sprite ###
Now, we have to make sure the code in the part where the player is actually assigned the proper sprite. This is done in sub AddChar. Now, MS already has a system like this, but the problem with it is it assigns the player the same sprite, whether the player chooses Male or Female. But you need to add "RaceNum" after ClassNum in AddChar. This is represented by these lines :
Code:
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
Just replace those lines with :
Code:
If Player(Index).Char(CharNum).Sex = SEX_MALE Then
Player(Index).Char(CharNum).Sprite = Race(RaceNum).MSprite
Else
Player(Index).Char(CharNum).Sprite = Race(RaceNum).FSprite
End If
And there you go! You now have a female and male sprite for each race and that you basically create a Race System!

Go look for the following lines, in modTypes :
Code:
Type ClassRec
Name As String * NAME_LENGTH
Sprite As Integer
Stat(1 To Stats.Stat_Count - 1) As Byte
End Type
and remove the Sprite as Integer.
Next I add a new Rec called RaceRec
Type RaceRec
Name As String * NAME_LENGTH
MSprite as Integer
FSprite as Integer
Stat(1 To Stats.Stat_Count - 1) As Byte
End Type
Next I copy the LoadClasses(modDatabase) as a new sub and renamed it to LoadRaces. I also change all Class() to Race().
Now, in the LoadClasses (modDatabase), look for the line :
Code:
Class(i).Sprite = Val(GetVar(FileName, "CLASS" & i, "Sprite"))
and remove it.
Now, in the LoadRaces (modDatabase), look for the line :
Code:
Race(i).Sprite = Val(GetVar(FileName, "Race" & i, "Sprite"))
and replace it with:
Code:
Race(i).MSprite = Val(GetVar(FileName, "RACE" & i, "MSprite"))
Race(i).FSprite = Val(GetVar(FileName, "RACE" & i, "FSprite"))
Next I copy the SaveClasses(modDatabase) to make a new sub called SaveRaces. I rename the Class() to Race().
In sub SaveClasses (modDatabase), look for :
Code:
Call PutVar(FileName, "CLASS" & i, "Sprite", CStr(Class(i).Sprite))
and remove it
In sub SaveRaces (modDatabase), look for :
Code:
Call PutVar(FileName, "RACE" & i, "Sprite", CStr(Race(i).Sprite))
and replace it with :
Code:
Call PutVar(FileName, "RACE" & i, "MSprite", CStr(Race(i).MSprite))
Call PutVar(FileName, "RACE" & i, "FSprite", CStr(Race(i).FSprite))
So far so good. It's all pretty self explanatory, you're just changing the single sprite variable to two variables, one that holds the female sprite and one that holds the male sprite, and you're properly loading/saving it

Quote:
Sprite=###
And that you make a new ini file called races.ini that basically have same stuff as classes.ini before the remove, but that the follow change:
Quote:
MSprite=Male Sprite ###
FSprite=Female Sprite ###
Now, we have to make sure the code in the part where the player is actually assigned the proper sprite. This is done in sub AddChar. Now, MS already has a system like this, but the problem with it is it assigns the player the same sprite, whether the player chooses Male or Female. But you need to add "RaceNum" after ClassNum in AddChar. This is represented by these lines :
Code:
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
Just replace those lines with :
Code:
If Player(Index).Char(CharNum).Sex = SEX_MALE Then
Player(Index).Char(CharNum).Sprite = Race(RaceNum).MSprite
Else
Player(Index).Char(CharNum).Sprite = Race(RaceNum).FSprite
End If
And there you go! You now have a female and male sprite for each race and that you basically create a Race System!
