Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

Hair Customization for EO DX7


damian666
 Share

Recommended Posts

SERVER SIDE:

First go to modTypes, and in PlayerRec add

```

Hair As byte

```

at the bottom.

At the bottom of modPlayer, add

```

Function GetPlayerHair(ByVal Index As Long) As byte

If Index <= 0 Or Index > MAX_PLAYERS Then Exit Function

GetPlayerHair = Player(Index).Hair

End Function

Sub SetPlayerHair(ByVal Index As Long, ByVal Hair As byte)

If Index <= 0 Or Index > MAX_PLAYERS Then Exit Sub

Player(Index).Hair = Hair

End Sub

```

in modDatabase find

```

Sub AddChar(ByVal Index As Long, ByVal Name As String, ByVal Sex As Byte, ByVal ClassNum As Long, ByVal Sprite As Long)

```

and replace it with

```

Sub AddChar(ByVal Index As Long, ByVal Name As String, ByVal Sex As Byte, ByVal ClassNum As Long, ByVal Sprite As Long, ByVal Hair As byte)
```

then, inside the sub, change

```

If Player(Index).Sex = SEX_MALE Then

Player(Index).Sprite = Class(ClassNum).MaleSprite(Sprite)

Else

Player(Index).Sprite = Class(ClassNum).FemaleSprite(Sprite)

End If

```

to

```

If Player(Index).Sex = SEX_MALE Then

Player(Index).Sprite = Sprite

Else

Player(Index).Sprite = Sprite

End If

```

under

```

Player(Index).Level = Level

```

Add

```

Player(Index).Hair = Hair

```

Now, in modHandleData, find

```

HandleAddChar

```

and under

```

Dim n As Long

```

Add

```

Dim Hair As byte

```

, under

```

Sprite = Buffer.ReadLong

```

add

```

Hair = Buffer.Readbyte

```

then find

```

Call AddChar(Index, Name, Sex, Class, Sprite)

```

and replace with

```

Call AddChar(Index, Name, Sex, Class, Sprite, Hair)

```

Next, in modServerTCP, find

```

Function PlayerData

```

and under

```

Buffer.WriteLong GetPlayerLevel(Index)

```

Add

```

Buffer.Writebyte GetPlayerHair(Index)

```

And that's the server work. Now comes the client work.

CLIENT SIDE:

Like with the server, first go to modTypes, and in PlayerRec add

```

Hair As byte

```

at the bottom.

Then in modClientTCP find

```

Public Sub SendAddChar(ByVal Name As String, ByVal Sex As Long, ByVal ClassNum As Long, ByVal Sprite As Long)

```

and replace with

```

Public Sub SendAddChar(ByVal Name As String, ByVal Sex As Long, ByVal ClassNum As Long, ByVal Sprite As Long, ByVal Hair As byte)

```

and under

```

Buffer.WriteLong Sprite

```

Add

```

Buffer.Writebyte Hair

```

In modDatabase add, at the bottom or somewhere:

```

Public Sub CheckHair()

Dim i As Long

' If debug mode, handle error then exit out

If Options.Debug = 1 Then On Error GoTo errorhandler

i = 1

While FileExist(GFX_PATH & "Characters\hair\" & i & GFX_EXT)

NumHair = NumHair + 1

i = i + 1

Wend

If NumHair = 0 Then Exit Sub

ReDim DDS_Hair(1 To NumHair)

ReDim DDSD_Hair(1 To NumHair)

ReDim HairTimer(1 To NumHair)

frmMenu.scrlHair.Max = NumHair

' Error handler

Exit Sub

errorhandler:

HandleError "CheckHair", "modDatabase", Err.Number, Err.Description, Err.Source, Err.HelpContext

Err.Clear

Exit Sub

End Sub

Function GetPlayerHair(ByVal Index As Long) As byte

' If debug mode, handle error then exit out

If Options.Debug = 1 Then On Error GoTo errorhandler

If Index > MAX_PLAYERS Then Exit Function

GetPlayerHair = Player(Index).Hair

' Error handler

Exit Function

errorhandler:

HandleError "GetPlayerSprite", "modDatabase", Err.Number, Err.Description, Err.Source, Err.HelpContext

Err.Clear

Exit Function

End Function

Sub SetPlayerHair(ByVal Index As Long, ByVal Hair As byte)

' If debug mode, handle error then exit out

If Options.Debug = 1 Then On Error GoTo errorhandler

If Index > MAX_PLAYERS Then Exit Sub

Player(Index).Hair = Hair

' Error handler

Exit Sub

errorhandler:

HandleError "SetPlayerSprite", "modDatabase", Err.Number, Err.Description, Err.Source, Err.HelpContext

Err.Clear

Exit Sub

End Sub

```

in modGlobals, under

```

Public newCharClass As Long

```

Add

```

Public newCharHair As byte

```

now, in modGeneral you have to find

```

Call SendAddChar

```

it will look somewhat like this:

```

If frmMenu.optMale.Value Then

Call SendAddChar(frmMenu.txtCName, SEX_MALE, frmMenu.cmbClass.ListIndex + 1, newCharSprite)

Else

Call SendAddChar(frmMenu.txtCName, SEX_FEMALE, frmMenu.cmbClass.ListIndex + 1, newCharSprite)

End If

```

replace it with this:

```

If frmMenu.optMale.Value Then

Call SendAddChar(frmMenu.txtCName, SEX_MALE, frmMenu.cmbClass.ListIndex + 1, newCharSprite, newCharHair)

Else

Call SendAddChar(frmMenu.txtCName, SEX_FEMALE, frmMenu.cmbClass.ListIndex + 1, newCharSprite, newCharHair)

End If

```

go to modHandleData and find

```

Call SetPlayerLevel(i, Buffer.ReadLong)

```

and add under it

```

Call SetPlayerHair(i, Buffer.Readbyte)

```

in modDirectDraw7, somewhere along or under

```

Public DDS_Face() As DirectDrawSurface7

```

Add

```

Public DDS_Hair() As DirectDrawSurface7

```

Under

```

Public DDSD_Face() As DDSURFACEDESC2

```

Add

```

Public DDSD_Hair() As DDSURFACEDESC2

```

, under

```

Public FaceTimer() As Long

```

Add

```

Public HairTimer() As Long

```

Under

```

Public NumFaces As Long

```

Add

```

Public NumHair As Long

```

under

```

Call CheckFaces

```

in Sub main, modgeneral, add

```

Call CheckHair

```

find BltPlayer and at the top add

```

Dim Hair As Byte

Dim recHair As DxVBLib.RECT

```

Then under```

Sprite = GetPlayerSprite(Index)
```

Add

```

Hair = GetPlayerHair(Index)

```

Then Under

```

If Sprite < 1 Or Sprite > NumCharacters Then Exit Sub

```

Add

```

If Hair < 1 Or Hair > NumHair Then Exit Sub

```

Then Under

```

CharacterTimer(Sprite) = GetTickCount + SurfaceTimerMax

```

Add

```

HairTimer(Hair) = GetTickCount + SurfaceTimerMax

```

Under

```

If DDS_Character(Sprite) Is Nothing Then

Call InitDDSurf("characters\" & Sprite, DDSD_Character(Sprite), DDS_Character(Sprite))

End If

```

Add

```

If DDS_Hair(Hair) Is Nothing Then

Call InitDDSurf("characters\hair\" & Hair, DDSD_Hair(Hair), DDS_Hair(Hair))

End If

```

Under

```

' Set the left

Select Case GetPlayerDir(Index)

Case DIR_UP

spritetop = 3

Case DIR_RIGHT

spritetop = 2

Case DIR_DOWN

spritetop = 0

Case DIR_LEFT

spritetop = 1

End Select

```

Add

```

With recHair

.Top = spritetop * (DDSD_Hair(Hair).lHeight / 4)

.Bottom = .Top + (DDSD_Hair(Hair).lHeight / 4)

.Left = Anim * (DDSD_Hair(Hair).lWidth / 4)

.Right = .Left + (DDSD_Hair(Hair).lWidth / 4)

End With

```

Under

```

' render the actual sprite

Call BltSprite(Sprite, x, y, recSprite)

```

Add

```

Call BltHair(Hair, x, y, recHair)

```

and at the bottom or somewhere in the module add

```

Public Sub BltHair(ByVal Hair As Byte, ByVal x2 As Long, ByVal y2 As Long, rec As DxVBLib.RECT)

Dim x As Long

Dim y As Long

Dim Width As Long

Dim Height As Long

' If debug mode, handle error then exit out

If Options.Debug = 1 Then On Error GoTo errorhandler

If Hair < 1 Or Hair > NumHair Then Exit Sub

x = ConvertMapX(x2)

y = ConvertMapY(y2)

Width = (rec.Right - rec.Left)

Height = (rec.Bottom - rec.Top)

' clipping

If y < 0 Then

With rec

.Top = .Top - y

End With

y = 0

End If

If x < 0 Then

With rec

.Left = .Left - x

End With

x = 0

End If

If y + Height > DDSD_BackBuffer.lHeight Then

rec.Bottom = rec.Bottom - (y + Height - DDSD_BackBuffer.lHeight)

End If

If x + Width > DDSD_BackBuffer.lWidth Then

rec.Right = rec.Right - (x + Width - DDSD_BackBuffer.lWidth)

End If

' /clipping

Call Engine_BltFast(x, y, DDS_Hair(Hair), rec, DDBLTFAST_WAIT Or DDBLTFAST_SRCCOLORKEY)

' Error handler

Exit Sub

errorhandler:

HandleError "BltHair", "modDirectDraw7", Err.Number, Err.Description, Err.Source, Err.HelpContext

Err.Clear

Exit Sub

End Sub

Public Sub NewCharacterBltHair()

Dim sRECT As DxVBLib.RECT

Dim dRECT As DxVBLib.RECT

Dim Width As Long, Height As Long

' If debug mode, handle error then exit out

If Options.Debug = 1 Then On Error GoTo errorhandler

If newCharHair < 1 Or newCharHair > NumHair Then

frmMenu.picHair.Cls

Exit Sub

End If

HairTimer(newCharHair) = GetTickCount + SurfaceTimerMax

If newCharHair > 0 Then

If DDS_Hair(newCharHair) Is Nothing Then

Call InitDDSurf("characters\hair\" & newCharHair, DDSD_Hair(newCharHair), DDS_Hair(newCharHair))

End If

End If

Width = DDSD_Hair(newCharHair).lWidth / 4

Height = DDSD_Hair(newCharHair).lHeight / 4

frmMenu.picHair.Width = Width

frmMenu.picHair.Height = Height

sRECT.Top = 0

sRECT.Bottom = sRECT.Top + Height

sRECT.Left = 0

sRECT.Right = sRECT.Left + Width

dRECT.Top = 0

dRECT.Bottom = Height

dRECT.Left = 0

dRECT.Right = Width

Call Engine_BltToDC(DDS_Hair(newCharHair), sRECT, dRECT, frmMenu.picHair)

' Error handler

Exit Sub

errorhandler:

HandleError "NewCharacterBltHair", "modDirectDraw7", Err.Number, Err.Description, Err.Source, Err.HelpContext

Err.Clear

Exit Sub

End Sub

```

in sub NewCharacterBltSprite, change

```

If frmMenu.optMale.Value = True Then

Sprite = Class(frmMenu.cmbClass.ListIndex + 1).MaleSprite(newCharSprite)

Else

Sprite = Class(frmMenu.cmbClass.ListIndex + 1).FemaleSprite(newCharSprite)

End If

```

to

```

If frmMenu.optMale.Value = True Then

Sprite = newCharSprite

Else

Sprite = newCharSprite

End If

```

Now open up frmMenu and make sure you've got picCharacter in front (make sure you can see the "new character" menu box), then add:

> A hscrollbar that will act as a button to change the sprite, named scrlSprite

> A hscrollbar that will act as a button to change the hair named scrlHair

> A picturebox called picHair, same size as picSprite

Now, inside frmMenu's code, add…

```

Private Sub scrlHair_Change()

' If debug mode, handle error then exit out

If Options.Debug = 1 Then On Error GoTo errorhandler

If newCharHair >= scrlHair.Max Then

newCharHair = 0

Else

newCharHair = scrlHair.Value

End If

NewCharacterBltHair

' Error handler

Exit Sub

errorhandler:

HandleError "scrlShirt_Change", "frmMenu", Err.Number, Err.Description, Err.Source, Err.HelpContext

Err.Clear

Exit Sub

End Sub

Private Sub scrlSprite_Change()

Dim spritecount As Long

' If debug mode, handle error then exit out

If Options.Debug = 1 Then On Error GoTo errorhandler

If optMale.Value Then

spritecount = UBound(Class(cmbClass.ListIndex + 1).MaleSprite)

Else

spritecount = UBound(Class(cmbClass.ListIndex + 1).FemaleSprite)

End If

If newCharSprite >= scrlSprite.Max Then

newCharSprite = 0

Else

newCharSprite = scrlSprite.Value

End If

NewCharacterBltSprite

' Error handler

Exit Sub

errorhandler:

HandleError "scrlSprite_Change", "frmMenu", Err.Number, Err.Description, Err.Source, Err.HelpContext

Err.Clear

Exit Sub

End Sub

```

Add

```

newCharHair = 1

```

under

```

' Load the username + pass

txtLUser.text = Trim$(Options.Username)

If Options.SavePass = 1 Then

txtLPass.text = Trim$(Options.Password)

chkPass.Value = Options.SavePass

End If

```

EDIT

forgot to put in the cleanup code xd

in ModGameLogic, somewhere beneath "' * Check surface timers *"

add

```

If NumHair > 0 Then

For i = 1 To NumHair 'Check to unload surfaces

If HairTimer(i) > 0 Then 'Only update surfaces in use

If HairTimer(i) < Tick Then 'Unload the surface

Call ZeroMemory(ByVal VarPtr(DDSD_Hair(i)), LenB(DDSD_Hair(i)))

Set DDS_Hair(i) = Nothing

HairTimer(i) = 0

End If

End If

Next

End If

```

then in modDirectDraw7, in sub DestroyDirectDraw add

```

For i = 1 To NumHair

Set DDS_Hair(i) = Nothing

ZeroMemory ByVal VarPtr(DDSD_Hair(i)), LenB(DDSD_Hair(i))

Next

```

that's all the code! Now, for the non-code stuff.

Inside the client folder, in "data files\graphics\characters", create a new folder called hair

Add your numbered hair files.

You will also have to replace the classes sprites with hairless/bald sprites so the hair isn't drawn over more hair

please note this is untested, since i ripped it from my heavily modded source, could be i forgot something xd

this is based on > [http://www.touchofde…air-hair-color/](http://www.touchofdeathforums.com/community/index.php?/topic/132296-eo-30-character-customization-hair-hair-color/)

premade clean Eo > http://freemmorpgmaker.com/uploadfiles/ba78e7f84aca93d16bf72291ae559c55.zip
Link to comment
Share on other sites

thanx mate, hope it works right away, else ask me, i proberly forgot something then xd

and if you know a way to draw the hair ontop of the sprite, do let me know ![:)](http://www.touchofdeathforums.com/community/public/style_emoticons/<#EMO_DIR#>/smile.png)
Link to comment
Share on other sites

> thanx mate, hope it works right away, else ask me, i proberly forgot something then xd
>
> and if you know a way to draw the hair ontop of the sprite, do let me know ![:)](http://www.touchofdeathforums.com/community/public/style_emoticons/<#EMO_DIR#>/smile.png)

Doesn't it work if you let your engine load from png

then ontop loading normally works
Link to comment
Share on other sites

I've only tested it with run with full compile ![:P](http://www.touchofdeathforums.com/community/public/style_emoticons/<#EMO_DIR#>/tongue.png)

I will stress test it after i converted all the hairs you've put in png ![:P](http://www.touchofdeathforums.com/community/public/style_emoticons/<#EMO_DIR#>/tongue.png)
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...