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

[EO DX8]Target-Details Tutorial


Kaymak
 Share

Recommended Posts

**Target-Details Tutorial**

(This Tutorial was made for every DX8 Engine)

**![](http://fs1.directupload.net/images/150615/67efct7c.png)**

**Hello Eclipse Community**

I saw a Tutorial from @[member="Abhi"] about Target-Detail Information, and i thought that we could make it way easier and also for DX8 Engines.

Also @[member="Hackertatio"], thanks to this guy who figured out with me some stuff at 4a.m in the morning to make this happen.

Basically all this Tutorial does is, when you target a NPC with your Left Mouse Button it shows a Information Bar with the Name, HP and Level. Of Course you add more things when you have a bit knowledge. Also i try to update this tutorial whenever i add something new.

**Lets get started! (Only Client-Side)**

First at all you need to a graphic where you want to show the target-details to your GUI Folder (data files/graphics/gui) I use for example:  [attachment=1518:24.png]

**Source Edit:**

**Add to "modGraphics" at the Bottom**

```

Public Sub DrawTargetDetails()

Dim i As Long, x As Long, y As Long, npcNum As Long
Dim Width As Long, Height As Long, SpriteNum As Long
Dim MapNpcNum As Long
Dim Name As String
Dim HpBar As String

    ' render the window
    Width = 256
    Height = 64
    ' render the window on screen
    x = 300
    y = 64

    ' render the details
    RenderTexture Tex_GUI(24), x, y, 0, 0, Width, Height, Width, Height

    npcNum = MapNpc(myTarget).Num
    ' exists?
    If npcNum > 0 Then
        Name = Trim$(NPC(npcNum).Name)
        HpBar = Trim$(MapNpc(npcNum).Vital(HP))
        ' show the information
        RenderText Font_Default, Name, x + 10, y + 4, Yellow
        RenderText Font_Default, MapNpc(myTarget).Vital(HP) & "/" & NPC(MapNpc(myTarget).Num).HP, x + 66, y + 15, Yellow
        RenderText Font_Default, NPC(npcNum).Level, x + 150, y + 4, Yellow
    End If

End Sub

```
^ This Sub will Render the Graphic and the Details on the Screen.

**At "modGraphics" look for:**

```
Public Sub DrawTarget(ByVal x As Long, ByVal y As Long)
```
In this Sub you add above Exit Sub:

```
If myTargetType = TARGET_TYPE_NPC Then
       DrawTargetDetails
   End If

```
^ This will call the the Sub we added before when you click a **NPC**.

This was my first Tutorial so excuse if i missed something. i would be glad if you leave a comment so i can improve my future tutorials.

Greetings

Kaymak
Link to comment
Share on other sites

  • Replies 53
  • Created
  • Last Reply

Top Posters In This Topic

@[member="Colonello"] Thank you alot. I try to post more Tutorials in a couple of days. I hope i can improve to make tutorials, to explain a little bit more.

@[member="Lelyiaa"] I'm using my own modified version of Eclipse Mega which you can find under custom versions . But i really recommend if you dont have alot of development knowledge to use Eclipse Final Frontier.
Link to comment
Share on other sites

just a question because i can't figure it out for the life of me, but why are you doing a for loop? it doesn't seem to be of any use inside of the code here. this is using myTarget, not i lol, from what i see, I is to check for nothing? sorry, i might be just not seeing the use for it xD
Link to comment
Share on other sites

> just a question because i can't figure it out for the life of me, but why are you doing a for loop? it doesn't seem to be of any use inside of the code here. this is using myTarget, not i lol, from what i see, I is to check for nothing? sorry, i might be just not seeing the use for it xD

Just glancing over it, it seems that the "i" is simply being used to check if it IS indeed an NPC being targeted.
Link to comment
Share on other sites

@[member="SkywardRiver"] You must be thinking of the check before the actual call is made

For loop is constantly drawing the same thing, i say this because it's not actually checking to see if it's the correct npc, it's just checking to see the ncpnum is higher than 0, and if so, render, essentially this is rendering nearly 10-20(depending on how many npcs there are) times everytime it's called lol

```
'write name & level & hp
For i = 1 To Npc_HighIndex ' Go through every possible npc within the map
       If MapNpc(i).num > 0 Then ' Check if MapNPC Num is more than 0, if so, proceed
RenderText Font_Default, NPC(MapNpc(myTarget).num).Name, x + 10, y + 4, Yellow
RenderText Font_Default, MapNpc(myTarget).Vital(HP) & "/" & NPC(MapNpc(myTarget).num).HP, x + 55, y + 15, Red
RenderText Font_Default, NPC(MapNpc(myTarget).num).Level, x + 150, y + 4, Yellow
End If
Next

```

it just looks highly innefficient to me
Link to comment
Share on other sites

> @[member="SkywardRiver"] You must be thinking of the check before the actual call is made
>
> For loop is constantly drawing the same thing, i say this because it's not actually checking to see if it's the correct npc, it's just checking to see the ncpnum is higher than 0, and if so, render, essentially this is rendering nearly 10-20(depending on how many npcs there are) times everytime it's called lol
>
> ```
> 'write name & level & hp
> For i = 1 To Npc_HighIndex ' Go through every possible npc within the map
>        If MapNpc(i).num > 0 Then ' Check if MapNPC Num is more than 0, if so, proceed
> RenderText Font_Default, NPC(MapNpc(myTarget).num).Name, x + 10, y + 4, Yellow
> RenderText Font_Default, MapNpc(myTarget).Vital(HP) & "/" & NPC(MapNpc(myTarget).num).HP, x + 55, y + 15, Red
> RenderText Font_Default, NPC(MapNpc(myTarget).num).Level, x + 150, y + 4, Yellow
> End If
> Next
>
> ```
> it just looks highly innefficient to me

I'd say it's still checking to make sure it's an NPC at all. There doesn't seem to be any code for checking other players. It needs to be rendered constantly because the health may change, yes?

Unless I'm just super tired and missing something.
Link to comment
Share on other sites

> I'd say it's still checking to make sure it's an NPC at all. There doesn't seem to be any code for checking other players. It need to be rendered constantly because the health may change, yes?
>
>  
>
> Unless I'm just super tired and missing something.

That's not what i mean

when the sub is actually called it's making a check to see if it's an NPC to begin with, after that, it goes into a for loop through NPC_HighIndex, meaning every npc within the map, this means, even if it's not the npc we're targeting, it's still calling DrawText, now mind you, 1 or 2 npcs you won't notice anything, throw nearly 30 to 40 in, and you'll start to see a drop in some performance and a bit more cpu usage since it's calling 3 DrawTexts for EVERY npc, not just the npc we're targeting. the constant rendering is done inside Render_Graphics. all im saying is, that for loop is going to kill the cpu with unnecessary calls

EDIT: and even if it does need to be updated constantly, it doesn't need to be updated to the absolute ms, it can be thrown into a small timer(about 15-60ms timer) and it will still be fast enough to read perfectly fine.
Link to comment
Share on other sites

> That's not what i mean
>
>  
>
> when the sub is actually called it's making a check to see if it's an NPC to begin with, after that, it goes into a for loop through NPC_HighIndex, meaning every npc within the map, this means, even if it's not the npc we're targeting, it's still calling DrawText, now mind you, 1 or 2 npcs you won't notice anything, throw nearly 30 to 40 in, and you'll start to see a drop in some performance and a bit more cpu usage since it's calling 3 DrawTexts for EVERY npc, not just the npc we're targeting. the constant rendering is done inside Render_Graphics. all im saying is, that for loop is going to kill the cpu with unnecessary calls
>
>  
>
> EDIT: and even if it does need to be updated constantly, it doesn't need to be updated to the absolute ms, it can be thrown into a small timer(about 15-60ms timer) and it will still be fast enough to read perfectly fine.

Ohhh Okay. Sorry I didn't see your point sooner, I must be pretty tired. Yeah, you're right.

```
Public Sub DrawTargetDetails()
Dim i As Long, x As Long, y As Long
Dim Width As Long, Height As Long
Dim UpdateTimer as Long

' render the window
Width = 256
Height = 64
' render the window on screen
x = 300
y = 64

' render the details
RenderTexture Tex_GUI(24), x, y, 0, 0, Width, Height, Width, Height

If UpdateTimer < GetTickCount then
'write name & level & hp *update*
RenderText Font_Default, NPC(MapNpc(myTarget).num).Name, x + 10, y + 4, Yellow
RenderText Font_Default, MapNpc(myTarget).Vital(HP) & "/" & NPC(MapNpc(myTarget).num).HP, x + 55, y + 15, Red
RenderText Font_Default, NPC(MapNpc(myTarget).num).Level, x + 150, y + 4, Yellow
UpdateTimer = GetTickCount + 30
End if

End Sub

```
 There, that should fix the problem while also keeping the Target Vitals updated. I didn't test this and I'm pretty tired, so I may have missed something.
Link to comment
Share on other sites

> Ohhh Okay. Sorry I didn't see your point sooner, I must be pretty tired. Yeah, you're right.
>
> ```
> Public Sub DrawTargetDetails()
> Dim i As Long, x As Long, y As Long
> Dim Width As Long, Height As Long
> Dim UpdateTimer as Long
>
> ' render the window
> Width = 256
> Height = 64
> ' render the window on screen
> x = 300
> y = 64
>
> ' render the details
> RenderTexture Tex_GUI(24), x, y, 0, 0, Width, Height, Width, Height
>
> If UpdateTimer < GetTickCount then
> 'write name & level & hp *update*
> RenderText Font_Default, NPC(MapNpc(myTarget).num).Name, x + 10, y + 4, Yellow
> RenderText Font_Default, MapNpc(myTarget).Vital(HP) & "/" & NPC(MapNpc(myTarget).num).HP, x + 55, y + 15, Red
> RenderText Font_Default, NPC(MapNpc(myTarget).num).Level, x + 150, y + 4, Yellow
> UpdateTimer = GetTickCount + 30
> End if
>
> End Sub
>
> ```
>  There, that should fix the problem while also keeping the Target Vitals updated. I didn't test this and I'm pretty tired, so I may have missed something.

xD that still won't work lol, UpdateTimer would get cleared the moment the sub goes out, technically speaking you'd want the timer as a public variable(in like modglobals or modGameLogic if you want to get organized) and store it there(although i would just put the tick check around the call check instead but this works too), doing what you have now would always say if UpdateTimer(which = 0 everytime) < Tick Then. it would act like that statement isn't even there lol sorry, just nit picky with code sometimes
Link to comment
Share on other sites

> xD that still won't work lol, UpdateTimer would get cleared the moment the sub goes out, technically speaking you'd want the timer as a public variable(in like modglobals or modGameLogic if you want to get organized) and store it there(although i would just put the tick check around the call check instead but this works too), doing what you have now would always say if UpdateTimer(which = 0 everytime) < Tick Then. it would act like that statement isn't even there lol sorry, just nit picky with code sometimes

~~Does it matter if it get's cleared every time? Because all I'm checking for is if it's less than GetTickCount. Even if cleared, the new number would still be less than GetTickCount. And then it will jump up to GetTickCount + 30ms after.~~

Wait a minute! Just realized how the render is called. >.< I'm an idiot. I'm going to just stop thinking for the night xD I'll post an updated source tomorrow morning.
Link to comment
Share on other sites

> ~~Does it matter if it get's cleared every time? Because all I'm checking for is if it's less than GetTickCount. Even if cleared, the new number would still be less than GetTickCount. And then it will jump up to GetTickCount + 30ms after.~~
>
>  
>
> Wait a minute! Just realized how the render is called. >.< I'm an idiot. I'm going to just stop thinking for the night xD I'll post an updated source tomorrow morning.

lol, it happens :P
Link to comment
Share on other sites

Just adding, not sure if it is just in the engine I used (Skywyre Primitive)  but under the **modEnumerations** -> **GUIType** -> I added **GUI_TARGETDETAILS** to get this to work, without it the game will crash.
Link to comment
Share on other sites

You might want to look into removing the for loop within your code, it's unnecessary and just adds into the cpu usage, especially since said for loop is literally checking to see if npcnum is more than 0 and is constantly called 10-20 times every "second"
Link to comment
Share on other sites

@'Growlith1223':

> You might want to look into removing the for loop within your code, it's unnecessary and just adds into the cpu usage, especially since said for loop is literally checking to see if npcnum is more than 0 and is constantly called 10-20 times every "second"

yes i was brain dead. gonna fix it in a couple of days and add some other features to it :) thank you for letting me know
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...