#include <acknex.h>
#include <default.c>
#define STATE skill1
#define ANIMATION skill2
#include "defines.c"
//#include "animation.c"
function camera_follow(ENTITY* ent)
{
while(1)
{
vec_set(camera.x,vector(-250,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);
}
}
function ninja_move()
{
camera_follow(me);
VECTOR vFeet;
vec_for_min(vFeet,me); // vFeet.z = distance from player origin to lowest vertex
my.STATE = 0;
var walk_speed;
//walking with the sword in hand state
while(1)
{
VECTOR move_to_vector;
var distance_to_ground;
if(my.STATE == 0)
{
my.ANIMATION += 5 *time_step;
ent_animate(me,"idleSWA",my.ANIMATION,ANM_CYCLE);
if(key_cuu == 1)
{
ent_blend("runWS",0,15);
my.ANIMATION = 1;
my.STATE = 1;
}
/*
if(key_space == 1)
{
my.ANIMATION = 1;
my.STATE = 3;
}
*/
if(key_t == 1)
{
my.ANIMATION = 0;
my.STATE = 5;
}
}
if(my.STATE ==1)
{
//rotate player with the left and right keys
my.pan += (key_cul-key_cur)*5* time_step;
//move the entity forward
var distance = (key_cuu) * 5 *time_step;
c_move(me,vector(distance,0,0),NULL,GLIDE);
var rotateAround = (key_cud)* 5 * time_step;
c_rotate(me,vector(rotateAround,0,0),GLIDE);
//animate the player
my.ANIMATION += 2* distance;
ent_animate(me,"runWS",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
if(!key_cuu)
{
my.ANIMATION = 1;
my.STATE = 0;
}
}
/*
if(my.STATE == 3)
{
var gravity = 6;
my.z += 4 * gravity;
ent_animate(me,"jump",my.ANIMATION,0);
my.ANIMATION = 1;
}
*/
if(my.STATE == 4)
{
my.ANIMATION += 5 *time_step;
ent_animate(me,"idleSWI",my.ANIMATION,ANM_CYCLE);
}
if(my.STATE == 5)
{
ent_animate(me,"takeSWO",my.ANIMATION,0);
my.STATE = 4;
}
if((my.STATE == 4) && key_cuu == 1)
{
//rotate player with the left and right keys
my.pan += (key_cul-key_cur)*5* time_step;
//move the entity forward
var distance = (key_cuu) * 5 *time_step;
c_move(me,vector(distance,0,0),NULL,GLIDE);
var rotateAround = (key_cud)* 5 * time_step;
c_rotate(me,vector(rotateAround,0,0),GLIDE);
//animate the player
my.ANIMATION += 2* distance;
ent_animate(me,"run",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
if(!key_cuu)
{
my.ANIMATION = 1;
my.STATE = 0;
}
}
wait(1);
}
}