Daimonin MMORPG Logo

grommit's blog

User Blog: grommit

 
grommit's picture

LUA function map:SetDarkness()

Since the forum is down, I'm posting these comments here for Smacky to read.

SetDarkness(-1) should reset the darkness to the value originally set for the map (or the ambient value for outdoor maps). I'm not sure what MAX_DARKNESS is, but I'm sure it's not that.

For outdoor maps, a min/max range is needed. If the maximum requested is darker that the ambient value, the new value should be set. Similarly, if the minimum requested is brighter than the ambient value, the new value should be set. In all other cases, the current ambient value should be unchanged. The darkness should follow the ambient setting outside these bounds: e.g. if ambient later becomes darker than the maximum set, the ambient value over-rides.

I haven't worked out the if statement needed for this yet!

0
Your rating: None
 

5 comments

smacky's picture
Core Team
Game Master
 


Perhaps min, max is a bit ambitious. But I can see the use of max, say, in a gloomy forest, where it follows the day/night lighting cycle, but never gets lighter than a certain value.

That's exactly what the gloomy patch is for! :)


I can see a problem at the map boundary, however, where you would see a step change in a straight line along the boundary from gloomy to normal daylight.

Yup. In fact you can smooth this border with static light sources (the old Sh prison maps used to do this -- they were pre-gloomy patch fixed darkness 3, but tiled with normal outdoors maps (so variable lighting) so at most hours of the day there would be a straight line border bettween the tiles which was 'smoothed' over with static light objects.


(And surely you can fix the forum problem? MT is not logged on afaics)

'Fraid not.

1 year 9 weeks ago
 

grommit's picture
Core Team
Game Master
 

Perhaps min, max is a bit ambitious. But I can see the use of max, say, in a gloomy forest, where it follows the day/night lighting cycle, but never gets lighter than a certain value.

I can see a problem at the map boundary, however, where you would see a step change in a straight line along the boundary from gloomy to normal daylight.

(And surely you can fix the forum problem? MT is not logged on afaics)

1 year 9 weeks ago
 

smacky's picture
Core Team
Game Master
 

I think the min/max stuff for outdoors maps is both too complex to be a useful feature (I think it will just scare off most scripters) and not complex enough to actually work.

The variable lighting for outdoors maps changes according to the hour of the day, according to these variables:

int world_darkness = MAX_DARKNESS;

const int season_timechange[5][HOURS_PER_DAY] =
{
{ 0, 0, 0, 0, 0, -1, -1, -1, -2, 0, 0, 0,
0, 0, 0, 0, 0, 0, 2, 1, 1, 1, 0, 0 }, { 0, 0, 0, 0, 0, -1, -1, -1, -2, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 2, 1, 1, 1, 0 }, { 0, 0, 0, 0, 0, -1, -1, -1, -2, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 2, 1, 1, 1, 0 }, { 0, 0, 0, 0, -1, -1, -1, -2, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 2, 1, 1, 1, 0 }, { 0, 0, 0, 0, 0, -1, -1, -1, -2, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 2, 1, 1, 1, 0 }
};

where world_darkness is changed by season_timechange[s][h] (this will be changed a bit when we come to implement the new calendar).

So AFAICS the min/max map-set darkness would also need a local copy of the season_timechange table (with different numbers of course) to make sense, but this seems much too complex (still, I very much like the idea of per-map total control of variable lighting, but I think we need a simpler interface).

Also bear in mind that currently B5 outdoors variable lighting already works differently than B4: http://daimonin.svn.sourceforge.net/viewvc/daimonin?view=rev&revision=3743

EDIT: Read your edit. Clearer, but I think it's still got the same basic problems outlined above.

1 year 9 weeks ago
 

grommit's picture
Core Team
Game Master
 
Think of it this way:

----------|            |------------
         min          max

     ^ ambient < min: map darkness does not go below min

               ^ ambient between min and max: map darkness = ambient value

                            ^ ambient > max: map does not get lighter than max
(I think the proportional font is going to mess this up)
(Edit he he - found the formatting options)
(Yes, I do mean SetDarkness(min, max) - optional second param)
1 year 9 weeks ago
 

smacky's picture
Core Team
Game Master
 

Hm, The reset is a nice idea, but not possible to implement via a core method without adding a new filed to the map header, say orig_darkness.

The thing is there is only one darkness field which is overwritten by SetDarkness. So once it is set to a new value, the old/original value is lost.

Also, -1 already has special meaning. It means MAX_DARKNESS. (But we could just create a game.MAP_DARKNESS_RESET set to whatever number we like to achieve this, for example. So it's NP but the para above is a problem.

But you could do all this in-script with a non-persistent ds:

ds = DataStore("mymap")
ds:SetPersistence(false)
ds:Set("darkness", map.darkness)
ds:WasChanged()
map:SetDarkness(game.MAP_DARKNESS_TOTAL)
...
map:SetDarkness(ds:Get("darkness"))

I need a bacon butty and a cuppa before I can understand your second para. Though by min/max, you mean map:SetDarkness(min, max)?

1 year 9 weeks ago
 

Please register or login to post a comment.

Game events

  • No upcoming events available

User pictures

Grim ReaperBlood Axe Travelers RobeSnake SheildFlame SwordFlame HammerFlame Daggerchat messed up a bitThats me

Status updates

New comments