diasurgical / devilutionX

Diablo build for modern operating systems
Other
8.09k stars 794 forks source link

[Issue Report]: Possible ai bug with succubi #6693

Open FitzRoyX opened 1 year ago

FitzRoyX commented 1 year ago

Operating System

Windows x64

DevilutionX version

1.5.1

Describe

Usually succubi make an effort to move when an obstacle blocks their projectile, but here it seems content to keep firing at it over and over.

dumbai.zip

https://github.com/diasurgical/devilutionX/assets/57089001/6b116881-68cc-41bc-be74-5e2181c42db4

To Reproduce

load save

Expected Behavior

No response

Additional context

No response

julealgon commented 1 year ago

Fairly well-known vanilla issue. I believe this is caused by the asymmetry in computing line of sight from A to B and B to A, so enemies "think" they should be able to hit you but the calculation for the hit is performed in reverse and the results are different.

StephenCWills commented 1 year ago

I think there is perhaps something a bit off in the AI's judgment regarding the path of their missiles, because sometimes they'll just stand still and stare and other times they'll shoot the wall. However, there's also the discrepancy between line of sight (vision) vs path of missiles (center-of-tile to center-of-tile).

StephenCWills commented 1 year ago

The difference between a Succubus standing and shooting versus standing and staring is the result of a call to the LineClearMissile() function.

https://github.com/diasurgical/devilutionX/blob/7470862b14e137499421c9a6b76a3ba7aa5aac2b/Source/monster.cpp#L1891-L1899

If the monster is firing and hitting an obstruction, it's because LineClearMissile() doesn't agree with what actually happens during missile collision.


The difference between a Succubus holding position versus repositioning to get a better angle has to do with activeForTicks.

Standing: https://github.com/diasurgical/devilutionX/blob/7470862b14e137499421c9a6b76a3ba7aa5aac2b/Source/monster.cpp#L1879

Repositioning: https://github.com/diasurgical/devilutionX/blob/7470862b14e137499421c9a6b76a3ba7aa5aac2b/Source/monster.cpp#L1904

activeForTicks is set to UINT8_MAX on every frame so long as the monster is visible from the player's tile. This means the monster will stand still if the monster is in the player's line of sight. If the monster is not visible, activeForTicks is decremented every frame until it reaches zero after about 12.8 seconds. This means the monster will attempt to reposition to get back in view of the player for about 12.8 seconds before becoming dormant again.

https://github.com/diasurgical/devilutionX/blob/7470862b14e137499421c9a6b76a3ba7aa5aac2b/Source/monster.cpp#L4011-L4016

If the monster is not repositioning but still firing directly at an obstruction, it means the monster is visible around or through the obstruction. It's a discrepancy between vision and missile collision.

D1-Constantine commented 6 months ago

The succubi AI will eventually ''figure out'' that it cannot hit you and will come in melee range if you stay enough. I'm pretty sure there is RNG aspect to it. In any case I don't think monsters being dumb is a bad thing, it's more of a game mechanic in most old games to abuse and exploit monster AI as it is not very complicated

julealgon commented 6 months ago

The succubi AI will eventually ''figure out'' that it cannot hit you and will come in melee range if you stay enough.

I don't think this is always the case. There are many situations (more often than not) that ranged attackers will never change their behavior and will become permanently stuck if you stay in the same positions.

Otherwise I'd agree with the rest of your statement that this would be an interesting mechanic potentially.