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

            [Art] => ReplaceableTextures\CommandButtons\BTNArmorGolem.blp
            [turnRate] => 3
            [dmgplus1] => 1304
            [bldtm] => 1
            [goldcost] => 750
            [unitSound] => SpiritOfVengeance
            [sides1] => 1
            [Missilearc] => 0.1
            [manaN] => 100
            [acquire] => 1000
            [upgrades] => Array
                (
                )

            [Upgrade] => Array
                (
                )

            [Name] => Malfunctioning Construct
            [weapTp1] => instant
            [impactZ] => 60
            [file] => units\creeps\GolemStatue\GolemStatue.mdl
            [MissileHoming] => 1
            [uberSplat] => YTDG
            [Missilespeed] => 3000
            [dice1] => 1
            [RngBuff1] => 250
            [regenMana] => 10
            [green] => 75
            [modelScale] => 0.4
            [rangeN1] => 1000
            [propWin] => 10
            [atkType1] => normal
            [cool1] => 2
            [Ubertip] => A mindless servant became mindless no more, but then lost its mind.
            [abilList] => @@0@@
            [moveHeight] => 10
            [customTeamColor] => 1
            [buildingShadow] => Array
                (
                )

            [targs1] => Array
                (
                )

            [weapsOn] => 1
        )

    [settings] => Array
        (
            [balanceTip] => |cffFFFF00+2% |rattack speed/lvl|n|cffFFFF00+2% |rmana regen/lvl
            [abil_factor] => 0.8
            [author] => Ashbringer
            [alpha] => 255
            [authorDisplay] => |cffff6600Ashbringer|r
            [version] => 1.0
            [element] => arcane
            [rarity] => rare
        )

    [effects] => Array
        (
            [0] => Array
                (
                    [x] => -0.121655
                    [y] => -0.0187047
                    [z] => 64
                    [scale] => 1.4
                    [rot] => 1.57216
                    [file] => Abilities\Weapons\FaerieDragonMissile\FaerieDragonMissile.mdl
                    [red] => 155
                    [green] => 5
                    [blue] => 255
                    [alpha] => 255
                    [pitch] => 0
                    [advanced] => false
                    [animation] => Array
                        (
                        )

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

            [1] => Array
                (
                    [x] => -0.0797588
                    [y] => -0.29705
                    [z] => 44.8
                    [scale] => 0.65
                    [rot] => 4.01426
                    [file] => Abilities\Spells\Undead\Possession\PossessionCaster.mdl
                    [red] => 1
                    [green] => 155
                    [blue] => 255
                    [alpha] => 255
                    [pitch] => 0
                    [advanced] => false
                    [animation] => Array
                        (
                        )

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

            [2] => Array
                (
                    [x] => -7.6234
                    [y] => -19.8063
                    [z] => -0.000000953674
                    [scale] => 0.7
                    [rot] => 1.09956
                    [file] => Abilities\Spells\Orc\Purge\PurgeBuffTarget.mdl
                    [red] => 115
                    [green] => 1
                    [blue] => 255
                    [alpha] => 255
                    [pitch] => 0
                    [advanced] => false
                    [animation] => Array
                        (
                        )

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

            [3] => Array
                (
                    [x] => -0.259491
                    [y] => 1.03378
                    [z] => 64
                    [scale] => 1.4
                    [rot] => 1.5708
                    [file] => Abilities\Weapons\SpiritOfVengeanceMissile\SpiritOfVengeanceMissile.mdl
                    [red] => 255
                    [green] => 255
                    [blue] => 255
                    [alpha] => 255
                    [pitch] => -1.57
                    [advanced] => false
                    [animation] => Array
                        (
                        )

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

            [4] => Array
                (
                    [x] => -28.692
                    [y] => -1.79542
                    [z] => -6.4
                    [scale] => 0.2
                    [rot] => 3.14159
                    [file] => Doodads\LordaeronSummer\Terrain\StoneWall0\StoneWall00.mdl
                    [red] => 45
                    [green] => 95
                    [blue] => 195
                    [alpha] => 255
                    [pitch] => 0
                    [advanced] => false
                    [animation] => Array
                        (
                        )

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

            [5] => Array
                (
                    [x] => 1.5451
                    [y] => -27.7207
                    [z] => -6.4
                    [scale] => 0.2
                    [rot] => 4.7022
                    [file] => Doodads\LordaeronSummer\Terrain\StoneWall0\StoneWall00.mdl
                    [red] => 45
                    [green] => 95
                    [blue] => 195
                    [alpha] => 255
                    [pitch] => 0
                    [advanced] => false
                    [animation] => Array
                        (
                        )

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

            [6] => Array
                (
                    [x] => 28.5255
                    [y] => 3.42785
                    [z] => -6.4
                    [scale] => 0.2
                    [rot] => 0.000000357628
                    [file] => Doodads\LordaeronSummer\Terrain\StoneWall0\StoneWall00.mdl
                    [red] => 45
                    [green] => 95
                    [blue] => 195
                    [alpha] => 255
                    [pitch] => 0
                    [advanced] => false
                    [animation] => Array
                        (
                        )

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

            [7] => Array
                (
                    [x] => -1.71157
                    [y] => 29.3532
                    [z] => -6.4
                    [scale] => 0.2
                    [rot] => 1.56061
                    [file] => Doodads\LordaeronSummer\Terrain\StoneWall0\StoneWall00.mdl
                    [red] => 45
                    [green] => 95
                    [blue] => 195
                    [alpha] => 255
                    [pitch] => 0
                    [advanced] => false
                    [animation] => Array
                        (
                        )

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

            [8] => Array
                (
                    [x] => -1.27165
                    [y] => 0.177083
                    [z] => 0
                    [scale] => 0.45
                    [rot] => 0
                    [file] => Doodads\Cityscape\Structures\CityLowWall90\CityLowWall90.mdl
                    [red] => 45
                    [green] => 95
                    [blue] => 195
                    [alpha] => 255
                    [pitch] => -1.57
                    [advanced] => false
                    [animation] => Array
                        (
                        )

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

            [9] => Array
                (
                    [x] => 2.57874
                    [y] => -0.0241006
                    [z] => 0
                    [scale] => 0.45
                    [rot] => 3.14159
                    [file] => Doodads\Cityscape\Structures\CityLowWall90\CityLowWall90.mdl
                    [red] => 45
                    [green] => 95
                    [blue] => 195
                    [alpha] => 255
                    [pitch] => -1.57
                    [advanced] => false
                    [animation] => Array
                        (
                        )

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

            [10] => Array
                (
                    [x] => -0.221507
                    [y] => 0.455017
                    [z] => 0
                    [scale] => 1
                    [rot] => 2.14676
                    [file] => Abilities\Spells\Other\GeneralAuraTarget\GeneralAuraTarget.mdl
                    [red] => 255
                    [green] => 1
                    [blue] => 255
                    [alpha] => 255
                    [pitch] => 0
                    [advanced] => false
                    [animation] => Array
                        (
                        )

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

            [11] => Array
                (
                    [x] => -0.234802
                    [y] => -0.0547583
                    [z] => -19.2
                    [scale] => 2
                    [rot] => 1.85005
                    [file] => Abilities\Spells\Other\GeneralAuraTarget\GeneralAuraTarget.mdl
                    [red] => 255
                    [green] => 255
                    [blue] => 255
                    [alpha] => 255
                    [pitch] => 0
                    [advanced] => false
                    [animation] => Array
                        (
                        )

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

        )

    [dmgTable] => Array
        (
            [0] => Array
                (
                    [id] => MOD_ATTACKSPEED
                    [base] => 0
                    [add] => 0.02
                )

            [1] => Array
                (
                    [id] => MOD_MANA_REGEN_PERC
                    [base] => 0
                    [add] => 0.02
                )

        )

    [triggers] => Array
        (
            [0] => Array
                (
                    [name] => On Attack
                    [code] => call ashbringer_haywire_repeat(tower, 5, 0.15 + (tower.getLevel() * 0.006), tower.getX(), tower.getY())
                    [values] => Array
                        (
                            [visible] => false
                            [icon] => 
                            [name] => 
                            [short_explain] => 
                            [ONATTACK_chance] => 1
                            [ONATTACK_chanceLevelAdd] => 0
                            [long_explain] => 
                        )

                )

            [1] => Array
                (
                    [name] => Header
                    [code] => globals
        BuffType ashbringer_polarize_positive
        BuffType ashbringer_polarize_negative
    endglobals
    
    function ashbringer_polarize_detonate takes Tower tower, Unit targetA, Unit targetB returns nothing
        local real angle
        local real distance
        local real a_x
        local real a_y
        local real b_x = targetB.getX()
        local real b_y = targetB.getY()
        local real damage = tower.getCurrentAttackDamageWithBonus() * (tower.userReal + (tower.getLevel() * tower.userReal2))
        
        if targetA != 0 then
            set a_x = targetA.getX()
            set a_y = targetA.getY()
            
            call Effect.createColored("Abilities\\Weapons\\Bolt\\BoltImpact.mdl", a_x, a_y, 0, 270, 3, 255, 1, 255, 255).destroy()
            call tower.doAttackDamageAoE(a_x, a_y, 250, damage, tower.calcAttackMulticrit(0, 0, 0), 0.0)
        else
            set damage = damage * 2
        endif
        
        call Effect.createColored("Abilities\\Weapons\\Bolt\\BoltImpact.mdl", b_x, b_y, 0, 270, 3, 255, 1, 255, 255).destroy()
        //call Effect.createSimple("war3mapImported\\ArcaneExplosion.mdx", b_x, b_y).destroy()
        call tower.doAttackDamageAoE(b_x, b_y, 250, damage, tower.calcAttackMulticrit(0, 0, 0), 0.0)
    endfunction
    
    //@export
    function ashbringer_haywire_repeat takes Tower tower, integer max, real chance, real x, real y returns nothing
        local Iterate i = Iterate.overUnitsInRangeOfCaster(tower, TARGET_TYPE_CREEPS, 1050)
        local Unit next = i.nextRandom()
        local unit towerunit = tower.getUnit()
        local Buff b_pos
        local Buff b_neg
        local real mana = GetUnitState(towerunit, UNIT_STATE_MANA)
        
        if next != 0 then
            call i.destroy()
            if max == 5 or mana > 20 then
                if max < 5 then
                    call tower.subtractMana(20, true)
                endif
                set b_pos = next.getBuffOfType(ashbringer_polarize_positive)
                set b_neg = next.getBuffOfType(ashbringer_polarize_negative)
                call ResetUnitAnimation(towerunit)
                call SetUnitFacingToFaceUnitTimed(towerunit, next.getUnit(), 0.01)
                if tower.userInt == 0 then
                    set tower.userInt = 1
                    call SetUnitAnimation(towerunit, "attack")
                    call Effect.createSimpleOnUnit("Abilities\\Spells\\Orc\\LightningBolt\\LightningBoltMissile.mdl", next, "chest").destroy()
                    if b_neg != 0 then
                        call b_neg.removeBuff()
                        call Lightning.createFromPointToUnit("ZAP9", x, y, 70+tower.userReal3, next).setLifetime(0.2)
                        call ashbringer_polarize_detonate(tower, 0, next)
                    elseif b_pos == 0 then
                        call ashbringer_polarize_positive.apply(tower, next, 0)
                        call Lightning.createFromPointToUnit("ZAP1", x, y, 70+tower.userReal3, next).setLifetime(0.2)
                    else
                        call Lightning.createFromPointToUnit("ZAP1", x, y, 70+tower.userReal3, next).setLifetime(0.2)
                    endif
                else
                    set tower.userInt = 0
                    call SetUnitAnimation(towerunit, "attack spell")
                    call Effect.createSimpleOnUnit("Abilities\\Spells\\Demon\\DemonBoltImpact\\DemonBoltImpact.mdl", next, "oritin").destroy()
                    if b_pos != 0 then
                        call b_pos.removeBuff()
                        call Lightning.createFromPointToUnit("ZAP9", x, y, 70+tower.userReal3, next).setLifetime(0.2)
                        call ashbringer_polarize_detonate(tower, 0, next)
                    elseif b_neg == 0 then
                        call Lightning.createFromPointToUnit("ZAP5", x, y, 70+tower.userReal3, next).setLifetime(0.2)
                        call ashbringer_polarize_negative.apply(tower, next, 0)
                    else
                        call Lightning.createFromPointToUnit("ZAP5", x, y, 70+tower.userReal3, next).setLifetime(0.2)
                    endif
                endif
            endif
            call tower.doAttackDamage(next, tower.getCurrentAttackDamageWithBonus(), tower.calcAttackMulticrit(0, 0, 0))
            call QueueUnitAnimation(towerunit, "stand")
        endif
    
        if tower.calcChance(chance) and max > 0 then
            call TriggerSleepAction(0.2)
            set max = max - 1
            call ashbringer_haywire_repeat(tower, max, chance, x, y)
        endif
    endfunction
    
    function ashbringer_polarize_positive_oncreate takes Buff b returns nothing
        set b.userInt = 0
        set b.userInt2 = b.getCaster()
        set b.userInt3 = b.getBuffedUnit()
    endfunction
    
    function ashbringer_polarize_negative_oncreate takes Buff b returns nothing
        set b.userInt = 1
        set b.userInt2 = b.getCaster()
        set b.userInt3 = b.getBuffedUnit()
    endfunction
    
    function ashbringer_polarize_periodic takes Buff b returns nothing
        local Tower tower = b.userInt2
        local Unit creep = b.userInt3
        local Iterate i = Iterate.overUnitsInRange(tower, TARGET_TYPE_CREEPS, creep.getX(), creep.getY(), 175)
        local Unit next
        local Buff opposite
        local boolean completed = false
        
        loop
            set next = i.next()
            exitwhen next == 0 or completed == true
            if next != creep then
                if b.userInt == 0 then
                    set opposite = next.getBuffOfType(ashbringer_polarize_negative)
                    if opposite != 0 then
                        call opposite.removeBuff()
                        call b.removeBuff()
                        
                        call Lightning.createFromUnitToUnit("ZAP9", creep, next).setLifetime(0.2)
                        
                        call ashbringer_polarize_detonate(tower, creep, next)
                        set completed = true
                    endif
                else
                    set opposite = next.getBuffOfType(ashbringer_polarize_positive)
                    if opposite != 0 then
                        call opposite.removeBuff()
                        call b.removeBuff()
                        
                        call Lightning.createFromUnitToUnit("ZAP9", creep, next).setLifetime(0.2)
                        
                        call ashbringer_polarize_detonate(tower, creep, next)
                        set completed = true
                    endif
                endif
            endif
        endloop
        if next != 0 then
            call i.destroy()
        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 ashbringer_polarize_positive = BuffType.create(-1, 0, true)
        call ashbringer_polarize_positive.setBuffIcon('@@1@@')
        call mod.addModification(MOD_MOVESPEED, 0.1, 0)
        call ashbringer_polarize_positive.setBuffModifier(mod)
        call ashbringer_polarize_positive.addEventOnCreate(EventHandler.ashbringer_polarize_positive_oncreate)
        call ashbringer_polarize_positive.addPeriodicEvent(ashbringer_polarize_periodic, 1.0)
        
        set mod = Modifier.create()
        set ashbringer_polarize_negative = BuffType.create(-1, 0, true)
        call ashbringer_polarize_negative.setBuffIcon('@@2@@')
        call mod.addModification(MOD_MOVESPEED, -0.1, 0)
        call ashbringer_polarize_negative.setBuffModifier(mod)
        call ashbringer_polarize_negative.addEventOnCreate(EventHandler.ashbringer_polarize_negative_oncreate)
        call ashbringer_polarize_negative.addPeriodicEvent(ashbringer_polarize_periodic, 1.0)
    endfunction
                    [values] => Array
                        (
                            [visible] => true
                            [icon] => ReplaceableTextures\CommandButtons\BTNGolemThunderclap.blp
                            [name] => Haywire
                            [short_explain] => Always attacks random targets. Chance on attack to attack again at the cost of mana.
                            [long_explain] => The construct always attacks random targets in range. Attacks have a |cffFFFF8015%|r chance to immediately attack again at the cost of |cffFFFF8020|r mana. This effect can trigger itself repeatedly.|n|n|cffFF8000Level Bonus:|r|n|cffFFFF80+0.6%|r chance
                        )

                )

            [2] => Array
                (
                    [name] => On Damage
                    [code] => if Event.isMainTarget() then
        set Event.damage = 0
    endif
                    [values] => Array
                        (
                            [ONDAMAGE_chance] => 1.0
                            [visible] => true
                            [icon] => ReplaceableTextures\CommandButtons\BTNSRUnrelentningStorm.blp
                            [name] => Polarize
                            [short_explain] => Attacks charge enemies with opposite effects, causing AoE damage when opposites come in contact.
                            [ONDAMAGE_chanceLevelAdd] => 0
                            [long_explain] => Attacks alternate between charging enemies with Positive or Negative charge, which lasts indefinitely. Positive charge increases the enemy's movement speed by |cffFFFF8010%|r whereas Negative charge reduces it by |cffFFFF8010%|r. If both charges exist on a single target, or if two oppositely charged enemies come in |cffFFFF80175|r range of each other, both charges detonate and deal |cffFFFF8025%|r of attack damage to enemies in |cffFFFF80250|r range each.|n|n|cffFF8000Level Bonus:|r|n|cffFFFF80+1%|r attack damage
                        )

                )

            [3] => Array
                (
                    [name] => On Tower Creation
                    [code] => set tower.userInt = 0
    
    set tower.userReal = 0.25
    set tower.userReal2 = 0.01
    set tower.userReal3 = 4
                    [values] => Array
                        (
                            [visible] => false
                            [icon] => 
                            [name] => 
                            [short_explain] => 
                            [long_explain] => 
                        )

                )

        )

    [abilities] => Array
        (
            [0] => Array
                (
                    [id] => @@0@@
                    [derivedFrom] => Asph
                    [oeValues] => Array
                        (
                            [Targetattach] => hand,left
                            [Art] => Array
                                (
                                )

                            [Untip] => -HIDE-
                            [Targetattach1] => hand,right
                            [Targetattach2] => Array
                                (
                                )

                            [TargetArt] => Abilities\Spells\Orc\Bloodlust\BloodlustTarget.mdl,war3mapImported\BlueBloodLustTarget.mdx
                            [Cool1] => 0.01
                            [Name] => Construct FX
                            [Ubertip] => -HIDE-
                            [Targetattachcount] => 2
                            [Missileart] => Array
                                (
                                )

                            [Missilespeed] => 4000
                            [Unubertip] => -HIDE-
                            [Tip] => -HIDE-
                        )

                )

        )

    [buffs] => Array
        (
            [0] => Array
                (
                    [id] => @@1@@
                    [derivedFrom] => BNrd
                    [oeValues] => Array
                        (
                            [Targetattach] => overhead
                            [Buffubertip] => Increased movement speed.
                            [TargetArt] => war3mapImported\BlueBloodLustTarget.mdx
                            [Bufftip] => Positive Charge
                            [Buffart] => ReplaceableTextures\CommandButtons\BTNSRUnrelentningStorm.blp
                        )

                )

            [1] => Array
                (
                    [id] => @@2@@
                    [derivedFrom] => BNrd
                    [oeValues] => Array
                        (
                            [Targetattach] => overhead
                            [Buffubertip] => Decreased movement speed.
                            [TargetArt] => Abilities\Spells\Orc\Bloodlust\BloodlustTarget.mdl
                            [Bufftip] => Negative Charge
                            [Buffart] => ReplaceableTextures\CommandButtons\BTNStasisTrap.blp
                        )

                )

        )

    [units] => Array
        (
        )

    [references] => Array
        (
        )

    [lightning] => Array
        (
        )

)