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

            [Art] => ReplaceableTextures\CommandButtons\BTNBanditMage.blp
            [turnRate] => 3
            [dmgplus1] => 0
            [bldtm] => 1
            [goldcost] => 1200
            [unitSound] => HeroArchMage
            [sides1] => 1
            [manaN] => 1000
            [acquire] => 900
            [upgrades] => Array
                (
                )

            [Upgrade] => Array
                (
                )

            [Name] => Spellweaver
            [weapTp1] => missile
            [impactZ] => 60
            [file] => units\creeps\BanditMage\BanditMage.mdl
            [MissileHoming] => 1
            [uberSplat] => YTDG
            [Missilespeed] => 9999
            [dice1] => 1
            [RngBuff1] => 250
            [regenMana] => 10
            [modelScale] => 0.5
            [rangeN1] => 900
            [propWin] => 10
            [atkType1] => magic
            [cool1] => 1.5
            [Ubertip] => Every incantation is custom-made to ruin someone’s day.
            [scaleBull] => 0
            [abilList] => @@0@@,@@5@@
            [moveHeight] => 17
            [buildingShadow] => Array
                (
                )

            [targs1] => Array
                (
                )

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

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

            [abil_factor] => 0
            [author] => Ashbringer
            [alpha] => 255
            [authorDisplay] => |cffff6600Ashbringer|r
            [version] => 1.0
            [element] => arcane
            [rarity] => rare
        )

    [effects] => Array
        (
            [0] => Array
                (
                    [x] => -34.9289
                    [y] => -35.218
                    [z] => -6.4
                    [scale] => 0.3
                    [rot] => 4.71239
                    [file] => Doodads\Cityscape\Structures\City_LowWall_ShortEndCap\City_LowWall_ShortEndCap.mdl
                    [red] => 55
                    [green] => 55
                    [blue] => 255
                    [alpha] => 255
                    [pitch] => 0
                    [advanced] => false
                    [animation] => Array
                        (
                        )

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

            [1] => Array
                (
                    [x] => -34.6882
                    [y] => 35.5062
                    [z] => -6.4
                    [scale] => 0.3
                    [rot] => 4.71239
                    [file] => Doodads\Cityscape\Structures\City_LowWall_ShortEndCap\City_LowWall_ShortEndCap.mdl
                    [red] => 55
                    [green] => 55
                    [blue] => 255
                    [alpha] => 255
                    [pitch] => 0
                    [advanced] => false
                    [animation] => Array
                        (
                        )

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

            [2] => Array
                (
                    [x] => 35.2529
                    [y] => 35.0514
                    [z] => -6.4
                    [scale] => 0.3
                    [rot] => 4.71239
                    [file] => Doodads\Cityscape\Structures\City_LowWall_ShortEndCap\City_LowWall_ShortEndCap.mdl
                    [red] => 55
                    [green] => 55
                    [blue] => 255
                    [alpha] => 255
                    [pitch] => 0
                    [advanced] => false
                    [animation] => Array
                        (
                        )

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

            [3] => Array
                (
                    [x] => 34.6772
                    [y] => -35.2284
                    [z] => -6.4
                    [scale] => 0.3
                    [rot] => 4.71239
                    [file] => Doodads\Cityscape\Structures\City_LowWall_ShortEndCap\City_LowWall_ShortEndCap.mdl
                    [red] => 55
                    [green] => 55
                    [blue] => 255
                    [alpha] => 255
                    [pitch] => 0
                    [advanced] => false
                    [animation] => Array
                        (
                        )

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

            [4] => Array
                (
                    [x] => -8.75914
                    [y] => 0.10038
                    [z] => 6.4
                    [scale] => 0.45
                    [rot] => 3.14159
                    [file] => Doodads\Cityscape\Structures\CityLowWall90\CityLowWall90.mdl
                    [red] => 115
                    [green] => 115
                    [blue] => 255
                    [alpha] => 255
                    [pitch] => -1.57
                    [advanced] => false
                    [animation] => Array
                        (
                        )

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

            [5] => Array
                (
                    [x] => 8.00265
                    [y] => 0.0200647
                    [z] => 6.4
                    [scale] => 0.45
                    [rot] => 0
                    [file] => Doodads\Cityscape\Structures\CityLowWall90\CityLowWall90.mdl
                    [red] => 115
                    [green] => 115
                    [blue] => 255
                    [alpha] => 255
                    [pitch] => -1.57
                    [advanced] => false
                    [animation] => Array
                        (
                        )

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

            [6] => Array
                (
                    [x] => -0.0242445
                    [y] => 8.29401
                    [z] => 6.4
                    [scale] => 0.45
                    [rot] => 1.5708
                    [file] => Doodads\Cityscape\Structures\CityLowWall90\CityLowWall90.mdl
                    [red] => 115
                    [green] => 115
                    [blue] => 255
                    [alpha] => 255
                    [pitch] => -1.57
                    [advanced] => false
                    [animation] => Array
                        (
                        )

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

            [7] => Array
                (
                    [x] => -0.10456
                    [y] => -8.46778
                    [z] => 6.4
                    [scale] => 0.45
                    [rot] => 4.71239
                    [file] => Doodads\Cityscape\Structures\CityLowWall90\CityLowWall90.mdl
                    [red] => 115
                    [green] => 115
                    [blue] => 255
                    [alpha] => 255
                    [pitch] => -1.57
                    [advanced] => false
                    [animation] => Array
                        (
                        )

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

            [8] => Array
                (
                    [x] => -32.7683
                    [y] => 34.153
                    [z] => -6.4
                    [scale] => 0.31
                    [rot] => 0.15072
                    [file] => buildings\other\BookOfSummoning\BookOfSummoning.mdl
                    [red] => 155
                    [green] => 155
                    [blue] => 255
                    [alpha] => 255
                    [pitch] => 0
                    [advanced] => false
                    [animation] => Array
                        (
                        )

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

            [9] => Array
                (
                    [x] => 34.6121
                    [y] => 33.0251
                    [z] => -6.4
                    [scale] => 0.31
                    [rot] => 4.68895
                    [file] => buildings\other\BookOfSummoning\BookOfSummoning.mdl
                    [red] => 155
                    [green] => 155
                    [blue] => 255
                    [alpha] => 255
                    [pitch] => 0
                    [advanced] => false
                    [animation] => Array
                        (
                        )

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

            [10] => Array
                (
                    [x] => 38.4421
                    [y] => -0.515609
                    [z] => 12.8
                    [scale] => 0.0999999
                    [rot] => 0
                    [file] => war3mapImported\City_ColumnSemiCircle2.mdl
                    [red] => 255
                    [green] => 55
                    [blue] => 255
                    [alpha] => 255
                    [pitch] => -1.57
                    [advanced] => false
                    [animation] => Array
                        (
                        )

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

            [11] => Array
                (
                    [x] => -39.4275
                    [y] => 0.114149
                    [z] => 12.8
                    [scale] => 0.1
                    [rot] => 3.14159
                    [file] => war3mapImported\City_ColumnSemiCircle2.mdl
                    [red] => 255
                    [green] => 55
                    [blue] => 255
                    [alpha] => 255
                    [pitch] => -1.57
                    [advanced] => false
                    [animation] => Array
                        (
                        )

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

            [12] => Array
                (
                    [x] => -0.167292
                    [y] => -39.5112
                    [z] => 12.8
                    [scale] => 0.1
                    [rot] => 4.71239
                    [file] => war3mapImported\City_ColumnSemiCircle2.mdl
                    [red] => 255
                    [green] => 55
                    [blue] => 255
                    [alpha] => 255
                    [pitch] => -1.57
                    [advanced] => false
                    [animation] => Array
                        (
                        )

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

            [13] => Array
                (
                    [x] => 0.091392
                    [y] => 38.8212
                    [z] => 12.8
                    [scale] => 0.1
                    [rot] => 1.5708
                    [file] => war3mapImported\City_ColumnSemiCircle2.mdl
                    [red] => 255
                    [green] => 55
                    [blue] => 255
                    [alpha] => 255
                    [pitch] => -1.57
                    [advanced] => false
                    [animation] => Array
                        (
                        )

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

            [14] => Array
                (
                    [x] => -0.0422805
                    [y] => -0.252569
                    [z] => 0
                    [scale] => 1.35
                    [rot] => 5.3058
                    [file] => war3mapImported\GeneralAuraTargetWhite.mdl
                    [red] => 255
                    [green] => 55
                    [blue] => 255
                    [alpha] => 255
                    [pitch] => 0
                    [advanced] => false
                    [animation] => Array
                        (
                        )

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

            [15] => Array
                (
                    [x] => -0.0861609
                    [y] => -0.0768084
                    [z] => 6.4
                    [scale] => 0.95
                    [rot] => 5.35816
                    [file] => war3mapImported\GeneralAuraTargetWhite.mdl
                    [red] => 1
                    [green] => 205
                    [blue] => 255
                    [alpha] => 255
                    [pitch] => 0
                    [advanced] => false
                    [animation] => Array
                        (
                        )

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

        )

    [dmgTable] => Array
        (
        )

    [triggers] => Array
        (
            [0] => Array
                (
                    [name] => On Level Up
                    [code] => local spellcraft s = tower.userInt
    
    set s.spellstorm_damage  = 1000 + (tower.getLevel() * 40)
    set s.barrage_damage  = 1000 + (tower.getLevel() * 40)
    set s.tempest_damage  = 1500 + (tower.getLevel() * 60)
    set s.familiar_damage  = 1200 + (tower.getLevel() * 48)
                    [values] => Array
                        (
                            [visible] => false
                            [icon] => 
                            [name] => 
                            [short_explain] => 
                            [long_explain] => 
                        )

                )

            [1] => Array
                (
                    [name] => Header
                    [code] => globals
        Cast ashbringer_spellstorm_cast
        ProjectileType ashbringer_barrage_projectile
        ProjectileType ashbringer_familiar_projectile
        BuffType ashbringer_tempest_buff
        BuffType ashbringer_echo_buff
        BuffType ashbringer_destabilize_buff
        //@export
        MultiboardValues ashbringer_spellcraft_mana
    endglobals
    
    //@export
    struct spellcraft
        integer base = 0
        integer secondary = 0
        real spellstorm_damage
        real barrage_damage
        real tempest_damage
        real familiar_damage
        real feedback_damage
    endstruct
        
    function do_secondary takes Tower tower, Unit target, integer secondary, real damage, real mult returns nothing
        local spellcraft s = tower.userInt
        local real mana
        local Buff b
        local integer power
        
        if secondary == 0 then
            if tower.calcChance(0.2) then
                call cb_stun.applyOnlyTimed(tower, target, 0.5 * mult)
            endif
        elseif secondary == 1 then
            set mana = target.subtractMana(15 * mult, true)
            if mana > 0 then
                call tower.doSpellDamage(target, s.feedback_damage * mana, tower.calcSpellCritNoBonus())
                call Effect.createSimpleOnUnit("Abilities\\Spells\\Human\\Feedback\\ArcaneTowerAttack.mdl", target, "chest").setLifetime(2.0)
            endif
        elseif secondary == 2 then
            set b = target.getBuffOfType(ashbringer_echo_buff)
            
            if b != 0 then
                set b.userReal = b.userReal + (damage * 0.05)
                call b.refreshDuration()
            else
                set b = ashbringer_echo_buff.apply(tower, target, 0)
                set b.userReal = damage * 0.05
            endif
        elseif secondary == 3 then
            set power = R2I((0.25 * mult) / 0.0001)
            set b = ashbringer_destabilize_buff.applyCustomPower(tower, target, power, power)
        endif
    endfunction
    
    function ashbringer_spellcraft_barrage takes Tower tower, Unit target, real damage, integer secondary, real mana_multiplier returns nothing
        local real target_x
        local real target_y
        local Projectile p
        local real random_angle
        local real random_distance
        local integer proj = 5
        
        loop
            exitwhen proj == 0
            set random_angle = GetRandomReal(0, 360)
            set random_distance = GetRandomReal(0, 250)
            set target_x = target.getX() + random_distance * Cos(Deg2Rad(random_angle))
            set target_y = target.getY() + random_distance * Sin(Deg2Rad(random_angle))
            set p = Projectile.createLinearInterpolationFromUnitToPoint(ashbringer_barrage_projectile, tower, 0, 0, tower, target_x, target_y, target.getZ(), 0.3)
            set p.userReal = target_x
            set p.userReal2 = target_y
            set p.userReal3 = mana_multiplier
            set p.userInt = secondary
            set p.userInt2 = R2I(damage * 1000)
            call p.setScale(1.25)
            set p.speed = 1400 + (proj * 50)
            set p.accelerate = RMaxBJ(40 - proj * 8, 0)
            set proj = proj - 1
        endloop
    endfunction
    
    function ashbringer_familiar_order takes Projectile p, Unit target returns nothing
        local Tower tower = p.getCaster()
        local Iterate i
        local Unit next
        local real end_x
        local real end_y
        local real random_angle
        local real random_distance
        local real angle_diff
        local real angle_mult
        local real height = 140 + GetRandomReal(-25, 25)
        local real move_modifier = 1 + (tower.getProp_Attackspeed() * 0.2)
        local Buff b
        
        if tower.getUID() != p.userInt then
            //call p.destroy()
        else
            call p.avertDestruction()
        endif
        
        if p.userReal==0 then
            set i = Iterate.overUnitsInRangeOfCaster(tower, TARGET_CREEPS, tower.getRange())
            set next = i.nextRandom()
            if next!=0 then
                set angle_diff = bj_RADTODEG * Atan2(next.getY() - p.y, next.getX() - p.x)
                set angle_diff = (angle_diff-180) - (p.direction-180)
                if angle_diff<-180.0 then
                    set angle_diff = angle_diff + 360.0
                endif
                if angle_diff>180.0 then
                    set angle_diff = angle_diff - 360.0
                endif
                if angle_diff>0.0 then
                    set angle_mult = 1
                elseif(angle_diff < 0.0) then
                    set angle_mult = -1
                else
                    set angle_mult = 1
                endif
                
                set p.speed = 800 * move_modifier
                call p.startBezierInterpolationToUnit(next, 0, GetRandomReal(0.2, 0.4)*angle_mult, GetRandomReal(0.2, 0.4), true)
                set p.userReal = 1
                call i.destroy()
            else
                set random_angle = GetRandomReal(0, 360)
                set random_distance = GetRandomReal(300, 900)
                set end_x = tower.getX() + random_distance * Cos(Deg2Rad(random_angle))
                set end_y = tower.getY() + random_distance * Sin(Deg2Rad(random_angle))
                
                set angle_diff = bj_RADTODEG * Atan2(end_y - p.y, end_x - p.x)
                set angle_diff = (angle_diff-180) - (p.direction-180)
                if angle_diff<-180.0 then
                    set angle_diff = angle_diff + 360.0
                endif
                if angle_diff>180.0 then
                    set angle_diff = angle_diff - 360.0
                endif
                if angle_diff>0.0 then
                    set angle_mult = -1
                elseif(angle_diff < 0.0) then
                    set angle_mult = 1
                else
                    set angle_mult = 0
                endif
                
                set p.speed = 400 * move_modifier
                call p.startBezierInterpolationToPoint(end_x, end_y, height, 0, GetRandomReal(0.2, 0.4)*angle_mult, 0.4)
            endif
        else
            set p.userReal = 0
            
            if target!=0 then
                set p.userInt3 = p.userInt3 - 1
                call tower.doSpellDamage(target, p.userReal, tower.calcSpellCritNoBonus())
                call do_secondary(tower, target, p.userInt2, p.userReal, p.userReal2)
                call Effect.createSimpleOnUnit("Abilities\\Weapons\\BlackKeeperMissile\\BlackKeeperMissile.mdl", target, "chest").destroy()
            endif
            
            if p.userInt3 > 0 then
                set random_angle = GetRandomReal(0, 360)
                set random_distance = GetRandomReal(300, 900)
                set end_x = tower.getX() + random_distance * Cos(Deg2Rad(random_angle))
                set end_y = tower.getY() + random_distance * Sin(Deg2Rad(random_angle))
                
                set angle_diff = bj_RADTODEG * Atan2(end_y - p.y, end_x - p.x)
                set angle_diff = (angle_diff-180) - (p.direction-180)
                if angle_diff<-180.0 then
                    set angle_diff = angle_diff + 360.0
                endif
                if angle_diff>180.0 then
                    set angle_diff = angle_diff - 360.0
                endif
                if angle_diff>0.0 then
                    set angle_mult = -1
                elseif(angle_diff < 0.0) then
                    set angle_mult = 1
                else
                    set angle_mult = 0
                endif
                
                set p.speed = 400 * move_modifier
                call p.startBezierInterpolationToPoint(end_x, end_y, height, 0, GetRandomReal(0.2, 0.4)*angle_mult, 0.4)
            else
                call p.destroy()
            endif
        endif
    endfunction
    
    //@export
    function ashbringer_spellcraft_cast takes Tower tower, Unit target, spellcraft s returns nothing
        local real mana_multiplier = 1 + ((tower.userReal / 10) * (0.01 + (tower.getLevel() * 0.0004)))
        local SpellDummy d
        local Buff b
        local Projectile p
        local Playor pl = tower.getOwner()
        
        set tower.userReal = 0
        call pl.displaySmallFloatingText("+" + I2S(R2I((mana_multiplier - 1) * 100)) + "%", tower, 255, 119, 255, 0)
        if s.base == 0 then
            set d = ashbringer_spellstorm_cast.pointCastFromUnitOnPointReturn(tower, target, target.getX(), target.getY(), s.spellstorm_damage * mana_multiplier, tower.calcSpellCritNoBonus())
            set d.userReal = s.spellstorm_damage * mana_multiplier
            set d.userReal2 = mana_multiplier
            set d.userInt = s.secondary
        elseif s.base == 1 then
            call ashbringer_spellcraft_barrage(tower, target, s.barrage_damage * mana_multiplier, s.secondary, mana_multiplier)
        elseif s.base == 2 then
            set b = ashbringer_tempest_buff.apply(tower, target, tower.getLevel())
            set b.userInt = s.secondary
            set b.userReal = s.tempest_damage * mana_multiplier
            set b.userReal2 = mana_multiplier
        elseif s.base == 3 then
            set p = Projectile.createBezierInterpolationFromPointToPoint(ashbringer_familiar_projectile, tower, 0, 0, tower.getX(), tower.getY(), 100, tower.getX(), tower.getY()-150, 140, 0, 0, 0)
            call p.setScale(1.3)
            set p.userReal = 0
            set p.userReal = s.familiar_damage * mana_multiplier
            set p.userReal2 = mana_multiplier
            set p.userInt = tower.getUID()
            set p.userInt2 = s.secondary
            set p.userInt3 = 4
        endif
    endfunction
    
    function ashbringer_spellstorm_hit takes DummyUnit d returns nothing
        call do_secondary(d.getCaster(), Event.getTarget(), d.userInt, d.userReal, d.userReal2)
    endfunction
    
    function ashbringer_barrage_hit takes Projectile p returns nothing
        local Tower tower = p.getCaster()
        local Iterate i = Iterate.overUnitsInRange(tower, TARGET_TYPE_CREEPS, p.userReal, p.userReal2, 100)
        local Unit next
        
        loop
            set next = i.next()
            exitwhen next == 0
            call Effect.createSimpleOnUnit("war3mapImported\\AbsorbManaBirthMissileArcane.mdx", next, "chest").destroy()
            call tower.doSpellDamage(next, p.userInt2 / 1000, tower.calcSpellCritNoBonus())
            call do_secondary(tower, next, p.userInt, p.userInt2 / 1000, p.userReal3)
        endloop
    endfunction
    
    function ashbringer_tempest_periodic takes Buff b returns nothing
        local Tower tower = b.getCaster()
        local Unit target = b.getBuffedUnit()
        local Iterate i = Iterate.overUnitsInRangeOfUnit(tower, TARGET_TYPE_CREEPS, target, 450)
        local Unit next
        
        call Effect.createSimpleOnUnit("war3mapImported\\BoltImpactArcane.mdx", target, "origin").setLifetime(3)
        call tower.doSpellDamage(target, b.userReal, tower.calcSpellCritNoBonus())
        call do_secondary(tower, target, b.userInt, b.userReal, b.userReal2)
        
        loop
            set next = i.nextRandom()
            exitwhen next == 0
            if next != target then
                call Effect.createSimpleOnUnit("war3mapImported\\BoltImpactArcane.mdx", next, "origin").setLifetime(3)
                call tower.doSpellDamage(next, b.userReal, tower.calcSpellCritNoBonus())
                call do_secondary(tower, next, b.userInt, b.userReal, b.userReal2)
                call Lightning.createFromUnitToUnit("PZAP", target, next).setLifetime(0.2)
                set next = 0
            endif
            exitwhen next == 0
        endloop
    endfunction
    
    function ashbringer_tempest_ondeath takes Buff b returns nothing
        local Tower tower = b.getCaster()
        local Unit target = b.getBuffedUnit()
        local Iterate i
        local Unit next
        local Buff n
    
        if b.getRemainingDuration() >= 1 then
            set i = Iterate.overUnitsInRangeOfUnit(tower, TARGET_TYPE_CREEPS, target, 450)
            loop
                set next = i.nextRandom()
                exitwhen next == 0
                if next != target then
                    call Effect.createSimpleOnUnit("war3mapImported\\BoltImpactArcane.mdx", next, "origin").setLifetime(3)
                    call tower.doSpellDamage(next, b.userReal, tower.calcSpellCritNoBonus())
                    call do_secondary(tower, next, b.userInt, b.userReal, b.userReal2)
                    call Lightning.createFromUnitToUnit("PZAP", target, next).setLifetime(0.2)
                    set n = ashbringer_tempest_buff.apply(tower, next, tower.getLevel())
                    set n.userInt = b.userInt
                    set n.userReal = b.userReal
                    set n.userReal2 = b.userReal2
                    call n.setRemainingDuration(b.getRemainingDuration())
                    set next = 0
                endif
                exitwhen next == 0
            endloop
        endif
    endfunction
    
    function ashbringer_echo_periodic takes Buff b returns nothing
        local Tower tower = b.getCaster()
        
        call tower.doSpellDamage(b.getBuffedUnit(), b.userReal, tower.calcSpellCritNoBonus())
    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
        local Modifier mod = Modifier.create()
        
        set ashbringer_spellstorm_cast = Cast.create('@@6@@', "blizzard", 5.5)
        call ashbringer_spellstorm_cast.setDamageEvent(EventHandler.ashbringer_spellstorm_hit)
        
        set ashbringer_barrage_projectile = ProjectileType.create("war3mapImported\\AbsorbManaBirthMissileArcane.mdx", 5, 1000) 
        call ashbringer_barrage_projectile.setEventOnCleanup(ProjectileEvent.ashbringer_barrage_hit)
        
        set ashbringer_tempest_buff = BuffType.create(6, 0, false)
        call ashbringer_tempest_buff.setBuffIcon('@@14@@')
        call ashbringer_tempest_buff.addPeriodicEvent(ashbringer_tempest_periodic, 1)
        call ashbringer_tempest_buff.addEventOnDeath(ashbringer_tempest_ondeath)
        
        set ashbringer_familiar_projectile = ProjectileType.createInterpolate("Abilities\\Weapons\\BlackKeeperMissile\\BlackKeeperMissile.mdl", 400)
        call ashbringer_familiar_projectile.disableExplodeOnExpiration()
        call ashbringer_familiar_projectile.setEventOnInterpolationFinished(ashbringer_familiar_order)
        
        set ashbringer_echo_buff = BuffType.create(5, 0, false)
        call ashbringer_echo_buff.setBuffIcon('@@12@@')
        call ashbringer_echo_buff.addPeriodicEvent(ashbringer_echo_periodic, 1)
        
        set ashbringer_destabilize_buff = BuffType.create(3, 0, false)
        call ashbringer_destabilize_buff.setBuffIcon('@@11@@')
        call mod.addModification(MOD_ATK_DAMAGE_RECEIVED, 0, 0.0001)
        call mod.addModification(MOD_SPELL_DAMAGE_RECEIVED, 0, 0.0001)
        call ashbringer_destabilize_buff.setBuffModifier(mod)
        
        set ashbringer_spellcraft_mana = MultiboardValues.create(1)  
        call ashbringer_spellcraft_mana.setKey(0, "Spellcraft Mana") 
    endfunction
                    [values] => Array
                        (
                            [visible] => false
                            [icon] => 
                            [name] => 
                            [short_explain] => 
                            [long_explain] => 
                        )

                )

            [2] => Array
                (
                    [name] => On Tower Details
                    [code] => call ashbringer_spellcraft_mana.setValue(0, formatFloat(tower.userReal, 0)) 
    return ashbringer_spellcraft_mana
                    [values] => Array
                        (
                            [0] => Array
                                (
                                    [_value] => 0
                                    [typ] => string
                                )

                        )

                )

            [3] => Array
                (
                    [name] => On Spell Cast
                    [code] => local spellcraft s = tower.userInt
    local integer ability_id = GetSpellAbilityId()
    
    call Effect.createSimpleOnUnit("Abilities\\Spells\\Undead\\DeathPact\\DeathPactTarget.mdl", tower, "origin").setLifetime(3)
    if ability_id == '@@0@@' then
        call UnitRemoveAbility(tower.getUnit(), '@@0@@')
        call UnitAddAbility(tower.getUnit(), '@@2@@')
        set s.base = 1
    elseif ability_id == '@@2@@' then
        call UnitRemoveAbility(tower.getUnit(), '@@2@@')
        call UnitAddAbility(tower.getUnit(), '@@7@@')
        set s.base = 2
    elseif ability_id == '@@7@@' then
        call UnitRemoveAbility(tower.getUnit(), '@@7@@')
        call UnitAddAbility(tower.getUnit(), '@@8@@')
        set s.base = 3
    elseif ability_id == '@@8@@' then
        call UnitRemoveAbility(tower.getUnit(), '@@8@@')
        call UnitAddAbility(tower.getUnit(), '@@0@@')
        set s.base = 0
    endif
    
    if ability_id == '@@5@@' then
        call UnitRemoveAbility(tower.getUnit(), '@@5@@')
        call UnitAddAbility(tower.getUnit(), '@@3@@')
        set s.secondary = 1
    elseif ability_id == '@@3@@' then
        call UnitRemoveAbility(tower.getUnit(), '@@3@@')
        call UnitAddAbility(tower.getUnit(), '@@4@@')
        set s.secondary = 2
    elseif ability_id == '@@4@@' then
        call UnitRemoveAbility(tower.getUnit(), '@@4@@')
        call UnitAddAbility(tower.getUnit(), '@@1@@')
        set s.secondary = 3
    elseif ability_id == '@@1@@' then
        call UnitRemoveAbility(tower.getUnit(), '@@1@@')
        call UnitAddAbility(tower.getUnit(), '@@5@@')
        set s.secondary = 0
    endif
                    [values] => Array
                        (
                            [visible] => false
                            [icon] => 
                            [name] => 
                            [short_explain] => 
                            [long_explain] => 
                        )

                )

            [4] => Array
                (
                    [name] => On Tower Destruction
                    [code] => local spellcraft s = tower.userInt
    local Effect e = tower.userInt2
    
    call s.destroy()
    call e.destroy()
                    [values] => Array
                        (
                            [visible] => false
                            [icon] => 
                            [name] => 
                            [short_explain] => 
                            [long_explain] => 
                        )

                )

            [5] => Array
                (
                    [name] => On Damage
                    [code] => local real mana = GetUnitState(tower.getUnit(), UNIT_STATE_MANA) * 0.1
    
    set Event.damage = 0
    set tower.userReal = RMinBJ(tower.userReal + mana, 10000)
    call tower.subtractMana(mana, true)
    call Effect.createSimpleAtUnit("war3mapImported\\DrainBlue.mdx", tower).setLifetime(3)
                    [values] => Array
                        (
                            [ONDAMAGE_chance] => 1.0
                            [visible] => true
                            [icon] => ReplaceableTextures\CommandButtons\BTNDispelMagic.blp
                            [name] => Mana Weaving
                            [short_explain] => Instead of attacking enemies, the Spellweaver channels mana into his next Spellcraft, increasing its potency.
                            [ONDAMAGE_chanceLevelAdd] => 0
                            [long_explain] => Instead of attacking, channel |cffFFFF8010%|r of current mana into the next Spellcraft. The damage of the next Spellcraft and the potency of secondary effects is increased by |cffFFFF801%|r per |cffFFFF8010|r mana channelled. Maximum |cffFFFF8010000|r mana can be channelled.|n|n|cffFF8000Level Bonus:|r|n|n|cffFFFF80+0.04%|r potency per |cffFFFF8010|r mana
                        )

                )

            [6] => Array
                (
                    [name] => Autocast
                    [code] => call ashbringer_spellcraft_cast(tower, Event.getTarget(), spellcraft(tower.userInt))
                    [values] => Array
                        (
                            [AUTOCAST_cooldown] => 6
                            [AUTOCAST_autoRange] => 900
                            [AUTOCAST_manacost] => 0
                            [icon] => ReplaceableTextures\CommandButtons\BTNArcaneBlast.blp
                            [AUTOCAST_range] => 900
                            [AUTOCAST_targetType] => 0
                            [AUTOCAST_numBuffsBeforeIdle] => 0
                            [caster_art] => 
                            [long_explain] => Casts a spell based on selected primary and secondary effects.
                            [target_art] => 
                            [AUTOCAST_autocastType] => AC_TYPE_OFFENSIVE_UNIT
                            [AUTOCAST_buffType] => 0
                            [AUTOCAST_isExtended] => false
                            [name] => Spellcraft
                            [AUTOCAST_targetSelf] => false
                            [short_explain] => Casts a spell based on selected primary and secondary effects.
                        )

                )

            [7] => Array
                (
                    [name] => On Tower Creation
                    [code] => local spellcraft s = spellcraft.create()
    local Effect e = Effect.createSimpleOnUnit("Abilities\\Weapons\\SpiritOfVengeanceMissile\\SpiritOfVengeanceMissile.mdl", tower, "weapon")
    
    call SetUnitColor(tower.getUnit(), ConvertPlayerColor(7))
    
    set s.spellstorm_damage  = 1000 + (tower.getLevel() * 40)
    set s.barrage_damage  = 1000 + (tower.getLevel() * 40)
    set s.tempest_damage  = 1500 + (tower.getLevel() * 60)
    set s.familiar_damage  = 1200 + (tower.getLevel() * 48)
    set s.feedback_damage  = 25
    
    set tower.userInt = s
    set tower.userInt2 = e
    set tower.userInt3 = 0
    set tower.userReal = 0
                    [values] => Array
                        (
                            [visible] => false
                            [icon] => 
                            [name] => 
                            [short_explain] => 
                            [long_explain] => 
                        )

                )

        )

    [abilities] => Array
        (
            [0] => Array
                (
                    [id] => @@0@@
                    [derivedFrom] => ANcl
                    [oeValues] => Array
                        (
                            [DataD1] => 0
                            [Buttonpos] => 1
                            [Art] => ReplaceableTextures\CommandButtons\BTNNetherTempest.blp
                            [DataF1] => unetherealform
                            [Untip] => Cycle Spellcraft Primary
                            [TargetArt] => Array
                                (
                                )

                            [hero] => 0
                            [CasterArt] => Array
                                (
                                )

                            [DataA1] => 0
                            [Cool1] => 10
                            [DataC1] => 1
                            [Name] => Cycle Spellcraft Primary: Spellstorm
                            [Ubertip] => Click to cycle between Spellcraft base spells.|n|nCurrent Primary: |cFFFF77FFSpellstorm|r|n|nCreates a storm at the target enemy's location that deals |cffffff801000|r spell damage per second to enemies in |cffffff80250|r area for |cffffff805|r seconds.|n|n|cffFF8000Level Bonus:|r|n|cffFFFF80+40|r spell damage
                            [Buttonpos1] => 1
                            [Casterattach] => Array
                                (
                                )

                            [EffectArt] => Array
                                (
                                )

                            [Tip] => Cycle Spellcraft Primary
                            [Unubertip] => Cycles between the base types of spell that Spellcraft will cast.
                            [Animnames] => spell
                            [Hotkey] => Array
                                (
                                )

                            [levels] => 1
                        )

                )

            [1] => Array
                (
                    [id] => @@1@@
                    [derivedFrom] => ANcl
                    [oeValues] => Array
                        (
                            [DataD1] => 0
                            [Art] => ReplaceableTextures\CommandButtons\BTNFaerieFire.blp
                            [DataF1] => undefend
                            [Untip] => Cycle Spellcraft Secondary
                            [TargetArt] => Array
                                (
                                )

                            [hero] => 0
                            [CasterArt] => Array
                                (
                                )

                            [DataA1] => 0
                            [Cool1] => 10
                            [DataC1] => 1
                            [Name] => Cycle Spellcraft Secondary: Destabilize
                            [Ubertip] => Click to cycle between secondary Spellcraft effects.|n|nCurrent Secondary: |cFFFF77FFDestabilize|r|n|nEnemies hit by Spellcraft take |cffffff8025%|r increased attack and spell damage for |cffffff803|r seconds.
                            [Buttonpos1] => 1
                            [Casterattach] => Array
                                (
                                )

                            [EffectArt] => Array
                                (
                                )

                            [Tip] => Cycle Spellcraft Secondary
                            [Unubertip] => Cycles between the secondary effects that Spellcraft can inflict.
                            [Animnames] => spell
                            [Hotkey] => Array
                                (
                                )

                            [levels] => 1
                        )

                )

            [2] => Array
                (
                    [id] => @@2@@
                    [derivedFrom] => ANcl
                    [oeValues] => Array
                        (
                            [DataD1] => 0
                            [Buttonpos] => 1
                            [Art] => ReplaceableTextures\CommandButtons\BTNStarfire.blp
                            [DataF1] => unetherealform
                            [Untip] => Cycle Spellcraft Primary
                            [TargetArt] => Array
                                (
                                )

                            [hero] => 0
                            [CasterArt] => Array
                                (
                                )

                            [DataA1] => 0
                            [Cool1] => 10
                            [DataC1] => 1
                            [Name] => Cycle Spellcraft Primary: Barrage
                            [Ubertip] => Click to cycle between Spellcraft base spells.|n|nCurrent Primary: |cFFFF77FFBarrage|r|n|nLaunch |cffffff805|r projectiles that land randomly in |cffffff80250|r range of the target, each dealing |cffffff801000|r spell damage in |cffffff80100|r area.|n|n|cffFF8000Level Bonus:|r|n|cffFFFF80+40|r spell damage
                            [Buttonpos1] => 1
                            [Casterattach] => Array
                                (
                                )

                            [EffectArt] => Array
                                (
                                )

                            [Tip] => Cycle Spellcraft Primary
                            [Unubertip] => Cycles between the base types of spell that Spellcraft will cast.
                            [Animnames] => spell
                            [Hotkey] => Array
                                (
                                )

                            [levels] => 1
                        )

                )

            [3] => Array
                (
                    [id] => @@3@@
                    [derivedFrom] => ANcl
                    [oeValues] => Array
                        (
                            [DataD1] => 0
                            [Art] => ReplaceableTextures\CommandButtons\BTNFeedBack.blp
                            [DataF1] => undefend
                            [Untip] => Cycle Spellcraft Secondary
                            [TargetArt] => Array
                                (
                                )

                            [hero] => 0
                            [CasterArt] => Array
                                (
                                )

                            [DataA1] => 0
                            [Cool1] => 10
                            [DataC1] => 1
                            [Name] => Cycle Spellcraft Secondary: Feedback
                            [Ubertip] => Click to cycle between secondary Spellcraft effects.|n|nCurrent Secondary: |cFFFF77FFFeedback|r|n|nEnemies hit by Spellcraft have up to |cffffff8015|r mana burnt, dealing |cffffff8025|r spell damage per point of mana removed.
                            [Buttonpos1] => 1
                            [Casterattach] => Array
                                (
                                )

                            [EffectArt] => Array
                                (
                                )

                            [Tip] => Cycle Spellcraft Secondary
                            [Unubertip] => Cycles between the secondary effects that Spellcraft can inflict.
                            [Animnames] => spell
                            [Hotkey] => Array
                                (
                                )

                            [levels] => 1
                        )

                )

            [4] => Array
                (
                    [id] => @@4@@
                    [derivedFrom] => ANcl
                    [oeValues] => Array
                        (
                            [DataD1] => 0
                            [Art] => ReplaceableTextures\CommandButtons\BTNBlink.blp
                            [DataF1] => undefend
                            [Untip] => Cycle Spellcraft Secondary
                            [TargetArt] => Array
                                (
                                )

                            [hero] => 0
                            [CasterArt] => Array
                                (
                                )

                            [DataA1] => 0
                            [Cool1] => 10
                            [DataC1] => 1
                            [Name] => Cycle Spellcraft Secondary: Echo
                            [Ubertip] => Click to cycle between secondary Spellcraft effects.|n|nCurrent Secondary: |cFFFF77FFEcho|r|n|nEnemies hit by Spellcraft take |cffffff805%|r of the base spell damage dealt per second for |cffffff805|r seconds. This effect can stack.
                            [Buttonpos1] => 1
                            [Casterattach] => Array
                                (
                                )

                            [EffectArt] => Array
                                (
                                )

                            [Tip] => Cycle Spellcraft Secondary
                            [Unubertip] => Cycles between the secondary effects that Spellcraft can inflict.
                            [Animnames] => spell
                            [Hotkey] => Array
                                (
                                )

                            [levels] => 1
                        )

                )

            [5] => Array
                (
                    [id] => @@5@@
                    [derivedFrom] => ANcl
                    [oeValues] => Array
                        (
                            [DataD1] => 0
                            [Art] => ReplaceableTextures\CommandButtons\BTNStun.blp
                            [DataF1] => undefend
                            [Untip] => Cycle Spellcraft Secondary
                            [TargetArt] => Array
                                (
                                )

                            [hero] => 0
                            [CasterArt] => Array
                                (
                                )

                            [DataA1] => 0
                            [Cool1] => 10
                            [DataC1] => 1
                            [Name] => Cycle Spellcraft Secondary: Concussive
                            [Ubertip] => Click to cycle between secondary Spellcraft effects.|n|nCurrent Secondary: |cFFFF77FFConcussive|r|n|nEnemies hit by Spellcraft have a |cffffff8020%|r chance to be stunned for |cffffff800.5|r seconds.
                            [Buttonpos1] => 1
                            [Casterattach] => Array
                                (
                                )

                            [EffectArt] => Array
                                (
                                )

                            [Tip] => Cycle Spellcraft Secondary
                            [Unubertip] => Cycles between the secondary effects that Spellcraft can inflict.
                            [Animnames] => spell
                            [Hotkey] => Array
                                (
                                )

                            [levels] => 1
                        )

                )

            [6] => Array
                (
                    [id] => @@6@@
                    [derivedFrom] => AHbz
                    [oeValues] => Array
                        (
                            [Cost1] => 0
                            [Rng1] => 99999
                            [EfctID1] => @@13@@
                            [DataD1] => 0
                            [Art] => ReplaceableTextures\CommandButtons\BTNNetherTempest.blp
                            [DataF1] => 99999
                            [hero] => 0
                            [BuffID1] => @@10@@,@@9@@
                            [Cool1] => 1
                            [DataA1] => 5
                            [Area1] => 250
                            [DataB1] => 1
                            [Name] => Spellstorm
                            [Ubertip] => Array
                                (
                                )

                            [Tip] => Array
                                (
                                )

                            [levels] => 1
                        )

                )

            [7] => Array
                (
                    [id] => @@7@@
                    [derivedFrom] => ANcl
                    [oeValues] => Array
                        (
                            [DataD1] => 0
                            [Buttonpos] => 1
                            [Art] => ReplaceableTextures\CommandButtons\BTNArcane Missile Barrage.blp
                            [DataF1] => unetherealform
                            [Untip] => Cycle Spellcraft Primary
                            [TargetArt] => Array
                                (
                                )

                            [hero] => 0
                            [CasterArt] => Array
                                (
                                )

                            [DataA1] => 0
                            [Cool1] => 10
                            [DataC1] => 1
                            [Name] => Cycle Spellcraft Primary: Tempest
                            [Ubertip] => Click to cycle between Spellcraft base spells.|n|nCurrent Primary: |cFFFF77FFTempest|r|n|nApplies a debuff which deals |cffffff801500|r spell damage to the target and one other enemy in |cffffff80450|r range every second for |cffffff806|r seconds. If the target dies, the debuff jumps to a nearby enemy.|n|n|cffFF8000Level Bonus:|r|n|cffFFFF80+60|r spell damage
                            [Buttonpos1] => 1
                            [Casterattach] => Array
                                (
                                )

                            [EffectArt] => Array
                                (
                                )

                            [Tip] => Cycle Spellcraft Primary
                            [Unubertip] => Cycles between the base types of spell that Spellcraft will cast.
                            [Animnames] => spell
                            [Hotkey] => Array
                                (
                                )

                            [levels] => 1
                        )

                )

            [8] => Array
                (
                    [id] => @@8@@
                    [derivedFrom] => ANcl
                    [oeValues] => Array
                        (
                            [DataD1] => 0
                            [Buttonpos] => 1
                            [Art] => ReplaceableTextures\CommandButtons\BTNThunderLizardEgg.blp
                            [DataF1] => unetherealform
                            [Untip] => Cycle Spellcraft Primary
                            [TargetArt] => Array
                                (
                                )

                            [hero] => 0
                            [CasterArt] => Array
                                (
                                )

                            [DataA1] => 0
                            [Cool1] => 10
                            [DataC1] => 1
                            [Name] => Cycle Spellcraft Primary: Summon Familiar
                            [Ubertip] => Click to cycle between Spellcraft base spells.|n|nCurrent Primary: |cFFFF77FFSummon Familiar|r|n|nSummons a familiar that will fly around, occasionally attacking random enemies. Deals |cffffff801200|r spell damage on attack and lasts for |cffffff804|r attacks.|n|n|cffFF8000Level Bonus:|r|n|cffFFFF80+48|r spell damage
                            [Buttonpos1] => 1
                            [Casterattach] => Array
                                (
                                )

                            [EffectArt] => Array
                                (
                                )

                            [Tip] => Cycle Spellcraft Primary
                            [Unubertip] => Cycles between the base types of spell that Spellcraft will cast.
                            [Animnames] => spell
                            [Hotkey] => Array
                                (
                                )

                            [levels] => 1
                        )

                )

        )

    [buffs] => Array
        (
            [0] => Array
                (
                    [id] => @@9@@
                    [derivedFrom] => BNrf
                    [oeValues] => Array
                        (
                            [EditorName] => Spellstorm (Caster)
                            [Buffart] => Array
                                (
                                )

                        )

                )

            [1] => Array
                (
                    [id] => @@10@@
                    [derivedFrom] => BNrd
                    [oeValues] => Array
                        (
                            [Buffubertip] => This unit is being damaged by Spellstorm.
                            [TargetArt] => Array
                                (
                                )

                            [Bufftip] => Spellstorm
                            [Buffart] => ReplaceableTextures\CommandButtons\BTNManaFlare.blp
                        )

                )

            [2] => Array
                (
                    [id] => @@11@@
                    [derivedFrom] => BNrd
                    [oeValues] => Array
                        (
                            [Targetattach] => origin
                            [Buffubertip] => Taking increased attack and spell damage.
                            [TargetArt] => war3mapImported\BanishTargetArcane.mdx
                            [Bufftip] => Destabilize
                            [Buffart] => ReplaceableTextures\CommandButtons\BTNFaerieFire.blp
                        )

                )

            [3] => Array
                (
                    [id] => @@12@@
                    [derivedFrom] => BNrd
                    [oeValues] => Array
                        (
                            [Targetattach] => chest
                            [Buffubertip] => Taking spell damage over time.
                            [TargetArt] => war3mapImported\ImmolationArcaneDamage.mdx
                            [Bufftip] => Spellcraft Echo
                            [Buffart] => ReplaceableTextures\CommandButtons\BTNBlink.blp
                        )

                )

            [4] => Array
                (
                    [id] => @@13@@
                    [derivedFrom] => XErf
                    [oeValues] => Array
                        (
                            [EditorName] => Spellstorm (Effect)
                            [Effectsoundlooped] => Array
                                (
                                )

                            [EffectArt] => war3mapImported\BoltImpactArcane.mdx
                            [Effectsound] => Array
                                (
                                )

                            [Buffart] => Array
                                (
                                )

                        )

                )

            [5] => Array
                (
                    [id] => @@14@@
                    [derivedFrom] => BNrd
                    [oeValues] => Array
                        (
                            [Targetattach] => origin
                            [Buffubertip] => Taking spell damage over time.
                            [TargetArt] => war3mapImported\BanishTargetArcane.mdx
                            [Bufftip] => Spellcraft: Tempest
                            [Buffart] => ReplaceableTextures\CommandButtons\BTNArcane Missile Barrage.blp
                        )

                )

        )

    [units] => Array
        (
        )

    [references] => Array
        (
            [0] => Array
                (
                    [export] => true
                    [category] => global
                    [typ] => MultiboardValues
                    [name] => ashbringer_spellcraft_mana
                )

        )

    [lightning] => Array
        (
        )

)