Page 1 of 2

Cave lighting

Posted: 01 Jul 2008, 14:14
by Jaxad0127
This is a continuation of the discussion from EJlol's candle.
Angeliex wrote:Player without candle is on map 1. Player with candle is on map 2.

(snip)

When entering the cave players without candles get send "You hear nothing but darkness..." to cover the map 1 - map 2 chat relation. And players with candles get sent to map 1, they light their candle then go to map 2.
Using multiple maps isn't a good idea. The reasons have been discussed a lot recently (look at the seasons topic in the suggestions forum).

Another idea is that players can benefit from other's candles, as well as there own. Multiple people/parties traveling together could use a single candle. When they meet another player/group that has one, the effect of the two candles combines and the field of view is larger (up to the outdoor limit, with some possible adjustment). This can be combined with fixed torches that are part of the map (and that themselves give off light like candles and player torches).

Re: Cave lighting

Posted: 01 Jul 2008, 18:11
by 5t3v3
I like the idea, I already mentioned in the past that the same should be done for miner's helmet
Also, it be nice that certain places like the snake-filled-mountains-caves or the mines second level which have torches, still do have the darkness over-layer with the exception of near the vicinity of the torches. As I recall it the reply I've gotten in the past, is that the over layer follows the character and thus can't be used for this purpose. Perhaps tmwserv could code two different overlayers, one that follows the player, and one that is dependent on sections of the map?

Re: Cave lighting

Posted: 01 Jul 2008, 18:16
by Shaggy
We'd need an overlay for every char with a lamp, if that's the way to implement it.

Re: Cave lighting

Posted: 01 Jul 2008, 18:21
by Jaxad0127
Using that overlay multiple times isn't a good idea, as it's center is transparent and everything else is opaque. It also doesn't cover the entire map, so you would encounter a hard edge when you got close enough. Another idea is per-tile shading.

Re: Cave lighting

Posted: 01 Jul 2008, 18:59
by Shaggy
Seems a lot better idea.

Re: Cave lighting

Posted: 01 Jul 2008, 20:08
by Crush
per tile shading would look bad because you would exactly see where one tile ends and where another tile starts.

The only solution for dynamic lightning would be to create the overlay image procedurally.

Re: Cave lighting

Posted: 02 Jul 2008, 15:22
by 5t3v3
Shaggy wrote:We'd need an overlay for every char with a lamp, if that's the way to implement it.
Not really you 'd have the classical overlayer system for sandstorms and so on. And for cave lightning you just have one overlayer that isn't client based, but fixed to the map. The overlayer constantly checks the positions of all characters (and NPC or torches, although he needn't do that constantly) and make transparent/opaque accordingly. We could even have the position of lamp snakes count. After all these things are kept track of either way since they are displayed on the mini map, right?

Re: Cave lighting

Posted: 06 Jul 2008, 13:42
by zick
What if every "object" placed on the map (torches, lamp posts, etc.) as well as enemies (like the lampsnake) as well equipment (like miners hat or a lightsaber :D ) has an ambiance mask image (basically a black shape) included in the spriteset that nullifies fogs of war or darkness overlays allowing you to see whats being hidden (hidden is too strong of a word, obscured is better) by that layer. Yes more work for sprite designers but an effective solution.

Re: Cave lighting

Posted: 06 Jul 2008, 17:21
by Jaxad0127
That wouldn't be anymore work for the sprite designers and would just be a client-side effect. I'm also going for a server side effect, where the server only sends you monster positions from lit areas. But it would work for most of the client visualizations.

Re: Cave lighting

Posted: 06 Jul 2008, 17:56
by Crush
The lightning effects could also cause the player to know more than before because he sees the light emitted by some creatures and most players before the being gets into the normal view distance.

But the problem is rather the low-level technical implementation.

A lot of people don't realize that the current cave spotlight overlay doesn't make anything brighter but only the stuff outside of the spotlight darker. Doing the opposite can not be accomplished by normal alpha blitting.

We rather have to take a screen-filling image and selectively reduce the opacity. This means implement a new blitting mode which multiplies the opacity (on a scale between 0.0 and 1.0) of the destination image with the opacity of the source image. This is harder than it sounds because we can't rely on external libraries for low level abstraction and thus run in all kinds of portability problems.

But when we could make it work it could also be used for a lot of other things. Like making the over layer transparent around your character so that you can see it behind obstacles.

Re: Cave lighting

Posted: 07 Jul 2008, 00:32
by Jaxad0127
One possibility is a reverse "opacity" map. Light creates black areas on a white lighting map. Application is just a simple subtraction and negative correction operation applied to the visible area: darker areas on the map remain more opaque (or visible) and lighter areas become more transparent (or darker).

With correct server-side codding, it would give too much away to those using it (only light in the players sight radius is visible).

Re: Cave lighting

Posted: 07 Jul 2008, 05:31
by Jaxad0127
I don't know why I thought that a reverse opacity map was needed. A regular opacity map (with dark being transparent and light being opaque and lights creating circles of white) could be used in the same way. This map could be used without any special coding. Just draw the area behind the game world (solid black), and draw the world with the lighting map as an opacity map.

Re: Cave lighting

Posted: 07 Jul 2008, 05:48
by Lecter
Could use Wesnoth's fog of war, sight stuff, but in wesnoth sight is based to maximum movement, we could add a sight property, or the client would see whole map yet not show it to the player, or we could do like u said with an opacity map/efect over the map, in both case we'll have to check for maphacks.
Sight property would also be good for monsters

Re: Cave lighting

Posted: 07 Jul 2008, 13:34
by Crush
jaxad: The technical problems I mentioned wouldn't be solved by that. The problem is that SDL does not support any opacity maps.

Lecter: Any kind of client-sided hack protection can be hacked itself, no matter how you implement it. Relying on the client to conceal information from the player is careless. I thought about using lightning in a way that the lowest possible light is still enough to see the map features so that people who disable it haven't got any advantages.

Re: Cave lighting

Posted: 07 Jul 2008, 14:26
by Jaxad0127
The only advantage a hacked client would provide is no "fog of war" (which you would get by disabling this in the first place, so no hacking needed). The server would only send information about stuff that should be visible to the player, given the player's sight range and local lighting conditions.