Array
(
    [scriptVersion] => 8
    [oeValues] => Array
        (
            [auto] => Array
                (
                )

            [Art] => ReplaceableTextures\CommandButtons\BTNSpell_Shadow_Twilight.blp
            [turnRate] => 3
            [dmgplus1] => 3826
            [bldtm] => 1
            [goldcost] => 4250
            [unitSound] => ObsidianDestroyer
            [sides1] => 1
            [acquire] => 900
            [upgrades] => Array
                (
                )

            [Upgrade] => Array
                (
                )

            [Name] => The Nightbringer
            [red] => 25
            [weapTp1] => missile
            [MissileHoming] => 1
            [file] => units\creeps\VoidWalker\VoidWalker.mdl
            [uberSplat] => YTDB
            [Missileart] => Abilities\Spells\NightElf\shadowstrike\ShadowStrikeMissile.mdl
            [Missilespeed] => 1400
            [dice1] => 1
            [RngBuff1] => 250
            [green] => 25
            [modelScale] => 0.8
            [rangeN1] => 900
            [atkType1] => hero
            [cool1] => 1.7
            [Ubertip] => An entity of incomprehensible darkness whose very presence suffocates the mind.
            [scaleBull] => 0
            [blue] => 25
            [abilList] => Array
                (
                )

            [moveHeight] => 45
            [buildingShadow] => Array
                (
                )

            [targs1] => Array
                (
                )

            [weapsOn] => 1
            [teamColor] => 3
        )

    [settings] => Array
        (
            [balanceTip] => Array
                (
                )

            [abil_factor] => 0.43
            [author] => Ashbringer
            [alpha] => 255
            [authorDisplay] => |cffff6600Ashbringer|r
            [version] => 1.0
            [element] => darkness
            [rarity] => unique
        )

    [effects] => Array
        (
            [0] => Array
                (
                    [x] => -0.0253258
                    [y] => 0.0556625
                    [z] => -25.6
                    [scale] => 1
                    [rot] => 3.14159
                    [file] => Doodads\Ruins\Props\RuinsPillar\RuinsPillar2.mdl
                    [red] => 15
                    [green] => 15
                    [blue] => 15
                    [alpha] => 255
                    [pitch] => 0
                    [advanced] => false
                    [animation] => Array
                        (
                        )

                    [aniSpeed] => 50
                    [pcolor] => 255
                )

            [1] => Array
                (
                    [x] => -0.146553
                    [y] => -0.0426588
                    [z] => 76.8
                    [scale] => 1
                    [rot] => 4.71239
                    [file] => war3mapImported\BanishTargetShadow.mdl
                    [red] => 255
                    [green] => 255
                    [blue] => 255
                    [alpha] => 255
                    [pitch] => 0
                    [advanced] => false
                    [animation] => Array
                        (
                        )

                    [aniSpeed] => 50
                    [pcolor] => 255
                )

            [2] => Array
                (
                    [x] => 0.0657482
                    [y] => 0.00636435
                    [z] => -25.6
                    [scale] => 2.1
                    [rot] => 0
                    [file] => war3mapImported\GeneralAuraTargetWhite.mdl
                    [red] => 155
                    [green] => 15
                    [blue] => 255
                    [alpha] => 255
                    [pitch] => 0
                    [advanced] => false
                    [animation] => Array
                        (
                        )

                    [aniSpeed] => 50
                    [pcolor] => 255
                )

            [3] => Array
                (
                    [x] => 0.089254
                    [y] => 0.171022
                    [z] => -147.2
                    [scale] => 1.55
                    [rot] => 4.71239
                    [file] => Doodads\Ruins\Props\RuinsPillar\RuinsPillar2.mdl
                    [red] => 15
                    [green] => 15
                    [blue] => 15
                    [alpha] => 255
                    [pitch] => 0
                    [advanced] => false
                    [animation] => Array
                        (
                        )

                    [aniSpeed] => 50
                    [pcolor] => 255
                )

            [4] => Array
                (
                    [x] => -0.0251986
                    [y] => -0.133928
                    [z] => 0
                    [scale] => 1.1
                    [rot] => 2.9147
                    [file] => war3mapImported\GeneralAuraTargetWhite.mdl
                    [red] => 155
                    [green] => 15
                    [blue] => 255
                    [alpha] => 255
                    [pitch] => 0
                    [advanced] => false
                    [animation] => Array
                        (
                        )

                    [aniSpeed] => 50
                    [pcolor] => 255
                )

            [5] => Array
                (
                    [x] => -40.9634
                    [y] => -43.4408
                    [z] => -25.6
                    [scale] => 0.6
                    [rot] => 4.62163
                    [file] => Doodads\Icecrown\Props\IceTorch\IceTorch.mdl
                    [red] => 45
                    [green] => 45
                    [blue] => 45
                    [alpha] => 255
                    [pitch] => 0
                    [advanced] => false
                    [animation] => Array
                        (
                        )

                    [aniSpeed] => 50
                    [pcolor] => 255
                )

            [6] => Array
                (
                    [x] => -43.1882
                    [y] => 40.4888
                    [z] => -25.6
                    [scale] => 0.6
                    [rot] => 3.05084
                    [file] => Doodads\Icecrown\Props\IceTorch\IceTorch.mdl
                    [red] => 45
                    [green] => 45
                    [blue] => 45
                    [alpha] => 255
                    [pitch] => 0
                    [advanced] => false
                    [animation] => Array
                        (
                        )

                    [aniSpeed] => 50
                    [pcolor] => 255
                )

            [7] => Array
                (
                    [x] => 40.5035
                    [y] => 43.8619
                    [z] => -25.6
                    [scale] => 0.6
                    [rot] => 1.48004
                    [file] => Doodads\Icecrown\Props\IceTorch\IceTorch.mdl
                    [red] => 45
                    [green] => 45
                    [blue] => 45
                    [alpha] => 255
                    [pitch] => 0
                    [advanced] => false
                    [animation] => Array
                        (
                        )

                    [aniSpeed] => 50
                    [pcolor] => 255
                )

            [8] => Array
                (
                    [x] => 43.4062
                    [y] => -40.5714
                    [z] => -25.6
                    [scale] => 0.6
                    [rot] => 6.19243
                    [file] => Doodads\Icecrown\Props\IceTorch\IceTorch.mdl
                    [red] => 45
                    [green] => 45
                    [blue] => 45
                    [alpha] => 255
                    [pitch] => 0
                    [advanced] => false
                    [animation] => Array
                        (
                        )

                    [aniSpeed] => 50
                    [pcolor] => 255
                )

            [9] => Array
                (
                    [x] => -0.156605
                    [y] => -29.7414
                    [z] => 0
                    [scale] => 0.15
                    [rot] => 4.71239
                    [file] => Doodads\Cityscape\Props\City_Oblisk\City_Oblisk.mdl
                    [red] => 15
                    [green] => 15
                    [blue] => 15
                    [alpha] => 255
                    [pitch] => 0
                    [advanced] => false
                    [animation] => Array
                        (
                        )

                    [aniSpeed] => 50
                    [pcolor] => 255
                )

            [10] => Array
                (
                    [x] => -0.14574
                    [y] => 29.0463
                    [z] => 0
                    [scale] => 0.15
                    [rot] => 4.71239
                    [file] => Doodads\Cityscape\Props\City_Oblisk\City_Oblisk.mdl
                    [red] => 15
                    [green] => 15
                    [blue] => 15
                    [alpha] => 255
                    [pitch] => 0
                    [advanced] => false
                    [animation] => Array
                        (
                        )

                    [aniSpeed] => 50
                    [pcolor] => 255
                )

            [11] => Array
                (
                    [x] => 29.1906
                    [y] => 0.285701
                    [z] => 0
                    [scale] => 0.15
                    [rot] => 4.71239
                    [file] => Doodads\Cityscape\Props\City_Oblisk\City_Oblisk.mdl
                    [red] => 15
                    [green] => 15
                    [blue] => 15
                    [alpha] => 255
                    [pitch] => 0
                    [advanced] => false
                    [animation] => Array
                        (
                        )

                    [aniSpeed] => 50
                    [pcolor] => 255
                )

            [12] => Array
                (
                    [x] => -30.1763
                    [y] => 0.138336
                    [z] => 0
                    [scale] => 0.15
                    [rot] => 4.71239
                    [file] => Doodads\Cityscape\Props\City_Oblisk\City_Oblisk.mdl
                    [red] => 15
                    [green] => 15
                    [blue] => 15
                    [alpha] => 255
                    [pitch] => 0
                    [advanced] => false
                    [animation] => Array
                        (
                        )

                    [aniSpeed] => 50
                    [pcolor] => 255
                )

            [13] => Array
                (
                    [x] => -21.1699
                    [y] => -19.6654
                    [z] => 0
                    [scale] => 0.15
                    [rot] => 3.92699
                    [file] => Doodads\Cityscape\Props\City_Oblisk\City_Oblisk.mdl
                    [red] => 15
                    [green] => 15
                    [blue] => 15
                    [alpha] => 255
                    [pitch] => 0
                    [advanced] => false
                    [animation] => Array
                        (
                        )

                    [aniSpeed] => 50
                    [pcolor] => 255
                )

            [14] => Array
                (
                    [x] => -19.9229
                    [y] => 20.6004
                    [z] => 0
                    [scale] => 0.15
                    [rot] => 3.92699
                    [file] => Doodads\Cityscape\Props\City_Oblisk\City_Oblisk.mdl
                    [red] => 15
                    [green] => 15
                    [blue] => 15
                    [alpha] => 255
                    [pitch] => 0
                    [advanced] => false
                    [animation] => Array
                        (
                        )

                    [aniSpeed] => 50
                    [pcolor] => 255
                )

            [15] => Array
                (
                    [x] => 20.6647
                    [y] => 20.4139
                    [z] => 0
                    [scale] => 0.15
                    [rot] => 3.92699
                    [file] => Doodads\Cityscape\Props\City_Oblisk\City_Oblisk.mdl
                    [red] => 15
                    [green] => 15
                    [blue] => 15
                    [alpha] => 255
                    [pitch] => 0
                    [advanced] => false
                    [animation] => Array
                        (
                        )

                    [aniSpeed] => 50
                    [pcolor] => 255
                )

            [16] => Array
                (
                    [x] => 21.1999
                    [y] => -19.8103
                    [z] => 0
                    [scale] => 0.15
                    [rot] => 3.92699
                    [file] => Doodads\Cityscape\Props\City_Oblisk\City_Oblisk.mdl
                    [red] => 15
                    [green] => 15
                    [blue] => 15
                    [alpha] => 255
                    [pitch] => 0
                    [advanced] => false
                    [animation] => Array
                        (
                        )

                    [aniSpeed] => 50
                    [pcolor] => 255
                )

            [17] => Array
                (
                    [x] => -0.236866
                    [y] => -0.0669469
                    [z] => -6.4
                    [scale] => 0.95
                    [rot] => 2.28368
                    [file] => Doodads\BlackCitadel\Props\RuneArt\RuneArt1.mdl
                    [red] => 1
                    [green] => 255
                    [blue] => 1
                    [alpha] => 255
                    [pitch] => 0
                    [advanced] => false
                    [animation] => Array
                        (
                        )

                    [aniSpeed] => 50
                    [pcolor] => 255
                )

        )

    [dmgTable] => Array
        (
        )

    [triggers] => Array
        (
            [0] => Array
                (
                    [name] => Header
                    [code] => globals
        Cast ashbringer_nightfall_cast
        BuffType ashbringer_wither_buff
        BuffType ashbringer_misery_buff
    endglobals
    
    struct nightfall
        Tower tower
        Iterate i
        integer waves
        real damage
        Unit last
        timer tm
        boolean destruct
        integer level
        
        static method create takes Tower tower, real damage, real duration returns nightfall
            local nightfall n = nightfall.allocate()
            set n.tower = tower
            set n.damage = damage
            set n.waves = R2I(duration / 3)
            set n.destruct = false
            set n.level = tower.getLevel()
            
            return n
        endmethod
        
        static method ashbringer_wither_apply takes Tower tower, Unit target, real amount, boolean already_dealt returns nothing
            local Buff b
            
            if not already_dealt then
                set b = target.getBuffOfType(ashbringer_misery_buff)
                call tower.doAttackDamage(target, amount * (1 + (b.getPower() * (0.05 + (tower.getLevel() * 0.001)))), tower.calcAttackMulticrit(0, 0, 0))
            endif
            
            set b = target.getBuffOfType(ashbringer_wither_buff)
            if b != 0 then
                set b.userReal = b.userReal + (amount * 0.25)
                set b.userInt = 5
                //call b.refreshDuration()
            else
                set b = ashbringer_wither_buff.apply(tower, target, tower.getLevel())
                set b.userReal = amount * 0.25
                set b.userInt = 5
            endif
        endmethod
        
        private static method hit takes nothing returns nothing
            local timer tm = GetExpiredTimer()
            local nightfall n = nightfall(GetTimerData(tm))
            local Unit next = n.i.nextRandom()
            local Buff b
            
            set n.last = next
            if next != 0 then
                set b = next.getBuffOfType(ashbringer_misery_buff)
                if b != 0 then
                    call b.setPower(b.getPower() + 1)
                    call b.refreshDuration()
                else
                    set b = ashbringer_misery_buff.applyCustomPower(n.tower, next, n.level, 1)
                endif
                call Effect.createSimpleOnUnit("war3mapImported\\StarfallTargetShadow.mdx", next, "origin").setLifetime(2)
                call ashbringer_wither_apply(n.tower, next, n.tower.getCurrentAttackDamageWithBonus() * n.damage, false)
            else
                call PauseTimer(n.tm)
                if n.destruct then
                    call DestroyTimer(n.tm)
                    call n.destroy()
                endif
            endif
        endmethod
        
        private method instant_wave takes nothing returns nothing
            set .i = Iterate.overUnitsInRangeOfCaster(.tower, TARGET_TYPE_CREEPS, 1200)
            call TimerStart(.tm, 0.1, true, function nightfall.hit)
        endmethod
        
        private static method wave takes nothing returns nothing
            local timer tm = GetExpiredTimer()
            local nightfall n = nightfall(GetTimerData(tm))
            
            if n.waves > 0 then
                set n.waves = n.waves - 1
                if n.last != 0 then
                    call n.i.destroy()
                endif
                set n.i = Iterate.overUnitsInRangeOfCaster(n.tower, TARGET_TYPE_CREEPS, 1200)
                call TimerStart(n.tm, 0.1, true, function nightfall.hit)
            else
            endif
            
            if n.waves == 0 then
                call PauseTimer(tm)
                call DestroyTimer(tm)
                set n.destruct = true
            endif
        endmethod
        
        method start takes nothing returns nothing
            local timer tm = CreateTimer()
            
            set .tm = CreateTimer()
            call SetTimerData(.tm, this)
            
            call .instant_wave()
            call SetTimerData(tm, this)
            call TimerStart(tm, 3, true, function nightfall.wave)
        endmethod
    endstruct
    
    function ashbringer_blackout takes Tower tower, Unit target, real damage returns nothing
        local Iterate i = Iterate.overUnitsInRangeOfUnit(tower, TARGET_TYPE_CREEPS, target, 200)
        local Unit next
        local Buff b
        
        call Effect.createScaled("war3mapImported\\AnimateDeadTargetShadow.mdx", target.getX(), target.getY(), target.getZ(), 0, 1.3).setLifetime(3)
        
        loop
            set next = i.next()
            exitwhen next==0
            if next != target then
                set b = target.getBuffOfType(ashbringer_misery_buff)
                call tower.doSpellDamage(next, damage * (1 + (b.getPower() * (0.05 + (tower.getLevel() * 0.001)))), tower.calcSpellCritNoBonus())
                call nightfall.ashbringer_wither_apply(tower, next, damage, true)
                call Effect.createSimpleOnUnit("Abilities\\Spells\\Undead\\DeathandDecay\\DeathandDecayTarget.mdl", next, "origin").setLifetime(2)
                call cb_stun.applyOnlyTimed(tower, next, 1)
            endif
        endloop
        
        call tower.killInstantly(target)
    endfunction
    
    function ashbringer_wither_periodic takes Buff b returns nothing
        local Tower tower = b.getCaster()
        local Unit target = b.getBuffedUnit()
        local real buff_multiplier = 1 + (target.countBuffs(false, true) * (0.05 + (tower.getLevel() * 0.002)))
        local real damage
        local Buff misery = target.getBuffOfType(ashbringer_misery_buff)
        local real misery_multiplier = 1 + (misery.getPower() * (0.05 + (tower.getLevel() * 0.001)))
        
        if b.userInt > 0 and b.userReal > 0 then
            set damage = b.userReal * buff_multiplier * misery_multiplier
            if damage > GetWidgetLife(target.getUnit()) then
                call ashbringer_blackout(tower, target, damage)
            else
                set damage = b.userReal / b.userInt
                call tower.doSpellDamage(target, damage * buff_multiplier * misery_multiplier, tower.calcSpellCritNoBonus())
                set b.userReal = b.userReal - damage
                set b.userInt = b.userInt - 1
            endif
        endif
        
        if b.userInt == 0 then
            call b.removeBuff()
        endif
    endfunction
    
    //Do not remove or rename this function!
    //Put your initialization tasks here, this function will be called on map init
    private function init takes nothing returns nothing
        set ashbringer_wither_buff = BuffType.create(-1, 0, false)
        call ashbringer_wither_buff.setBuffIcon('@@1@@')
        call ashbringer_wither_buff.addPeriodicEvent(ashbringer_wither_periodic, 1)
        
        set ashbringer_misery_buff = BuffType.create(5, 0.1, false)
        call ashbringer_misery_buff.setBuffIcon('@@0@@')
    endfunction
                    [values] => Array
                        (
                            [visible] => true
                            [icon] => ReplaceableTextures\CommandButtons\BTNSpell_Shadow_BlackPlague.blp
                            [name] => Suffocating Darkness
                            [short_explain] => Attacks and abilities deal additional spell damage over time, increased by the number of debuffs on the enemy.
                            [long_explain] => This tower's attacks and abilities deal |cffffff8025%|r of the base damage as additional spell damage over |cffffff805|r seconds. The damage over time portion can accumulate and the damage dealt is increased by |cffffff805%|r per debuff on the target. The duration cannot be modified.|n|n|cffFF8000Level Bonus:|r|n|cffFFFF80+0.2%|r damage per debuff
                        )

                )

            [1] => Array
                (
                    [name] => On Damage
                    [code] => local Unit target = Event.getTarget()
    local Buff b = target.getBuffOfType(ashbringer_misery_buff)
    local integer power = 1
    
    if b != 0 then
        set power = b.getPower() + 1
        call b.setPower(power)
        call b.refreshDuration()
    else
        set b = ashbringer_misery_buff.applyCustomPower(tower, target, tower.getLevel(), 1)
    endif
    
    set Event.damage = Event.damage * (1 + (power * (0.05 + (tower.getLevel() * 0.001))))
    
    call nightfall.ashbringer_wither_apply(tower, target, tower.getCurrentAttackDamageWithBonus(), true)
                    [values] => Array
                        (
                            [ONDAMAGE_chance] => 1
                            [visible] => true
                            [icon] => ReplaceableTextures\CommandButtons\BTNSpell_Shadow_ChillTouch.blp
                            [name] => Shadow Weaving
                            [short_explain] => Attacks apply a stacking debuff which increases damage taken from this tower.
                            [ONDAMAGE_chanceLevelAdd] => 0
                            [long_explain] => Attacks apply a stacking debuff which increases damage taken from this tower's attacks and abilities by |cffffff805%|r per stack. Lasts |cffffff805|r seconds.|n|n|cffFF8000Level Bonus:|r|n|cffFFFF80+0.1%|r damage taken per stack|n|cffFFFF80+0.1|r seconds duration
                        )

                )

            [2] => Array
                (
                    [name] => Autocast
                    [code] => local real damage = 0.25 + (tower.getLevel() * 0.01)
    local real duration = 6 * tower.getProp_BuffDuration()
    
    call nightfall.create(tower, damage, duration).start()
                    [values] => Array
                        (
                            [AUTOCAST_cooldown] => 20
                            [AUTOCAST_autoRange] => 875
                            [AUTOCAST_manacost] => 0
                            [icon] => ReplaceableTextures\CommandButtons\BTNSpell_Shadow_Twilight.blp
                            [AUTOCAST_range] => 900
                            [AUTOCAST_targetType] => 0
                            [AUTOCAST_numBuffsBeforeIdle] => 0
                            [caster_art] => 
                            [long_explain] => Calls down waves of darkness onto enemies within |cffFFFF801200|r range, dealing |cffFFFF8025%|r attack damage and applying Shadow Weaving. A wave occurs immediately and again every |cffFFFF803|r seconds for |cffFFFF806|r seconds. The duration is affected by buff duration.|n|n|cffFF8000Level Bonus:|r|n|cffFFFF80+1%|r attack damage
                            [target_art] => 
                            [AUTOCAST_autocastType] => AC_TYPE_OFFENSIVE_IMMEDIATE
                            [AUTOCAST_buffType] => 0
                            [AUTOCAST_isExtended] => false
                            [name] => Nightfall
                            [AUTOCAST_targetSelf] => false
                            [short_explain] => Calls down multiple waves of darkness onto enemies in attack range, dealing attack damage and applying Shadow Weaving.
                        )

                )

            [3] => Array
                (
                    [name] => On Tower Creation
                    [code] => call SetUnitColor(tower.getUnit(), ConvertPlayerColor(3))
                    [values] => Array
                        (
                            [visible] => true
                            [icon] => ReplaceableTextures\CommandButtons\BTNSpell_Shadow_GatherShadows.blp
                            [name] => Blackout
                            [short_explain] => Enemies explode when the accumulated damage from Suffocating Darkness exceeds their remaining health.
                            [long_explain] => When Suffocating Darkness would deal damage and the accumulated damage exceeds an enemy's remaining life, the enemy will instead explode, killing them and dealing the remaining damage to enemies in |cffffff80200|r range and stunning them for |cffffff801|r second. This effect takes the number of debuffs on the target and the number of Shadow Weaving stacks into account.
                        )

                )

        )

    [abilities] => Array
        (
        )

    [buffs] => Array
        (
            [0] => Array
                (
                    [id] => @@0@@
                    [derivedFrom] => BHbd
                    [oeValues] => Array
                        (
                            [Targetattach] => overhead
                            [Buffubertip] => Taking increased damage from the Nightbringer.
                            [TargetArt] => war3mapImported\BrandShadow.mdx
                            [Bufftip] => Shadow Weaving
                            [Buffart] => ReplaceableTextures\CommandButtons\BTNSpell_Shadow_ChillTouch.blp
                        )

                )

            [1] => Array
                (
                    [id] => @@1@@
                    [derivedFrom] => BHbd
                    [oeValues] => Array
                        (
                            [Targetattach] => origin
                            [Buffubertip] => Taking spell damage over time.
                            [TargetArt] => war3mapImported\BanishTargetShadow.mdx
                            [Bufftip] => Suffocating Darkness
                            [Buffart] => ReplaceableTextures\CommandButtons\BTNSpell_Shadow_BlackPlague.blp
                        )

                )

        )

    [units] => Array
        (
        )

    [references] => Array
        (
        )

    [lightning] => Array
        (
        )

)