How do monsters join hordes?

Hi!

I love DDA as a survival game but have never been a huge fan of zombies. So I’m experimenting on a handful of different non-zombie apocalypses instead.

The wandering horde mechanic seems perfect for co-opting, especially on canonically-intelligent creatures that should be able to sneak into secure buildings while your back is turned.
I’ve already gotten some useful mechanics out of this forum, but still have one big question about how hordes work:

Apparently static zombies can join a passing horde, possibly causing a small town’s entire zombie population to eventually wander off. What allows them to do this, under the hood? Like, apparently hordes spawn in using the GROUP_ZOMBIE list, but what lets an existing zombie join an existing horde?
I’d guess it’s related to species or faction, but hordes are hard to empirically test.

Does anybody happen to know off the top of their head? Thanks! :slight_smile:

I did not know this off the top of my head, but a bit of code diving later I might have some answers…

There’s a function in monster.cpp that checks if a monster can join a horde or not. This function get’s called by an other function in overmap.cpp. The part of it that you’re probably interested in is this:

!type.species.count( species_ZOMBIE ) || // Only add zombies to hordes.
type.id == mtype_id( "mon_jabberwock" ) || // Jabberwockies are an exception.
this_monster.get_speed() <= 30 || // So are very slow zombies, like crawling zombies.
!this_monster.will_join_horde( INT_MAX ) || // So are zombies who won't join a horde of any size.

The first line defines that anything other than a Zombie will not join a horde, so yes, it’s mainly related to species and some other factors.

1 Like

Whoah, wasn’t expecting anyone to actually code-dive for this, let alone so quickly. Thank you very much for the answers and source links, Valase! You’re a star.

1 Like