action gun_action
{
gun=my;
my.passable=on;
my.alpha=100;

while(1)
{
aiming();
wait(1);
}
}

action bat_movement()//some bat entities act as targets
{
bat=my;
my.enable_impact=on;
my.enable_entity=on;
my.event=die_event;
while(1)
{
movement();
wait(1);
}
}

action move_bullets()
{
bullet=my;
gun=you;
var bullet_speed;
my.enable_impact = on;
my.enable_entity = on;
my.enable_block = on;
my.passable=off;
my.event = remove_bullets;
my.pan = camera.pan;
my.tilt = camera.tilt;
bullet_speed.x = 10 * time;
bullet_speed.y = 0;
bullet_speed.z = 0;
while (my != null)
{
c_move (my, bullet_speed, nullvector, IGNORE_YOU);
}

////////////////////////////////////////////////////

function aiming()
{
my.pan-=3*mouse_force.x*time_step;
my.tilt+=3*mouse_force.y*time_step;
camera.pan=my.pan;
camera.tilt=my.tilt;
camera.x=my.x;
camera.z=my.z;
camera.y=my.y;
my.transparent=on;
if (key_space==on){fire_bullets();}
if (key_s==on){my.alpha-=5;}
}

starter random_directions()

{
randomize();
}

function movement()//controls the movements of the bat entities
{
var index;
index = random(10);
var tempo = 0;
while (index > 0)
{
tempo = random (1);
if (tempo <= 0.2){my.pan-=0*time_step;}
if ((tempo > 0.2) && (random(1)<= 0.4)){my.pan-=10*time_step;}
if ((tempo > 0.4) && (random(1)<= 0.6)){my.pan+=10*time_step;}
if ((tempo > 0.6) && (random(1)<= 0.8)){my.tilt+=10*time_step;}
if (tempo > 0.8){my.tilt-=10*time_step;}
index-=1;
}
c_move(my,vector(0,0,0),nullvector,glide);
ent_animate(my,"fly",fly_percentage,anm_cycle);
fly_percentage+=2*time_frame;
}

function fire_bullets()
{

proc_kill(4);
while (key_space== on) {wait (1);}
var shoot_percentage;
ent_animate(my,"shot",shoot_percentage,NULL);
shoot_percentage+=3*time_frame;
ent_create (bullets,vector(camera.x+60,camera.y+60*sin(camera.pan),(camera.z+60*sin(camera.tilt))-10), move_bullets);
snd_play (shot2, 100, 0);
}



function remove_bullets()
{
if (event_type==event_impact)
{
wait (1);
ent_remove(my);
}

if (event_type==event_entity)
{
wait (1);
ent_remove(my);
}

if (event_type==event_block)
{
wait (1);
ent_remove(my);
}
}

function die_event()
{
wait(1);
ent_remove(my);
snd_play(damage1,100,0);
}

the function aiming() is the one which is getting the error message

when I press space the gun fires a bullets and when it collides with a bat the bat is removed , and the but is not moving so dont fell strange about that
the error began when I modified the remove_bullets() function , I just added an if instruction for event_entity and event_block , thats where every thing was screwed up

the rest of the code is nothing more than definisions like vars and panles , and by the way , the gun is supposed to play an animation when it fires a bullet , but it doesent , dont know why


there are some meanless commands like controling the transparency of the gun

Last edited by Marwan; 07/09/08 21:51.

age:16 game design and programming experience:2 years