damage above enemy

Posted By: wyldecatt

damage above enemy - 01/27/08 05:36

Could i get set in the right direction for writting a bit of code to display the damage done above an enemy. I knos this should be pretty common as it is done in most games but i couldnt seem to find a snipit for it or get my eggorts offf the ground
thanks
Posted By: Xarthor

Re: damage above enemy - 01/27/08 09:44

I will write some information how this can be done:

1. get the world coordinates of the entity (through a vertex above the head and vec_for_vertex or just the z-pos plus any value)

2. translate that position into screen coordinates with vec_to_screen

3.1 If you want a digit display: just show a text/panel at that position.

3.2 If you want a bar displaying how much HP the enemie has left you would need to subtract half of the bars width from the x-position you got in #2 and display the panel at that location


Hope this helps a bit
Posted By: wyldecatt

Re: damage above enemy - 01/30/08 01:00

Ive given it a shot but cant seem to get it to work right. Ive decied to use the health var to display atm because my damage is computed from a random defence/atack varibles. I dont need a health above char i do already have a working health bar above my enemys here is what i have

PANEL health_pan =
{
bmap = health_map;
digits(0,0,4,health_fnt,10,health);
//flags = transparent,d3d,VISIBLE;
flags = VISIBLE;

}



function health_panel()
{
while(1)
{
vec_set(temp,my.x);
if (vec_to_screen(temp,camera)) // if visible on screen
{
health_pan.pos_x = temp.x; // place the flare panel
health_pan.pos_y = temp.y;
health_pan.visible = on;
} else
{
//health_pan.visible = off; // otherwise disable it
}
wait(1);
}
}

thanks in advance
Posted By: wyldecatt

Re: damage above enemy - 01/30/08 01:02

A note to the above post my function is called from the enemys action.
and its actually my.health in the function
i do get the panel to display at one of my enemys but it displays 0 for health
Posted By: Xarthor

Re: damage above enemy - 01/30/08 11:30

Well the panel does not know what "my.health" is, or does it?
You need a global var (I think) which gets the current my.health value.
That global var can then be used in the panel.
© 2024 lite-C Forums