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

            [Art] => ReplaceableTextures\CommandButtons\BTNMindsooth.blp
            [dmgplus1] => 1045
            [bldtm] => 1
            [goldcost] => 3750
            [unitSound] => MageTower
            [sides1] => 1
            [manaN] => 3000
            [launchZ] => 220
            [acquire] => 1000
            [upgrades] => Array
                (
                )

            [Upgrade] => Array
                (
                )

            [Name] => Apex of Thought
            [weapTp1] => missile
            [MissileHoming] => 1
            [file] => .mdl
            [uberSplat] => YTDG
            [Missileart] => Abilities\Weapons\BlackKeeperMissile\BlackKeeperMissile.mdl
            [Missilespeed] => 1500
            [dice1] => 1
            [RngBuff1] => 250
            [regenMana] => 30
            [green] => 55
            [animProps] => alternate
            [modelScale] => 0.1
            [rangeN1] => 1000
            [atkType1] => normal
            [cool1] => 2.5
            [Ubertip] => The pinnacle of arcane intellect.
            [scaleBull] => 0
            [abilList] => @@0@@
            [buildingShadow] => Array
                (
                )

            [targs1] => Array
                (
                )

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

    [settings] => Array
        (
            [balanceTip] => |cffFFFF00+1.2 |rmana regen/lvl
            [abil_factor] => 0.09
            [author] => Ashbringer
            [alpha] => 255
            [authorDisplay] => |cffff6600Ashbringer|r
            [version] => 1.0
            [element] => arcane
            [rarity] => unique
        )

    [effects] => Array
        (
            [0] => Array
                (
                    [x] => -0.0531339
                    [y] => 0.033065
                    [z] => 0
                    [scale] => 0.41
                    [rot] => 5.49779
                    [file] => doodads\cinematic\IcecrownObelisk\IcecrownObelisk.mdl
                    [red] => 255
                    [green] => 55
                    [blue] => 255
                    [alpha] => 255
                    [pitch] => 0
                    [advanced] => true
                    [animation] => work
                    [aniSpeed] => 50
                    [pcolor] => 8
                )

            [1] => Array
                (
                    [x] => -0.0531339
                    [y] => 0.033065
                    [z] => 0
                    [scale] => 0.41
                    [rot] => 2.3562
                    [file] => doodads\cinematic\IcecrownObelisk\IcecrownObelisk.mdl
                    [red] => 255
                    [green] => 55
                    [blue] => 255
                    [alpha] => 255
                    [pitch] => 0
                    [advanced] => true
                    [animation] => work
                    [aniSpeed] => 50
                    [pcolor] => 8
                )

            [2] => Array
                (
                    [x] => -0.101295
                    [y] => 0.100187
                    [z] => 0.000000953674
                    [scale] => 1.75
                    [rot] => 2.3911
                    [file] => Abilities\Spells\Other\GeneralAuraTarget\GeneralAuraTarget.mdl
                    [red] => 1
                    [green] => 1
                    [blue] => 255
                    [alpha] => 255
                    [pitch] => 0
                    [advanced] => false
                    [animation] => Array
                        (
                        )

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

            [3] => Array
                (
                    [x] => -0.134523
                    [y] => -44.8021
                    [z] => -6.4
                    [scale] => 0.4
                    [rot] => 4.71239
                    [file] => Doodads\Cityscape\Structures\CityLowWall90\CityLowWall90.mdl
                    [red] => 45
                    [green] => 15
                    [blue] => 115
                    [alpha] => 255
                    [pitch] => 0
                    [advanced] => false
                    [animation] => Array
                        (
                        )

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

            [4] => Array
                (
                    [x] => 37.8869
                    [y] => -24.6113
                    [z] => -6.4
                    [scale] => 0.4
                    [rot] => 5.75959
                    [file] => Doodads\Cityscape\Structures\CityLowWall90\CityLowWall90.mdl
                    [red] => 45
                    [green] => 15
                    [blue] => 115
                    [alpha] => 255
                    [pitch] => 0
                    [advanced] => false
                    [animation] => Array
                        (
                        )

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

            [5] => Array
                (
                    [x] => 0.158873
                    [y] => 45.1705
                    [z] => -6.4
                    [scale] => 0.4
                    [rot] => 4.71239
                    [file] => Doodads\Cityscape\Structures\CityLowWall90\CityLowWall90.mdl
                    [red] => 45
                    [green] => 15
                    [blue] => 115
                    [alpha] => 255
                    [pitch] => 0
                    [advanced] => false
                    [animation] => Array
                        (
                        )

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

            [6] => Array
                (
                    [x] => -38.8966
                    [y] => 22.5034
                    [z] => -6.4
                    [scale] => 0.4
                    [rot] => 2.61799
                    [file] => Doodads\Cityscape\Structures\CityLowWall90\CityLowWall90.mdl
                    [red] => 45
                    [green] => 15
                    [blue] => 115
                    [alpha] => 255
                    [pitch] => 0
                    [advanced] => false
                    [animation] => Array
                        (
                        )

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

            [7] => Array
                (
                    [x] => -38.7002
                    [y] => -22.8658
                    [z] => -6.4
                    [scale] => 0.4
                    [rot] => 0.523599
                    [file] => Doodads\Cityscape\Structures\CityLowWall90\CityLowWall90.mdl
                    [red] => 45
                    [green] => 15
                    [blue] => 115
                    [alpha] => 255
                    [pitch] => 0
                    [advanced] => false
                    [animation] => Array
                        (
                        )

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

            [8] => Array
                (
                    [x] => 39.0026
                    [y] => 22.3349
                    [z] => -6.4
                    [scale] => 0.4
                    [rot] => 0.523599
                    [file] => Doodads\Cityscape\Structures\CityLowWall90\CityLowWall90.mdl
                    [red] => 45
                    [green] => 15
                    [blue] => 115
                    [alpha] => 255
                    [pitch] => 0
                    [advanced] => false
                    [animation] => Array
                        (
                        )

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

            [9] => Array
                (
                    [x] => 0.0939001
                    [y] => 3.08779
                    [z] => 198.4
                    [scale] => 1.35
                    [rot] => 0
                    [file] => war3mapImported\Dalaran BrillianceSmall.mdl
                    [red] => 255
                    [green] => 255
                    [blue] => 255
                    [alpha] => 255
                    [pitch] => 0
                    [advanced] => false
                    [animation] => Array
                        (
                        )

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

            [10] => Array
                (
                    [x] => 14.1344
                    [y] => -25.4236
                    [z] => 32
                    [scale] => 0.25
                    [rot] => 0.523599
                    [file] => Doodads\Terrain\DalaranMagicalPenWall\DalaranMagicalPenWall.mdl
                    [red] => 1
                    [green] => 1
                    [blue] => 1
                    [alpha] => 255
                    [pitch] => 0
                    [advanced] => false
                    [animation] => Array
                        (
                        )

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

            [11] => Array
                (
                    [x] => -29.1739
                    [y] => 0.224343
                    [z] => 32
                    [scale] => 0.25
                    [rot] => 4.71239
                    [file] => Doodads\Terrain\DalaranMagicalPenWall\DalaranMagicalPenWall.mdl
                    [red] => 1
                    [green] => 1
                    [blue] => 1
                    [alpha] => 255
                    [pitch] => 0
                    [advanced] => false
                    [animation] => Array
                        (
                        )

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

            [12] => Array
                (
                    [x] => 14.6463
                    [y] => 24.8252
                    [z] => 32
                    [scale] => 0.25
                    [rot] => 2.61799
                    [file] => Doodads\Terrain\DalaranMagicalPenWall\DalaranMagicalPenWall.mdl
                    [red] => 1
                    [green] => 1
                    [blue] => 1
                    [alpha] => 255
                    [pitch] => 0
                    [advanced] => false
                    [animation] => Array
                        (
                        )

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

            [13] => Array
                (
                    [x] => -14.4183
                    [y] => 25.209
                    [z] => 32
                    [scale] => 0.25
                    [rot] => 3.66519
                    [file] => Doodads\Terrain\DalaranMagicalPenWall\DalaranMagicalPenWall.mdl
                    [red] => 1
                    [green] => 1
                    [blue] => 1
                    [alpha] => 255
                    [pitch] => 0
                    [advanced] => false
                    [animation] => Array
                        (
                        )

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

            [14] => Array
                (
                    [x] => 28.8899
                    [y] => -0.438941
                    [z] => 32
                    [scale] => 0.25
                    [rot] => 1.5708
                    [file] => Doodads\Terrain\DalaranMagicalPenWall\DalaranMagicalPenWall.mdl
                    [red] => 1
                    [green] => 1
                    [blue] => 1
                    [alpha] => 255
                    [pitch] => 0
                    [advanced] => false
                    [animation] => Array
                        (
                        )

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

            [15] => Array
                (
                    [x] => -14.9303
                    [y] => -25.0399
                    [z] => 32
                    [scale] => 0.25
                    [rot] => 5.75959
                    [file] => Doodads\Terrain\DalaranMagicalPenWall\DalaranMagicalPenWall.mdl
                    [red] => 1
                    [green] => 1
                    [blue] => 1
                    [alpha] => 255
                    [pitch] => 0
                    [advanced] => false
                    [animation] => Array
                        (
                        )

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

            [16] => Array
                (
                    [x] => -28.0901
                    [y] => -49.1809
                    [z] => -6.4
                    [scale] => 0.35
                    [rot] => 5.75959
                    [file] => Doodads\Cityscape\Structures\City_LowWall_TallEndCap\City_LowWall_TallEndCap.mdl
                    [red] => 25
                    [green] => 15
                    [blue] => 115
                    [alpha] => 255
                    [pitch] => 0
                    [advanced] => false
                    [animation] => Array
                        (
                        )

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

            [17] => Array
                (
                    [x] => 28.4374
                    [y] => 49.8485
                    [z] => -6.4
                    [scale] => 0.35
                    [rot] => 5.75959
                    [file] => Doodads\Cityscape\Structures\City_LowWall_TallEndCap\City_LowWall_TallEndCap.mdl
                    [red] => 25
                    [green] => 15
                    [blue] => 115
                    [alpha] => 255
                    [pitch] => 0
                    [advanced] => false
                    [animation] => Array
                        (
                        )

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

            [18] => Array
                (
                    [x] => -57.6308
                    [y] => -0.230854
                    [z] => -6.4
                    [scale] => 0.35
                    [rot] => 0
                    [file] => Doodads\Cityscape\Structures\City_LowWall_TallEndCap\City_LowWall_TallEndCap.mdl
                    [red] => 25
                    [green] => 15
                    [blue] => 115
                    [alpha] => 255
                    [pitch] => 0
                    [advanced] => false
                    [animation] => Array
                        (
                        )

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

            [19] => Array
                (
                    [x] => 56.5753
                    [y] => -0.207521
                    [z] => -6.4
                    [scale] => 0.35
                    [rot] => 0
                    [file] => Doodads\Cityscape\Structures\City_LowWall_TallEndCap\City_LowWall_TallEndCap.mdl
                    [red] => 25
                    [green] => 15
                    [blue] => 115
                    [alpha] => 255
                    [pitch] => 0
                    [advanced] => false
                    [animation] => Array
                        (
                        )

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

            [20] => Array
                (
                    [x] => 28.9541
                    [y] => -49.374
                    [z] => -6.4
                    [scale] => 0.35
                    [rot] => 0.523599
                    [file] => Doodads\Cityscape\Structures\City_LowWall_TallEndCap\City_LowWall_TallEndCap.mdl
                    [red] => 25
                    [green] => 15
                    [blue] => 115
                    [alpha] => 255
                    [pitch] => 0
                    [advanced] => false
                    [animation] => Array
                        (
                        )

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

            [21] => Array
                (
                    [x] => -29.2609
                    [y] => 49.6315
                    [z] => -6.4
                    [scale] => 0.35
                    [rot] => 0.523599
                    [file] => Doodads\Cityscape\Structures\City_LowWall_TallEndCap\City_LowWall_TallEndCap.mdl
                    [red] => 25
                    [green] => 15
                    [blue] => 115
                    [alpha] => 255
                    [pitch] => 0
                    [advanced] => false
                    [animation] => Array
                        (
                        )

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

            [22] => Array
                (
                    [x] => -1.71315
                    [y] => -1.45587
                    [z] => 230.4
                    [scale] => 2.05
                    [rot] => 1.5708
                    [file] => Abilities\Spells\NightElf\SpiritOfVengeance\SpiritOfVengeanceOrbs1.mdl
                    [red] => 255
                    [green] => 255
                    [blue] => 255
                    [alpha] => 255
                    [pitch] => -5.15
                    [advanced] => false
                    [animation] => Array
                        (
                        )

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

            [23] => Array
                (
                    [x] => -1.71315
                    [y] => -1.45587
                    [z] => 230.4
                    [scale] => 2.05
                    [rot] => 4.71239
                    [file] => Abilities\Spells\NightElf\SpiritOfVengeance\SpiritOfVengeanceOrbs1.mdl
                    [red] => 255
                    [green] => 255
                    [blue] => 255
                    [alpha] => 255
                    [pitch] => -5.15
                    [advanced] => false
                    [animation] => Array
                        (
                        )

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

        )

    [dmgTable] => Array
        (
            [0] => Array
                (
                    [id] => MOD_MANA_REGEN
                    [base] => 0
                    [add] => 1.2
                )

        )

    [triggers] => Array
        (
            [0] => Array
                (
                    [name] => Header
                    [code] => globals
        BuffType ashbringer_presence_aura
    endglobals

    function ashbringer_presence_oncast takes Buff b returns nothing
        local Tower tower = b.getCaster()
        local Tower caster = b.getBuffedUnit()
        local integer UID = tower.getUID()
        local real duration = 3 + (tower.getLevel() * 0.12) 
        local AutocastType ac = Event.getAutocastType()
        local real max_mana = GetUnitState(caster.getUnit(), UNIT_STATE_MAX_MANA)
        local real mana_perc
        local integer power
        
        
        if not ac.isItemAutocast() and max_mana > 0 then
            set mana_perc = ac.getManacost() / max_mana
            if mana_perc > 0 then
                //set power = R2I(1000 * (mana_perc / 0.3) * (0.015 + (tower.getLevel() * 0.0006)))
                set power = R2I((mana_perc / 0.3) * ((0.015 + (tower.getLevel() * 0.0006)) / 0.0001))
                set tower.userInt = tower.userInt + power
                call tower.refreshAuras()
                call TriggerSleepAction(duration * tower.getProp_BuffDuration())
                if tower.getUID() == UID then
                    set tower.userInt = tower.userInt - power
                    call tower.refreshAuras()
                endif
            endif
        endif
    endfunction

    private function ashbringer_presence_refresh takes Buff b returns nothing
        local Tower tower = b.getCaster()
        
        if tower == b.getBuffedUnit() then
            call b.setPower(tower.userInt * 3)
        else
            call b.setPower(tower.userInt)
        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_presence_aura = BuffType.createAuraEffectType(true)
        call ashbringer_presence_aura.setBuffIcon('@@1@@')
        call ashbringer_presence_aura.setStackingGroup("ashbringer_presence_aura")
        call mod.addModification(MOD_ATTACKSPEED, 0.0, 0.0001)
        call mod.addModification(MOD_MANA_REGEN_PERC, 0.0, 0.0001)
        call ashbringer_presence_aura.setBuffModifier(mod)
        call ashbringer_presence_aura.addEventOnSpellCast(EventHandler.ashbringer_presence_oncast)
        call ashbringer_presence_aura.setEventOnRefresh(ashbringer_presence_refresh)
    endfunction
                    [values] => Array
                        (
                            [visible] => false
                            [icon] => 
                            [name] => 
                            [short_explain] => 
                            [long_explain] => 
                        )

                )

            [1] => Array
                (
                    [name] => On Damage
                    [code] => local Unit target = Event.getTarget()
    local real max_mana = GetUnitState(tower.getUnit(), UNIT_STATE_MAX_MANA)
    local real mana_perc = GetUnitState(tower.getUnit(), UNIT_STATE_MANA) / max_mana
    local real mana_cost = 0.06 + (tower.getLevel() * 0.0012)
    local real damage = 0.9 + (tower.getLevel() * 0.036)
    local real mana_modify = 0.0
    local Iterate i
    set tower.userInt3 = tower.userInt3 + 1
    
    if tower.userInt3 >= 3 then
        set tower.userInt3 = tower.userInt3 - 3
        set mana_modify = mana_modify + 0.03 + (tower.getLevel() * 0.0012)
        call target.subtractMana(mana_modify, true)
    endif
    
    if mana_perc >= mana_cost and not target.isImmune() then
        set damage = damage * max_mana * (1.0 - (mana_perc - mana_cost))
        if damage > 0 then
            call Lightning.createFromPointToUnit("ZAP9", tower.getX(), tower.getY(), 220, target).setLifetime(0.2)
            call Effect.createScaled("Abilities\\Spells\\Undead\\DevourMagic\\DevourMagicBirthMissile.mdl", target.getX(), target.getY(), target.getZ(), 270, 4).destroy()
            set mana_modify = mana_modify - mana_cost
            set i = Iterate.overUnitsInRangeOfUnit(tower, TARGET_TYPE_CREEPS, target, 222)
            loop
                set target = i.next()
                exitwhen target == 0
                call tower.doSpellDamage(target, damage, tower.calcSpellCritNoBonus())
                call Effect.createSimpleOnUnit("Abilities\\Weapons\\BlackKeeperMissile\\BlackKeeperMissile.mdl", target, "chest").destroy()
            endloop
        endif
    endif
    
    if mana_modify != 0 then
        call tower.addManaPerc(mana_modify)
    endif
                    [values] => Array
                        (
                            [ONDAMAGE_chance] => 1.0
                            [visible] => true
                            [icon] => ReplaceableTextures\CommandButtons\BTNMagicalSentry.blp
                            [name] => Manabond
                            [short_explain] => Attacks spend mana to deal additional spell damage based on how much mana the tower is missing.
                            [ONDAMAGE_chanceLevelAdd] => 0
                            [long_explain] => Each attack hit consumes |cffffff806%|r of maximum mana to deal spell damage to enemies in |cffffff80222|r range equal to |cffffff8090%|r of the amount of mana consumed plus the amount of mana the tower is missing. Does not trigger if tower has insufficient mana or if the target is immune.|n|n|cffFF8000Level Bonus:|r|n|cffFFFF80+0.12%|r mana cost|n|cffFFFF80+3.6%|r mana as spell damage
                        )

                )

            [2] => Array
                (
                    [name] => Tower Aura
                    [code] => Array
                        (
                        )

                    [values] => Array
                        (
                            [AURA_powerAdd] => 0
                            [visible] => true
                            [AURA_auraEffect] => ashbringer_presence_aura
                            [AURA_levelAdd] => 0
                            [AURA_power] => 0
                            [icon] => ReplaceableTextures\CommandButtons\BTNMindsooth.blp
                            [AURA_targetType] => TARGET_TYPE_TOWERS
                            [long_explain] => Whenever a tower within |cffffff80333|r range casts a spell, all towers under the effect of the aura gain |cffffff801.5%|r attack speed and mana regeneration for every |cffffff8030%|r of maximum mana that the casting tower spent. The effect of Presence of Mind on the Apex of Thought is tripled. Lasts |cffffff803|r seconds and each occurence expires independently.|n|n|cffFF8000Level Bonus:|r|n|cffFFFF80+0.06%|r attack speed per mana|n|cffFFFF80+0.06%|r mana regeneration per mana|n|cffFFFF80+0.12|r seconds duration
                            [AURA_targetSelf] => true
                            [name] => Presence of Mind
                            [AURA_level] => 0
                            [short_explain] => Increases the attack speed and mana regeneration of nearby towers whenever a nearby tower casts a spell.
                            [AURA_auraRange] => 333
                        )

                )

            [3] => Array
                (
                    [name] => On Tower Creation
                    [code] => set tower.userInt = 0
    set tower.userInt3 = 0
    call SetUnitAnimation(tower.getUnit(), "alternate")
    call SetUnitColor(tower.getUnit(), ConvertPlayerColor(7))
    call tower.addManaPerc(1)
                    [values] => Array
                        (
                            [visible] => false
                            [icon] => 
                            [name] => 
                            [short_explain] => 
                            [long_explain] => 
                        )

                )

        )

    [abilities] => Array
        (
            [0] => Array
                (
                    [id] => @@0@@
                    [derivedFrom] => Aroc
                    [oeValues] => Array
                        (
                            [Art] => ReplaceableTextures\CommandButtons\BTNNetherTempest.blp
                            [Untip] => The tower attacks up to |cffFFFF802|r additional enemies and drains mana on every third hit.
                            [Requires] => Array
                                (
                                )

                            [DataA1] => 0
                            [Cool1] => 1
                            [Area1] => 1000
                            [DataC1] => 1
                            [DataB1] => 0
                            [Name] => Rule of Threes
                            [Ubertip] => The tower attacks up to |cffFFFF803|r enemies at a time. Every third hit restores |cffFFFF803%|r of maximum mana. Removes an equal percentage of mana from the target if possible.|n|n|cffFF8000Level Bonus:|r|n|cffFFFF80+0.12%|r mana restored
                            [Missileart] => war3mapImported\TwilightRageTarget.mdx
                            [Missilespeed] => 1500
                            [Tip] => Rule of Threes
                            [Unubertip] => The tower attacks up to |cffFFFF802|r additional enemies and drains mana on every third hit.
                            [targs1] => enemies
                        )

                )

        )

    [buffs] => Array
        (
            [0] => Array
                (
                    [id] => @@1@@
                    [derivedFrom] => Binf
                    [oeValues] => Array
                        (
                            [Targetattach] => Array
                                (
                                )

                            [Buffubertip] => Increased attack speed.
                            [TargetArt] => Array
                                (
                                )

                            [Bufftip] => Presence Of Mind
                            [Buffart] => ReplaceableTextures\CommandButtons\BTNMindsooth.blp
                        )

                )

        )

    [units] => Array
        (
        )

    [references] => Array
        (
        )

    [lightning] => Array
        (
        )

)