Mirage Source

Free ORPG making software.
It is currently Thu Mar 28, 2024 3:04 pm

All times are UTC


Forum rules


Make sure your tutorials are kept up to date with the latest MS4 releases.



Post new topic Reply to topic  [ 1484 posts ]  Go to page 1, 2, 3, 4, 5 ... 60  Next
Author Message
 Post subject: Display NPC Names
PostPosted: Mon Sep 15, 2008 10:35 pm 
Offline
Regular
User avatar

Joined: Tue Jun 17, 2008 12:39 pm
Posts: 55
It's really simple to do really...Just gotta add a few things, and all done. I've tested it and it works.

Difficulty: 1/5

::Client Side::

Go to modGameLogic and at the bottom add this:

Code:
Sub BltNPCName(ByVal Index As Long)
Dim TextX As Long
Dim TextY As Long

    With Npc(MapNpc(Index).Num)
   
    'Draw name
TextX = MapNpc(Index).X * PIC_X + MapNpc(Index).XOffset + CLng(PIC_X / 2) - ((Len(Trim$(.Name)) / 2) * 8)
TextY = MapNpc(Index).Y * PIC_Y + MapNpc(Index).YOffset - CLng(PIC_Y / 2) - 4
DrawText TexthDC, TextX, TextY, Trim$(.Name), vbWhite
    End With
End Sub


Then find(still in modGameLogic):

Code:
                ' Lock the backbuffer so we can draw text and names
                TexthDC = DD_BackBuffer.GetDC


Below that add:

Code:
                'Draw npc name
                For i = LBound(MapNpc) To UBound(MapNpc)
                If MapNpc(i).Num > 0 Then
                    BltNPCName i
                End If
            Next i


Top
 Profile  
 
 Post subject: Re: Display NPC Names
PostPosted: Mon Sep 15, 2008 10:39 pm 
Offline
Persistant Poster
User avatar

Joined: Fri Aug 15, 2008 3:11 pm
Posts: 633
hope it works
*crosses fingers

_________________
╔╗╔═╦═╦══╦═══╗
║║║║║║║╔╗║╔═╗║
║║║║║║║╚╝║║║║║
║╚╣║║║║╔╗║╚═╝║
╚═╩╩═╩╩╝╚╩═══╝


╔╦═╦╦════╦═══╗
║║║║╠═╗╔═╣╔══╝
║║║║║║║║╚═╗
║║║║║║║║╔═╝
╚═╩═╝╚╝╚╝ ?


Top
 Profile  
 
 Post subject: Re: Display NPC Names
PostPosted: Mon Sep 15, 2008 10:55 pm 
Offline
Regular
User avatar

Joined: Tue Jun 17, 2008 12:39 pm
Posts: 55
It does for me, I test out all my code that I make tutorials for before I post them up. But if it doesn't for you, for some reason, just post here with the details, I'll try to help you.


Top
 Profile  
 
 Post subject: Re: Display NPC Names
PostPosted: Tue Sep 16, 2008 12:34 am 
Offline
Regular

Joined: Sat Sep 13, 2008 1:41 am
Posts: 97
Nice tutorial


Top
 Profile  
 
 Post subject: Re: Display NPC Names
PostPosted: Tue Sep 16, 2008 12:56 am 
Offline
Regular
User avatar

Joined: Tue Jun 17, 2008 12:39 pm
Posts: 55
Thank you.


Top
 Profile  
 
 Post subject: Re: Display NPC Names
PostPosted: Tue Sep 16, 2008 2:56 am 
Offline
Pro

Joined: Mon May 29, 2006 5:01 pm
Posts: 420
Location: Canada, BC
Google Talk: anthony.fleck@gmail.com
Just thought I would add something to this really quick. I haven't tested it but it should work.

If you want to have it only blt the names when you put your mouse over then replace this:

Code:
'Draw npc name
                For i = LBound(MapNpc) To UBound(MapNpc)
                If MapNpc(i).Num > 0 Then
                    BltNPCName i
                End If
            Next i


With this:

Code:
'Draw NPC Names
                For i = LBound(MapNpc) To UBound(MapNpc)
                    If MapNpc(i).Num > 0 Then
                        If CurX = MapNpc(i).x Then
                            If CurY = MapNpc(i).y Then
                                Call BltNPCName(i)
                            End If
                        End If
                    End If
                Next i


Top
 Profile  
 
 Post subject: Re: Display NPC Names
PostPosted: Tue Sep 16, 2008 4:25 am 
Offline
Persistant Poster
User avatar

Joined: Fri Aug 15, 2008 3:11 pm
Posts: 633
thx now imma use this XD

_________________
╔╗╔═╦═╦══╦═══╗
║║║║║║║╔╗║╔═╗║
║║║║║║║╚╝║║║║║
║╚╣║║║║╔╗║╚═╝║
╚═╩╩═╩╩╝╚╩═══╝


╔╦═╦╦════╦═══╗
║║║║╠═╗╔═╣╔══╝
║║║║║║║║╚═╗
║║║║║║║║╔═╝
╚═╩═╝╚╝╚╝ ?


Top
 Profile  
 
 Post subject: Re: Display NPC Names
PostPosted: Fri Sep 19, 2008 8:54 pm 
Offline
Persistant Poster
User avatar

Joined: Thu Mar 29, 2007 10:30 pm
Posts: 1510
Location: Virginia, USA
Google Talk: hpmccloud@gmail.com
Also it would be better to make all those If statements just a single If blah And blah2 and blah3 Then because you're just using them for one call.

_________________
Nean wrote:
Yes harold. Give it to me.

Image
Image


Top
 Profile  
 
 Post subject: Re: Display NPC Names
PostPosted: Fri Sep 19, 2008 9:14 pm 
Offline
Persistant Poster
User avatar

Joined: Thu Mar 29, 2007 10:30 pm
Posts: 1510
Location: Virginia, USA
Google Talk: hpmccloud@gmail.com
???

Code:
'Draw NPC Names
                For i = LBound(MapNpc) To UBound(MapNpc)
                    If MapNpc(i).Num > 0 And CurX = MapNpc(i).x And CurY = MapNpc(i).y Then
                        Call BltNPCName(i)
                    End If
                Next i

_________________
Nean wrote:
Yes harold. Give it to me.

Image
Image


Top
 Profile  
 
 Post subject: Re: Display NPC Names
PostPosted: Fri Sep 19, 2008 9:28 pm 
Offline
Persistant Poster
User avatar

Joined: Thu Mar 29, 2007 10:30 pm
Posts: 1510
Location: Virginia, USA
Google Talk: hpmccloud@gmail.com
Short circuit evaluations still work they just don't work how they should. It would just be for organization really. But never mind on my post.

EDIT:

Never mind...I just did a test with the And statements and without them. I did 10 checks if something was true or not in both ways and did a loop 100 million times and without the and took 8 seconds and with the and took 18 seconds. Don't use And people :D

_________________
Nean wrote:
Yes harold. Give it to me.

Image
Image


Top
 Profile  
 
 Post subject: Re: Display NPC Names
PostPosted: Sat Sep 20, 2008 10:20 am 
Offline
Submit-Happy
User avatar

Joined: Fri Jun 16, 2006 7:01 am
Posts: 2768
Location: Yorkshire, UK
Shit.

_________________
Quote:
Robin:
Why aren't maps and shit loaded up in a dynamic array?
Jacob:
the 4 people that know how are lazy
Robin:
Who are those 4 people?
Jacob:
um
you, me, and 2 others?


Image


Top
 Profile  
 
 Post subject: Re: Display NPC Names
PostPosted: Sun Dec 14, 2008 9:33 pm 
Offline
Regular
User avatar

Joined: Tue Jun 03, 2008 6:22 pm
Posts: 50
Code:
                ' Lock the backbuffer so we can draw text and names
                TexthDC = DD_BackBuffer.GetDC


that doesnt exist in modGameLogic.. :\


Top
 Profile  
 
 Post subject: Re: Display NPC Names
PostPosted: Sun Dec 14, 2008 9:39 pm 
Jared wrote:
Code:
                ' Lock the backbuffer so we can draw text and names
                TexthDC = DD_BackBuffer.GetDC


that doesnt exist in modGameLogic.. :\


Do a project wide search?


Top
  
 
 Post subject: Re: Display NPC Names
PostPosted: Sun Dec 14, 2008 9:40 pm 
Offline
Regular
User avatar

Joined: Tue Jun 03, 2008 6:22 pm
Posts: 50
Yes i did a project wide search, "Nothing"

:\


Top
 Profile  
 
 Post subject: Re: Display NPC Names
PostPosted: Sun Dec 14, 2008 9:42 pm 
Do a search for "TexthDC = DD_BackBuffer.GetDC" without the quotes.


Top
  
 
 Post subject: Re: Display NPC Names
PostPosted: Sun Dec 14, 2008 9:43 pm 
Offline
Regular
User avatar

Joined: Tue Jun 03, 2008 6:22 pm
Posts: 50
that's what i tried first. lol.


Top
 Profile  
 
 Post subject: Re: Display NPC Names
PostPosted: Sun Dec 14, 2008 9:48 pm 
It's in the gameloop sub. Look through it. It's after it calls all the shit for blitting tiles and what not.


Top
  
 
 Post subject: Re: Display NPC Names
PostPosted: Mon Dec 15, 2008 2:36 am 
Offline
Regular
User avatar

Joined: Wed Jul 30, 2008 4:32 pm
Posts: 44
Try to search for:
Code:
TexthDC = DDS_BackBuffer.GetDC

Good luck!

_________________
Image


Top
 Profile  
 
 Post subject: Re: Display NPC Names
PostPosted: Mon Dec 15, 2008 4:53 am 
Offline
Regular
User avatar

Joined: Tue Jun 03, 2008 6:22 pm
Posts: 50
Code:
If GettingMap Then
       
        TexthDC = DDS_BackBuffer.GetDC ' Lock the backbuffer so we can draw text and names


Top
 Profile  
 
 Post subject: Re: Display NPC Names
PostPosted: Sun Jul 12, 2009 5:01 pm 
Offline
Newbie
User avatar

Joined: Sat Jul 11, 2009 4:22 pm
Posts: 1
Google Talk: iHybrid93
Sorry for necro'ing but I have the same problem where I can't find the line Jared couldn't find, I find it in the map portion of the code.
Not only that but I programmed all the code in and it still doesn't work, im using MSE3.79.

This isn't the first time its happened, a lot of times people post tutorials and some people can't even find the line of code they quote and tell them to find, i'm guessing they're using an older version of the source. I just want to know why it doesn't work, I compile it successfully but I test it out and the npcs don't have names over their heads, the only way i'll get an npc name is if I click it.


Top
 Profile  
 
 Post subject: Re: Display NPC Names
PostPosted: Mon Jul 13, 2009 1:39 am 
Offline
Persistant Poster

Joined: Fri Jun 26, 2009 10:15 pm
Posts: 701
Google Talk: FAProductions
I assume you're new, so I'll be nice.

Don't bother using tutorials for things this simple, you really won't learn anything. Your best bet is to look at the code for drawing Player names and modifying it for npcs. Very easy to do.


Top
 Profile  
 
 Post subject: Re: Display NPC Names
PostPosted: Mon Jul 13, 2009 7:45 pm 
Offline
Persistant Poster
User avatar

Joined: Thu Jul 24, 2008 6:42 am
Posts: 703
Google Talk: infectiousbyte@gmail.com
Matt wrote:
I assume you're new, so I'll be nice.

Don't bother using tutorials for things this simple, you really won't learn anything. Your best bet is to look at the code for drawing Player names and modifying it for npcs. Very easy to do.


Exactly.

Try doing it on your own, if you encounter any problems just post and we'd be happy to help you figure it out. However, we will NOT do it for you.

_________________
Image
GIAKEN wrote:
Since I'm into men, not women

GIAKEN wrote:
I can't take these huge penises anymore! All that's left is shame! And blood


Top
 Profile  
 
 Post subject: Re: Display NPC Names
PostPosted: Tue Aug 11, 2009 6:13 am 
Offline
Newbie
User avatar

Joined: Thu Mar 05, 2009 2:45 am
Posts: 20
I tried doing this on my own but whenever I put my mouse over an npc nothing happens, I did it correctly as shown above and when I hover my mouse over an npc nothing exquisite happens, is there anything else I have to add because it won't show the character name when I hover my mouse over the npc.


Top
 Profile  
 
 Post subject: Re: Display NPC Names
PostPosted: Thu Oct 01, 2009 6:13 pm 
Offline
Newbie

Joined: Wed Sep 23, 2009 12:34 am
Posts: 3
Code:
Public Sub DrawNPCName(ByVal Index As Long)
Dim TextX As Long
Dim TextY As Long
Dim color As Long
   
    Select Case Npc(MapNpc(Index).Num).Behavior
        Case 0
            color = KeyRed
        Case 1
            color = KeyYellow
        Case 2
            color = KeyWhite
        Case 3
            color = KeyWhite
        Case 4
            color = KeyWhite
    End Select
   
    With Npc(MapNpc(Index).Num)
   
    'Draw name and determine location
        TextX = MapNpc(Index).x * PIC_X + MapNpc(Index).XOffset + CLng(PIC_X / 2) - ((Len(Trim$(.Name)) / 2) * 8)
        TextY = MapNpc(Index).y * PIC_Y + MapNpc(Index).YOffset - CLng(PIC_Y / 2) - 4
        Call DrawText(TextX, TextY, TextY + 15, ((Len(Npc(MapNpc(Index).Num).Name)) * 8) + 15, Trim$(.Name), CStr(color))
    End With
   
   
    If TextX < 0 Then TextX = 0
    If TextY < 0 Then TextY = 0

End Sub


My code is working fine, except that all NPCs regardless of behavior have their name in red. Do you think that the select case I made should work correctly? Or did I mess up somewhere, I am trying to have the name of each npc be in a different color based on their behavior (attack on sight, attack when attacked, etc.) And I just can't think of what I did wrong here.


Top
 Profile  
 
 Post subject: Re: Display NPC Names
PostPosted: Fri Oct 02, 2009 5:26 am 
Offline
Persistant Poster
User avatar

Joined: Tue May 30, 2006 2:07 am
Posts: 836
Location: Nashville, Tennessee, USA
Google Talk: rs.ruggles@gmail.com
I think NPC behavior are strictly strings. like FRIENDLY or ATTACKONSIGHT or whatever. Been a while since I opened a source.

_________________
I'm on Facebook! Google Plus My Youtube Channel My Steam Profile

Image


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 1484 posts ]  Go to page 1, 2, 3, 4, 5 ... 60  Next

All times are UTC


Who is online

Users browsing this forum: No registered users and 21 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB® Forum Software © phpBB Group