[BUGFIX] Stairs, teleportation, and mob disappearing when they shouldn't


Fixes a lot of things related to disappearing mobs, including going upstairs/downstairs.

If you went up/down stairs, the mobs around you would vanish when you come back.
If you load the game, the monsters that loaded around you wouldn’t be stored to the map buffer and would eventually disappear when you went off screen.
If you teleport, the monsters in your current grid aren’t saved to the map buffer, so will disappear when you go back.

The above three issues are fixed.

Also fixes the stair buffer, so mobs can actually use stairs and won’t disappear, and saves it to file so they don’t vanish when they’re using the stairs.
Mobs will also now come out of the stairs they should. Previously they came out of the first stairs found by looping from a random location in the submap… which meant zombies could come out stairs from other houses’ basements instead of the one the player is in.

Plus, improved functionality:

Mobs can block you from using the stairs. You can try to slip past using a dex roll, or push past with a strength roll.
The mobs will still be stored in the stair buffer so they’ll pop out again. Before, the stair buffer was being wiped so they’d get lost in the stairs.

Because stairs are now fixed, the player can potentially block mobs infinitely by standing on the exit.
Now, I’ve allowed zombies to try and push you back. There’s a chance for you to stumble, meaning you won’t be able to simply go back on the stair tile.
This means the zombie will be able to get out, and prevents a potential exploit.

If the zombie can’t push you back for whatever reason (e.g. surrounded by obstacles), he will attack you instead, giving incentive for the player to try to slip past instead, or to unblock the stairs.

Oooooh nice. Thank you.

Have you added the functionality to put furniture on it? When you try dragging something over it, it says that there is something blocking the way. It would be kinda awesome if you could trap zombies in a basement by dragging a bookcase over the stairs. I think that it shouldnt be hard to implement.

That will require a new branch of modifications and a new flag added to furniture, “BLOCKS_STAIRS”.

Then we would check if the obstacle is on the stairs when the mob is coming up.
If it is, the mob will periodically attack the obstacle, making noise, until the obstacle is destroyed.

It would also require a change to the way monsters are stored in the stair buffer.

Currently there is just one buffer, so if the player goes to a new submap with different stairs, those mobs in the stair buffer would be transferred.
Because I’ve only let a max of 7 mobs be in the buffer at any one time, realistically the player can’t move fast enough to change submap before all the zombies have come out.

If we allow blocking, the player would be able to do this, so each mob would need to store a “stair_id”, and we would need to generate a checksum for the stair on the map the zombie is in (based on submap location, stair x and y).

All of that is some significant work.

Here’s another image:

Just showing that full hordes will follow you through too.

Wow, good job! Too bad that it’s hard to implement the furniture blocking stairs thingy, but oh well.

It’s a good idea and it should be implemented at some time, but apparently the z-levels are being reworked so it’ll have to wait until then.

This is exciting! Can’t wait to play this in the 0.9 stable. :slight_smile:

If you want to test it out, you can grab my modified build here: https://github.com/freezerbunny/Freezerbunny-Modified-DDA

It also includes some other fixes which will hopefully get merged to master soon.