abhi2011 Posted October 31, 2012 Author Share Posted October 31, 2012 **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 PaperdollsPublic NumMPaperdolls As Long ' Male paperdollsPublic NumFPaperdolls As Long ' Female paperdolls```Still in the same module find in the sub bltPlayer```' check for paperdollingFor 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 paperdollingFor i = 1 To UBound(PaperdollOrder)If GetPlayerEquipment(Index, PaperdollOrder(i)) > 0 ThenIf Item(GetPlayerEquipment(Index, PaperdollOrder(i))).Paperdoll > 0 ThenIf Item(GetPlayerEquipment(Index, PaperdollOrder(i))).GenderBased = True ThenCall BltPaperdoll(x, y, Item(GetPlayerEquipment(Index, PaperdollOrder(i))).Paperdoll, anim, spritetop, True, Index)ElseCall BltPaperdoll(x, y, Item(GetPlayerEquipment(Index, PaperdollOrder(i))).Paperdoll, anim, spritetop)End IfEnd IfEnd IfNext```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.RECTDim x As Long, y As LongDim width As Long, height As Long' If debug mode, handle error then exit outIf Options.Debug = 1 Then On Error GoTo errorhandlerIf Sprite < 1 Or Sprite > NumPaperdolls Then Exit SubIf DDS_Paperdoll(Sprite) Is Nothing ThenIf GenderBased = True ThenIf Player(Index).Sex = 0 ThenCall InitDDSurf("Paperdolls\male\" & Sprite, DDSD_Paperdoll(Sprite), DDS_Paperdoll(Sprite))ElseCall InitDDSurf("Paperdolls\female\" & Sprite, DDSD_Paperdoll(Sprite), DDS_Paperdoll(Sprite))End IfElseCall InitDDSurf("Paperdolls\" & Sprite, DDSD_Paperdoll(Sprite), DDS_Paperdoll(Sprite))End IfEnd IfWith 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' clippingx = ConvertMapX(x2)y = ConvertMapY(y2)width = (rec.Right - rec.Left)height = (rec.Bottom - rec.top)' Clip to screenIf y < 0 ThenWith rec.top = .top - yEnd Withy = 0End IfIf x < 0 ThenWith rec.Left = .Left - xEnd Withx = 0End IfIf y + height > DDSD_BackBuffer.lHeight Thenrec.Bottom = rec.Bottom - (y + height - DDSD_BackBuffer.lHeight)End IfIf x + width > DDSD_BackBuffer.lWidth Thenrec.Right = rec.Right - (x + width - DDSD_BackBuffer.lWidth)End If' /clippingCall Engine_BltFast(x, y, DDS_Paperdoll(Sprite), rec, DDBLTFAST_WAIT Or DDBLTFAST_SRCCOLORKEY)' Error handlerExit Suberrorhandler:HandleError "BltPaperdoll", "modDirectDraw7", Err.Number, Err.Description, Err.Source, Err.HelpContextErr.ClearExit SubEnd Sub```Then in modDatabase, find the sub checkPaperdollsreplace the sub with```Public Sub CheckPaperdolls()Dim i As LongDim x As LongDim y As Long' If debug mode, handle error then exit outIf Options.Debug = 1 Then On Error GoTo errorhandleri = 1x = 1y = 1While FileExist(GFX_PATH & "\paperdolls\" & x & GFX_EXT)NumNPaperdolls = NumNPaperdolls + 1x = x + 1WendWhile FileExist(GFX_PATH & "paperdolls\male\" & i & GFX_EXT)NumMPaperdolls = NumMPaperdolls + 1i = i + 1WendWhile FileExist(GFX_PATH & "\paperdolls\female\" & y & GFX_EXT)NumFPaperdolls = NumFPaperdolls + 1y = y + 1WendNumPaperdolls = NumFPaperdolls + NumNPaperdolls + NumMPaperdollsIf NumPaperdolls = 0 Then Exit SubReDim DDS_Paperdoll(1 To NumPaperdolls)ReDim DDSD_Paperdoll(1 To NumPaperdolls)ReDim PaperdollTimer(1 To NumPaperdolls)' Error handlerExit Suberrorhandler:HandleError "CheckPaperdolls", "modDatabase", Err.Number, Err.Description, Err.Source, Err.HelpContextErr.ClearExit SubEnd Sub```In modGameEditorsfind```frmEditor_Item.scrlPaperdoll = .Paperdoll```underneath add```If .GenderBased = True ThenfrmEditor_Item.chkGenderBased = 1ElsefrmEditor_Item.chkGenderBased = 0End 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_ItemName 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 ThenItem(EditorIndex).GenderBased = TruechkPrvwFemale.visible = trueElseItem(EditorIndex).GenderBased = FalsechkPrvwFemale.visible = falseEnd If```Then doubleclick chkPrvw and add the following lines of code```If chkPrvwFemale.Value = 1 ThenscrlPaperdoll.Max = NumFPaperdollsElsescrlPaperdoll.Max = NumMPaperdollsEnd 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 playerdatafind```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 More sharing options...
tslusny Posted October 31, 2012 Share Posted October 31, 2012 Nice tut Abhi ![:P](http://www.touchofdeathforums.com/community/public/style_emoticons/<#EMO_DIR#>/tongue.png) Link to comment Share on other sites More sharing options...
Guest Posted October 31, 2012 Share Posted October 31, 2012 ```While FileExist(GFX_PATH & "\paperdolls\" & x & GFX_EXT)NumNPaperdolls = NumNPaperdolls + 1x = x + 1Wend```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 More sharing options...
abhi2011 Posted November 1, 2012 Author Share Posted November 1, 2012 @Sekaru just used the one that Robin used Link to comment Share on other sites More sharing options...
Guest Posted November 1, 2012 Share Posted November 1, 2012 Yeah I know, I'm just pointing that out. Link to comment Share on other sites More sharing options...
abhi2011 Posted November 2, 2012 Author Share Posted November 2, 2012 But Could you tell me how it is faster?Want to learn something new everyday ![:D](http://www.touchofdeathforums.com/community/public/style_emoticons/<#EMO_DIR#>/biggrin.png) Link to comment Share on other sites More sharing options...
Joyce Posted November 2, 2012 Share Posted November 2, 2012 It isn't faster, but to quote the documentation:> _The Do…Loop statement provides a more structured and flexible way to perform looping._> > Not to mention, you can perform an Exit Do statement in them. Link to comment Share on other sites More sharing options...
lcarens Posted November 3, 2012 Share Posted November 3, 2012 Thanks for linking to my tutorial. ![^_^](http://www.touchofdeathforums.com/community/public/style_emoticons/<#EMO_DIR#>/happy.png) Link to comment Share on other sites More sharing options...
abhi2011 Posted November 4, 2012 Author Share Posted November 4, 2012 welcome 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