Snippet DayNightRequirements

Azlier

Old World Ghost
Reaction score
461
This little script lets you easily create abilities that only work at day or at night.

Just follow the unusually complicated import instructions, and you're good to go. Simply adding a dummy to an ability's techtree requirements will make it day or night specific.

Requires DNE.
JASS:
library DNR initializer Init requires DNE
globals
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//  ~~    DayNightRequirements   ~~    By Azlier    ~~
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//
//  What is DNR?
//         - DNR allows the quick and easy creation of abilites that only work at day or night.
//
//  How to use:
//         - For each ability that requires day or night, add the respective dummy
//           created by the system in the ability's techtree requirements.
//
//  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 dayd ufoo 0 uabi Avul,Aloc umdl " " usca 0 ushu " " unam "Daytime" unsf "(DNR Dummy)" util 0
//!        external ObjectMerger w3u hpea nitd ufoo 0 uabi Avul,Aloc umdl " " usca 0 ushu " " unam "Nighttime" unsf "(DNR Dummy)" util 0
//         - Save again.
//
//
//  Configuration:
    private constant boolean STARTS_DURING_DAY = true
//  If your map starts at night, set this to false. Otherwise, do not touch.
    private constant player HOLDER = Player(15)
//  Substitute a player that will not need to have day/night specific abilities.
//
//
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

    private unit array DayU //Rhymes.
    private unit array NightU //Does not.
    private constant integer DAY = 'dayd'
    private constant integer NIGHT = 'nitd'
    private player Holder = HOLDER
endglobals

private function Day takes nothing returns boolean
    local integer i = 11
    loop
        call SetUnitOwner(DayU<i>, Player(i), false)
        call SetUnitOwner(NightU<i>, Holder, false)
        exitwhen i == 0
        set i = i - 1
    endloop
    return false
endfunction

private function Night takes nothing returns boolean
    local integer i = 11
    loop
        call SetUnitOwner(DayU<i>, Holder, false)
        call SetUnitOwner(NightU<i>, Player(i), false)
        exitwhen i == 0
        set i = i - 1
    endloop
    return false
endfunction

private function Init takes nothing returns nothing
    local integer i = 11
    local trigger t = CreateTrigger()
    
    loop
        set DayU<i> = CreateUnit(Holder, DAY, 0, 0, 270)
        set NightU<i> = CreateUnit(Holder, NIGHT, 0, 0, 270)
        call PauseUnit(DayU<i>, true)
        call PauseUnit(NightU<i>, true)
        call SetUnitX(DayU<i>, 10000)
        call SetUnitY(DayU<i>, 10000)
        call SetUnitX(NightU<i>, 10000)
        call SetUnitY(NightU<i>, 10000)
        static if STARTS_DURING_DAY then
            call SetUnitOwner(DayU<i>, Player(i), false)
        else
            call SetUnitOwner(NightU<i>, Player(i), false)
        endif
        exitwhen i == 0
        set i = i - 1
    endloop
    
    call TriggerRegisterDayEvent(t)
    call TriggerAddCondition(t, function Day)
    //Did you know that Jasshelper allows this? Handy.
    
    set t = CreateTrigger()
    call TriggerRegisterNightEvent(t)
    call TriggerAddCondition(t, function Night)
endfunction

endlibrary</i></i></i></i></i></i></i></i></i></i></i></i></i></i>


The demo map will turn the clock to night when "-night" is typed, and I wonder what "-day" could possibly do...
 

Attachments

  • DNR Test Map.w3x
    18.3 KB · Views: 279

Azlier

Old World Ghost
Reaction score
461
>lol
What's so funny?

Shadowmeld only works at night, yes. What does that have to do with anything?
 

Azlier

Old World Ghost
Reaction score
461
Ah, so that's what you're saying. There's really no way other than making it a configurable, which I can do.

One player HAS to have the units.
 

Azlier

Old World Ghost
Reaction score
461
>Or morph them into eachother when day/night ticks.

Almost perfect. Now if only that was instant, and does that work outside the map bounds?

>if (GetTimeOfDay() >= DAWN_TIME and GetTimeOfDay < NIGHT_TIME) then

That won't guarantee it'll work. Sadly.

Odds are that this library will run before anything that sets the time.

>p = ?

Fail on my part.

Performing fix's.
 

Azlier

Old World Ghost
Reaction score
461
>Use a 0 sec timer. C'mon, Azlier.

And what happens if THEY use a 0 second timer? :p
 

quraji

zap
Reaction score
144
I tried to test it and GetTimeOfDay() returns 0.000
Incidentally, this is also the time my map starts at...

How do you set the time a map starts at :p
(without using the function, of course)
 

SanKakU

Member
Reaction score
21
this is very cool, but uhm...are you going to add spells that can be cast night or day but are stronger(possibly by having secondary effects) at day time or night time?

in other words, make a peon with a fire breath attack and ice attack that casts any time of day, but the ice attack if casted at night slows the targets, but the fire attack if cast at day damages the targets over time...just as an example.

not only that, i'd like to see your system prepare hero abilities without bugs.
 

SanKakU

Member
Reaction score
21
That should be coded in the spell. The most this could do is provide IsDay/IsNight [LJASS]boolean[/LJASS]s.

are you serious? if that's the case, his system is a total joke, but hey, i can't say mine looks better than his...but that doesn't mean it's not better, because it is...
maybe that isn't so complicated...but i don't remember
i do remember for sure the hero ability learning bugs, though...at least make sure you find that the system prepares hero abilities without bugs.
if it can do that, then i'll be impressed.
 
General chit-chat
Help Users
  • No one is chatting at the moment.
  • The Helper The Helper:
    What is up WildTurkey?
  • The Helper The Helper:
    Looks like Google fixed whatever mistake that made the recipes on the site go crazy and we are no longer trending towards a recipe site lol - I don't care though because it motivated me to spend alot of time on the site improving it and at least now the content people are looking at is not stupid and embarrassing like it was when I first got back into this like 5 years ago.
  • The Helper The Helper:
    Plus - I have a pretty bad ass recipe collection now! That section of the site is 10 thousand times better than it was before
  • The Helper The Helper:
    We now have a web designer at my job. A legit talented professional! I am going to get him to redesign the site theme. It is time.
  • Varine Varine:
    I got one more day of community service and then I'm free from this nonsense! I polished a cop car today for a funeral or something I guess
  • Varine Varine:
    They also were digging threw old shit at the sheriff's office and I tried to get them to give me the old electronic stuff, but they said no. They can't give it to people because they might use it to impersonate a cop or break into their network or some shit? idk but it was a shame to see them take a whole bunch of radios and shit to get shredded and landfilled
  • The Helper The Helper:
    whatever at least you are free
  • 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!

      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