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

            [Art] => ReplaceableTextures\CommandButtons\BTNCloudOfFog.blp
            [dmgplus1] => 1658
            [bldtm] => 1
            [goldcost] => 2000
            [unitSound] => AltarofStorms
            [sides1] => 1
            [manaN] => 10000
            [launchZ] => 127.5
            [acquire] => 800
            [upgrades] => Array
                (
                )

            [Upgrade] => Array
                (
                )

            [Name] => Cloudy Temple of Absorption
            [weapTp1] => missile
            [impactZ] => 127.5
            [MissileHoming] => 1
            [file] => buildings\other\ElvenGuardTower\ElvenGuardTower.mdl
            [Missilespeed] => 1500
            [Missileart] => Abilities\Weapons\ChimaeraLightningMissile\ChimaeraLightningMissile.mdl
            [dice1] => 1
            [RngBuff1] => 250
            [regenMana] => 0.01
            [modelScale] => 0.5
            [rangeN1] => 900
            [atkType1] => normal
            [cool1] => 1.4
            [Ubertip] => An ancient building, storing the power of storms.
            [abilList] => @@0@@
            [buildingShadow] => Array
                (
                )

            [targs1] => Array
                (
                )

            [weapsOn] => 1
        )

    [settings] => Array
        (
            [balanceTip] => |cffFFFF00+500 |rmana/lvl
            [abil_factor] => 0.5
            [author] => Natac
            [alpha] => 255
            [authorDisplay] => Natac
            [version] => 1.0
            [element] => storm
            [rarity] => unique
        )

    [effects] => Array
        (
            [0] => Array
                (
                    [x] => 17.1285
                    [y] => -7.76444
                    [z] => 0
                    [scale] => 0.3
                    [rot] => 4.62512
                    [file] => Doodads\Cityscape\Structures\City_ColumnSingle1_Ruined\City_ColumnSingle1_Ruined.mdl
                    [red] => 255
                    [green] => 255
                    [blue] => 255
                    [alpha] => 255
                    [pitch] => 0
                    [advanced] => false
                    [animation] => Array
                        (
                        )

                    [aniSpeed] => 50
                )

            [1] => Array
                (
                    [x] => -17.5544
                    [y] => -7.51003
                    [z] => 0
                    [scale] => 0.3
                    [rot] => 2.53073
                    [file] => Doodads\Cityscape\Structures\City_ColumnSingle1_Ruined\City_ColumnSingle1_Ruined.mdl
                    [red] => 255
                    [green] => 255
                    [blue] => 255
                    [alpha] => 255
                    [pitch] => 0
                    [advanced] => false
                    [animation] => Array
                        (
                        )

                    [aniSpeed] => 50
                )

            [2] => Array
                (
                    [x] => 0.0946293
                    [y] => 18.8388
                    [z] => 0
                    [scale] => 0.3
                    [rot] => 0.436332
                    [file] => Doodads\Cityscape\Structures\City_ColumnSingle1_Ruined\City_ColumnSingle1_Ruined.mdl
                    [red] => 255
                    [green] => 255
                    [blue] => 255
                    [alpha] => 255
                    [pitch] => 0
                    [advanced] => false
                    [animation] => Array
                        (
                        )

                    [aniSpeed] => 50
                )

            [3] => Array
                (
                    [x] => 15.0154
                    [y] => -7.78635
                    [z] => 44.8
                    [scale] => 0.2
                    [rot] => 4.62512
                    [file] => Doodads\Cityscape\Structures\City_ColumnSingle1_Ruined\City_ColumnSingle1_Ruined.mdl
                    [red] => 255
                    [green] => 255
                    [blue] => 255
                    [alpha] => 255
                    [pitch] => 0
                    [advanced] => false
                    [animation] => Array
                        (
                        )

                    [aniSpeed] => 50
                )

            [4] => Array
                (
                    [x] => -16.6542
                    [y] => -5.48066
                    [z] => 44.8
                    [scale] => 0.2
                    [rot] => 2.53073
                    [file] => Doodads\Cityscape\Structures\City_ColumnSingle1_Ruined\City_ColumnSingle1_Ruined.mdl
                    [red] => 255
                    [green] => 255
                    [blue] => 255
                    [alpha] => 255
                    [pitch] => 0
                    [advanced] => false
                    [animation] => Array
                        (
                        )

                    [aniSpeed] => 50
                )

            [5] => Array
                (
                    [x] => 1.19539
                    [y] => 16.6892
                    [z] => 44.8
                    [scale] => 0.2
                    [rot] => 0.436332
                    [file] => Doodads\Cityscape\Structures\City_ColumnSingle1_Ruined\City_ColumnSingle1_Ruined.mdl
                    [red] => 255
                    [green] => 255
                    [blue] => 255
                    [alpha] => 255
                    [pitch] => 0
                    [advanced] => false
                    [animation] => Array
                        (
                        )

                    [aniSpeed] => 50
                )

            [6] => Array
                (
                    [x] => 9.63957
                    [y] => -34.9407
                    [z] => 0
                    [scale] => 0.1
                    [rot] => 3.14159
                    [file] => Doodads\Cityscape\Structures\City_ColumnSemiCircle\City_ColumnSemiCircle.mdl
                    [red] => 255
                    [green] => 255
                    [blue] => 255
                    [alpha] => 255
                    [pitch] => 0
                    [advanced] => false
                    [animation] => Array
                        (
                        )

                    [aniSpeed] => 50
                )

            [7] => Array
                (
                    [x] => -15.8926
                    [y] => -34.4244
                    [z] => 0
                    [scale] => 0.1
                    [rot] => 0
                    [file] => Doodads\Cityscape\Structures\City_ColumnSemiCircle\City_ColumnSemiCircle.mdl
                    [red] => 255
                    [green] => 255
                    [blue] => 255
                    [alpha] => 255
                    [pitch] => 0
                    [advanced] => false
                    [animation] => Array
                        (
                        )

                    [aniSpeed] => 50
                )

            [8] => Array
                (
                    [x] => -0.724352
                    [y] => -0.938237
                    [z] => 108.8
                    [scale] => 1
                    [rot] => 2.23402
                    [file] => Abilities\Spells\Undead\UnholyFrenzy\UnholyFrenzyTarget.mdl
                    [red] => 255
                    [green] => 255
                    [blue] => 255
                    [alpha] => 255
                    [pitch] => 0
                    [advanced] => false
                    [animation] => Array
                        (
                        )

                    [aniSpeed] => 50
                )

            [9] => Array
                (
                    [x] => -4.4073
                    [y] => -33.4295
                    [z] => 6.4
                    [scale] => 1
                    [rot] => 2.23402
                    [file] => Abilities\Spells\Undead\UnholyFrenzy\UnholyFrenzyTarget.mdl
                    [red] => 255
                    [green] => 255
                    [blue] => 255
                    [alpha] => 255
                    [pitch] => 0
                    [advanced] => false
                    [animation] => Array
                        (
                        )

                    [aniSpeed] => 50
                )

            [10] => Array
                (
                    [x] => -30.0588
                    [y] => 25.3148
                    [z] => 12.8
                    [scale] => 1
                    [rot] => 2.23402
                    [file] => Abilities\Spells\Undead\UnholyFrenzy\UnholyFrenzyTarget.mdl
                    [red] => 255
                    [green] => 255
                    [blue] => 255
                    [alpha] => 255
                    [pitch] => 0
                    [advanced] => false
                    [animation] => Array
                        (
                        )

                    [aniSpeed] => 50
                )

            [11] => Array
                (
                    [x] => -37.3846
                    [y] => 14.4721
                    [z] => 0
                    [scale] => 0.1
                    [rot] => 0.904637
                    [file] => Doodads\Cityscape\Structures\City_ColumnSemiCircle\City_ColumnSemiCircle.mdl
                    [red] => 255
                    [green] => 255
                    [blue] => 255
                    [alpha] => 255
                    [pitch] => 0
                    [advanced] => false
                    [animation] => Array
                        (
                        )

                    [aniSpeed] => 50
                )

            [12] => Array
                (
                    [x] => -21.8678
                    [y] => 32.5137
                    [z] => 0
                    [scale] => 0.1
                    [rot] => 4.01426
                    [file] => Doodads\Cityscape\Structures\City_ColumnSemiCircle\City_ColumnSemiCircle.mdl
                    [red] => 255
                    [green] => 255
                    [blue] => 255
                    [alpha] => 255
                    [pitch] => 0
                    [advanced] => false
                    [animation] => Array
                        (
                        )

                    [aniSpeed] => 50
                )

            [13] => Array
                (
                    [x] => 34.6135
                    [y] => 20.513
                    [z] => 12.8
                    [scale] => 1
                    [rot] => 2.23402
                    [file] => Abilities\Spells\Undead\UnholyFrenzy\UnholyFrenzyTarget.mdl
                    [red] => 255
                    [green] => 255
                    [blue] => 255
                    [alpha] => 255
                    [pitch] => 0
                    [advanced] => false
                    [animation] => Array
                        (
                        )

                    [aniSpeed] => 50
                )

            [14] => Array
                (
                    [x] => 24.9044
                    [y] => 27.9886
                    [z] => 0
                    [scale] => 0.1
                    [rot] => 5.44543
                    [file] => Doodads\Cityscape\Structures\City_ColumnSemiCircle\City_ColumnSemiCircle.mdl
                    [red] => 255
                    [green] => 255
                    [blue] => 255
                    [alpha] => 255
                    [pitch] => 0
                    [advanced] => false
                    [animation] => Array
                        (
                        )

                    [aniSpeed] => 50
                )

            [15] => Array
                (
                    [x] => 40.132
                    [y] => 9.96611
                    [z] => 0
                    [scale] => 0.1
                    [rot] => 2.27315
                    [file] => Doodads\Cityscape\Structures\City_ColumnSemiCircle\City_ColumnSemiCircle.mdl
                    [red] => 255
                    [green] => 255
                    [blue] => 255
                    [alpha] => 255
                    [pitch] => 0
                    [advanced] => false
                    [animation] => Array
                        (
                        )

                    [aniSpeed] => 50
                )

        )

    [dmgTable] => Array
        (
            [0] => Array
                (
                    [id] => MOD_MANA
                    [base] => 0
                    [add] => 500
                )

        )

    [triggers] => Array
        (
            [0] => Array
                (
                    [name] => Header
                    [code] => globals
        // --- Aura ---
        BuffType        natac_obsorption_BuffType
        ProjectileType  natac_obsorption_ProjectileType
        
        // --- Storm ---
        BuffType        natac_stormTarget_BuffType
        integer array   natac_stormManaReductionValues
        
        // --- MB ---
        MultiboardValues MB
    endglobals
    
    // --- Storm Buff Handling ---
    
    function storm_onDamaged takes Buff b returns nothing
        local Tower caster = b.getCaster()
        local Creep buffed = b.getBuffedUnit()
        local unit bufUnit = buffed.getUnit()
        local real dmgTaken= RMinBJ(Event.damage, GetUnitState(bufUnit, UNIT_STATE_LIFE)) // Calculate how much damage is really dealt
        local integer size = buffed.getSize()
        
        // Remove mana from the tower according to the damage taken and the size of the creep
        call caster.subtractMana(dmgTaken * 0.1 * natac_stormManaReductionValues[size] * (dmgTaken/GetUnitState(bufUnit, UNIT_STATE_MAX_LIFE)), true)
        call b.removeBuff()
        set bufUnit = null
    endfunction
    
    // Enables the storm. This function is needed, cause the storm can be enabled by two events:
    // a) Tower reaches max mana per mana ball
    // b) Creep comes in range of tower when tower's mana has satisfied threshold
    function enableStorm takes Tower tower returns nothing
        if(tower.userInt3 == 0) then
            call PeriodicEvent(tower.userInt).enable()
            set tower.userInt3 = Effect.create("Abilities\\Spells\\Human\\CloudOfFog\\CloudOfFog.mdl", tower.getX(), tower.getY(), 150.0, 0.0)
        endif
    endfunction
    
    
    //--- Aura Buff + Projectile Handling ---
    //If a creep with the auras buff is killed, a projectile spawns
    
    // Reaction of a natac_obsorption_AuraBuffType on Damage
    function aura_onDamagedSpawnManaBall takes Buff b returns nothing
        local real damage = Event.damage
        local Unit target = b.getBuffedUnit()
        local real life  = GetUnitState(target.getUnit(), UNIT_STATE_LIFE)
        local Unit caster
        local Projectile manaBall
        
        // Only spawn the ball if
        // a) the unit will die
        // b) the unit isnt hit by the storm spell
        if damage > life and target.getBuffOfType(natac_stormTarget_BuffType) == 0 then
            set caster = b.getCaster() 
            set manaBall = Projectile.createFromPointToUnit(natac_obsorption_ProjectileType, caster, 0.0, 0.0, target.getX(), target.getY(), 0.0, caster, true, false, false)
            set manaBall.userReal = damage - life
        endif
    endfunction
    
    // Reaction of a natac_obsorption_ProjectileType if it reaches the tower
    function aura_reachTower takes Projectile p, Unit tower returns nothing
        local real grantedMana
        local real maxMana
        local real currentMana
        
        if(tower != 0) then
            set maxMana = GetUnitState(tower.getUnit(), UNIT_STATE_MAX_MANA)
            set currentMana = GetUnitState(tower.getUnit(), UNIT_STATE_MANA)
            set grantedMana = p.userReal * (1 + tower.getLevel()*0.05)
            
            // Add mana
            if(grantedMana > 0) then
                call tower.addMana(grantedMana)
            endif
            call tower.getOwner().displaySmallFloatingText("+"+I2S(R2I(RMinBJ(maxMana - currentMana, grantedMana))), tower, 0, 0, 255, 40)
            
            // If Mana is filled, enable storm
            if tower.userInt != 0 and (currentMana + grantedMana >= maxMana) then
                call enableStorm(tower)
            endif
        endif
    endfunction
    
    // --- Init Function ---
    
    //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
        // --- Aura ---
        set  natac_obsorption_BuffType = BuffType.createAuraEffectType(false)
        call natac_obsorption_BuffType.setBuffIcon('@@1@@')
        call natac_obsorption_BuffType.addEventOnDamaged(EventHandler.aura_onDamagedSpawnManaBall, 1.0, 0.0)
        
        set  natac_obsorption_ProjectileType = ProjectileType.createRanged("Abilities\\Weapons\\FarseerMissile\\FarseerMissile.mdl", 1000+100, 500)
        call natac_obsorption_ProjectileType.enableHoming(aura_reachTower, 0.0)
        
        // --- Storm ---
        set  natac_stormTarget_BuffType = BuffType.create(-1.0, 0.0, false)
        call natac_stormTarget_BuffType.addEventOnDamaged(EventHandler.storm_onDamaged, 1.0, 0.0)
        set  natac_stormManaReductionValues[SIZE_CHALLENGE] = 130
        set  natac_stormManaReductionValues[SIZE_BOSS] = 100
        set  natac_stormManaReductionValues[SIZE_CHAMPION] = 20
        set  natac_stormManaReductionValues[SIZE_NORMAL] = 10
        set  natac_stormManaReductionValues[SIZE_AIR] = 20
        set  natac_stormManaReductionValues[SIZE_MASS] = 5
        set  natac_stormManaReductionValues[SIZE_MASS_CHALLENGE] = 13
        
        // --- MB ---
        set MB = MultiboardValues.create(1)
        call MB.setKey(0, "Mana required")
	endfunction
                    [values] => Array
                        (
                            [visible] => false
                            [icon] => 
                            [name] => 
                            [short_explain] => 
                            [long_explain] => 
                        )

                )

            [1] => Array
                (
                    [name] => On Tower Details
                    [code] => call MB.setValue(0, formatPercent(tower.userReal, 0))
    return MB
                    [values] => Array
                        (
                        )

                )

            [2] => Array
                (
                    [name] => On Tower Destruction
                    [code] => if tower.userInt3 != 0 then
        call Effect(tower.userInt3).destroy()
    endif
                    [values] => Array
                        (
                            [visible] => false
                            [icon] => 
                            [name] => 
                            [short_explain] => 
                            [long_explain] => 
                        )

                )

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

                    [values] => Array
                        (
                            [AURA_powerAdd] => 1
                            [visible] => true
                            [AURA_auraEffect] => natac_obsorption_BuffType
                            [AURA_levelAdd] => 1
                            [AURA_power] => 1
                            [icon] => ReplaceableTextures\CommandButtons\BTNHornOfFog.blp
                            [AURA_targetType] => TARGET_TYPE_CREEPS
                            [long_explain] => Creates a lightning ball if a creep in |cFFFFFF801000|r range is killed with more damage than needed. The lighting ball absorbs the redundant damage and transfers it to this temple. Every |cFFFFFF801|r damage absorbed grants |cFFFFFF801|r mana.|n|n|cffFF8000Level Bonus:|r|n|cFFFFFF80+0.05|r mana per absorbed damage
                            [AURA_targetSelf] => false
                            [name] => Cloud of Absorption
                            [AURA_level] => 1
                            [short_explain] => Absorbs redundant damage when creeps in range die.
                            [AURA_auraRange] => 1000
                        )

                )

            [4] => Array
                (
                    [name] => Periodic
                    [code] => local unit towerUnit = tower.getUnit()
    local real mana = GetUnitState(towerUnit, UNIT_STATE_MANA)
    local PeriodicEvent storm  
    local Iterate it
    local Unit target
  
    // The next strike will be realeased, if
    // a) The storm is enabled AND
    // b) The tower has still some mana AND
    // c) No timeout is reached
    if tower.userInt != 0 and mana > 1000.0 and tower.userInt2 < 10 then
        // -> Release next strike
        
        // Set the local values
        set it = Iterate.overUnitsInRangeOfCaster(tower, TARGET_CREEPS, 1000)
        set target = it.nextRandom()
        
        if(target != 0) then
            call it.destroy()
            // Do full available damage and apply buff,
            set tower.userInt2 = 0 // Reset timeout-counter
            call natac_stormTarget_BuffType.apply(tower, target, 1)
            call tower.doSpellDamage(target, GetUnitState(towerUnit, UNIT_STATE_MANA) * (0.5+tower.getLevel()*0.02), tower.calcSpellCritNoBonus())
            call SFXAtUnit("Abilities\\Spells\\Other\\Monsoon\\MonsoonBoltTarget.mdl", target.getUnit())
        else
            // Increase timeout counter
            set tower.userInt2 = tower.userInt2 + 1 
        endif
    else
        // -> Disable Storm
        set storm = Event.getCurrentPeriodicEvent() 
        set tower.userInt = storm
        call storm.disable()
        
        if tower.userInt3 != 0 then
            call Effect(tower.userInt3).destroy()
            set tower.userInt3 = 0
        endif
        
        set tower.userInt2 = 0 //reset timeout counter
    endif
    set towerUnit = null
                    [values] => Array
                        (
                            [visible] => false
                            [PERIODIC_period] => 0.4
                            [icon] => 
                            [name] => 
                            [short_explain] => 
                            [long_explain] => 
                        )

                )

            [5] => Array
                (
                    [name] => Autocast
                    [code] => call SetUnitState(tower.getUnit(), UNIT_STATE_MANA, GetUnitState(tower.getUnit(), UNIT_STATE_MANA) + 1000.0)
    if tower.userInt != 0 then
        call enableStorm(tower)
    endif
                    [values] => Array
                        (
                            [AUTOCAST_cooldown] => 0.01
                            [AUTOCAST_autoRange] => 0
                            [visible] => true
                            [AUTOCAST_manacost] => 1000
                            [icon] => ReplaceableTextures\CommandButtons\BTNMonsoon.blp
                            [AUTOCAST_range] => 0
                            [AUTOCAST_targetType] => 0
                            [AUTOCAST_numBuffsBeforeIdle] => 0
                            [caster_art] => 
                            [long_explain] => Summons a cloudy thunderstorm, which strikes random creeps in |cffFFFF801000|r range every |cffFFFF800.4|r seconds with lightning. Each strike deals |cffFFFF80[Current Mana x 0.5]|r spell damage and costs mana based on the target's size and the damage dealt. The storm ends when this tower's mana falls below |cffFFFF801000|r, or no creep comes within range for |cffFFFF804|r seconds.|nThis ability will activate automatically when this tower's mana reaches a set threshold, as determined by the 'Adjust Autocast Threshold' ability. The autocast cannot be disabled.|n|n|cffFF8000Level Bonus:|r|n|cFFFFFF80+0.02|r damage per current mana
                            [target_art] => 
                            [AUTOCAST_autocastType] => AC_TYPE_NOAC_IMMEDIATE
                            [AUTOCAST_buffType] => 0
                            [AUTOCAST_isExtended] => false
                            [name] => Cloudy Thunderstorm
                            [AUTOCAST_targetSelf] => false
                            [short_explain] => Summons a cloudy thunderstorm after absorbing enough mana.
                        )

                )

            [6] => Array
                (
                    [name] => Autocast
                    [code] => if tower.userReal >= 1.0 then
        set tower.userReal = 0.0
    endif
    set tower.userReal = tower.userReal + 0.1
    
    call tower.getOwner().displaySmallFloatingText(formatPercent(tower.userReal, 0), tower, 155, 155, 255, 40.0)
                    [values] => Array
                        (
                            [AUTOCAST_cooldown] => 0.01
                            [AUTOCAST_autoRange] => 0
                            [visible] => true
                            [AUTOCAST_manacost] => 0
                            [icon] => ReplaceableTextures\CommandButtons\BTNReplay-Loop.blp
                            [AUTOCAST_range] => 0
                            [AUTOCAST_targetType] => 0
                            [AUTOCAST_numBuffsBeforeIdle] => 0
                            [caster_art] => 
                            [long_explain] => Use this ability to adjust the percentual mana required for Cloudy Thunderstorm's autocast.
                            [target_art] => 
                            [AUTOCAST_autocastType] => AC_TYPE_NOAC_IMMEDIATE
                            [AUTOCAST_buffType] => 0
                            [AUTOCAST_isExtended] => false
                            [name] => Adjust Autocast Threshold
                            [AUTOCAST_targetSelf] => false
                            [short_explain] => Adjusts the required mana threshold for Cloudy Thunderstorm's autocast.
                        )

                )

            [7] => Array
                (
                    [name] => On Unit Comes In Range
                    [code] => local unit towerUnit = tower.getUnit()
    
    // Enable the storm if the tower is ready and a non-immune creep comes in range
    if tower.userInt != 0 and not Event.getTarget().isImmune() then
        if GetUnitState(towerUnit, UNIT_STATE_MANA) >= (tower.userReal * GetUnitState(towerUnit, UNIT_STATE_MAX_MANA)) then
            call enableStorm(tower)
        endif
    endif
    set towerUnit = null
                    [values] => Array
                        (
                            [UNITINRANGE_targetType] => TARGET_TYPE_CREEPS
                            [visible] => false
                            [icon] => 
                            [name] => 
                            [short_explain] => 
                            [UNITINRANGE_range] => 1000
                            [long_explain] => 
                        )

                )

            [8] => Array
                (
                    [name] => On Tower Creation
                    [code] => set tower.userInt  = 0 // Stores the periodic event. Init with 0
    set tower.userInt2 = 0 // Stores the number of effectless periodic events. Is used for the timeout. 
    set tower.userInt3 = 0 // Stores the effect, shown during the storm
    
    set tower.userReal = 1.0 //Percentage required to trigger the storm
                    [values] => Array
                        (
                            [visible] => false
                            [icon] => 
                            [name] => 
                            [short_explain] => 
                            [long_explain] => 
                        )

                )

        )

    [abilities] => Array
        (
            [0] => Array
                (
                    [id] => @@0@@
                    [derivedFrom] => Alit
                    [oeValues] => Array
                        (
                            [Art] => Array
                                (
                                )

                            [race] => creeps
                            [Unubertip] => -HIDE-
                            [Name] => Lightning Attack
                        )

                )

        )

    [buffs] => Array
        (
            [0] => Array
                (
                    [id] => @@1@@
                    [derivedFrom] => Bclf
                    [oeValues] => Array
                        (
                            [EditorName] => Cloud of Absorption
                            [Buffubertip] => The damage wasted on this units death will be absorbed.
                            [Bufftip] => Cloud of Obsorption
                            [Buffart] => ReplaceableTextures\CommandButtons\BTNHornOfFog.blp
                        )

                )

        )

    [units] => Array
        (
        )

    [references] => Array
        (
        )

)