Sign in to follow this  
tbone

[help]item Cooldown, Hp Bar

Recommended Posts

As topic suggests, i wanna work on the Item cooldown, and show hp of monsters in game. Brainstorming pls, i will start posting ideas when i get hm.

Share this post


Link to post
Share on other sites

And exact number of HP should never be displayed.

 

A percentage of the HP left would be better to display.

 

A player, or monster's hp is not suposed to be disclosed or known by the enemy.

 

How to get it done code-wise, well, there is a packet in the gameserver which it sent to your client, in this packet you add one more value (a byte value) which indicated the percentage.

 

*cp = (int)((m_pClientList[i]->m_iHP / iGetMaxHP(i)) * 100);
cp++;

Share this post


Link to post
Share on other sites

yeah thats the "easy part", but how you create a dynamic bar in the head of the BOSS showing that percentage? there's the challenge

Share this post


Link to post
Share on other sites

Easy for u guys, i'be been cracking my head to no avail -.-".. Been too long away from hb codes now im a goner lolx. Does the client have to be coded as well to receive other's hp%?

 

request for more clues plz.

Edited by tbone

Share this post


Link to post
Share on other sites

Easy for u guys, i'be been cracking my head to no avail -.-".. Been too long away from hb codes now im a goner lolx. Does the client have to be coded as well to receive other's hp%?

actually in this case is mostly client side, the HG only sends the %, the client resolves it by drawing the graphics of the hp bar.

Share this post


Link to post
Share on other sites

Easy for u guys, i'be been cracking my head to no avail -.-".. Been too long away from hb codes now im a goner lolx. Does the client have to be coded as well to receive other's hp%?

actually in this case is mostly client side, the HG only sends the %, the client resolves it by drawing the graphics of the hp bar.

 

true.

 

For the drawing of the health bar a new graphic could be created that looks simeliar to the green SP bar in the bottom interface, slightly smaller bar colored red could be used as a HP bar, both player & npc related.

Share this post


Link to post
Share on other sites

probably you can re use code from that function, but location, parameters and sprites are totaly different, since Guild name request is just a String and is shown as a String, what you need here is get a double and represent it as a percentage of the hp bar,

 

but definitely you can re use a lot of code from there, since that function gets an attribute and prints it in char's status!

Share this post


Link to post
Share on other sites

I'll give you a couple hints for client side part:

 

There is a packed called:

MSGID_EVENT_MOTION

 

It handles all events with motion in them which happen around yourself.

 

Depending on which type of motion, different data is received.

 

All you have to do is add the HP percentage to the global part of this packet.

 

The first actual data is the Object ID.

Depending on this ID, player data or npc data is being read.

 

The last received value for both player & npc is:

iLoc

 

Below thatone, you add the HP Status for both player and npc.

 

Extra Note: You'll have to add the sending of the status at the server side too ! in the identical packet !

 

Now you are able to receive the status, only thing left is to draw it.

If you scroll a bit down, you'll figure OBJECT_MAGIC to draw the spell name and OBJECT_DAMAGE and OBJECT_DAMAGEMOVE to draw the damage you're being hit.

Figure the main part of the drawing where the player/npc is being drawn, and add the HP bar drawing to it.

Share this post


Link to post
Share on other sites

well i tried, funny thing happened.

 

Now when my char appears on screen, he has "Current HP : 488466993" written under him.

 

And everytime I walk, i lose like 1k++ hp. And hp goes to negative LOL.

 

Any comments, coding masters?

Edited by tbone

Share this post


Link to post
Share on other sites

This might sound dumb, but forgive me for i r nuudz:

 

1) How do u check how much data you send, and whether its the correct 1?

 

2)

*cp = (int)((m_pClientList->m_iHP / iGetMaxHP(i)) * 100);

cp++;

 

*cp - string which we store memory

The rest is parsing the str into an int with the formula to get hp%

cp++ - string msg to be passed to client + 1

For the array of clientlist, i use w_object_id, or smth like that.

 

Did i get that right, can you point out where i went wrong?

 

Thx man.

Share this post


Link to post
Share on other sites

The amount of data can be figured from the increment made to the cp variable in this case.

 

++ means 1 byte, += X means X bytes.

 

Char/Byte value: ++

short value: += 2

integer value: += 4

long value: += 8 (<< mostly not used in helbreath as long (aka QWord) does not exist)

 

mostly map names, char names are 10 bytes, guild names 20 bytes, profile 100 bytes.

Share this post


Link to post
Share on other sites

K thx for the explanation, 1 more question. To display the value, i should putstring in draw object name, right?

 

Currently my display is still 48865442+, and mobs disappear from screen when they walk. This is screw up on client side right?

 

Sry for so many questions, im at work nw and no srcs to test on but this is too interesting lol.

Share this post


Link to post
Share on other sites

K thx for the explanation, 1 more question. To display the value, i should putstring in draw object name, right?

 

Currently my display is still 48865442+, and mobs disappear from screen when they walk. This is screw up on client side right?

 

Sry for so many questions, im at work nw and no srcs to test on but this is too interesting lol.

 

yes, because your client reads too much or too less data, it puts wrong values in wrong variables causing unwanted behavior such as the hp display and the monsters disapear.

Long-term usage of invalid or mismatching data can cause serveral client crashes.

If the data is being written to the memory and there's a msmatch, it can even cause serious issues on your computer !

Share this post


Link to post
Share on other sites

bleh, i'm still stuck on this -___-"

 

nvm, tmr i will start from fresh srcs again, chances are i screwed my srcs up with so much playing around :(

 

now i get my hp to show, but client keeps crashing.. zz.

Share this post


Link to post
Share on other sites

bleh, i'm still stuck on this -___-"

 

nvm, tmr i will start from fresh srcs again, chances are i screwed my srcs up with so much playing around :(

 

now i get my hp to show, but client keeps crashing.. zz.

 

it's easy to screw up...

 

even harder to fix...

 

Now you see, adding new features ain't that easy ;)

 

Packets and Pointers are the 2 hardest parts in coding helbreath, you need to know and understand completly how the system works to get something done.

Share this post


Link to post
Share on other sites

Yeah, i agree.

 

But i think hb code is very messy to begin with, makes it a nightmare for newbie coders like me.

 

yeah true, the code is very messy and old.

there is class separation, but none of the variables are private, so there's no encapsulation...

Share this post


Link to post
Share on other sites

Btw about packets.

 

Nemesis is CURRENTLY holding a bug.

2nd slot char is not working in some cases.

It was 4th slot and white fixed. then it was 3rd slot and white fixed. Now is Slot 2 !!!

 

ALWAYS BE CARE WITH PACKET Counting!!.

Share this post


Link to post
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
Sign in to follow this