Time

Time flows during the World of Kirbycraft movies and Mary's Magical Adventure. It is hard to describe time, thought of as another dimension.

World of Kirbycraft
During all of the World of Kirbycraft movies, each fight or scene takes place at a random time chosen by Kirby Air Ride when City Trial is loaded.

Mary's Magical Adventure
In Mary's Magical Adventure, there is a time cycle that consistently changes between four times of day, daytime, sunset, night, and sunrise. Most areas are compatible, changing visual things such as light/fog colors, fog distance, and how the sky looks. In some areas, lights turn on and off depending on the time of day. This system, called the "time-of-day system" by Xane, is easy to make any map compatible with and can be turned off by setting the CVAR xane_timecycle to 0. If this is done, every area will be seen at the time of day it's designed for.

Modding
As stated above, making any map compatible with the time-of-day system is easy. First, tag any outdoors sectors with sector tag 183. This will give them the correct colors and fog distance automatically when the time of day changes. The sky is changed even if this isn't done, but the map won't change to match it.

If a sector already has a tag in your selection (indicated in GZDoom Builder/MMA Builder X by the tag being [???] instead of a number), push the "+" button in the sector properties dialog and enter 183 as the tag there. Be warned that it will place 183 as the last tag for every sector, meaning if a sector has a tag of 20, it'll become "20, 183" while untagged sectors become only "183"; This makes it harder to remove the 183 tag as the tags will appear as a list like "[???], ???" when the sectors are selected at the same time.

If any areas under 3D floors aren't affected by the time-of-day system, remember to tag the 3D floor's dummy sector out of bounds too!

Preparing the ACS script
Next, open your level's script file. In GZDoom Builder/MMA Builder X, push. If it doesn't have any ACS scripts yet, wrte #include "zcommon.acs" on the first line. Also, if mma_extra.acs isn't already linked to in your copy of zcommon.acs, add these defines to the top of your script:

These are included in mma_extra.acs and only make it easier to reference the times of day by names. Next, copy this ACS code into your level script. The linked ACS scripts have comments that explain how to use them. If any variables are already used in the level, just remove the duplicates. You can also remove the "SetupLevelVariables" script if your map already has one.

If you want your map to have storm clouds over it, set time_override to 1. This will immediately take effect, so it's recommended to make your script wait until "time_safe" is equal to 1/TRUE before changing it unless it's at the beginning of your map or it is impossible to see the sky at that moment.

Setting up safe areas
If you try playing your map now, you will notice the time of day never changes. This is because the "time_safe" variable isn't set to 1 so it considered "safe" to abruptly transition to the next time of day. To fix this, find any areas of your map that have little to no view of the sky. Add linedefs and give them the action 226:ACS Execute Always. Use the named script "TimeSafeBoundary" and make it only trigger by the player walking over it. Make the linedef's front side (with the small peg) face toward the unsafe area.

Now play the game and step over that linedef then activate noclip and go over it the opposite direction, which avoids setting the time_safe variable to 0, allowing you to see the time of day change. If all is set up correctly, the time of day will change and your map should visually change with each time of day change.

Setting the setting set
The time-of-day system uses a couple arrays for each "set" of settings which determine the light/fog color, fog distance, and sky images used for each time of day and when "storming". You can use any of the settings Xane made by changing the "time_settings" variable to any of these values: If this is changed mid-map, the settings you changed this variable to will immediately take effect, even if the player can see the sky at that moment! To avoid that, add an "until" loop that waits until "time_safe" equals 1/TRUE before changing this variable.

ADVANCED: Custom settings
Although Xane's settings are available, you can make your own set, as complicated as this is.
 * Open TIME_SYS.acs inside MaryMagicalAdventure.pk3.
 * Scroll down to below the world/global variable definitions.
 * You'll see a couple arrays, named things like "sectorcolors0" and "brightness0". Copy a whole set of those variables, such as all of the ones numbered '0' at the end of their variable names.
 * Paste those below the list and change each array's number at the end to a unique number.
 * Tutorial TODSettings2.PNGl down to the bottom of the "ApplyTODSettings" script that you're currently within. You'll see two "cases", one in the 'normal' section and another below it for 'stormy' weather. Copy both cases individually, pasting them below the existing ones.
 * Tediously change every referenced array within those commands to use the number your arrays use, along with the "Case #" line.
 * Compile the script. You may get errors about missing "TIME_NIGHT" and other variables. To fix this, add the "TIME_" defines in the preparing ACS section above to the script or hook mma_extra.acs to your copy of zcommon.acs, which is already done if you're using MMA Builder X.
 * If all of this was done correctly, you can set the time_settings variable to your number and your map will use your settings immediately.