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

How to show a npc's level above its name


smashman186
 Share

Recommended Posts

Ok, Heres how you make a Npc have its level over its name.

First, Open Client.vbp. Now scroll down to "ModText (modText.Bas) And double click it. Now push "ctrl" + "F" Keys.
Type in "Public Sub DrawNpcName(ByVal Index As Long)" Now scroll down a little until you see-

>! Name = Trim$(Npc(npcNum).Name)
    TextX = ConvertMapX(MapNpc(Index).x * PIC_X) + MapNpc(Index).XOffset + (PIC_X \ 2) - getWidth(TexthDC, (Trim$(Name)))
    If Npc(npcNum).Sprite < 1 Or Npc(npcNum).Sprite > NumCharacters Then
        TextY = ConvertMapY(MapNpc(Index).y * PIC_Y) + MapNpc(Index).YOffset - 16
    Else
        ' Determine location for text
        TextY = ConvertMapY(MapNpc(Index).y * PIC_Y) + MapNpc(Index).YOffset - (DDSD_Character(Npc(npcNum).Sprite).lHeight / 4) + 16
    End If
>!     ' Draw name
    Call DrawText(TexthDC, TextX, TextY, Name, color)

- Now, Right Under the

>! 'Draw name
  Call DrawText(RexthDC, TextX, TextY, Name, color)

- Add -

>! ' calc pos
    Level = Trim$(Npc(npcNum).Level)
    TextA = ConvertMapX(MapNpc(Index).x * PIC_X) + MapNpc(Index).XOffset + (PIC_X \ 2) - getWidth(TexthDC, (Trim$("Level " & (Npc(npcNum).Level))))
    If Npc(npcNum).Sprite < 1 Or Npc(npcNum).Sprite > NumCharacters Then
        TextB = ConvertMapY(MapNpc(Index).y * PIC_Y) + MapNpc(Index).YOffset - 5
    Else
        ' Determine location for text
        TextB = ConvertMapY(MapNpc(Index).y * PIC_Y) + MapNpc(Index).YOffset - (DDSD_Character(Npc(npcNum).Sprite).lHeight / 4) + 5
    End If

    'Draw level
    Call DrawText(TexthDC, TextA, TextB, "Level " & (Npc(npcNum).Level), color)

- Now scroll back up to "Public Sub DrawNpcName(ByVal Index As Long)" And find -

>! Dim npcNum As Long

- Now, Right below it, Add -

>! Dim TextA As Long
Dim TextB As Long
Dim Level As String

- Now your done! Go up to your vb6 Toolbar, And click on "File" Then click on "save project" Then, Click on "File" Again, And click on "Make Eclipse Orgines.exe"  Or w/e your game name is.
Now your done! :D Simple edit, I know, But it took me like 2 hours to figure it out o.o Good for noobs like me, right? :D
I don't take credit for anything except for copying and pasting o.o Heres the full code for it -

>! Public Sub DrawNpcName(ByVal Index As Long)
Dim TextX As Long
Dim TextY As Long
Dim color As Long
Dim Name As String
Dim npcNum As Long
Dim TextA As Long
Dim TextB As Long
Dim Level As String
>!     ' If debug mode, handle error then exit out
    If Options.Debug = 1 Then On Error GoTo errorhandler
>!     npcNum = MapNpc(Index).num
>!     Select Case Npc(npcNum).Behaviour
        Case NPC_BEHAVIOUR_ATTACKONSIGHT
            color = QBColor(BrightRed)
        Case NPC_BEHAVIOUR_ATTACKWHENATTACKED
            color = QBColor(Yellow)
        Case NPC_BEHAVIOUR_GUARD
            color = QBColor(Grey)
        Case Else
            color = QBColor(BrightGreen)
    End Select
>!     Name = Trim$(Npc(npcNum).Name)
    TextX = ConvertMapX(MapNpc(Index).x * PIC_X) + MapNpc(Index).XOffset + (PIC_X \ 2) - getWidth(TexthDC, (Trim$(Name)))
    If Npc(npcNum).Sprite < 1 Or Npc(npcNum).Sprite > NumCharacters Then
        TextY = ConvertMapY(MapNpc(Index).y * PIC_Y) + MapNpc(Index).YOffset - 16
    Else
        ' Determine location for text
        TextY = ConvertMapY(MapNpc(Index).y * PIC_Y) + MapNpc(Index).YOffset - (DDSD_Character(Npc(npcNum).Sprite).lHeight / 4) + 16
    End If
>!     ' Draw name
    Call DrawText(TexthDC, TextX, TextY, Name, color)

    ' calc pos
    Level = Trim$(Npc(npcNum).Level)
    TextA = ConvertMapX(MapNpc(Index).x * PIC_X) + MapNpc(Index).XOffset + (PIC_X \ 2) - getWidth(TexthDC, (Trim$("Level " & (Npc(npcNum).Level))))
    If Npc(npcNum).Sprite < 1 Or Npc(npcNum).Sprite > NumCharacters Then
        TextB = ConvertMapY(MapNpc(Index).y * PIC_Y) + MapNpc(Index).YOffset - 5
    Else
        ' Determine location for text
        TextB = ConvertMapY(MapNpc(Index).y * PIC_Y) + MapNpc(Index).YOffset - (DDSD_Character(Npc(npcNum).Sprite).lHeight / 4) + 5
    End If

    'Draw level
    Call DrawText(TexthDC, TextA, TextB, "Level " & (Npc(npcNum).Level), color)

    ' Error handler
    Exit Sub
errorhandler:
    HandleError "DrawNpcName", "modText", Err.Number, Err.Description, Err.Source, Err.HelpContext
    Err.Clear
    Exit Sub
End Sub

- All you have to do is erase "Public Sub DrawNpcName(ByVal Index As Long)" And right click on your mouse and select paste! :D

Thanks for reading, And i hope its easy to understand….Because i like reading easy to understand tuturials! :D
Link to comment
Share on other sites

  • 5 weeks later...
  • 3 weeks later...

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