Screenshot:
Spoiler:The idea is simple. Light points are spawned in a sector in visible corners. As the player moves through a sector the nearest and darkest light point is found. If the light level is 128 or less the flashlight snaps on, otherwise it turns off. The flashlight itself is a basic GLDEF light attached and removed from the player. This is nothing fancy but it gets the job done.
GLDEFS:
Code: Select all
pointlight flight1
{
Color 1.0 1.0 1.0
Size 512
Offset 0 36 0
Spot 8 12
dontlightself 1
attenuate 1
}
pointlight flight2
{
Color 1.0 1.0 1.0
Size 256
Offset 0 36 0
Spot 16 32
dontlightself 1
attenuate 1
}
Code: Select all
// find SL_Point based on proximity and orientation
SL_Point findSmartLighter(vector3 v3)
{
ThinkerIterator SL_PointFinder;
SL_PointFinder = ThinkerIterator.Create("SL_Point");
SL_Point idpoint;
SL_Point ptr = null;
int nearest = 1024; // check distance
int darkest = 256;
while (idpoint = SL_Point(SL_PointFinder.Next()))
{
double pl2id = player.mo.Distance2D(idpoint);
int light = getBrightest(idpoint);
if (pl2id < nearest && player.mo.CheckSight(idpoint))
{
if (isfacing(idpoint) && light < darkest)
{
ptr = idpoint;
darkest = light;
nearest = pl2id;
}
}
}
return ptr;
}
Heck I don't think the flashlight looks bad either and does the job.
Update:
Spoiler: