#include <acknex.h>
#include <default.c>
///// DE-Bugging ONLY - START
STRING* health = "#15"; STRING* v1 = "#15"; STRING* v2 = "#15";
TEXT* healthbar = { pos_x=20; pos_y=210; font="Arial#24bi"; string(health,v1,v2); flags=SHOW; }
//
var test1() { player.skill98 += 1; }
var test2() { player.skill98 -= 1; }
///// DE-Bugging ONLY - END
//=================================================================================================================================
// //
// DAS HUD-SCRIPT //
// ^^^^^^^^^^^^^^ //
// //
//=================================================================================================================================
function heart_1();function heart_2();function heart_3();function heart_4();function heart_5();
function heart_6();function heart_7();function heart_8();function heart_9();function heart_10();function heart_11();
function heart_12();function heart_13();function heart_14();function heart_15();function heart_16();
//
//=================================================================================================================================
// //
// FUNKTIONEN //
// """""""""" //
// //
//=================================================================================================================================
//
ENTITY* hud_ent_heart[8];
//
function heart_startup()
{ var h; for(h=0; h<8; h++) //only needs running ONCE bet game-boot
{ hud_ent_heart[h] = ent_createlayer("Herz.mdl", NULL, 1000);
vec_set(hud_ent_heart[h].x, vector(700,(360-(h*35)),280));
hud_ent_heart[h].tilt = 90; }
}
//
//
function heart_1()
{
var heart_num = integer(player.skill98 / 4);
var h; for(h=0; h<8; h++)
{
if(heart_num<h) //if lower health than this heart
{ ent_animate(hud_ent_heart[h], "heartp", 0, ANM_SKIP); }
else
{
if(heart_num>h) //if higher health than this heart
{ ent_animate(hud_ent_heart[h], "heartp", 100, ANM_SKIP); }
else //if ON this heart
{ ent_animate(hud_ent_heart[h], "heartp", fraction(player.skill98/4)*100, ANM_SKIP); }
}
//insert standard heartbeat animation gere if you want to.
}
///// DE-Bugging ONLY - START
str_cpy(health, ""); str_cat_num(health, "health = %.0f", player.skill98);
str_cpy(v1,""); str_cat_num(v1,"heart = %.0f",heart_num);
str_cpy(v2,""); str_cat_num(v2,"percent = %.0f",fraction(player.skill98/4)*100);
///// DE-Bugging ONLY - END
}
//=================================================================================================================================
// //
// AKTIONEN //
// """""""" //
// //
//=================================================================================================================================
function hud_update()
{
while(1)
{
heart_1();
wait(1);
}
}
function main()
{
fps_max = 60; level_load(NULL); wait(5); diag("\n\n\n"); wait(5);
player = ent_create("player.mdl", nullvector, NULL);
player.skill99 = player.skill98 = 12;
hud_update();
///// DE-Bugging ONLY - START
on_1=test1;
on_2=test2;
///// DE-Bugging ONLY - END
while(1) wait(1);
}