Skip to content

Player pushed into a machine room by monsters entering the level #783

@brturn

Description

@brturn

Reported by babonk on Discord

The reported issue is the player being pushed into a machine room due to many jellies coming down the stairs. Since the machine room is locked, this ended the run.

ANALYSIS

When monsters enter a level, the function monsterEntersLevel() is called:

static void monsterEntersLevel(creature *monst, short n) {

If another creature is already there, they are pushed into a nearby space:

BrogueCE/src/brogue/Time.c

Lines 1899 to 1904 in 2e0ea9a

// Monsters using the stairs will displace any creatures already located there, to thwart stair-dancing.
creature *prevMonst = monsterAtLoc(monst->loc);
brogueAssert(prevMonst);
prevMonst->loc = getQualifyingPathLocNear(monst->loc, true,
T_DIVIDES_LEVEL & avoidedFlagsForMonster(&(prevMonst->info)), 0,
avoidedFlagsForMonster(&(prevMonst->info)), (HAS_MONSTER | HAS_PLAYER | HAS_STAIRS), false);

The call to getQualifyingPathLocNear() selects a spot based on the provided flags. The forbiddenMapFlags parameter says not to choose a spot with a monster, player, or stairs.

Unfortunately, it does allow spaces that are in machines.

RECOMMENDED FIX

Adjust the forbiddenMapFlags to exclude machine rooms:

(IS_IN_MACHINE | HAS_MONSTER | HAS_PLAYER | HAS_STAIRS)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions