diff --git a/reaction/game/ai_dmq3.c b/reaction/game/ai_dmq3.c index 458621fe..767e4b03 100644 --- a/reaction/game/ai_dmq3.c +++ b/reaction/game/ai_dmq3.c @@ -5,6 +5,9 @@ //----------------------------------------------------------------------------- // // $Log$ +// Revision 1.44 2002/06/15 15:02:05 makro +// Recoded AI for weapon mode switching. Bots can now zoom with the sg +// // Revision 1.43 2002/06/11 14:03:04 makro // Forgot (), heh // @@ -411,6 +414,23 @@ int RQ3_Bot_GetWeaponMode(bot_state_t *bs, int weapon) return 0; } } + case WP_SSG3000: + { + //6x + if ( (bs->cur_ps.stats[STAT_RQ3] & RQ3_ZOOM_MED) == RQ3_ZOOM_MED && + (bs->cur_ps.stats[STAT_RQ3] & RQ3_ZOOM_LOW) == RQ3_ZOOM_LOW ) { + return 3; + //4x + } else if ( (bs->cur_ps.stats[STAT_RQ3] & RQ3_ZOOM_MED) == RQ3_ZOOM_MED ) { + return 2; + //2x + } else if ( (bs->cur_ps.stats[STAT_RQ3] & RQ3_ZOOM_LOW) == RQ3_ZOOM_LOW ) { + return 1; + //unzoomed + } else { + return 0; + } + } default: return 0; } @@ -424,18 +444,25 @@ Added by Makro ================== */ void RQ3_Bot_SetWeaponMode(bot_state_t *bs, int weapon, int mode) { - int i, modeCount, oldMode, press; + //int i, modeCount, oldMode, press; float reactionTime = trap_Characteristic_BFloat(bs->character, CHARACTERISTIC_REACTIONTIME, 0, 1); + //invalid weapon + if (weapon <= WP_NONE || weapon >= WP_NUM_WEAPONS) + return; + + /* Makro - old code //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) + if (FloatTime() < bs->weaponModeChange_time + 2 - reactionTime) return; + /* Old code switch (bs->cur_ps.weapon) { case WP_PISTOL: case WP_KNIFE: @@ -443,10 +470,12 @@ void RQ3_Bot_SetWeaponMode(bot_state_t *bs, int weapon, int mode) { break; case WP_MP5: case WP_M4: - case WP_SSG3000: case WP_GRENADE: modeCount = 3; break; + case WP_SSG3000: + modeCount = 4; + break; default: modeCount = 1; break; @@ -468,8 +497,12 @@ 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(); + //new code + bs->weapMode[weapon] = mode; + + bs->weaponModeChange_time = FloatTime(); } /* @@ -2123,8 +2156,15 @@ BotChooseWeapon void BotChooseWeapon(bot_state_t *bs) { int newweaponnum; //distance from the enemy - int dist = sqrt(bs->inventory[ENEMY_HORIZONTAL_DIST] * bs->inventory[ENEMY_HORIZONTAL_DIST] + + int dist; + + if (bs->enemy != -1) { + dist = sqrt(bs->inventory[ENEMY_HORIZONTAL_DIST] * bs->inventory[ENEMY_HORIZONTAL_DIST] + bs->inventory[ENEMY_HEIGHT] * bs->inventory[ENEMY_HEIGHT]); + } else { + dist = 8; + } + if (dist <= 0) { dist = 8; } @@ -2150,6 +2190,14 @@ void BotChooseWeapon(bot_state_t *bs) { } else { RQ3_Bot_SetWeaponMode(bs, WP_GRENADE, 0); } + } else if (bs->weaponnum == WP_SSG3000) { + //2x + if (bs->enemy != -1 && dist > 600) { + RQ3_Bot_SetWeaponMode(bs, WP_SSG3000, 1); + //unzoomed + } else { + RQ3_Bot_SetWeaponMode(bs, WP_SSG3000, 0); + } } } else { @@ -2175,6 +2223,14 @@ void BotChooseWeapon(bot_state_t *bs) { } else { RQ3_Bot_SetWeaponMode(bs, WP_GRENADE, 0); } + } else if (bs->weaponnum == WP_SSG3000) { + //2x + if (bs->enemy != -1 && dist > 600) { + RQ3_Bot_SetWeaponMode(bs, WP_SSG3000, 1); + //unzoomed + } else { + RQ3_Bot_SetWeaponMode(bs, WP_SSG3000, 0); + } } } } @@ -2436,6 +2492,16 @@ void BotUpdateInventory(bot_state_t *bs) { } */ BotCheckItemPickup(bs, oldinventory); + + //Makro - new weapon mode switching code + if (RQ3_Bot_GetWeaponMode(bs, bs->cur_ps.weapon) != bs->weapMode[bs->cur_ps.weapon]) { + if (bs->weaponModeClick_time + 0.1 < FloatTime()) { + if (bs->cur_ps.weaponstate == WEAPON_READY) { + Cmd_New_Weapon(&g_entities[bs->entitynum]); + } + bs->weaponModeClick_time = FloatTime(); + } + } } /* @@ -2724,6 +2790,11 @@ void RQ3_Bot_IdleActions( bot_state_t *bs ) { int weapon = bs->cur_ps.weapon; //float reactiontime = trap_Characteristic_BFloat(bs->character, CHARACTERISTIC_REACTIONTIME, 0, 1); + //always unzoom SSG when idle + if (RQ3_Bot_GetWeaponMode(bs, WP_SSG3000)) { + RQ3_Bot_SetWeaponMode(bs, WP_SSG3000, 0); + } + //too soon to reload/bandage again ? if (bs->idleAction_time > FloatTime()) return; diff --git a/reaction/game/ai_main.h b/reaction/game/ai_main.h index 799fbcf9..0873df64 100644 --- a/reaction/game/ai_main.h +++ b/reaction/game/ai_main.h @@ -5,6 +5,9 @@ //----------------------------------------------------------------------------- // // $Log$ +// Revision 1.11 2002/06/15 15:02:05 makro +// Recoded AI for weapon mode switching. Bots can now zoom with the sg +// // Revision 1.10 2002/06/11 13:42:54 makro // Added a time limit for changing weapon modes for bots // @@ -225,7 +228,10 @@ typedef struct bot_state_s 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 weapoModeChange_time; //Makro - last time the bot changed weapon modes + float weaponModeChange_time; //Makro - last time the bot changed weapon modes + float weaponModeClick_time; //Makro - last time the bot "pressed" the weapon button + + int weapMode[WP_NUM_WEAPONS]; //Makro - the weapon modes the bot wants to use vec3_t aimtarget; vec3_t enemyvelocity; //enemy velocity 0.5 secs ago during battle diff --git a/reaction/game/game.plg b/reaction/game/game.plg index 3551c986..698f6025 100644 --- a/reaction/game/game.plg +++ b/reaction/game/game.plg @@ -6,6 +6,61 @@ --------------------Configuration: game - Win32 Release--------------------

Command Lines

+Creating temporary file "D:\DOCUME~1\Andrei\LOCALS~1\Temp\RSPA71.tmp" with contents +[ +/nologo /G6 /ML /W4 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /FR"c:\reactionoutput/" /Fp"c:\reactionoutput/game.pch" /YX /Fo"c:\reactionoutput/" /Fd"c:\reactionoutput/" /FD /c +"C:\Games\Quake3\rq3source\reaction\game\ai_dmq3.c" +] +Creating command line "cl.exe @D:\DOCUME~1\Andrei\LOCALS~1\Temp\RSPA71.tmp" +Creating temporary file "D:\DOCUME~1\Andrei\LOCALS~1\Temp\RSPA72.tmp" with contents +[ +kernel32.lib user32.lib winmm.lib /nologo /base:"0x20000000" /subsystem:windows /dll /incremental:no /pdb:"c:\reactionoutput/qagamex86.pdb" /map:"c:\reactionoutput/qagamex86.map" /machine:I386 /def:".\game.def" /out:"..\Release/qagamex86.dll" /implib:"c:\reactionoutput/qagamex86.lib" +\reactionoutput\ai_chat.obj +\reactionoutput\ai_cmd.obj +\reactionoutput\ai_dmnet.obj +\reactionoutput\ai_dmq3.obj +\reactionoutput\ai_main.obj +\reactionoutput\ai_team.obj +\reactionoutput\ai_vcmd.obj +\reactionoutput\bg_misc.obj +\reactionoutput\bg_pmove.obj +\reactionoutput\bg_slidemove.obj +\reactionoutput\g_active.obj +\reactionoutput\g_arenas.obj +\reactionoutput\g_bot.obj +\reactionoutput\g_client.obj +\reactionoutput\g_cmds.obj +\reactionoutput\g_combat.obj +\reactionoutput\g_fileio.obj +\reactionoutput\g_items.obj +\reactionoutput\g_main.obj +\reactionoutput\g_matchmode.obj +\reactionoutput\g_mem.obj +\reactionoutput\g_misc.obj +\reactionoutput\g_missile.obj +\reactionoutput\g_mover.obj +\reactionoutput\g_session.obj +\reactionoutput\g_spawn.obj +\reactionoutput\g_svcmds.obj +\reactionoutput\g_syscalls.obj +\reactionoutput\g_target.obj +\reactionoutput\g_team.obj +\reactionoutput\g_teamplay.obj +\reactionoutput\g_trigger.obj +\reactionoutput\g_utils.obj +\reactionoutput\g_weapon.obj +\reactionoutput\q_math.obj +\reactionoutput\q_shared.obj +\reactionoutput\rxn_game.obj +\reactionoutput\zcam.obj +\reactionoutput\zcam_target.obj +] +Creating command line "link.exe @D:\DOCUME~1\Andrei\LOCALS~1\Temp\RSPA72.tmp" +

Output Window

+Compiling... +ai_dmq3.c +Linking... + Creating library c:\reactionoutput/qagamex86.lib and object c:\reactionoutput/qagamex86.exp