Added a time limit for changing weapon modes for bots

This commit is contained in:
Andrei Drexler 2002-06-11 13:42:54 +00:00
parent 58a41b0d1a
commit 260b904e76
2 changed files with 16 additions and 1 deletions

View file

@ -5,6 +5,9 @@
//-----------------------------------------------------------------------------
//
// $Log$
// Revision 1.42 2002/06/11 13:42:54 makro
// Added a time limit for changing weapon modes for bots
//
// Revision 1.41 2002/06/06 20:04:10 makro
// Checking teams
//
@ -419,11 +422,17 @@ Added by Makro
*/
void RQ3_Bot_SetWeaponMode(bot_state_t *bs, int weapon, int mode) {
int i, modeCount, oldMode, press;
float reactionTime = trap_Characteristic_BFloat(bs->character, CHARACTERISTIC_REACTIONTIME, 0, 1);
//not holding the right weapon
if (weapon != bs->cur_ps.weapon)
return;
//too soon ?
//TODO: array with weapon mode change times for individual weapons ?
if (FloatTime() < bs->weapoModeChange_time + 2 - reactionTime)
return;
switch (bs->cur_ps.weapon) {
case WP_PISTOL:
case WP_KNIFE:
@ -456,6 +465,8 @@ void RQ3_Bot_SetWeaponMode(bot_state_t *bs, int weapon, int mode) {
//Cmd_Weapon( &g_entities[bs->entitynum] );
Cmd_New_Weapon( &g_entities[bs->entitynum] );
}
bs->weapoModeChange_time = FloatTime;
}
/*

View file

@ -5,6 +5,9 @@
//-----------------------------------------------------------------------------
//
// $Log$
// Revision 1.10 2002/06/11 13:42:54 makro
// Added a time limit for changing weapon modes for bots
//
// Revision 1.9 2002/05/30 21:18:28 makro
// Bots should reload/bandage when roaming around
// Added "pathtarget" key to all the entities
@ -221,7 +224,8 @@ typedef struct bot_state_s
int predictobstacles_goalareanum; //last goal areanum the bot predicted obstacles for
float radioresponse_time; //Makro - the last time the bot responded to a radio message
int radioresponse_count; //Makro - how many times the bot responded to radio messages
float idleAction_time; //Makro - last time the bot did something while roaming around (reload/bandage)
float idleAction_time; //Makro - last time the bot did something while roaming around (reload/bandage)
float weapoModeChange_time; //Makro - last time the bot changed weapon modes
vec3_t aimtarget;
vec3_t enemyvelocity; //enemy velocity 0.5 secs ago during battle