DJMaxus Posted December 18, 2011 Author Share Posted December 18, 2011 This is a tutorial for Crystalshire Developer's Edition. It's two tutorials in one topic. The first part will allow you to have paperdolling in your game, and the second part will allow you to have gender based paperdolling in your game. Don't think I saw a paperdolling tutorial on here for CS:DE so I thought I'd share mine._**How It Works:**_Everyone knows how paperdolling works, but this gender based paperdoll will have you create two folders within the paperdolling folder. One called "male" one called "female" When a player equips an item, based on their gender, it will show the corresponding graphic from the specific folder. This way, "Heavy Steel Armor" will look different on Male characters than on Female characters, but will still be the same item. All you'll have to do is put the male graphic in the male folder, female graphic in the female folder, and they of course must be the same number. Simple._**Part One: Standard Paperdoll**_* Follow part one only if you want just standard paperdolling in your project.**All Client Side**As you may have known, Paperdolling is already in CS:DE, we just have to render it.In **modDirectX8**Find : **Sub GDIRenderChar**Underneath that entire sub, we're going to add this:```' Paperdoll show up in item editorPublic Sub GDIRenderPaperdoll(ByRef picBox As PictureBox, ByVal Sprite As Long)Dim height As Long, Width As Long, sRECT As RECT ' exit out if doesn't exist If Sprite <= 0 Or Sprite > Count_Paperdoll Then Exit Sub height = 32 Width = 32 sRECT.top = 0 sRECT.bottom = sRECT.top + height sRECT.left = 0 sRECT.Right = sRECT.left + Width ' Start Rendering Call D3DDevice8.Clear(0, ByVal 0, D3DCLEAR_TARGET, 0, 1#, 0) Call D3DDevice8.BeginScene RenderTexture Tex_Paperdoll(Sprite), 0, 0, 0, 0, Width, height, Width, height ' Finish Rendering Call D3DDevice8.EndScene Call D3DDevice8.Present(sRECT, ByVal 0, picBox.hwnd, ByVal 0)End Sub```In : **Sub DrawPlayer**Find:```RenderTexture Tex_Char(Sprite), ConvertMapX(x), ConvertMapY(y), rec.left, rec.top, rec.Width, rec.height, rec.Width, rec.height```Underneath it Add:```' check for paperdolling For i = 1 To UBound(PaperdollOrder) If GetPlayerEquipment(Index, PaperdollOrder(i)) > 0 Then If Item(GetPlayerEquipment(Index, PaperdollOrder(i))).Paperdoll > 0 Then Call DrawPaperdoll(x, y, Item(GetPlayerEquipment(Index, PaperdollOrder(i))).Paperdoll, Anim, spritetop) End If End If Next```Underneath the entire **DrawPlayer** sub, paste this:```Public Sub DrawPaperdoll(ByVal x2 As Long, ByVal y2 As Long, ByVal Sprite As Long, ByVal Anim As Long, ByVal spritetop As Long)Dim rec As GeomRec If Sprite < 1 Or Sprite > Count_Paperdoll Then Exit Sub With rec .top = spritetop * (D3DT_TEXTURE(Tex_Paperdoll(Sprite)).height / 4) .height = (D3DT_TEXTURE(Tex_Paperdoll(Sprite)).height / 4) .left = Anim * (D3DT_TEXTURE(Tex_Paperdoll(Sprite)).Width / 4) .Width = (D3DT_TEXTURE(Tex_Paperdoll(Sprite)).Width / 4) End With ' Clip to screen If y2 < 0 Then With rec .top = .top - y2 End With y2 = 0 End If If x2 < 0 Then With rec .left = .left - x2 End With x2 = 0 End If RenderTexture Tex_Paperdoll(Sprite), ConvertMapX(x2), ConvertMapY(y2), rec.left, rec.top, rec.Width, rec.height, rec.Width, rec.heightEnd Sub```In **Sub DrawGDI**Find:```GDIRenderItem frmEditor_Item.picItem, frmEditor_Item.scrlPic.value```Underneath it add this:```GDIRenderPaperdoll frmEditor_Item.picPaperdoll, frmEditor_Item.scrlPaperdoll.value```That's it for standard paperdolling. You now have paperdolling in your project._**Part Two: Gender Based Paperdoll**_* Follow part one first, then follow this for gender based paperdollingFirst thing you're going to want to do is create two folders in your "paperdolls" folder. One called "male" and one called "female"**Server Side**In **modServerTCP**Find : **Function PlayerData**Find:```For i = 1 To Stats.Stat_Count - 1 Buffer.WriteLong GetPlayerStat(index, i) Next```Underneath it add:```Buffer.WriteLong GetPlayerSex(index)```In **modPlayer**Add this to the bottom:```Function GetPlayerSex(ByVal index As Long) As Long If index <= 0 Or index > MAX_PLAYERS Then Exit Function GetPlayerSex = Player(index).SexEnd Function```**Client Side**In **modDirectX8**Near the top of the entire module, find this:```Public Tex_Paperdoll() As Long```And replace it with this:```Public Tex_Paperdoll_M() As LongPublic Tex_Paperdoll_F() As Long```Find:```Public Const Path_Paperdoll As String = "\data files\graphics\paperdolls\"```And replace it with this:```Public Const Path_Paperdoll_M As String = "\data files\graphics\paperdolls\male\"Public Const Path_Paperdoll_F As String = "\data files\graphics\paperdolls\female\"```In **EngineCacheTextures**Find:```' Paperdoll Textures Count_Paperdoll = 1 Do While FileExist(App.path & Path_Paperdoll & Count_Paperdoll & ".png") ReDim Preserve Tex_Paperdoll(0 To Count_Paperdoll) Tex_Paperdoll(Count_Paperdoll) = SetTexturePath(App.path & Path_Paperdoll & Count_Paperdoll & ".png") Count_Paperdoll = Count_Paperdoll + 1 Loop Count_Paperdoll = Count_Paperdoll - 1```And Replace it with this:```' Male Paperdoll Textures Count_Paperdoll = 1 Do While FileExist(App.Path & Path_Paperdoll_M & Count_Paperdoll & ".png") ReDim Preserve Tex_Paperdoll_M(0 To Count_Paperdoll) Tex_Paperdoll_M(Count_Paperdoll) = SetTexturePath(App.Path & Path_Paperdoll_M & Count_Paperdoll & ".png") Count_Paperdoll = Count_Paperdoll + 1 Loop Count_Paperdoll = Count_Paperdoll - 1 ' Female Paperdoll Textures Count_Paperdoll = 1 Do While FileExist(App.Path & Path_Paperdoll_F & Count_Paperdoll & ".png") ReDim Preserve Tex_Paperdoll_F(0 To Count_Paperdoll) Tex_Paperdoll_F(Count_Paperdoll) = SetTexturePath(App.Path & Path_Paperdoll_F & Count_Paperdoll & ".png") Count_Paperdoll = Count_Paperdoll + 1 Loop Count_Paperdoll = Count_Paperdoll - 1```Replace **Sub GDIRenderPaperdoll** with this one:```' Paperdoll show up in item editorPublic Sub GDIRenderPaperdoll(ByRef picBox As PictureBox, ByVal Sprite As Long)Dim height As Long, Width As Long, sRECT As RECT ' exit out if doesn't exist If Sprite <= 0 Or Sprite > Count_Paperdoll Then Exit Sub height = 32 Width = 32 sRECT.top = 0 sRECT.bottom = sRECT.top + height sRECT.left = 0 sRECT.Right = sRECT.left + Width ' Start Rendering Call D3DDevice8.Clear(0, ByVal 0, D3DCLEAR_TARGET, 0, 1#, 0) Call D3DDevice8.BeginScene RenderTexture Tex_Paperdoll_M(Sprite), 0, 0, 0, 0, Width, height, Width, height ' Finish Rendering Call D3DDevice8.EndScene Call D3DDevice8.Present(sRECT, ByVal 0, picBox.hwnd, ByVal 0)End Sub```In **Sub DrawPlayer**Find this line:```Call DrawPaperdoll(x, y, Item(GetPlayerEquipment(Index, PaperdollOrder(i))).Paperdoll, Anim, spritetop)```Replace it with this line:```Call DrawPaperdoll(Index, x, y, Item(GetPlayerEquipment(Index, PaperdollOrder(i))).Paperdoll, Anim, spritetop)```In **modTypes**In **Private Type PlayerRec**Find:```name As String```Underneath it add:```Sex As Byte```Replace **Sub DrawPaperdoll** with this one:```Public Sub DrawPaperdoll(ByVal index As Long, ByVal x2 As Long, ByVal y2 As Long, ByVal Sprite As Long, ByVal Anim As Long, ByVal spritetop As Long)Dim rec As GeomRecDim G_Paperdoll As Long If Sprite < 1 Or Sprite > Count_Paperdoll Then Exit Sub If GetPlayerSex(index) = SEX_MALE Then G_Paperdoll = Tex_Paperdoll_M(Sprite) Else G_Paperdoll = Tex_Paperdoll_F(Sprite) End If With rec .top = spritetop * (D3DT_TEXTURE(G_Paperdoll).height / 4) .height = (D3DT_TEXTURE(G_Paperdoll).height / 4) .left = Anim * (D3DT_TEXTURE(G_Paperdoll).Width / 4) .Width = (D3DT_TEXTURE(G_Paperdoll).Width / 4) End With ' Clip to screen If y2 < 0 Then With rec .top = .top - y2 End With y2 = 0 End If If x2 < 0 Then With rec .left = .left - x2 End With x2 = 0 End If RenderTexture G_Paperdoll, ConvertMapX(x2), ConvertMapY(y2), rec.left, rec.top, rec.Width, rec.height, rec.Width, rec.heightEnd Sub```In **modDatabase**Add This to the very bottom:```Function GetPlayerSex(ByVal Index As Long) As Long ' If debug mode, handle error then exit out If Options.Debug = 1 Then On Error GoTo errorhandler If Index > MAX_PLAYERS Then Exit Function GetPlayerSex = Player(Index).Sex ' Error handler Exit Functionerrorhandler: HandleError "GetPlayerPK", "modDatabase", Err.Number, Err.Description, Err.Source, Err.HelpContext Err.Clear Exit FunctionEnd FunctionSub SetPlayerSex(ByVal Index As Long, ByVal Sex As Long) ' 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).Sex = Sex ' Error handler Exit Suberrorhandler: HandleError "SetPlayerPK", "modDatabase", Err.Number, Err.Description, Err.Source, Err.HelpContext Err.Clear Exit SubEnd Sub```In **modHandleData**Find : **Sub HandlePlayerData**Find:```For x = 1 To Stats.Stat_Count - 1 SetPlayerStat i, x, Buffer.ReadLong Next```Underneath it add this:```Call SetPlayerSex(i, Buffer.ReadLong)```That should be everything. You now have gender based paperdolling in your game. This is copy pasted right out of my project so if I missed anything let me know. Hope this helps you further your project. If you have any questions feel free to ask. Link to comment Share on other sites More sharing options...
Esmeyana Posted December 18, 2011 Share Posted December 18, 2011 Awesome tutorial, gonna try it…Thnx btw.. Link to comment Share on other sites More sharing options...
Whackeddie99 Posted December 18, 2011 Share Posted December 18, 2011 Works great always wanted this Link to comment Share on other sites More sharing options...
Domino_ Posted December 18, 2011 Share Posted December 18, 2011 Part Two works with OE too? Link to comment Share on other sites More sharing options...
DJMaxus Posted December 18, 2011 Author Share Posted December 18, 2011 @ThereIsNoDomino_:> Part Two works with OE too?This one is CS:DE only, but it would only take a few modifications to get it work with EO. Link to comment Share on other sites More sharing options...
Techos Posted December 19, 2011 Share Posted December 19, 2011 Finally! this is what i'm waiting for! thank you!!EDIT:But how females can wear it ? because when they registering it automatically choose MALE Link to comment Share on other sites More sharing options...
DJMaxus Posted December 22, 2011 Author Share Posted December 22, 2011 This tutorial goes nicely with this one:http://www.touchofdeathforums.com/smf/index.php/topic,77052.0.html Link to comment Share on other sites More sharing options...
Ulyx Posted December 22, 2011 Share Posted December 22, 2011 Nice job Maxus ! Works very well :D Link to comment Share on other sites More sharing options...
zzuurraa Posted December 24, 2011 Share Posted December 24, 2011 Found Bug! if map is longer than 24x18 , paperdolls stay in the position 24/18 when map starts to slide down :|![](http://img839.imageshack.us/img839/5682/44872266.png) Link to comment Share on other sites More sharing options...
DJMaxus Posted December 24, 2011 Author Share Posted December 24, 2011 @zzuurraa:> Found Bug! if map is longer than 24x18 , paperdolls stay in the position 24/18 when map starts to slide down :|Ah ok, I'll fix that when I get home today.That just goes to show that I should do a better job testing my tutorials. Link to comment Share on other sites More sharing options...
zzuurraa Posted December 24, 2011 Share Posted December 24, 2011 Everyone does mistakes, You do Brilliant job :) :P :P Link to comment Share on other sites More sharing options...
DJMaxus Posted December 25, 2011 Author Share Posted December 25, 2011 Ok its fixed, and I updated the topic.Just replace the respective DrawPaperdoll sub with the one in the first post. Link to comment Share on other sites More sharing options...
Recoil Posted December 25, 2011 Share Posted December 25, 2011 –-------------------------Microsoft Visual Basic---------------------------Compile error:Wrong number of arguments or invalid property assignment---------------------------OK Help ---------------------------All I did was replace the DrawPaperdoll sub with the one in the first post. I am unable to check where the error is coming from because for some reason VB6 is shutting down on me before I can debug it.Edit: I do have the gender and hair one implemented, and I notice that part of it that are needed for the male/female portions are not there in the update.EDIT: Ignore this! I was replacing with the first one, not the second DrawPaperdoll sub :/ Link to comment Share on other sites More sharing options...
zzuurraa Posted December 25, 2011 Share Posted December 25, 2011 I have a problem , paperdolls are the same on both sexes.Help Please Link to comment Share on other sites More sharing options...
Recoil Posted December 25, 2011 Share Posted December 25, 2011 In your graphics/paperdolls/male & graphics/paperdolls/female folders, if you have the same sprite in both folder for each sex wearing the exact same item, then it will show up the same. You have to have the same number (item2 = 2.png) but different sprites labeled as "2.png".If that is the case, and you have the same sprite showing no matter which sex is chosen, and the images in the sex folders are different, then you might try going back over the tutorial to make sure.I have already checked, going Exactly by this tutorial will make paperdolling work for both sexes. Link to comment Share on other sites More sharing options...
Emy Posted January 11, 2012 Share Posted January 11, 2012 Great tutorial, but I found a bug. I only used part one, don't know if that matters, but after equipping an item and dropping it, it's not visible to other clients. Thanks for all the help!Edit: My bad, it wasn't this fix who was the problem, I got it figured out. But still, thanks a lot for this! Link to comment Share on other sites More sharing options...
avengingevi1l Posted March 30, 2013 Share Posted March 30, 2013 so how can i transfer this over to EO? is it possible? Link to comment Share on other sites More sharing options...
DJMaxus Posted March 31, 2013 Author Share Posted March 31, 2013 > so how can i transfer this over to EO? is it possible?Yes, look throught the tutorial and copy over everything having to do with gender (male and female constants). Since paperdolling is already present, you just have to tell the game to load a certain image based on gender. Link to comment Share on other sites More sharing options...
avengingevi1l Posted March 31, 2013 Share Posted March 31, 2013 the only files i found were moddatabase, modtypes and modhandledata, am i missing files? 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