03-17-2016, 02:27 PM
(This post was last modified: 03-17-2016, 02:27 PM by Rinoldo.
Edit Reason: replaced if with while in the very end of code
)
Here is my full code for flying Shooter:
Code:
extern void object::HuntAnt()
{
object ant, power;
power = radar(PowerStation);
point pos, pos2;
jet(0.2);
aim(-40);
while(true)
{
while(true)
{
while(radar(AlienAnt, 0, 360, 0, 20) == null)
{
ant=radar(AlienAnt);
turn(direction(ant.position));
motor(1,1);
/*errmode(0);
int err;
err = motor(1,1);
if ( err != 0 )
{
motor(-1, -1);
jet(1);
wait(0.5);
}*/
jet(0);
if (position.z - topo(position) < 8)
jet(1);
if(position.z - topo(position) > 9)
jet(-0.1);
wait(0.1);
pos = position;
wait(0.1);
pos2 = position;
if (pos == pos2)
{
move(-3);
turn(90);
move(3);
}
}
fire(1);
if (energyCell.energyLevel < 0.3)
break;
}
errmode(0);
int err;
err = goto(power.position);
if ( err != 0 )
{
motor(-1, -1);
jet(1);
wait(0.5);
}
while (energyCell.energyLevel < 1)
wait(1);
}
}