01-10-2009, 06:13 PM
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.