Kaymak Posted May 20, 2015 Author Share Posted May 20, 2015 **Target-Details Tutorial**(This Tutorial was made for every DX8 Engine)******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 LongDim Width As Long, Height As Long, SpriteNum As LongDim MapNpcNum As LongDim Name As StringDim 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 IfEnd 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.GreetingsKaymak Link to comment Share on other sites More sharing options...
GalacticGlum Posted May 20, 2015 Share Posted May 20, 2015 @[member="Kaymak"] great tutorial and again I have no problem helping you again or anyone else. Link to comment Share on other sites More sharing options...
whitespirits Posted May 20, 2015 Share Posted May 20, 2015 fantastic to see tutorials again :) Link to comment Share on other sites More sharing options...
Helladen Posted May 20, 2015 Share Posted May 20, 2015 We'll start to see more, once there's actual scripting. No one likes to use Visual Basic 6, sadly. Link to comment Share on other sites More sharing options...
Lelyiaa Posted May 22, 2015 Share Posted May 22, 2015 Thank you for this great tutorial! :) which DX8 Engine are you using in this example? :) Link to comment Share on other sites More sharing options...
GalacticGlum Posted May 22, 2015 Share Posted May 22, 2015 @[member="Lelyiaa"] this engine is Eclipse Mega. It can be found in custom versions. Link to comment Share on other sites More sharing options...
Lelyiaa Posted May 22, 2015 Share Posted May 22, 2015 @[member="Hackertatio"] Thank you for this very fast answer! ^^ Link to comment Share on other sites More sharing options...
GalacticGlum Posted May 22, 2015 Share Posted May 22, 2015 @[member="Lelyiaa"] no problem! Link to comment Share on other sites More sharing options...
Colonello Posted May 22, 2015 Share Posted May 22, 2015 Excellent tutorial, hopefully we'll start to see even more being made soon. :) Link to comment Share on other sites More sharing options...
Kaymak Posted May 22, 2015 Author Share Posted May 22, 2015 @[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 More sharing options...
Growlith1223 Posted May 24, 2015 Share Posted May 24, 2015 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 More sharing options...
SkywardRiver Posted May 24, 2015 Share Posted May 24, 2015 > 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 xDJust 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 More sharing options...
Growlith1223 Posted May 24, 2015 Share Posted May 24, 2015 @[member="SkywardRiver"] You must be thinking of the check before the actual call is madeFor 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 & hpFor 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, proceedRenderText Font_Default, NPC(MapNpc(myTarget).num).Name, x + 10, y + 4, YellowRenderText Font_Default, MapNpc(myTarget).Vital(HP) & "/" & NPC(MapNpc(myTarget).num).HP, x + 55, y + 15, RedRenderText Font_Default, NPC(MapNpc(myTarget).num).Level, x + 150, y + 4, YellowEnd IfNext```it just looks highly innefficient to me Link to comment Share on other sites More sharing options...
SkywardRiver Posted May 24, 2015 Share Posted May 24, 2015 > @[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 meI'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 More sharing options...
Growlith1223 Posted May 24, 2015 Share Posted May 24, 2015 > 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 meanwhen 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 callsEDIT: 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 More sharing options...
SkywardRiver Posted May 24, 2015 Share Posted May 24, 2015 > 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 LongDim Width As Long, Height As LongDim 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 ifEnd 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 More sharing options...
Growlith1223 Posted May 24, 2015 Share Posted May 24, 2015 > 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 More sharing options...
SkywardRiver Posted May 24, 2015 Share Posted May 24, 2015 > 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 More sharing options...
Growlith1223 Posted May 24, 2015 Share Posted May 24, 2015 > ~~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 More sharing options...
Kizzaa Posted May 26, 2015 Share Posted May 26, 2015 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 More sharing options...
Daneta Posted May 27, 2015 Share Posted May 27, 2015 i did what Kizzaa supposed, but get unrecoverable DX8 error, but if i dont u just cant complie cause the variable GUI_TARGETDETAILS isnt defined so any ideas? Link to comment Share on other sites More sharing options...
Kaymak Posted May 27, 2015 Author Share Posted May 27, 2015 Remove- If GUIWindow(GUI_TARGETDETAILS).Visible Then DrawTargetDetails - and it works#edited tutorial Link to comment Share on other sites More sharing options...
Growlith1223 Posted May 28, 2015 Share Posted May 28, 2015 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 More sharing options...
Kaymak Posted May 28, 2015 Author Share Posted May 28, 2015 @'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 More sharing options...
Growlith1223 Posted May 28, 2015 Share Posted May 28, 2015 lol it happens, I have had so many of these moments xD and no problem! im always here if you or anyone else needs help :P Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now