tmewett / BrogueCE

Brogue: Community Edition - a community-lead fork of the much-loved minimalist roguelike game
https://sites.google.com/site/broguegame/
GNU Affero General Public License v3.0
988 stars 107 forks source link

Eels escaped from water somehow. #102

Open tinyrodentprime opened 4 years ago

tinyrodentprime commented 4 years ago

1.9 beta. I didn't do anything to provoke it. Just walking past the doorway I noticed an eel out of the water. Then later noticed another one. stranded eel.zip

tmewett commented 4 years ago

Here's a screenshot of it: https://i.ibb.co/tz2VRd3/Screenshot-6.png

As I mentioned on Reddit, the recent change to water-borne creatures made their movement more restrictive, not less, so I think this could be an unrelated bug, maybe involving the fire traps.

tmewett commented 4 years ago

It's possible eaeb7fd293464017b4e3189864c2e3a02f488b41 is the culprit.

tmewett commented 4 years ago

That commit is not the culprit; koputusx observed this bug in 1.8.1.

zenzombie commented 3 years ago

Here are my debugging efforts so far. Not sure how best to fix this yet.

An eel moves out of the water to location (56,8) on turn 965 of the attached 1.9.1 recording. CE191_Recordingeel.zip

Occurs during an interaction with a monster and a "defender", where the defender's location gets modified:

boolean moveMonster(creature *monst, short dx, short dy)
...
if (monsterAvoids(defender, x, y)) { // don't want a flying monster to swap a non-flying monster into lava!
    getQualifyingPathLocNear(&(defender->xLoc), &(defender->yLoc), x, y, true,
                             forbiddenFlagsForMonster(&(defender->info)), HAS_PLAYER,
                             forbiddenFlagsForMonster(&(defender->info)), (HAS_PLAYER | HAS_MONSTER | HAS_STAIRS), false);

The defender location is passed to, and modified by function getQualifyingPathLocNear which takes parameters for restricting valid locations:

boolean getQualifyingPathLocNear(short *retValX, short *retValY,
                                 short x, short y,
                                 boolean hallwaysAllowed,
                                 unsigned long blockingTerrainFlags,
                                 unsigned long blockingMapFlags,
                                 unsigned long forbiddenTerrainFlags,
                                 unsigned long forbiddenMapFlags,
                                 boolean deterministic) {

However, neither enum tileFlags nor enum terrainFlagCatalog has a flag for "water" so it would seem they can't be used as the sole method for keeping eels restricted to water.

One possible fix is adding a new terrain flag. I think that would require setting it for each tile during dungeon generation, in addition to the monster catalog. Another option is passing the monster to getQualifyingPathLocNearso that additional checks can be done based on a monster's properties.

apgove commented 3 years ago

I'm not positive this is related, but hopefully it's an extra data point while considering a fix. Playing the 2021-04-23 weekend contest [CE 1.9.3], I beckoned a kraken from bog to a dry patch of land adjacent to bog, while standing in bog myself. It was labeled as helpless, but proceeded to seize me and then strike me. While I can fathom a "helpless" waterborne creature will flop itself to adjacent water and recover (which it eventually did), it doesn't smell right that it can attack from dry land.