Module/Radar/WideLock
Jump to navigation
Jump to search
package jab.radar; import jab.Module; import jab.Radar; import robocode.Event; import robocode.ScannedRobotEvent; import robocode.util.Utils; /** * Credits * RadarBot by PEZ */ public class WideLock extends Radar { public WideLock(Module bot) { super(bot); } private int timeSinceLastScan = 10; private double enemyAbsoluteBearing; public void scan(){ timeSinceLastScan++; double radarOffset = Double.NEGATIVE_INFINITY; if (timeSinceLastScan < 3) { radarOffset = Utils .normalRelativeAngle(bot.getRadarHeadingRadians() - enemyAbsoluteBearing); radarOffset += Math.signum(radarOffset) * 0.2; } bot.setTurnRadarLeftRadians(radarOffset); } public void listen(Event e){ if (e instanceof ScannedRobotEvent){ enemyAbsoluteBearing = bot.getHeadingRadians() + bot.enemy.bearingRadians; timeSinceLastScan = 0; } } }