action player_action()
{
VECTOR temp[3];VECTOR temp2[3];VECTOR temp_target[3];VECTOR pos1[3];VECTOR pos2[3];
var anim_percentage;
vec_set(temp_target,my.x);
while(1)
{
if(mouse_left)
{
while (mouse_left){wait(1);}
pos1.x = mouse_pos.x;pos1.y = mouse_pos.y;pos1.z = 0;
vec_for_screen (pos1, camera);
pos2.x = mouse_pos.x;pos2.y = mouse_pos.y;pos2.z = 20000;
vec_for_screen (pos2, camera);
c_trace (pos1,pos2,IGNORE_ME|IGNORE_PASSABLE|IGNORE_MODELS);
vec_set(temp_target,target);
}
if(vec_dist(my.x,temp_target.x)>20)
{
vec_set(temp.x,temp_target.x);
vec_sub(temp.x,my.x) ;
vec_to_angle(my.pan,temp);
my.tilt=0;
c_move (my, vector(30*time_step,0 , -2), nullvector, IGNORE_PASSABLE | GLIDE);
ent_animate(my, "walk", anim_percentage, ANM_CYCLE);
anim_percentage += 10 * time_step;
}
else
{
ent_animate(my, "idle", anim_percentage, ANM_CYCLE);
anim_percentage += 2 * time_step;
}
wait(1);
}
}
function main()
{
player = ent_create("player.mdl",vector(0,0,0),player_action);
c_setminmax(player);
}