Birdoggydog's Builds

Making monsters follow the party down pits and through water

A hunter now drops down an open pit after the party and takes the fall. Some monsters swim after you at half speed, and your swimming sounds like swimming.

Monsters in the dungeons follow the party through two more kinds of obstacle. A hunter that sees the party fall through a pit goes to the hole, drops down it, takes the fall damage and keeps hunting on the floor below. Some monster kinds also swim after the party through deep water, and the party’s swimming now has strokes and a splash instead of footsteps. These are the first two items of the dungeon features plan I approved on 20 October.

How does a monster follow the party down a pit?

The party steps on cracked plates in a room on floor 1 and falls to floor 2. A few seconds later the monster that was chasing it comes to the same hole, drops down, and the caption gives the damage it took.

Before this, walkers went around a pit and nothing came after you. Monsters could already follow the party between floors by stairs, ladders, ducts and vents, so I had an agent add the pit to that system instead of building a second one.

That system keeps a list of “ways” between floors. When the party changes floors, it notes which way was nearest and when. A hunter on the old floor walks to that way’s mouth if it fits and gets there within 15 game seconds. Then it goes along the way at that kind of way’s speed and comes out the other end hunting.

An open pit is now one more way, and a pit that hasn’t given way yet is not. A pit is also the only way that goes down and nowhere else. The pit has no mouth on the lower floor, so nothing climbs back up it, and a follower that gives up below can’t use it to go home.

Three details made it more than a list entry.

The first is the arrival distance. A hunter normally counts as at a way’s mouth when it’s within 1.1 m of it. A walker is kept off a pit’s square, though, by its body radius plus a 0.15 m gap, so it can never get that close to the middle of a 3 m pit. For a pit the distance is the lip instead: half the square, plus the body radius, plus the gap, plus 0.3 m.

The second is how the party’s crossing gets noted. A fall is long, and the party can still be high in the drop when the game notices it changed floors. So for a pit the distance to the way is measured across the floor only, ignoring height. Without that the pit isn’t the nearest way and the crossing gets filed under something else.

The third is the fall itself. I had the agent use the climb machinery with a fall speed of 9 m per game second, so the window, the crossing and the hand-over to the floor below work as they do for a ladder. The hunter takes the same damage the party does, 2 per meter of drop, which is 12 for the default 6 m pit. It’s dealt as blunt damage through the monster’s usual damage code, so its resistances count. The combat log says it dropped and landed hard, or landed dead. A monster that dies of the fall leaves its body on the lower floor, and one that lives comes out hunting and provoked, so it doesn’t give up for losing sight of the party on the way.

A monster that was standing on the plates when they gave way just falls with the party, as before. It takes no damage and isn’t provoked, because it’s already on the party’s floor. Flyers don’t follow down a pit, and neither does anything wider than the pit’s square.

The test builds the two-floor dungeon the follow tests already used. It checks that a pit with whole plates is not a way and that an open one is, exactly once. It checks that the way goes down from floor 1 and nowhere from floor 2, that the crossing is noted as the pit’s, and that going back up is never by the pit. A big monster follows and loses no more than the fall’s damage. One that reaches the pit after the 15 seconds stays up. A one-health monster dies of the fall and its body is on floor 2 under the hole.

Why do some monsters swim after the party?

The party swims into the middle of a flooded room. A Slab Warden stops at the water’s edge. A Rind Stalker swims out after the party at half its pace without striking, then follows it out of the water and strikes once it’s out.

Walkers stopped at deep water, flyers crossed it, and nothing swam after the party. The plan I approved had swimming monsters follow the party into deep water.

Which monsters swim is data now. Monster.swims is a flag on the monster, false unless its profile says otherwise. I set it on the Rind Stalker, the Meat Boy and the Meat Beast. Those are placeholders.

There are two places where a walker is kept out of deep water, and both ask the flag. In a dungeon, the check that says a walker can’t enter a deep square is DungeonDeep.lets(). It’s called through the passage-fit code while a monster walks, and also when the dungeon is planned. A new static, LevelQueries.swimmer, is set from the monster’s flag just before the walk check and cleared right after. Plan time never sets it, so a pack that couldn’t reach across deep water when the dungeon was planned still can’t. I decided not to widen that. Outdoors, PartySwim.bars() is the check that stops a monster stepping into water deeper than the party can wade, and it lets a swimmer through.

Afloat, a swimmer’s speed is multiplied by 0.5, the same pace the party swims at, right after its AI has decided where to go. It stays on the bed and doesn’t float, so it has no new look. It also doesn’t fight. Melee, ranged attacks, spells and healing each return false while it’s afloat, and it strikes once it’s out of the water or from the edge, as any walker does. Monsters don’t drown and don’t have a breath meter.

The test puts a Rind Stalker and a Slab Warden on one bank of the flooded-room fixture and rouses both. It records the Stalker’s best dry speed and best afloat speed and checks that their ratio is within 0.03 of 0.5. It checks the Stalker crossed to the shallows on the far side, and that every time it’s afloat and asked to attack, it refuses. The Warden’s furthest point stays short of the water. Then the test puts the Stalker back on dry floor and checks it strikes.

Why does swimming sound like walking?

In a dungeon the party afloat still stands on the floor under the surface. That’s why the footsteps kept playing in the water, and why no stroke or splash was ever heard.

Now the sound code checks whether the party is swimming. Going in plays a splash. Afloat and moving, it plays a stroke every 2.3 m, the same stride as walking, and no footsteps. There are no recorded water sounds yet, and the audio tool is on hold, so both are slices of an existing loop of bubbles, played once at a random offset. A stroke is 0.45 seconds at -12 dB and a splash is 0.9 seconds at -4 dB. A swimming monster makes no sound yet, and recorded sounds for the party’s strokes and splash are on the work list.

I added a play counter to the sound code, a dictionary of how many times each sound has played, so the test can count. It goes in the shallows, then afloat, and checks one splash and no stroke. Then it swims for 4 seconds and checks no footsteps, at least one stroke per stride swum, and still one splash. On dry floor again it checks footsteps and no strokes.

Following by lift, flying monsters following, and pits laid by the generator are not part of this.