System DayNightEvent

Azlier

Old World Ghost
Reaction score
461
A script that detects when it turns day or night. DNR will be requiring this.

Detects moonstones and other nonsense.

Requires Event.
JASS:
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//  ~~    DayNightEvent   ~~    By Azlier    ~~
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//
//  What is DNE?
//         - DNE allows bugless detection of when day or night falls in WC3.
//
//  Functions:
//         TriggerRegisterDayEvent takes trigger whichTrigger
//           - Registers a trigger to fire whenever daytime begins.
//
//         TriggerRegisterNightEvent takes trigger whichTrigger
//           - Registers a trigger to fire whenenver nighttime begins.
//         
//  Note:
//    The booleans IsDay and IsNight can be used to determine whether it is day or night.
//
//  How to import:
//         - Create a trigger named DNR.
//         - Convert it to custom text and replace the whole trigger text with this.
//         - Save the map, and close it.
//         - Reopen the map and remove the exclamation marks from the start of the two lines below this one.
//!        external ObjectMerger w3u hpea dadt ufoo 0 uabi Avul,Aloc umdl " " usca 0 ushu " " unam "DayDetect" unsf "(DNE Dummy)" util 0 uhpm 5 uhpr 100 uhrt "day"
//!        external ObjectMerger w3u hpea nidt ufoo 0 uabi Avul,Aloc umdl " " usca 0 ushu " " unam "NightDetect" unsf "(DNE Dummy)" util 0 uhpm 5 uhpr 100 uhrt "night"
//         - Save again.
//
//
//      Thanks to Jesus4Lyf for the method on how to detect day/night.
//
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
library DNE initializer Init requires Event

globals
    private constant integer DAY = 'dadt'
    private constant integer NIGHT = 'nidt'
    private Event DayEv
    private Event NightEv
    boolean IsDay = false
    boolean IsNight = false
    private unit DayU
    private unit NightU
    private trigger DayT = CreateTrigger()
    private trigger NightT = CreateTrigger()
endglobals

function TriggerRegisterDayEvent takes trigger t returns nothing
    call DayEv.register(t)
endfunction

function TriggerRegisterNightEvent takes trigger t returns nothing
    call NightEv.register(t)
endfunction

private function FlagDay takes nothing returns boolean
    set IsDay = true
    set IsNight = false
    call DayEv.fire()
    call SetWidgetLife(NightU, 1)
    return false
endfunction

private function FlagNight takes nothing returns boolean
    set IsNight = true
    set IsDay = false
    call NightEv.fire()
    call SetWidgetLife(DayU, 1)
    return false
endfunction

private function Init takes nothing returns nothing
    local trigger t
    
    set DayU = CreateUnit(Player(15), DAY, 0, 0, 270)
    set NightU = CreateUnit(Player(15), NIGHT, 0, 0, 270)
    call PauseUnit(DayU, true)
    call PauseUnit(NightU, true)
    call SetUnitX(DayU, 10000)
    call SetUnitX(NightU, 10000)
    call SetUnitY(DayU, 10000)
    call SetUnitY(NightU, 10000)
    //call ShowUnit(DayU, false)
    //call ShowUnit(NightU, false)
    call SetWidgetLife(DayU, 1)
    call SetWidgetLife(NightU, 1)
    
    set t = CreateTrigger()
    call TriggerRegisterUnitStateEvent(t, DayU, UNIT_STATE_LIFE, GREATER_THAN_OR_EQUAL, 2)
    call TriggerAddCondition(t, function FlagDay)
    
    set t = CreateTrigger()
    call TriggerRegisterUnitStateEvent(t, NightU, UNIT_STATE_LIFE, GREATER_THAN_OR_EQUAL, 2)
    call TriggerAddCondition(t, function FlagNight)
    
    set DayEv = Event.create()
    set NightEv = Event.create()
endfunction

endlibrary
 

Attachments

  • DNE Test Map.w3x
    15.7 KB · Views: 327

Jesus4Lyf

Good Idea™
Reaction score
397
I think I deserve credits in this one. :p

JASS:
//         - Reopen the map and delete the two lines below this one.
//!        external ObjectMerger w3u hpea dadt ufoo 0 uabi Avul,Aloc umdl " " usca 0 ushu " " unam "DayDetect" unsf "(DNE Dummy)" util 0 uhpm 5 uhpr 100 uhrt "day"
//!        external ObjectMerger w3u hpea nidt ufoo 0 uabi Avul,Aloc umdl " " usca 0 ushu " " unam "NightDetect" unsf "(DNE Dummy)" util 0 uhpm 5 uhpr 100 uhrt "night"

Would prefer the ol' "remove exclaimation mark" thing...

But this is pretty awesome, well done.
 

Azlier

Old World Ghost
Reaction score
461
I, for one, forgot that you can do that.
 

Azlier

Old World Ghost
Reaction score
461
They aren't even supposed to have those, this is the DNE test map, not the DNR test map :(.
 

SanKakU

Member
Reaction score
21
lol...i can't think of the last time a series of threads about war3 programming made me chuckle that much...well anyway i'll examine this stuff later on...

it sounds like from this thread's original post that you plan to update DNR...i guess i'll check back later
 

Azlier

Old World Ghost
Reaction score
461
DNR is already updated. It's just that I can't make it not require a holder player.
 

Azlier

Old World Ghost
Reaction score
461
Huh. Why was this graveyarded?
 

Azlier

Old World Ghost
Reaction score
461
Once again, I either find this tossed into the graveyard by an angry script or it never left at all.

Why?
 

Nestharus

o-o
Reaction score
84
tuts/resources submission section has an expiration on resources. If a resource has not received a reply in a set amount of time, it is auto moved to the graveyard.
 

Azlier

Old World Ghost
Reaction score
461
So it must have been an angry script.
 

tooltiperror

Super Moderator
Reaction score
231
1) What if someone sets game time to something past 12:00 or 6:00 or whatever? Then the event is skipped.
2) What if someone uses a moonstone? Game time won't change.
3) What if someone has paused the game time and uses a simulated night? Game time won't change.
 

Jedi

New Member
Reaction score
63
1)That can be countered easily with two booleans Day and Night.But you need to set events "time becomes less-more than or equal to xx, but because of that trigger will run everytime time change, only advantage this system I can see is that(which is not so important for me)

2)Moonstone sets time to 0:00?Game time event should be fired.

3)I don't understand what are you talking about.
 

tooltiperror

Super Moderator
Reaction score
231
>That can be countered easily with two booleans Day and Night.But you need to set events "time becomes less-more than or equal to xx, but because of that trigger will run everytime time change, only advantage this system I can see is that(which is not so important for me)
Okay, so you're now firing an event every game second. In addition to that, you're still not detecting moonstones.

>Moonstone sets time to 0:00?Game time event should be fired.
Moonstone won't change game time, so the event won't fire.

>I don't understand
Then nevermind it, it was random anyways.
 
General chit-chat
Help Users
  • No one is chatting at the moment.
  • Monovertex Monovertex:
    How are you all? :D
    +1
  • Ghan Ghan:
    Howdy
  • Ghan Ghan:
    Still lurking
    +3
  • The Helper The Helper:
    I am great and it is fantastic to see you my friend!
    +1
  • The Helper The Helper:
    If you are new to the site please check out the Recipe and Food Forum https://www.thehelper.net/forums/recipes-and-food.220/
  • Monovertex Monovertex:
    How come you're so into recipes lately? Never saw this much interest in this topic in the old days of TH.net
  • Monovertex Monovertex:
    Hmm, how do I change my signature?
  • tom_mai78101 tom_mai78101:
    Signatures can be edit in your account profile. As for the old stuffs, I'm thinking it's because Blizzard is now under Microsoft, and because of Microsoft Xbox going the way it is, it's dreadful.
  • The Helper The Helper:
    I am not big on the recipes I am just promoting them - I use the site as a practice place promoting stuff
    +2
  • Monovertex Monovertex:
    @tom_mai78101 I must be blind. If I go on my profile I don't see any area to edit the signature; If I go to account details (settings) I don't see any signature area either.
  • The Helper The Helper:
    You can get there if you click the bell icon (alerts) and choose preferences from the bottom, signature will be in the menu on the left there https://www.thehelper.net/account/preferences
  • The Helper The Helper:
    I think I need to split the Sci/Tech news forum into 2 one for Science and one for Tech but I am hating all the moving of posts I would have to do
  • The Helper The Helper:
    What is up Old Mountain Shadow?
  • The Helper The Helper:
    Happy Thursday!
  • Varine Varine:
    Crazy how much 3d printing has come in the last few years. Sad that it's not as easily modifiable though
  • Varine Varine:
    I bought an Ender 3 during the pandemic and tinkered with it all the time. Just bought a Sovol, not as easy. I'm trying to make it use a different nozzle because I have a fuck ton of Volcanos, and they use what is basically a modified volcano that is just a smidge longer, and almost every part on this thing needs to be redone to make it work
  • Varine Varine:
    Luckily I have a 3d printer for that, I guess. But it's ridiculous. The regular volcanos are 21mm, these Sovol versions are about 23.5mm
  • Varine Varine:
    So, 2.5mm longer. But the thing that measures the bed is about 1.5mm above the nozzle, so if I swap it with a volcano then I'm 1mm behind it. So cool, new bracket to swap that, but THEN the fan shroud to direct air at the part is ALSO going to be .5mm to low, and so I need to redo that, but by doing that it is a little bit off where it should be blowing and it's throwing it at the heating block instead of the part, and fuck man
  • Varine Varine:
    I didn't realize they designed this entire thing to NOT be modded. I would have just got a fucking Bambu if I knew that, the whole point was I could fuck with this. And no one else makes shit for Sovol so I have to go through them, and they have... interesting pricing models. So I have a new extruder altogether that I'm taking apart and going to just design a whole new one to use my nozzles. Dumb design.
  • Varine Varine:
    Can't just buy a new heatblock, you need to get a whole hotend - so block, heater cartridge, thermistor, heatbreak, and nozzle. And they put this fucking paste in there so I can't take the thermistor or cartridge out with any ease, that's 30 dollars. Or you can get the whole extrudor with the direct driver AND that heatblock for like 50, but you still can't get any of it to come apart
  • Varine Varine:
    Partsbuilt has individual parts I found but they're expensive. I think I can get bits swapped around and make this work with generic shit though

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top