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.
The demo map will turn the clock to night when "-night" is typed, and I wonder what "-day" could possibly do...
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 = 039;dayd039;
private constant integer NIGHT = 039;nitd039;
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...