Cerez Posted July 11, 2014 Author Share Posted July 11, 2014 Wow, thanks Serenity! I'll have to hit up the JKA source and give this a try. I was planning on compiling OpenJK for Mac OS X anyway. Just to make things crystal clear: which source file do these lines reside in? Link to comment
Stoiss Posted July 11, 2014 Share Posted July 11, 2014 Its from EoC Source code Cerez and Serenity937 like this Link to comment
Serenity937 Posted July 11, 2014 Share Posted July 11, 2014 As for the Bot jumping problem !!!! The best solution is to have a alternate path "BotFallbackNavigation" you can do it all in ai_main.c or get the EoC Source as stoiss correctly pointed out // Fallback Navigation. int BotFallbackNavigation(bot_state_t *bs) { vec3_t b_angle, fwd, trto, mins, maxs; trace_t tr; vec3_t a, ang; if (gWPArray && gWPArray[0]) return 2; if (bs->currentEnemy && bs->frame_Enemy_Vis) { return 2; //we're busy } if (bs->cur_ps.weapon != WP_SABER && bs->currentEnemy && bs->frame_Enemy_Vis) {// If we are looking at enemy and have line of sight, don't move. Stand and shoot. return 2; //we're busy } mins[0] = -15; mins[1] = -15; mins[2] = 0; maxs[0] = 15; maxs[1] = 15; maxs[2] = 32; bs->goalAngles[PITCH] = 0; bs->goalAngles[ROLL] = 0; VectorCopy(bs->goalAngles, b_angle); AngleVectors(b_angle, fwd, NULL, NULL); if (bs->currentEnemy && bs->currentEnemy->health > 0 && bs->currentEnemy->client->ps.fallingToDeath == 0 && bs->frame_Enemy_Vis && bs->currentEnemy->health > 0 && !(bs->currentEnemy->client && bs->currentEnemy->client->ps.weapon == WP_SABER && bs->currentEnemy->client->ps.saberHolstered >= 1)) {// head toward any enimies. VectorCopy(bs->currentEnemy->r.currentOrigin, trto); } else {// No current enemy. Randomize. Fallback code. if (next_point[bs->entitynum] < level.time || VectorDistance(bs->goalPosition, bs->origin) < 64 || !( bs->velocity[0] < 32 && bs->velocity[1] < 32 && bs->velocity[2] < 32 && bs->velocity[0] > -32 && bs->velocity[1] > -32 && bs->velocity[2] > -32 )) {// Ready for a new point. int choice = rand()%4; qboolean found = qfalse; while (found == qfalse) { if (choice == 2) { trto[0] = bs->origin[0] - ((rand()%1000)); trto[1] = bs->origin[1] + ((rand()%1000)); } else if (choice == 3) { trto[0] = bs->origin[0] + ((rand()%1000)); trto[1] = bs->origin[1] - ((rand()%1000)); } else if (choice == 4) { trto[0] = bs->origin[0] - ((rand()%1000)); trto[1] = bs->origin[1] - ((rand()%1000)); } else { trto[0] = bs->origin[0] + ((rand()%1000)); trto[1] = bs->origin[1] + ((rand()%1000)); } trto[2] = bs->origin[2]; if (OrgVisible(bs->origin, trto, -1)) found = qtrue; } next_point[bs->entitynum] = level.time + 2000 + (rand()%5)*1000; } else {// Still moving to the last point. return 1; // All is ok.. Keep moving forward. } } // Set the angles forward for checks. VectorSubtract(trto, bs->origin, a); vectoangles(a, ang); VectorCopy(ang, bs->goalAngles); trap_Trace(&tr, bs->origin, mins, maxs, trto, -1, MASK_SOLID); if (tr.fraction == 1) {// Visible point. if (CheckFall_By_Vectors(bs->origin, ang, &g_entities[bs->entitynum]) == qtrue) {// We would fall. VectorCopy(bs->origin, bs->goalPosition); // Stay still. } else {// Try to walk to "trto" if we won't fall. VectorCopy(trto, bs->goalPosition); // Original. VectorSubtract(bs->goalPosition, bs->origin, a); vectoangles(a, ang); VectorCopy(ang, bs->goalAngles); BotChangeViewAngles(bs, bs->goalAngles[YAW]); } } else { int tries = 0; while (CheckFall_By_Vectors(bs->origin, ang, &g_entities[bs->entitynum]) == qtrue && tries <= bot_thinklevel.integer) {// Keep trying until we get something valid? Too much CPU maybe? bs->goalAngles[YAW] = rand()%360; // Original. BotChangeViewAngles(bs, bs->goalAngles[YAW]); tries++; bs->goalAngles[PITCH] = 0; bs->goalAngles[ROLL] = 0; VectorCopy(bs->goalAngles, b_angle); AngleVectors(b_angle, fwd, NULL, NULL); VectorCopy(b_angle, ang); trto[0] = bs->origin[0] + ((rand()%4)*64); trto[1] = bs->origin[1] + ((rand()%4)*64); trto[2] = bs->origin[2]; VectorCopy(trto, bs->goalPosition); // Move to new goal. } if (tries > bot_thinklevel.integer) {// Ran out of random attempts. We would fall. Stay still instead for now. VectorCopy(bs->origin, bs->goalPosition); // Stay still. } } return 1; // Success! } // End of fallback nav. and connect it in void StandardBotAI(bot_state_t *bs, float thinktime) { here like this //RACC - Touched a waypoint. Do touch stuff and move onto next waypoint. if (bs->frame_Waypoint_Len < wpTouchDist || (g_RMG.integer && bs->frame_Waypoint_Len < wpTouchDist*2)) { WPTouchRoutine(bs); if (!bs->wpDirection) { desiredIndex = bs->wpCurrent->index+1; } else { desiredIndex = bs->wpCurrent->index-1; } if (gWPArray[desiredIndex] && gWPArray[desiredIndex]->inuse && desiredIndex < gWPNum && desiredIndex >= 0 && PassWayCheck(bs, desiredIndex)) { bs->wpCurrent = gWPArray[desiredIndex]; } else { if (bs->wpDestination) { bs->wpDestination = NULL; bs->destinationGrabTime = level.time + 10000; } if (bs->wpDirection) { bs->wpDirection = 0; } else { bs->wpDirection = 1; } } } } else //We can't find a waypoint, going to need a fallback routine. { doingFallback = BotFallbackNavigation(bs); } It wont make them perform miracles on maps without way points but it does make them more bearable. Cerez likes this Link to comment
Raz0r Posted July 11, 2014 Share Posted July 11, 2014 To clarify, we've been able to modify the NPC and bot AI for something like 8 years now. The recent source release did not affect that. Also, I barely read the thread. Link to comment
Cerez Posted August 6, 2014 Author Share Posted August 6, 2014 @@Serenity937, just to say that I've managed to patch my build of OpenJK to remove the jumping behaviour, and the results are fantastic! The bots will now attack and evade, and if there is no path they will either walk on a way of their own choosing, or stop and hide, waiting for an unsuspecting enemy to pass by, and attack by surprise. I've had a great experience duelling Darth Vader where he fell off the normal bot path and I lost sight of him. When I went to the lower level to search, he took me by surprise with a lightsaber throw which I barely managed to block, and then he stood clam in the shadows, waiting ready for my attack. It was just like in the movies! Thanks so much for your help! Futuza and Serenity937 like this Link to comment
Serenity937 Posted August 16, 2014 Share Posted August 16, 2014 @@Serenity937, just to say that I've managed to patch my build of OpenJK to remove the jumping behaviour, and the results are fantastic! The bots will now attack and evade, and if there is no path they will either walk on a way of their own choosing, or stop and hide, waiting for an unsuspecting enemy to pass by, and attack by surprise. I've had a great experience duelling Darth Vader where he fell off the normal bot path and I lost sight of him. When I went to the lower level to search, he took me by surprise with a lightsaber throw which I barely managed to block, and then he stood clam in the shadows, waiting ready for my attack. It was just like in the movies! Thanks so much for your help! Happy to be of service Link to comment
minilogoguy18 Posted August 16, 2014 Share Posted August 16, 2014 I haven't read this whole thread but I can easily put it that no matter how much work you put into AI a computer controlled character will never match the skill of a real, live, breathing person that can be totally unpredictable, especially when backed into a corner. I played JA online near daily for years a while back and the game on the hardest settings could never match real people that were only about 1/4 as good as some of the best players I've played against in a 1v1, no force power (except jump) duel. It taught me that there is no such thing as difficult AI, the only time they can be a challenge is in mods like Survival Mod 2 where you're fighting 5+ npc's using the reborn boss class with 5x or more health. If you've never played in a serious online duel you should try it out, a bit of advice though that new players tend to do, don't use those "kata" attacks, you'll die within the first 5 seconds. Omicron likes this Link to comment
Archangel35757 Posted August 16, 2014 Share Posted August 16, 2014 I haven't read this whole thread but I can easily put it that no matter how much work you put into AI a computer controlled character will never match the skill of a real, live, breathing person that can be totally unpredictable, especially when backed into a corner. I played JA online near daily for years a while back and the game on the hardest settings could never match real people that were only about 1/4 as good as some of the best players I've played against in a 1v1, no force power (except jump) duel. It taught me that there is no such thing as difficult AI, the only time they can be a challenge is in mods like Survival Mod 2 where you're fighting 5+ npc's using the reborn boss class with 5x or more health. If you've never played in a serious online duel you should try it out, a bit of advice though that new players tend to do, don't use those "kata" attacks, you'll die within the first 5 seconds.Some of the best AI enemies I've played against was in Rebellion's Sniper Elite game... try Version 2 of the game on Steam. Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now