Snippet DayNightRequirements

Jesus4Lyf

Good Idea™
Reaction score
397
The following is trash:
JASS:
    private constant real DAWN_TIME = 6.
//  The time in your map at which day starts. This is the default.
    private constant real NIGHT_TIME = 18.
//  The time in your map at which night starts. This is the default.
    private constant player HOLDER = Player(15)
//  Substitute a player that will not need to have day/night specific abilities.

FIXXIT. :)
Good work. ;)
 

Azlier

Old World Ghost
Reaction score
461
The holder is still in effect, but the dawn/dusk times are no longer needed.
 

Azlier

Old World Ghost
Reaction score
461
Fine. Morphing it is. /grumble

EDIT: I simply CANNOT get morphing to work.

The units just keep chaosing into eachother, despite the fact that I disable the alternate morph ability before issuing the order and enabling it after a 0 second timer. I even tried a 1 second timer.

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 4 lines below this one.
///!        external ObjectMerger w3u hpea dayd ufoo 0 uabi Avul,Aloc,nitm umdl " " usca 0 ushu " " unam "Daytime" unsf "(DNR Dummy)" util 0 ucbs 0 ucpt 0
///!        external ObjectMerger w3u hpea nitd ufoo 0 uabi Avul,Aloc,daym umdl " " usca 0 ushu " " unam "Nighttime" unsf "(DNR Dummy)" util 0 ucbs 0 ucpt 0
///!        external ObjectMerger w3a Sca6 daym Cha1 1 dayd areq 0 ansf "(DNR Morph Ability)" anam "Chaos"
///!        external ObjectMerger w3a Sca6 nitm Cha1 1 nitd areq 0 ansf "(DNR Morph Ability)" anam "Chaos"
//         - 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 unit array U
    private constant integer DAY = 'dayd'
    private constant integer NIGHT = 'nitd'
    private constant integer DAY_MORPH = 'daym'
    private constant integer NIGHT_MORPH = 'nitm'
    private constant integer CHAOS_ID = 0
    private timer T = CreateTimer()
endglobals

private function Reset takes nothing returns nothing
    local integer i = 15
    call PauseTimer(T)
    loop
        call SetPlayerAbilityAvailable(Player(i), DAY_MORPH, true)
        call SetPlayerAbilityAvailable(Player(i), NIGHT_MORPH, true)
        exitwhen i == 0
        set i = i - 1
    endloop
endfunction

private function Day takes nothing returns boolean
    local integer i = 15
    loop
        call SetPlayerAbilityAvailable(Player(i), DAY_MORPH, false)
        if IssueImmediateOrder(U<i>, &quot;chaos&quot;) then
            call BJDebugMsg(&quot;SUCCESS&quot;)
        else
            call BJDebugMsg(&quot;ONOZ&quot;)
        endif
        exitwhen i == 0
        set i = i - 1
    endloop
    call ResumeTimer(T)
    return false
endfunction

private function Night takes nothing returns boolean
    local integer i = 15
    loop
        call SetPlayerAbilityAvailable(Player(i), NIGHT_MORPH, false)
        if IssueImmediateOrder(U<i>, &quot;chaos&quot;) then
            call BJDebugMsg(&quot;SUCCESS&quot;)
        else
            call BJDebugMsg(&quot;ONOZ&quot;)
        endif
        exitwhen i == 0
        set i = i - 1
    endloop
    call ResumeTimer(T)
    return false
endfunction

private function Init takes nothing returns nothing
    local integer i = 15
    local trigger t = CreateTrigger()
    
    loop
        static if STARTS_DURING_DAY then
            set U<i> = CreateUnit(Player(i), DAY, 0, 0, 270)
        else
            set U<i> = CreateUnit(Player(i), NIGHT, 0, 0, 270)
        endif
        //call SetUnitX(U<i>, 10000)
        //call SetUnitY(U<i>, 10000)
        //call ShowUnit(U<i>, false)
        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)
    
    call TimerStart(T, 0, true, function Reset)
    call PauseTimer(T)
endfunction

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

xAnaMorphine

Active Member
Reaction score
43
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&#039;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 &quot; &quot; usca 0 ushu &quot; &quot; unam &quot;Daytime&quot; unsf &quot;(DNR Dummy)&quot; util 0
//!        external ObjectMerger w3u hpea nitd ufoo 0 uabi Avul,Aloc umdl &quot; &quot; usca 0 ushu &quot; &quot; unam &quot;Nighttime&quot; unsf &quot;(DNR Dummy)&quot; 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.
//
//        Do not delete these. These are for those who possibly open your map and see this system and want to be able to use it.
//!        external ObjectMerger w3u nalb dayd uabi Avul,Aloc umdl &quot; &quot; usca 0 ushu &quot; &quot; unam &quot;Daytime&quot; unsf &quot;(DNR Dummy)&quot;
//!        external ObjectMerger w3u nalb nitd uabi Avul,Aloc umdl &quot; &quot; usca 0 ushu &quot; &quot; unam &quot;Nighttime&quot; unsf &quot;(DNR Dummy)&quot;
//
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

    private unit array DayU //Rhymes.
    private unit array NightU //Does not.
    private constant integer DAY = &#039;dayd&#039;
    private constant integer NIGHT = &#039;nitd&#039;
    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...


Does "-day" set the clock to day when typed?
 

Azlier

Old World Ghost
Reaction score
461
That's certainly a possiblity.
 
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