Hello guys,
I am creating a 3d game and create an object that has a special
action it would serve as a bomb if hit by another object shall we say a ball, will explode an the surrounding objects which is within reach of the scan range will also explode but my problem is, though there is no object around the bomb object seems that it also hit those object that i set ENABLE_SCAN, and as debug my code it really passed to the function that has ENABLE_SCAN and perform its action also.
How can i fix this? i only want to explode objects that are in scan range from the bomb object. Somebody advice me please...
Here is my code:
// function : this function will trigger explosion of the sorounding bricks when hit
//-------------------------------------------------------------------------------------------
function time_bomb()
{
while(!player){wait(1);}
c_setminmax(my);
my.z = player.z;
set(my, POLYGON);
my.emask |= (ENABLE_IMPACT | ENABLE_ENTITY | ENABLE_DETECT );//ENABLE_SCAN |
my.event = bomb_explosion;
swinging_bricks();
}
// functionality :triggers the explosion of bricks and will scan all objects within range
//-------------------------------------------------------------------------------------------
function bomb_explosion()
{
if(event_type == EVENT_IMPACT)
{
c_scan(my.x, my.pan, vector(360,180,89), SCAN_ENTS | SCAN_LIMIT); //vector(360,180,59)
effect(p_fountain,maxv(1,40*time_step),my.x,vector(0,0,5));
set (me, INVISIBLE);
numberOfBricks-=1; // minus the number of numberOfBricks in the level
scorePoints+=50; // score gained
numberOfBricks+=11; // minus the number of numberOfBricks in the level
ent_remove(my);
}
}
//function: will explode ih hit or when triggered by scan
//-------------------------------------------------------------------------------------------
action act_simple(){
while(!player){wait(1);}
c_setminmax(my);
my.z = player.z;
set(my, POLYGON);
my.emask |= (ENABLE_IMPACT | ENABLE_ENTITY | ENABLE_SCAN | ENABLE_DETECT);
my.event = brick_explosion;
swinging_bricks();
}
//function: the actual explossion of the brick object when hit or when triggered by scan
//-------------------------------------------------------------------------------------------
function brick_explosion()
{
if(event_type == EVENT_SCAN)
{
// my.z = player.z;
snd_play(explosion,100, 0);
effect(p_fountain,maxv(1,40*time_step),my.x,vector(0,0,5));
set (me, INVISIBLE);
//wait(2);
numberOfBricks-=1; // minus the number of bricks in the level
scorePoints+=20; // score gained
ent_remove(my);
}else
if(event_type == EVENT_IMPACT)
{
my.z = player.z;
snd_play(explosion,100, 0);
effect(p_fountain,maxv(1,40*time_step),my.x,vector(0,0,5));
set (me, INVISIBLE);
//wait(2);
numberOfBricks-=1; // minus the number of bricks in the level
scorePoints+=20; // score gained
ent_remove(my);
}
}