#define health skill100
#define id skill99
#define id_barrel 1234
void _event_barrel(){
if (event_type == EVENT_SCAN || event_type == EVENT_IMPACT) if (you) if (you.id == id_barrel) my.health = 0;
}
//skill1 BarrelHealth 100
action BarrelExplode_WED(){
set (my, POLYGON);
my.id = id_barrel;
my.emask |= (ENABLE_SCAN | ENABLE_IMPACT); // impact: 4ex use ents as bullets ( 4my taste better than using c_trace btw )
my.event = _event_barrel;
if (my.skill1) my.health = my.skill1 // takes value from WED's settings panel
else my.health = 50 + integer (random (50));
while (my.health){
// if u want, add more code here. maybe barrel's idle animation lol
wait (1);
}
my.event = NULL;
set (my, INVISIBLE | PASSABLE); // ghostmode
c_scan (my.x, my.pan, vector (360,0, 150 + random (250)), SCAN_ENTS | IGNORE_ME | IGNORE_PASSABLE);
// put your "BOOM - code" here ^^ ...like playing explosion sounds etc.
/*
// example: wait until sound was played ( via handle )
var _sndhandle = 0;
_sndhandle = ent_playsound (me, snd_explo, 200);
while (snd_playing (_sndhandle)) wait (1);
*/
wait (-1);
ptr_remove (me);
}