View Javadoc

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