When struggling to compile a map under the BSP limits, it can be frustrating to encounter cases where deleting geometry consumes more marksurfaces, or adding brushes causes the number to go down. It makes it hard to optimise, and also suggests that perhaps the compiler is doing something sub-optimal. To understand why this happens, we need to know about another Computer Science idea: the Greedy Algorithm.
So in the last post we had a map hack set-up to create a “gate”, which can be set to open or closed, so that it behaves like a
trigger_relay only when open. This is helpful in itself, but we can do more by combining two or more gates. Today we’ll create AND, OR and IF-ELSE logic gates, and don’t forget to stick around to the end where I post an example .map file with prefabs for all the gates.
The spawn functions of triggers in Quake invariably do two things. One is to set appropriate fields on the trigger to make it function – most importantly giving the trigger the right “touch” function, but often setting other keys that function needs (e.g. trigger_monsterjump setting default values for speed and height of jump). The other thing they do is call the InitTrigger function. This function makes the trigger touchable, invisible and the correct size – all the technical stuff a trigger needs. Read on for how this lets us build a custom trigger…
Most mappers are familiar with the idea of “logic gates”. These are a way to get more complex behaviour out of triggers in maps, allowing you to ask if one event OR another has been fired before activating another event, along with one event AND another, and IF…ELSE constructions. Usually these are created out of spikeshooters, doors and shootable triggers in a box hidden outside the main map. The doors are designed so that the shots from the spikeshooters can hit the triggers only if the right logical conditions are met in the map.
I’m going to describe a variation on this system, with two goals in mind. Click here to read how it works
I think it was the hipnotic expansion pack which added an entity called trigger_damagethreshold. This entity works like a shootable trigger, except that there is a minimum amount of damage which it takes to set it off. While working on a different hack I came up with a way to recreate this entity in stock quake by setting some fields and exploiting things about floats.