Saving Entity Tricks

Part 1 in an irregular series

Recently on func_msgboard there’s been a discussion on inert entities – in this case entities which are needed for the compilation process but not for the mod being played. In particular the light entity was discussed – does it use up an entity slot on the map?

The answer is no, but I wanted to clarify why, and also to point out how it breaks down for some related entities. Lastly, I wanted to share a few tricks that might be helpful in future for clearing out inert entities. light is explicitly removed by the QuakeC code if it doesn’t have a targetname. This is very helpful, but it is worth noting that the same does not extend to the very similar light_fluoro entity – the humming sound the light produces is static and doesn’t require the entity to stick around, but the QuakeC code doesn’t bother to remove it. In the same vein, all the ambient_... entities can be safely removed once their sounds are initiated, but the QuakeC doesn’t do that, so the entities hang around.

As far as I know, light entities are not stripped out as part of the compile process by any existing utilities. I think I used to be a fan of this idea but I’m not any more. It’s useful to have the light entities around for one purpose – if someone wants to re-run the lighting pass on the map. This might be to test their new compiler which might improve glitches you’ve encountered. It might even be for your own benefit, if you forgot to run -extra 4 first time round and now you’ve completed a lengthy vis on the bsp.

There is an alternative for compile-time-only entities, which leaves them in the bsp file but never loads them in the map. Simply set all four spawnflags: not_in_easy, not_in_medium, not_in_hard and not_in_deathmatch. This works on the engine level, so regardless of the mod that you are running the entities will not be present. This might be a safer way for compilers to “strip out” entities automatically – just have them set the flags for you and the entities are invisible outside the compile process.

You can do this explicitly for new entity classes you create which are compile time only, but what about the light_fluoro? We need that to be loaded by the mod to get the sound effect, we just want to discard it afterwards. The spawnflag trick will eliminate it too soon! Instead, we can employ a bog standard map hack to remove it:
"nextthink" "0.05"
"think" "SUB_Remove"

This does mean that the entity lasts for a single frame. When saving entities, the critical scenario usually occurs later in the map, when lots of projectiles and transitory entities appear. If you have too many inert entities to even load the map, you may have to killtarget them with a “frame 0 trigger” – an entity with classname DelayThink that targets them for removal. This is not the preferred set-up because it’s more fiddly to create – you have to make sure the DelayThink loads after all the things you want to killtarget, but it’s an option if the need is great.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.