#include <acknex.h>
#include <default.c>
VECTOR runter;
VECTOR walk_speed;
void alignToVec(ANGLE* entAng, VECTOR* vec, VECTOR* axis, var factor) {
vec_rotate(axis, entAng);
vec_normalize(axis, 1);
vec_normalize(vec, 1);
VECTOR rotAxis;
vec_cross(rotAxis, vec, axis);
var angle = -acosv(vec_dot(axis, vec))* factor * vec_length(rotAxis);
ANGLE rotAngle;
ang_for_axis(rotAngle, rotAxis, angle);
ang_add(entAng, rotAngle);
}
var oben=0;
ANGLE lo;
void gravitz()
{
vec_set(runter.x, vector(0, 0, -20000));
vec_rotate(runter.x, my.pan);
vec_add(runter.x, my.x);
my.skill96 = c_trace(my.x, runter.x,IGNORE_ME+IGNORE_SPRITES+USE_BOX+IGNORE_PASSABLE+IGNORE_PASSENTS+IGNORE_FLAG2); // get maniac's height above the floor
if (my.skill96 > 2) // if I'm in the air
{
oben=1;
walk_speed.z -= 1*time_step; // gravity force pulls me down
}
else
{
oben=0;
walk_speed.z = 0; // if I'm on the ground, why worry
}
}
action le()
{
var relTilt = 0;
player=me;
VECTOR temp;
while(1)
{
gravitz();
if(key_space&&!oben)
walk_speed.z=5;
my.skill9=100*(key_k-key_l); //Target angle/ 100 or -100
alignToVec(my.pan, normal, vector(0, 0, 1), time_step);
c_rotate(my,vector(-ang(my.pan-my.skill9)*0.9*time_step,0,0),GLIDE);
c_move(my,vector((key_w-key_s)*20*time_step,(key_a-key_d)*20*time_step,walk_speed.z),nullvector,GLIDE | IGNORE_PASSABLE|IGNORE_FLAG2);
wait(1);
}
}
void main()
{
VECTOR camang;
level_load("test2.wmb");
ent_create("block.mdl",nullvector,le);
vec_set(camera.x,vector(-100,0,-50));
while(1)
{
vec_set(camang.x,player.x);
vec_sub(camang.x,camera.x);
vec_to_angle(camera.pan,camang.x);
wait(1);
}
}