View Javadoc

1   package cz.cuni.amis.pogamut.udk.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.base3d.worldview.object.Rotation;
7   import cz.cuni.amis.pogamut.udk.bot.impl.UDKBot;
8   import cz.cuni.amis.pogamut.udk.communication.messages.gbcommands.Act;
9   import cz.cuni.amis.pogamut.udk.communication.messages.gbcommands.Pick;
10  import cz.cuni.amis.pogamut.udk.communication.messages.gbcommands.Respawn;
11  import cz.cuni.amis.pogamut.udk.communication.messages.gbcommands.Throw;
12  import cz.cuni.amis.pogamut.unreal.communication.messages.UnrealId;
13  
14  /**
15   * Class providing Pogamut2 UT2004 bot action commands - throwing weapon,
16   * issuing combos, item interactions and other commands that didn't fit in other
17   * categories.
18   * 
19   * @author Michal 'Knight' Bida
20   */
21  public class Action extends BotCommands {
22  
23  	/**
24  	 * Throws out bots current weapon (just if he is allowed to throw this kind
25  	 * of weapon out - some weapons cannot be thrown e.g. ShieldGun) and will
26  	 * change to best weapon available.
27  	 * 
28  	 * (issues GB THROW command)
29  	 */
30  	public void throwWeapon() {
31  		agent.getAct().act(new Throw());
32  	}
33  
34  	/**
35  	 * This function will kill the bot and force him to respawn. He will respawn
36  	 * on some randomly chosen starting point in the map.
37  	 * 
38  	 * (issues GB RESPAWN command)
39  	 * 
40  	 * @see respawn(ILocated)
41  	 * @see respawn(ILocated,Rotation)
42  	 */
43  	public void respawn() {
44  		agent.getAct().act(new Respawn());
45  	}
46  
47  	/**
48  	 * This function will kill the bot and force him to respawn. He will respawn
49  	 * at the location supplied (if he is allowed to respawn there). Be carefull
50  	 * when supporting some object in the game that is ILocated, may kill other
51  	 * player if respawned at his positions.
52  	 * 
53  	 * (issues GB RESPAWN command)
54  	 * 
55  	 * @param location
56  	 *            Bot will be respawned at this location (if he can). Be
57  	 *            carefull may kill players this way. Usefull when wanted to
58  	 *            specify NavPoint you want the bot to have respawned at.
59  	 * 
60  	 * @see respawn()
61  	 * @see respawn(ILocated,Rotation)
62  	 * 
63  	 */
64  	public void respawn(ILocated location) {
65  		Respawn respawn = new Respawn();
66  
67  		respawn.setStartLocation(location.getLocation());
68  		agent.getAct().act(respawn);
69  	}
70  
71  	/**
72  	 * This function will kill the bot and force him to respawn. He will respawn
73  	 * at the location specified (if he is allowed to respawn there). Be
74  	 * carefull when supporting some object in the game that is ILocated, may
75  	 * kill other player if respawned at his positions. He will be respawned
76  	 * with supplied rotation set.
77  	 * 
78  	 * (issues GB RESPAWN command)
79  	 * 
80  	 * @param location
81  	 *            Location where the bot will be respawned.
82  	 * @param rotation
83  	 *            Initial rotation of the bot.
84  	 * 
85  	 * @see respawn()
86  	 * @see respawn(ILocated)
87  	 * 
88  	 */
89  	public void respawn(ILocated location, Rotation rotation) {
90  		Respawn respawn = new Respawn();
91  
92  		respawn.setStartLocation(location.getLocation());
93  		respawn.setStartRotation(rotation);
94  		agent.getAct().act(respawn);
95  	}
96  
97  	/**
98  	 * If the items are set to be picked up manualy, this command can be used to
99  	 * pick up the items. Note that the bot must be touching the item, when this
100 	 * command is issued to picked it up.
101 	 * 
102 	 * To disable auto pickup (so the bots will pick items manually by this
103 	 * command) set in GameBots ini file found in UT_HOME/System directory
104 	 * variable bDisableAutoPickup to true (the variable should be in .RemoteBot
105 	 * section).
106 	 * 
107 	 * @param id
108 	 *            UnrealId of the item we want to pick up.
109 	 */
110 	public void pick(UnrealId id) {
111 		agent.getAct().act(new Pick().setId(id));
112 	}
113 
114 	/**
115 	 * This command can be used to play some available bot animation. To see
116 	 * which animations are available, go to UnrealEd Actor Class browser,
117 	 * select Animations tab and open the .ukx file containing the animations of
118 	 * the model of the bot you are using in UT.
119 	 * 
120 	 * Note that movement animations will always override animations issued by
121 	 * this command. The bot must stand still for the issued animation to
122 	 * finish.
123 	 * 
124 	 * @param animName
125 	 *            name of the animation we want to run
126 	 */
127 	public void playAnimation(String animName) {
128 		agent.getAct().act(new Act().setName(animName));
129 	}
130 
131 	/**
132 	 * Constructor. Setups the command module based on given agent and logger.
133 	 * 
134 	 * @param agent
135 	 *            AbstractUT2004Bot we will send commands for
136 	 * @param log
137 	 *            Logger to be used for logging runtime/debug info.
138 	 */
139 	public Action(UDKBot agent, Logger log) {
140 		super(agent, log);
141 	}
142 }