From 746b33120f5b988f5ed23cdb090951948b0c66d3 Mon Sep 17 00:00:00 2001 From: Andrei Drexler Date: Sun, 5 May 2002 15:18:03 +0000 Subject: [PATCH] Fixed some crash bugs. Bot stuff. Triggerable func_statics. Made flags only spawn in CTF mode --- reaction/game/ai_dmnet.c | 16 +++++-- reaction/game/ai_dmq3.c | 91 ++++++++++++++++++++++++++++++++++++--- reaction/game/ai_main.h | 6 +++ reaction/game/g_mover.c | 34 ++++++++++++++- reaction/game/g_spawn.c | 16 ++++++- reaction/game/g_trigger.c | 24 +++++++---- reaction/game/g_weapon.c | 10 +++++ reaction/game/game.plg | 12 +++--- 8 files changed, 184 insertions(+), 25 deletions(-) diff --git a/reaction/game/ai_dmnet.c b/reaction/game/ai_dmnet.c index 0e1ee6eb..8861a260 100644 --- a/reaction/game/ai_dmnet.c +++ b/reaction/game/ai_dmnet.c @@ -5,6 +5,10 @@ //----------------------------------------------------------------------------- // // $Log$ +// Revision 1.23 2002/05/05 15:18:02 makro +// Fixed some crash bugs. Bot stuff. Triggerable func_statics. +// Made flags only spawn in CTF mode +// // Revision 1.22 2002/05/04 16:13:04 makro // Bots // @@ -22,7 +26,7 @@ // // Revision 1.17 2002/05/01 05:32:45 makro // Bots reload akimbos/handcannons. Also, they can decide whether -// or not an item in the ground is better than theirs +// or not an item on the ground is better than theirs // // Revision 1.16 2002/04/30 11:54:37 makro // Bots rule ! Also, added clips to give all. Maybe some other things @@ -439,6 +443,9 @@ qboolean RQ3_Bot_NeedToDropStuff(bot_state_t *bs, bot_goal_t *goal) { if (RQ3_Bot_CanReload(bs, dropWeapon)) return qfalse; //Makro - the current weapon is empty, drop it Cmd_DropWeapon_f( &g_entities[bs->entitynum] ); +#ifdef DEBUG + BotAI_Print(PRT_MESSAGE, "droppping weapon %i\n", dropWeapon); +#endif //DEBUG return qtrue; } @@ -1796,13 +1803,16 @@ int AINode_Seek_ActivateEntity(bot_state_t *bs) { targetvisible = qtrue; // if holding the right weapon // Makro - or if no weapon is set for the goal - if (bs->cur_ps.weapon == bs->activatestack->weapon || bs->activatestack->weapon == WP_NONE) { + if (bs->cur_ps.weapon == bs->activatestack->weapon || bs->activatestack->noWeapon) { VectorSubtract(bs->activatestack->target, bs->eye, dir); vectoangles(dir, ideal_viewangles); // if the bot is pretty close with it's aim if (InFieldOfVision(bs->viewangles, 20, ideal_viewangles)) { //Makro - using custom function to allow in-combat reloads //trap_EA_Attack(bs->client); +#ifdef DEBUG + BotAI_Print(PRT_MESSAGE, "attacking an entity; weapon = %i, required = %i\n", bs->cur_ps.weapon, bs->activatestack->weapon); +#endif //DEBUG BotAttack(bs); } } @@ -1814,7 +1824,7 @@ int AINode_Seek_ActivateEntity(bot_state_t *bs) { BotEntityInfo(goal->entitynum, &entinfo); // if the entity the bot shoots at moved // Makro - or if the entity is no longer in use - for func_breakables - if (!VectorCompare(bs->activatestack->origin, entinfo.origin) || !(g_entities[entinfo.number].inuse)) { + if (!VectorCompare(bs->activatestack->origin, entinfo.origin) || !(g_entities[entinfo.number].r.linked)) { #ifdef DEBUG BotAI_Print(PRT_MESSAGE, "hit shootable button or trigger\n"); #endif //DEBUG diff --git a/reaction/game/ai_dmq3.c b/reaction/game/ai_dmq3.c index 75d36415..b5ba5954 100644 --- a/reaction/game/ai_dmq3.c +++ b/reaction/game/ai_dmq3.c @@ -5,6 +5,10 @@ //----------------------------------------------------------------------------- // // $Log$ +// Revision 1.29 2002/05/05 15:18:02 makro +// Fixed some crash bugs. Bot stuff. Triggerable func_statics. +// Made flags only spawn in CTF mode +// // Revision 1.28 2002/05/04 16:13:04 makro // Bots // @@ -28,7 +32,7 @@ // // Revision 1.21 2002/05/01 05:32:45 makro // Bots reload akimbos/handcannons. Also, they can decide whether -// or not an item in the ground is better than theirs +// or not an item on the ground is better than theirs // // Revision 1.20 2002/04/30 12:14:53 makro // Fixed a small warning @@ -354,12 +358,13 @@ qboolean RQ3_Bot_GetWeaponInfo(bot_state_t *bs, int weaponstate, int weapon, voi //if the weapon is not valid if (weapon <= WP_NONE || weapon >= WP_NUM_WEAPONS) { #ifdef DEBUG - BotAI_Print(PRT_MESSAGE, "weapon not ready (%i)\n", bs->cur_ps.weapon); -#endif //DEBUG + BotAI_Print(PRT_MESSAGE, "Bot_GetWeaponInfo: weapon number out of range (%i)\n", weapon); +#else //DEBUG if (trap_Cvar_VariableIntegerValue("developer")) { BotAI_Print(PRT_ERROR, "Bot_GetWeaponInfo: weapon number out of range (%i)\n", weapon); } return qfalse; +#endif } else { weaponinfo_t *wi; trap_BotGetWeaponInfo(weaponstate, weapon, weaponinfo); @@ -1903,6 +1908,70 @@ int BotSynonymContext(bot_state_t *bs) { return context; } +/* +==================================== +RQ3_Bot_WeaponFitness + +Added by Makro +We have to take into account factors +that the trap calls don't seem to +==================================== +*/ +#define Score_M3_1 50 +#define Score_M3_2 65 +#define Score_M3_3 80 + +#define Score_HC_1 50 +#define Score_HC_2 65 +#define Score_HC_3 80 + +int RQ3_Bot_WeaponFitness(bot_state_t *bs, int weapon) +{ + int dist = bs->inventory[ENEMY_HORIZONTAL_DIST] * bs->inventory[ENEMY_HORIZONTAL_DIST] + + bs->inventory[ENEMY_HEIGHT] * bs->inventory[ENEMY_HEIGHT]; + + if (bs->cur_ps.ammo[weapon] <= 0 && !RQ3_Bot_CanReload(bs, weapon)) + return 0; + + switch (weapon) { + case WP_PISTOL: + return 70; + case WP_AKIMBO: + return 80; + case WP_M3: + { + if (dist > 1000) + return (int) (Score_M3_1 * 1000 / dist); + else if (dist > 500) + return Score_M3_2; + else + return Score_M3_3; + } + case WP_HANDCANNON: + { + if (dist > 500) + return 0; + else if (dist > 200) + return 50; + else if (dist > 100) + return 50; + else + return 80; + } + default: + return 0; + } +} +/* +====================== +RQ3_Bot_ChooseWeapon + +Added by Makro +====================== +*/ +void RQ3_Bot_ChooseBestFightWeapon(bot_state_t *bs) { +} + /* ================== BotChooseWeapon @@ -4511,7 +4580,8 @@ int BotFuncBreakableGoal(bot_state_t *bs, int bspent, bot_activategoal_t *activa activategoal->goal.entitynum = entitynum; activategoal->goal.number = 0; activategoal->goal.flags = 0; - activategoal->weapon = WP_NONE; + //activategoal->weapon = WP_NUM_WEAPONS; + activategoal->noWeapon = qtrue; //Makro - hmm, not quite sure this is right, but they did it for func_doors VectorCopy(bs->origin, activategoal->goal.origin); activategoal->goal.areanum = bs->areanum; @@ -5702,9 +5772,20 @@ void BotCheckEvents(bot_state_t *bs, entityState_t *state) { case EV_FOOTSPLASH: case EV_FOOTWADE: case EV_SWIM: + break; case EV_FALL_SHORT: case EV_FALL_MEDIUM: - case EV_FALL_FAR: + case EV_FALL_FAR: // Makro - check for falling damage + { + int skill = trap_Characteristic_BFloat(bs->character, CHARACTERISTIC_ATTACK_SKILL, 0, 1); + if (random() > (1.0f - skill)) { + if ((bs->cur_ps.stats[STAT_RQ3] & RQ3_BANDAGE_NEED) == RQ3_BANDAGE_NEED || + (bs->cur_ps.stats[STAT_RQ3] & RQ3_LEGDAMAGE) == RQ3_LEGDAMAGE) { + //Makro - this is the attack skill, we should be using the overall skill + Cmd_Bandage( &g_entities[bs->entitynum] ); + } + } + } case EV_STEP_4: case EV_STEP_8: case EV_STEP_12: diff --git a/reaction/game/ai_main.h b/reaction/game/ai_main.h index 2db10019..1377b589 100644 --- a/reaction/game/ai_main.h +++ b/reaction/game/ai_main.h @@ -5,6 +5,10 @@ //----------------------------------------------------------------------------- // // $Log$ +// Revision 1.8 2002/05/05 15:18:02 makro +// Fixed some crash bugs. Bot stuff. Triggerable func_statics. +// Made flags only spawn in CTF mode +// // Revision 1.7 2002/04/05 03:12:28 makro // Radio stuff // @@ -119,6 +123,8 @@ typedef struct bot_activategoal_s int shoot; //true if bot has to shoot to activate int openDoor; //Makro - true if bot has to open a door int weapon; //weapon to be used for activation + qboolean noWeapon; //Makro - true if a weapon is NOT needed for + //activation - breakables can be shot with any weapon vec3_t target; //target to shoot at to activate something vec3_t origin; //origin of the blocking entity to activate int areas[MAX_ACTIVATEAREAS]; //routing areas disabled by blocking entity diff --git a/reaction/game/g_mover.c b/reaction/game/g_mover.c index 1b4484e7..757fe02b 100644 --- a/reaction/game/g_mover.c +++ b/reaction/game/g_mover.c @@ -5,6 +5,10 @@ //----------------------------------------------------------------------------- // // $Log$ +// Revision 1.26 2002/05/05 15:18:02 makro +// Fixed some crash bugs. Bot stuff. Triggerable func_statics. +// Made flags only spawn in CTF mode +// // Revision 1.25 2002/04/03 15:51:01 jbravo // Small warning fixes // @@ -2136,17 +2140,45 @@ STATIC */ -/*QUAKED func_static (0 .5 .8) ? +/*QUAKED func_static (0 .5 .8) ? START_OFF A bmodel that just sits there, doing nothing. Can be used for conditional walls and models. "model2" .md3 model to also draw "color" constantLight color "light" constantLight radius */ +//Makro - added for triggerable func_statics +void use_func_static( gentity_t *ent, gentity_t *other, gentity_t *activator ) { + ent->count ^= 1; + if ( ent->count ) { + ent->s.eFlags &= ~EF_NODRAW; + ent->r.contents = CONTENTS_SOLID; + ent->r.svFlags &= ~SVF_NOCLIENT; + } else { + ent->s.eFlags |= EF_NODRAW; + ent->r.contents = CONTENTS_TRIGGER; + ent->r.svFlags |= SVF_NOCLIENT; + } +} + void SP_func_static( gentity_t *ent ) { trap_SetBrushModel( ent, ent->model ); InitMover( ent ); VectorCopy( ent->s.origin, ent->s.pos.trBase ); VectorCopy( ent->s.origin, ent->r.currentOrigin ); + //Makro - added + if ( ent->spawnflags & 1 ) { + ent->s.eFlags |= EF_NODRAW; + ent->r.contents = CONTENTS_TRIGGER; + ent->r.svFlags |= SVF_NOCLIENT; + ent->count = 0; + } else { + ent->s.eFlags &= ~EF_NODRAW; + ent->r.contents = CONTENTS_SOLID; + ent->r.svFlags &= ~SVF_NOCLIENT; + ent->count = 1; + } + ent->use = use_func_static; + //end Makro } diff --git a/reaction/game/g_spawn.c b/reaction/game/g_spawn.c index f95351d6..27e7f734 100644 --- a/reaction/game/g_spawn.c +++ b/reaction/game/g_spawn.c @@ -5,6 +5,10 @@ //----------------------------------------------------------------------------- // // $Log$ +// Revision 1.24 2002/05/05 15:18:02 makro +// Fixed some crash bugs. Bot stuff. Triggerable func_statics. +// Made flags only spawn in CTF mode +// // Revision 1.23 2002/05/04 06:28:58 makro // no message // @@ -439,8 +443,16 @@ qboolean G_CallSpawn( gentity_t *ent ) { //Makro - new code for ( item=bg_itemlist+1 ; item->classname ; item++ ) { if ( !strcmp(item->classname, ent->classname) ) { - G_SpawnItem( ent, item ); - return qtrue; + //only spawn flags in CTF mode + if ( item->giTag == PW_REDFLAG || item->giTag == PW_BLUEFLAG ) { + if (g_gametype.integer == GT_CTF) { + G_SpawnItem( ent, item ); + return qtrue; + } + } else { + G_SpawnItem( ent, item ); + return qtrue; + } } } diff --git a/reaction/game/g_trigger.c b/reaction/game/g_trigger.c index 39915072..28be90c8 100644 --- a/reaction/game/g_trigger.c +++ b/reaction/game/g_trigger.c @@ -5,6 +5,10 @@ //----------------------------------------------------------------------------- // // $Log$ +// Revision 1.9 2002/05/05 15:18:03 makro +// Fixed some crash bugs. Bot stuff. Triggerable func_statics. +// Made flags only spawn in CTF mode +// // Revision 1.8 2002/03/18 06:20:39 blaze // noise tag will play sounds for trigger_push and target_push // @@ -46,14 +50,18 @@ void multi_trigger( gentity_t *ent, gentity_t *activator ) { return; // can't retrigger until the wait is over } - if ( activator->client ) { - if ( ( ent->spawnflags & 1 ) && - activator->client->sess.sessionTeam != TEAM_RED ) { - return; - } - if ( ( ent->spawnflags & 2 ) && - activator->client->sess.sessionTeam != TEAM_BLUE ) { - return; + //Makro - added check; Q3 crashed in archives when playing + //with .dll's and shooting one of the barrels + if ( activator != NULL ) { + if ( activator->client ) { + if ( ( ent->spawnflags & 1 ) && + activator->client->sess.sessionTeam != TEAM_RED ) { + return; + } + if ( ( ent->spawnflags & 2 ) && + activator->client->sess.sessionTeam != TEAM_BLUE ) { + return; + } } } diff --git a/reaction/game/g_weapon.c b/reaction/game/g_weapon.c index d8f182d8..2be16adb 100644 --- a/reaction/game/g_weapon.c +++ b/reaction/game/g_weapon.c @@ -5,6 +5,10 @@ //----------------------------------------------------------------------------- // // $Log$ +// Revision 1.53 2002/05/05 15:18:03 makro +// Fixed some crash bugs. Bot stuff. Triggerable func_statics. +// Made flags only spawn in CTF mode +// // Revision 1.52 2002/05/03 18:09:20 makro // Bot stuff. Jump kicks // @@ -2086,6 +2090,12 @@ LogAccuracyHit =============== */ qboolean LogAccuracyHit( gentity_t *target, gentity_t *attacker ) { + //Makro - some checks; Q3 crashed with .dlls + //when shooting one of the barrels in archives + if (target == NULL || attacker == NULL) { + return qfalse; + } + if( !target->takedamage ) { return qfalse; } diff --git a/reaction/game/game.plg b/reaction/game/game.plg index c59c9f68..2a0f3413 100644 --- a/reaction/game/game.plg +++ b/reaction/game/game.plg @@ -6,13 +6,13 @@ --------------------Configuration: game - Win32 Debug--------------------

Command Lines

-Creating temporary file "D:\DOCUME~1\Andrei\LOCALS~1\Temp\RSP2454.tmp" with contents +Creating temporary file "D:\DOCUME~1\Andrei\LOCALS~1\Temp\RSPE4.tmp" with contents [ /nologo /G5 /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "BUILDING_REF_GL" /D "DEBUG" /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" +"C:\Games\Quake3\rq3source\reaction\game\g_spawn.c" ] -Creating command line "cl.exe @D:\DOCUME~1\Andrei\LOCALS~1\Temp\RSP2454.tmp" -Creating temporary file "D:\DOCUME~1\Andrei\LOCALS~1\Temp\RSP2455.tmp" with contents +Creating command line "cl.exe @D:\DOCUME~1\Andrei\LOCALS~1\Temp\RSPE4.tmp" +Creating temporary file "D:\DOCUME~1\Andrei\LOCALS~1\Temp\RSPE5.tmp" with contents [ kernel32.lib user32.lib winmm.lib /nologo /base:"0x20000000" /subsystem:windows /dll /incremental:yes /pdb:"c:\reactionoutput/qagamex86.pdb" /map:"c:\reactionoutput/qagamex86.map" /debug /machine:I386 /def:".\game.def" /out:"..\Debug/qagamex86.dll" /implib:"c:\reactionoutput/qagamex86.lib" \reactionoutput\ai_chat.obj @@ -55,10 +55,10 @@ kernel32.lib user32.lib winmm.lib /nologo /base:"0x20000000" /subsystem:windows \reactionoutput\zcam.obj \reactionoutput\zcam_target.obj ] -Creating command line "link.exe @D:\DOCUME~1\Andrei\LOCALS~1\Temp\RSP2455.tmp" +Creating command line "link.exe @D:\DOCUME~1\Andrei\LOCALS~1\Temp\RSPE5.tmp"

Output Window

Compiling... -ai_dmq3.c +g_spawn.c Linking...