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

            [Art] => ReplaceableTextures\CommandButtons\BTNNetherTempest.blp
            [bldtm] => 1
            [dmgplus1] => 3197
            [goldcost] => 3400
            [unitSound] => ArcaneTower
            [sides1] => 1
            [manaN] => 150
            [launchZ] => 90
            [acquire] => 1000
            [upgrades] => Array
                (
                )

            [Upgrade] => Array
                (
                )

            [Name] => Arcane Tempest
            [red] => 205
            [weapTp1] => instant
            [MissileHoming] => 1
            [file] => Objects\InventoryItems\CrystalShard\CrystalShard.mdl
            [uberSplat] => YTDG
            [Missilespeed] => 5000
            [dice1] => 1
            [RngBuff1] => 250
            [regenMana] => 3
            [modelScale] => 1.1
            [rangeN1] => 1000
            [atkType1] => normal
            [cool1] => 1.8
            [Ubertip] => This extremely unstable artifact can barely be contained.
            [scaleBull] => 0
            [abilList] => Array
                (
                )

            [buildingShadow] => Array
                (
                )

            [targs1] => Array
                (
                )

            [weapsOn] => 1
        )

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

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

    [effects] => Array
        (
            [0] => Array
                (
                    [x] => -0.383064
                    [y] => 2.94636
                    [z] => -0.000000953674
                    [scale] => 0.41
                    [rot] => 0
                    [file] => Doodads\Terrain\DalaranMagicalPen\DalaranMagicalPen.mdl
                    [red] => 255
                    [green] => 85
                    [blue] => 255
                    [alpha] => 255
                    [pitch] => 0
                    [advanced] => false
                    [animation] => Array
                        (
                        )

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

            [1] => Array
                (
                    [x] => 45.8736
                    [y] => -45.3687
                    [z] => 0
                    [scale] => 0.29
                    [rot] => 2.3562
                    [file] => Doodads\Cityscape\Structures\City_ColumnSingle\City_ColumnSingle.mdl
                    [red] => 155
                    [green] => 55
                    [blue] => 255
                    [alpha] => 255
                    [pitch] => 0
                    [advanced] => false
                    [animation] => Array
                        (
                        )

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

            [2] => Array
                (
                    [x] => -45.7217
                    [y] => -44.4049
                    [z] => 0
                    [scale] => 0.29
                    [rot] => 0.785398
                    [file] => Doodads\Cityscape\Structures\City_ColumnSingle\City_ColumnSingle.mdl
                    [red] => 155
                    [green] => 55
                    [blue] => 255
                    [alpha] => 255
                    [pitch] => 0
                    [advanced] => false
                    [animation] => Array
                        (
                        )

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

            [3] => Array
                (
                    [x] => -44.3365
                    [y] => 44.5351
                    [z] => 0
                    [scale] => 0.29
                    [rot] => 2.3562
                    [file] => Doodads\Cityscape\Structures\City_ColumnSingle\City_ColumnSingle.mdl
                    [red] => 155
                    [green] => 55
                    [blue] => 255
                    [alpha] => 255
                    [pitch] => 0
                    [advanced] => false
                    [animation] => Array
                        (
                        )

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

            [4] => Array
                (
                    [x] => -0.777549
                    [y] => -17.5764
                    [z] => 0
                    [scale] => 0.12
                    [rot] => 1.5708
                    [file] => Doodads\Cityscape\Structures\City_ColumnSemiCircle\City_ColumnSemiCircle.mdl
                    [red] => 25
                    [green] => 5
                    [blue] => 55
                    [alpha] => 255
                    [pitch] => 0
                    [advanced] => false
                    [animation] => Array
                        (
                        )

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

            [5] => Array
                (
                    [x] => 0.35849
                    [y] => -0.714272
                    [z] => 96
                    [scale] => 1.3
                    [rot] => 4.8473
                    [file] => Abilities\Weapons\FarseerMissile\FarseerMissile.mdl
                    [red] => 255
                    [green] => 90
                    [blue] => 255
                    [alpha] => 255
                    [pitch] => 0
                    [advanced] => true
                    [animation] => stand
                    [aniSpeed] => 50
                    [pcolor] => 255
                )

            [6] => Array
                (
                    [x] => 2.34774
                    [y] => 5.24931
                    [z] => 0
                    [scale] => 0.8
                    [rot] => 4.71239
                    [file] => Abilities\Spells\Orc\Purge\PurgeBuffTarget.mdl
                    [red] => 155
                    [green] => 255
                    [blue] => 255
                    [alpha] => 255
                    [pitch] => 0
                    [advanced] => true
                    [animation] => stand
                    [aniSpeed] => 50
                    [pcolor] => 255
                )

            [7] => Array
                (
                    [x] => 0.153543
                    [y] => 16.8432
                    [z] => 0
                    [scale] => 0.12
                    [rot] => 4.71239
                    [file] => Doodads\Cityscape\Structures\City_ColumnSemiCircle\City_ColumnSemiCircle.mdl
                    [red] => 25
                    [green] => 5
                    [blue] => 55
                    [alpha] => 255
                    [pitch] => 0
                    [advanced] => false
                    [animation] => Array
                        (
                        )

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

            [8] => Array
                (
                    [x] => 44.875
                    [y] => 45.4689
                    [z] => 0
                    [scale] => 0.29
                    [rot] => 0.785398
                    [file] => Doodads\Cityscape\Structures\City_ColumnSingle\City_ColumnSingle.mdl
                    [red] => 155
                    [green] => 55
                    [blue] => 255
                    [alpha] => 255
                    [pitch] => 0
                    [advanced] => false
                    [animation] => Array
                        (
                        )

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

            [9] => Array
                (
                    [x] => 0.121866
                    [y] => 0.605091
                    [z] => 25.6
                    [scale] => 0.85
                    [rot] => 4.18879
                    [file] => Abilities\Spells\Orc\LightningShield\LightningShieldTarget.mdl
                    [red] => 255
                    [green] => 105
                    [blue] => 255
                    [alpha] => 255
                    [pitch] => 0
                    [advanced] => false
                    [animation] => Array
                        (
                        )

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

            [10] => Array
                (
                    [x] => -0.262973
                    [y] => 0.784644
                    [z] => 57.6
                    [scale] => 0.18
                    [rot] => 0.785398
                    [file] => Doodads\Cityscape\Structures\Archway1\Archway1.mdl
                    [red] => 155
                    [green] => 55
                    [blue] => 255
                    [alpha] => 255
                    [pitch] => 0
                    [advanced] => false
                    [animation] => Array
                        (
                        )

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

            [11] => Array
                (
                    [x] => -0.138763
                    [y] => 0.863313
                    [z] => 57.6
                    [scale] => 0.18
                    [rot] => 2.3562
                    [file] => Doodads\Cityscape\Structures\Archway1\Archway1.mdl
                    [red] => 155
                    [green] => 55
                    [blue] => 255
                    [alpha] => 255
                    [pitch] => 0
                    [advanced] => false
                    [animation] => Array
                        (
                        )

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

            [12] => Array
                (
                    [x] => -0.111835
                    [y] => 0.195259
                    [z] => 12.8
                    [scale] => 0.5
                    [rot] => 0
                    [file] => Abilities\Spells\Other\Tornado\TornadoElementalSmall.mdl
                    [red] => 155
                    [green] => 255
                    [blue] => 255
                    [alpha] => 255
                    [pitch] => 0
                    [advanced] => false
                    [animation] => stand walk
                    [aniSpeed] => 50
                    [pcolor] => 255
                )

            [13] => Array
                (
                    [x] => -0.122171
                    [y] => 1.63318
                    [z] => 44.8
                    [scale] => 0.41
                    [rot] => 0
                    [file] => Doodads\Terrain\DalaranMagicalPen\DalaranMagicalPen.mdl
                    [red] => 255
                    [green] => 85
                    [blue] => 255
                    [alpha] => 255
                    [pitch] => 0
                    [advanced] => false
                    [animation] => Array
                        (
                        )

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

        )

    [dmgTable] => Array
        (
        )

    [triggers] => Array
        (
            [0] => Array
                (
                    [name] => Header
                    [code] => globals
        BuffType ashbringer_attraction_buff
    endglobals
    
    function ashbringer_attraction_apply takes Tower tower, Creep target, integer stacks, Buff b returns nothing
        if b == 0 then
            set b = target.getBuffOfType(ashbringer_attraction_buff)
        endif
        
        if stacks>0 then
            if b != 0 then
                call b.setPower(b.getPower() + stacks)
            else
                set b = ashbringer_attraction_buff.apply(tower, target, 1)
            endif
        endif
    endfunction
    
    function ashbringer_attraction_tempest takes Tower tower, Creep target, integer max, boolean do_damage returns nothing
        local Buff b = target.getBuffOfType(ashbringer_attraction_buff)
        local Iterate i
        
        call Lightning.createFromPointToUnit("PZAP", tower.getX(), tower.getY(), 90, target).setLifetime(0.2)
        call Effect.createSimpleOnUnit("war3mapImported\\BoltImpactArcane.mdx", target, "chest").destroy()
        if do_damage then
            call tower.doAttackDamage(target, tower.getCurrentAttackDamageWithBonus() * (1 + (I2R(b.getPower()) * 0.01)), tower.calcAttackMulticrit(0,0,0))
        endif
        call ashbringer_attraction_apply(tower, target, 1, b)
        
        if b != 0 and max > 0 then
            if tower.calcChance(I2R(b.getPower()) * (0.03 + (tower.getLevel() * 0.0006))) then
                call TriggerSleepAction(0.1)
                if tower.getUID() == tower.userInt2 then
                    set i = Iterate.overUnitsInRangeOfCaster(tower, TARGET_TYPE_CREEPS, tower.getRange())
                    set target = i.nextRandom()
                    set max = max - 1
                    call ashbringer_attraction_tempest(tower, target, max, true)
                endif
            endif
        endif
    endfunction
    
    function ashbringer_attraction_ondeath takes Buff b returns nothing
        local Tower tower = b.getCaster()
        local Creep target = b.getBuffedUnit()
        local Iterate i = Iterate.overUnitsInRangeOfUnit(tower, TARGET_TYPE_CREEPS, target, 400 + (tower.getLevel() * 8))
        local integer count = i.count()
        local Creep next
        local integer stacks = b.getPower()
        local integer stacks_spare = 0
        local integer stacks_each = 0
        local integer applied = 0
        local real damage_per_stack = tower.getCurrentAttackDamageWithBonus() * (0.1 + (tower.getLevel() * 0.002))
        local Buff b2
        
        if stacks > 20 then
            set stacks = 20
        endif
        
        if stacks < count then
            set stacks_spare = stacks
        else
            set stacks_spare = ModuloInteger(stacks, count)
            set stacks_each = (stacks - stacks_spare) / count
        endif
        
        set next = i.next()
        loop
            exitwhen next==0
            if stacks_spare>0 then
                set applied = stacks_each + 1
                set stacks_spare = stacks_spare - 1
            else
                set applied = stacks_each
            endif
            set b2 = next.getBuffOfType(ashbringer_attraction_buff)
            call ashbringer_attraction_apply(tower, next, applied, b2)
            call tower.doAttackDamage(next, (applied * damage_per_stack) * (1 + (I2R(b2.getPower()) * 0.01)), tower.calcAttackMulticrit(0,0,0))
            call Effect.createSimpleOnUnit("war3mapImported\\AbsorbManaBirthMissileArcane.mdx", next, "chest").destroy()
            set next = i.next()
        endloop
    endfunction
    
    function ashbringer_surge_start takes Tower tower, Creep target returns nothing
        local Buff b
        local integer level = tower.getLevel()
        local Iterate i = Iterate.overUnitsInRangeOfCaster(tower, TARGET_TYPE_CREEPS, tower.getRange())
        local Unit next = i.next()
        local real damage = tower.getCurrentAttackDamageWithBonus() * (4.0 + (level * 0.08))
        local real chance_per_stack = 0.04 + (level * S2R("surge_chance_pl"))
        local Unit prev = target
        local boolean jump = true
        
        call tower.doAttackDamage(target, damage, tower.calcAttackMulticrit(0,0,0))
        call Lightning.createFromPointToUnit("PMBZ", tower.getX(), tower.getY(), 90, target).setLifetime(0.3)
        call Effect.createSimpleOnUnit("Abilities\\Weapons\\VoidWalkerMissile\\VoidWalkerMissile.mdl", target, "chest").destroy()
        
        loop
            exitwhen next==0
            if next == target then
            else
                set b = next.getBuffOfType(ashbringer_attraction_buff)
                
                if b!=0 then
                    if tower.calcChance(I2R(b.getPower())*chance_per_stack) then
                        call tower.doAttackDamage(next, damage, tower.calcAttackMulticrit(0,0,0))
                        call Lightning.createFromUnitToUnit("PMBZ", prev, next).setLifetime(0.3)
                        call Effect.createSimpleOnUnit("Abilities\\Weapons\\VoidWalkerMissile\\VoidWalkerMissile.mdl", next, "chest").destroy()
                        set prev = next
                    endif
                endif
            endif
            
            set next = i.nextRandom()
        endloop
    endfunction
    
    //Do not remove or rename this function!
    //Put your initialization tasks here, this function will be called on map init
    private function init takes nothing returns nothing
        set  ashbringer_attraction_buff = BuffType.create(-1, 0, false)
        call ashbringer_attraction_buff.setBuffIcon('@@0@@')
        call ashbringer_attraction_buff.addEventOnDeath(ashbringer_attraction_ondeath)
    endfunction
                    [values] => Array
                        (
                            [visible] => true
                            [icon] => ReplaceableTextures\CommandButtons\BTNPurge.blp
                            [name] => Arcane Attraction
                            [short_explain] => Hits apply a permanent debuff that increases damage taken by the Arcane Tempest.
                            [long_explain] => Attacks apply a stack of Arcane Attraction on hit, a permanent debuff that increases damage taken from the Arcane Tempest by |cffFFFF801%|r per stack. When an enemy dies, up to |cffFFFF8020|r stacks of Arcane Attraction on it will distribute evenly to enemies in |cffFFFF80400|r area, dealing |cffFFFF8010%|r attack damage per stack transferred.|n|n|cffFF8000Level Bonus:|r|n|cffFFFF80+8|r area|n|cffFFFF80+0.2%|r attack damage per stack
                        )

                )

            [1] => Array
                (
                    [name] => On Damage
                    [code] => local Unit target = Event.getTarget()
    local Buff b = target.getBuffOfType(ashbringer_attraction_buff)
    
    set Event.damage = Event.damage * (1 + (I2R(b.getPower()) * 0.01))
    
    if Event.isMainTarget() then
        if tower.userInt > 0 then
            set tower.userInt = tower.userInt - 1
            call ashbringer_surge_start(tower, target)
        endif
        call ashbringer_attraction_tempest(tower, target, 4, false)
    endif
                    [values] => Array
                        (
                            [ONDAMAGE_chance] => 1.0
                            [visible] => true
                            [icon] => ReplaceableTextures\CommandButtons\BTNFeedBack.blp
                            [name] => Unstable Tempest
                            [short_explain] => The tower's attacks have a chance to repeat based on number of Arcane Attraction stacks on the target.
                            [ONDAMAGE_chanceLevelAdd] => 0.0
                            [long_explain] => Each attack has a |cffFFFF803%|r chance per Arcane Attraction stack on the target to strike again at a random enemy in attack range. These extra attacks apply Arcane Attraction and can trigger this effect again up to a maximum of |cffFFFF804|r times.|n|n|cffFF8000Level Bonus:|r|n|cffFFFF80+0.06%|r chance per stack
                        )

                )

            [2] => Array
                (
                    [name] => Autocast
                    [code] => set tower.userInt = tower.userInt + 1
                    [values] => Array
                        (
                            [AUTOCAST_cooldown] => 4
                            [AUTOCAST_autoRange] => 1000.00
                            [AUTOCAST_manacost] => 100
                            [icon] => ReplaceableTextures\CommandButtons\BTNHeartOfAszune.blp
                            [AUTOCAST_range] => 1000.00
                            [AUTOCAST_targetType] => 0
                            [AUTOCAST_numBuffsBeforeIdle] => 0
                            [caster_art] => 
                            [long_explain] => On the next attack, unleash a chaotic beam of energy that deals |cffFFFF80400%|r attack damage to the target and then attempts to bounce to every other enemy within attack range. At each additional enemy, the chance to be hit is |cffFFFF804%|r per Arcane Attraction stack on them.|n|n|cffFF8000Level Bonus:|r|n|cffFFFF80+0.08%|r chance per stack|n|cffFFFF80+8%|r attack damage
                            [target_art] => 
                            [AUTOCAST_autocastType] => AC_TYPE_OFFENSIVE_IMMEDIATE
                            [AUTOCAST_buffType] => 0
                            [AUTOCAST_isExtended] => false
                            [name] => Chaotic Surge
                            [AUTOCAST_targetSelf] => false
                            [short_explain] => Unleash a beam that deals attack damage and chains to enemies in a large area based on Arcane Attraction stacks.
                        )

                )

            [3] => Array
                (
                    [name] => On Tower Creation
                    [code] => set tower.userInt = 0
    set tower.userInt2 = tower.getUID()
                    [values] => Array
                        (
                            [visible] => false
                            [icon] => 
                            [name] => 
                            [short_explain] => 
                            [long_explain] => 
                        )

                )

        )

    [abilities] => Array
        (
        )

    [buffs] => Array
        (
            [0] => Array
                (
                    [id] => @@0@@
                    [derivedFrom] => BHab
                    [oeValues] => Array
                        (
                            [Targetattach] => chest
                            [Buffubertip] => Array
                                (
                                )

                            [TargetArt] => war3mapImported\AbsorbManaBirthMissileArcane.mdx
                            [Bufftip] => Arcane Attraction
                            [Buffart] => ReplaceableTextures\CommandButtons\BTNPurge.blp
                        )

                )

        )

    [units] => Array
        (
        )

    [references] => Array
        (
        )

    [lightning] => Array
        (
        )

)