Source curiosity question thread!

So I’ve been playing. And there’s one thing I really wanna find out. Just how do the spawns work in this game? I’ve been looking around the sources and been wondering where they are and why it works in the way it does, but I’m having trouble pinpointing where it is.

Given how high the spawns can be sometimes I’m wondering how silly things would get if I could somehow pump them upwards.

It’s pretty wacky how it works.
The action happens in spawn_mon() in game.cpp, and is called by either update_map() (when you move to a new sub-tile and turn is greater than nextspawn) or do_turn() (when turn is 100 greater than nextspawn (or 400 if you’re inconspicuous)).

The idea is that it’s simulating you coming upon monster groups as you move around, so it spawns them in the direction you are moving. I really don’t understand the logic behind how many monsters it spawns in a group, it’s a kind of convoluted iterative thing.

The simplest way to make more monsters appear would be to make spawns more frequent by default, which you could do by adjusting the line “nextspawn += rng(group * 4 + z.size() * 4, group * 10 + z.size() * 10);” in spawn_mon().

group is the number of monsters being spawned by the function.
z.size() is the total number of active monsters not counting the new group.
In other words, the next spawn is set to a number of turns in the future between 4 and 10 times the total number of active monsters. So if there are 10 monsters it will be between 40 and 100 turns until the next spawn. The thing that modifies this is noise, sufficiently loud noise decrements nextspawn and makes it happen sooner.

I haven’t taken a look yet because of updates but that sounds like something I should play with in both directions to see what it does.

I guess I got another source code question though. If I make some edits and want to keep them through updates , is there a way I can patch them in without manually punching them in again? I know about diff files but I don’t really know how to make or apply them. Or if this is even the right way to do it.

Which approach is easier depends on you, one option is to make a diff file and reapply it to new versions as they arrive. It’s considered heresy by many to suggest this, but if it’s a really small change, especially in an area of the cod ethat doesn’t change much, it’s the simplest. The other main approach would be to come up to speed with git. git makes merging changes much, much easier, but it has a learning curve of its own.

I wouldn’t mind using a diff myself, since all I really change is a few numbers in player.ccp and weather.ccp. Just I have no idea how to make one or where to start with it