Print Page | Close Window

Paperdoll (Working/Tested)

Printed From: Mirage Source
Category: Tutorials
Forum Name: Temporary Archive (Read Only)
Forum Discription: Temporary 3.0.3 archive tutorials, will be deleted when converted.
URL: http://ms.shannaracorp.com/backup-forums/forum_posts.asp?TID=235
Printed Date: 20 December 2006 at 5:53pm
Software Version: Web Wiz Forums 8.01 - http://www.webwizforums.com


Topic: Paperdoll (Working/Tested)
Posted By: Sync
Subject: Paperdoll (Working/Tested)
Date Posted: 11 February 2006 at 3:43pm
Difficulty: Easy 2/5

I made the paperdoll... It's 100% working :) Enjoy!
~ Client Side ~
Find:
Sub BltPlayer(ByVal Index As Long)

Replace It All With:
Sub BltPlayer(ByVal Index As Long)
Dim Anim As Byte
Dim x As Long, y As Long

    ' Only used if ever want to switch to blt rather then bltfast
    With rec_pos
        .top = GetPlayerY(Index) * PIC_Y + Player(Index).YOffset
        .Bottom = .top + PIC_Y
        .Left = GetPlayerX(Index) * PIC_X + Player(Index).XOffset
        .Right = .Left + PIC_X
    End With
    
    ' Check for animation
    Anim = 0
    If Player(Index).Attacking = 0 Then
        Select Case GetPlayerDir(Index)
             Case DIR_UP
                 If (Player(Index).YOffset < PIC_Y / 2) Then Anim = 1
             Case DIR_DOWN
                 If (Player(Index).YOffset < PIC_Y / 2 * -1) Then Anim = 1
             Case DIR_LEFT
                 If (Player(Index).XOffset < PIC_Y / 2) Then Anim = 1
             Case DIR_RIGHT
                 If (Player(Index).XOffset < PIC_Y / 2 * -1) Then Anim = 1
        End Select
    Else
        If Player(Index).AttackTimer + 500 > GetTickCount Then
             Anim = 2
        End If
    End If
   
    ' Check to see if we want to stop making him attack
    If Player(Index).AttackTimer + 1000 < GetTickCount Then
        Player(Index).Attacking = 0
        Player(Index).AttackTimer = 0
    End If
   
    rec.Left = (GetPlayerDir(Index) * 3 + Anim) * PIC_X
    rec.Right = rec.Left + PIC_X
   
    x = GetPlayerX(Index) * PIC_X + Player(Index).XOffset
    y = GetPlayerY(Index) * PIC_Y + Player(Index).YOffset - 4
   
    ' Check if its out of bounds because of the offset
    If y < 0 Then
        y = 0
        rec.top = rec.top + (y * -1)
    End If
   
    If GetPlayerDir(Index) = DIR_UP Then
        If Player(Index).Shield > 0 Then
             rec.top = Item(Player(Index).Shield).Pic * PIC_Y
             rec.Bottom = rec.top + PIC_Y
             Call DD_BackBuffer.BltFast(x, y, DD_ItemSurf, rec, DDBLTFAST_WAIT Or DDBLTFAST_SRCCOLORKEY)
        End If
        If Player(Index).Weapon > 0 Then
             rec.top = Item(Player(Index).Weapon).Pic * PIC_Y
             rec.Bottom = rec.top + PIC_Y
             Call DD_BackBuffer.BltFast(x, y, DD_ItemSurf, rec, DDBLTFAST_WAIT Or DDBLTFAST_SRCCOLORKEY)
        End If
    End If
   
    rec.top = GetPlayerSprite(Index) * PIC_Y
    rec.Bottom = rec.top + PIC_Y
       
    'Call DD_BackBuffer.Blt(rec_pos, DD_SpriteSurf, rec, DDBLT_WAIT Or DDBLT_KEYSRC)
    Call DD_BackBuffer.BltFast(x, y, DD_SpriteSurf, rec, DDBLTFAST_WAIT Or DDBLTFAST_SRCCOLORKEY)
   
    If Player(Index).Armor > 0 Then
        rec.top = Item(Player(Index).Armor).Pic * PIC_Y
        rec.Bottom = rec.top + PIC_Y
        Call DD_BackBuffer.BltFast(x, y, DD_ItemSurf, rec, DDBLTFAST_WAIT Or DDBLTFAST_SRCCOLORKEY)
    End If
    If Player(Index).Helmet > 0 Then
        rec.top = Item(Player(Index).Helmet).Pic * PIC_Y
        rec.Bottom = rec.top + PIC_Y
        Call DD_BackBuffer.BltFast(x, y, DD_ItemSurf, rec, DDBLTFAST_WAIT Or DDBLTFAST_SRCCOLORKEY)
    End If
    If GetPlayerDir(Index) <> DIR_UP Then
        If Player(Index).Shield > 0 Then
             rec.top = Item(Player(Index).Shield).Pic * PIC_Y
             rec.Bottom = rec.top + PIC_Y
             Call DD_BackBuffer.BltFast(x, y, DD_ItemSurf, rec, DDBLTFAST_WAIT Or DDBLTFAST_SRCCOLORKEY)
        End If
        If Player(Index).Weapon > 0 Then
             rec.top = Item(Player(Index).Weapon).Pic * PIC_Y
             rec.Bottom = rec.top + PIC_Y
             Call DD_BackBuffer.BltFast(x, y, DD_ItemSurf, rec, DDBLTFAST_WAIT Or DDBLTFAST_SRCCOLORKEY)
        End If
    End If
End Sub

Find:
Type PlayerRec

And Add:
Armor As Long
    Helmet As Long
    Shield As Long
    Weapon As Long

Somewhere in HandleData add:
' ::::::::::::::::::::::::::::::::::::::::
    ' :: Index player worn equipment packet ::
    ' ::::::::::::::::::::::::::::::::::::::::
    If LCase(Parse(0)) = "itemworn" Then
        Player(Val(Parse(1))).Armor = Val(Parse(2))
        Player(Val(Parse(1))).Weapon = Val(Parse(3))
        Player(Val(Parse(1))).Helmet = Val(Parse(4))
        Player(Val(Parse(1))).Shield = Val(Parse(5))
        Exit Sub
    End If


~ Server Side ~
Add These In Any Module:
Sub SendIndexWornEquipment(ByVal Index As Long)
Dim Packet As String
Dim Armor As Long
Dim Helmet As Long
Dim Shield As Long
Dim Weapon As Long

    Armor = 0
    Helmet = 0
    Shield = 0
    Weapon = 0

    If GetPlayerArmorSlot(Index) > 0 Then Armor = GetPlayerInvItemNum(Index, GetPlayerArmorSlot(Index))
    If GetPlayerHelmetSlot(Index) > 0 Then Helmet = GetPlayerInvItemNum(Index, GetPlayerHelmetSlot(Index))
    If GetPlayerShieldSlot(Index) > 0 Then Shield = GetPlayerInvItemNum(Index, GetPlayerShieldSlot(Index))
    If GetPlayerWeaponSlot(Index) > 0 Then Weapon = GetPlayerInvItemNum(Index, GetPlayerWeaponSlot(Index))
   
    Packet = "itemworn" & SEP_CHAR & Index & SEP_CHAR & Armor & SEP_CHAR & Weapon & SEP_CHAR & Helmet & SEP_CHAR & Shield & SEP_CHAR & END_CHAR
    Call SendDataToMap(GetPlayerMap(Index), Packet)
End Sub

Sub SendIndexWornEquipmentFromMap(ByVal Index As Long)
Dim Packet As String
Dim i As Long
Dim Armor As Long
Dim Helmet As Long
Dim Shield As Long
Dim Weapon As Long
  
    For i = 1 To MAX_PLAYERS
        If IsPlaying(i) = True Then
             If GetPlayerMap(Index) = GetPlayerMap(i) Then
                 Armor = 0
                 Helmet = 0
                 Shield = 0
                 Weapon = 0
            
                 If GetPlayerArmorSlot(i) > 0 Then Armor = GetPlayerInvItemNum(i, GetPlayerArmorSlot(i))
                 If GetPlayerHelmetSlot(i) > 0 Then Helmet = GetPlayerInvItemNum(i, GetPlayerHelmetSlot(i))
                 If GetPlayerShieldSlot(i) > 0 Then Shield = GetPlayerInvItemNum(i, GetPlayerShieldSlot(i))
                 If GetPlayerWeaponSlot(i) > 0 Then Weapon = GetPlayerInvItemNum(i, GetPlayerWeaponSlot(i))
               
                 Packet = "itemworn" & SEP_CHAR & i & SEP_CHAR & Armor & SEP_CHAR & Weapon & SEP_CHAR & Helmet & SEP_CHAR & Shield & SEP_CHAR & END_CHAR
                 Call SendDataTo(Index, Packet)
             End If
        End If
    Next i
End Sub

Find:
"useitem"

Near The Bottom Of The Packet But Before Exit Sub Add:
' Send everyone player's equipment
        Call SendIndexWornEquipment(Index)

Now Find:
"needmap"

Right Before Exit Sub Add:
' Send everyone player's equipment
    Call SendIndexWornEquipment(Index)
    Call SendIndexWornEquipmentFromMap(Index)




Print Page | Close Window

Bulletin Board Software by Web Wiz Forums version 8.01 - http://www.webwizforums.com
Copyright ©2001-2006 Web Wiz Guide - http://www.webwizguide.info