VECTOR targetpos;
function bullet()
{
VECTOR ziel;
vec_set(ziel,targetpos);
vec_sub(ziel,my.x);
vec_to_angle(my.pan,ziel); //bullet looks at the target :)
while(my)
{
c_move(my,vector(30*time_step,0,0),nullvector,IGNORE_SPRITES + IGNORE_PASSABLE + IGNORE_ME); //and shoots
}}
function player()
{
while(my)
{
vec_set(my.skill7,vector(10000,0,0));
vec_rotate(my.skill7,camera.pan);
vec_add(my.skill7,camera.x);
my.skill6 = c_trace(camera.x,my.skill7,IGNORE_SPRITES + IGNORE_PASSABLE);
if(my.skill6==0)
vec_set(my.skill10,vector(10000,0,0));
else
vec_set(my.skill10,vector(my.skill6,0,0));
vec_rotate(my.skill10,camera.pan);
vec_add(my.skill10,camera.x); //my.skill10 is now the vector from the target
vec_set(targetpos,my.skill10); //targetpos is now the vector from the target
if(key_space) //if you press the space key
ent_create("bullet.mdl",my.x,bullet); //create bullet
wait(1);
}}