[Tutorial]How to make freeroam maps that don't crash servers

TheOysterHippopotami

Active Adventurer
MSS Developer
DarkTide
Sep 6, 2009
1,213
42
31
Example Map
RMF: https://www.dropbox.com/s/bp4na7l0ls208 ... s.rmf?dl=1

BSP: https://www.dropbox.com/s/rqvbcjoctmvcv ... s.bsp?dl=1

One of the problems with freeroam maps is that they have a tendency cause strain on the server. This is because players are not usually forced to kill monsters in a non linear map, so many monsters will likely be active at the same time in many different areas. This stresses the server and can cause lag or, even worse, a crash. However, there are ways to get around this problem.

You will need the following basic entities for this to work:

- several ms_monsterspawn entities
- an equal number of trigger_multiple entities
- an equal number of multisource entities
- an equal number of func_buttons
- at least three multimanagers
- 1 trigger_once


Here is what you do:

1) Take each area of your map with monsters in it, and cover the floor with a trigger_multiple brush which targets an ms_monsterspawn entity. We will call these areas "combat zones". Don't forget to set the "delay before reset" time on your trigger_multiple brushes (we will come back to this later).
2) Create a multisource entity for each combat zone and type the name of that entity in the "Master" property of the trigger_multiple brush. This has the effect of "locking" your combat zone. Monsters wont spawn unless the multisource entity is being triggered.
3) Create a func_button that targets each multisource entity. Give each button a unique name. Don't forget to set the "delay before reset" time (we will come back to this later).
4) Create a multimanager entity that targets each func_button and set it's random property to "1". If you have too many combat zones in your map you may need to make more than one multimanager. In the example map, this entity is named "random_button".
5) Create another multimanager. This multimanager must target the previous multimanager, and a third multimanager that you will create in the next step. Make sure the "random" property of this multimanager is set to "0". In the example map, this entity is named "start".
6) Create one last multimanager. This one has to target the multimanager that you made in step 5, which creates an infinite loop. In the example map, this entity is named "restart".
7) Create a trigger_once brush that targets the multimanager you made in step 5. Monsters will not be able to spawn until a player triggers the "start" multimanager by walking through this brush.
8 ) Finally, you need to make sure any monster gets deleted if it hasn't attacked a player in a long time. Use the addparam set_die_nt;120 for this. This will cause any monster who has no target to die after 120 seconds. However, 120 seconds is just an estimate, and this number should vary based on the size of your map.

It is important to set the timers correctly on all of your entities. This allows you to adjust the number of combat zones that can spawn monsters at a single time. In the example map it is possible for two out of three combat zones to be unlocked at any given time because the "Delay before reset" timer on the trigger_multiple brush is 10 seconds, and the "delay before reset" timer on each of the func_buttons is 20 seconds. Note that it also takes 10 seconds for the "start" multimanager to loop with the "restart" multimanager so you don't spawn monsters twice in the same room if you kill them before the combat zone locks down again.
Also, be aware that every map is different, and you will have to adjust these numbers in your map in a way that makes sense. You don't want monsters to spawn too rapidly or too slowly. You will probably have to do some testing to find the "Goldilocks" zone for your particular map.

...and there you have it. Monsters will now spawn in your map forever, in random locations, without ever flooding the server with too many active monster entities. Players can split up, and run away from as many monsters as they want, and the server will not crash or even lag. This is a great way to make high level, exploration oriented maps. Combined with randomly spawning monsters and events, you can add a lot of replay value. Hopefully this method will be used more often in the future because it opens up a lot of avenues for creative level design.
 

Caluminium

Adventurer
Shadows of Torkalath
Alpha Tester
Feb 16, 2010
491
12
23
England
Re: [Tutorial]How to make freeroam maps that don't crash ser

Using this method I've also found a way to make avg HP scalable respawns.

You will need:

  • 2+ trigger_multiples
  • 2+ ms_monsterspawns
  • 2+ monster entities e.g. msmonster_random

Example:

  • Create 2 trigger_multiples in the same area, modifying the "Req. Avg HP" on them for your HP range of the spawns (one could be 1;499.99 and the other 500; which means one triggers the spawn with under 500 avg HP whereas the other triggers the spawn with 500 avg HP or more)
  • Create 2 ms_monsterspawns with different names (spawn1 & spawn2)
  • For both trigger_multiples, target the ms_monsterspawn depending on which HP range you would like them to spawn within (one trigger_multiple targets spawn1, the other trigger_multiple targets spawn2)
  • Create 2 msmonster_randoms in the same area and then set their spawn area name to their respective ms_monsterspawn (spawn1 & spawn2)
 

Thothie

Administrator
Staff member
Administrator
Moderator
Lead MSC Developer
MSC Developer
Apr 8, 2005
16,225
272
lost
Re: [Tutorial]How to make freeroam maps that don't crash ser

TheOysterHippopotami said:
[Virtual Rube Goldberg Machine]
Gah, there's gotta be an easier way to deal with this crap... I suppose, barring rigging up internally automated systems in the distant future, that's one way to do it - and sadly, the only documented method I can think of. But yeesh.

I congratulate you on finding a solution though - that's some serious engineering logic there.

Caluminium said:
[*]Create 2 ms_monsterspawns with different names (spawn1 & spawn2)
Ah, didn't realize that's how you were going about it - but yeah, you want to avoid having different monster spawners with the same name - bad and unpredictable things will happen - I mean, beyond the usual bad and unpredictable things that happen.


One thing ya'll should be considering more heavily, however, is map flow.

aunt_flow.png

The main that reason Thornlands holds on at all (even if it is really past the limit of what should be acceptable on the map), is its map flow. The fact that it is low level, and thus battles are short, and thus don't have time to create strange stacks in memory, is also a big factor, but the primary factor is still flow.

A lot of the overhead problems crop up when players start fighting well apart from one another, which inevitably prolongs those battles to boot. Thornlands encourages players to remain fairly corralled and able to reach one another without engaging in many additional battles, regardless of where they are on the map relative to one another. The way Thornlands goes about this is fairly clever: The upper half the map acts as a hub, connecting all the other bits of the map where players may congregate in extended battles. Almost none of the mobs on the upper half are agro, so when players are trying to reach one another, it's a fairly simple matter to run across the map, jump down a hole or crawl into a cave, without stopping to battle through a dozen mobs in the process.

So, when designing your map layouts, it helps to envision them as a series of encounters, allowing you to predict choke points, and points players may cross and agitate more monsters, or otherwise start battles apart from the main event, destabilizing the server. From that perspective, Thornlands might look like so:

encounter-flow_thornlands.ai.png

It also helps that there's only one prolonged encounter (the spider boss).

But let's compare that to say, Undercliffs...

encounter-flow_undercliffs.ai.png

Now, this isn't the worst flow design, in terms of optimization, as it's essentially a two way circular gauntlet, and players can only run off in two directions, but it is still fairly troublesome - especially if the players actually do take both paths. As it's a high end map, every battle is prolonged, and it makes it even more tempting to simply run by monsters, all of which are agro, thus "spinning them up".

By "spinning them up" I mean: A monster with no target only "thinks" every 3 seconds, but a monster that has a player targeted, thinks every 0.1 seconds, as any less and their reaction time becomes comical. Monsters don't release targets simply because they are out of sight either - they will keep trying to reach them for quite awhile before they give up and "spin down". Further, a monster that "hears" a player's footsteps, will consider itself to have a target, and walk in the direction of the sound - it doesn't matter if the monster manages to engage the target, and hearing a player will reset the think cool-down. (The exception being if the mob is non-agro and hasn't been attacked - but there are no such exceptions on this map.)

Under this layout, if a player late joins, or dies, he may have to solo a half-dozen high end encounters before reaching the other players for aid, so it's much more tempting to simply spin every monster up by running past them instead - server be damned. Stopping to battle such powerful monsters, with all the damage script stacking involved, isn't easy on the server either. It would be ideal, from a server stability perspective, if the main group of players went back for their fallen comrade, but that isn't likely to happen, as they won't normally want to be going back and forth through this circle, respawning the same battles over and over again, in a never ending pendulum. (Though, on the plus side, if you're trying to get the queen to spawn, this would be a good way to do it - if only that was obvious without inside knowledge.)

Still... Again, it isn't the worst design... This, however, is:

encounter-flow_bad.ai.png

This is, a slight exaggeration - but yeah, this, this is exactly what you want to avoid - a bunch of repeating random encounters that all have to be fought through each time with no way to bypass any of them, save luck, nor any intuitive way to find your fellow players, no logical branching, nor obvious core. A maze like this isn't a problem if things stay dead, mind ye, but in a limitless spawn situation, yeah, this is bad.

Mind ye, this isn't just about optimization. A map that flows well is simply much more of a joy to play, while one that doesn't can seem like endless repetition and grind, regardless of how random the monsters in each encounter are.

I do feel a bit bad about singling Oyster's maps out, but he is the only one ambitious enough to attempt make high level unlimited spawn maps, thus far. This is, technically, illegal - we had a big debate about it ages ago, and came to the conclusion that any map that kept dolling out high-end XP and drops, forever, was a cheat map - which is why there are certain odd caps on some maps, and well, Orc_Arena is what it is. I've kinda pulled back on this, and basically, so long as it isn't rigged up like an XP dispenser, where a player can simply set attack and walk away (like Orc_Arena), then, while I don't advise it, I won't slot it into cheatmap oblivion.

Really, you aren't going to get slapped with a cheat accusation, unless you're really trying to make a cheat map (not that, lots of people, haven't tried to stick cheats in legit maps), but, for this sort of map, optimization is a much bigger hurdle. If your map eats so much resources it locks up whole boxes, it won't be put into a patch nor made available on FN. Primary reason being that if certain RKS boxes get too badly flooded by poorly designed maps - FN itself becomes inaccessible to all the servers world wide. So, keep in mind: we may need to trim fat. (Not that we won't do it for you, but it will delay release, and you might not like our solution.)


[RANT]
Also, unrelated side note. I know msmonster_random is fun and all - but seriously - THINK ABOUT WHAT YOU ARE DOING - rather than just slopping random scripts in. Think about the structure of your encounter, which mobs are going to be ranged, which are going to move in close, based on their placement ("Don't be a fool Anakin - I have the high ground!"). Also try to think about what combination of elements make the battle viable and fun, rather than going all b_castle on us. Think - do not do LOLRANDOM everywhere. I do not want to see, for instance:
- Khaz Cultist
- Dwarven Zombie
- Giant Flying Ant
...All on the same goddamned msmonster_random, copy pasted six times into the same friggen encounter. In addition to being mean on the resource overhead, it makes no gershdern sense. These things don't work together. They don't operate in any strategic form in relation to one another when they are all on the same spawner. If you want to setup three different random encounters, one all ants, one all Khaz cultists, and one all random dwarf zombs - that'd be another thing, but seriously... I've never regretted introducing a useful mapping feature as much as I've regretted this one, as everything I feared has some true in spades.

I know random is the in thing for you youngins these days, but please, consider my blood pressure.
[/RANT]
 

TheOysterHippopotami

Active Adventurer
MSS Developer
DarkTide
Sep 6, 2009
1,213
42
31
Re: [Tutorial]How to make freeroam maps that don't crash ser

Underpath doesn't actually use this system at all, but virtually never crashes or lags. It never has. Rmines used to be a problem... until this system was implemented and now it won't crash or lag, irrespective of it's layout. Same with Fmines, and same with any other map that uses this system correctly.

If you want to setup three different random encounters, one all ants, one all Khaz cultists, and one all random dwarf zombs - that'd be another thing, but seriously... I've never regretted introducing a useful mapping feature as much as I've regretted this one, as everything I feared has some true in spades.
This is laaaaame. You want true variety in your encounters; You don't want players to know when, where or how many foes they will be encountering; You want the map to be different each time you run it. You don't want a small handful of predetermined, predictable encounters ala old school Final Fantasy.

Also, it's not true that those particular monsters "don't work well together". A group of all khaz cultists or all zombie dwarves don't work together at all, and certainly no better than the aforementioned groups you just mentioned.

A group of only ants "works together" by having a ranged fire spitter push you back while a regular ant closes in and melees you. That's it. That is EXACTLY the same thing that happens if you have a fire spitting ant plus dwarf zombies or khaz cultists. The ant pushes you back... and the dwarf or cultist closes in and melees you.

Plenty of thought is put into my spawn pools.
 

Thothie

Administrator
Staff member
Administrator
Moderator
Lead MSC Developer
MSC Developer
Apr 8, 2005
16,225
272
lost
Re: [Tutorial]How to make freeroam maps that don't crash ser

Ya be missing mah point, entirely.

The individual monsters used should be thought out according to the structure of the encounter. They should not be each individually randomized, rather, the nature of the encounter, should be randomized, and thought of as a whole. It adds a lot more variety to game play to a map, when the entire theme of an encounter changes, rather than each of a dozen mobs being one of three random mobs, with no attention paid to what any of the other three mobs maybe, for they are also chosen randomly, and thus no attention *can* be paid. (And when it's elemental randomness, it defeats the purpose of having an elemental system to boot.)

It's especially bad, yes, when you have monsters that have no discernable reason to ally (or just start fighting each other for random luls, due to happening to randomly spawned next to one another, rather than as part of a story device).

I mean, if you have a battle with Khaz cultists going on, and half way through, a bunch of ants burst into the room and start fighting everyone, that's interesting (if a bit rough res wise).

But if you have an ant and a Khaz cultist spawn right next to each other, then it's just silly. Compounding that six times in the same encounter, is both silly, and lazy. Even if you tweak the race settings to allow it, ants, undead, and Khaz cultists aren't natural allies, and it just looks absurd.

And they aren't complementing each other save haphazardly, especially when the Khaz cultist is randomized as well, since they come both in ranged and melee. You could end up with all ranged in a tight room or all melee in a huge empty one. Or all ranged, right in the player's face, and all the melees back along the edges and the ceilings, or a bunch of slow moving zombs that can't close and block the shots and movement of the mobs behind them, who can't get around them... All for shiggles? At that point, why place monsters at all? Just spawn random crap everywhere.

The intent of msmonster_random was to make it easier to add more variety in monsters of the same basic type and function in each encounter. Not to create non-sense encounters where every monster is of a random type and function. (And compound the gay elemental rainbow effect that's plagued this game so long.)


I'm not referring to rmines, mind ye. I mean, there's some of that going on there, but it isn't too bad. I just put "lolrandom" cuz I was too lazy to fill out all the bubbles.


...I'm not touching the rest with a 10 foot pole though, beyond to say, yes, the system does help, some. It doesn't resolve the issue entirely, however, nor does it touch upon the more frustrating aspects of gameplay bad layout generates. Some fundamental redesign in layout would aid these maps in more ways than one, but it's more something to keep in mind with future maps than with past ones - live and learn (or don't, whatevs).
 

TheOysterHippopotami

Active Adventurer
MSS Developer
DarkTide
Sep 6, 2009
1,213
42
31
Re: [Tutorial]How to make freeroam maps that don't crash ser

I mean, if you have a battle with Khaz cultists going on, and half way through, a bunch of ants burst into the room and start fighting everyone, that's interesting (if a bit rough res wise).
This can't happen since encounters can only happen 1x per room before a long cooldown.

But if you have an ant and a Khaz cultist spawn right next to each other, then it's just silly. Compounding that six times in the same encounter, is both silly, and lazy. Even if you tweak the race settings to allow it, ants, undead, and Khaz cultists aren't natural allies, and it just looks absurd.
They actually are natural allies, which is partly why I picked them. They all naturally play nice with "evil race". If ya didn't intend them to be used together, why did you make them all play nicely?
...and I don't think it looks absurd, either. They all look like the type of monster that gets along with other "evil" creatures.
 

Thothie

Administrator
Staff member
Administrator
Moderator
Lead MSC Developer
MSC Developer
Apr 8, 2005
16,225
272
lost
Re: [Tutorial]How to make freeroam maps that don't crash ser

TheOysterHippopotami said:
I mean, if you have a battle with Khaz cultists going on, and half way through, a bunch of ants burst into the room and start fighting everyone, that's interesting (if a bit rough res wise).
This can't happen since encounters can only happen 1x per room before a long cooldown.
You can make it happen. I'm saying it makes more sense and is more interesting than the alternative of just randomly plopping random combinations of them in the same room - both cases being hypothetical.

TheOysterHippopotami said:
But if you have an ant and a Khaz cultist spawn right next to each other, then it's just silly. Compounding that six times in the same encounter, is both silly, and lazy. Even if you tweak the race settings to allow it, ants, undead, and Khaz cultists aren't natural allies, and it just looks absurd.
They actually are natural allies, which is partly why I picked them. They all naturally play nice with "evil race". If ya didn't intend them to be used together, why did you make them all play nicely?
...and I don't think it looks absurd, either. They all look like the type of monster that gets along with other "evil" creatures.
Aren't our current ants race ant_red? In anycase, ants aren't "evil" - they are just ants. Ants hate everything that aren't ants, that's just their nature. Khaz cultists hate everything that aren't cultists, and undead hate everything that's alive (unless it's spooky vermin, cuz, themes). There's only a few factions in the script system, so of course all sorts of things that are clearly not designed to work together, will. I mean you can put a dozen Maldora's Images and Runegahrs in the same room, and, on any map other than Lodagond-4, they'll play together fine (one being demon faction and the other being orc) - that dun mean it makes sense and you should go ahead and do it, just cuz you can, nor that it won't look terrifyingly silly if you do. The scripted factions only provide AI behavior, not thematic logic nor common sense.

I mean, even if ya insist on it (not gonna stop ya if yer just into kinky stuff), there's the random combat role that ignores the roles of everything else in the room in addition to position to consider. I suppose I'm not gonna stop ya being screwy that way either, I'm just begging that one consider the exercise of reason here, rather than just continuous abuse of random for the sake of random, making me further regret adding the function.
 

TheOysterHippopotami

Active Adventurer
MSS Developer
DarkTide
Sep 6, 2009
1,213
42
31
Re: [Tutorial]How to make freeroam maps that don't crash ser

Aren't our current ants race ant_red? In anycase, ants aren't "evil" - they are just ants. Ants hate everything that aren't ants, that's just their nature. Khaz cultists hate everything that aren't cultists, and undead hate everything that's alive (unless it's spooky vermin, cuz, themes).
Well, this may be how it was intended to work, but this is not, in fact, how it works. Undead has always played nice with "evil" race, and ants seem to have no issue with them, either.

I looked back over the map source, though, and these combinations you are talking about aren't even possible. You can't ever get zombie dwarves to spawn at the same time and location as Khaz cultists. Ants + zombie dwarves and khaz cultists + zombie dwarves are impossible combinations in Fyrefall. They wont spawn together. Either pay more attention or, y'know, actually run through the map a few times without spamming cheats before you tell me it's all thoughtless porridge.

Initially, I did want the ants and cultists to be fighting, but when I found out they did not naturally attack each other I left it at that, because I figured you'd flip your shit again if I had lots of monster fights. 0 monster fights were added in to this map, solely and exclusively because I was considering your blood pressure, and now you are telling me you'd rather them be fighting? Well, I can happily do that for you... Pretty sure I'll never be able to produce a map that won't make you complain, though, short of making a traditional linear snore-fest with static monster design. :?
 

Thothie

Administrator
Staff member
Administrator
Moderator
Lead MSC Developer
MSC Developer
Apr 8, 2005
16,225
272
lost
Re: [Tutorial]How to make freeroam maps that don't crash ser

The Infuriator cannot be stopped said:
Well, this may be how it was intended to work, but this is not, in fact, how it works. Undead has always played nice with "evil" race, and ants seem to have no issue with them, either.
>< Scripted races are just functions for the AI. "evil" is just a race that allies with everything that's hostile to players. So yes, evil and undead factioned mobs play together fine, as is intended. But it's just an AI function, it doesn't mean giant insects like ants are literally evil and ally with undead and dragon cultists as a matter of lore or some crap. Use some common sense in monster placement - that's all I'm asking FFS.

And yes, you do want to be careful with mobs fighting each other, as yes, it is rough on the server, but I r saying, if yer going to do it, it's better to have it rigged up in some logical and eventful way, rather than just having them randomly spawned right next to each other due to a dice roll.

Cannot be reasoned with said:
Pretty sure I'll never be able to produce a map that won't make you complain, though, short of making a traditional linear snore-fest with static monster design.
Yes, that's exactly what I'm asking for, and thank you for keeping the crows away from the corn.

*sigh* You're just screwing with me at this point, aren't you?

MS:C community said:
...Like this guy. :p

Actually, in terms of resources, moving to Svencoop might help with some of the issues involved in the original topic, but you still want to pay attention to encounter layout, regardless. Even if resources weren't an issue at all, there's still endless amounts of player frustration to be saved.

Still, seems there must be some simpler way to achieve a global mob cap meantime. I can think of a few different systems to rig up script side, but I can't think of an easier map side solution at the moment. Our trigger brushes are kinda bad at realizing there's X# of players in a certain area and the like.
 

Thothie

Administrator
Staff member
Administrator
Moderator
Lead MSC Developer
MSC Developer
Apr 8, 2005
16,225
272
lost
Re: [Tutorial]How to make freeroam maps that don't crash ser

In regards to this effort, mappers should be aware that we now have a global spawn limiter that can be overridden, on a spawn area by spawn area basis set by the mapper, for bosses, treasures, and such. Coupled with the addparam "set_die_nt;<seconds>" this should have the same effect desired of this mechanism - while being more predictable and entity count friendly.

So if you're a mapper working on populating an "infini spawn" map, give me a heads up so I can send an alpha your way.

We also have a new option for monsters to spawn at random locations within an area, but attempt to do so "out of sight" (behind boxes, or rocks, or some other place where no player can see them). Still need to work up a variant of this that does the same, but randomly around the players, anywhere on the map, favoring the clustered groups.

edit: Now we have that global world spawn option as well, and it's even smart enough to find the tightest cluster of players to spawn near so as to keep the action centralized. Not perfect, but does the job.
 
Top