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

Rendering quest markers


Joyce
 Share

Recommended Posts

Well, I've been doodling around with the code below, but it either crashes on some NPCs for some reason with a subscript out of range(because a value is a string with "                            and more spaces, trimming them out has no effect), and when it does work the NPCs that don't even have any quest relations sometimes get marks as well, and the ones that need to have marks don't? I bet I did something wrong somewhere, but I really can't figure out what. :S
```
Public Sub BltQuestMarkers()
    Dim rec As DxVBLib.RECT
    Dim i As Long
    Dim n As Long
    Dim X As Long
    Dim NewQuests As Long
    Dim Data() As String
    Dim maxdata As Long

    If DDS_QuestMarker Is Nothing Then
        Call InitDDSurf("Quest", DDSD_QuestMarker, DDS_QuestMarker)
    End If

    rec.top = 0
    rec.Left = 0
    rec.Bottom = 32
    rec.Right = 32

    For i = 1 To MAX_MAP_NPCS
        If MapNpc(i).Num = 0 Then Exit Sub
        If Trim(Npc(MapNpc(i).Num).QuestRelation) <> "" Then
            Data = Split(Trim(Npc(MapNpc(i).Num).QuestRelation), ",")
            maxdata = UBound(Data())
            NewQuests = 0

            For n = 0 To maxdata
                If Trim(Data(n)) <> "0" Then
                    For X = 1 To QUEST_MAXLOG
                        If Trim(Data(n)) <> "" Then
                            If Questlog(MyIndex).QuestComplete(Val(Data(n))) = 0 Then
                                NewQuests = NewQuests + 1
                            End If
                        End If
                    Next X
                End If
            Next n

        End If
        If NewQuests > 0 Then
            Call Engine_BltFast(ConvertMapX(MapNpc(i).X * PIC_X), ConvertMapY((MapNpc(i).Y * PIC_Y) - 64), DDS_QuestMarker, rec, DDBLTFAST_WAIT Or DDBLTFAST_SRCCOLORKEY)
        End If
    Next i

End Sub
```
Link to comment
Share on other sites

It doesn't simply just error, it sometimes also simply renders the bugger on NPCs with no quests at all, for example enemies, or it doesn't render over the NPC it should render on.. But anyways, if it does error it errors on
```
If Questlog(MyIndex).QuestComplete(Val(Data(n))) = 0 Then
```
And Data(n) then equals "                                                  and it says Subscript out of range.. Trimming it doesn't work :S
Link to comment
Share on other sites

Everything looks good, but I've spotted out a few things that could use some improving, and maybe they will solve your problem. First, try using Trim$ instead of Trim. Second, use vbNullString instead of open quotation marks ("") to cut down on wasting a few bytes of memory. Also, check out this line:

```
maxdata = UBound(Data())
```
I don't think this will make a difference, but I usually UBound my arrays without the **()**, so try that.
Link to comment
Share on other sites

Fixed it with some help.. But he asked me not to mention him so I won't. ;D

Anyways, here's the result..
![](http://www.freemmorpgmaker.com/files/imagehost/pics/497d00c96c5169ff02176b63353291e5.png)

Note that the sub has changed as well, on map load it parses the data of which NPCs to render them marks for, and then it'll use that data to blt them, rather then parsing it every frame.
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...