diff --git a/doc/050_commands.md b/doc/050_commands.md index 9b2c05a4..a393c9cb 100644 --- a/doc/050_commands.md +++ b/doc/050_commands.md @@ -63,6 +63,3 @@ original clients (Vanilla Quake II) commands are still in place. it's just the same thing) * **sv removebot **: Remove a bot ("all" removes every bot in the map). - -* **sv addmonster**: Spawns a monster. It's a testing function. Spawning - from map files is not present in the code. diff --git a/src/game/bot/ai_class_monster_default.c b/src/game/bot/ai_class_monster_default.c index 63c2f06a..9ccd1408 100644 --- a/src/game/bot/ai_class_monster_default.c +++ b/src/game/bot/ai_class_monster_default.c @@ -254,7 +254,7 @@ void M_default_FireWeapon (edict_t *self) monster_fire_bullet (self, start, forward, 4, 4, rand(), rand(), MZ2_INFANTRY_MACHINEGUN_2); } - //if(AIDevel.debugMode && bot_debugmonster->integer) + //if(AIDevel.debugMode && bot_debugmonster->value) // gi.cprintf(NULL, PRINT_HIGH, "monster: attacking\n"); } @@ -645,121 +645,3 @@ void M_default_RunFrame( edict_t *self ) self->nextthink = level.time + FRAMETIME; } - - -//========================================== -// M_default_InitPersistant -// Persistant after respawns. -//========================================== -void M_default_InitPersistant(edict_t *self) -{ - //set 'class' functions - self->ai.pers.RunFrame = M_default_RunFrame; - self->ai.pers.UpdateStatus = M_default_UpdateStatus; - self->ai.pers.bloquedTimeout = M_default_BloquedTimeout; - self->ai.pers.deadFrame = M_default_DeadFrame; - - //skill - self->ai.pers.skillLevel = (int)(random()*MAX_BOT_SKILL); - if (self->ai.pers.skillLevel > MAX_BOT_SKILL) //fix if off-limits - self->ai.pers.skillLevel = MAX_BOT_SKILL; - else if (self->ai.pers.skillLevel < 0) - self->ai.pers.skillLevel = 0; - - //available moveTypes for this class - self->ai.pers.moveTypesMask = (LINK_MOVE|LINK_STAIRS|LINK_WATER|LINK_WATERJUMP); - - //Persistant Inventory Weights (0 = can not pick) - memset(self->ai.pers.inventoryWeights, 0, sizeof (self->ai.pers.inventoryWeights)); -} - - -//========================================== -// M_default_Spawn -// -//========================================== - -void M_default_Start( edict_t *self ) -{ - self->health = 30; - self->max_health = self->health; - self->item = FindItemByClassname("ammo_bullets"); - - - self->think = AI_Think; - self->nextthink = level.time + FRAMETIME; - self->yaw_speed = 100; - M_default_InitPersistant(self); - AI_ResetNavigation(self); - - //add as bot enemy - AI_EnemyAdded( self ); - - //if(AIDevel.debugMode && bot_debugmonster->integer) - Com_Printf ("monster: Spawn\n"); -} - - -void M_default_Spawn (void) -{ - edict_t *ent; - vec3_t spawn_origin, spawn_angles;//spawn at a spawnpoint - vec3_t mins = {-15, -15, -24}; - vec3_t maxs = {15, 15, 32}; - - ent = G_Spawn(); - - //spawn at a spawnpoint - SelectSpawnPoint (ent, spawn_origin, spawn_angles); - spawn_origin[2] += 8; - - //------------------------------------------------- - - // clear entity values - ent->groundentity = NULL; - ent->takedamage = DAMAGE_AIM; - ent->movetype = MOVETYPE_WALK; - ent->viewheight = 22; - ent->inuse = true; - - ent->classname = "monster"; - - ent->mass = 200; - ent->solid = SOLID_BBOX; - ent->deadflag = DEAD_NO; - ent->air_finished = level.time + 12; - ent->clipmask = MASK_MONSTERSOLID; - //ent->model = "models/monsters/infantry/tris.md2";//jalfixme - ent->waterlevel = 0; - ent->watertype = 0; - ent->flags &= ~FL_NO_KNOCKBACK; - - ent->pain = M_default_pain; - ent->die = M_default_die; - - VectorCopy (mins, ent->mins); - VectorCopy (maxs, ent->maxs); - VectorClear (ent->velocity); - - ent->s.modelindex = gi.modelindex("models/monsters/infantry/tris.md2"); - - // clear entity state values - ent->s.effects = 0; - ent->s.frame = 0; - VectorCopy (spawn_origin, ent->s.origin); - VectorCopy (ent->s.origin, ent->s.old_origin); - - ent->s.angles[PITCH] = 0; - ent->s.angles[YAW] = spawn_angles[YAW]; - ent->s.angles[ROLL] = 0; - - if (!KillBox (ent)) - { // could't spawn in? - } - gi.linkentity (ent); - - //finish - M_default_Start(ent); -} - - diff --git a/src/game/bot/ai_dropnodes.c b/src/game/bot/ai_dropnodes.c index 38dcc8f1..68b6301a 100644 --- a/src/game/bot/ai_dropnodes.c +++ b/src/game/bot/ai_dropnodes.c @@ -69,14 +69,20 @@ edict_t *AI_PlayerDroppingNodesPassent(void) int AI_AddNode( vec3_t origin, int flagsmask ) { if (nav.num_nodes + 1 > MAX_NODES) + { return -1; + } - if( flagsmask & NODEFLAGS_WATER ) + if (flagsmask & NODEFLAGS_WATER) + { flagsmask |= NODEFLAGS_FLOAT; + } VectorCopy( origin, nodes[nav.num_nodes].origin ); - if( !(flagsmask & NODEFLAGS_FLOAT) ) + if (!(flagsmask & NODEFLAGS_FLOAT)) + { AI_DropNodeOriginToFloor( nodes[nav.num_nodes].origin, player.ent ); + } //if( !(flagsmask & NODEFLAGS_NOWORLD) ) { //don't spawn inside solids // trace_t trace; @@ -88,7 +94,10 @@ int AI_AddNode( vec3_t origin, int flagsmask ) nodes[nav.num_nodes].flags = flagsmask; nodes[nav.num_nodes].flags |= AI_FlagsForNode( nodes[nav.num_nodes].origin, player.ent ); - Com_Printf("Dropped Node\n"); + if (bot_debugmonster->value) + { + Com_Printf("Dropped Node\n"); + } nav.num_nodes++; return nav.num_nodes-1; // return the node added @@ -118,7 +127,10 @@ void AI_UpdateNodeEdge(int from, int to) link = AI_FindLinkType( from, to ); } - Com_Printf("Link: %d -> %d. %s\n", from, to, AI_LinkString(link) ); + if (bot_debugmonster->value) + { + Com_Printf("Link: %d -> %d. %s\n", from, to, AI_LinkString(link)); + } } diff --git a/src/game/bot/ai_local.h b/src/game/bot/ai_local.h index 164f9b06..a94d6ec6 100644 --- a/src/game/bot/ai_local.h +++ b/src/game/bot/ai_local.h @@ -37,11 +37,11 @@ //bot debug_chase options -extern cvar_t *bot_showpath; -extern cvar_t *bot_showcombat; -extern cvar_t *bot_showsrgoal; -extern cvar_t *bot_showlrgoal; -extern cvar_t *bot_debugmonster; +// extern cvar_t *bot_showpath; +// extern cvar_t *bot_showcombat; +// extern cvar_t *bot_showsrgoal; +// extern cvar_t *bot_showlrgoal; +extern cvar_t *bot_debugmonster; //---------------------------------------------------------- @@ -49,12 +49,6 @@ extern cvar_t *bot_debugmonster; #define AI_GOAL_SR_RADIUS 200 #define MAX_BOT_SKILL 5 //skill levels graduation -// Platform states: -#define STATE_TOP 0 -#define STATE_BOTTOM 1 -#define STATE_UP 2 -#define STATE_DOWN 3 - // Bot state types #define BOT_STATE_STAND 0 #define BOT_STATE_MOVE 1 @@ -94,14 +88,6 @@ extern ai_devel_t AIDevel; //---------------------------------------------------------- -//game -//---------------------------------------------------------- -void CopyToBodyQue (edict_t *ent); -void Use_Plat (edict_t *ent, edict_t *other, edict_t *activator); -void ClientThink (edict_t *ent, usercmd_t *ucmd); -void SelectSpawnPoint (edict_t *ent, vec3_t origin, vec3_t angles); -qboolean ClientConnect (edict_t *ent, char *userinfo); - // bot_spawn.c //---------------------------------------------------------- void BOT_Respawn(edict_t *ent); @@ -129,24 +115,23 @@ void AI_ChangeAngle (edict_t *ent); qboolean AI_MoveToGoalEntity(edict_t *self, usercmd_t *ucmd); qboolean AI_SpecialMove(edict_t *self, usercmd_t *ucmd); qboolean AI_CanMove(edict_t *self, int direction); -qboolean AI_IsLadder(vec3_t origin, vec3_t v_angle, vec3_t mins, vec3_t maxs, edict_t *passent); -qboolean AI_IsStep (edict_t *ent); +qboolean AI_IsLadder(vec3_t origin, vec3_t v_angle, vec3_t mins, vec3_t maxs, edict_t *passent); +qboolean AI_IsStep(edict_t *ent); // ai_navigation.c //---------------------------------------------------------- -int AI_FindCost(int from, int to, int movetypes); +int AI_FindCost(int from, int to, int movetypes); int AI_FindClosestReachableNode( vec3_t origin, edict_t *passent, int range, int flagsmask ); -void AI_SetGoal(edict_t *self, int goal_node); -qboolean AI_FollowPath(edict_t *self); +void AI_SetGoal(edict_t *self, int goal_node); +qboolean AI_FollowPath(edict_t *self); // ai_nodes.c //---------------------------------------------------------- -qboolean AI_DropNodeOriginToFloor( vec3_t origin, edict_t *passent ); -void AI_InitNavigationData(void); -int AI_FlagsForNode( vec3_t origin, edict_t *passent ); -float AI_Distance( vec3_t o1, vec3_t o2 ); - +qboolean AI_DropNodeOriginToFloor( vec3_t origin, edict_t *passent ); +void AI_InitNavigationData(void); +int AI_FlagsForNode( vec3_t origin, edict_t *passent ); +float AI_Distance( vec3_t o1, vec3_t o2 ); void AITools_AddBotRoamNode(void); @@ -182,12 +167,10 @@ void AI_BotRoamFinishTimeouts(edict_t *self); //bot_classes //---------------------------------------------------------- void BOT_DMclass_InitPersistant(edict_t *self); -qboolean BOT_ChangeWeapon (edict_t *ent, gitem_t *item); -void M_default_Spawn (void); +qboolean BOT_ChangeWeapon(edict_t *ent, gitem_t *item); //ai_weapons.c //---------------------------------------------------------- -void AI_InitAIWeapons (void); - +void AI_InitAIWeapons(void); qboolean AI_IsLadder(vec3_t origin, vec3_t v_angle, vec3_t mins, vec3_t maxs, edict_t *passent); diff --git a/src/game/bot/ai_main.c b/src/game/bot/ai_main.c index 986e8840..fc18aab1 100644 --- a/src/game/bot/ai_main.c +++ b/src/game/bot/ai_main.c @@ -29,6 +29,12 @@ int num_players; edict_t *players[MAX_CLIENTS]; // pointers to all players in the game ai_devel_t AIDevel; +// cvar_t *bot_showpath; +// cvar_t *bot_showcombat; +// cvar_t *bot_showsrgoal; +// cvar_t *bot_showlrgoal; +cvar_t *bot_debugmonster; + //ACE @@ -39,10 +45,10 @@ ai_devel_t AIDevel; void AI_Init(void) { //Init developer mode - bot_showpath = gi.cvar("bot_showpath", "0", CVAR_SERVERINFO); - bot_showcombat = gi.cvar("bot_showcombat", "0", CVAR_SERVERINFO); - bot_showsrgoal = gi.cvar("bot_showsrgoal", "0", CVAR_SERVERINFO); - bot_showlrgoal = gi.cvar("bot_showlrgoal", "0", CVAR_SERVERINFO); + // bot_showpath = gi.cvar("bot_showpath", "0", CVAR_SERVERINFO); + // bot_showcombat = gi.cvar("bot_showcombat", "0", CVAR_SERVERINFO); + // bot_showsrgoal = gi.cvar("bot_showsrgoal", "0", CVAR_SERVERINFO); + // bot_showlrgoal = gi.cvar("bot_showlrgoal", "0", CVAR_SERVERINFO); bot_debugmonster = gi.cvar("bot_debugmonster", "0", CVAR_SERVERINFO|CVAR_ARCHIVE); AIDevel.debugMode = false; diff --git a/src/game/bot/ai_navigation.c b/src/game/bot/ai_navigation.c index 9acbbed2..c74068f3 100644 --- a/src/game/bot/ai_navigation.c +++ b/src/game/bot/ai_navigation.c @@ -163,11 +163,13 @@ qboolean AI_FollowPath( edict_t *self ) float dist; // Show the path + /* if(bot_showpath->value) { if( AIDevel.debugChased ) AITools_DrawPath(self, self->ai.current_node, self->ai.goal_node); } + */ if( self->ai.goal_node == INVALID ) return false; diff --git a/src/game/bot/astar.c b/src/game/bot/astar.c index 002ec848..a709165b 100644 --- a/src/game/bot/astar.c +++ b/src/game/bot/astar.c @@ -221,7 +221,7 @@ static void AStar_PutAdjacentsInOpen(int node) int plinkDist; plinkDist = AStar_PLinkDistance( node, addnode ); - if( plinkDist == -1) + if (plinkDist == -1 && bot_debugmonster->value) { Com_Printf("WARNING: AStar_PutAdjacentsInOpen - Couldn't find distance between nodes\n"); } @@ -247,7 +247,10 @@ static void AStar_PutAdjacentsInOpen(int node) plinkDist = 999;//jalFIXME } - Com_Printf("WARNING: AStar_PutAdjacentsInOpen - Couldn't find distance between nodes\n"); + if (bot_debugmonster->value) + { + Com_Printf("WARNING: AStar_PutAdjacentsInOpen - Couldn't find distance between nodes\n"); + } } //put in global list @@ -287,7 +290,11 @@ static int AStar_FindInOpen_BestF ( void ) } } - Com_Printf("BEST:%i\n", best); + if (bot_debugmonster->value) + { + Com_Printf("BEST:%i\n", best); + } + return best; } @@ -350,8 +357,11 @@ int AStar_ResolvePath ( int n1, int n2, int movetypes ) AStar_ListsToPath(); - Com_Printf("RESULT:\n Origin:%i\n Goal:%i\n numNodes:%i\n FirstInPath:%i\n LastInPath:%i\n", originNode, goalNode, Apath_numNodes, Apath[0], Apath[Apath_numNodes-1]); - + if (bot_debugmonster->value) + { + Com_Printf("RESULT:\n Origin:%i\n Goal:%i\n numNodes:%i\n FirstInPath:%i\n LastInPath:%i\n", + originNode, goalNode, Apath_numNodes, Apath[0], Apath[Apath_numNodes-1]); + } return 1; } diff --git a/src/game/bot/bot_common.c b/src/game/bot/bot_common.c index 1453b598..daced4c8 100644 --- a/src/game/bot/bot_common.c +++ b/src/game/bot/bot_common.c @@ -35,34 +35,39 @@ qboolean BOT_ServerCommand (void) { char *cmd; - cmd = gi.argv (1); - - + cmd = gi.argv(1); if (Q_stricmp (cmd, "addbot") == 0) { if(ctf->value) // name, skin, team + { BOT_SpawnBot ( gi.argv(2), gi.argv(3), gi.argv(4), NULL ); + } else // name, skin + { BOT_SpawnBot ( NULL, gi.argv(2), gi.argv(3), NULL ); + } } else if( !Q_stricmp (cmd, "editnodes") ) + { AITools_InitEditnodes(); - - else if( !Q_stricmp (cmd, "makenodes") ) + } + else if (!Q_stricmp (cmd, "makenodes")) + { AITools_InitMakenodes(); - - else if( !Q_stricmp (cmd, "savenodes") ) + } + else if (!Q_stricmp (cmd, "savenodes")) + { AITools_SaveNodes(); - - else if( !Q_stricmp (cmd, "addbotroam") ) + } + else if (!Q_stricmp (cmd, "addbotroam")) + { AITools_AddBotRoamNode(); - - else if( !Q_stricmp (cmd, "addmonster") ) - M_default_Spawn (); - + } else + { return false; + } return true; } diff --git a/src/game/g_func.c b/src/game/g_func.c index 1d49d5df..d21e3965 100644 --- a/src/game/g_func.c +++ b/src/game/g_func.c @@ -34,11 +34,6 @@ #define PLAT2_TRIGGER_BOTTOM 16 #define PLAT2_BOX_LIFT 32 -#define STATE_TOP 0 -#define STATE_BOTTOM 1 -#define STATE_UP 2 -#define STATE_DOWN 3 - #define DOOR_START_OPEN 1 #define DOOR_REVERSE 2 #define DOOR_CRUSHER 4 diff --git a/src/game/g_main.c b/src/game/g_main.c index a95044cc..aaafac04 100644 --- a/src/game/g_main.c +++ b/src/game/g_main.c @@ -108,12 +108,6 @@ cvar_t *g_start_items; cvar_t *ai_model_scale; cvar_t *g_game; -cvar_t *bot_showpath; -cvar_t *bot_showcombat; -cvar_t *bot_showsrgoal; -cvar_t *bot_showlrgoal; -cvar_t *bot_debugmonster; - static void G_RunFrame(void); /* =================================================================== */ diff --git a/src/game/g_newai.c b/src/game/g_newai.c index a1abec18..ed882df6 100644 --- a/src/game/g_newai.c +++ b/src/game/g_newai.c @@ -13,11 +13,6 @@ #include "header/local.h" -#define STATE_TOP 0 -#define STATE_BOTTOM 1 -#define STATE_UP 2 -#define STATE_DOWN 3 - #define HINT_ENDPOINT 0x0001 #define MAX_HINT_CHAINS 100 diff --git a/src/game/header/local.h b/src/game/header/local.h index ff0ee768..703f9a49 100644 --- a/src/game/header/local.h +++ b/src/game/header/local.h @@ -1796,6 +1796,16 @@ qboolean Pickup_PowerArmor(edict_t * ent, edict_t * other); qboolean Pickup_Powerup(edict_t * ent, edict_t * other); qboolean Pickup_Sphere(edict_t * ent, edict_t * other); +void CopyToBodyQue(edict_t *ent); +void Use_Plat(edict_t *ent, edict_t *other, edict_t *activator); +void SelectSpawnPoint(edict_t *ent, vec3_t origin, vec3_t angles); + +/* platforms states */ +#define STATE_TOP 0 +#define STATE_BOTTOM 1 +#define STATE_UP 2 +#define STATE_DOWN 3 + /* * Uncomment for check that exported functions declarations are same as in * implementation. (-Wmissing-prototypes )