Relighting Lights
Overview
Contributed by Grayman.
Starting in version 1.06, TDM supports AI relighting lights. A previous version of TDM supported this in a rudimentary way, but interim versions lost that capability.
In general, the human AI in TDM notice when a light that's been on suddenly goes out. They might simply comment on this, or they might try to relight the light. The mapper has control over which lights can be relit, which arouse suspicion when they've gone out, and which can be ignored. This gives the mapper another tool to enhance the atmosphere of their map.
AI Spawnargs
Most lights in TDM can be relit if they go out. However, it's not in the player's interest if every wall torch they douse with a water arrow gets relit a moment later by a passing AI. For the player's benefit, TDM uses AI spawnargs to control relight behavior.
- chanceNoticeLight: Whether an AI responds to a light going out. (from 0.0 to 1.0)
- canLightTorches: Whether an AI can relight doused flames. (1 = yes, 0 = no)
- canOperateSwitchLights: Whether an AI can turn on electric lights that have gone out. (1 = yes, 0 = no)
- chanceLightTorches: The probability that an AI will attempt to relight a doused flame. (from 0.0 to 1.0)
- chanceOperateSwitchLights: The probability that an AI will attempt to turn on an electric light that has gone out. (from 0.0 to 1.0)
The default settings for these spawnargs on human AI are:
chanceNoticeLight 0.9 canLightTorches 1 canOperateSwitchLights 1 chanceLightTorches 0.4 chanceOperateSwitchLights 0.7
Certain AI override these defaults. For example, revenants and zombies couldn't care less when lights go out, so their chanceNoticeLight spawnarg is set to 0.
When you add an AI to your map, override these defaults as needed to change the AI's relight behavior.
Light Spawnargs
Lights use these spawnargs to define how they're treated by the AI:
- shouldBeOn: Controls AI response to a light going out. (0, 1, or 2. See description below.)
- AIUse: Set to AIUSE_LIGHTSOURCE for light sources.
- lightType: Set to AIUSE_LIGHTTYPE_TORCH for flames or AIUSE_LIGHTTYPE_ELECTRIC for electric lights.
The default settings for these spawnargs are:
shouldBeOn 0 AIUse AIUSE_LIGHTSOURCE lightType AIUSE_LIGHTTYPE_TORCH (for flames) lightType AIUSE_LIGHTTYPE_ELECTRIC (for electrics)
shouldBeOn
A light's shouldBeOn spawnarg defines how AI will respond to its going out.
- 0 - Comment that the light has gone out, but don't relight it.
- 1 - Comment that the light has gone out, and try to relight it. If discovered w/in 10 seconds of when it went out, increase suspicion that an intruder might be present.
- 2 - Comment that the light has gone out, and try to relight it. Increase suspicion that an intruder might be present.
shouldBeOn can be set on light holders. For example, a candle is a candleflame bound to a candle model. The candle entity is what you place in your map, and since you can't directly change the shouldBeOn spawnarg on the flame, you need to set it on the candle.
Factors Affecting Relight
Certain factors affect whether a relight will be attempted, and where the AI will stand when relighting.
Light Switches
Some lights, for example the desk lamp, are turned on/off by frobbing them directly. For lights that have a switch, AI will use the switch. If more than one switch can turn a light on/off, AI will use the nearest. Though AI need a direct line of sight to the light to notice that it's out, they don't need a direct line of sight to a switch. The switch can be behind a door, around a corner, or even on a different floor. Wherever it is, if AI can walk to it, they'll use it.
Height of Light
When a light is high off the floor (or ground), AI reach up to perform the relight. For the animation to look as real as possible, don't place relightable lights more than 100 off the floor. AI will not try to relight lights higher than that. The same applies to switches: a switch more than 100 off the floor won't be used.
Relight Position
If you find that relight positions determined by TDM aren't working--perhaps you have a complex light design--you can use a relight_position entity (darkmod/Lights/atdm:relight_position).
Place this at the spot where you want the AI to stand when relighting. One requirement is that its horizontal distance from the light be no more than 68. Link it to the light by adding a target spawnarg on the light, with its value set to the name of the relight_position. You can define multiple relight positions (target1, target2, etc.) and TDM will select the one that's nearest to the AI at relight time.
Unreachable Lights
When a light can't be reached to be turned back on, we don't want patrolling AI to incessantly comment on the light being out. Over time, the number of comments will dwindle, then stop.
The Light Entity
If you construct an electric light using the basic light entity (light) and an electric light model, the AI won't try to relight it if it goes out. This may or may not change in a future rev.
If you want AI to notice that an electric light has gone out, use one of the electric light entities in darkmod/Lights/Switchable/Electric/Flickering/. These entities use both lit and unlit model skins to match the light state, which makes them preferable to roll-your-own electric lights.