// This is just a bit of code to try and give a % (0-1) of the brightness at any point. // It doesn't work that well, but it might be handy to someone // You can do whatever you want with this code, just as long as you credit me at some point // // Jeffrey Lee, 1999 float(vector org) Brightness = { local float bright; // The % brightness local float dist; // The current distance from light local entity e; // The current light // Returns, for the position given, the % brightness (i.e. 1 is full bright) // Only works for lights, light_fluoros, and light_fluorosparks because the others are // made into static entities and so are not in the entity list... // Also the "light" entities are removed if they don't have a target name... // Probably best to remove that bit of code, although it would increase the number of // entities a bit... // Checks the distance first, and whether the light is on (as all these are switchable, // and so not static). // Does not work with different styles! e = find(world,classname,"light"); bright = 0; // Initial value, dark while (e != world) { dist = vlen(org - e.origin); if ((dist < e.light_lev) && (e.spawnflags == 0)) // Does it light us? { traceline(org,e.origin,TRUE,e); if (trace_fraction == 1) { bright = bright + ((e.light_lev - dist) / e.light_lev); // Add on % brightness if (bright >= 1) return 1; // Full brightness } } e = find(e,classname,"light"); } e = find(world,classname,"light_fluoro"); while (e != world) { dist = vlen(org - e.origin); if ((dist < e.light_lev) && (e.spawnflags == 0)) // Does it light us? { traceline(org,e.origin,TRUE,e); if (trace_fraction == 1) { bright = bright + ((e.light_lev - dist) / e.light_lev); if (bright >= 1) return 1; // Full brightness } } e = find(e,classname,"light_fluoro"); } e = find(world,classname,"light_fluorospark"); while (e != world) { dist = vlen(org - e.origin); if ((dist < e.light_lev) && (e.spawnflags == 0)) // Does it light us? { traceline(org,e.origin,TRUE,e); if (trace_fraction == 1) { bright = bright + ((e.light_lev - dist) / e.light_lev); if (bright >= 1) return 1; // Full brightness } } e = find(e,classname,"light_fluorospark"); } return bright; };