// Action to handle machine gun bullets
action mg_action()
{
wait(1);
ang_for_bone(my.pan,player,"turret_bone");
ang_rotate(my.tilt,vector(Turr_Ang,0,0));
c_move(me,vector(15,0,0),NULLVECTOR,IGNORE_YOU);
c_setminmax(my);
phent_settype(me,PH_RIGID,PH_BOX);
phent_setmass(me,0.012,PH_SPHERE);//45kg
phent_setfriction(me,100);
phent_setdamping(me,2,100);
phent_addvellocal(my, vector(2000,0,0), nullvector);
wait(1);
my.emask |= (ENABLE_BLOCK | ENABLE_ENTITY | ENABLE_IMPACT);
my.event = impact_mghit;
set(my,POLYGON|BRIGHT|METAL|INVISIBLE);
VECTOR tail, lastPos;
while(1)
{
tracerglow.x = - 20; tracerglow.y = 0; tracerglow.z = 0;
vec_rotate(tracerglow,my.pan);
vec_for_vertex(tail,me,1);
effect(effect_smktrail, 1, tail,tracerglow);
effect(effect_tracer,1,tail,tracerglow);
vec_rotate(tracerglow,my.pan);
//Check if still moving far enough, per frame, to call it "alive".
vec_set(lastPos, my.x);
wait(1);
//this min_distance "10" is just a guess, you'll need to calculate a distance yourself
if(vec_dist(lastPos, my.x)<10) break;
}
// kill_bullet(); dunno what "kill_bullet" is for, but I'll assume its the [no-longer-needed] 10 second timer
phent_settype (me,NULL,NULL);
ent_remove(me);
}
function impact_mghit()
{
switch (event_type)
{
///////////////////////////////////////////////////////////////////////////////////////////////////
case EVENT_IMPACT:
effect(effect_sandhit,5,my.x,nullvector);
phent_clearvelocity(me);
///////////////////////////////////////////////////////////////////////////////////////////////////
case EVENT_ENTITY:
effect(effect_sandhit,5,my.x,nullvector);
phent_clearvelocity(me);
///////////////////////////////////////////////////////////////////////////////////////////////////
case EVENT_BLOCK:
effect(effect_sandhit,5,my.x,nullvector);
phent_clearvelocity(me);
}
}