OK, I made wasp turns using "motor" - not "turn", so it flies faster and more fluently, so it's harder to shoot it down.
I rewritted whole program to make it simpler. It works much better but I'm still working on few issues (and learning CBOT :D)
Maybe you can help me - i don't have any idea what to do:
When wasps have stolen all resources, they make a big crowd near "dustbin" point - they all want to grab resources which are laying there just ti drop it again. I don't know what to do with that. I tried to make object "Cleaner" (it's in code) which will destroy resources in dustbin, but it doesn't help much.
I know the solution is to throw resources to lava, but it would work only on maps with it...
For now It works best on Tropica map.
I rewritted whole program to make it simpler. It works much better but I'm still working on few issues (and learning CBOT :D)
Maybe you can help me - i don't have any idea what to do:
When wasps have stolen all resources, they make a big crowd near "dustbin" point - they all want to grab resources which are laying there just ti drop it again. I don't know what to do with that. I tried to make object "Cleaner" (it's in code) which will destroy resources in dustbin, but it doesn't help much.
I know the solution is to throw resources to lava, but it would work only on maps with it...
For now It works best on Tropica map.
Code:
void object::goto2(point dest)
{
float rand1 = rand(), rand2 = rand();
float dir;
errmode(0);
turn(direction(dest));
while (distance(position, dest) > 30)
{
dir = direction(dest);
if ( dir < 0 ) // on the right ?
{
motor(1, 1+dir/90);
}
else // on the left ?
{
motor(1-dir/90, 1);
}
jet(1);
wait(0.8);
motor(1, 0.5+rand1);
jet(0.8);
wait(0.8);
motor(0.5+rand2, 1);
jet(1);
wait(1.6);
motor(1, 0.5+rand2);
jet(0.7);
wait(0.8);
motor(1,1);
if (rand1 > 0.9) // make a spin sometimes. looks natural and it helps when wasp is stuck :)
{
jet(1);
motor(1,0);
wait(2);
}
if (rand2 > 0.9)
{
jet(1);
motor(0,1);
wait(2);
}
}
while (distance(position, dest) < 30)
{
while (distance(position, dest) > 7)
{
jet(1);
turn(direction(dest));
motor(1,1);
wait(0.1);
break;
}
if (distance(position, dest) <= 7)
{
motor (0,1);
wait(0.1);
}
break;
}
}
void object::Fight()
{
int danger[], i = 0;
danger[i++] = Shielder;
danger[i++] = WingedShooter;
danger[i++] = TrackedShooter;
danger[i++] = WheeledShooter;
danger[i++] = LeggedShooter;
danger[i++] = WingedOrgaShooter;
danger[i++] = TrackedOrgaShooter;
danger[i++] = WheeledOrgaShooter;
danger[i++] = LeggedOrgaShooter;
danger[i++] = PhazerShooter;
danger[i++] = DefenseTower;
danger[i++] = NuclearPlant;
danger[i++] = RadarStation;
int alien[], j = 0;
//alien[j++] = Me;
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++] = 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;
object item;
errmode(0);
if (this.load != null) {drop();}
item = radar(danger);
while (item != null)
{
Produceammo();
item = radar(alien, 0, 360, 0, 10000, FilterOnlyLanding);
goto2(item.position);
if (this.load != null) {drop();}
item = radar(danger);
if (item != null) {GoBack();}
}
}
void object::Steal()
{
int list[], k = 0;
list[k++] = Titanium;
list[k++] = PowerCell;
list[k++] = NuclearCell;
object item;
errmode(0);
if (this.load != null) {drop();}
item = radar(list, 0, 360, 200, 10000, FilterOnlyLanding);
for (;this.load==null;)
{
item = radar(list, 0, 360, 0, 10000, FilterOnlyLanding);
if (item != null)
{
goto2(item.position);
motor(0,0);
jet(-1);
turn(direction(item.position));
move(distance2d(position, item.position));
while (this.altitude > 1)
{
jet(-1);
wait(0.1);
}
wait(0.1);
goto(item.position);
wait(0.1);
if (this.load == null) {grab();}
}
}
}
void object::Randomfly()
{
jet(1);
motor(1,0);
wait(0.5);
turn(rand()*360);
jet(1);
motor(0,1);
wait(0.5);
turn(rand()*360);
}
void object::GoBack()
{
point dustbin(34, 240);
errmode(0);
goto2(dustbin);
if (this.load == null) {drop();}
}
void object::Clear()
{
int list[], k = 0;
list[k++] = Titanium;
list[k++] = PowerCell;
list[k++] = NuclearCell;
object item;
errmode(0);
item = radar(list, 0, 360, 0, 200, FilterOnlyLanding);
if (item != null)
{
Produceammo();
goto(item.position);
drop();
}
}
void object::Produceammo()
{
errmode(0);
while (this.load == null)
{
goto(space(position));
while (this.altitude > 1)
{
jet(-1);
wait(0.1);
continue;
}
wait(1);
produce(OrgaMatter);
wait(0.5);
grab();
}
}
extern void object::NaturalWasp()
{
while(true)
{
Clear();
Fight();
Steal();
GoBack();
Randomfly();
continue;
}
}