1 package cz.cuni.amis.pogamut.ut2004.bot.command; 2 3 import java.util.logging.Logger; 4 5 import cz.cuni.amis.pogamut.base3d.worldview.object.ILocated; 6 import cz.cuni.amis.pogamut.ut2004.bot.impl.UT2004Bot; 7 import cz.cuni.amis.pogamut.unreal.communication.messages.UnrealId; 8 import cz.cuni.amis.pogamut.ut2004.communication.messages.gbcommands.Shoot; 9 import cz.cuni.amis.pogamut.ut2004.communication.messages.gbcommands.StopShooting; 10 import cz.cuni.amis.pogamut.ut2004.communication.messages.gbinfomessages.Player; 11 12 /** 13 * Class providing Pogamut2 UT2004 simple shooting commands for the bot 14 * 15 * @author Michal 'Knight' Bida 16 */ 17 public class SimpleShooting extends BotCommands { 18 19 /** 20 * Bot will start shooting his current weapon (Issues GB SHOOT command) 21 * 22 * @see stopShoot() 23 * @see shoot(UnrealId) 24 * @see shoot(ILocated) 25 */ 26 public void shoot() { 27 agent.getAct().act(new Shoot()); 28 } 29 30 /** 31 * Bot will start shooting his current weapon to a specified location (Issues GB SHOOT command). 32 * 33 * @param location 34 * 35 * @see stopShoot() 36 * @see shoot(UnrealId); 37 */ 38 public void shoot(ILocated location) { 39 if (location instanceof Player) { 40 shoot((Player)location); 41 } else { 42 agent.getAct().act(new Shoot().setLocation(location.getLocation())); 43 } 44 } 45 46 /** 47 * Bot will start shooting with his current weapon at the target provided. 48 * (Issues GB SHOOT command) Note that the bot will track the target while 49 * shooting. If not interrupted by other command that will change bot target 50 * or that will change bot focus too much. 51 * 52 * @param target 53 * Target (that should be ILocated) the bot will shoot at. Bot 54 * will track the target, but see note above. 55 * 56 * @see stopShoot() 57 * @see shoot() 58 */ 59 public void shoot(UnrealId target) { 60 agent.getAct().act(new Shoot().setTarget(target)); 61 } 62 63 /** 64 * Bot will start shooting with his current weapon at the target provided. 65 * (Issues GB SHOOT command) Note that the bot will track the target while 66 * shooting. If not interrupted by other command that will change bot target 67 * or that will change bot focus too much. 68 * 69 * @param target 70 * Player the bot wants to shoot at. 71 * 72 * @see stopShoot() 73 * @see shoot() 74 */ 75 public void shoot(Player target) { 76 agent.getAct().act(new Shoot().setTarget(target.getId())); 77 } 78 79 /** 80 * Bot will stop shooting his current weapon (Issues GB STOPSHOOT command) 81 * 82 * @see shoot() 83 * @see shoot(UnrealId) 84 */ 85 public void stopShoot() { 86 agent.getAct().act(new StopShooting()); 87 } 88 89 /** 90 * Constructor. Setups the command module based on given agent and logger. 91 * 92 * @param agent 93 * AbstractUT2004Bot we will send commands for 94 * @param log 95 * Logger to be used for logging runtime/debug info. 96 */ 97 public SimpleShooting(UT2004Bot agent, Logger log) { 98 super(agent, log); 99 } 100 101 }