barreytor Posted March 11, 2013 Author Share Posted March 11, 2013 This tutorial is based on a personal adaptation of DJMaxus' [[CS:DE] Character Customization (Gender & Hair)](http://www.touchofdeathforums.com/community/index.php?/topic/123485-csde-character-customization-gender-hair/), moved to EO 3.0What it does: It lets you have a separate graphic file for character hair, and to color it at render time.Screenshots of what you should end up with (just the important bits, it's in Spanish, sorry about that):>! ![](http://i.imgur.com/sW2DErM.png)![](http://i.imgur.com/TAShk8I.png)>! Both of those hairs are the same hair file. Neat, isn't it?This might sound hard, but don't worry, it's just me, being bad at explaining.**REMEMBER! Always make a backup of your working source!****SERVER SIDE:**First go to **modTypes**, and in **PlayerRec** add```Hair As LongHairTint As Long```at the bottom.Add it to **TempPlayerRec** too. (I'm not sure it's needed, but I did it just in case.)At the bottom of **modPlayer**, add```Function GetPlayerHair(ByVal Index As Long) As LongIf Index <= 0 Or Index > MAX_PLAYERS Then Exit FunctionGetPlayerHair = Player(Index).HairEnd FunctionSub SetPlayerHair(ByVal Index As Long, ByVal Hair As Long)If Index <= 0 Or Index > MAX_PLAYERS Then Exit SubPlayer(Index).Hair = HairEnd SubFunction GetPlayerHairTint(ByVal Index As Long) As LongIf Index <= 0 Or Index > MAX_PLAYERS Then Exit FunctionGetPlayerHairTint = Player(Index).HairTintEnd FunctionSub SetPlayerHairTintTint(ByVal Index As Long, ByVal HairTint As Long)If Index <= 0 Or Index > MAX_PLAYERS Then Exit SubPlayer(Index).HairTint = HairTintEnd 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 Long, ByVal HairTint As Long)```then, inside the sub, under```Player(Index).Level = Level```add```Player(Index).Hair = HairPlayer(Index).HairTint = HairTint```Now, in **modHandleData**, find```HandleAddChar```and under```Dim n As Long```add```Dim Hair As LongDim HairTint As Long```, under```Sprite = Buffer.ReadLong```add```Hair = Buffer.ReadLongHairTint = Buffer.ReadLong```(if you place it somewhere else, remember where!), then find```Call AddChar(Index, Name, Sex, Class, Sprite)```and replace with```Call AddChar(Index, Name, Sex, Class, Sprite, Hair, HairTint)```Next, in **modServerTCP**, find```Function PlayerData```and under```Buffer.WriteLong GetPlayerLevel(Index)```add```Buffer.WriteLong GetPlayerHair(Index)Buffer.WriteLong GetPlayerHairTint(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 LongHairTint As Long```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 Long, ByVal HairTint As Long)```and under```Buffer.WriteLong Sprite```add```Buffer.WriteLong HairBuffer.WriteLong HairTint```(If in the server **modHandleData HandleAddChar** you placed the lines somewhere else, place them in the same point of order)In **modDatabase** add, at the bottom or somewhere:```' HairsPublic Sub CheckHairs()Dim i As Long' If debug mode, handle error then exit outIf Options.Debug = 1 Then On Error GoTo errorhandleri = 1NumHairs = 1ReDim Tex_Hair(1)While FileExist(GFX_PATH & "hair\" & i & GFX_EXT)ReDim Preserve Tex_Hair(NumHairs)NumTextures = NumTextures + 1ReDim Preserve gTexture(NumTextures)Tex_Hair(NumHairs).filepath = App.Path & GFX_PATH & "hair\" & i & GFX_EXTTex_Hair(NumHairs).Texture = NumTexturesNumHairs = NumHairs + 1i = i + 1WendNumHairs = NumHairs - 1If NumHairs = 0 Then Exit SubFor i = 1 To NumHairsLoadTexture Tex_Hair(i)Next' Error handlerExit Suberrorhandler:HandleError "CheckHairs", "modDatabase", Err.Number, Err.Description, Err.Source, Err.HelpContextErr.ClearExit SubEnd SubFunction GetPlayerHair(ByVal Index As Long) As Long' If debug mode, handle error then exit outIf Options.Debug = 1 Then On Error GoTo errorhandlerIf Index > MAX_PLAYERS Then Exit FunctionGetPlayerHair = Player(Index).Hair' Error handlerExit Functionerrorhandler:HandleError "GetPlayerSprite", "modDatabase", Err.Number, Err.Description, Err.Source, Err.HelpContextErr.ClearExit FunctionEnd FunctionSub SetPlayerHair(ByVal Index As Long, ByVal Hair As Long)' If debug mode, handle error then exit outIf Options.Debug = 1 Then On Error GoTo errorhandlerIf Index > MAX_PLAYERS Then Exit SubPlayer(Index).Hair = Hair' Error handlerExit Suberrorhandler:HandleError "SetPlayerSprite", "modDatabase", Err.Number, Err.Description, Err.Source, Err.HelpContextErr.ClearExit SubEnd SubFunction GetPlayerHairTint(ByVal Index As Long) As Long' If debug mode, handle error then exit outIf Options.Debug = 1 Then On Error GoTo errorhandlerIf Index > MAX_PLAYERS Then Exit FunctionGetPlayerHairTint = Player(Index).HairTint' Error handlerExit Functionerrorhandler:HandleError "GetPlayerSprite", "modDatabase", Err.Number, Err.Description, Err.Source, Err.HelpContextErr.ClearExit FunctionEnd FunctionSub SetPlayerHairTint(ByVal Index As Long, ByVal HairTint As Long)' If debug mode, handle error then exit outIf Options.Debug = 1 Then On Error GoTo errorhandlerIf Index > MAX_PLAYERS Then Exit SubPlayer(Index).HairTint = HairTint' Error handlerExit Suberrorhandler:HandleError "SetPlayerSprite", "modDatabase", Err.Number, Err.Description, Err.Source, Err.HelpContextErr.ClearExit SubEnd Sub```in **modGlobals**, under```Public newCharClass As Long```add```Public newCharHair As LongPublic newCharHairTint As Long```now, in **modGeneral** you have to find```Call SendAddChar```it will look somewhat like this:```If frmMenu.optMale.Value ThenCall SendAddChar(frmMenu.txtCName, SEX_MALE, frmMenu.cmbClass.ListIndex + 1, newCharSprite)ElseCall SendAddChar(frmMenu.txtCName, SEX_FEMALE, frmMenu.cmbClass.ListIndex + 1, newCharSprite)End If```replace it with this:```If frmMenu.optMale.Value ThenCall SendAddChar(frmMenu.txtCName, SEX_MALE, frmMenu.cmbClass.ListIndex + 1, newCharSprite, newCharHair, newCharHairTint)ElseCall SendAddChar(frmMenu.txtCName, SEX_FEMALE, frmMenu.cmbClass.ListIndex + 1, newCharSprite, newCharHair, newCharHairTint)End If```go to **modHandleData** and find```Call SetPlayerLevel(i, Buffer.ReadLong)```and add under it```Call SetPlayerHair(i, Buffer.ReadLong)Call SetPlayerHairTint(i, Buffer.ReadLong)```in **modGraphics**, somewhere along or under```Public Tex_Fog() As DX8TextureRec```add```Public Tex_Hair() As DX8TextureRec```, under```Public NumFogs As Long```add```Public NumHairs As Long```, under```Call CheckFogs```(in Sub LoadTextures) add```Call CheckHairs```find DrawPlayer and under```Call DrawSprite(Sprite, x, y, rec)```add```Call DrawHair(x, y, GetPlayerHair(Index), Anim, spritetop, GetPlayerHairTint(Index))```and at the bottom or somewhere in the module add```Public Sub DrawHair(ByVal x2 As Long, ByVal y2 As Long, ByVal Hair As Long, ByVal Anim As Long, ByVal spritetop As Long, ByVal tint As Long)Dim rec As RECTIf Hair < 1 Or Hair > NumHairs Then Exit SubWith rec.Top = spritetop * (Tex_Hair(Hair).Height / 4).Bottom = .Top + (Tex_Hair(Hair).Height / 4).Left = Anim * (Tex_Hair(Hair).Width / 4).Right = .Left + (Tex_Hair(Hair).Width / 4)End With' Clip to screenIf y2 < 0 ThenWith rec.Top = .Top - y2End Withy2 = 0End IfIf x2 < 0 ThenWith rec.Left = .Left - x2End Withx2 = 0End If'RenderTexture Tex_Hair(Hair), ConvertMapX(x2), ConvertMapY(y2), rec.Left, rec.Top, rec.Right - rec.Left, rec.Bottom - rec.Top, rec.Width, rec.HeightRenderTexture Tex_Hair(Hair), ConvertMapX(x2), ConvertMapY(y2), rec.Left, rec.Top, rec.Right - rec.Left, rec.Bottom - rec.Top, rec.Right - rec.Left, rec.Bottom - rec.Top, tintEnd Sub```still in **modGraphics**, find```Public Sub NewCharacterDrawSprite()```and under```RenderTextureByRects Tex_Character(Sprite), sRect, dRect```add```RenderTexture Tex_Hair(newCharHair), 0, 0, 0, 0, Width, Height, Width, Height, newCharHairTint```Alright. 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 label that will act as a button to change the hairstyle, named **lblHair** (preferably with a relevant caption)> A label to show what hair is selected out of them all, named **lblHairNum** (caption unnecesary)> Three scrollbars, named **scrlCRed** , **scrlCGreen** and **scrlCBlue** (preferably with labels alongside to show which is which) with a **Min** of 0 and a **Max** of 255 (You can change them if you prefer, but always within those bounds) and a **Value** of 128, or somewhere around the middle.Now, inside **frmMenu**'s code, add… (Choice time!)>If all your hairs fit both male and female characters:```Private Sub lblHair_Click()' If debug mode, handle error then exit outIf Options.Debug = 1 Then On Error GoTo errorhandlerIf newCharHair >= NumHairs ThennewCharHair = 0ElsenewCharHair = newCharHair + 1End IflblHairNum.Caption = newCharHair & " / " & NumHairs' Error handlerExit Suberrorhandler:HandleError "lblHair_Click", "frmMenu", Err.Number, Err.Description, Err.Source, Err.HelpContextErr.ClearExit SubEnd Sub```>On the other hand, if your males and females need different hairs…```Private Sub lblHair_Click()' If debug mode, handle error then exit outIf Options.Debug = 1 Then On Error GoTo errorhandlerDim haircount As LongIf optMale.Value Thenhaircount = Round((NumHairs + 1) / 2)Elsehaircount = Round((NumHairs) / 2)End IfIf optMale.Value And newCharHair >= NumHairs ThennewCharHair = 0ElseIf newCharHair >= NumHairs - 1 ThennewCharHair = 0ElseIf optMale.Value And newCharHair = 0 ThennewCharHair = 1ElseIf newCharHair = 0 ThennewCharHair = 2ElsenewCharHair = newCharHair + 2End IfEnd IfIf optMale.Value ThenlblHairNum.Caption = Round((newCharHair + 1) / 2) & " / " & haircountElselblHairNum.Caption = Round(newCharHair / 2) & " / " & haircountEnd If' Error handlerExit Suberrorhandler:HandleError "lblHair_Click", "frmMenu", Err.Number, Err.Description, Err.Source, Err.HelpContextErr.ClearExit SubEnd Sub```Note that with "Males get different hairs than Females", odd numbered hairs (1,3,5…) are used for males and even numbered hairs (2,4,6...) are used for females.Now, somewhere within the form's code add```Private Sub scrlCRed_Change()newCharHairTint = D3DColorRGBA(frmMenu.scrlCRed.Value, frmMenu.scrlCGreen.Value, frmMenu.scrlCBlue.Value, 255)End SubPrivate Sub scrlCGreen_Change()newCharHairTint = D3DColorRGBA(frmMenu.scrlCRed.Value, frmMenu.scrlCGreen.Value, frmMenu.scrlCBlue.Value, 255)End SubPrivate Sub scrlCBlue_Change()newCharHairTint = D3DColorRGBA(frmMenu.scrlCRed.Value, frmMenu.scrlCGreen.Value, frmMenu.scrlCBlue.Value, 255)End Sub```Now, inside```Private Sub Form_Load()```, under```If Options.Debug = 1 Then On Error GoTo errorhandler```add```If optMale.Value ThennewCharHair = 1ElsenewCharHair = 2End IfnewCharHairTint = D3DColorRGBA(frmMenu.scrlCRed.Value, frmMenu.scrlCGreen.Value, frmMenu.scrlCBlue.Value, 255)```to make sure the default hair isn't "no hair" (though "no hair" can still be chosen by going around all the hairs and all the way back to 0)If you went the "different hairs for males and females" way, find```Private Sub optFemale_Click()```and under```newCharSprite = 0```add```newCharHair = 2Dim haircount As Longhaircount = Round(NumHairs / 2)frmMenu.lblHairNum.Caption = Round(newCharHair / 2) & " / " & haircount```, then in```Private Sub optMale_Click()```under```newCharSprite = 0```add```newCharHair = 1Dim haircount As Longhaircount = Round((NumHairs + 1) / 2)frmMenu.lblHairNum.Caption = Round(newCharHair / 2) & " / " & haircount```Whelp, that's all the code! Now, for the non-code stuff.Inside the client folder, in "**data files\graphics**", create a new folder called **hair**Add your numbered hair files, making sure to previously desaturate them so they look grayscale and can be properly colored at runtime. Examples:>! ![](http://i.imgur.com/tHcUG5x.png)![](http://i.imgur.com/7cTd4j7.png)>! These are a male and a female hair, respectively, the male hair being 1.png and the female hair being 2.png>! This is using "male and female hairs are different", so odd numbers are male hairs and even numbers are female hairs.>! Make sure the initial picture is as bright as it needs to be, because you can use the sliders to get darker colors, but not brighter.You will also have to replace the classes sprites with hairless/bald sprites so the hair isn't drawn over more hair. Existing characters will have no hair, and there is no way given in this tutorial on how to change a player's hair, but it's as easy as making the server do a SetPlayerHair or a SetPlayerHairTint, so probably with a custom event, or command… I'll leave that for you to find a way on how do you want to do it.Original tutorial on which this one is based on: [[CS:DE] Character Customization (Gender & Hair)](http://www.touchofdeathforums.com/community/index.php?/topic/123485-csde-character-customization-gender-hair/), by DJMaxus Link to comment Share on other sites More sharing options...
Kemerd Posted March 11, 2013 Share Posted March 11, 2013 Nice tutorial! Thanks for converting it over for me! (I was just about to finish!) Saves me a lot of time! Link to comment Share on other sites More sharing options...
barreytor Posted March 11, 2013 Author Share Posted March 11, 2013 > Nice tutorial! Thanks for converting it over for me! (I was just about to finish!) Saves me a lot of time!Thanks! I hope the hair tinting is useful! Link to comment Share on other sites More sharing options...
Kemerd Posted March 11, 2013 Share Posted March 11, 2013 Yes. Hair tinting. YES *Laughs maniacally.* Link to comment Share on other sites More sharing options...
Zexion Posted March 13, 2013 Share Posted March 13, 2013 Thank you so much, I already knew how to code the custom hairs in from scratch, but I had no idea how to change the color by code. This saves me from having to do so many pictues, and the concept can be applied in several places such as clothes, face pictures, and more ![:D](http://www.touchofdeathforums.com/community/public/style_emoticons/<#EMO_DIR#>/biggrin.png) Link to comment Share on other sites More sharing options...
barreytor Posted March 13, 2013 Author Share Posted March 13, 2013 > the concept can be applied in several places such as clothes, face pictures, and more ![:D](http://www.touchofdeathforums.com/community/public/style_emoticons/<#EMO_DIR#>/biggrin.png)While that is indeed true (And I intend to, maybe, do that to my engine and make a tutorial about it), there's the limitation of "It paints everything with the color". Haven't tried to tint already colored stuff, though.EDIT: Tried it, and for anything that has more than one color it's completely useless. Link to comment Share on other sites More sharing options...
Kemerd Posted March 29, 2013 Share Posted March 29, 2013 Don't understand why there isn't more replies. This thing is awesome. Link to comment Share on other sites More sharing options...
barreytor Posted March 30, 2013 Author Share Posted March 30, 2013 I don't know either, but I guess that, after all, it's just an adaptation and that's why, or maybe no one sees it.Though it's simple to make more editable things like eyes (in fact, I did make eyes, it's the same thing only without the "letting the user choose from a few" and only having color picker) Link to comment Share on other sites More sharing options...
santa-clause Posted April 14, 2013 Share Posted April 14, 2013 Is there any way to make this fully work with dx7? Link to comment Share on other sites More sharing options...
boyesjs03 Posted April 14, 2013 Share Posted April 14, 2013 > Is there any way to make this fully work with dx7?is Eclipse 3.0 Dx8 then? Link to comment Share on other sites More sharing options...
santa-clause Posted April 14, 2013 Share Posted April 14, 2013 > is Eclipse 3.0 Dx8 then?yes Link to comment Share on other sites More sharing options...
damian666 Posted April 14, 2013 Share Posted April 14, 2013 i got it working in dx7, ill release a tut when i clean it up ![:P](http://www.touchofdeathforums.com/community/public/style_emoticons/<#EMO_DIR#>/tongue.png) Link to comment Share on other sites More sharing options...
santa-clause Posted April 14, 2013 Share Posted April 14, 2013 > i got it working in dx7, ill release a tut when i clean it up ![:P](http://www.touchofdeathforums.com/community/public/style_emoticons/<#EMO_DIR#>/tongue.png)tnx damian i'll wait for your tutorial then ![;)](http://www.touchofdeathforums.com/community/public/style_emoticons/<#EMO_DIR#>/wink.png) Link to comment Share on other sites More sharing options...
damian666 Posted April 14, 2013 Share Posted April 14, 2013 just 1 thing, the coloring is not gonna happen, i use premade hair images. Link to comment Share on other sites More sharing options...
santa-clause Posted April 14, 2013 Share Posted April 14, 2013 > just 1 thing, the coloring is not gonna happen, i use premade hair images.I use premades too ![;)](http://www.touchofdeathforums.com/community/public/style_emoticons/<#EMO_DIR#>/wink.png) Link to comment Share on other sites More sharing options...
barreytor Posted April 14, 2013 Author Share Posted April 14, 2013 Well, counting DX7 and DX8 have far different ways of handling drawing… It'd require quite a bit of editing, but it could be done.Except the tinting part, where you'd probably have to tamper around the graphics engine and change to use D3D instead of DD... And you'd end faster by jumping directly to DX8. Link to comment Share on other sites More sharing options...
Daneta Posted May 20, 2013 Share Posted May 20, 2013 i have a problem with it when ever i chose a hair it just changes my sprite to sprte six in game why is that Link to comment Share on other sites More sharing options...
barreytor Posted May 20, 2013 Author Share Posted May 20, 2013 > i have a problem with it when ever i chose a hair it just changes my sprite to sprte six in game why is thatCan you specify where/when it happens? When creating the character or after having created it?Let's see if we can manage to get this sorted out, I'll try to help you as best as I can, but I need to know where to start. Link to comment Share on other sites More sharing options...
Daneta Posted May 20, 2013 Share Posted May 20, 2013 when creating the charatcer and im chsing hair it dowsint even show the hair and when i make the charatecr it just changes my sprite to sprite 6 in game Link to comment Share on other sites More sharing options...
barreytor Posted May 20, 2013 Author Share Posted May 20, 2013 Did you add hair sprites? You might have to recheck if you missed anything when editing the source.It's all I can try to help you, as what you say suggests you didn't do it all and/or right. Link to comment Share on other sites More sharing options...
Daneta Posted May 20, 2013 Share Posted May 20, 2013 i added hair sprites so i dont know but where do i put the folder with the hair sprites Link to comment Share on other sites More sharing options...
barreytor Posted May 20, 2013 Author Share Posted May 20, 2013 Inside the graphics folder… Link to comment Share on other sites More sharing options...
Daneta Posted May 20, 2013 Share Posted May 20, 2013 weres pic character i cant find it Link to comment Share on other sites More sharing options...
Daneta Posted May 20, 2013 Share Posted May 20, 2013 i found piccharacter but how i make labels Link to comment Share on other sites More sharing options...
Growlith1223 Posted May 20, 2013 Share Posted May 20, 2013 > i found piccharacter but how i make labelsLook to your left, you will see a menu, click on one that has an "A" as the icon, then go onto the picCharacter or whatever box it is, and hold left to size it right then let go to play it. Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now