K
kreiger3750
Enthusiast
Never seen anyone use this integrated code (btw its untested) dwack left me sooo no tests today
Actually i guarantee you don't need the level endon unless you make a function before wait_for_grenades i don't feel like messing with it since i can't test
Code:
wait_for_grenades()
{
level endon ( "end_cluster_grenades" ); //May not need this if that be the
//case change the below to for (;;)
while(1)
{
self waittill("grenade_fire", grenade, weapname);
if ( weapname != "fraggrenade" )
continue;
grenade thread create_clusterGrenade();
}
}
create_clusterGrenade()
{
prevorigin = self.origin;
while(1)
{
if ( !isdefined( self ) )
break;
prevorigin = self.origin;
wait .1;
}
prevorigin += (0,0,5);
numSecondaries = 8;
aiarray = getaiarray();
if ( aiarray.size == 0 )
return;
ai = undefined;
for ( i = 0; i < aiarray.size; i++ )
{
if ( aiarray[i].team == "allies" )
{
ai = aiarray[i];
break;
}
}
if ( !isdefined( ai ) )
ai = aiarray[0];
oldweapon = ai.grenadeweapon;
ai.grenadeweapon = "fraggrenade";
for ( i = 0; i < numSecondaries; i++ )
{
velocity = getClusterGrenadeVelocity();
timer = 1.5 + i / 6 + randomfloat(0.1);
ai magicGrenadeManual( prevorigin, velocity, timer );
}
ai.grenadeweapon = oldweapon;
}
getClusterGrenadeVelocity()
{
yaw = randomFloat( 360 );
pitch = randomFloatRange( 65, 85 );
amntz = sin( pitch );
cospitch = cos( pitch );
amntx = cos( yaw ) * cospitch;
amnty = sin( yaw ) * cospitch;
speed = randomFloatRange( 400, 600);
velocity = (amntx, amnty, amntz) * speed;
return velocity;
}