Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Race Sprites Tut
#1
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! Smile 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 Smile 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! Smile
Reply
#2
Use code tags please.
Reply
#3
Not sure if it's like this because you didn't use code tags, but make sure you format your code properly, otherwise it's too much trouble to actually go through and read.
Reply
#4
It's formatted. You can see the spaces when you quote it.
Reply
#5
It feels like copy and paste Dx
Reply
#6
yea, thats how a tutorial will look if you copy and paste the exact text from another forum (not the bbcode).
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)