Code:
extern void object::Attack()
{
int alien[], j = 0;
alien[j++] = WingedGrabber;
//alien[j++] = TrackedGrabber;
//alien[j++] = WheeledGrabber;
alien[j++] = LeggedGrabber;
alien[j++] = WingedShooter;
alien[j++] = TrackedShooter;
alien[j++] = WheeledShooter;
alien[j++] = LeggedShooter;
alien[j++] = WingedOrgaShooter;
alien[j++] = TrackedOrgaShooter;
alien[j++] = WheeledOrgaShooter;
alien[j++] = LeggedOrgaShooter;
alien[j++] = WingedSniffer;
alien[j++] = TrackedSniffer;
alien[j++] = WheeledSniffer;
alien[j++] = LeggedSniffer;
alien[j++] = Thumper;
alien[j++] = PhazerShooter;
alien[j++] = Recycler;
alien[j++] = Shielder;
alien[j++] = Subber;
//alien[j++] = Me;
alien[j++] = Houston;
alien[j++] = ExchangePost;
alien[j++] = RadarStation;
alien[j++] = Derrick;
alien[j++] = Converter;
alien[j++] = PowerPlant;
alien[j++] = NuclearPlant;
alien[j++] = BotFactory;
alien[j++] = RepairCenter;
alien[j++] = PowerStation;
alien[j++] = DefenseTower;
alien[j++] = PowerCaptor;
alien[j++] = AutoLab;
alien[j++] = ResearchCenter;
float rand1 = rand(), rand2 = rand();
float dir;
object item;
while(true)
{
try
{
item = radar(alien, 0, 360, 0, 10000);
if (item != null)
{
turn(direction(item.position));
while (distance(position, item.position) > 10)
{
dir = direction(item.position);
if ( dir < 0 )
{
motor(1, 1+dir/90);
}
else
{
motor(1-dir/90, 1);
}
wait(0.8);
motor(1, 0.5+rand1);
wait(0.8);
motor(0.5+rand2, 1);
wait(1.6);
motor(1, 0.5+rand2);
wait(0.8);
motor(1,1);
break;
}
while (distance(position, item.position) <= 10)
{
turn(direction(item.position));
motor(1,1);
wait(0.1);
break;
}
}
else
{
motor(1, 0.5+rand1);
wait(0.8);
motor(0.5+rand2, 1);
wait(1.6);
motor(1, 0.5+rand2);
wait(0.8);
}
}
catch(radar(alien, 0, 360, 0, 5) != null)
{
motor(0,0);
wait(0.1);
fire();
}
}
}