Quote:

hello,
am trying to make smoke effect for the AI car when ever it collides with other AI cars or the player car.

CODE:

//////////SMOKE Function //////////////

function smokeAction()
{
vec_randomize(temp,1.5);
//** extract passed values
var car_speed; car_speed= my.vel_x;
my.vel_x=0;
vec_add (my.vel_x, temp);
my.bmap = bmpSmoke;//bmap for smoke
my.move = on;
my.function = part_alphafade; // change to a shorter, faster function

if (random(2)>1)
{
// *****every other particle is white
my.bright = on;
my.alpha = 10 + random(10);
my.size= 1+car_speed*random(10);
} else {
my.alpha = 5 + random(25);
my.size= 5+car_speed*random(30);
}
}

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


//AI car action

action car
{
Code:

:
:


my.enable_scan = on; // the car is sensitive to scanning
my.event = make_way; // its event function will run if it is scanned


/////////////////ON_IMPACT = Smoke Effect //////////////////////////////////
//The cars on collision with player car or with the other AI cars produce smoke effect
my.enable_impact = on;
my.event = smokeAction;
effect(smokeAction, 5, temp, vector(car1_speed,0,0));//on_impact the car shud have this effect
effect(smokeAction, 5, temp, vector(car2_speed,0,0));
effect(smokeAction, 5, temp, vector(car3_speed,0,0));
///////////////////////////////////////////////////////////////////////////////


// //******generate a random value that will be used together with snd_tune to generate a unique engine sound

engine_offset = random(3);
if (my.skill1 == 1) // setting skill1 = 1 for the first car, skill1 = 2 for the second car and so on
{
ent_path("car01"); // if skill1 = 1 the car will follow the path named "car01"
car1 = me; // I'm car 1
}
:
:

//******* this loop will run until my.race_over = 1
while (my.race_over == 0)
{
temp.x = 60; // horizontal scanning angle
temp.y = 60; // vertical scanning angle
temp.z = 150; // scanning range

//****** scaning the cars in front of me on a distance of 150 quants
scan_entity (my.x, temp);

temp.x = target_coords.x - my.x; // get the vector that points towards the target
temp.y = target_coords.y - my.y;
temp.z = 0;
:
:
move_mode = ignore_you + ignore_passable + glide;
my.skill2 = ent_move (my.car_speed, nullskill); // store the distance covered by this car in skill2

//**** stores the total distance in my.distance (know which car is in front at a certain moment, etc)
my.distance += my.skill2;

vec_set (temp, my.x);
temp.z -= 1000;
c_trace (my.x, temp.x, ignore_me | ignore_passable | scan_texture);

:Code:

:
:




Last edited by prog; 11/23/07 07:13.