Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BUGFIX: fix bots not jumping out of water in some cases. #11

Closed
wants to merge 2 commits into from
Closed

BUGFIX: fix bots not jumping out of water in some cases. #11

wants to merge 2 commits into from

Conversation

ghost
Copy link

@ghost ghost commented Apr 29, 2022

In some cases bots will not be able to jump out of water. The reason is that inside the bot movement logic (see 'BotTravel_WaterJump') they are are using EA_MoveUp to get out of the water. Unfortunately the actual setting as a bot user command (actionflags) was missing, hence the bot didn't 'know' to move upwards.

NOTE: all idtech3 games using default botai are suffering from this bug. This bug can also be solved by tweaking the 'BotTravel_WaterJump' function (normally this code resides inside the engine, not game code). Fixing this bug inside the mod code seems more accurate, especially because ACTION_MOVEDOWN was also missing. Adding ACTION_MOVEDOWN can help to also fix bots using the 'Flight' powerup.

@zturtleman
Copy link
Owner

EA_MoveUp() doing nothing is clearly wrong (nice find). Do you have an example of a map water jump is an issue on or how to cause bot to fail to jump out of water?

It's not clear to me if EA_MoveUp() is needed in BotTravel_WaterJump(). (Sorry, I haven't tested this. I'm just guessing/asking from briefly looking at the source code.)

BotTravel_WaterJump() sets ideal_viewangles to face toward end of reachability and adds upward and calls EA_MoveForward() which move in direction of view angles (toward end of reachability and also upward). As far as I can tell, BotFinishTravel_WaterJump() is what is suppose to do the actual jump.

@ghost
Copy link
Author

ghost commented May 4, 2022

Unfortunately, I can't remember which custom maps show this problem. I know there are a few, but these were of such poor quality that I don't think anyone used them anyway.
The good thing is that it's not that difficult to create your own map that shows the problem.
I have added a map where you can easily see the issue. But first a few notes. The attached map was made for a completely different purpose, it is a parcour for bots. The map contains lot of geometry that isn't needed to show this bug, additionally a lot of things are printed on screen, this printed information (target_print) is wrong because the map was made for my own Spearmint fork with completely different player dimensions (Doom3/Q4 player dimensions and physics).
Anyways, I rebuild the specific water jump location to vanilla Q3a (Spearmint) dimensions and the issue occurs (even if the message on screen is wrong).
In other words ignore the things you read on screen.
Okay, here is how to reproduce the issue:

  1. dl the attached zip file and rename it to pk3 (it contains the map file the bsp file and an aas file).
  2. copy the pak file into your Spearmint/baseq3 folder.
  3. Start Spearmint, and type \devmap def_parcours.
  4. Join the spectators and move to your left (the map works like an anthouse. You can observe the bot from the side).
  5. Add any bot you want.
  6. Watch the bot, he will move through water, collecting the plasmagun, then he will move back through the pool to collect the shotgun (again), but this time he will NOT be able to get out of the pool.

Now, apply the PR (to a temporary repository on your HDD, just to compile new vms). Add the patched vms to your existing Spearmint/Mint-Arena installation and start the test map again. Now the bot should be able to get out of the pool to collect the SG.

Well, as I said, you can also fix the bug by forcing the bot to JUMP (if he is onground), this is mainly for other projects where the movement code is in the engine.
Please inform me if the map doesn't work as expected, or if the issue didn't occur.
NOTE: swim reachabilities are computed wrong in many ways, see: zturtleman/spearmint#324.
I compiled the AAS file with the default 2.1h BSPC tool, if you want to compile the attached map/bsp/aas files for yourself, I can't promise that everything works as described.
pak_test_parcours.zip

@zturtleman
Copy link
Owner

Without the patch, the bot just runs in place toward the ledge (doesn't jump out) until it gives up.

With the patch, the bot will sometimes jump out (on first or second jump) but other times it runs back and forth along the ledge jumping until it gives up.

This doesn't seem like a great solution. I tried changing a couple things but I didn't get anywhere.

@zturtleman
Copy link
Owner

In this case, it seems like it should be a barrier jump as shallow water is not swimable. I'm not sure if the problem is water jump movement or that BSPC thinks it's a water jump instead of a barrier jump.

Changing calls in Game VM from Bot[Finish]Travel_WaterJump() to _BarrierJump() fixes getting out to get the shotgun. (It does break getting out of the plasma gun side which is in swimable water depth. Bot gives up eventually.)

So it could definitely be fixed in BSPC by using barrier jump reachability.

@ghost
Copy link
Author

ghost commented May 4, 2022

With the patch, the bot will sometimes jump out (on first or second jump) but other times it runs back and forth along the ledge jumping until it gives up.

That's pretty weird, if patched the bots jumps out of the water without issues, at least for me.
I made a demo of my Spearmint Q3 installation without any modification, except the patch (though I don't know if a demo works in this case).
parcour_toku1.zip
EDIT: yeah in my Q3e fork I fixed this by using EA_Jump if the bot is onground, but I don't like it because of the BSPC issue (zturtleman/spearmint#324.)

@zturtleman
Copy link
Owner

Yeah, your demo works. The bot failing to get out occurred three times but now it doesn't.

After way too much time watching the bot, kicking and reloading map, in my eighth demo I manage to record jumping back and forth but the bot does manage to get out. It at 2 minutes in the demo. It seem to be caused by bot coming at an angle for whatever reason.
parcour_ztm.zip

@ghost
Copy link
Author

ghost commented May 5, 2022

Your demo works as well.
The bug you found at ~ minute 2 is another issue, and as you said, it depends on the angle/distance. This bad behaviour can be seen in nearly any map with water pools (even q3dm12).
I didn't mention this issue because there are many more issues as far as swimming is concerned.

This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant