From ZDoom Wiki
Jump to navigation Jump to search


native bool A_AttachLight(Name lightid, int type, Color lightcolor, int radius1, int radius2, int flags = 0, Vector3 ofs = (0,0,0), double param = 0, double spoti = 10, double spoto = 25, double spotp = 0)

Note: this function is not fully supported by DECORATE. If used from DECORATE, all parameters starting from ofs should be omitted. Consider switching to ZScript to fully utilize this function.


Creates and attaches a dynamic light to the calling actor.

Can be removed with A_RemoveLight.


  • Name lightid
An identifier for the light. Can be any name. If a new light is created with the same id, it'll replace the old one.
  • int type
The type of the light, which can be one of the following:
  • DynamicLight.PointLight - PointLight. Default setting.
  • DynamicLight.PulseLight - PointLightPulse.
  • DynamicLight.FlickerLight - PointLightFlicker.
  • DynamicLight.RandomFlickerLight - PointLightFlickerRandom.
  • DynamicLight.SectorLight - SectorPointLight.
  • DynamicLight.DummyLight - (Need more info)
  • DynamicLight.ColorPulseLight - (Need more info)
  • DynamicLight.ColorFlickerLight - (Need more info)
  • DynamicLight.RandomColorFlickerLight - (Need more info)
  • Color lightcolor
The color of the light. This can be a color variable or a string name (such as "Red").
  • int radius1
The primary radius of the light.
  • int radius2
The secondary radius of the light, primarily used for lights that flicker or pulse.
  • int flags
Flags that determine the behavior of the light. Multiple flags can be combined with |:
  • DYNAMICLIGHT.LF_SUBTRACTIVE - Light becomes subtractive (darkening effect).
  • DYNAMICLIGHT.LF_ADDITIVE - Light becomes additive, making the colors whiter.
  • DYNAMICLIGHT.LF_DONTLIGHTSELF - Actor does not light itself.
  • DYNAMICLIGHT.LF_ATTENUATE - Light uses the angle attenuation formula, providing more realistic (if slightly dimmer) illumination on angled surfaces.
  • DYNAMICLIGHT.LF_NOSHADOWMAP - Light will not create shadow maps, which are realistic shadows created from map geometry obscuring other surfaces.
  • DYNAMICLIGHT.LF_DONTLIGHTACTORS - Light will not affect other actors.
  • DYNAMICLIGHT.LF_SPOT - Light is a spot light. Spot lights are in cones like a lamp, or a flash light.
  • DYNAMICLIGHT.LF_DONTLIGHTOTHERS - The light will not light other actors, only the actor that it is attached to.
  • DYNAMICLIGHT.LF_DONTLIGHTMAP - The light will not light up the level geometry, only actors.
  • Vector3 ofs
The offset of the light as a vector. Default is (0, 0, 0).
  • double param
If the light is a pulse light, this represents the interval to switch between the two radii in seconds. Otherwise, it is used for flicker lights (between 0 and 1) to represent the chance to be the first radius or the second. Default is 0.
  • double spoti
Sets the inner angle of a spot light. Ignored if not a spot light. Default is 10.
  • double spoto
Sets the outer angle of a spot light. Default is 25.
  • double spotp
Sets the pitch of the spot light. Default is 0. If set to > 90 or < -90, the light will use the pitch of the actor instead.

Return value

Returns true when the dynamic light has been spawned. Currently, there are no situations where false can be returned.


Nuvolachalk.png Note: This article lists no examples. If you make use of this feature in your own project(s) or know of any basic examples that could be shared, please add them. This will make it easier to understand for future authors seeking assistance. Your contributions are greatly appreciated.

See also