public class ChaoticDroid extends AdvancedRobot implements Droid {
boolean hit=false; public void run() { setAdjustGunForRobotTurn(true); setColors(Color.black,Color.black,Color.black); while (true) { if(!hit){ setAhead(200); setTurnRight?(200); } if(getGunHeat()==0 && getTurnRemaining?()==0 && getDistanceRemaining?()==0){ hit=false; } execute(); } }
public void onHitRobot?(HitRobotEvent? e) { turnGunRight?(Utils.normalizeBearing(getHeading() - getGunHeading?() + e.getBearing())); fire(3); }
public void onBulletHit?(BulletHitEvent? e) { hit=true; Bullet bullet = e.getBullet(); turnGunRight?(Utils.normalizeBearing(Utils.absoluteBearing(getX(), getY(), bullet.getX(), bullet.getY())-getGunHeading?())); while(getGunHeat()!=0){ turnRight(1); } fire(3); setTurnGunRight(Utils.normalizeBearing(Utils.absoluteBearing(getX(), getY(), bullet.getX(), bullet.getY())-getGunHeading?())); setTurnRight?(Utils.normalizeBearing(Utils.absoluteBearing(getX(), getY(), bullet.getX(), bullet.getY())-getHeading())); setAhead(Point2D.distance(getX(), getY(), bullet.getX(), bullet.getY())); execute(); }
public void onHitByBullet?(HitByBulletEvent? e){ hit=true; setInterruptible(false); setTurnRight?(e.getBearing()); setAhead(5000); execute(); }}