Main Page | Class Hierarchy | Alphabetical List | Data Structures | Directories | File List | Data Fields | Globals

be_ea.c

Go to the documentation of this file.
00001 /*
00002 ===========================================================================
00003 Copyright (C) 1999-2005 Id Software, Inc.
00004 
00005 This file is part of Quake III Arena source code.
00006 
00007 Quake III Arena source code is free software; you can redistribute it
00008 and/or modify it under the terms of the GNU General Public License as
00009 published by the Free Software Foundation; either version 2 of the License,
00010 or (at your option) any later version.
00011 
00012 Quake III Arena source code is distributed in the hope that it will be
00013 useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
00014 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015 GNU General Public License for more details.
00016 
00017 You should have received a copy of the GNU General Public License
00018 along with Foobar; if not, write to the Free Software
00019 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
00020 ===========================================================================
00021 */
00022 
00023 /*****************************************************************************
00024  * name:        be_ea.c
00025  *
00026  * desc:        elementary actions
00027  *
00028  * $Archive: /MissionPack/code/botlib/be_ea.c $
00029  *
00030  *****************************************************************************/
00031 
00032 #include "../game/q_shared.h"
00033 #include "l_memory.h"
00034 #include "l_script.h"
00035 #include "l_precomp.h"
00036 #include "l_struct.h"
00037 #include "../game/botlib.h"
00038 #include "be_interface.h"
00039 
00040 #define MAX_USERMOVE                400
00041 #define MAX_COMMANDARGUMENTS        10
00042 #define ACTION_JUMPEDLASTFRAME      128
00043 
00044 bot_input_t *botinputs;
00045 
00046 //===========================================================================
00047 //
00048 // Parameter:               -
00049 // Returns:                 -
00050 // Changes Globals:     -
00051 //===========================================================================
00052 void EA_Say(int client, char *str)
00053 {
00054     botimport.BotClientCommand(client, va("say %s", str) );
00055 } //end of the function EA_Say
00056 //===========================================================================
00057 //
00058 // Parameter:               -
00059 // Returns:                 -
00060 // Changes Globals:     -
00061 //===========================================================================
00062 void EA_SayTeam(int client, char *str)
00063 {
00064     botimport.BotClientCommand(client, va("say_team %s", str));
00065 } //end of the function EA_SayTeam
00066 //===========================================================================
00067 //
00068 // Parameter:               -
00069 // Returns:                 -
00070 // Changes Globals:     -
00071 //===========================================================================
00072 void EA_Tell(int client, int clientto, char *str)
00073 {
00074     botimport.BotClientCommand(client, va("tell %d, %s", clientto, str));
00075 } //end of the function EA_SayTeam
00076 //===========================================================================
00077 //
00078 // Parameter:               -
00079 // Returns:                 -
00080 // Changes Globals:     -
00081 //===========================================================================
00082 void EA_UseItem(int client, char *it)
00083 {
00084     botimport.BotClientCommand(client, va("use %s", it));
00085 } //end of the function EA_UseItem
00086 //===========================================================================
00087 //
00088 // Parameter:               -
00089 // Returns:                 -
00090 // Changes Globals:     -
00091 //===========================================================================
00092 void EA_DropItem(int client, char *it)
00093 {
00094     botimport.BotClientCommand(client, va("drop %s", it));
00095 } //end of the function EA_DropItem
00096 //===========================================================================
00097 //
00098 // Parameter:               -
00099 // Returns:                 -
00100 // Changes Globals:     -
00101 //===========================================================================
00102 void EA_UseInv(int client, char *inv)
00103 {
00104     botimport.BotClientCommand(client, va("invuse %s", inv));
00105 } //end of the function EA_UseInv
00106 //===========================================================================
00107 //
00108 // Parameter:           -
00109 // Returns:             -
00110 // Changes Globals:     -
00111 //===========================================================================
00112 void EA_DropInv(int client, char *inv)
00113 {
00114     botimport.BotClientCommand(client, va("invdrop %s", inv));
00115 } //end of the function EA_DropInv
00116 //===========================================================================
00117 //
00118 // Parameter:           -
00119 // Returns:             -
00120 // Changes Globals:     -
00121 //===========================================================================
00122 void EA_Gesture(int client)
00123 {
00124     bot_input_t *bi;
00125 
00126     bi = &botinputs[client];
00127 
00128     bi->actionflags |= ACTION_GESTURE;
00129 } //end of the function EA_Gesture
00130 //===========================================================================
00131 //
00132 // Parameter:               -
00133 // Returns:                 -
00134 // Changes Globals:     -
00135 //===========================================================================
00136 void EA_Command(int client, char *command)
00137 {
00138     botimport.BotClientCommand(client, command);
00139 } //end of the function EA_Command
00140 //===========================================================================
00141 //
00142 // Parameter:           -
00143 // Returns:             -
00144 // Changes Globals:     -
00145 //===========================================================================
00146 void EA_SelectWeapon(int client, int weapon)
00147 {
00148     bot_input_t *bi;
00149 
00150     bi = &botinputs[client];
00151 
00152     bi->weapon = weapon;
00153 } //end of the function EA_SelectWeapon
00154 //===========================================================================
00155 //
00156 // Parameter:           -
00157 // Returns:             -
00158 // Changes Globals:     -
00159 //===========================================================================
00160 void EA_Attack(int client)
00161 {
00162     bot_input_t *bi;
00163 
00164     bi = &botinputs[client];
00165 
00166     bi->actionflags |= ACTION_ATTACK;
00167 } //end of the function EA_Attack
00168 //===========================================================================
00169 //
00170 // Parameter:           -
00171 // Returns:             -
00172 // Changes Globals:     -
00173 //===========================================================================
00174 void EA_Talk(int client)
00175 {
00176     bot_input_t *bi;
00177 
00178     bi = &botinputs[client];
00179 
00180     bi->actionflags |= ACTION_TALK;
00181 } //end of the function EA_Talk
00182 //===========================================================================
00183 //
00184 // Parameter:           -
00185 // Returns:             -
00186 // Changes Globals:     -
00187 //===========================================================================
00188 void EA_Use(int client)
00189 {
00190     bot_input_t *bi;
00191 
00192     bi = &botinputs[client];
00193 
00194     bi->actionflags |= ACTION_USE;
00195 } //end of the function EA_Use
00196 //===========================================================================
00197 //
00198 // Parameter:           -
00199 // Returns:             -
00200 // Changes Globals:     -
00201 //===========================================================================
00202 void EA_Respawn(int client)
00203 {
00204     bot_input_t *bi;
00205 
00206     bi = &botinputs[client];
00207 
00208     bi->actionflags |= ACTION_RESPAWN;
00209 } //end of the function EA_Respawn
00210 //===========================================================================
00211 //
00212 // Parameter:           -
00213 // Returns:             -
00214 // Changes Globals:     -
00215 //===========================================================================
00216 void EA_Jump(int client)
00217 {
00218     bot_input_t *bi;
00219 
00220     bi = &botinputs[client];
00221 
00222     if (bi->actionflags & ACTION_JUMPEDLASTFRAME)
00223     {
00224         bi->actionflags &= ~ACTION_JUMP;
00225     } //end if
00226     else
00227     {
00228         bi->actionflags |= ACTION_JUMP;
00229     } //end if
00230 } //end of the function EA_Jump
00231 //===========================================================================
00232 //
00233 // Parameter:           -
00234 // Returns:             -
00235 // Changes Globals:     -
00236 //===========================================================================
00237 void EA_DelayedJump(int client)
00238 {
00239     bot_input_t *bi;
00240 
00241     bi = &botinputs[client];
00242 
00243     if (bi->actionflags & ACTION_JUMPEDLASTFRAME)
00244     {
00245         bi->actionflags &= ~ACTION_DELAYEDJUMP;
00246     } //end if
00247     else
00248     {
00249         bi->actionflags |= ACTION_DELAYEDJUMP;
00250     } //end if
00251 } //end of the function EA_DelayedJump
00252 //===========================================================================
00253 //
00254 // Parameter:           -
00255 // Returns:             -
00256 // Changes Globals:     -
00257 //===========================================================================
00258 void EA_Crouch(int client)
00259 {
00260     bot_input_t *bi;
00261 
00262     bi = &botinputs[client];
00263 
00264     bi->actionflags |= ACTION_CROUCH;
00265 } //end of the function EA_Crouch
00266 //===========================================================================
00267 //
00268 // Parameter:           -
00269 // Returns:             -
00270 // Changes Globals:     -
00271 //===========================================================================
00272 void EA_Walk(int client)
00273 {
00274     bot_input_t *bi;
00275 
00276     bi = &botinputs[client];
00277 
00278     bi->actionflags |= ACTION_WALK;
00279 } //end of the function EA_Walk
00280 //===========================================================================
00281 //
00282 // Parameter:           -
00283 // Returns:             -
00284 // Changes Globals:     -
00285 //===========================================================================
00286 void EA_Action(int client, int action)
00287 {
00288     bot_input_t *bi;
00289 
00290     bi = &botinputs[client];
00291 
00292     bi->actionflags |= action;
00293 } //end of function EA_Action
00294 //===========================================================================
00295 //
00296 // Parameter:           -
00297 // Returns:             -
00298 // Changes Globals:     -
00299 //===========================================================================
00300 void EA_MoveUp(int client)
00301 {
00302     bot_input_t *bi;
00303 
00304     bi = &botinputs[client];
00305 
00306     bi->actionflags |= ACTION_MOVEUP;
00307 } //end of the function EA_MoveUp
00308 //===========================================================================
00309 //
00310 // Parameter:           -
00311 // Returns:             -
00312 // Changes Globals:     -
00313 //===========================================================================
00314 void EA_MoveDown(int client)
00315 {
00316     bot_input_t *bi;
00317 
00318     bi = &botinputs[client];
00319 
00320     bi->actionflags |= ACTION_MOVEDOWN;
00321 } //end of the function EA_MoveDown
00322 //===========================================================================
00323 //
00324 // Parameter:           -
00325 // Returns:             -
00326 // Changes Globals:     -
00327 //===========================================================================
00328 void EA_MoveForward(int client)
00329 {
00330     bot_input_t *bi;
00331 
00332     bi = &botinputs[client];
00333 
00334     bi->actionflags |= ACTION_MOVEFORWARD;
00335 } //end of the function EA_MoveForward
00336 //===========================================================================
00337 //
00338 // Parameter:           -
00339 // Returns:             -
00340 // Changes Globals:     -
00341 //===========================================================================
00342 void EA_MoveBack(int client)
00343 {
00344     bot_input_t *bi;
00345 
00346     bi = &botinputs[client];
00347 
00348     bi->actionflags |= ACTION_MOVEBACK;
00349 } //end of the function EA_MoveBack
00350 //===========================================================================
00351 //
00352 // Parameter:           -
00353 // Returns:             -
00354 // Changes Globals:     -
00355 //===========================================================================
00356 void EA_MoveLeft(int client)
00357 {
00358     bot_input_t *bi;
00359 
00360     bi = &botinputs[client];
00361 
00362     bi->actionflags |= ACTION_MOVELEFT;
00363 } //end of the function EA_MoveLeft
00364 //===========================================================================
00365 //
00366 // Parameter:           -
00367 // Returns:             -
00368 // Changes Globals:     -
00369 //===========================================================================
00370 void EA_MoveRight(int client)
00371 {
00372     bot_input_t *bi;
00373 
00374     bi = &botinputs[client];
00375 
00376     bi->actionflags |= ACTION_MOVERIGHT;
00377 } //end of the function EA_MoveRight
00378 //===========================================================================
00379 //
00380 // Parameter:           -
00381 // Returns:             -
00382 // Changes Globals:     -
00383 //===========================================================================
00384 void EA_Move(int client, vec3_t dir, float speed)
00385 {
00386     bot_input_t *bi;
00387 
00388     bi = &botinputs[client];
00389 
00390     VectorCopy(dir, bi->dir);
00391     //cap speed
00392     if (speed > MAX_USERMOVE) speed = MAX_USERMOVE;
00393     else if (speed < -MAX_USERMOVE) speed = -MAX_USERMOVE;
00394     bi->speed = speed;
00395 } //end of the function EA_Move
00396 //===========================================================================
00397 //
00398 // Parameter:           -
00399 // Returns:             -
00400 // Changes Globals:     -
00401 //===========================================================================
00402 void EA_View(int client, vec3_t viewangles)
00403 {
00404     bot_input_t *bi;
00405 
00406     bi = &botinputs[client];
00407 
00408     VectorCopy(viewangles, bi->viewangles);
00409 } //end of the function EA_View
00410 //===========================================================================
00411 //
00412 // Parameter:           -
00413 // Returns:             -
00414 // Changes Globals:     -
00415 //===========================================================================
00416 void EA_EndRegular(int client, float thinktime)
00417 {
00418 /*
00419     bot_input_t *bi;
00420     int jumped = qfalse;
00421 
00422     bi = &botinputs[client];
00423 
00424     bi->actionflags &= ~ACTION_JUMPEDLASTFRAME;
00425 
00426     bi->thinktime = thinktime;
00427     botimport.BotInput(client, bi);
00428 
00429     bi->thinktime = 0;
00430     VectorClear(bi->dir);
00431     bi->speed = 0;
00432     jumped = bi->actionflags & ACTION_JUMP;
00433     bi->actionflags = 0;
00434     if (jumped) bi->actionflags |= ACTION_JUMPEDLASTFRAME;
00435 */
00436 } //end of the function EA_EndRegular
00437 //===========================================================================
00438 //
00439 // Parameter:           -
00440 // Returns:             -
00441 // Changes Globals:     -
00442 //===========================================================================
00443 void EA_GetInput(int client, float thinktime, bot_input_t *input)
00444 {
00445     bot_input_t *bi;
00446 //  int jumped = qfalse;
00447 
00448     bi = &botinputs[client];
00449 
00450 //  bi->actionflags &= ~ACTION_JUMPEDLASTFRAME;
00451 
00452     bi->thinktime = thinktime;
00453     Com_Memcpy(input, bi, sizeof(bot_input_t));
00454 
00455     /*
00456     bi->thinktime = 0;
00457     VectorClear(bi->dir);
00458     bi->speed = 0;
00459     jumped = bi->actionflags & ACTION_JUMP;
00460     bi->actionflags = 0;
00461     if (jumped) bi->actionflags |= ACTION_JUMPEDLASTFRAME;
00462     */
00463 } //end of the function EA_GetInput
00464 //===========================================================================
00465 //
00466 // Parameter:           -
00467 // Returns:             -
00468 // Changes Globals:     -
00469 //===========================================================================
00470 void EA_ResetInput(int client)
00471 {
00472     bot_input_t *bi;
00473     int jumped = qfalse;
00474 
00475     bi = &botinputs[client];
00476     bi->actionflags &= ~ACTION_JUMPEDLASTFRAME;
00477 
00478     bi->thinktime = 0;
00479     VectorClear(bi->dir);
00480     bi->speed = 0;
00481     jumped = bi->actionflags & ACTION_JUMP;
00482     bi->actionflags = 0;
00483     if (jumped) bi->actionflags |= ACTION_JUMPEDLASTFRAME;
00484 } //end of the function EA_ResetInput
00485 //===========================================================================
00486 //
00487 // Parameter:           -
00488 // Returns:             -
00489 // Changes Globals:     -
00490 //===========================================================================
00491 int EA_Setup(void)
00492 {
00493     //initialize the bot inputs
00494     botinputs = (bot_input_t *) GetClearedHunkMemory(
00495                                     botlibglobals.maxclients * sizeof(bot_input_t));
00496     return BLERR_NOERROR;
00497 } //end of the function EA_Setup
00498 //===========================================================================
00499 //
00500 // Parameter:           -
00501 // Returns:             -
00502 // Changes Globals:     -
00503 //===========================================================================
00504 void EA_Shutdown(void)
00505 {
00506     FreeMemory(botinputs);
00507     botinputs = NULL;
00508 } //end of the function EA_Shutdown

Generated on Thu Aug 25 12:37:12 2005 for Quake III Arena by  doxygen 1.3.9.1