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

            [Art] => ReplaceableTextures\CommandButtons\BTNOrbofSlowness.blp
            [dmgplus1] => 0
            [bldtm] => 1
            [goldcost] => 3250
            [unitSound] => Waygate
            [sides1] => 1
            [manaN] => 10000
            [acquire] => 850
            [upgrades] => Array
                (
                )

            [Upgrade] => Array
                (
                )

            [Name] => Condensed Mana Sphere
            [weapTp1] => missile
            [MissileHoming] => 1
            [file] => .mdl
            [uberSplat] => YTDG
            [Missileart] => Abilities\Spells\Undead\ReplenishMana\ReplenishManaCaster.mdl
            [Missilespeed] => 3000
            [dice1] => 1
            [RngBuff1] => 250
            [modelScale] => 0.1
            [rangeN1] => 850
            [atkType1] => normal
            [cool1] => 2.2
            [Ubertip] => Mana this dense risks tearing reality apart.
            [scaleBull] => 0
            [abilList] => Array
                (
                )

            [customTeamColor] => 1
            [buildingShadow] => Array
                (
                )

            [targs1] => Array
                (
                )

            [teamColor] => 1
        )

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

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

    [effects] => Array
        (
            [0] => Array
                (
                    [x] => 44.9842
                    [y] => 44.2244
                    [z] => 0
                    [scale] => 0.2
                    [rot] => 0.785398
                    [file] => Doodads\Cityscape\Structures\City_LowWall_TallEndCap\City_LowWall_TallEndCap.mdl
                    [red] => 55
                    [green] => 55
                    [blue] => 155
                    [alpha] => 255
                    [pitch] => 0
                    [advanced] => false
                    [animation] => Array
                        (
                        )

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

            [1] => Array
                (
                    [x] => -43.4362
                    [y] => 43.1245
                    [z] => 0
                    [scale] => 0.2
                    [rot] => 0.785398
                    [file] => Doodads\Cityscape\Structures\City_LowWall_TallEndCap\City_LowWall_TallEndCap.mdl
                    [red] => 55
                    [green] => 55
                    [blue] => 155
                    [alpha] => 255
                    [pitch] => 0
                    [advanced] => false
                    [animation] => Array
                        (
                        )

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

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

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

            [3] => Array
                (
                    [x] => 43.4629
                    [y] => -43.9578
                    [z] => 0
                    [scale] => 0.2
                    [rot] => 0.785398
                    [file] => Doodads\Cityscape\Structures\City_LowWall_TallEndCap\City_LowWall_TallEndCap.mdl
                    [red] => 55
                    [green] => 55
                    [blue] => 155
                    [alpha] => 255
                    [pitch] => 0
                    [advanced] => false
                    [animation] => Array
                        (
                        )

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

            [4] => Array
                (
                    [x] => -0.362884
                    [y] => -0.160326
                    [z] => -19.2
                    [scale] => 0.3
                    [rot] => 0.785398
                    [file] => Doodads\Cityscape\Structures\City_LowWall_TallEndCap\City_LowWall_TallEndCap.mdl
                    [red] => 55
                    [green] => 55
                    [blue] => 155
                    [alpha] => 255
                    [pitch] => 0
                    [advanced] => false
                    [animation] => Array
                        (
                        )

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

            [5] => Array
                (
                    [x] => -1.00995
                    [y] => 0.598768
                    [z] => 25.6
                    [scale] => 0.17
                    [rot] => 1.5708
                    [file] => war3mapImported\City_ColumnSemiCircle2.mdl
                    [red] => 55
                    [green] => 55
                    [blue] => 155
                    [alpha] => 255
                    [pitch] => -4.71
                    [advanced] => false
                    [animation] => Array
                        (
                        )

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

            [6] => Array
                (
                    [x] => 0.513245
                    [y] => -0.973803
                    [z] => 25.6
                    [scale] => 0.17
                    [rot] => 4.71239
                    [file] => war3mapImported\City_ColumnSemiCircle2.mdl
                    [red] => 55
                    [green] => 55
                    [blue] => 155
                    [alpha] => 255
                    [pitch] => -4.71
                    [advanced] => false
                    [animation] => Array
                        (
                        )

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

            [7] => Array
                (
                    [x] => -1.24628
                    [y] => -0.0357993
                    [z] => 25.6
                    [scale] => 0.17
                    [rot] => 3.14159
                    [file] => war3mapImported\City_ColumnSemiCircle2.mdl
                    [red] => 55
                    [green] => 55
                    [blue] => 155
                    [alpha] => 255
                    [pitch] => -4.71
                    [advanced] => false
                    [animation] => Array
                        (
                        )

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

            [8] => Array
                (
                    [x] => 0.326294
                    [y] => 1.48741
                    [z] => 25.6
                    [scale] => 0.17
                    [rot] => 0
                    [file] => war3mapImported\City_ColumnSemiCircle2.mdl
                    [red] => 55
                    [green] => 55
                    [blue] => 155
                    [alpha] => 255
                    [pitch] => -4.71
                    [advanced] => false
                    [animation] => Array
                        (
                        )

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

            [9] => Array
                (
                    [x] => -0.809143
                    [y] => -21.4398
                    [z] => 0
                    [scale] => 0.13
                    [rot] => 1.5708
                    [file] => war3mapImported\City_ColumnSemiCircle2.mdl
                    [red] => 155
                    [green] => 55
                    [blue] => 155
                    [alpha] => 255
                    [pitch] => -0.78
                    [advanced] => false
                    [animation] => Array
                        (
                        )

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

            [10] => Array
                (
                    [x] => 0.219208
                    [y] => 21.0455
                    [z] => 0
                    [scale] => 0.13
                    [rot] => 4.71239
                    [file] => war3mapImported\City_ColumnSemiCircle2.mdl
                    [red] => 155
                    [green] => 55
                    [blue] => 155
                    [alpha] => 255
                    [pitch] => -0.78
                    [advanced] => false
                    [animation] => Array
                        (
                        )

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

            [11] => Array
                (
                    [x] => -21.4705
                    [y] => 0.317655
                    [z] => 0
                    [scale] => 0.13
                    [rot] => 0.000000119209
                    [file] => war3mapImported\City_ColumnSemiCircle2.mdl
                    [red] => 155
                    [green] => 55
                    [blue] => 155
                    [alpha] => 255
                    [pitch] => -0.78
                    [advanced] => false
                    [animation] => Array
                        (
                        )

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

            [12] => Array
                (
                    [x] => 21.0149
                    [y] => -0.710711
                    [z] => 0
                    [scale] => 0.13
                    [rot] => 3.14159
                    [file] => war3mapImported\City_ColumnSemiCircle2.mdl
                    [red] => 155
                    [green] => 55
                    [blue] => 155
                    [alpha] => 255
                    [pitch] => -0.78
                    [advanced] => false
                    [animation] => Array
                        (
                        )

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

        )

    [dmgTable] => Array
        (
        )

    [triggers] => Array
        (
            [0] => Array
                (
                    [name] => Header
                    [code] => globals
        BuffType ashbringer_sphere_aura
    endglobals
    
    struct mana_sphere
        integer tier
        Effect e1 = 0
        Effect e2 = 0
        Effect e3 = 0
        Effect array e4[4]
        integer state
        
        method spawnballs takes Tower tower, integer forcestate returns nothing
            local integer i = 0
            local real angle = 0
            local real x = tower.getX()
            local real y = tower.getY()
            local real tx
            local real ty
            
            if .e2 != 0 then
                call .e2.destroy()
            endif
            if .tier == 3 then
                if .e3 != 0 then
                    call .e3.destroy()
                endif
                if forcestate == 0 then
                    set .e2 = Effect.createColored("Abilities\\Weapons\\FarseerMissile\\FarseerMissile.mdl", x, y, 102.4, 270.0, 1.25, 255, 55, 255, 255)
                    set .e3 = Effect.createColored("Abilities\\Weapons\\SpiritOfVengeanceMissile\\SpiritOfVengeanceMissile.mdl", x, y, 108.8, 270.0, 2.55, 255, 255, 255, 255)
                else
                    set .e2 = Effect.createColored("Abilities\\Weapons\\VengeanceMissile\\VengeanceMissile.mdl", x-6, y, 89.6, 270.0, 2.55, 255, 155, 1, 255)
                    set .e3 = Effect.createColored("Abilities\\Weapons\\WitchDoctorMissile\\WitchDoctorMissile.mdl", x, y, 96, 270.0, 1.55, 255, 255, 255, 255)
                endif
            else
                if forcestate == 0 then
                    set .e2 = Effect.createColored("Abilities\\Weapons\\SpiritOfVengeanceMissile\\SpiritOfVengeanceMissile.mdl", x, y, 64 + tower.userReal, 0, 1.9 + (.tier * 0.1), 255, 255, 255, 255)
                else
                    set .e2 = Effect.createColored("Abilities\\Weapons\\VengeanceMissile\\VengeanceMissile.mdl", x-6, y, 57.6 + tower.userReal, 270.0, 1.75 + (.tier * 0.1), 255, 155, 1, 255)
                endif
            endif
            
            if .tier > 1 then
                loop
                    exitwhen i > 3
                    
                    if .e4[i] != 0 then
                        call e4[i].destroy()
                    endif
                    
                    set angle = 45 + (i * 90)
                    set tx = x + 61 * Cos(Deg2Rad(angle))
                    set ty = y + 61 * Sin(Deg2Rad(angle))
                    
                    if forcestate == 0 then
                        set .e4[i] = Effect.createColored("Abilities\\Weapons\\SpiritOfVengeanceMissile\\SpiritOfVengeanceMissile.mdl", tx, ty, 30 + (tower.userReal / 2), ModuloReal(angle, 360), 0.45, 255, 255, 255, 255)
                    else
                        set .e4[i] = Effect.createColored("Abilities\\Weapons\\VengeanceMissile\\VengeanceMissile.mdl", tx, ty, 30 + (tower.userReal / 2), ModuloReal(angle, 360), 0.55, 255, 155, 1, 255)
                    endif
                    
                    call .e4[i].setFacing(angle)
                    
                    set i = i + 1
                endloop
            endif
        endmethod
        
        method setup takes Tower tower, integer tier returns nothing
            set .tier = tier
            set .state = 0
            
            set e4[0] = 0
            set e4[1] = 0
            set e4[2] = 0
            set e4[3] = 0
            
            if .tier == 3 then
                set .e1 = Effect.createColored("Abilities\\Weapons\\FaerieDragonMissile\\FaerieDragonMissile.mdl", tower.getX(), tower.getY(), 102.4, 270.0, 2.25, 255, 55, 255, 255)
            else
                set .e1 = Effect.createColored("Abilities\\Spells\\Items\\PotionOfOmniscience\\CrystalBallCaster.mdl", tower.getX(), tower.getY(), 38.4 + tower.userReal, 0, 1.2 + (.tier * 0.1), 255, 55, 255, 255)
            endif
            
            call .spawnballs(tower, 0)
        endmethod
        
        method switch takes Tower tower, integer forcestate returns nothing
            if .state == 0 or forcestate == 1 then
                set .state = 1
                call Effect.create("Abilities\\Spells\\Demon\\DarkPortal\\DarkPortalTarget.mdl", tower.getX(), tower.getY(), 50 + tower.userReal, 270).setLifetime(3.0)
                call e1.setColor(255, 155, 1, 255)
                
                call .spawnballs(tower, .state)
            elseif .state == 1 or forcestate == 0 then
                set .state = 0
                call Effect.create("Abilities\\Spells\\Other\\Charm\\CharmTarget.mdl", tower.getX(), tower.getY(), 50 + tower.userReal, 270).setLifetime(3.0)
                call e1.setColor(255, 55, 255, 255)
                
                call .spawnballs(tower, .state)
            endif
            set tower.userInt2 = .state
        endmethod
        
        method update_mana takes Tower tower returns nothing
            local real mana_perc = GetUnitState(tower.getUnit(), UNIT_STATE_MANA) / GetUnitState(tower.getUnit(), UNIT_STATE_MAX_MANA)
            
            if .state == 0 then
                call tower.subtractManaPerc(0.04, true)
            
                if mana_perc < 0.01 then
                    call .switch(tower, 1)
                endif
            else
                call tower.addManaPerc(0.04)
                
                if mana_perc > 0.99 then
                    call .switch(tower, 0)
                endif
            endif
        endmethod
        
        method cleanup takes nothing returns nothing
            call .e1.destroy()
            call .e2.destroy()
            if .tier > 1 then
                call .e4[0].destroy()
                call .e4[1].destroy()
                call .e4[2].destroy()
                call .e4[3].destroy()
                if .tier > 2 then
                    call .e3.destroy()
                endif
            endif
        endmethod
    endstruct
    
    function ashbringer_sphere_periodic takes Buff b returns nothing
        local Tower caster = b.getCaster()
        local Tower target = b.getBuffedUnit()
        local real mana
        local real max_mana
        local real mana_alt
        
        if caster.userInt2 == 0 then
            set max_mana = GetUnitState(target.getUnit(), UNIT_STATE_MAX_MANA)
            if max_mana > 0 then
                set mana = GetUnitState(target.getUnit(), UNIT_STATE_MANA)
                set mana = (0.005 + (b.getLevel() * 0.0002)) * (max_mana - mana)
                set mana_alt = (1 + (caster.getProp_ManaPercBonus() * 0.5)) * mana
                set mana = (1 + caster.getProp_ManaRegPercBonus()) * mana
                if caster.subtractManaPerc(mana_alt / max_mana, false) > 0 then
                    call target.addMana(mana)
                    call Effect.create("Abilities\\Spells\\Undead\\ReplenishMana\\ReplenishManaCaster.mdl", target.getX(), target.getY(), 38.4, 270).setLifetime(2.0)
                    if (mana_alt / max_mana) >= caster.userReal2 then
                        call Lightning.createFromPointToUnit("PMBZ", caster.getX(), caster.getY(), 57 + caster.userReal, target).setLifetime(0.2)
                    endif
                endif
            endif
        endif
    endfunction
    
    function ashbringer_sphere_ondamage takes Buff b returns nothing
        local Tower caster = b.getCaster()
        local Tower tower = b.getBuffedUnit()
        local Creep target = Event.getTarget()
        local real mana
        
        if caster.userInt2 == 1 then
            set mana = (1 + caster.getProp_ManaPercBonus()) * (10 + (b.getLevel() * 0.4))
            set mana = target.subtractMana(mana, true)
            if mana > 0 then
                call caster.addManaPerc((1 + (caster.getProp_ManaRegPercBonus() * 0.5)) * 0.01)
                call tower.doSpellDamage(target, mana * (100 + (b.getLevel() * 4)), tower.calcSpellCritNoBonus())
                call Effect.createSimpleOnUnit("Abilities\\Spells\\Human\\Feedback\\SpellBreakerAttack.mdl", target, "chest").setLifetime(2.0)
                call Lightning.createFromPointToUnit("YLWL", caster.getX(), caster.getY(), 57 + caster.userReal, target).setLifetime(0.2)
            endif
        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_sphere_aura = BuffType.createAuraEffectType(true)
        call ashbringer_sphere_aura.setBuffIcon('@@0@@')
        call ashbringer_sphere_aura.addPeriodicEvent(EventHandler.ashbringer_sphere_periodic, 2.0)
        call ashbringer_sphere_aura.addEventOnDamage(EventHandler.ashbringer_sphere_ondamage, 1.0, 0.0)
        call ashbringer_sphere_aura.setStackingGroup("ashbringer_sphere_aura")
    endfunction
                    [values] => Array
                        (
                            [visible] => true
                            [icon] => ReplaceableTextures\CommandButtons\BTNAbsorbMagic.blp
                            [name] => Relative Dissonance
                            [short_explain] => Bonus maximum mana and mana regeneration increase the effects of Negative Absorption and Positive Outflow.
                            [long_explain] => Bonus maximum mana stats increases the effects of Negative Absorption while decreasing time spent in the Positive state. |n|nBonus mana regeneration stats increases the effects of Positive Outflow while decreasing time spent in the Negative state.
                        )

                )

            [1] => Array
                (
                    [name] => On Tower Destruction
                    [code] => local mana_sphere ms = tower.userInt
    
    call ms.cleanup()
                    [values] => Array
                        (
                            [visible] => false
                            [icon] => 
                            [name] => 
                            [short_explain] => 
                            [long_explain] => 
                        )

                )

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

                    [values] => Array
                        (
                            [AURA_powerAdd] => 1
                            [visible] => true
                            [AURA_auraEffect] => ashbringer_sphere_aura
                            [AURA_levelAdd] => 1
                            [AURA_power] => 0
                            [icon] => ReplaceableTextures\CommandButtons\BTNOrbofSlowness.blp
                            [AURA_targetType] => TARGET_TYPE_TOWERS
                            [long_explain] => While in the Positive state, towers within |cffffff80300|r range regenerate |cffffff800.5%|r of their missing mana every |cffffff802|r seconds and the Mana Sphere will lose a proportional percentage of its maximum mana.|n|n|cffFF8000Level Bonus:|r|n|cffFFFF80+0.02%|r of missing mana regenerated
                            [AURA_targetSelf] => false
                            [name] => Positive Outflow
                            [AURA_level] => 0
                            [short_explain] => While Positive, regenerates the mana of nearby towers.
                            [AURA_auraRange] => 300
                        )

                )

            [3] => Array
                (
                    [name] => Periodic
                    [code] => local mana_sphere ms = tower.userInt
    
    call ms.update_mana(tower)
                    [values] => Array
                        (
                            [visible] => true
                            [PERIODIC_period] => 2.0
                            [icon] => ReplaceableTextures\CommandButtons\BTNFeedBack.blp
                            [name] => Negative Absorption
                            [short_explain] => While Negative, nearby towers burn mana on attack.
                            [long_explain] => While in the Negative state, towers within |cffffff80300|r range burn |cffffff8010|r mana on attack, dealing |cffffff80100|r spell damage for each point of mana burnt. Each attack that burns mana will cause the Mana Sphere to gain |cffffff801%|r of its maximum mana.|n|n|cffFF8000Level Bonus:|r|n|cffFFFF80+10|r mana burnt|n|cffFFFF80+100|r spell damage per mana
                        )

                )

            [4] => Array
                (
                    [name] => Autocast
                    [code] => local mana_sphere ms = tower.userInt
    
    call ms.switch(tower, -1)
                    [values] => Array
                        (
                            [AUTOCAST_cooldown] => 30
                            [AUTOCAST_autoRange] => 900
                            [AUTOCAST_manacost] => 0
                            [icon] => ReplaceableTextures\CommandButtons\BTNReplay-Loop.blp
                            [AUTOCAST_range] => 900
                            [AUTOCAST_targetType] => 0
                            [AUTOCAST_numBuffsBeforeIdle] => 0
                            [caster_art] => 
                            [long_explain] => Switch between Positive and Negative states. Every |cffFFFF802|r seconds, the Mana Sphere will lose |cffFFFF804%|r of its maximum mana if Positive or gain |cffFFFF804%|r of its maximum if Negative. Automatically switch states upon reaching either |cffFFFF800%|r or |cffFFFF80100%|r mana.
                            [target_art] => 
                            [AUTOCAST_autocastType] => AC_TYPE_NOAC_IMMEDIATE
                            [AUTOCAST_buffType] => 0
                            [AUTOCAST_isExtended] => false
                            [name] => Inversion
                            [AUTOCAST_targetSelf] => false
                            [short_explain] => Switches the Mana Sphere between Negative and Positive states. Switches automatically at zero or full mana.
                        )

                )

            [5] => Array
                (
                    [name] => On Tower Creation
                    [code] => local mana_sphere ms = mana_sphere.create()
    
    set tower.userReal = 20
    set tower.userReal2 = 2 * 0.01
    call ms.setup(tower, 2)
    
    call tower.addManaPerc(0.5)
    set tower.userInt = ms
    set tower.userInt2 = 0
                    [values] => Array
                        (
                            [visible] => false
                            [icon] => 
                            [name] => 
                            [short_explain] => 
                            [long_explain] => 
                        )

                )

        )

    [abilities] => Array
        (
        )

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

                            [Buffubertip] => Array
                                (
                                )

                            [TargetArt] => Array
                                (
                                )

                            [Bufftip] => Mana Sphere
                            [Buffart] => ReplaceableTextures\CommandButtons\BTNOrbofSlowness.blp
                        )

                )

        )

    [units] => Array
        (
        )

    [references] => Array
        (
        )

    [lightning] => Array
        (
        )

)