Code:#include <acknex.h>
#include <default.c>
#define walk_percentage skill11
#define STATE skill1
#define STATE skill1
#define ANIMATION skill2
////////////////////////////////////////////////////////////////////
BMAP* cursor_pcx = "cursor.pcx";
BMAP* crosshair_pcx = "crosshair.pcx";
////////////////////////////////////////////////////////////////////
function camera_follow(ENTITY* ent)
{
while(1)
{
vec_set(camera.x,vector(-150,10,50)); // camera position relative to the player
vec_rotate(camera.x,ent.pan); // rotate the camera position with the player
vec_add(camera.x,ent.x); // add player position
vec_set(camera.pan,vector(ent.pan,-10,0)); // look in player direction, slighty down
wait(1);
}
}
action character_walking()
{
camera_follow(me);
VECTOR vFeet;
vec_for_min(vFeet,me); // vFeet.z = distance from player origin to lowest vertex
my.STATE = 1;
while (1)
{
// state 1: walking ////////////////////////////////////////////
if (my.STATE == 1)
{
// rotate the entity with the arrow keys
my.pan += (key_cul-key_cur)*5*time_step;
// move the entity forward/backward with the arrow keys
var distance = (key_cuu-key_cud)*5*time_step;
c_move(me, vector(distance,0,0), NULL, GLIDE);
// animate the entity
my.ANIMATION += 2*distance;
ent_animate(me,"walk",my.ANIMATION,ANM_CYCLE);
// adjust entity to the ground height, using a downwards trace
c_trace(my.x,vector(my.x,my.y,my.z-1000),IGNORE_ME | IGNORE_PASSABLE);
my.z = hit.z - vFeet.z; // always place player's feet on the ground
}
}
}
function change_mouse_mode()
{
mouse_mode += 1;
mouse_mode %= 3;
if (1 == mouse_mode)
mouse_map = crosshair_pcx;
if (2 == mouse_mode)
mouse_map = cursor_pcx;
}
action zombie_bars()
{
while (1)
{
my.walk_percentage += 2 * time_step; // 3 = animation speed
ent_animate(me, "attack", my.walk_percentage, ANM_CYCLE); // "attack" animation loop
wait (1);
}
}
action zombie_fight_against_eachother()
{
while (1)
{
my.walk_percentage += 3 * time_step; // 3 = animation speed
ent_animate(me, "hit", my.walk_percentage, ANM_CYCLE); // "attack" animation loop
wait (1);
}
}
action zombie_fight_against_eachotherr()
{
while (1)
{
my.walk_percentage += 2.5 * time_step; // 3 = animation speed
ent_animate(me, "hit", my.walk_percentage, ANM_CYCLE); // "attack" animation loop
wait (1);
}
}
function main()
{
video_mode = 7;
level_load ("Huis.wmb");
ent_create("zombiek.mdl",vector(293,-107,-55), zombie_bars);
you = ent_create("zombiek.mdl",vector(425,106,-47), zombie_fight_against_eachother);
you.pan= 60;
you = ent_create("zombiek.mdl",vector(530,106,-47), zombie_fight_against_eachotherr);
you.pan= 240;
on_m = change_mouse_mode;
while (1)
{
mouse_pos.x = mouse_cursor.x;
mouse_pos.y = mouse_cursor.y;
camera.pan -= mouse_force.x;
camera.tilt += mouse_force.y;
wait (1);
}
camera.z = 120; // choose a convenient height
camera.tilt = -15; // and tilt angle for the camera
}