var PlayerGesundheit = 100;
action Spieler
{
var Bewegung;
var Gravitation;
var Distanz_zum_Boden;
var Laufgeschwindigkeit = 10; // Grundwert
var Drehgeschwindigkeit = 5; // Grundwert
var Animationsfortschritt = 0; // Grundwert
var Animationsgeschwindigkeit = 6; // Grundwert
c_setminmax(my);
player = my;
my.shadow = on;
while (PlayerGesundheit > 0)
{
// Gravitation
// -----------
vec_set(temp, player.x);
temp.z -= 10000;
Distanz_zum_Boden = c_trace (my.x, temp.x, ignore_me | use_box | ignore_passable);
Gravitation.z -= Distanz_zum_Boden; // Fuesse der Spielerfigur auf Boden setzen
Gravitation.z = max (-25 * time_step, Gravitation.z); // 25 = Fallgeschwindigkeit
// rennen
// ------
Bewegung.x = Laufgeschwindigkeit * ((key_w || key_cuu) - (key_s || key_cud)) * time_step;
Bewegung.y = 0;
my.pan += Drehgeschwindigkeit * ((key_a || key_cul) - (key_d || key_cur)) * time_step;
if (Bewegung.x != 0)
{
Animationsgeschwindigkeit = 10;
ent_animate(my, "walk", Animationsfortschritt, anm_cycle);
}
else
{
Animationsgeschwindigkeit = 6;
ent_animate(my, "stand", Animationsfortschritt, anm_cycle);
}
Animationsfortschritt += Animationsgeschwindigkeit * time_step;
// laufen
// ------
if (key_shiftl == on || key_shiftr == on)
{
Laufgeschwindigkeit = 6;
Drehgeschwindigkeit = 3;
Animationsgeschwindigkeit = 6;
}
// wieder rennen
// -------------
if (key_shiftl == off && key_shiftr == off)
{
Laufgeschwindigkeit = 10;
Drehgeschwindigkeit = 5;
}
// angreifen
// ---------
if (key_ctrl == on && key_space == off)
{
Laufgeschwindigkeit = 0;
ent_animate(my, "attack", 0, anm_cycle);
}
if (key_ctrl == on && key_space == on)
{
Laufgeschwindigkeit = 0;
Animationsgeschwindigkeit = 6;
ent_animate(my, "attack", Animationsfortschritt, anm_cycle);
Animationsfortschritt += Animationsgeschwindigkeit * time_step;
//Messer();
Pistole();
}
// Items
// -----
if (key_1 == on)
{
c_scan(player.x, player.pan, vector(120, 180, 70), ignore_me);
}
// Bewegungen umsetzen
// -------------------
c_move (my, Bewegung, nullvector, glide | ignore_passable);
c_move (my, Gravitation, nullvector, glide | ignore_passable);
// Endlosschleife verhindern
wait(1);
}
// sterben
// -------
Animationsfortschritt = 0;
Animationsgeschwindigkeit = 6;
while (Animationsfortschritt < 100)
{
ent_animate(my, "death", Animationsfortschritt, null);
Animationsfortschritt += Animationsgeschwindigkeit * time_step;
wait (1);
}
my.passable = on;
}