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

[DX7]Gender Based Paperdoll Rendering


abhi2011
 Share

Recommended Posts

**Yet another tutorial. Due to many requests on the forums I decided to make one. This uses player gender checks that will allow players to wear the appropriate items without devs worrying about making 1 for every gender. It just supports male and female. (If you want more just do some edits to it. But not sure why you will want more genders apart from male and female)**

[NOTE: This doesn't support DX8 based engines. (EO 3.0/EA/CS:DE/ER) Use [url="http://www.touchofdeathforums.com/community/index.php?/topic/130304-eo-30-paperdoll-based-on-gender/"]this tutorial for DX8 engines]

**CLIENT SIDE:**

In modDirectDraw7 Find

```

Public NumPaperdolls As Long

```
Underneath add

```

Public NumNPaperdolls As Long ' Normal Paperdolls

Public NumMPaperdolls As Long ' Male paperdolls

Public NumFPaperdolls As Long ' Female paperdolls

```
Still in the same module find in the sub bltPlayer

```

' check for paperdolling

For i = 1 To UBound(PaperdollOrder)

If GetPlayerEquipment(Index, PaperdollOrder(i)) > 0 Then

```
Replace the entire text of code upto next before ' error handler with

```

' 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

If Item(GetPlayerEquipment(Index, PaperdollOrder(i))).GenderBased = True Then

Call BltPaperdoll(x, y, Item(GetPlayerEquipment(Index, PaperdollOrder(i))).Paperdoll, anim, spritetop, True, Index)

Else

Call BltPaperdoll(x, y, Item(GetPlayerEquipment(Index, PaperdollOrder(i))).Paperdoll, anim, spritetop)

End If

End If

End If

Next

```

Then replace the sub bltPaperdoll with

```

Public Sub BltPaperdoll(ByVal x2 As Long, ByVal y2 As Long, ByVal Sprite As Long, ByVal anim As Long, ByVal spritetop As Long, Optional ByVal GenderBased As Boolean = False, Optional ByVal Index As Long)

Dim rec As DxVBLib.RECT

Dim x As Long, y As Long

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 Sprite < 1 Or Sprite > NumPaperdolls Then Exit Sub

If DDS_Paperdoll(Sprite) Is Nothing Then

If GenderBased = True Then

If Player(Index).Sex = 0 Then

Call InitDDSurf("Paperdolls\male\" & Sprite, DDSD_Paperdoll(Sprite), DDS_Paperdoll(Sprite))

Else

Call InitDDSurf("Paperdolls\female\" & Sprite, DDSD_Paperdoll(Sprite), DDS_Paperdoll(Sprite))

End If

Else

Call InitDDSurf("Paperdolls\" & Sprite, DDSD_Paperdoll(Sprite), DDS_Paperdoll(Sprite))

End If

End If

With rec

.top = spritetop * (DDSD_Paperdoll(Sprite).lHeight / 4)

.Bottom = .top + (DDSD_Paperdoll(Sprite).lHeight / 4)

.Left = anim * (DDSD_Paperdoll(Sprite).lWidth / 4)

.Right = .Left + (DDSD_Paperdoll(Sprite).lWidth / 4)

End With

' clipping

x = ConvertMapX(x2)

y = ConvertMapY(y2)

width = (rec.Right - rec.Left)

height = (rec.Bottom - rec.top)

' Clip to screen

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_Paperdoll(Sprite), rec, DDBLTFAST_WAIT Or DDBLTFAST_SRCCOLORKEY)

' Error handler

Exit Sub

errorhandler:

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

Err.Clear

Exit Sub

End Sub

```

Then in modDatabase, find the sub checkPaperdolls

replace the sub with

```

Public Sub CheckPaperdolls()

Dim i As Long

Dim x As Long

Dim y As Long

' If debug mode, handle error then exit out

If Options.Debug = 1 Then On Error GoTo errorhandler

i = 1

x = 1

y = 1

While FileExist(GFX_PATH & "\paperdolls\" & x & GFX_EXT)

NumNPaperdolls = NumNPaperdolls + 1

x = x + 1

Wend

While FileExist(GFX_PATH & "paperdolls\male\" & i & GFX_EXT)

NumMPaperdolls = NumMPaperdolls + 1

i = i + 1

Wend

While FileExist(GFX_PATH & "\paperdolls\female\" & y & GFX_EXT)

NumFPaperdolls = NumFPaperdolls + 1

y = y + 1

Wend

NumPaperdolls = NumFPaperdolls + NumNPaperdolls + NumMPaperdolls

If NumPaperdolls = 0 Then Exit Sub

ReDim DDS_Paperdoll(1 To NumPaperdolls)

ReDim DDSD_Paperdoll(1 To NumPaperdolls)

ReDim PaperdollTimer(1 To NumPaperdolls)

' Error handler

Exit Sub

errorhandler:

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

Err.Clear

Exit Sub

End Sub

```

In modGameEditors

find

```

frmEditor_Item.scrlPaperdoll = .Paperdoll

```
underneath add

```

If .GenderBased = True Then

frmEditor_Item.chkGenderBased = 1

Else

frmEditor_Item.chkGenderBased = 0

End If

```
in modTypes find

```

PK As Byte

```
Underneath add

```

Sex as byte
```
Find

```
Paperdoll as long
```
Underneath add

```
GenderBased As Boolean
```

in modHandleData find

```
Call SetPlayerClass(i, Buffer.ReadLong)
```
underneath add

```
Player(Index).Sex = Buffer.ReadLong
```

**Form Editing (frmEditor_Item)**

Then as in the image add to new check boxes in frmEditor_Item

Name them chkGenderBased and chkPrvwFemale. Set chkPrvwFemale's visible = false

![](http://i.imgur.com/BODwi.png)

Then double click chkGenderBased and add the following lines of code.

```

If chkGenderBased.Value = 1 Then

Item(EditorIndex).GenderBased = True

chkPrvwFemale.visible = true

Else

Item(EditorIndex).GenderBased = False

chkPrvwFemale.visible = false

End If

```
Then doubleclick chkPrvw and add the following lines of code

```

If chkPrvwFemale.Value = 1 Then

scrlPaperdoll.Max = NumFPaperdolls

Else

scrlPaperdoll.Max = NumMPaperdolls

End If

```
In the form's load event (form_Load)

replace

```

scrlPaperdoll.Max = NumPaperdolls

```
with

```

scrlPaperdoll.Max = NumNPaperdolls

```

**SERVER SIDE**

modTypes, Find

```

Paperdoll As Long
```
underneath add

```
GenderBased as boolean
```
in modServerTCP, function playerdata

find

```

buffer.WriteLong GetPlayerClass(index)
```
underneath add

```
buffer.WriteLong Player(index).Sex
```

Finished, I suppose. If you have any errors post below.
Link to comment
Share on other sites

```

While FileExist(GFX_PATH & "\paperdolls\" & x & GFX_EXT)

NumNPaperdolls = NumNPaperdolls + 1

x = x + 1

Wend
```

I might be totally wrong, but I'm pretty sure Do While - Loop is faster than While - Wend.
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...