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 Discord

      Staff online

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top