Post by GCN on Nov 5, 2007 19:07:30 GMT -5
Step 2: Day and Night System
Coding level [**---]
The Day and Night system is basically just a parallel process that changes the screen tone from time to time, to suggest that it really becomes day and night. Between day and night there is also dawn and dusk. We will insert those transistions between day and night as well.
Now, think of the hours you want it to be dawn, day, dusk and night. Write it down if you need to. Personally, I chose for 0-5 Night, 6-9 Dawn, 10-17 Day, 18-21 Dusk, 22-24 Night. I'll be using these values in this tutorial, but feel free to use other values.
We will be using 'Set Screen Tone'. By changing the amount of red, green, blue and saturation we're able to change the color tone of the screen to our liking. Once the 'Set Screen Tone' is used, it will stick to that color tone until you use the command again. This means that for a day and night system, we only have to change the color tone once at the beginning of a new part of the day (dawn, day, dusk, night). That means (in my case) when HOURS reaches 6 it becomes dawn, when 10 day, when 18 dusk, when 22 night. Also, we want the system to remember when he already changed the screen tone correctly, since he only has to do it once per part of the day.
Open Database, and go to Common Event. Create a new parallel process, called DAY/NIGHT. Mark 'Appearance Condition Switch' on, get a new Switch called DAY/NIGHT and use it as the Condition Switch. In the Parallel Process, insert a wait 10 x0.1 sec.
Get a new variable, called [dn]Current state. This variable will remember what part of the day the screen tone has been set to. I'll be using 0 for dawn, 1 for day, 2 for dusk, 3 for night. So let's start the first transistion, from night to dawn. In this case, Current state is still set to 3, and HOURS has just become 6 (or more). Make a new Fork: Fork [dn]Current state, same as 3. Inside this fork, make another Fork: Fork HOURS, above 6. And inside this fork, place the Set Screen Tone you want to use to make it dawn. I chose Red 120, Green 80, Blue 50, Saturation 80 and the timer setting 30 x0.1 sec (that is 3 sec)to get a slow transistion. After the Set Screen Tone, Change [dn]Current state to 0. Voilá, this is your first transistion.
Now we do this for dawn to day. Copy the Fork 'Current state' and paste below it. Change the new Fork 'Current State' to same as 0. Change the 'HOURS' Fork within it to above 10. Change the Set Screen Tone to whatever you think is fit for day. I used R100, G120, B110, S100 and timer 3 sec. Then, below the Set Screen Tone, change [dn]Current state to 1. And that's your second transistion.
Do this 2 more times, for day to dusk and for dusk to night. I'd suggest the Set Screen tone for dusk the same as dawn and for night R30, G40, B60, S50 and timer 3 sec.
You have now created the parallel process that covers the screen changing during the days. However, this is just the first half of the system. When you enter a building with artifical light, the Screen Tone of course changes to the color of the artifical light. When you get back in the open again, the Screen Tone must be Set back to the corresponding part of the day. This will be the second half of the Day and Night system. We're going to create the common event that changes the Screen Tone to the correct part of the day.
In Database, Common Event, create a new Call Event below DAY/NIGHT, called ^Auto reset (the ^ used as an arrow to emphasize that the event is part of the DAY/NIGHT system). In this event, copy all the Forks 'HOURS' of DAY/NIGHT, in ascending order. So, on top you have Fork 'HOURS above 6', then 'HOURS above 10', 'HOURS above 18', and finally 'HOURS above 22'. Change all the Set Screen Tone timers within the Forks to 0 sec. Then, copy the Fork 'HOURS above 22' and paste it on top of the list, above 'HOURS above 6'. Change the Fork to 'HOURS above 0'. Now, for every part of the day, the Screen Tone reset is covered.
Realize that when this event is run, DAY/NIGHT isn't on yet and is supposed to get on right after this event has set the correct Screen Tone. Go to the bottom of the list. Below Fork 'HOURS above 22', Change Switch DAY/NIGHT to ON. And finally, on the end of the list, put a wait 0 sec.
Congratulations, you have completed your ^Auto Reset event. Now we must put it into practice. This event should be used right after your character has entered the new map, before you can see the map (or else you'll still see the wrong Set Screen Tone).
The following solution is perhaps kind of drastic, but unavoidable if you want the system look good and convincing. Go to the System tab in Database. At Teleport Transistion Setting, change Erase Screen Type to 'Do not erase' and the Show Screen Type to 'Instant Display'.
Go back to Common Event. Create two new Call events, One Called Pre-teleporting and one Post-teleporting. In Pre-teleporting, insert the command 'Erase Screen' and choose the screen transistion to your liking. I used the traditional Fade-Out. In Post-teleporting, insert a Wait 0.1 sec and then the command 'Show Screen', and yet again choose the screen transistion to your liking. I used Fade-In.
The following step is crucial if you're planning to finish this whole tutorial. For every teleport you use, use the Call Event command before the teleport to call Pre-teleporting and after the teleport to call Post-teleporting. This will become the standard teleport map event from now on.
The following is very simple. If you want to enter a building with its own Screen Tone, add to the standard teleport map event the following: After teleport and before Post-teleporting, insert the Set Screen Tone you want inside the building you just entered, and right after that Change Switch DAY/NIGHT to OFF.
You also want a special teleport map event for when you leave the building into the open again. In order to make this, add to a standard teleport map event the following: After Pre-teleporting and before the teleport, Call Event ^Auto reset. That is all.
Congratulations, you have made all components for the Day and Night system. Make sure you'll be consistent with the use of these teleport events from now on.
You can now test your Day and Night system. If you wish to do so, make sure the switch CLOCK is ON, and common call event ^Auto reset is run once.
Coding level [**---]
The Day and Night system is basically just a parallel process that changes the screen tone from time to time, to suggest that it really becomes day and night. Between day and night there is also dawn and dusk. We will insert those transistions between day and night as well.
Now, think of the hours you want it to be dawn, day, dusk and night. Write it down if you need to. Personally, I chose for 0-5 Night, 6-9 Dawn, 10-17 Day, 18-21 Dusk, 22-24 Night. I'll be using these values in this tutorial, but feel free to use other values.
We will be using 'Set Screen Tone'. By changing the amount of red, green, blue and saturation we're able to change the color tone of the screen to our liking. Once the 'Set Screen Tone' is used, it will stick to that color tone until you use the command again. This means that for a day and night system, we only have to change the color tone once at the beginning of a new part of the day (dawn, day, dusk, night). That means (in my case) when HOURS reaches 6 it becomes dawn, when 10 day, when 18 dusk, when 22 night. Also, we want the system to remember when he already changed the screen tone correctly, since he only has to do it once per part of the day.
Open Database, and go to Common Event. Create a new parallel process, called DAY/NIGHT. Mark 'Appearance Condition Switch' on, get a new Switch called DAY/NIGHT and use it as the Condition Switch. In the Parallel Process, insert a wait 10 x0.1 sec.
Get a new variable, called [dn]Current state. This variable will remember what part of the day the screen tone has been set to. I'll be using 0 for dawn, 1 for day, 2 for dusk, 3 for night. So let's start the first transistion, from night to dawn. In this case, Current state is still set to 3, and HOURS has just become 6 (or more). Make a new Fork: Fork [dn]Current state, same as 3. Inside this fork, make another Fork: Fork HOURS, above 6. And inside this fork, place the Set Screen Tone you want to use to make it dawn. I chose Red 120, Green 80, Blue 50, Saturation 80 and the timer setting 30 x0.1 sec (that is 3 sec)to get a slow transistion. After the Set Screen Tone, Change [dn]Current state to 0. Voilá, this is your first transistion.
Now we do this for dawn to day. Copy the Fork 'Current state' and paste below it. Change the new Fork 'Current State' to same as 0. Change the 'HOURS' Fork within it to above 10. Change the Set Screen Tone to whatever you think is fit for day. I used R100, G120, B110, S100 and timer 3 sec. Then, below the Set Screen Tone, change [dn]Current state to 1. And that's your second transistion.
Do this 2 more times, for day to dusk and for dusk to night. I'd suggest the Set Screen tone for dusk the same as dawn and for night R30, G40, B60, S50 and timer 3 sec.
You have now created the parallel process that covers the screen changing during the days. However, this is just the first half of the system. When you enter a building with artifical light, the Screen Tone of course changes to the color of the artifical light. When you get back in the open again, the Screen Tone must be Set back to the corresponding part of the day. This will be the second half of the Day and Night system. We're going to create the common event that changes the Screen Tone to the correct part of the day.
In Database, Common Event, create a new Call Event below DAY/NIGHT, called ^Auto reset (the ^ used as an arrow to emphasize that the event is part of the DAY/NIGHT system). In this event, copy all the Forks 'HOURS' of DAY/NIGHT, in ascending order. So, on top you have Fork 'HOURS above 6', then 'HOURS above 10', 'HOURS above 18', and finally 'HOURS above 22'. Change all the Set Screen Tone timers within the Forks to 0 sec. Then, copy the Fork 'HOURS above 22' and paste it on top of the list, above 'HOURS above 6'. Change the Fork to 'HOURS above 0'. Now, for every part of the day, the Screen Tone reset is covered.
Realize that when this event is run, DAY/NIGHT isn't on yet and is supposed to get on right after this event has set the correct Screen Tone. Go to the bottom of the list. Below Fork 'HOURS above 22', Change Switch DAY/NIGHT to ON. And finally, on the end of the list, put a wait 0 sec.
Congratulations, you have completed your ^Auto Reset event. Now we must put it into practice. This event should be used right after your character has entered the new map, before you can see the map (or else you'll still see the wrong Set Screen Tone).
The following solution is perhaps kind of drastic, but unavoidable if you want the system look good and convincing. Go to the System tab in Database. At Teleport Transistion Setting, change Erase Screen Type to 'Do not erase' and the Show Screen Type to 'Instant Display'.
Go back to Common Event. Create two new Call events, One Called Pre-teleporting and one Post-teleporting. In Pre-teleporting, insert the command 'Erase Screen' and choose the screen transistion to your liking. I used the traditional Fade-Out. In Post-teleporting, insert a Wait 0.1 sec and then the command 'Show Screen', and yet again choose the screen transistion to your liking. I used Fade-In.
The following step is crucial if you're planning to finish this whole tutorial. For every teleport you use, use the Call Event command before the teleport to call Pre-teleporting and after the teleport to call Post-teleporting. This will become the standard teleport map event from now on.
The following is very simple. If you want to enter a building with its own Screen Tone, add to the standard teleport map event the following: After teleport and before Post-teleporting, insert the Set Screen Tone you want inside the building you just entered, and right after that Change Switch DAY/NIGHT to OFF.
You also want a special teleport map event for when you leave the building into the open again. In order to make this, add to a standard teleport map event the following: After Pre-teleporting and before the teleport, Call Event ^Auto reset. That is all.
Congratulations, you have made all components for the Day and Night system. Make sure you'll be consistent with the use of these teleport events from now on.
You can now test your Day and Night system. If you wish to do so, make sure the switch CLOCK is ON, and common call event ^Auto reset is run once.