///////////////////////////////
#include <acknex.h>
#include <default.c>
#define STATE skill1
#define ANIMATION skill2
function main()
{
level_load("Puschel.wmb");
}
function camera_follow(ENTITY* ent)
{
while(1)
{
vec_set(camera.x,vector(-400,0,300)); // 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,-20,0)); // look in player direction, slighty down
wait(1);
}
}
action puschel()
{
camera_follow(me);
var speed_down = 0; // downward speed by gravity
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)
{
if(key_space)
{
c_move(my, vector(0 ,0,15*time_step), nullvector,GLIDE); //jump upwards
}
}
}
// determine the ground distance by a downwards trace
var dist_down;
if (c_trace(my.x,vector(my.x,my.y,my.z-5000),IGNORE_ME | IGNORE_PASSABLE | USE_BOX) > 0)
dist_down = my.z + vFeet.z - target.z; // get distance between player's feet and the ground
else
dist_down = 0;
// apply gravity when the player is in the air
if (dist_down > 0) // above floor, fall down with increasing speed
dist_down = clamp(dist_down,0,accelerate(speed_down,5,0.1));
else // on or below floor, set downward speed to zero
speed_down = 0;
// rotate the entity with the arrow keys
my.pan += (key_cul-key_cur)*8*time_step;
// move the entity forward/backward with the arrow keys
var distance = (key_cuu-key_cud)*8*time_step;
c_move(me, vector(distance,0,0), nullvector,GLIDE);
wait(1);
}
}
}