bmap smoky_map, <smoke2.bmp>; 
SOUND explosion,<exp.wav>;
SOUND explo1_wav,<fassexp.wav>;
SOUND fire_blob,<smoke.wav>;
SOUND ding,<rang2.wav>;

action mad_explo
{
my._HEALTH = 20; // setting your health damage.
my.enable_shoot = on; // telling the program that you are going to shoot   the barrell.
my.enable_scan = on; // scanning the entity to make sure that you did shoot it.
my.event = explo_event; // heres your event ill explain more below.
my.frame = 1;
while(my._HEALTH>=1)
{
wait 1;
}

my.frame = 2;
play_entsound me,explosion,1200;
wait(10);
play_entsound me,explo1_wav,1200;

gib_blown(4); // this is the function that will explode the barrel 
wait(12); // wait a few milliseconds to call the next few events
barrell_gib(1); // calling a gib to fly from the barrel
barrell_gib2(1); // calling a gib to fly from the barrel living a second one for more power.
wait(1);
create(<expl2+16.pcx>,MY.POS, drum_explode);
wait(1);
REMOVE ME;
}

function explo_event()
{
IF(EVENT_TYPE==EVENT_SHOOT && indicator== PLAYER_GUN_DAMAGE) // what the gun can shoot how many shots.
{
indicator = 0;
my._HEALTH -= 50; // the initial health.
return;
}
IF(EVENT_TYPE==EVENT_SCAN && indicator==DRUM_EXPLODE) // go to the drum explode function.
{
wait(2);
my._HEALTH = -155; // take of so much health depending on position.
RETURN;
}
}

function drum_explode() // your function name.
{
MY.PASSABLE = ON; // passable pieces
MY.SCALE_X *= (2); // scale x y and z going down.
MY.SCALE_Y *= (2);
MY.SCALE_Z *= (2);
MY.FLARE = ON; // making it very bright like a glow
MY.LIGHT = ON; // bright
MY.BRIGHT = ON; // giving more light
MY.BLEND = ON; // blend into everything else.
MY.LIGHTRED = 255; // very red for fire 255 bright 0 black
MY.LIGHTGREEN = 150; // medium blue
MY.LIGHTBLUE = 0; // no blue
MY.LIGHTRANGE = 100; // range of 100 change to distance of shot.
temp.PAN = 360;
temp.TILT = 360;
temp.Z = 105; //105 Unit exploding range
indicator = DRUM_EXPLODE;
SCAN MY.POS,MY_ANGLE,temp;
temp = 10000;
PLAY_ENTSOUND ME,explo1_wav,temp; // play sound from the main defines.
MY.FRAME = 1;
WHILE(MY.FRAME<=16)
{
MY.LIGHTRANGE += 2;
MY.FRAME+=TIME;
MY.Z += 6*TIME;
WAITT 1;
}
MY.INVISIBLE = ON; // turning the pieces off and all of the explode.
WHILE(MY.LIGHTRANGE > 0)
{
MY.LIGHTRANGE -= 5; // turning the range down.
WAITT 1;
}
REMOVE ME; // remove all of the function.
}

function gib_blown(numberOfParts) // your function for the blown gib.
{
EXCLUSIVE_ENTITY;
wait(1);
temp = 0;
while(temp < numberOfParts) // the number of parts we already defined that
above (4)
{
create(<barrell_gib.mdl>, MY.POS,
barrell_gib_action); // now this is the part where you define read below.
temp += 1;
}
WAIT 5;
REMOVE ME;
}

function barrell_gib_action() // function name
{
my.passable = on;
my.metal = on;
my.scale_x *= 1.0;
my.scale_y *= 1.0;
my.scale_z *= 1.0;
// throw part
my._speed_x = random(6) - 3;
my._speed_y = random(6) - 3;
my._speed_z = random(3) + 8;
//reset:
my._aspeed_pan = 0 + random(20);
my._aspeed_tilt = 0 + random(70);
my._aspeed_roll = 0;
MY.PAN = YOUR.PAN;
MY.TILT = YOUR.TILT;
MY.ROLL = YOUR.ROLL;
//Animate
my.skill9 = 20 + random(50);
while(my.skill9 > -16)
{
move_mode=ignore_models;
abspeed[0] = my._speed_x * time;
abspeed[1] = my._speed_y * time;
abspeed[2] = my._speed_z * time;
my.pan += my._aspeed_pan * time;
my.tilt += my._aspeed_tilt * time;
my.roll += my._aspeed_roll * time;
vec_scale(absdist,movement_scale); // scale absolute distance by
movement_scale
move(my,nullvector,abspeed);
if(bounce.z)
{
my._speed_z = -(my._speed_z/2);
if(my._speed_z < 0.25)
{
my._speed_x = 0;
my._speed_y = 0;
my._speed_z = 0;
my._aspeed_pan = 0;
my._aspeed_tilt = 0;
my._aspeed_roll = 0;
}
}
my._speed_z -= 2*time;
my.skill9 -= 1;
//fade out:
my.alpha -= 2*time;
if(my.alpha <=0)
{
//remove
wait(3);
remove(me);
return;
}
wait(1);
}
}

function barrell_gib(numberOfParts) // the function name its the same as the rest of it called (1) part.
{
EXCLUSIVE_ENTITY;
wait(1);
temp = 0;
while(temp < numberOfParts)
{
create(<shard.mdl>, MY.POS, drum_gib_action); //another model for the shards going to drum gib.
temp += 1;
}
WAIT 1;
REMOVE ME;
}

{
EXCLUSIVE_ENTITY;
wait(1);
temp = 0;
while(temp < numberOfParts)
{
create(<shard.mdl>, MY.POS, drum_gib_action);
temp += 1;
}
WAIT 1;
REMOVE ME;
}

CREATE <smoke2.bmp>,TARGET,stain_action;
emit(7,my.pos,particle_smoke);


function stain_action()
{
my.Z += 2;
my.PASSABLE = ON;
my.ORIENTED = ON;
my.flare = on;
my.TRANSPARENT = on;
my.alpha = 20;
my.TILT = 90;
my.SCALE_X = 1;
my.SCALE_Y = 1;
}
