… | |
… | |
268 | return 0; |
268 | return 0; |
269 | } |
269 | } |
270 | |
270 | |
271 | /* radius, distance => lightness adjust */ |
271 | /* radius, distance => lightness adjust */ |
272 | static sint8 light_atten[MAX_LIGHT_RADIUS * 2 + 1][MAX_LIGHT_RADIUS * 3 / 2 + 1]; |
272 | static sint8 light_atten[MAX_LIGHT_RADIUS * 2 + 1][MAX_LIGHT_RADIUS * 3 / 2 + 1]; |
|
|
273 | static sint8 vision_atten[MAX_DARKNESS + 1][MAX_DARKNESS * 3 / 2 + 1]; |
273 | |
274 | |
274 | static struct los_init |
275 | static struct los_init |
275 | { |
276 | { |
276 | los_init () |
277 | los_init () |
277 | { |
278 | { |
|
|
279 | /* for lights */ |
278 | for (int radius = -MAX_LIGHT_RADIUS; radius <= MAX_LIGHT_RADIUS; ++radius) |
280 | for (int radius = -MAX_LIGHT_RADIUS; radius <= MAX_LIGHT_RADIUS; ++radius) |
279 | for (int distance = 0; distance <= MAX_LIGHT_RADIUS * 3 / 2; ++distance) |
281 | for (int distance = 0; distance <= MAX_LIGHT_RADIUS * 3 / 2; ++distance) |
280 | { |
282 | { |
281 | // max intensity |
283 | // max intensity |
282 | int intensity = min (LOS_MAX, abs (radius) + 1); |
284 | int intensity = min (LOS_MAX, abs (radius) + 1); |
… | |
… | |
285 | intensity = max (0, lerp_rd (distance, 0, abs (radius) + 1, intensity, 0)); |
287 | intensity = max (0, lerp_rd (distance, 0, abs (radius) + 1, intensity, 0)); |
286 | |
288 | |
287 | light_atten [radius + MAX_LIGHT_RADIUS][distance] = radius < 0 |
289 | light_atten [radius + MAX_LIGHT_RADIUS][distance] = radius < 0 |
288 | ? min (3, intensity) |
290 | ? min (3, intensity) |
289 | : LOS_MAX - intensity; |
291 | : LOS_MAX - intensity; |
|
|
292 | } |
|
|
293 | |
|
|
294 | /* for general vision */ |
|
|
295 | for (int radius = 0; radius <= MAX_DARKNESS; ++radius) |
|
|
296 | for (int distance = 0; distance <= MAX_DARKNESS * 3 / 2; ++distance) |
|
|
297 | { |
|
|
298 | vision_atten [radius][distance] = distance <= radius ? 3 : 4; |
290 | } |
299 | } |
291 | } |
300 | } |
292 | } los_init; |
301 | } los_init; |
293 | |
302 | |
294 | sint8 |
303 | sint8 |
… | |
… | |
399 | apply_light<los_brighten> (op, x - op->x, y - op->y, light, light_atten [light + MAX_LIGHT_RADIUS]); |
408 | apply_light<los_brighten> (op, x - op->x, y - op->y, light, light_atten [light + MAX_LIGHT_RADIUS]); |
400 | } |
409 | } |
401 | |
410 | |
402 | /* grant some vision to the player, based on the darklevel */ |
411 | /* grant some vision to the player, based on the darklevel */ |
403 | { |
412 | { |
404 | int light = clamp (MAX_DARKNESS - darklevel, 0, MAX_LIGHT_RADIUS); |
413 | int light = clamp (MAX_DARKNESS - darklevel, 0, MAX_DARKNESS); |
405 | |
414 | |
406 | apply_light<los_brighten> (op, 0, 0, light, light_atten [light + MAX_LIGHT_RADIUS]); |
415 | apply_light<los_brighten> (op, 0, 0, light, vision_atten [light]); |
407 | } |
416 | } |
408 | } |
417 | } |
409 | |
418 | |
410 | // possibly do 2nd pass for rare negative glow radii |
419 | // possibly do 2nd pass for rare negative glow radii |
411 | // for effect, those are always considered to be stronger than anything else |
420 | // for effect, those are always considered to be stronger than anything else |
… | |
… | |
436 | * really need for any reasonable game play. |
445 | * really need for any reasonable game play. |
437 | */ |
446 | */ |
438 | static void |
447 | static void |
439 | blinded_sight (object *op) |
448 | blinded_sight (object *op) |
440 | { |
449 | { |
441 | op->contr->los[LOS_X0][LOS_Y0] = 3; |
450 | op->contr->los[LOS_X0][LOS_Y0] = 1; |
442 | } |
451 | } |
443 | |
452 | |
444 | /* |
453 | /* |
445 | * update_los() recalculates the array which specifies what is |
454 | * update_los() recalculates the array which specifies what is |
446 | * visible for the given player-object. |
455 | * visible for the given player-object. |