////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////
#include <acknex.h>
#include <default.c>
////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////
function main()
{
video_set(800,600,32,0);
fps_max = 60;
level_load("level.WMB");
wait(3);
}
////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////
VECTOR dist;
VECTOR absdist;
////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////
#define health skill1
#define state skill2
////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////
SOUND* p_death = "p_death.wav";
SOUND* p_pain = "p_pain.wav";
SOUND* z_alert = "z_alert.wav";
SOUND* z_attack = "z_attack.wav";
SOUND* z_death = "z_death.wav";
////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////
function handle_camera()
{
camera.genius = my; //camera position
camera.arc = 80;
vec_set(camera.x,vector(my.x,my.y,my.z+30));
my.pan = camera.pan;
camera.pan -= 10 * mouse_force.x * time_step;
camera.tilt += 10 * mouse_force.y * time_step;
camera.tilt = clamp(camera.tilt,-90,90);
}
function handle_movement()
{
if(key_shift) //using wasd keys for movement
{
dist.x = 15 * (key_w - key_s) * time_step;
dist.y = 15 * (key_a - key_d) * time_step;
}
else
{
dist.x = 10 * (key_w - key_s) * time_step;
dist.y = 10 * (key_a - key_d) * time_step;
}
}
function handle_gravity()
{
result = c_trace(my.x,vector(my.x,my.y,my.z-1000),IGNORE_PASSABLE|IGNORE_MODELS|USE_BOX);
if(result > 5)
{
absdist.z -= 2 * time_step;
}
else
{
absdist.z = 0;
}
}
action hero()
{
player = my;
my.eflags |= FAT | NARROW;
wait(1);
vec_set(my.min_x,vector(-20,-20,-40));
vec_set(my.max_x,vector(20,20,40));
my.health = 100;
while(my.health > 0) // while I'm alive
{
handle_gravity();
handle_movement();
c_move(my,dist,absdist,IGNORE_PASSABLE|GLIDE);
handle_camera();
wait(1);
}
set(my,PASSABLE);
vec_set(camera.x,vector(my.x,my.y,my.z-20));
snd_play(p_death,70,0);
wait(-0.5);
error("YOU ARE DEAD!!!");
}
////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////
action zombie()
{
VECTOR zdist;
VECTOR zabsdist;
VECTOR temp;
VECTOR p;
VECTOR p2;
var hand_palm = 346;
var hand_top = 338;
var alert_snd = 1;
var pain_snd = 0;
var attack_snd = 0;
my.eflags |= FAT | NARROW;
wait(1);
vec_set(my.min_x,vector(-20,-20,-40));
vec_set(my.max_x,vector(20,20,40));
my.health = 100;
my.state = 0; // waiting for player
while(my.health > 0)
{
if(my.state == 0)
{
ent_animate(my,"stand",my.skill60,ANM_CYCLE);
my.skill60 += 2 * time_step;
vec_set(zdist.x,nullvector);
vec_set(zabsdist.x,nullvector);
if(vec_dist(my.x,player.x) < 800 && player.health > 0) //350
{
my.state = 1;
}
}
if(my.state == 1)
{
if(alert_snd == 1)
{
snd_play(z_alert,70,0);
alert_snd = 0;
}
vec_set(temp.x,player.x);
vec_sub(temp.x,my.x);
vec_to_angle(my.pan,temp);
my.tilt = 0;
ent_animate(my,"walk",my.skill60,ANM_CYCLE);
my.skill60 += 8 * time_step;
zdist.x = 5 * time_step;
zdist.y = 0;
zdist.z = 0;
vec_set(zabsdist.x,nullvector);
if(vec_dist(my.x,player.x) > 360)
{
my.state = 0;
}
if(vec_dist(my.x,player.x) < 65)
{
my.state = 2;
}
if(player.health <= 0)
{
my.state = 0;
}
}
if(my.state == 2)
{
vec_set(temp.x,player.x);
vec_sub(temp.x,my.x);
vec_to_angle(my.pan,temp);
my.tilt = 0;
my.roll = 0;
my.skill40 = 0;
while(my.skill40 < 100)
{
vec_for_vertex(p,my,hand_palm);
vec_for_vertex(p2,my,hand_top);
if(c_trace(p,p2,IGNORE_ME | IGNORE_PASSABLE) > 0)
{
attack_snd = 1;
if(attack_snd == 1)
{
snd_play(z_attack,70,0);
attack_snd = 0;
}
if(you == player)
{
pain_snd = 1;
if(pain_snd == 1)
{
snd_play(p_pain,70,0);
pain_snd = 0;
}
you.health -= 100 * time_step;
}
}
ent_animate(my,"attack",my.skill40,NULL);
my.skill40 += 8 * time_step;
wait (1);
}
vec_set(zdist.x,nullvector);
vec_set(zabsdist.x,nullvector);
if(vec_dist(my.x,player.x) > 70)
{
my.state = 1;
}
if(player.health <= 0)
{
my.state = 0;
}
}
c_move(my,zdist,zabsdist,IGNORE_PASSABLE|GLIDE);
wait(1);
}
set(my,PASSABLE);
snd_play(z_death,70,0);
my.skill60 = 0;
while(my.skill60 < 100)
{
ent_animate(my,"deaht",my.skill60,NULL);
my.skill60 += 5 * time_step;
wait(1);
}
}
////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////
PANEL* gui =
{
digits(10,0,4,"Arial#24bi",1,player.skill1);
flags = SHOW;
}