Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Npc Targeting
#1
Hello,

These are few questions more targeted to Robin... Its based on the source I got from him [v0.0.9].
But anyone else willing can take a shot at answering them Smile

I have a problem right now with targeting NPC's. If I click on myself or another player it tells me that they are my target. But if I click on an NPC [monster/npc], it dosent show them as targeted. I was wondering how I could do that.

Also I would like when they are targeted to blt a 32x32 sprite box around them, and also if their a NPC/Friendly to have a seprete sprite [a blue square], and if their a monster [bat/etc.] to blt a seprate [a red square] sprite.

Ex:
[Image: bee_target.jpg] [Image: guy_target.jpg]

Thanks Smile

*Edit: Heres the code (i think) for the targeting:
Code:
Public Sub BltTarget()
If TargetType = TARGET_TYPE_PLAYER Then
  rec.top = 240
  rec.Left = 0
  rec.Bottom = rec.top + 80 + 8
  rec.Right = rec.Left + 48
  'rec.top = 0
  'rec.Bottom = 20
  'rec.Left = 0
  'rec.Right = 20
  DD_MiddleBuffer.BltFast (Player(Target).X * 32) + Player(Target).XOffset - 8, (Player(Target).Y * 32) + Player(Target).YOffset - 44, DD_MiscSurf, rec, DDBLTFAST_WAIT Or DDBLTFAST_SRCCOLORKEY
  'DD_MiddleBuffer.BltFast 20, 20, DD_MiscSurf, rec, DDBLTFAST_SRCCOLORKEY And DDBLTFAST_WAIT
Else
  rec.top = 240
  rec.Left = 0
  rec.Bottom = rec.top + 80 + 8
  rec.Right = rec.Left + 48
  DD_MiddleBuffer.BltFast (MapNpc(Target).X * 32) + MapNpc(Target).XOffset - 8, (MapNpc(Target).Y * 32) + MapNpc(Target).YOffset - 44, DD_MiscSurf, rec, DDBLTFAST_WAIT Or DDBLTFAST_SRCCOLORKEY
End If
End Sub
Reply
#2
Try and post the code for it, maybe something is wrong with whats currently there.
Reply
#3
For the squares, I suggest you just use directdraw. Don't waste time with the sprite.
Reply
#4
Allright ill try that, does anyone know whats up with the npc targeting though?
Reply
#5
Here's my BltTargetting sub.

Code:
Public Sub BltTargetting()
Dim X As Long
Dim Y As Long
Dim rec As DXVBLib.RECT

    If Not OverPlay Then
        If Current_Target = 0 Or Current_TargetType = TARGET_TYPE_NONE Then Exit Sub
    End If

    If Current_TargetType = TARGET_TYPE_PLAYER And HasTarget Then
        If Current_Target  MyIndex Then
            If GetPlayerMap(Current_Target)  GetPlayerMap(MyIndex) Then Exit Sub
        End If
    End If

    With rec
        .Top = PIC_Y
        If Not HasTarget Then .Top = 0
        .Bottom = .Top + PIC_Y
        .Left = 40 * TargetLeft
        .Right = .Left + 40
    End With
    
    If HasTarget Then
        If Current_TargetType = TARGET_TYPE_PLAYER Then
            X = ((Norm.X_Loc(GetPlayerX(Current_Target)) + Player(Current_Target).XOffset) - 4)
            Y = ((Norm.Y_Loc(GetPlayerY(Current_Target)) + Player(Current_Target).YOffset) + 8)
        ElseIf Current_TargetType = TARGET_TYPE_NPC Then
            X = ((Norm.X_Loc(MapNpc(Current_Target).X) + MapNpc(Current_Target).XOffset) - 4)
            Y = ((Norm.Y_Loc(MapNpc(Current_Target).Y) + MapNpc(Current_Target).YOffset) + 8)
        End If
    Else
        X = (CurX * PIC_X) - 4
        Y = (CurY * PIC_Y) + 8
    End If
    
    If X < 0 Then
        X = 0
        With rec
            .Left = .Left + (X * -1)
        End With
    End If
    
    Call DD_BackBuffer.BltFast(X, Y, DD_Target, rec, DDBLTFAST_WAIT Or DDBLTFAST_SRCCOLORKEY)

End Sub
Reply
#6
I tried it but it gave me some errors, i guess ill have to modify it Tongue

Thank you though.

Edit* Nope i modified it and it still wont target npc's :/

Double Edit* Im trying to get it when you target an NPC it tells you in the txtChat that it is your target. Right now it only works for players like "n% is now your target."
Reply
#7
find where it targets the player when you click on them. copy that paste it where it should be and change to NPC. IT really help me if i saw the code though.

like for example, 4.6 code sorry ^^ but basically find something close to this in the player

Code:
' Change target
            TempPlayer(Index).Target = i
            TempPlayer(Index).TargetType = TARGET_TYPE_PLAYER
            Call PlayerMsg(Index, "Your target is now " & GetPlayerName(i) & ".", Yellow)

//npc// for 4.6
Code:
' Check for an npc
    For i = 1 To MAX_MAP_NPCS
        If MapNpc(GetPlayerMap(Index), i).Num > 0 Then
            If MapNpc(GetPlayerMap(Index), i).x = x And MapNpc(GetPlayerMap(Index), i).y = y Then
                ' Change target
                TempPlayer(Index).Target = i
                TempPlayer(Index).TargetType = TARGET_TYPE_NPC
                Call PlayerMsg(Index, "Your target is now a " & Trim$(Npc(MapNpc(GetPlayerMap(Index), i).Num).Name) & ".", Yellow)
                Exit Sub
            End If


TempPlayer(Index).Target = i changes the target selected

TempPlayer(Index).TargetType = TARGET_TYPE_NPC changes the target type to npc so it doesn't show up as a player haha ^^

Call PlayerMsg(Index, "Your target is now " & Trim$(Npc(MapNpc(GetPlayerMap(Index), i).Num).Name) & ".", Yellow) calls the message that says "Your target is now npc1.
Reply
#8
well the code i used is from MSE 4.6< which i said on there> but basically search for TargetType and you should find it.
should be server side for one.
in mod handle data in 4.6 so you can try that ^^.

just things to help you find it.

he must have just deleted his recent post V.V sigh~
Reply
#9
Sweet!

Got it working Smile Thanks alot genusis!

heres what I came up with:
Code:
' Check for an npc
  For i = MAX_MAP_NPCS To 1 Step -1
    If MapNpc(GetPlayerMap(index), i).Num > 0 Then
    If MapNpc(GetPlayerMap(index), i).x = x And MapNpc(GetPlayerMap(index), i).y = y Then
      ' Change target
      Player(index).Target = i
      Player(index).TargetType = TARGET_TYPE_NPC
      SendTarget index
      If Mid(Trim(Npc(MapNpc(GetPlayerMap(index), i).Num).Name), 0, 1) = "a" Then
        Call PlayerMsg(index, "Your target is now a " & Trim(Npc(MapNpc(GetPlayerMap(index), i).Num).Name) & ".", Yellow)
      End If
      Exit Sub
    End If
    End If
  Next i

Works great now Smile
Reply
#10
you are welcomed ^^.
Reply
#11
What button are you using to cast spells?
Reply
#12
I dont know Tongue where could i find that out?

this is my first week working with vb6 and ms XD
Reply
#13
Yeah my code for targetting is a bit more complicated than just the blting part, sorry.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)