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

CODE:

//AI car action

action car
{
var waypoint_number = 0;
var target_coords; // the coordinates of the next waypoint on the path
var engine_handle;
var angle_diff;
var engine_offset; // creates a random (unique) engine sound for every car
my.race_over = 0;
my.counting_laps = 1;
my.laps = -1;
my.max_speed = 50; // initial value needed to start the car
my.min_speed = 50; // initial value needed to start the car
my.enable_scan = on; // the car is sensitive to scanning
my.event = make_way; // its event function will run if it is scanned

////////////////////////////////////////////////////////////////////////
my.enable_impact = on;
my.event = smoke_action;
////effect(smoke_action, 5, temp, vector(car1_speed,0,0));
////effect(smoke_action, 5, temp, vector(car2_speed,0,0));
////effect(smoke_action, 5, temp, vector(car3_speed,0,0));
///////////////////////////////////////////////////////////////////////////////

engine_offset = random(3); // generate a random value that will be used together with snd_tune to generate a unique engine sound
if (my.skill1 == 1) // don't forget to set 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" without the quotes
car1 = me; // I'm car 1
}
if (my.skill1 == 2) // same thing for the rest of the cars
{
ent_path("car02");
car2 = me;
}
if (my.skill1 == 3)
{
ent_path("car03");
car3 = me;
}
while (race_started == 0) {wait (1);}
engine_handle = ent_playloop (my, engine_wav, 50); // play the engine sound in a loop
ent_waypoint(target_coords, 1); // set the target coordinates to the first point on the path
while (my.race_over == 0) // this loop will run until my.race_over = 1
{
temp.x = 60; // horizontal scanning angle
temp.y = 60; // vertical scanning angle
temp.z = 150; // scanning range
scan_entity (my.x, temp); // scan the cars in front of me on a distance of 150 quants

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;
if (vec_to_angle (angle_diff.pan, temp) < 150) // closer than 150 quants to the target?
{
waypoint_number = ent_nextpoint(target_coords); // move towards the new point on the path
}
angle_diff.pan = ang(angle_diff.pan - my.pan); // get the difference angle
my.pan += my.car_speed * angle_diff.pan * 0.005; // change the pan angle of the car slowly
if (((waypoint_number > 65) || (waypoint_number < 8)) || ((waypoint_number > 34) && (waypoint_number < 49))) // horizontal areas of the track?
{
if (my.car_speed < (my.max_speed * time)) // and the speed is below max_speed?
{
my.car_speed += 1 * time; // increase the speed of the car
}
}
else // curved areas of the track
{
if (my.car_speed > (my.min_speed * time)) // and the speed is above min_speed?
{
my.car_speed -= 0.5 * time; // decrease the speed of the car
}
}
if (waypoint_number == 66) // close to the end of the lap?
{
pick_new_path(); // pick a new, random path from the ones that are available
}
if ((my.distance < 500) && (my.car_speed > 15))
{
my.car_speed -= my.distance / 200; // start slowly
}
my.skill28 = 0; // second skill used for car_speed, we are using skill27..skill29 (skill27 was defined as car_speed)
my.skill29 = 0; // third skill used for car_speed
move_mode = ignore_you + ignore_passable + glide;
my.skill2 = ent_move (my.car_speed, nullskill); // store the distance covered by this car in skill2
my.distance += my.skill2; // and store the total distance in my.distance (know which car is in front at a certain moment, etc)
snd_tune (engine_handle, 50, (my.skill2 * 5 + engine_offset), 0); // tune the sound depending on the "real" speed of the car (distance covered)

vec_set (temp, my.x);
temp.z -= 1000;
//trace_mode = ignore_me + ignore_passable + scan_texture;
//trace (my.x, temp); // trace 1000 quants below the car
c_trace (my.x, temp.x, ignore_me | ignore_passable | scan_texture);
if (str_cmpi ("checker1", tex_name)) // if we've got the texture named "checker1" (without the quotes)
{
add_laps(); // increase the number of laps
}
if (my.laps == max_laps) // end of race?
{
my.race_over = 1; // get out of the while loop after max_laps
place += 1;
if (place == 1) // i'm the first car that finishes the race?
{
if (my.skill1 == 1)
{
str_cpy (car1_str, "1st place: Green car Time: ");
str_for_num (temp_str, car1_time);
str_cat (car1_str, temp_str);
car1_txt.pos_y = 250;
car1_txt.visible = on;
}
if (my.skill1 == 2)
{
str_cpy (car2_str, "1st place: Red car Time: ");
str_for_num (temp_str, car2_time);
str_cat (car2_str, temp_str);
car2_txt.pos_y = 250;
car2_txt.visible = on;
}
if (my.skill1 == 3)
{
str_cpy (car3_str, "1st place: Blue car Time: ");
str_for_num (temp_str, car3_time);
str_cat (car3_str, temp_str);
car3_txt.pos_y = 250;
car3_txt.visible = on;
}
}
if (place == 2) // i'm the second car that finishes the race?
{
if (my.skill1 == 1)
{
str_cpy (car1_str, "2nd place: Green car Time: ");
str_for_num (temp_str, car1_time);
str_cat (car1_str, temp_str);
car1_txt.pos_y = 280;
car1_txt.visible = on;
}
if (my.skill1 == 2)
{
str_cpy (car2_str, "2nd place: Red car Time: ");
str_for_num (temp_str, car2_time);
str_cat (car2_str, temp_str);
car2_txt.pos_y = 280;
car2_txt.visible = on;
}
if (my.skill1 == 3)
{
str_cpy (car3_str, "2nd place: Blue car Time: ");
str_for_num (temp_str, car3_time);
str_cat (car3_str, temp_str);
car3_txt.pos_y = 280;
car3_txt.visible = on;
}
}
if (place == 3) // i'm the third car that finishes the race?
{
if (my.skill1 == 1)
{
str_cpy (car1_str, "3rd place: Green car Time: ");
str_for_num (temp_str, car1_time);
str_cat (car1_str, temp_str);
car1_txt.pos_y = 310;
car1_txt.visible = on;
}
if (my.skill1 == 2)
{
str_cpy (car2_str, "3rd place: Red car Time: ");
str_for_num (temp_str, car2_time);
str_cat (car2_str, temp_str);
car2_txt.pos_y = 310;
car2_txt.visible = on;
}
if (my.skill1 == 3)
{
str_cpy (car3_str, "3rd place: Blue car Time: ");
str_for_num (temp_str, car3_time);
str_cat (car3_str, temp_str);
car3_txt.pos_y = 310;
car3_txt.visible = on;
}
}
if (place == 4) // i'm the fourth car that finishes the race?
{
if (my.skill1 == 1)
{
str_cpy (car1_str, "4th place: Green car Time: ");
str_for_num (temp_str, car1_time);
str_cat (car1_str, temp_str);
car1_txt.pos_y = 340;
car1_txt.visible = on;
}
if (my.skill1 == 2)
{
str_cpy (car2_str, "4th place: Red car Time: ");
str_for_num (temp_str, car2_time);
str_cat (car2_str, temp_str);
car2_txt.pos_y = 340;
car2_txt.visible = on;
}
if (my.skill1 == 3)
{
str_cpy (car3_str, "4th place: Blue car Time: ");
str_for_num (temp_str, car3_time);
str_cat (car3_str, temp_str);
car3_txt.pos_y = 340;
car3_txt.visible = on;
}
}
finish_pan.visible = on;
}
wait(1);
}
while (my.car_speed > 1) // decrease the speed from its current speed to 1
{
my.car_speed -= 1 * time;
snd_tune (engine_handle, 50, my.car_speed * 5, 0); // and tune the sound accordingly
my.skill28 = 0;
my.skill29 = 0;
move_mode = ignore_you + ignore_passable + glide;
ent_move (my.car_speed, nullskill);
wait (1);
}
snd_stop (engine_handle); // stop the engine sound
if (place == 4) // race finished for all the cars?
{
while (finish_pan.alpha < 95)
{
finish_pan.alpha += 2 * time; // increase alpha
wait (1);
}
finish_pan.transparent = off; // the panel is opaque now
}
}

//PLAYER car action

// CarControl: Assigning this to car's chassis
action CarInit
{
// build a car and wait til all wheels are ready
ChassisInit();
while (wheelCounter<4) { wait(1); }
my.material = mat_metal;

mat_metal.power = 8;
mat_metal.diffuse_blue = 150;
mat_metal.diffuse_green = 150;
mat_metal.diffuse_red = 150;
mat_metal.specular_blue = 255;
mat_metal.specular_green = 200;
mat_metal.specular_red = 200;


UpdateSpeed(); // update rear wheel speed (continuous)
SpeedControl();// change speed (continuous)
SteerControl();// change heading (continuous)
player = my; // I'm the player
my.race_over = 0;
my.counting_laps = 1;
my.laps = -1;
my.albedo = 0
}

action FLInit
{
my.passable=on;
while(!pChassis) { wait(1);}
pFL=my;
InitWheel();
// make wheel constraint pointing up and towards center
wheelFL= phcon_add(PH_WHEEL, pChassis, my);
phcon_setparams1(wheelFL, my.x, vecUp, vecRight);
phcon_setparams2(wheelFL, vector(0,0,0), nullvector, vector(suspensionERP, suspensionCFM,0));
my.passable=off;
}
action FRInit
{
my.passable=on;
while (!pChassis) { wait(1);}
pFR=my;
InitWheel();
// make wheel constraint pointing up and towards center
wheelFR= phcon_add(PH_WHEEL, pChassis, my);
phcon_setparams1(wheelFR, my.x, vecUp, vecRight);
phcon_setparams2(wheelFR, vector(0,0,0), nullvector, vector(suspensionERP, suspensionCFM,0));
my.passable=off;
}
action RLInit
{
my.passable=on;
while (!pChassis) { wait(1);}
pRL=my;
InitWheel();
// make wheel constraint pointing up and towards center
wheelRL= phcon_add(PH_WHEEL, pChassis, my);
phcon_setparams1(wheelRL, my.x, vecUp, vecRight);
phcon_setparams2(wheelRL, vector(0,0,0), nullvector, vector(suspensionERP, suspensionCFM,0));
my.passable=off;
}
action RRInit
{
my.passable=on;
while (!pChassis) { wait(1);}
pRR=my;
InitWheel();
// make wheel constraint pointing up
wheelRR= phcon_add(PH_WHEEL, pChassis, my);
phcon_setparams1(wheelRR, my.x, vecUp, vecRight);
phcon_setparams2(wheelRR, vector(0,0,0), nullvector, vector(suspensionERP, suspensionCFM,0));
my.passable=off;
}