Mirage Source http://www.miragesource.net/forums/ |
|
Display NPC Names http://www.miragesource.net/forums/viewtopic.php?f=183&t=4328 |
Page 1 of 60 |
Author: | DarkC [ Mon Sep 15, 2008 10:35 pm ] |
Post subject: | Display NPC Names |
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 |
Author: | Doomy [ Mon Sep 15, 2008 10:39 pm ] |
Post subject: | Re: Display NPC Names |
hope it works *crosses fingers |
Author: | DarkC [ Mon Sep 15, 2008 10:55 pm ] |
Post subject: | Re: Display NPC Names |
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. |
Author: | skillzalot [ Tue Sep 16, 2008 12:34 am ] |
Post subject: | Re: Display NPC Names |
Nice tutorial |
Author: | DarkC [ Tue Sep 16, 2008 12:56 am ] |
Post subject: | Re: Display NPC Names |
Thank you. |
Author: | Anthony [ Tue Sep 16, 2008 2:56 am ] |
Post subject: | Re: Display NPC Names |
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 |
Author: | Doomy [ Tue Sep 16, 2008 4:25 am ] |
Post subject: | Re: Display NPC Names |
thx now imma use this XD |
Author: | GIAKEN [ Fri Sep 19, 2008 8:54 pm ] |
Post subject: | Re: Display NPC Names |
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. |
Author: | GIAKEN [ Fri Sep 19, 2008 9:14 pm ] |
Post subject: | Re: Display NPC Names |
??? 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 |
Author: | GIAKEN [ Fri Sep 19, 2008 9:28 pm ] |
Post subject: | Re: Display NPC Names |
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 |
Author: | Robin [ Sat Sep 20, 2008 10:20 am ] |
Post subject: | Re: Display NPC Names |
Shit. |
Author: | Jared [ Sun Dec 14, 2008 9:33 pm ] |
Post subject: | Re: Display NPC Names |
Code: ' Lock the backbuffer so we can draw text and names TexthDC = DD_BackBuffer.GetDC that doesnt exist in modGameLogic.. :\ |
Author: | Matt [ Sun Dec 14, 2008 9:39 pm ] |
Post subject: | Re: Display NPC Names |
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? |
Author: | Jared [ Sun Dec 14, 2008 9:40 pm ] |
Post subject: | Re: Display NPC Names |
Yes i did a project wide search, "Nothing" :\ |
Author: | Matt [ Sun Dec 14, 2008 9:42 pm ] |
Post subject: | Re: Display NPC Names |
Do a search for "TexthDC = DD_BackBuffer.GetDC" without the quotes. |
Author: | Jared [ Sun Dec 14, 2008 9:43 pm ] |
Post subject: | Re: Display NPC Names |
that's what i tried first. lol. |
Author: | Matt [ Sun Dec 14, 2008 9:48 pm ] |
Post subject: | Re: Display NPC Names |
It's in the gameloop sub. Look through it. It's after it calls all the shit for blitting tiles and what not. |
Author: | Kraft [ Mon Dec 15, 2008 2:36 am ] |
Post subject: | Re: Display NPC Names |
Try to search for: Code: TexthDC = DDS_BackBuffer.GetDC Good luck! |
Author: | Jared [ Mon Dec 15, 2008 4:53 am ] |
Post subject: | Re: Display NPC Names |
Code: If GettingMap Then
TexthDC = DDS_BackBuffer.GetDC ' Lock the backbuffer so we can draw text and names |
Author: | iHybrid [ Sun Jul 12, 2009 5:01 pm ] |
Post subject: | Re: Display NPC Names |
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. |
Author: | Matt [ Mon Jul 13, 2009 1:39 am ] |
Post subject: | Re: Display NPC Names |
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. |
Author: | Nean [ Mon Jul 13, 2009 7:45 pm ] |
Post subject: | Re: Display NPC Names |
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. |
Author: | Ciao [ Tue Aug 11, 2009 6:13 am ] |
Post subject: | Re: Display NPC Names |
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. |
Author: | predators [ Thu Oct 01, 2009 6:13 pm ] |
Post subject: | Re: Display NPC Names |
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. |
Author: | Rian [ Fri Oct 02, 2009 5:26 am ] |
Post subject: | Re: Display NPC Names |
I think NPC behavior are strictly strings. like FRIENDLY or ATTACKONSIGHT or whatever. Been a while since I opened a source. |
Page 1 of 60 | All times are UTC |
Powered by phpBB® Forum Software © phpBB Group https://www.phpbb.com/ |