From abdf718672c64355a8a74c25feb821f124a11d05 Mon Sep 17 00:00:00 2001 From: Andrei Drexler Date: Fri, 31 May 2002 18:17:10 +0000 Subject: [PATCH] Bot stuff. Added a server command that prints a line to a client and everyone who is spectating him --- reaction/game/ai_dmq3.c | 9 ++++++- reaction/game/g_cmds.c | 60 ++++++++++++++++++++++++++++++++--------- reaction/game/g_local.h | 7 ++++- reaction/game/game.plg | 57 --------------------------------------- 4 files changed, 61 insertions(+), 72 deletions(-) diff --git a/reaction/game/ai_dmq3.c b/reaction/game/ai_dmq3.c index 0e67bc66..88671606 100644 --- a/reaction/game/ai_dmq3.c +++ b/reaction/game/ai_dmq3.c @@ -5,6 +5,10 @@ //----------------------------------------------------------------------------- // // $Log$ +// Revision 1.39 2002/05/31 18:17:10 makro +// Bot stuff. Added a server command that prints a line to a client +// and everyone who is spectating him +// // Revision 1.38 2002/05/30 21:18:28 makro // Bots should reload/bandage when roaming around // Added "pathtarget" key to all the entities @@ -164,6 +168,7 @@ void Cmd_Bandage (gentity_t *ent); void G_Say( gentity_t *ent, gentity_t *target, int mode, const char *chatText ); gentity_t *SelectRandomDeathmatchSpawnPoint( void ); +void Cmd_New_Weapon(gentity_t *ent); // from aasfile.h #define AREACONTENTS_MOVER 1024 @@ -441,7 +446,9 @@ void RQ3_Bot_SetWeaponMode(bot_state_t *bs, int weapon, int mode) { //use the weapon command "press" times for (i = 0; i < press; i++) { - Cmd_Weapon( &g_entities[bs->entitynum] ); + //changed it to use Slicer's new command + //Cmd_Weapon( &g_entities[bs->entitynum] ); + Cmd_New_Weapon( &g_entities[bs->entitynum] ); } } diff --git a/reaction/game/g_cmds.c b/reaction/game/g_cmds.c index afe7a7a4..43879a50 100644 --- a/reaction/game/g_cmds.c +++ b/reaction/game/g_cmds.c @@ -5,6 +5,10 @@ //----------------------------------------------------------------------------- // // $Log$ +// Revision 1.114 2002/05/31 18:17:10 makro +// Bot stuff. Added a server command that prints a line to a client +// and everyone who is spectating him +// // Revision 1.113 2002/05/21 04:58:28 blaze // kicked the reload bugs ass! // @@ -2465,7 +2469,7 @@ void Cmd_Weapon(gentity_t *ent) if(ent->client->ps.weaponstate == WEAPON_BANDAGING) { if(!ent->client->weapon_after_bandage_warned) { ent->client->weapon_after_bandage_warned = qtrue; - trap_SendServerCommand( ent-g_entities, va("print \"You'll get to your weapon when you are finished bandaging!\n\"")); + G_SendClientSpec( ent, va("print \"You'll get to your weapon when you are finished bandaging!\n\"")); } ent->client->weapon_attempts++; return; @@ -2525,12 +2529,12 @@ void Cmd_Weapon(gentity_t *ent) { ent->client->ps.persistant[PERS_WEAPONMODES] &= ~RQ3_MK23MODE; - trap_SendServerCommand( ent-g_entities, va("print \"Switched to full automatic.\n\"")); + G_SendClientSpec( ent, va("print \"Switched to full automatic.\n\"")); } else { ent->client->ps.persistant[PERS_WEAPONMODES] |= RQ3_MK23MODE; - trap_SendServerCommand( ent-g_entities, va("print \"Switched to semi-automatic.\n\"")); + G_SendClientSpec( ent, va("print \"Switched to semi-automatic.\n\"")); } G_Sound(ent, CHAN_ITEM, G_SoundIndex("sound/misc/click.wav")); break; @@ -2539,12 +2543,12 @@ void Cmd_Weapon(gentity_t *ent) if ((ent->client->ps.persistant[PERS_WEAPONMODES] & RQ3_M4MODE) == RQ3_M4MODE) { ent->client->ps.persistant[PERS_WEAPONMODES] &= ~RQ3_M4MODE; - trap_SendServerCommand( ent-g_entities, va("print \"Switched to full automatic.\n\"")); + G_SendClientSpec( ent, va("print \"Switched to full automatic.\n\"")); } else { ent->client->ps.persistant[PERS_WEAPONMODES] |= RQ3_M4MODE; - trap_SendServerCommand( ent-g_entities, va("print \"Switched to 3 round burst.\n\"")); + G_SendClientSpec( ent, va("print \"Switched to 3 round burst.\n\"")); } G_Sound(ent, CHAN_ITEM, G_SoundIndex("sound/misc/click.wav")); break; @@ -2553,12 +2557,12 @@ void Cmd_Weapon(gentity_t *ent) if ((ent->client->ps.persistant[PERS_WEAPONMODES] & RQ3_MP5MODE) == RQ3_MP5MODE) { ent->client->ps.persistant[PERS_WEAPONMODES] &= ~RQ3_MP5MODE; - trap_SendServerCommand( ent-g_entities, va("print \"Switched to full automatic.\n\"")); + G_SendClientSpec( ent, va("print \"Switched to full automatic.\n\"")); } else { ent->client->ps.persistant[PERS_WEAPONMODES] |= RQ3_MP5MODE; - trap_SendServerCommand( ent-g_entities, va("print \"Switched to 3 round burst.\n\"")); + G_SendClientSpec( ent, va("print \"Switched to 3 round burst.\n\"")); } G_Sound(ent, CHAN_ITEM, G_SoundIndex("sound/misc/click.wav")); break; @@ -2571,7 +2575,7 @@ void Cmd_Weapon(gentity_t *ent) { //Elder: added ent->client->ps.persistant[PERS_WEAPONMODES] &= ~RQ3_KNIFEMODE; - trap_SendServerCommand( ent-g_entities, va("print \"Switched to throwing.\n\"")); + G_SendClientSpec( ent, va("print \"Switched to throwing.\n\"")); // Niceass: Animations added ent->client->ps.weaponstate = WEAPON_MODECHANGE; ent->client->ps.weaponTime = 550; @@ -2581,7 +2585,7 @@ void Cmd_Weapon(gentity_t *ent) { //Elder: we're gonna use this to flag throw or slash with the knife ent->client->ps.persistant[PERS_WEAPONMODES] |= RQ3_KNIFEMODE; - trap_SendServerCommand( ent-g_entities, va("print \"Switched to slashing.\n\"")); + G_SendClientSpec( ent, va("print \"Switched to slashing.\n\"")); // Niceass: Animations added ent->client->ps.weaponstate = WEAPON_MODECHANGE; ent->client->ps.weaponTime = 550; @@ -2610,19 +2614,19 @@ void Cmd_Weapon(gentity_t *ent) {//Going into Short ent->client->ps.persistant[PERS_WEAPONMODES] |= RQ3_GRENSHORT; //Set the short flag ent->client->ps.persistant[PERS_WEAPONMODES] &= ~RQ3_GRENMED; //unset the med flag - trap_SendServerCommand( ent-g_entities, va("print \"Grenade set for short range throw.\n\"")); + G_SendClientSpec(ent, va("print \"Grenade set for short range throw.\n\"")); } else if ( (ent->client->ps.persistant[PERS_WEAPONMODES] & RQ3_GRENSHORT) == RQ3_GRENSHORT) {//Going into Med ent->client->ps.persistant[PERS_WEAPONMODES] &= ~RQ3_GRENSHORT; //unset the short flag ent->client->ps.persistant[PERS_WEAPONMODES] |= RQ3_GRENMED; //Set the med flag - trap_SendServerCommand( ent-g_entities, va("print \"Grenade set for medium range throw.\n\"")); + G_SendClientSpec(ent, va("print \"Grenade set for medium range throw.\n\"")); } else if ( (ent->client->ps.persistant[PERS_WEAPONMODES] & RQ3_GRENMED) == RQ3_GRENMED) {//Going into Long ent->client->ps.persistant[PERS_WEAPONMODES] |= RQ3_GRENSHORT; //Set the short flag ent->client->ps.persistant[PERS_WEAPONMODES] |= RQ3_GRENMED; //Set the med flag - trap_SendServerCommand( ent-g_entities, va("print \"Grenade set for long range throw.\n\"")); + G_SendClientSpec(ent, va("print \"Grenade set for long range throw.\n\"")); } //Elder: added else { @@ -2639,7 +2643,8 @@ void Cmd_Weapon(gentity_t *ent) default: break; } - +//Makro - changed all the trap_SendServerCommand prints to G_SendClientSpec prints +//so that players spectating this client get his messages, too } //Slicer void Cmd_New_Weapon(gentity_t *ent) { @@ -3113,3 +3118,32 @@ int RQ3_ValidateSay ( gentity_t *ent ) return SAY_OK; } + +//Makro - this function sends print commands to the client and the ones spectating him +void G_SendClientSpec( gentity_t *ent, const char *msg ) +{ + int i; + + if (!ent) return; + if (!ent->client) return; + + trap_SendServerCommand( ent-g_entities, msg ); + + for (i = 0; i < level.maxclients; i++) { + gclient_t *follower = &level.clients[i]; + + //no need to send the message twice + if (i == ent-g_entities) + continue; + if (follower->pers.connected != CON_CONNECTED) + continue; + if (follower->sess.sessionTeam != TEAM_SPECTATOR) + continue; + if (follower->sess.spectatorState != SPECTATOR_FOLLOW) + continue; + //gotcha ! + if (follower->sess.spectatorClient == ent-g_entities) + trap_SendServerCommand( i, msg ); + } +} + diff --git a/reaction/game/g_local.h b/reaction/game/g_local.h index 5de15364..0740e1d0 100644 --- a/reaction/game/g_local.h +++ b/reaction/game/g_local.h @@ -5,6 +5,10 @@ //----------------------------------------------------------------------------- // // $Log$ +// Revision 1.86 2002/05/31 18:17:10 makro +// Bot stuff. Added a server command that prints a line to a client +// and everyone who is spectating him +// // Revision 1.85 2002/05/31 17:32:11 jbravo // HC gibs almost working :) // @@ -771,7 +775,8 @@ void Laser_Think( gentity_t *self ); int RQ3_ValidateSay ( gentity_t *ent ); //Elder: commented out for Homer //void toggleSemi(gentity_t *ent); - +//Makro - sends a command to a client and all the ones spectating him +void G_SendClientSpec( gentity_t *ent, const char *msg ); // // g_items.c // diff --git a/reaction/game/game.plg b/reaction/game/game.plg index 087a2094..3551c986 100644 --- a/reaction/game/game.plg +++ b/reaction/game/game.plg @@ -6,63 +6,6 @@ --------------------Configuration: game - Win32 Release--------------------

Command Lines

-Creating temporary file "D:\DOCUME~1\Andrei\LOCALS~1\Temp\RSP189.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_dmnet.c" -"C:\Games\Quake3\rq3source\reaction\game\ai_dmq3.c" -] -Creating command line "cl.exe @D:\DOCUME~1\Andrei\LOCALS~1\Temp\RSP189.tmp" -Creating temporary file "D:\DOCUME~1\Andrei\LOCALS~1\Temp\RSP18A.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\RSP18A.tmp" -

Output Window

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