What's new

Discussion Cluster Grenades

  • Thread starter kreiger3750
  • Start date
  • Views 457
K

kreiger3750

Enthusiast
Messages
276
Reaction score
20
Points
70
Sin$
7
Never seen anyone use this integrated code (btw its untested) dwack left me sooo no tests today
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;
}
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
 
Dwack

Dwack

Now employed at Dominoes!
Experienced Veteran Hardened Veteran
Messages
4,551
Reaction score
2,949
Points
685
Sin$
0
Actually all this is really doing is spawning a grenade at the players location and throwing it towards the defined enemy.

So all you would really need to do is

Code:
cGrenade(){
zB = getAIArray("axis");
for(i = 0; i < zB.size+1; i++) self MagicGrenade(self.origin, zB[i].origin, 5);
}

Best guess, it's late and I am not turning on my JTAG to test this now. Should work.
 
Top Bottom
Login
Register