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

            [Art] => ReplaceableTextures\CommandButtons\BTNBloodMage2.blp
            [turnRate] => 3
            [dmgplus1] => 4259
            [bldtm] => 1
            [goldcost] => 4750
            [unitSound] => Kael
            [sides1] => 1
            [manaN] => 2000
            [acquire] => 1000
            [upgrades] => Array
                (
                )

            [Upgrade] => Array
                (
                )

            [Name] => Invoker
            [weapTp1] => missile
            [impactZ] => 60
            [file] => units\human\HeroBloodElf\HeroBloodElf.mdl
            [MissileHoming] => 1
            [uberSplat] => YTDG
            [Missilespeed] => 900
            [Missileart] => war3mapImported\AbsorbManaBirthMissileArcane.mdl
            [dice1] => 1
            [RngBuff1] => 250
            [regenMana] => 20
            [modelScale] => 0.7
            [rangeN1] => 1000
            [propWin] => 10
            [atkType1] => magic
            [cool1] => 3.4
            [Ubertip] => His age unknown to others, legend has it that he single-handedly defended the ancients from dire evils.
            [scaleBull] => 0
            [abilList] => Array
                (
                )

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

            [targs1] => Array
                (
                )

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

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

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

    [effects] => Array
        (
            [0] => Array
                (
                    [x] => -1.30405
                    [y] => -16.352
                    [z] => 25.6
                    [scale] => 0.1
                    [rot] => 4.71239
                    [file] => Doodads\Cityscape\Structures\City_ColumnDouble\City_ColumnDouble.mdl
                    [red] => 255
                    [green] => 255
                    [blue] => 255
                    [alpha] => 255
                    [pitch] => -1.57
                    [advanced] => false
                    [animation] => Array
                        (
                        )

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

            [1] => Array
                (
                    [x] => 15.0895
                    [y] => 8.17629
                    [z] => 25.6
                    [scale] => 0.1
                    [rot] => 0.523599
                    [file] => Doodads\Cityscape\Structures\City_ColumnDouble\City_ColumnDouble.mdl
                    [red] => 255
                    [green] => 255
                    [blue] => 255
                    [alpha] => 255
                    [pitch] => -1.57
                    [advanced] => false
                    [animation] => Array
                        (
                        )

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

            [2] => Array
                (
                    [x] => -15.3062
                    [y] => 9.96053
                    [z] => 25.6
                    [scale] => 0.1
                    [rot] => 2.61799
                    [file] => Doodads\Cityscape\Structures\City_ColumnDouble\City_ColumnDouble.mdl
                    [red] => 255
                    [green] => 255
                    [blue] => 255
                    [alpha] => 255
                    [pitch] => -1.57
                    [advanced] => false
                    [animation] => Array
                        (
                        )

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

            [3] => Array
                (
                    [x] => -46.969
                    [y] => 28.6774
                    [z] => -12.8
                    [scale] => 0.1
                    [rot] => 2.61799
                    [file] => Doodads\Cityscape\Structures\City_ColumnDouble\City_ColumnDouble.mdl
                    [red] => 255
                    [green] => 255
                    [blue] => 255
                    [alpha] => 255
                    [pitch] => 0
                    [advanced] => false
                    [animation] => Array
                        (
                        )

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

            [4] => Array
                (
                    [x] => -1.06578
                    [y] => -52.4858
                    [z] => -12.8
                    [scale] => 0.1
                    [rot] => 4.71239
                    [file] => Doodads\Cityscape\Structures\City_ColumnDouble\City_ColumnDouble.mdl
                    [red] => 255
                    [green] => 255
                    [blue] => 255
                    [alpha] => 255
                    [pitch] => 0
                    [advanced] => false
                    [animation] => Array
                        (
                        )

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

            [5] => Array
                (
                    [x] => 47.2392
                    [y] => 26.8417
                    [z] => -12.8
                    [scale] => 0.1
                    [rot] => 0.523599
                    [file] => Doodads\Cityscape\Structures\City_ColumnDouble\City_ColumnDouble.mdl
                    [red] => 255
                    [green] => 255
                    [blue] => 255
                    [alpha] => 255
                    [pitch] => 0
                    [advanced] => false
                    [animation] => Array
                        (
                        )

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

            [6] => Array
                (
                    [x] => -21.156
                    [y] => 27.9213
                    [z] => 25.6
                    [scale] => 0.1
                    [rot] => 4.18879
                    [file] => Doodads\Cityscape\Structures\City_ColumnDouble\City_ColumnDouble.mdl
                    [red] => 255
                    [green] => 255
                    [blue] => 255
                    [alpha] => 255
                    [pitch] => -1.57
                    [advanced] => false
                    [animation] => Array
                        (
                        )

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

            [7] => Array
                (
                    [x] => 13.2516
                    [y] => -28.2487
                    [z] => 25.6
                    [scale] => 0.1
                    [rot] => 3.14159
                    [file] => Doodads\Cityscape\Structures\City_ColumnDouble\City_ColumnDouble.mdl
                    [red] => 255
                    [green] => 255
                    [blue] => 255
                    [alpha] => 255
                    [pitch] => -1.57
                    [advanced] => false
                    [animation] => Array
                        (
                        )

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

            [8] => Array
                (
                    [x] => -13.8693
                    [y] => -30.2573
                    [z] => 25.6
                    [scale] => 0.1
                    [rot] => 0
                    [file] => Doodads\Cityscape\Structures\City_ColumnDouble\City_ColumnDouble.mdl
                    [red] => 255
                    [green] => 255
                    [blue] => 255
                    [alpha] => 255
                    [pitch] => -1.57
                    [advanced] => false
                    [animation] => Array
                        (
                        )

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

            [9] => Array
                (
                    [x] => 18.6178
                    [y] => 27.8731
                    [z] => 25.6
                    [scale] => 0.1
                    [rot] => 5.23599
                    [file] => Doodads\Cityscape\Structures\City_ColumnDouble\City_ColumnDouble.mdl
                    [red] => 255
                    [green] => 255
                    [blue] => 255
                    [alpha] => 255
                    [pitch] => -1.57
                    [advanced] => false
                    [animation] => Array
                        (
                        )

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

            [10] => Array
                (
                    [x] => 34.581
                    [y] => 4.33188
                    [z] => 25.6
                    [scale] => 0.1
                    [rot] => 2.10825
                    [file] => Doodads\Cityscape\Structures\City_ColumnDouble\City_ColumnDouble.mdl
                    [red] => 255
                    [green] => 255
                    [blue] => 255
                    [alpha] => 255
                    [pitch] => -1.57
                    [advanced] => false
                    [animation] => Array
                        (
                        )

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

            [11] => Array
                (
                    [x] => -32.8489
                    [y] => 3.88936
                    [z] => 25.6
                    [scale] => 0.1
                    [rot] => 1.0472
                    [file] => Doodads\Cityscape\Structures\City_ColumnDouble\City_ColumnDouble.mdl
                    [red] => 255
                    [green] => 255
                    [blue] => 255
                    [alpha] => 255
                    [pitch] => -1.57
                    [advanced] => false
                    [animation] => Array
                        (
                        )

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

            [12] => Array
                (
                    [x] => -0.681851
                    [y] => -9.82756
                    [z] => -12.8
                    [scale] => 0.1
                    [rot] => 4.71239
                    [file] => Doodads\Cityscape\Structures\City_ColumnDouble\City_ColumnDouble.mdl
                    [red] => 255
                    [green] => 255
                    [blue] => 255
                    [alpha] => 255
                    [pitch] => 0
                    [advanced] => false
                    [animation] => Array
                        (
                        )

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

            [13] => Array
                (
                    [x] => 10.7402
                    [y] => 6.19242
                    [z] => -12.8
                    [scale] => 0.1
                    [rot] => 0.523599
                    [file] => Doodads\Cityscape\Structures\City_ColumnDouble\City_ColumnDouble.mdl
                    [red] => 255
                    [green] => 255
                    [blue] => 255
                    [alpha] => 255
                    [pitch] => 0
                    [advanced] => false
                    [animation] => Array
                        (
                        )

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

            [14] => Array
                (
                    [x] => -9.06055
                    [y] => 8.0297
                    [z] => -12.8
                    [scale] => 0.1
                    [rot] => 2.61799
                    [file] => Doodads\Cityscape\Structures\City_ColumnDouble\City_ColumnDouble.mdl
                    [red] => 255
                    [green] => 255
                    [blue] => 255
                    [alpha] => 255
                    [pitch] => 0
                    [advanced] => false
                    [animation] => Array
                        (
                        )

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

            [15] => Array
                (
                    [x] => 23.6988
                    [y] => -30.7246
                    [z] => -12.8
                    [scale] => 0.1
                    [rot] => 0
                    [file] => Doodads\Cityscape\Structures\City_ColumnDouble\City_ColumnDouble.mdl
                    [red] => 255
                    [green] => 255
                    [blue] => 255
                    [alpha] => 255
                    [pitch] => 0
                    [advanced] => false
                    [animation] => Array
                        (
                        )

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

            [16] => Array
                (
                    [x] => 36.6362
                    [y] => -4.21724
                    [z] => -12.8
                    [scale] => 0.1
                    [rot] => 5.23599
                    [file] => Doodads\Cityscape\Structures\City_ColumnDouble\City_ColumnDouble.mdl
                    [red] => 255
                    [green] => 255
                    [blue] => 255
                    [alpha] => 255
                    [pitch] => 0
                    [advanced] => false
                    [animation] => Array
                        (
                        )

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

            [17] => Array
                (
                    [x] => 15.2369
                    [y] => 36.9777
                    [z] => -12.8
                    [scale] => 0.1
                    [rot] => 2.0944
                    [file] => Doodads\Cityscape\Structures\City_ColumnDouble\City_ColumnDouble.mdl
                    [red] => 255
                    [green] => 255
                    [blue] => 255
                    [alpha] => 255
                    [pitch] => 0
                    [advanced] => false
                    [animation] => Array
                        (
                        )

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

            [18] => Array
                (
                    [x] => -23.6734
                    [y] => -28.0009
                    [z] => -12.8
                    [scale] => 0.1
                    [rot] => 3.14159
                    [file] => Doodads\Cityscape\Structures\City_ColumnDouble\City_ColumnDouble.mdl
                    [red] => 255
                    [green] => 255
                    [blue] => 255
                    [alpha] => 255
                    [pitch] => 0
                    [advanced] => false
                    [animation] => Array
                        (
                        )

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

            [19] => Array
                (
                    [x] => -40.5511
                    [y] => -4.32753
                    [z] => -12.8
                    [scale] => 0.1
                    [rot] => 4.18879
                    [file] => Doodads\Cityscape\Structures\City_ColumnDouble\City_ColumnDouble.mdl
                    [red] => 255
                    [green] => 255
                    [blue] => 255
                    [alpha] => 255
                    [pitch] => 0
                    [advanced] => false
                    [animation] => Array
                        (
                        )

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

            [20] => Array
                (
                    [x] => -14.3424
                    [y] => 36.3392
                    [z] => -12.8
                    [scale] => 0.1
                    [rot] => 1.0472
                    [file] => Doodads\Cityscape\Structures\City_ColumnDouble\City_ColumnDouble.mdl
                    [red] => 255
                    [green] => 255
                    [blue] => 255
                    [alpha] => 255
                    [pitch] => 0
                    [advanced] => false
                    [animation] => Array
                        (
                        )

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

            [21] => Array
                (
                    [x] => -28.7113
                    [y] => 14.5753
                    [z] => 0
                    [scale] => 0.15
                    [rot] => 1.68451
                    [file] => Doodads\Cityscape\Props\FountainRuined\FountainRuined.mdl
                    [red] => 255
                    [green] => 255
                    [blue] => 255
                    [alpha] => 255
                    [pitch] => 0
                    [advanced] => false
                    [animation] => Array
                        (
                        )

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

            [22] => Array
                (
                    [x] => 26.3174
                    [y] => 13.1647
                    [z] => 0
                    [scale] => 0.15
                    [rot] => 1.68451
                    [file] => Doodads\Cityscape\Props\FountainRuined\FountainRuined.mdl
                    [red] => 255
                    [green] => 255
                    [blue] => 255
                    [alpha] => 255
                    [pitch] => 0
                    [advanced] => false
                    [animation] => Array
                        (
                        )

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

            [23] => Array
                (
                    [x] => -1.37022
                    [y] => -33.098
                    [z] => 0
                    [scale] => 0.15
                    [rot] => 1.68451
                    [file] => Doodads\Cityscape\Props\FountainRuined\FountainRuined.mdl
                    [red] => 255
                    [green] => 255
                    [blue] => 255
                    [alpha] => 255
                    [pitch] => 0
                    [advanced] => false
                    [animation] => Array
                        (
                        )

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

            [24] => Array
                (
                    [x] => -30.6876
                    [y] => 12.4676
                    [z] => 19.2
                    [scale] => 0.85
                    [rot] => 6.12856
                    [file] => Abilities\Weapons\FarseerMissile\FarseerMissile.mdl
                    [red] => 85
                    [green] => 85
                    [blue] => 255
                    [alpha] => 255
                    [pitch] => 0
                    [advanced] => false
                    [animation] => Array
                        (
                        )

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

            [25] => Array
                (
                    [x] => 26.6275
                    [y] => 11.7393
                    [z] => 12.8
                    [scale] => 0.85
                    [rot] => 2.26893
                    [file] => Abilities\Weapons\FireBallMissile\FireBallMissile.mdl
                    [red] => 255
                    [green] => 255
                    [blue] => 255
                    [alpha] => 255
                    [pitch] => -4.71
                    [advanced] => false
                    [animation] => Array
                        (
                        )

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

            [26] => Array
                (
                    [x] => -1.41077
                    [y] => -34.3617
                    [z] => 6.4
                    [scale] => 0.75
                    [rot] => 5.65487
                    [file] => Abilities\Weapons\LichMissile\LichMissile.mdl
                    [red] => 255
                    [green] => 255
                    [blue] => 255
                    [alpha] => 255
                    [pitch] => -4.71
                    [advanced] => false
                    [animation] => Array
                        (
                        )

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

            [27] => Array
                (
                    [x] => -1.91886
                    [y] => -34.2725
                    [z] => 19.2
                    [scale] => 1.05
                    [rot] => 2.3562
                    [file] => war3mapImported\GeneralAuraTargetWhite.mdl
                    [red] => 155
                    [green] => 155
                    [blue] => 255
                    [alpha] => 255
                    [pitch] => 0
                    [advanced] => false
                    [animation] => Array
                        (
                        )

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

            [28] => Array
                (
                    [x] => 26.7061
                    [y] => 14.8259
                    [z] => 19.2
                    [scale] => 1.05
                    [rot] => 0.802852
                    [file] => war3mapImported\GeneralAuraTargetWhite.mdl
                    [red] => 255
                    [green] => 115
                    [blue] => 1
                    [alpha] => 255
                    [pitch] => 0
                    [advanced] => false
                    [animation] => Array
                        (
                        )

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

            [29] => Array
                (
                    [x] => -31.1529
                    [y] => 14.9239
                    [z] => 19.2
                    [scale] => 1.05
                    [rot] => 2.98451
                    [file] => war3mapImported\GeneralAuraTargetWhite.mdl
                    [red] => 15
                    [green] => 15
                    [blue] => 255
                    [alpha] => 255
                    [pitch] => 0
                    [advanced] => false
                    [animation] => Array
                        (
                        )

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

            [30] => Array
                (
                    [x] => -29.1784
                    [y] => 14.4767
                    [z] => -6.4
                    [scale] => 1.05
                    [rot] => 3.68265
                    [file] => war3mapImported\GeneralAuraTargetWhite.mdl
                    [red] => 15
                    [green] => 15
                    [blue] => 255
                    [alpha] => 255
                    [pitch] => 0
                    [advanced] => false
                    [animation] => Array
                        (
                        )

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

            [31] => Array
                (
                    [x] => -2.34695
                    [y] => -35.3685
                    [z] => -6.4
                    [scale] => 1
                    [rot] => 6.23083
                    [file] => war3mapImported\GeneralAuraTargetWhite.mdl
                    [red] => 155
                    [green] => 155
                    [blue] => 255
                    [alpha] => 255
                    [pitch] => 0
                    [advanced] => false
                    [animation] => Array
                        (
                        )

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

            [32] => Array
                (
                    [x] => 27.9259
                    [y] => 11.7078
                    [z] => -6.4
                    [scale] => 1.15
                    [rot] => 4.11898
                    [file] => war3mapImported\GeneralAuraTargetWhite.mdl
                    [red] => 255
                    [green] => 115
                    [blue] => 1
                    [alpha] => 255
                    [pitch] => 0
                    [advanced] => false
                    [animation] => Array
                        (
                        )

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

        )

    [dmgTable] => Array
        (
        )

    [triggers] => Array
        (
            [0] => Array
                (
                    [name] => Header
                    [code] => globals
        BuffType ashbringer_fire_buff
        BuffType ashbringer_frost_buff
        BuffType ashbringer_align_buff
        Cast ashbringer_sheepfall_cast
        ProjectileType ashbringer_fire_projectile
        ProjectileType ashbringer_frost_projectile
        ProjectileType ashbringer_lightning_projectile
    endglobals
    
    struct ashbringer_invoker
        integer count = 0
        integer array charges[3]
        integer fire = 0
        integer frost = 0
        integer light = 0
        integer array mods_a[3]
        real array mods_a_values[3]
        integer array mods_b[3]
        real array mods_b_values[3]
        Effect array effects[3]
        string array models[3]
        
        method init takes nothing returns nothing
            set .charges[0] = 0
            set .charges[1] = 0
            set .charges[2] = 0
                
            set .models[0] = "war3mapImported\\GlowingRunes8_np.mdx"
            set .models[1] = "war3mapImported\\GlowingRunes2_np.mdx"
            set .models[2] = "war3mapImported\\GlowingRunes4_np.mdx"
            
            set .mods_a[0] = MOD_SPELL_CRIT_CHANCE
            set .mods_a_values[0] = 0.05
            set .mods_b[0] = MOD_DMG_TO_BOSS
            set .mods_b_values[0] = 0.15
            
            set .mods_a[1] = MOD_DEBUFF_RESISTANCE
            set .mods_a_values[1] = 0.1
            set .mods_b[1] = MOD_DMG_TO_MASS
            set .mods_b_values[1] = 0.15
            
            set .mods_a[2] = MOD_MANA_REGEN_PERC
            set .mods_a_values[2] = 0.15
            set .mods_b[2] = MOD_DMG_TO_AIR
            set .mods_b_values[2] = 0.15
        endmethod
        
        method reset takes Tower tower returns nothing
            local integer i = 0
            
            loop
                exitwhen i > 2
                call tower.modifyProperty(.mods_a[.charges[i]], -.mods_a_values[.charges[i]])
                call tower.modifyProperty(.mods_b[.charges[i]], -.mods_b_values[.charges[i]])
                set i = i + 1
            endloop
            
            set .fire = 0
            set .frost = 0
            set .light = 0
            set .count = 0
            set .charges[0] = 0
            set .charges[1] = 0
            set .charges[2] = 0
            call .effects[0].destroy()
            call .effects[1].destroy()
            call .effects[2].destroy()
        endmethod
        
        method shift takes Tower tower returns nothing
            if .charges[0] == 0 then
                set .fire = .fire - 1
            elseif .charges[0] == 1 then
                set .frost = .frost - 1
            elseif .charges[0] == 2 then
                set .light = .light - 1
            endif
            
            call tower.modifyProperty(.mods_a[.charges[0]], -.mods_a_values[.charges[0]])
            call tower.modifyProperty(.mods_b[.charges[0]], -.mods_b_values[.charges[0]])
            
            call .effects[0].destroy()
            set .effects[0] = .effects[1]
            call .effects[0].setPosition(tower.getX()-40, tower.getY())
            set .effects[1] = .effects[2]
            call .effects[1].setPosition(tower.getX(), tower.getY())
            
            set .charges[0] = .charges[1]
            set .charges[1] = .charges[2]
            
            set .count = .count - 1
        endmethod
        
        method generate takes Tower tower, Unit target, real damage, integer element returns nothing
            local Projectile p
            local Playor pl = tower.getOwner()
            
            if element == -1 then
                set element = GetRandomInt(0, 2)
            endif
            
            if .count > 2 then
                call .shift(tower)
            endif
            
            set .charges[count] = element
            
            call tower.modifyProperty(.mods_a[element], .mods_a_values[element])
            call tower.modifyProperty(.mods_b[element], .mods_b_values[element])
            
            if element == 0 then
                set .effects[count] = Effect.createScaled(.models[element], tower.getX() - 55 + (count * 55), tower.getY(), 150, 270, 1.15)
                call pl.displaySmallFloatingText("Fire!", tower, 255, 83, 0, 35.0)
                set .fire = .fire + 1
                if target != 0 then
                    set p = Projectile.createFromUnitToUnit(ashbringer_fire_projectile, tower, 0.0, 0.0, tower, target, true, false, false)
                    set p.userReal = damage
                    call p.setScale(1.15)
                endif
            elseif element == 1 then
                set .effects[count] = Effect.createColored(.models[element], tower.getX() - 55 + (count * 55), tower.getY(), 150, 270, 1.15, 155, 155, 255, 255)
                call pl.displaySmallFloatingText("Frost!", tower, 170, 221, 255, 35.0)
                set .frost = .frost + 1
                if target != 0 then
                    set p = Projectile.createFromUnitToUnit(ashbringer_frost_projectile, tower, 0.0, 0.0, tower, target, true, false, false)
                    set p.userReal = damage
                    call p.setScale(1.3)
                endif
            else
                set .effects[count] = Effect.createColored(.models[element], tower.getX() - 55 + (count * 55), tower.getY(), 150, 270, 1.15, 105, 105, 255, 255)
                call pl.displaySmallFloatingText("Lightning!", tower, 102, 102, 255, 35.0)
                set .light = .light + 1
                if target != 0 then
                    call Effect.create("Abilities\\Weapons\\Bolt\\BoltImpact.mdl", target.getX(), target.getY(), target.getZ(), GetRandomReal(0,359.99)).setLifetime(3.0)
                    //call Effect.createSimpleOnUnit("Abilities\\Spells\\Orc\\LightningBolt\\LightningBoltMissile.mdl", target, "chest").destroy()
                    call Lightning.createFromUnitToUnit("CLPB", tower, target).setLifetime(0.3)
                    call tower.doSpellDamage(target, damage, tower.calcSpellCritNoBonus())
                endif
            endif
            
            set .count = .count + 1
        endmethod
        
        method invocation_fire_burst takes Tower tower, Unit target, real damage, real area_mult, real crit_mult returns nothing
            local real crit = tower.calcSpellCritNoBonus()
            local Iterate i
            local Unit next
            
            if crit > 1 then
                set crit = crit * crit_mult
            endif
            call Effect.createScaled("Abilities\\Spells\\Other\\Doom\\DoomDeath.mdl", target.getX(), target.getY(), target.getZ(), 0, 1 * area_mult).setLifetime(3)
            set i = Iterate.overUnitsInRangeOfUnit(tower, TARGET_TYPE_CREEPS, target, 200 * area_mult)
            loop
                set next = i.next()
                exitwhen next == 0
                call tower.doSpellDamage(next, damage * 2.0, crit)
                set ashbringer_fire_buff.apply(tower, next, 2).userReal = damage * 2.0 * 0.1
            endloop
        endmethod
        
        method invocation_frost_burst takes Tower tower, Unit target, real damage, real area_mult, real crit_mult returns nothing
            local real crit = tower.calcSpellCritNoBonus()
            local Iterate i
            local Unit next
            
            if crit > 1 then
                set crit = crit * crit_mult
            endif
            call Effect.createScaled("war3mapImported\\AnimateDeadTargetFrost.mdx", target.getX(), target.getY(), target.getZ(), 0, 1.3 * area_mult).setLifetime(3)
            set i = Iterate.overUnitsInRangeOfUnit(tower, TARGET_TYPE_CREEPS, target, 200 * area_mult)
            loop
                set next = i.next()
                exitwhen next == 0
                call tower.doSpellDamage(next, damage * 2.0, crit)
                call ashbringer_frost_buff.apply(tower, next, 2)
            endloop
        endmethod
        
        method invocation_lightning_burst takes Tower tower, Unit target, real damage, real area_mult, real crit_mult returns nothing
            local real crit = tower.calcSpellCritNoBonus()
            local Iterate i
            local Unit next
            
            if crit > 1 then
                set crit = crit * crit_mult
            endif
            call Effect.createScaled("Abilities\\Spells\\Human\\Thunderclap\\ThunderClapCaster.mdl", target.getX(), target.getY(), target.getZ(), 0, 1 * area_mult).setLifetime(3)
            set i = Iterate.overUnitsInRangeOfUnit(tower, TARGET_TYPE_CREEPS, target, 200 * area_mult)
            loop
                set next = i.next()
                exitwhen next == 0
                call tower.doSpellDamage(next, damage * 2.0, crit)
                call cb_stun.applyOnlyTimed(tower, next, 2)
            endloop
        endmethod
        
        method invocation_meteor takes Tower tower, Unit target, real damage, real area_mult, real crit_mult returns nothing
            local real crit = tower.calcSpellCritNoBonus()
            local Iterate i
            local Unit next
            local real x = target.getX()
            local real y = target.getY()
            
            if crit > 1 then
                set crit = crit * crit_mult
            endif
            //Abilities\\Spells\\Demon\\RainOfFire\\RainOfFireTarget.mdl
            call Effect.createScaled("war3mapImported\\InfernalBirthOrange.mdx", x, y, target.getZ(), 0, 1.2 * area_mult).setLifetime(3)
            call TriggerSleepAction(0.5)
            set i = Iterate.overUnitsInRange(tower, TARGET_TYPE_CREEPS, x, y, 300 * area_mult)
            loop
                set next = i.next()
                exitwhen next == 0
                call tower.doSpellDamage(next, damage * 4.0, crit)
                set ashbringer_fire_buff.apply(tower, next, 2).userReal = damage * 4.0 * 0.15
                call cb_stun.applyOnlyTimed(tower, next, 2)
            endloop
        endmethod
        
        method invocation_glaciate takes Tower tower, Unit target, real damage, real area_mult, real crit_mult returns nothing
            local real crit = tower.calcSpellCritNoBonus()
            local Iterate i
            local Unit next
            local real x = target.getX()
            local real y = target.getY()
            local integer count = 0
            
            if crit > 1 then
                set crit = crit * crit_mult
            endif
            
            loop
                call Effect.createScaled("Abilities\\Spells\\Undead\\FrostNova\\FrostNovaTarget.mdl", x, y, target.getZ(), 0, (1.2 + (count * 0.65)) * area_mult).setLifetime(2)
                set i = Iterate.overUnitsInRange(tower, TARGET_TYPE_CREEPS, x, y, (150 + (count * 75)) * area_mult)
                loop
                    set next = i.next()
                    exitwhen next == 0
                    call tower.doSpellDamage(next, damage * 1.5, crit)
                    call ashbringer_frost_buff.apply(tower, next, 3)
                endloop
                set count = count + 1
                exitwhen count == 3
                call TriggerSleepAction(0.5)
            endloop
        endmethod
        
        method invocation_ball_lightning takes Tower tower, Unit target, real damage, real area_mult, real crit_mult returns nothing
            local real crit = tower.calcSpellCritNoBonus()
            local Iterate i
            local Unit next
            local real x = target.getX()
            local real y = target.getY()
            local integer count = 0
            local Projectile p
            
            if crit > 1 then
                set crit = crit * crit_mult
            endif
            
            set p = Projectile.create(ashbringer_lightning_projectile, tower, 0, 0, tower.getX(), tower.getY(), 60, 270)
            call p.aimAtUnit(target, false, true, false)
            call p.setScale(1.75 * area_mult)
            set p.userReal = damage
            set p.userReal2 = crit
            set p.userReal3 = area_mult
        endmethod
        
        method consume takes Tower tower, Unit target, real damage returns nothing
            local real area_mult = 1
            local real crit_mult = 1
            local Playor pl = tower.getOwner()
            
            if .light > 0 then
                call tower.addMana(250)
            endif
            if .fire > 0 then
                set crit_mult = 1.25
            endif
            if .frost > 0 then
                set area_mult = 1.25
            endif
            
            if .fire == 2 then
                call pl.displaySmallFloatingText("Fire Burst!", tower, 255, 83, 0, 35.0)
                call .invocation_fire_burst(tower, target, damage, area_mult, crit_mult)
            elseif .frost == 2 then
                call pl.displaySmallFloatingText("Frost Burst!", tower, 170, 221, 255, 35.0)
                call .invocation_frost_burst(tower, target, damage, area_mult, crit_mult)
            elseif .light == 2 then
                call pl.displaySmallFloatingText("Lightning Burst!", tower, 102, 102, 255, 35.0)
                call .invocation_lightning_burst(tower, target, damage, area_mult, crit_mult)
            elseif .fire == 3 then
                call pl.displaySmallFloatingText("Meteor!", tower, 255, 83, 0, 35.0)
                call .invocation_meteor(tower, target, damage, area_mult, crit_mult)
            elseif .frost == 3 then
                call pl.displaySmallFloatingText("Glaciate!", tower, 170, 221, 255, 35.0)
                call .invocation_glaciate(tower, target, damage, area_mult, crit_mult)
            elseif .light == 3 then
                call pl.displaySmallFloatingText("Ball Lightning!", tower, 102, 102, 255, 35.0)
                call .invocation_ball_lightning(tower, target, damage, area_mult, crit_mult)
            elseif .fire == 1 and .frost == 1 and .light == 1 then
                call pl.displaySmallFloatingText("Elemental Alignment!", tower, 255, 255, 0, 35.0)
                call ashbringer_align_buff.apply(tower, tower, tower.getLevel())
            endif
            
            call .reset(tower)
        endmethod
    endstruct
    
    //@export
    function ashbringer_invocation_cast takes Tower tower, Unit target, real damage, integer element returns nothing
        local ashbringer_invoker ai = tower.userInt
        
        if ai.count >= 3 and target != 0 then
            call ai.consume(tower, target, damage)
        else
            call ai.generate(tower, target, damage, element)
        endif
    endfunction
    
    function ashbringer_fire_periodic takes Buff b returns nothing
        local Tower tower = b.getCaster()
        local real crit = tower.calcSpellCritNoBonus()
        
        if crit > 1 then
            set crit = crit * 1.25
        endif
        
        call tower.doSpellDamage(b.getBuffedUnit(), b.userReal, crit)
    endfunction
    
    function ashbringer_fire_hit takes Projectile p, Unit target returns nothing
        local Tower tower = p.getCaster()
        call tower.doSpellDamage(target, p.userReal, tower.calcSpellCritNoBonus())
    endfunction
    
    function ashbringer_frost_hit takes Projectile p, Unit target returns nothing
        local Tower tower = p.getCaster()
        call tower.doSpellDamage(target, p.userReal, tower.calcSpellCritNoBonus())
    endfunction
        
    function ashbringer_ball_lightning_periodic takes Projectile p returns nothing
        local Tower tower = p.getCaster()
        local Iterate i = Iterate.overUnitsInRange(tower, TARGET_TYPE_CREEPS, p.x, p.y, 300 * p.userReal3)
        local Unit next
        local Unit target = 0
        
        loop
            set next = i.nextRandom()
            exitwhen next == 0
            set target = next
        endloop
        if target != 0 then
            call tower.doSpellDamage(target, p.userReal * 2.0, p.userReal2)
            call Lightning.createFromPointToUnit("CLSB", p.x, p.y, 60, target).setLifetime(0.2)
            call Effect.createSimpleOnUnit("Abilities\\Weapons\\Bolt\\BoltImpact.mdl", target, "origin").setLifetime(3.0)
            call cb_stun.applyOnlyTimed(tower, next, 3)
        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
        local Modifier mod = Modifier.create()
        
        set mod = Modifier.create()
        set ashbringer_frost_buff = BuffType.create(5, 0, false)
        call ashbringer_frost_buff.setBuffIcon('@@3@@')
        call mod.addModification(MOD_MOVESPEED, 0, -0.1)
        call ashbringer_frost_buff.setBuffModifier(mod)
        
        set ashbringer_fire_buff = BuffType.create(5, 0, false)
        call ashbringer_fire_buff.setBuffIcon('@@4@@')
        call ashbringer_fire_buff.addPeriodicEvent(ashbringer_fire_periodic, 1)
        
        set ashbringer_align_buff = BuffType.create(10, 0, true)
        call ashbringer_align_buff.setBuffIcon('@@5@@')
        call mod.addModification(MOD_SPELL_DAMAGE_DEALT, 0.75, 0.03)
        call mod.addModification(MOD_SPELL_CRIT_DAMAGE, 0.75, 0.03)
        call ashbringer_align_buff.setBuffModifier(mod)
        
        set ashbringer_fire_projectile = ProjectileType.create("war3mapImported\\DemonHunterMissileOrange.mdx", 5.0, 1350)
        call ashbringer_fire_projectile.enableHoming(ashbringer_fire_hit, 0.0)
        
        set ashbringer_frost_projectile = ProjectileType.create("war3mapImported\\VolcanoMissileFrost.mdx", 5.0, 1350)
        call ashbringer_frost_projectile.enableHoming(ashbringer_frost_hit, 0.0)
        
        set ashbringer_lightning_projectile = ProjectileType.create("Abilities\\Weapons\\FarseerMissile\\FarseerMissile.mdl", 5.0, 325)
        call ashbringer_lightning_projectile.enablePeriodic(ashbringer_ball_lightning_periodic, 0.2)
    endfunction
                    [values] => Array
                        (
                            [visible] => true
                            [icon] => ReplaceableTextures\CommandButtons\BTNScatterRockets.blp
                            [name] => Elemental Alignment
                            [short_explain] => When Elemental Invocation consumes one of each charge, gain a powerful buff.
                            [long_explain] => When Elemental Invocation consumes one of each charge, the Invoker gains |cffFFFF80+75%|r spell damage and |cffFFFF80+x0.75|r spell crit damage for |cffFFFF8010|r seconds.|n|n|cffFF8000Level Bonus:|r|n|cffFFFF80+3%|r spell damage|n|cffFFFF80+x0.03|r spell crit damage
                        )

                )

            [1] => Array
                (
                    [name] => On Spell Cast
                    [code] => local integer ability_id = GetSpellAbilityId()
    
    if ability_id == '@@2@@' then
        call ashbringer_invocation_cast(tower, 0, 0, 0)
        call Effect.createSimpleOnUnit("Abilities\\Weapons\\FireBallMissile\\FireBallMissile.mdl", tower, "chest").destroy()
    elseif ability_id == '@@0@@' then
        call ashbringer_invocation_cast(tower, 0, 0, 1)
        call Effect.createSimpleOnUnit("Abilities\\Spells\\Other\\FrostBolt\\FrostBoltMissile.mdl", tower, "chest").destroy()
    elseif ability_id == '@@1@@' then
        call ashbringer_invocation_cast(tower, 0, 0, 2)
        call Effect.createSimpleOnUnit("Abilities\\Weapons\\FarseerMissile\\FarseerMissile.mdl", tower, "chest").destroy()
    endif
                    [values] => Array
                        (
                            [visible] => false
                            [icon] => 
                            [name] => 
                            [short_explain] => 
                            [long_explain] => 
                        )

                )

            [2] => Array
                (
                    [name] => On Tower Destruction
                    [code] => local ashbringer_invoker ai = ashbringer_invoker.create()
    
    call ai.destroy()
                    [values] => Array
                        (
                            [visible] => false
                            [icon] => 
                            [name] => 
                            [short_explain] => 
                            [long_explain] => 
                        )

                )

            [3] => Array
                (
                    [name] => Autocast
                    [code] => call ashbringer_invocation_cast(tower, Event.getTarget(), 25000 + (tower.getLevel() * 1000), -1)
                    [values] => Array
                        (
                            [AUTOCAST_cooldown] => 1
                            [AUTOCAST_autoRange] => 1000
                            [AUTOCAST_manacost] => 500
                            [icon] => ReplaceableTextures\CommandButtons\BTNEchooftheElements.blp
                            [AUTOCAST_range] => 1000
                            [AUTOCAST_targetType] => 0
                            [AUTOCAST_numBuffsBeforeIdle] => 0
                            [caster_art] => 
                            [long_explain] => Casts a random Fire, Frost or Lightning spell at a target enemy, dealing |cffFFFF8025000|r spell damage and generating an elemental charge matching the chosen spell. Each charge provides a passive effect based on its element. If the Invoker has |cffFFFF803|r charges, Elemental Invocation will instead consume the charges to cast a powerful spell which deals damage based on this ability's based spell damage.|n|nSee other abilities for elemental charge passive and invocation effects.|n|n|cffFF8000Level Bonus:|r|n|cffFFFF80+1000|r spell damage
                            [target_art] => 
                            [AUTOCAST_autocastType] => AC_TYPE_OFFENSIVE_UNIT
                            [AUTOCAST_buffType] => 0
                            [AUTOCAST_isExtended] => true
                            [name] => Elemental Invocation
                            [AUTOCAST_targetSelf] => false
                            [short_explain] => Deals spell damage to a target enemy and generates a random elemental charge. With |cffFFFF803|r charges, instead consume the charges to cast a powerful spell based on the charge consumed. The invoker has additional abilities to generate specific charges on demand and these abilities detail the possible effects of each charge.
                        )

                )

            [4] => Array
                (
                    [name] => On Tower Creation
                    [code] => local ashbringer_invoker ai = ashbringer_invoker.create()
    call SetUnitColor(tower.getUnit(), ConvertPlayerColor(9))
    
    call ai.init()
    
    call UnitAddAbility(tower.getUnit(), '@@2@@')
    call UnitAddAbility(tower.getUnit(), '@@0@@')
    call UnitAddAbility(tower.getUnit(), '@@1@@')
    
    set tower.userInt = ai
                    [values] => Array
                        (
                            [visible] => false
                            [icon] => 
                            [name] => 
                            [short_explain] => 
                            [long_explain] => 
                        )

                )

        )

    [abilities] => Array
        (
            [0] => Array
                (
                    [id] => @@0@@
                    [derivedFrom] => ANcl
                    [oeValues] => Array
                        (
                            [DataD1] => 0
                            [Art] => ReplaceableTextures\CommandButtons\BTNOrbOfFrost.blp
                            [DataF1] => undefend
                            [Untip] => Invocation: |cffaaddffFrost|r - |cffffcc00W|r
                            [TargetArt] => Array
                                (
                                )

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

                            [DataA1] => 0
                            [Cool1] => 10
                            [DataC1] => 1
                            [Name] => Invocation: Frost
                            [Ubertip] => Cast this spell to generate a |cffaaddffFrost|r charge. |cffFFFF80Cooldown:|r |cffFFFF0010 sec|r|n|n|cffff8000Passive Effects Per Charge:|r|n|cffffff80+10%|r debuff resistance|n|cffffff80+15%|r damage vs Mass|n|cffffff80+10%|r slow for |cffffff805|r seconds to enemies hit by Frost Burst and Glaciate|n|n|cffff8000Invocation Effects:|r|nAt least |cffffff801|r |cffaaddffFrost|r charge: Invocation has |cffffff8025%|r increased area of effect.|n|cffffff802|r |cffaaddffFrost|r charges: Invocation casts Frost Burst, dealing |cffffff80200%|r of invocation's damage to enemies in |cffffff80200|r area.|n|cffffff803|r |cffaaddffFrost|r charges: Invocation casts Glaciate, causing |cffffff803|r explosions that each deal |cffffff80150%|r of invocation's damage to enemies in |cffffff80150|r area. Damage and area increases with each explosion.
                            [Buttonpos1] => 1
                            [Casterattach] => Array
                                (
                                )

                            [EffectArt] => Array
                                (
                                )

                            [Tip] => Invocation: |cffaaddffFrost|r - |cffffcc00W|r
                            [Animnames] => spell
                            [Hotkey] => W
                            [levels] => 1
                        )

                )

            [1] => Array
                (
                    [id] => @@1@@
                    [derivedFrom] => ANcl
                    [oeValues] => Array
                        (
                            [DataD1] => 0
                            [Buttonpos] => 3
                            [Art] => ReplaceableTextures\CommandButtons\BTNOrbOfLightning.blp
                            [DataF1] => unimmolation
                            [Untip] => Invocation: |cff6666ffLightning|r - |cffffcc00E|r
                            [TargetArt] => Array
                                (
                                )

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

                            [DataA1] => 0
                            [Cool1] => 10
                            [DataC1] => 1
                            [Name] => Invocation: Lightning
                            [Ubertip] => Cast this spell to generate a |cff6666ffLightning|r charge. |cffFFFF80Cooldown:|r |cffFFFF0010 sec|r|n|n|cffff8000Passive Effects Per Charge:|r|n|cffffff80+15%|r mana regeneration|n|cffffff80+15%|r damage vs Air|n|cffffff80+1|r second stun to enemies hit by Lightning Burst and Ball Lightning|n|n|cffff8000Invocation Effects:|r|nAt least |cffffff801|r |cff6666ffLightning|r charge: Invocation refunds |cffffff80250|r mana.|n|cffffff802|r |cff6666ffLightning|r charges: Invocation casts Lightning Burst, dealing |cffffff80200%|r of invocation's damage to enemies in |cffffff80200|r area.|n|cffffff803|r |cff6666ffLightning|r charges: Invocation casts Ball Lightning, a slow moving orb which zaps a nearby enemy in |cffffff80300|r range every |cffffff800.2|r seconds for |cffffff80200%|r of invocation's damage.
                            [Buttonpos1] => 1
                            [Casterattach] => Array
                                (
                                )

                            [EffectArt] => Array
                                (
                                )

                            [Tip] => Invocation: |cff6666ffLightning|r - |cffffcc00E|r
                            [Animnames] => spell
                            [Hotkey] => E
                            [levels] => 1
                        )

                )

            [2] => Array
                (
                    [id] => @@2@@
                    [derivedFrom] => ANcl
                    [oeValues] => Array
                        (
                            [DataD1] => 0
                            [Buttonpos] => 1
                            [Art] => ReplaceableTextures\CommandButtons\BTNOrbOfFire.blp
                            [DataF1] => unetherealform
                            [Untip] => Invocation: |cffff5300Fire|r - |cffffcc00Q|r
                            [TargetArt] => Array
                                (
                                )

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

                            [DataA1] => 0
                            [Cool1] => 10
                            [DataC1] => 1
                            [Name] => Invocation: Fire
                            [Ubertip] => Cast this spell to generate a |cffff5300Fire|r charge. |cffFFFF80Cooldown:|r |cffFFFF0010 sec|r.|n|n|cffff8000Passive Effects Per Charge:|r|n|cffffff80+5%|r spell crit chance|n|cffffff80+15%|r damage vs Bosses|n|cffffff80+25%|r additional damage dealt over |cffffff805|r seconds for Fire Burst and Meteor|n|n|cffff8000Invocation Effects:|r|nAt least |cffffff801|r |cffff5300Fire|r charge: Invocation critical hits do |cffffff8025%|r more damage.|n|cffffff802|r |cffff5300Fire|r charges: Invocation casts Fire Burst, dealing |cffffff80200%|r of invocation's damage to enemies in |cffffff80200|r area.|n|cffffff803|r |cffff5300Fire|r charges: Invocation casts Meteor, dealing |cffffff80400%|r of invocation's damage to enemies in |cffffff80300|r area and stunning them for |cffffff802|r seconds.
                            [Buttonpos1] => 1
                            [Casterattach] => Array
                                (
                                )

                            [EffectArt] => Array
                                (
                                )

                            [Tip] => Invocation: |cffff5300Fire|r - |cffffcc00Q|r
                            [Animnames] => spell
                            [Hotkey] => Q
                            [levels] => 1
                        )

                )

        )

    [buffs] => Array
        (
            [0] => Array
                (
                    [id] => @@3@@
                    [derivedFrom] => BNrd
                    [oeValues] => Array
                        (
                            [Targetattach] => chest
                            [Buffubertip] => Reduced movement speed.
                            [TargetArt] => Abilities\Spells\Other\FrostDamage\FrostDamage.mdl
                            [Bufftip] => Frost Invocation
                            [Buffart] => ReplaceableTextures\CommandButtons\BTNOrbOfFrost.blp
                        )

                )

            [1] => Array
                (
                    [id] => @@4@@
                    [derivedFrom] => BNrd
                    [oeValues] => Array
                        (
                            [Targetattach] => origin
                            [Buffubertip] => Taking spell damage over time.
                            [TargetArt] => Abilities\Spells\Human\FlameStrike\FlameStrikeEmbers.mdl
                            [Bufftip] => Fire Invocation
                            [Buffart] => ReplaceableTextures\CommandButtons\BTNOrbOfFire.blp
                        )

                )

            [2] => Array
                (
                    [id] => @@5@@
                    [derivedFrom] => BNrd
                    [oeValues] => Array
                        (
                            [Targetattach] => sprite,first
                            [Targetattach1] => sprite,second
                            [Targetattach2] => sprite,third
                            [Buffubertip] => Increased spell damage and spell crit damage.
                            [TargetArt] => Abilities\Spells\Items\AIfb\AIfbTarget.mdl,Abilities\Spells\Items\AIob\AIobTarget.mdl,Abilities\Spells\Items\AIlb\AIlbTarget.mdl
                            [Targetattachcount] => 3
                            [Bufftip] => Elemental Alignment
                            [Buffart] => ReplaceableTextures\CommandButtons\BTNScatterRockets.blp
                        )

                )

        )

    [units] => Array
        (
        )

    [references] => Array
        (
        )

    [lightning] => Array
        (
        )

)