• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.
  • The Hive's 22nd Icon Contest: Creep Abilities is now concluded, time to vote for your favourite set of icons! Click here to vote!
  • ✅ The POLL for Hive's Texturing Contest #34 is OPEN! Vote for the TOP 3 SKINS! 🔗Click here to cast your vote!
  • ✅ The POLL for Hive's Techtree Contest #20 is OPEN! Vote for the TOP 3 FACTIONS! 🔗Click here to cast your vote!

[MATH] Strong at Night, Weak During Day spell

Status
Not open for further replies.
Level 14
Joined
Jul 26, 2008
Messages
1,008
So I want to create a spell that is stronger towards midnight (0.00) and weaker towards day. (12.00)

The problem is, the second before midnight is 23.99, so the GetFloatGameState command in JASS has to be converted into an algorithm that properly creates a zenith at midnight and a nadir at noon.

Does anyone know how to convert these numbers to do this?
 
Would a function like this fit your needs?
attachment.php

The formula is ((cos(time * pi / 12) + 1) / 2) * (max - min) + min
Where
"time" is daytime between 0 and 24.
"min" and "max" are minimum and maximum values the function can yield.
 

Attachments

  • graph.png
    graph.png
    7.9 KB · Views: 273
Last edited:
Just a note here:
When the daytime becomes 00:00> and <12:00 then set a boolean Night to true, when it becomes 12:00> and <23:59 set Night to false.
Your logic here is wrong.
For example 11:00 AM is not exactly night. If anything, he would need to set 6 AM as start of day and 6 PM as start of night (this is the default day/night time in wc3).
 
Just a note here:

Your logic here is wrong.
For example 11:00 AM is not exactly night. If anything, he would need to set 6 AM as start of day and 6 PM as start of night (this is the default day/night time in wc3).

Yes I know, but that can be changed, so when he said he wants the unit get stronger towards 00:00 and weaker towards 12:00, I thought his night begins at 00:00 and day at 12:00 and he wants the unit to become stronger when night begins, but I got what he was sayin' later.
 
As Garfield1337 said, use the sine/cosine functions by converting the time into an angle. Due to the circular nature of angles it can be used to mask the discontinuity with time. You just need to make sure that the full day fits exactly into an integer multiple of a circle (360 degrees or 2pi is a full circle).
 
It works for boosting skills during the day, but I'm not sure how to inverse the algorithm for night. Would I use sin instead of cos?

That equation already represents for both day and night. You will only use a single equation mentioned by Garfield1337 which is a cosine. Using sine will shift the phase by 90 degrees and will not invert. Adding a pi phase offset on the cosine will invert it making the max at 12 and min at 0.
 
Thanks! That's definitely the algorithm I was looking for.

It works for boosting skills during the day, but I'm not sure how to inverse the algorithm for night. Would I use sin instead of cos?

The value will tend towards minimum during night, so there's no need to invert anything.

EDIT: towards maximum*
 
Last edited:
Status
Not open for further replies.
Back
Top