action player_walk()
{
player = my;
set(my,SHADOW);
my.skill4 = 1; // height above ground, should not be equal or below zero - increase min_z (min_z is negative) instead, if necessary
cameraa();
showMiniMap();
health_indicator();
power_indicator();
my.health = 100;
var anim_percent = 0; // animation percentage
mouse_mode = 0;
while (my.health > 0)
{
// horizontal movement
if(my.health < 100)
{
ent_morphskin(my,"sid1.bmp");
}
if(my.health < 75)
{
ent_morphskin(my,"sid2.bmp");
}
if(my.health < 10 )
{
ent_morphskin(my,"sid3.bmp");
}
my.pan += (key_a-key_d)*15*time_step;
my.skill1 += ((key_w-key_s)*20 - my.skill1)*time_step; // makes player accelerate and stop smoothly
c_move (my, vector(my.skill1*time_step, 0, 0), nullvector, GLIDE);
if(key_w)
{
anim_percent += 10*time_step;
ent_animate(me,"run",anim_percent,ANM_CYCLE); // play the "stand" animation
}
else // player stands still
{
anim_percent += 2*time_step;
ent_animate(me,"stand",anim_percent,ANM_CYCLE); // play the "stand" animation
}
if(key_s)
{
anim_percent -= 15*time_step;
ent_animate(me,"run",anim_percent,ANM_CYCLE); // play the "stand" animation
}
if(mouse_middle)
{
cameraa_fly();
}
else
{
cameraa();
}
if(key_w && mouse_right)
{
my.skill2 += ((key_w && mouse_right)*20 - my.skill2)*time_step;
c_move (my, vector(my.skill2*time_step, 0, 0), nullvector, GLIDE);
anim_percent += 10*time_step;
ent_animate(me,"fly",anim_percent,ANM_CYCLE); // play the "stand" animation
powers_ok();
}
if(key_space)
{
anim_percent += 1*time_step;
ent_animate(me,"jump",anim_percent,ANM_CYCLE); // play the "stand" animation
}
// vertical movement and gravity
result = c_trace(my.x,vector(my.x,my.y,my.z-200),IGNORE_ME | IGNORE_PASSABLE)+my.min_z;
result += !trace_hit*200; // when !trace_hit ist true, c_trace returns 0, that's why we have to add some quants (f.i. the maximum trace distance)
if(trace_hit) my.skill3 = target.z; // see 25 lines below
else my.skill3 = -9999999;
if(result > my.skill4 || my.skill2 > 0) {
my.skill2 -= gravity_acceleration*time_step;
my.skill2 = maxv(my.skill2,-80);
c_move(me,nullvector,vector(0,0,my.skill2*time_step),GLIDE);
}
else {
my.skill2 = 0;
if(key_space)
{
if(key_space_released) {
key_space_released = 0;
my.skill2 = 35; // jump strength
}
}
else key_space_released = 1; // no infinite jumping, release space (while on ground) for a new jump
}
// my.z = maxv(my.z,my.skill3+my.skill4-my.min_z); // make sure player's feet stay above ground
wait(1);
}
wait(1);
// the player is dead here
my.skill22 = 0;
while (my.skill22 < 100)
{
reset (time_pan, VISIBLE);
reset (timex, VISIBLE);
sec = -1;
ent_morphskin(my,"sid3.bmp");
//die_cam();
mouse_mode = 2;
set(die , VISIBLE);
my.skill22 += 3 * time_step;
ent_animate(my, "die", my.skill22, NULL); // play a one-shot "death" animation
time_factor = 0.5;
wait (1);
}
set (my, PASSABLE);
wait(1);
}