extern void object::HunterKiller() { errmode ( 0 ); float height; float aimz; object obj, item; point dest,scrap, storage, target; int j=0, err, i; float dist, pl, xt,yt,x,y; while(true) { if ( shieldLevel < 0.5 ) { message("Bot shields are at "+ (shieldLevel *100) + "% Heading back for repairs" ,DisplayInfo); item = radar(RepairCenter); if ( item != null ) { goto(item.position); while ( shieldLevel < 1 ) { wait(1); } } } obj=radar(PowerStation); if(obj==null) { obj = radar(SpaceShip);} i=1; do{ item=radar(TargetBot,0,360,0,i); if(item == null) { item=radar(AlienAnt,0,360,0,i); } if(item == null) { item=radar(AlienSpider,0,360,0,i); } if(item == null) { item=radar(AlienWasp,0,360,0,i); } if(item == null) { item=radar(AlienWorm,0,360,0,i); } i += 10; } while(item ==null and i < 1000); message("An enemy " + item.category + " has been found. Exterminiation mode Active",DisplayInfo); dist=distance(obj.position,item.position) + distance(position,item.position); message("Range is to taget is " + distance(position,item.position)+ " meters",DisplayInfo); if(category == LeggedShooter or category == LeggedOrgaShooter) { pl = (0.05 + 1.05*(dist*0.0008)); } if(category == WheeledShooter or category == WheeledOrgaShooter) { pl = (0.10 + 1.25*(dist*0.0016)); } if(category == TrackedShooter or category == TrackedOrgaShooter) { pl = (0.10 + 1.25*(dist*0.0025)); } if(energyCell.category == NuclearCell) { pl = pl * 0.1;} message("Estimated Safe power needed is :"+(pl*100)+"% Current Cell level is:"+ (energyCell.energyLevel*100)+"%",DisplayInfo); if(energyCell.energyLevel < pl and energyCell.category != NuclearCell and (radar(PowerStation)) != null) { j=5; do { item = radar(PowerStation,0,360,j-5,j); j+=5; if (item != null) { err = goto(item.position); if(err != 0){item = radar(WayPoint,0,1,0,1);} } if (j >= 600){ j=5; message("PowerStation(s) are blocked!",DisplayWarning); wait(30); } } while (item == null); if (item != null){ message("The Bot is recharging its power cells.",DisplayInfo); while ( energyCell.energyLevel < 1 ) { wait(1); } } } else { if (category != Subber) { if(energyCell.energyLevel < pl ) { message("The Bot is changing power cells.",DisplayInfo); j= 5; do{ item = radar(PowerCell,0,360,j-5,j); if (item == null) {item = radar(NuclearCell,0,360,j-5,j);} j+=5; if (item != null) {if (item.energyLevel <= 0.8) { item = radar(WayPoint,0,1,0,1);} } if (j >= 400){ j=5; message("Bot Cannot find any energy cells.",DisplayInfo); wait(30); } } while ( item == null ); do{ err = goto(item.position); if (err != 0) { message("powercell get error.. trying again.",DisplayInfo); turn(120); move(15); } } while(err !=0 ); grab(InFront); // take the new cell in front drop(Behind); // and drop it behind grab(EnergyCell); // take the cell from the bot drop(InFront); // and drop it in front grab(Behind); // take the new cell drop(EnergyCell); // and drop it on the bot } else{ if(energyCell.energyLevel < pl ) { item = radar(SpaceShip); goto(item.position); message("Subber needs a Cell change at SpaceShip.",DisplayError);} } } } turn(direction(item.position)); target=item.position; dist = distance(position, item.position); if (dist > 69) { message("Current position is: X1="+position.x+" Y1=" +position.y,DisplayInfo); message("Target Position is: X2="+item.position.x+" Y2=" + item.position.y,DisplayInfo); x = ((item.position.x) - (cos(asin((item.position.y - position.y)/dist)))*60); y = ((item.position.y) - (cos(acos((item.position.y - position.y)/dist)))*60); message("WayPoint to start attack run is at: X="+x+" Y=" + y,DisplayInfo); target.x = x; target.y = y; goto(target); } else{ if(dist <= 70){ err = move(dist-41); if (err != 0) {move(-5); turn(120); move(12);} dist = distance(position, item.position); height = topo(item.position) - topo(position); turn(direction(item.position)); dist = distance(position, item.position); aimz = atan(height / dist); aimz = (aimz - pitch); message("Targeting at:"+aimz+"Degrees"); aim(aimz); if(dist <= 44) { fire(0.1); motor(-0.5 + -rand() * 0.5 ,-0.5 + -rand() * 0.5 ); wait(rand()*0.5); } } } } }