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

            [Art] => ReplaceableTextures\CommandButtons\BTNGolemThunderclap.blp
            [bldtm] => 1
            [dmgplus1] => 2159
            [goldcost] => 3400
            [unitSound] => ArcaneTower
            [sides1] => 1
            [manaN] => 100
            [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
            [Missileart] => Abilities\Spells\Undead\OrbOfDeath\OrbOfDeathMissile.mdl
            [dice1] => 1
            [RngBuff1] => 250
            [modelScale] => 1.1
            [rangeN1] => 1000
            [atkType1] => normal
            [cool1] => 1.6
            [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.35
            [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 returns integer
        local Buff b
        local integer i
        
        if stacks<1 then
            set stacks = 1
        endif
        set b = target.getBuffOfType(ashbringer_attraction_buff)
        if ( b != 0 ) then
            set i = b.getPower() + stacks
            call ashbringer_attraction_buff.applyCustomPower(tower, target, 1, i)
        else
            set i = 1
            call ashbringer_attraction_buff.applyCustomPower(tower, target, 1, i)
        endif
        
        return i
    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.004))
        
        if stacks > 50 then
            set stacks = 50
        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
            call ashbringer_attraction_apply(tower, next, applied)
            //call tower.doAttackDamage(next, applied * damage_per_stack, tower.calcAttackMulticrit(0,0,0))
            call Effect.createSimpleOnUnit("Abilities\\Spells\\Human\\Feedback\\ArcaneTowerAttack.mdl", next, "origin").destroy()
            set next = i.next()
        endloop
    endfunction
    
    function ashbringer_surge_start takes Tower tower, Creep target, real mana returns nothing
        local Buff b
        local integer level = tower.getLevel()
        local Iterate i = Iterate.overUnitsInRangeOfCaster(tower, TARGET_TYPE_CREEPS, 1000)
        local Unit next = i.next()
        local real damage = tower.getCurrentAttackDamageWithBonus() * (3.0 + (level * 0.06)) * (1 + (mana * (0.0025 + (level * 0.0001))))
        local real chance_per_stack = 0.02 + (level * S2R("disintegrate_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\BTNHeartOfAszune.blp
                            [name] => Surge
                            [short_explain] => Attacks have a chance to deal additional damage that can bounce to nearby targets.
                            [long_explain] => Attacks have a |cffFFFF802%|r chance per Arcane Attraction stack on the target to send a surge of energy that deals |cffFFFF80300%|r of attack damage to the target and then attempts to jump to every enemy within attack range. At each enemy, the chance to jump is calculated based on the next target's Arcane Attraction stacks. Benefits from Mana Storm's damage bonus.|n|n|cffFF8000Level Bonus:|r|n|cffFFFF80+0.04%|r chance per stack|n|cffFFFF80+6%|r attack damage
                        )

                )

            [1] => Array
                (
                    [name] => On Damage
                    [code] => local Buff b
    local integer level = tower.getLevel()
    local Unit main_target = Event.getTarget()
    local real chance_per_stack = 0.02 + (level * S2R("disintegrate_chance_pl"))
    local Unit target
    local real mana = GetUnitState(tower.getUnit(), UNIT_STATE_MANA)
    local real extra_per = 50 - (level * 0.8)
    local integer extra_attacks = 2 + R2I((mana - ModuloReal(mana, extra_per)) / extra_per)
    local real original_damage = Event.damage
    local real damage = original_damage * (1 + (mana * (0.0025 + (level * 0.0001))))
    local Iterate i = Iterate.overUnitsInRangeOfCaster(tower, TARGET_TYPE_CREEPS, 1000)
    local boolean iterate_destroyed = false
    local integer stacks = 0
    local integer total_stacks = 0
    local real x = tower.getX()
    local real y = tower.getY()
    
    set Event.damage = damage
    call tower.subtractMana(mana, true)
    
    loop
        exitwhen extra_attacks < 1
        
        if not iterate_destroyed then
            set target = i.nextRandom()

            if target == 0 then
                set iterate_destroyed = true
                set target = main_target
            endif
        endif
  
        if iterate_destroyed or target != main_target then
            
            set stacks = ashbringer_attraction_apply(tower, target, 1)
            
            if target != main_target then
                call Lightning.createFromPointToUnit("PZAP", x, y, 90, target).setLifetime(0.2)
                call Effect.createSimpleOnUnit("Abilities\\Spells\\Undead\\OrbOfDeath\\OrbOfDeathMissile.mdl", target, "chest").destroy()
                set total_stacks = total_stacks + stacks
            endif
            
            call tower.doAttackDamage(target, damage, tower.calcAttackMulticrit(0,0,0))
            
            set extra_attacks = extra_attacks - 1
        endif
    endloop
 
    if not iterate_destroyed then
        call i.destroy()
    endif
    
    //call ashbringer_manastorm_cast.targetCastFromCaster(tower, main_target, 0.0, 0.0)
    call Lightning.createFromPointToUnit("PZAP", x, y, 90, main_target).setLifetime(0.2)
    //call Effect.createSimpleOnUnit("Abilities\\Spells\\Undead\\OrbOfDeath\\OrbOfDeathMissile.mdl", target, "chest").destroy()
    set stacks = ashbringer_attraction_apply(tower, main_target, 1)
    set total_stacks = total_stacks + stacks
    
    if tower.calcChance(I2R(stacks)*chance_per_stack) then
        call ashbringer_surge_start(tower, main_target, mana)
    endif
    
    call tower.addMana(total_stacks)
                    [values] => Array
                        (
                            [ONDAMAGE_chance] => 1.0
                            [visible] => true
                            [icon] => ReplaceableTextures\CommandButtons\BTNPurge.blp
                            [name] => Arcane Attraction
                            [short_explain] => Hits apply Arcane Attraction and generate mana. Spreads on death, dealing damage.
                            [ONDAMAGE_chanceLevelAdd] => 0.0
                            [long_explain] => Attacks apply a stack of Arcane Attraction on hit and generate |cffFFFF801|r mana per stack on each target. Can only gain mana once per target hit on each attack. When an enemy dies, up to |cffFFFF8050|r stacks of Arcane Attraction on it will distribute evenly to nearby targets within |cffFFFF80400|r range. Arcane Attraction lasts indefinitely.|n|n|cffFF8000Level Bonus:|r|n|cffFFFF80+8|r range|n|cffFFFF80+0.4%|r attack damage per stack
                        )

                )

            [2] => Array
                (
                    [name] => On Tower Creation
                    [code] => Array
                        (
                        )

                    [values] => Array
                        (
                            [visible] => true
                            [icon] => ReplaceableTextures\CommandButtons\BTNFeedBack.blp
                            [name] => Mana Storm
                            [short_explain] => Attacks consume mana to deal more damage and strike more targets.
                            [long_explain] => Attacks hit up to |cffFFFF802|r additional enemies within attack range and consume all mana, dealing |cffFFFF800.25%|r more damage per point of mana consumed. Mana Storm gains an additional attack for every |cffFFFF8050|r mana consumed. If there are less creeps than attacks, the remaining attacks will hit the main target.|n|n|cffFF8000Level Bonus:|r|n|cffFFFF80+0.006%|r damage per mana|n|cffFFFF80-0.8|r mana per extra attack
                        )

                )

        )

    [abilities] => Array
        (
        )

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

                            [TargetArt] => Abilities\Weapons\DruidoftheTalonMissile\DruidoftheTalonMissile.mdl
                            [Bufftip] => Arcane Attraction
                            [Buffart] => ReplaceableTextures\CommandButtons\BTNPurge.blp
                        )

                )

        )

    [units] => Array
        (
        )

    [references] => Array
        (
        )

    [lightning] => Array
        (
        )

)