Check future full moon
- Ralzar
- Posts: 2211
- Joined: Mon Oct 07, 2019 4:11 pm
- Location: Norway
Check future full moon
Is there some way to have a mod check how long it is until a full moon?
Most of all: is there a way to check if this night will be a full moon?
For my Lousy Lycans mod I am trying to implement a function where you get warned before a full moon happens so you have some time to get your affairs in order. The best I have managed so far is a text warning each evening when one of the moons is at ThreeWax.
Problem with that, is that it will be a ThreeWax until the second it hits midnight. Then it shifts to the next day which is Full.
What I am hoping to do is something like
DaggerfallUnity.Instance.WorldTime.Now
+
12 hours
=
nextNigth
Then pass nextNight through a formula that checks if it will return a Full Moon?
Anyone have any ideas of ways to pull this off?
Most of all: is there a way to check if this night will be a full moon?
For my Lousy Lycans mod I am trying to implement a function where you get warned before a full moon happens so you have some time to get your affairs in order. The best I have managed so far is a text warning each evening when one of the moons is at ThreeWax.
Problem with that, is that it will be a ThreeWax until the second it hits midnight. Then it shifts to the next day which is Full.
What I am hoping to do is something like
DaggerfallUnity.Instance.WorldTime.Now
+
12 hours
=
nextNigth
Then pass nextNight through a formula that checks if it will return a Full Moon?
Anyone have any ideas of ways to pull this off?
- joshcamas
- Posts: 87
- Joined: Mon Sep 21, 2020 7:01 am
Re: Check future full moon
Here's the function that calculates the full moon, found inside DaggerfallDateTime:
It looks like for Masser Full Moon happens every 29th day of the month, and Secunda happens every 33rd day of the month? Which is odd because it also looks like there are 3 days in a month so uh.. not sure how Secunda works.
Also it looks like Daggerfall considers it to be full moon if either Masser or Secunda is in full moon
Code: Select all
private LunarPhases GetLunarPhase(bool isMasser)
{
// Validate
if (Year < 0)
{
Debug.LogError("GetLunarPhase: Year < 0 not supported.");
return LunarPhases.None;
}
// 3 aligns full moon with vanilla DF for Masser, -1 for secunda
int offset = (isMasser) ? 3 : -1;
// Find the lunar phase for current day
int moonRatio = (Day + offset) % 32;
LunarPhases phase = LunarPhases.None;
if (moonRatio == 0)
phase = LunarPhases.Full;
else if (moonRatio == 16)
phase = LunarPhases.New;
else if (moonRatio <= 5)
phase = LunarPhases.ThreeWane;
else if (moonRatio <= 10)
phase = LunarPhases.HalfWane;
else if (moonRatio <= 15)
phase = LunarPhases.OneWane;
else if (moonRatio <= 22)
phase = LunarPhases.OneWax;
else if (moonRatio <= 28)
phase = LunarPhases.HalfWax;
else if (moonRatio <= 31)
phase = LunarPhases.ThreeWax;
return phase;
}
Also it looks like Daggerfall considers it to be full moon if either Masser or Secunda is in full moon
- Ralzar
- Posts: 2211
- Joined: Mon Oct 07, 2019 4:11 pm
- Location: Norway
Re: Check future full moon
Yup, it sucks to be a lycanthrope in Daggerfall. Two full moons per month
Which is also why my mod doesn't tries to just code in the dates. The moon cycles seem a bit too complex for that.
But if I can't figure out some other way to reliably identify the correct dates I might have to go that route.
Which is also why my mod doesn't tries to just code in the dates. The moon cycles seem a bit too complex for that.
But if I can't figure out some other way to reliably identify the correct dates I might have to go that route.
- Hazelnut
- Posts: 3016
- Joined: Sat Aug 26, 2017 2:46 pm
- Contact:
Re: Check future full moon
I would suggest using the same logic in your mod but where you can set the date it calculates for.
See my mod code for examples of how to change various aspects of DFU: https://github.com/ajrb/dfunity-mods
- joshcamas
- Posts: 87
- Joined: Mon Sep 21, 2020 7:01 am
Re: Check future full moon
Ralzar, to calculate the next moon all you need to do is calculate the distance between the current Day and the 29th and 33rd day. The smallest number is the number of days until a full moon
Question, Hazelnut - why does Secunda's full moon happen on the 33rd if there are only 30 days per month? Doesn't the Day value wrap around to 0 after 30?
Question, Hazelnut - why does Secunda's full moon happen on the 33rd if there are only 30 days per month? Doesn't the Day value wrap around to 0 after 30?
- pango
- Posts: 3358
- Joined: Wed Jul 18, 2018 6:14 pm
- Location: France
- Contact:
Re: Check future full moon
From the look of the code, I assume "Day" is some day number (not the day of the month), and the lunar month is 32 days. Calendar month is not involved.
Mastodon: @pango@fosstodon.org
When a measure becomes a target, it ceases to be a good measure.
-- Charles Goodhart
When a measure becomes a target, it ceases to be a good measure.
-- Charles Goodhart
- Hazelnut
- Posts: 3016
- Joined: Sat Aug 26, 2017 2:46 pm
- Contact:
Re: Check future full moon
No idea, this is the first time I've ever seen this code.
See my mod code for examples of how to change various aspects of DFU: https://github.com/ajrb/dfunity-mods
- Ralzar
- Posts: 2211
- Joined: Mon Oct 07, 2019 4:11 pm
- Location: Norway
Re: Check future full moon
I'm working on getting this up and running. However in my testing I noticed soemthing about the phase behaviour that might be a bug?
On the 1st of the month, both moons are at ThreeWane.
Then when it ticks over to 2nd, Secunda becomes Full.
Then on the 3rd they are both ThreeWane again.
Shouldn't Secunda have gone from ThreeWax to Full to ThreeWane? A moon doesn't wane and wane. It waxes and wanes.
On the 1st of the month, both moons are at ThreeWane.
Then when it ticks over to 2nd, Secunda becomes Full.
Then on the 3rd they are both ThreeWane again.
Shouldn't Secunda have gone from ThreeWax to Full to ThreeWane? A moon doesn't wane and wane. It waxes and wanes.
- pango
- Posts: 3358
- Joined: Wed Jul 18, 2018 6:14 pm
- Location: France
- Contact:
Re: Check future full moon
Looking at the whole class, Day is the day of month, so this code is broken.
Mastodon: @pango@fosstodon.org
When a measure becomes a target, it ceases to be a good measure.
-- Charles Goodhart
When a measure becomes a target, it ceases to be a good measure.
-- Charles Goodhart
- Ralzar
- Posts: 2211
- Joined: Mon Oct 07, 2019 4:11 pm
- Location: Norway
Re: Check future full moon
I'm not sure, but another weakness this code has, although that might just be to copy vanilla Daggerfall, is that there's a full moon from midnight until the next midnight.
Which is a bit weird. You don't consider the moon full in the middle of the day. But this leads to werewolfs being forced into beastform for 24 hours
Which is a bit weird. You don't consider the moon full in the middle of the day. But this leads to werewolfs being forced into beastform for 24 hours