Hi there,
i got a problem. I´ve written a script that shows the dmg or healing over the head of a unit. For that i always check if the health of the unit is the same as before. if not it start a function that checks if the health is over the old value or above. Then it starts another function that creates the text and moves the text up.
Everything works fine. My problem now is.
I´m using draw_text for this.
draw_text(value_str,vTextpos.x,vTextpos.y+move_up,text_color);
the problem now is. if my unit gets several dmg in a short time. The string of draw text changes to the new value. Thats ok but my old strings (thos who are flying upwards with the dmg before) also change their value to the new one.
DMG Income (252) -> Text above (252)
DMG Income (332) -> Text above (332, 332)
DMG Income (415) -> Text above (415, 415, 415)
normally it should be
DMG Income (415) -> Text above (252, 332, 415)
I think it depends on draw_text. Can draw_text jsut display on string at the same time even if the functions are seperated?
Greets
Here´s the code from the unit:
if(save_health != my.health)
{
show_dmg(save_health);
save_health = my.health;
}
Here´s the function show_dmg:
function show_dmg(var save_health)
{
STRING* health_add_str = "#5";
STRING* health_loose_str = "#5";
var health_add = 0;
var health_loose = 0;
VECTOR color;
if(my.health > save_health)
{
health_add = (my.health - save_health);
vec_set(color, vector(100,255,100));
str_for_num(health_add_str, health_add);
dmg_text(health_add_str, color);
}
if(my.health < save_health)
{
health_loose = (save_health - my.health);
vec_set(color, vector(50,50,255));
str_for_num(health_loose_str, health_loose);
dmg_text(health_loose_str, color);
}
}
here´s the dmg_text function:
function dmg_text(STRING* ab_text, VECTOR* color)
{
var hold_text = 0;
var move_up = 0;
var fade = 100;
var draw_var;
VECTOR text_color;
VECTOR vTextpos;
STRING* value_str = "#5";
vec_set(text_color, color);
str_cpy(value_str, ab_text);
while(1)
{
vec_set(vTextpos, vector(my.x,my.y,my.z+my.max_z+40)) ;
vec_to_screen(vTextpos,camera);
move_up -= 2*time_step;
fade -= 3*time_step;
draw_text(value_str,vTextpos.x,vTextpos.y+move_up,text_color);
//draw_textmode(NULL,0,0,fade);
if(fade <= 0)
{
break;
}
wait(1);
}
}