About Dynamic Lighting
The day-night demo doesn't work if you toggle the mobs light- is this intentional?
I'm trying to make a spooky game where you walk around in caves and have a very limited view distance which is based on lighting, much like the original silent hill games. Would this be possible with your system?
I've tried making the mob non-opaque to solve it, but it still causes the same issue. Is this an intended effect?
loc = owner.loc
proc // this used to be called be an infinite loop that was local to // the light object, but now there is a single infinite loop in // the global lighting object that calls this proc. loop() // if the light is mobile (if it was attached to an atom of // type /atom/movable), check to see if the owner has moved if(mobile) loc = owner.loc // compute the owner's coordinates var/opx = owner.x var/opy = owner.y
Not sure if you're still checking on this thread, but I'm having some problems with the library. Everything works fine, but all objects with opacity are halfway lit, although no light source is nearby. Wat dis be?
shading pixel_x = 0 pixel_y = 0light lum(atom/a) if(!radius) return 0 var/d = (__x - a.x - 0.5) * (__x - a.x - 0.5) + (__y - a.y - 0.5) * (__y - a.y - 0.5) if(d > radius_squared) return 0 return cos(90 * sqrt(d) / radius) * intensity + ambient
+---+---+| | |<--- turfs+---+---+| | |+---+---++---+---+| +---+ |+-| |<--- shadow overlay| +---+ |+---+---+
proc/lum(atom/a) if(!radius) return 0 var/dx = abs(__x - a.x) var/dy = abs(__y - a.y) var/dist if(dx >= dy) dist = (0.934 * dx) + (0.427 * dy) else dist = (0.934 * dy) + (0.427 * dx) // if the turf is outside the radius the light doesn't illuminate it if(dist > radius) return 0 // this creates a circle of light that non-linearly transitions between // the value of the intensity var and zero. return cos(90 * dist / radius) * intensity
for(var/shading/s in changed)
for(var/i=1,i<=changed.len,i++) var/shading/s = changed[i]
You can fix the light-strips by setting the mob.sight |= SEE_PIXELS flag.
Also, Forum_account, you could try using this snippet to eliminate the need for squares to find the hypotenuse of a triangle. It's a quite accurate linear approximation and will work flawlessy for your needs.
> proc/lum(atom/a)> if(!radius) return 0>> var/dx = abs(__x - a.x)> var/dy = abs(__y - a.y)>> var/dist> if(dx >= dy) dist = (0.934 * dx) + (0.427 * dy)> else dist = (0.934 * dy) + (0.427 * dx)>> // if the turf is outside the radius the light doesn't illuminate it> if(dist > radius) return 0>> // this creates a circle of light that non-linearly transitions between> // the value of the intensity var and zero.> return cos(90 * dist / radius) * intensity>>
light Del() off() apply() ..()
effect() //original opacity var/list/L = list() for(var/shading/s in range(radius, src)) if(!isnull(L[s])) continue if(s.x == x && s.y == y) L[s] = lum(s) continue var/dx = (s.x - x) var/dy = (s.y - y) var/d = sqrt(dx * dx + dy * dy) if(d > 0) dx /= d dy /= d var/tx = x + dx + 0.5 var/ty = y + dy + 0.5 for(var/i = 1 to radius) var/turf/t = locate(round(tx), round(ty), z) if(!t) break if(t.opaque) break if(t.shading == s) break if(!L[t.shading]) L[t.shading] = lum(t.shading) tx += dx ty += dy return L