In DECORATE, you are limited to
A_AttachLightDef.
In the actor's Spawn state, you simply call something like
Code: Select all
A_AttachLightDef("light","Lightprop1Light");
for a light prop. In GLDEFS, you define the dynamic light, like this:
Code: Select all
pointlight Lightprop1Light
{
color 1.0 0.94 0.0
size 192
offset 0 60 0//The offset for the light in map units.
//This is relative to a thing's sprite, not the world, so the Y axis is height and the Z axis is depth. Defaults to 0,0,0.
dontlightself 1
attenuate 1// Attenuated lights illuminate surfaces depending on surface angle — surfaces that are not facing the light will get progressively less illuminated.
}
EDIT: You can also use the
Light("lightname") keyword with an actor frame, which works the same way as A_AttachLightDef, but automatically removes the light after the frame's duration.
If at all possible, do not use this method, because the offsets will only work properly for the z (up-down) axis, meaning that you won't be able to have your lights be offset on the xy axis and turn along with the actor; here, the xy offsets are in world space. To make this more clear: When you set an x offset of 32, the light will always be 32 units to the "East" of the map, no matter which direction the actor is facing.
This means going the ZScript route, which has the added benefit that you can use randomization as much as you like (note that you can of course use the DECORATE method in ZScript as well, but it will have the same limits).
A_AttachLight.
For a muzzleflash light, you call something like
Code: Select all
A_AttachLight
(
"mflight",//Name lightid
DynamicLight.PointLight,//int type
"fff8bd",//Color lightcolor
frandom(56,64),//int radius1
0,//int radius2
DYNAMICLIGHT.LF_ATTENUATE|DYNAMICLIGHT.LF_DONTLIGHTSELF|DYNAMICLIGHT.LF_ATTENUATE|DYNAMICLIGHT.LF_ADDITIVE,//int flags
(16,0,height * 0.6)//Vector3 ofs
);
when the actor fires. With A_AttachLight, no GLDEFS entry is neccessary. Note the randomized radius and offset which will turn with the actor. The x offset is 16 so the light is offset 16 units to the front of the actor, approximately where the muzzle of a rifle would be. This will always be towards the actor's front since it follows the actor's angle.
In both cases (A_AttachLightDef and A_AttachLight), it is neccessary to call
A_RemoveLight when the light should be removed, otherwise it will stay with the actor.
The lightid parameter values can be freely chosen by you. Just remember to use the same for both attaching and removing lights.
So typically, for a monster or weapon, you would call A_AttachLight when firing, and then after about two tics call A_RemoveLight. It it also a good idea to call A_RemoveLight at the start of the Pain and Death states to make sure a light is properly removed when a monster enteres it's Pain state, or killed, between attaching the light and removing it after firing. If a prop can be destroyed so the light should turn off, the same principle applies.
Thanks to Ash for bringing up the possibilities of A_AttachLight