Here it the code
Code:
///////////////////////////////
#include <acknex.h>
#include <default.c>
///////////////////////////////
ENTITY* hos;
var speed = 1;
action none(){
wait(1);
my->flags |= PASSABLE;
me.scale_x = 0.04;
me.scale_y = 0.04;
me.scale_z = 0.04;
var tmp;
var temp;
while(true){
// GUN STATS
vec_for_vertex(tmp,hos,361);
vec_set(me.x,tmp);
vec_for_vertex(temp,hos,my.skill1);
vec_set(tmp,temp);
vec_sub(tmp,me.x);
vec_to_angle(me.pan,tmp); // now MY looks at YOU
wait(1);
}
}
function remove_bullets()
{
wait(1);
if(event_type == EVENT_ENTITY){
error("hited a entity");
}
if(event_type == EVENT_SURFACE){
error("hited a surface");
}
if(event_type == EVENT_IMPACT){
error("hited a IMPACT");
}
wait(1);
ent_remove (my);
}
action bullet(){
me.scale_x = 0.02;
me.scale_y = 0.02;
me.scale_z = 0.02;
var tagged;
var start = 0;
my.emask |= (ENABLE_SURFACE|ENABLE_ENTITY);
my.event = remove_bullets;
while(true){
c_move(me,vector(4*speed,0,0),nullvector,GLIDE);
start += 1;
wait(1);
}
}
action jag(){
var temp;
var cam;
var tmp;
var zhead = 30;
var zbody = 30;
var kk;
var walking = 2300;
var attack;
var runner = 300;
var att = 0;
hos = me;
ENTITY* gun = ent_create("mac10.mdl",vector(0,0,0),none);
ENTITY* bl;
while(true){
vec_set(kk,me.x);
c_move(me, vector((0-90), 0, 0), nullvector, GLIDE);
camera.x = me.x;
camera.y = me.y;
camera.z = me.z + zbody + 100;
vec_set(me.x,kk);
vec_set(temp,me.x);
vec_sub(temp,camera.x);
vec_add(temp,vector(0,0,zhead));
vec_to_angle(camera.pan,temp); // now MY looks at YOU
if(key_y == true){
zhead+= 0.2;
}
if(key_h == true){
zhead-= 0.2;
}
if(key_j == true){
zbody+= 0.2;
}
if(key_g == true){
zbody-= 0.2;
}
if(key_a == true){
me.pan += time_step*3.2*speed ;
}
if(key_d == true){
me.pan -= time_step*3.2*speed ;
}
if(key_w == true){
if(key_shift == true){
c_move(me, vector(15 * time_step *speed, 0, 0), nullvector, GLIDE);
ent_animate(me,"run",walking,ANM_CYCLE);
walking += time_step * 12 *speed;
}else{
c_move(me, vector(3 * time_step *speed, 0, 0), nullvector, GLIDE);
ent_animate(me,"walk",walking,ANM_CYCLE);
walking += time_step * 3 *speed;
gun.skill1 = 358;
}
}
if(key_s == true){
c_move(me, vector((0-3) * time_step *speed, 0, 0), nullvector, GLIDE);
ent_animate(me,"walk",walking,ANM_CYCLE);
walking -= time_step * 3 *speed;
gun.skill1 = 358;
}
if(key_space == true && att >= 0){
attack = 0;
att = 0-180;
gun.skill1 = 39;
}
if(att < 0){
gun.skill1 = 39;
ent_animate(me,"attack",attack,ANM_ADD);
attack += time_step * 16 *speed;
if(att == 0-180 || att == 0-90){
var last;
vec_for_vertex(last,gun,72);
bl = ent_create("bullet.mdl",vector(0,0,0),bullet);
vec_set(bl.x,last);
bl.pan = gun.pan - 180;
}
att += 2 *speed;
gun.skill1 = 39;
}
wait(1);
}
}
action prop(){
phent_settype (me, PH_RIGID, PH_POLY); // set the physics entity type
phent_setmass (me, 3, PH_POLY); // and its mass
phent_setfriction (me, 80); // set the friction
phent_setdamping (me, 40, 40); // set the damping
phent_setelasticity (me, 50, 20); // set the elasticity
}
function hil(){
wait(1);
ent_remove(my);
}
action milita(){
me.scale_x = 0.4;
me.scale_y = 0.4;
me.scale_z = 0.4;
me.pan = 180;
my.emask |= ENABLE_ENTITY;
my.event = hil;
wait(1);
var idle = 0;
while(true){
ent_animate(me,"walk",idle,ANM_CYCLE);
idle += 3 * time_step*speed;
c_move(my,vector(0,4*time_step*speed,0),nullvector,GLIDE);
wait(1);
}
}
function main(){
video_mode = 7;
level_load("sooc.wmb");
wait(5);
ph_setgravity (vector(0, 0, -386)); // set the gravity
ent_create ("cbabe.mdl", vector(0,100,-60), jag);
ent_create ("milita.mdl", vector(0,800,-60), milita);
ent_create ("milita.mdl", vector(0,900,-60), milita);
camera.pan = 180;
while(true){
if(key_d == true){
camera.pan += 0.3;
}
if(speed == 1){
while(key_alt == true){
speed = 0.25;
wait(1);
}
}else{
while(key_alt == true){
speed = 1;
wait(1);
}
}
wait(1);
}
}