PDA

View Full Version : [Question] Changing lighting tones (day and night)


xdanx
February 3rd, 2012, 06:38 PM
I've been checking about how to change the tones for both, day and night. As far as I've seen, I'd say this is done by editing the first part of the PokemonTime script, where you see this:

module PBDayNight
HourlyTones=[
Tone.new(-142.5,-142.5,-22.5,68),
Tone.new(-135.5,-135.5,-24, 68),
Tone.new(-127.5,-127.5,-25.5,68),
Tone.new(-127.5,-127.5,-25.5,68),
........

Now, if that's the case, what I don't understand is how are exactly this lines ordered. I tried changing some stuff, and as time keeps running, it was quite difficult to find which one to change. So what I want to know is basically 2 things:

1- Is this based on the 24 hours of the day meaning each line represents 1 hour?
If that's the case, I'd like to know how do I identify every time of the day. 'cause I tried changing some values within the same hour and I had to use change them on lines for it to work.

2- How do values work?
As far as I've seen, negative values seem to be related to night time and positive values to day time. Last number doesn't seem to be a tone, but some kind of identification of the time of the day, though I'm not sure about that. So I'd like to know what effect does it have each value.

That, of course, if this is what should be changed to edit light tones.

Maruno
February 4th, 2012, 07:20 AM
The day/night system is a bit fiddly. All the information I'm about to give would be an ideal addition to the wiki, where the Day and night page currently doesn't exist. I may also speak nonsense in the first paragraph, because I'm making it up as I go along.

Adding a tone to something is a way of changing its colour. A tone is given as Tone.new(red,green,blue,grey), where each value is between -255 and 255, and describes how much of that colour to add/subtract from the existing image. For example, Tone.new(255,0,0,0) will make the image as red as possible, but it will still keep the same amount of blue and green in it (so applying this tone to a solid blue will turn it magenta, a mixture of the two).

The day/night system constantly applies tones to the overworld. It starts with the hourly tones, which describe the tone to apply at each hour on that hour, starting at midnight then 1am then 2am and so forth, up to 11pm. These tones are ingeniously defined in the array HourlyTones.

That's just the start of it, though. The first thing the game does is decide what time it is, and this is less obvious than it seems. It looks at the actual time on the clock, then performs calculations to change that time to an "effective" time. This involves looking at the time of year and applying corrections for that - 4:30pm in summer is bright while 4:30pm in winter is dark. Both the month and the date are used here, and the amount of correction applied are defined in the arrays SummerAdjustment, WinterAdjustment, SummerMultiplier and WinterMultiplier.

Once an "effective" time is calculated, the game then uses it to decide which tone to use. For our example, let's say the "effective" time ends up being 6:30pm (i.e. it's now as dark as it would be at 6:30pm, therefore it must be winter). It doesn't just take the nearest hour's tone, though; in our example it would take both the 6pm and 7pm tones, and take a tone between them depending on how far though the hour it currently is. This derived tone is therefore how the screen looks.

The tone can change pretty much every minute (technically it's every "effective" minute, but that's about the same as a real minute), but this change is really tiny (maybe 0.02 for each tone value at most). This allows the tone to change smoothly with time, rather than change abruptly.

Any limitations? Of course. For one, the time adjustments are fixed, where in reality they would depend on the player's latitude (how far north/south they are - it's brighter for longer at the Equator). It also assumes the player is in the Northern Hemisphere, where winter and long nights are in December rather than June. Eagle-eyed viewers will remember a common "latlong" problem old version of Essentials used to have, and this is exactly why said code existed in the first place - it was supposed to read the computer to find out where it was in the world, and then use the latitude in the screen tone calculations so that wherever you were, your game would get brighter and darker when you did. This feature was removed because of the constant error and for a general feeling on my part that it was too complicated for a Pokémon game.

So now you know.

xdanx
February 4th, 2012, 07:43 AM
Amazing post. Now I fully undertand how does it work and why, while the time was passing by, colors were changing too. Thank you very much for the fast and really complete reply!

Maruno
February 4th, 2012, 07:52 AM
While we're on the subject, does anyone have any ideas about options/settings that could be included with the day/night system? Currently there's just "use it or not", but I'm sure there are other possible options too.

charizard124
February 4th, 2012, 08:33 AM
I also needed that thankyou!, you have added a sunny time effect but can you add a sunlight stream at certain time(ex.midday?)

xdanx
February 4th, 2012, 08:53 AM
While we're on the subject, does anyone have any ideas about options/settings that could be included with the day/night system? Currently there's just "use it or not", but I'm sure there are other possible options too.

I guess you could add some sort of moon phases system, making night brighter on full moon and darker on new moon. Though that would only be visible if you play for many nights.

I dunno, it could have some long-term uses, like adding a function to make some pokemon appear more or less depending on that. For example making Clefairy or Lunatone aprear more on full moon, and some dark pokemon to be easier to find under new moon.

zingzags
February 4th, 2012, 10:22 AM
I guess you could add some sort of moon phases system, making night brighter on full moon and darker on new moon. Though that would only be visible if you play for many nights.

I dunno, it could have some long-term uses, like adding a function to make some pokemon appear more or less depending on that. For example making Clefairy or Lunatone aprear more on full moon, and some dark pokemon to be easier to find under new moon.

If I recall correctly there is a lunar positioning. How about shadows and lighting with the day and night system instead of just the player having a shadow how about make an option to give it to all events that you want, but they need to have a certain something included in there name for example, Professor, and you want to give him a shadow to something like Professor_Shadow for dependent events as well, and instead of having the that old ugly one, I like the circle under the event a lot better, and the lighting, the light source instead of making shadows dependent on a light source, how about make it so the opacity of the shadow looks different depending on the day, Like in the morning its 50-70%, and in night it could be almost 10%.

FL
February 4th, 2012, 11:55 AM
While we're on the subject, does anyone have any ideas about options/settings that could be included with the day/night system? Currently there's just "use it or not", but I'm sure there are other possible options too.Maybe to reduce the number of tones at HourlyTones, to have less like GSC.

A sugestion that I like a lot and has even thinking on make a game with this, but probably never get implemented on essentials is to counting the time in a way like Zelda: Ocarina of Time. Maybe a minute or two of actual play may be equivalent an hour.
For me this make a lot more sense that keeping changing the computer time to take advantage of game.
Maybe you can implement even a feature that pauses the game when the player stop touching at game in more that one minute.

Maruno
February 4th, 2012, 01:35 PM
I also needed that thankyou!, you have added a sunny time effect but can you add a sunlight stream at certain time(ex.midday?)
I only might be able to do something like that with my skills, but I'm unlikely to. The same goes for fixing it so that it looks better at night.


I guess you could add some sort of moon phases system, making night brighter on full moon and darker on new moon. Though that would only be visible if you play for many nights.

I dunno, it could have some long-term uses, like adding a function to make some pokemon appear more or less depending on that. For example making Clefairy or Lunatone aprear more on full moon, and some dark pokemon to be easier to find under new moon.
Not essential, won't be widely used, fiddly, not in the official games, no.


If I recall correctly there is a lunar positioning. How about shadows and lighting with the day and night system instead of just the player having a shadow how about make an option to give it to all events that you want, but they need to have a certain something included in there name for example, Professor, and you want to give him a shadow to something like Professor_Shadow for dependent events as well, and instead of having the that old ugly one, I like the circle under the event a lot better, and the lighting, the light source instead of making shadows dependent on a light source, how about make it so the opacity of the shadow looks different depending on the day, Like in the morning its 50-70%, and in night it could be almost 10%.
From all that I got: "improve the shadows". I'd like to, but I don't know how to display them (tweaking their opacity/size is child's play in comparison). When you figure out how (preferably by just drawing an oval beneath the sprite rather than adding in shadow sprites), let me know.


Maybe to reduce the number of tones at HourlyTones, to have less like GSC.

A sugestion that I like a lot and has even thinking on make a game with this, but probably never get implemented on essentials is to counting the time in a way like Zelda: Ocarina of Time. Maybe a minute or two of actual play may be equivalent an hour.
For me this make a lot more sense that keeping changing the computer time to take advantage of game.
Maybe you can implement even a feature that pauses the game when the player stop touching at game in more that one minute.
These are the kind of suggestions I was hoping for. Simplify the tones to have more distinct times of day, make day/night depend on play time rather than real world time, I like them both. Perhaps also being able to define a game day as X hours of real-world time (default 24).

I don't know how the game would be considered "paused", though, except in that play time doesn't increase. I can't really think how inactivity would be detected either.

FL
February 4th, 2012, 02:55 PM
I don't know how the game would be considered "paused", though, except in that play time doesn't increase. I can't really think how inactivity would be detected either.When the player use the directional you can picks the frame rate on certain variable, if this variable had a certain amount diference in frame (like 2400), only consider 2400.
Instead of directional you can use the steps counter, maybe even you can consider the cursor moviment.

FL
March 4th, 2012, 05:44 AM
New ideas: Maybe a clock when you open the menu and events that can make the time jump (like a bed that can make you go 12 hours in time, but you cannot use it again for even 12 hours).