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

[CS:DE] Paperdoll & Gender Based Paperdoll


DJMaxus
 Share

Recommended Posts

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 editor
Public 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.height

End 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 paperdolling

First 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).Sex
End 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 Long
Public 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 editor
Public 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 GeomRec
Dim 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.height

End 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 Function
errorhandler:
    HandleError "GetPlayerPK", "modDatabase", Err.Number, Err.Description, Err.Source, Err.HelpContext
    Err.Clear
    Exit Function
End Function

Sub 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 Sub
errorhandler:
    HandleError "SetPlayerPK", "modDatabase", Err.Number, Err.Description, Err.Source, Err.HelpContext
    Err.Clear
    Exit Sub
End 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

–-------------------------
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

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

  • 3 weeks later...
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

  • 1 year later...
> 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

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...