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

            [Art] => ReplaceableTextures\CommandButtons\BTNCyclone.blp
            [dmgplus1] => 945
            [bldtm] => 1
            [goldcost] => 4000
            [sides1] => 7
            [Missilearc] => 0.3
            [manaN] => 100
            [acquire] => 1100
            [upgrades] => Array
                (
                )

            [Upgrade] => Array
                (
                )

            [Name] => Chaining Storm
            [splashTargs1] => enemies
            [weapTp1] => missile
            [MissileHoming] => 1
            [file] => Doodads\Cityscape\Props\MagicRunes\MagicRunes0.mdl
            [Missileart] => Abilities\Weapons\FarseerMissile\FarseerMissile.mdl
            [Missilespeed] => 1500
            [dice1] => 1
            [RngBuff1] => 250
            [regenMana] => 10
            [modelScale] => 1.4
            [rangeN1] => 1100
            [atkType1] => normal
            [cool1] => 1.5
            [Ubertip] => A mighty storm surrounds this tower to crush enemies in range!
            [abilList] => Array
                (
                )

            [moveHeight] => -40
            [buildingShadow] => Array
                (
                )

            [targs1] => enemies
            [weapsOn] => 1
        )

    [settings] => Array
        (
            [balanceTip] => |cffFFFF00+50% |rdmg to air (|cffFFFF00+2%|r/lvl)|n|cffFFFF00+15 |rmana/lvl|n|cffFFFF00+0.1 |rmana regen/lvl
            [abil_factor] => 0.15
            [author] => SternBogen
            [alpha] => 255
            [comment] => :)
            [authorDisplay] => SternBogen
            [version] => 1.43
            [element] => storm
            [rarity] => unique
        )

    [effects] => Array
        (
            [0] => Array
                (
                    [x] => 1.23227
                    [y] => 2.45123
                    [z] => 0
                    [scale] => 0.3
                    [rot] => 2.28708
                    [file] => Abilities\Spells\NightElf\Cyclone\CycloneTarget.mdl
                    [red] => 255
                    [green] => 255
                    [blue] => 255
                    [alpha] => 255
                    [pitch] => 0
                    [advanced] => false
                    [animation] => Array
                        (
                        )

                    [aniSpeed] => 50
                )

            [1] => Array
                (
                    [x] => 0.538401
                    [y] => -0.164124
                    [z] => -51.2
                    [scale] => 1
                    [rot] => 2.29374
                    [file] => Doodads\Cinematic\FootSwitch\FootSwitch.mdl
                    [red] => 255
                    [green] => 255
                    [blue] => 255
                    [alpha] => 255
                    [pitch] => 0
                    [advanced] => false
                    [animation] => Array
                        (
                        )

                    [aniSpeed] => 50
                )

            [2] => Array
                (
                    [x] => 0.602627
                    [y] => 1.07624
                    [z] => -70.4
                    [scale] => 0.5
                    [rot] => 2.29748
                    [file] => buildings\other\HarpyNest\HarpyNest.mdl
                    [red] => 255
                    [green] => 255
                    [blue] => 255
                    [alpha] => 255
                    [pitch] => 0
                    [advanced] => false
                    [animation] => Array
                        (
                        )

                    [aniSpeed] => 50
                )

            [3] => Array
                (
                    [x] => 11.781
                    [y] => 6.30794
                    [z] => 0
                    [scale] => 0.08
                    [rot] => 3.1444
                    [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
                )

            [4] => Array
                (
                    [x] => -11.7302
                    [y] => 6.63216
                    [z] => 0
                    [scale] => 0.08
                    [rot] => 0.0200329
                    [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
                )

            [5] => Array
                (
                    [x] => -0.532457
                    [y] => 4.60856
                    [z] => 0
                    [scale] => 1
                    [rot] => 0.802852
                    [file] => Abilities\Spells\Human\StormBolt\StormBoltTarget.mdl
                    [red] => 255
                    [green] => 255
                    [blue] => 255
                    [alpha] => 255
                    [pitch] => 0
                    [advanced] => false
                    [animation] => Array
                        (
                        )

                    [aniSpeed] => 50
                )

            [6] => Array
                (
                    [x] => 42.0864
                    [y] => -42.4701
                    [z] => 0
                    [scale] => 0.4
                    [rot] => 2.30457
                    [file] => Doodads\Cityscape\Props\CrystalLamp\CrystalLamp.mdl
                    [red] => 255
                    [green] => 255
                    [blue] => 255
                    [alpha] => 255
                    [pitch] => 0
                    [advanced] => false
                    [animation] => Array
                        (
                        )

                    [aniSpeed] => 50
                )

            [7] => Array
                (
                    [x] => 2.14734
                    [y] => 3.43321
                    [z] => 0
                    [scale] => 0.35
                    [rot] => 4.71466
                    [file] => Doodads\Ruins\Props\Ruins_NagaCircle\Ruins_NagaCircle.mdl
                    [red] => 200
                    [green] => 200
                    [blue] => 200
                    [alpha] => 255
                    [pitch] => 0
                    [advanced] => false
                    [animation] => Array
                        (
                        )

                    [aniSpeed] => 50
                )

            [8] => Array
                (
                    [x] => 3.73858
                    [y] => -5.57118
                    [z] => -38.4
                    [scale] => 1
                    [rot] => 3.33358
                    [file] => Doodads\Cityscape\Props\MagicRunes\MagicRunes0.mdl
                    [red] => 255
                    [green] => 255
                    [blue] => 255
                    [alpha] => 255
                    [pitch] => 0
                    [advanced] => false
                    [animation] => Array
                        (
                        )

                    [aniSpeed] => 50
                )

            [9] => Array
                (
                    [x] => 1.43731
                    [y] => -0.609868
                    [z] => -32
                    [scale] => 0.45
                    [rot] => 2.29536
                    [file] => Doodads\Cityscape\Props\CrystalLamp\CrystalLamp.mdl
                    [red] => 255
                    [green] => 255
                    [blue] => 255
                    [alpha] => 255
                    [pitch] => 0
                    [advanced] => false
                    [animation] => Array
                        (
                        )

                    [aniSpeed] => 50
                )

            [10] => Array
                (
                    [x] => -39.7941
                    [y] => -45.2936
                    [z] => 0
                    [scale] => 0.4
                    [rot] => 2.04868
                    [file] => Doodads\Cityscape\Props\CrystalLamp\CrystalLamp.mdl
                    [red] => 255
                    [green] => 255
                    [blue] => 255
                    [alpha] => 255
                    [pitch] => 0
                    [advanced] => false
                    [animation] => Array
                        (
                        )

                    [aniSpeed] => 50
                )

            [11] => Array
                (
                    [x] => 1.96213
                    [y] => -63.6821
                    [z] => 0
                    [scale] => 0.4
                    [rot] => 1.5708
                    [file] => Doodads\Cityscape\Props\CrystalLamp\CrystalLamp.mdl
                    [red] => 255
                    [green] => 255
                    [blue] => 255
                    [alpha] => 255
                    [pitch] => 0
                    [advanced] => false
                    [animation] => Array
                        (
                        )

                    [aniSpeed] => 50
                )

            [12] => Array
                (
                    [x] => 53.8934
                    [y] => 9.53792
                    [z] => 0
                    [scale] => 0.4
                    [rot] => 2.47115
                    [file] => Doodads\Cityscape\Props\CrystalLamp\CrystalLamp.mdl
                    [red] => 255
                    [green] => 255
                    [blue] => 255
                    [alpha] => 255
                    [pitch] => 0
                    [advanced] => false
                    [animation] => Array
                        (
                        )

                    [aniSpeed] => 50
                )

            [13] => Array
                (
                    [x] => -56.8243
                    [y] => 5.26087
                    [z] => 0
                    [scale] => 0.4
                    [rot] => 2.09034
                    [file] => Doodads\Cityscape\Props\CrystalLamp\CrystalLamp.mdl
                    [red] => 255
                    [green] => 255
                    [blue] => 255
                    [alpha] => 255
                    [pitch] => 0
                    [advanced] => false
                    [animation] => Array
                        (
                        )

                    [aniSpeed] => 50
                )

            [14] => Array
                (
                    [x] => -20.2417
                    [y] => 57.3945
                    [z] => 0
                    [scale] => 0.4
                    [rot] => 1.5708
                    [file] => Doodads\Cityscape\Props\CrystalLamp\CrystalLamp.mdl
                    [red] => 255
                    [green] => 255
                    [blue] => 255
                    [alpha] => 255
                    [pitch] => 0
                    [advanced] => false
                    [animation] => Array
                        (
                        )

                    [aniSpeed] => 50
                )

            [15] => Array
                (
                    [x] => 20.0885
                    [y] => 57.7223
                    [z] => 0
                    [scale] => 0.4
                    [rot] => 1.5708
                    [file] => Doodads\Cityscape\Props\CrystalLamp\CrystalLamp.mdl
                    [red] => 255
                    [green] => 255
                    [blue] => 255
                    [alpha] => 255
                    [pitch] => 0
                    [advanced] => false
                    [animation] => Array
                        (
                        )

                    [aniSpeed] => 50
                )

            [16] => Array
                (
                    [x] => 1.76795
                    [y] => 2.1936
                    [z] => -19.2
                    [scale] => 0.12
                    [rot] => 3.80482
                    [file] => Doodads\Dalaran\Terrain\DalaranBuilding\DalaranBuilding1.mdl
                    [red] => 255
                    [green] => 255
                    [blue] => 255
                    [alpha] => 255
                    [pitch] => 0
                    [advanced] => false
                    [animation] => Array
                        (
                        )

                    [aniSpeed] => 50
                )

        )

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

            [1] => Array
                (
                    [id] => MOD_MANA
                    [base] => 0
                    [add] => 15
                )

            [2] => Array
                (
                    [id] => MOD_MANA_REGEN
                    [base] => 0
                    [add] => 0.1
                )

        )

    [triggers] => Array
        (
            [0] => Array
                (
                    [name] => On Attack
                    [code] => local Unit creep = Event.getTarget()
    local real x = creep.getX()
    local real y = creep.getY()
    local integer numCreeps = 0
    local integer lvl = tower.getLevel()
    local Creep curCreep
    local Iterate creepsInRange
    local real bonusSpellCrit = 0.0
    local real mod
    local real airBonus = 1.0
    local unit towerUnit = tower.getUnit()
    local real mana = GetUnitState(towerUnit, UNIT_STATE_MANA)
    
    if tower.calcChance(0.25 + 0.0125 * lvl + tower.userInt * 0.0002) and tower.subtractMana(100, false) == 100 then
        // remove Mana
        // First Iteration
        // for damage -> count creeps (save in: numCreeps)
        
        set creepsInRange = Iterate.overUnitsInRangeOfUnit(tower, TARGET_CREEPS, creep, 350)
        loop
            set curCreep = creepsInRange.next()
            exitwhen curCreep == 0
            set numCreeps = numCreeps + 1
        endloop
        
        // do effects
        call Effect.createSimple("Abilities\\Spells\\Human\\Thunderclap\\ThunderClapCaster.mdl", x, y).destroy()
        call Effect.createSimple("Abilities\\Spells\\NightElf\\Cyclone\\CycloneTarget.mdl", x, y).destroy()
        call Effect.createSimple("Abilities\\Spells\\Other\\Drain\\ManaDrainTarget.mdl", x, y).setLifetime(1)
        
        //Adjust ratios against air.
        if (SIZE_AIR == creep.getSize()) then
            set bonusSpellCrit = 0.25
            set airBonus = 2.0
        endif
        call tower.doSpellDamageAoEUnit(creep, 350, numCreeps * airBonus * (200 + lvl * 65), tower.calcSpellCritNoBonus() + bonusSpellCrit,0)
        
        // weaken creeps (weakening is divided by the number of creeps hit)
        set creepsInRange = Iterate.overUnitsInRangeOfUnit(tower, TARGET_CREEPS, creep, 350)
        set mod = (0.02 + 0.0012 * lvl) * numCreeps
        loop
            set curCreep = creepsInRange.next()
            exitwhen curCreep == 0
            call curCreep.modifyProperty(MOD_DMG_FROM_STORM, mod)
            call curCreep.modifyProperty(MOD_DMG_FROM_ICE, mod)
            call curCreep.modifyProperty(MOD_DMG_FROM_ASTRAL, mod)
        endloop
    endif
    set towerUnit = null
                    [values] => Array
                        (
                            [visible] => true
                            [icon] => ReplaceableTextures\CommandButtons\BTNTornado.blp
                            [name] => Chaining Storm
                            [short_explain] => There is a chance to attack all creeps around the main target with a Chaining Storm for the cost of some mana.
                            [ONATTACK_chance] => 1.0
                            [ONATTACK_chanceLevelAdd] => 0.0
                            [long_explain] => Whenever this tower attacks, it has a |cffFFFF8025%|r chance to cast a Chaining Storm at the position of the attacked creep for the cost of |cffFFFF80100|r mana. All creeps in |cffFFFF80350|r range of the Chaining Storm suffer |cffFFFF80200|r spelldamage multiplied by the number of creeps hit. They are also weakened to receive |cffFFFF802%|r more damage from |cFF8080FFStorm|r, |cFF00FFFFIce|r and |cFFFFFF80Astral|r Towers for each hitted creep. All effects of this ability are doubled and a |cffFFFF8025%|r higher spell critical chance is applied whenever the main target hit is an air unit.|n|n|cffFF8000Level Bonus:|r|n|cffFFFF80+1.25%|r trigger chance|n|cffFFFF80+65|r damage|n|cffFFFF80+0.12%|r received damage
                        )

                )

            [1] => Array
                (
                    [name] => Header
                    [code] => globals
        BuffType stern_slowBuffCS
        MultiboardValues stern_stormPowerMB
    endglobals
    
    //Do not remove or rename this function!
    //Put your initialization tasks here, this function will be called on map init
    
    function strongWindOnCreate takes Buff b returns nothing
        set b.userInt = 0 //will be used to store buff level
        set b.userInt2 = 0 // counts number of stacks
        set b.userReal = 0.0 //records movespeed stolen (in case aura has levelled)
        set b.userReal2 = 0.03 //stores slow factor, so that we don't need to recalculate it every second
    endfunction
    
    function strongWindPeriodic takes Buff b returns nothing
        local Tower caster = b.getCaster()
        local Unit creep = b.getBuffedUnit()
        local integer buffLevel = b.getLevel()
        // local unit u = caster.getUnit()
        
        //Check if aura level hasn't changed
        if buffLevel != b.userInt then
            set b.userInt = buffLevel
            //Give creep back its old movespeed and calculate new slow factor.
            set b.userReal2 = 0.03 + 0.0008 * buffLevel
            if (creep.getSize() == SIZE_AIR) then
                set b.userReal2 = b.userReal2 * 2
            endif
            
            //Adjust movespeed accordingly
            call creep.modifyProperty(MOD_MOVESPEED, b.userReal - b.userReal2 * b.userInt2)
            set b.userReal = b.userReal2 * b.userInt2
        endif
        
        //Apply slow
        if b.userInt2 < 15 then //Max 15 stacks
            //Add slow
            set b.userInt2 = b.userInt2 + 1
            call creep.modifyProperty(MOD_MOVESPEED, -b.userReal2)
            set b.userReal = b.userReal + b.userReal2
        endif
        
        //Deal damage
        call caster.doAttackDamage(creep, b.userReal * 10 * caster.getCurrentAttackDamageWithBonus() * (1 + 0.05 * buffLevel + 0.0005 * caster.userInt), caster.calcAttackMulticrit(0,0,0))
        // method displayFloatingText takes string whichText, Unit whichUnit, integer red, integer green, integer blue returns nothing
        // call caster.getOwner().displayFloatingText(R2S(1 + 0.05 * buffLevel + 0.0005 * caster.userInt), caster, 200, 0, 0)
        // call caster.getOwner().displayFloatingText(R2S(b.userReal), caster, 0, 200, 0)
        
        // userReal 0.01 -> 0.02 -> *100   10% of damage  -> *10 total
        // call caster.getOwner().displayFloatingText(R2S(b.userReal * 10 * caster.getCurrentAttackDamageWithBonus() * (1 + 0.05 * buffLevel + 0.0005 * caster.userInt)), creep, 200, 0, 0)
    endfunction
    
    function strongWindOnCleanup takes Buff b returns nothing
        local Tower caster = b.getCaster()
        local Unit creep = b.getBuffedUnit()
        if (GetUnitState(creep.getUnit(), UNIT_STATE_LIFE) > 0) then
            //Give creep its movespeed back
            call creep.modifyProperty(MOD_MOVESPEED, b.userReal)
        else
            // creep died under the effect? Increse storm power!
            set caster.userInt = caster.userInt + 1
            // + mana
            call caster.subtractMana(-35,true)
        endif

    endfunction
    
    private function init takes nothing returns nothing
        set stern_slowBuffCS = BuffType.createAuraEffectType(false)
        call stern_slowBuffCS.setBuffIcon('@@0@@')
        call stern_slowBuffCS.addEventOnCreate(strongWindOnCreate)
        call stern_slowBuffCS.addPeriodicEvent(strongWindPeriodic, 1.0)
        call stern_slowBuffCS.addEventOnCleanup(strongWindOnCleanup)
        
        set stern_stormPowerMB = MultiboardValues.create(1)
        call stern_stormPowerMB.setKey(0,"Storm Power")
    endfunction
                    [values] => Array
                        (
                            [visible] => true
                            [icon] => ReplaceableTextures\CommandButtons\BTNCyclone.blp
                            [name] => Strong Wind
                            [short_explain] => The Strong Wind slows and damages nearby creeps.
                            [long_explain] => All creeps in |cffFFFF80900|r range are affected by Strong Winds. Every second a creep is under this effect, it loses |cffFFFF803%|r of its movespeed and it is dealt |cffFFFF8010%|r of towers attack damage for every |cffFFFF801%|r of movespeed it is missing. Slow effect stacks up to |cffFFFF8015|r times. Slow effect and damage is doubled for air units.|n|n|cffFF8000Level Bonus:|r|n|cffFFFF80+0.08%|r slow|n|cffFFFF80+5|r damage per |cffFFFF801%|r slow
                        )

                )

            [2] => Array
                (
                    [name] => On Tower Details
                    [code] => call stern_stormPowerMB.setValue(0, I2S(tower.userInt))
    return stern_stormPowerMB
                    [values] => Array
                        (
                            [0] => Array
                                (
                                    [_value] => 0
                                    [typ] => string
                                )

                        )

                )

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

                    [values] => Array
                        (
                            [AURA_powerAdd] => 1
                            [visible] => true
                            [AURA_auraEffect] => stern_slowBuffCS
                            [AURA_levelAdd] => 1
                            [AURA_power] => 0
                            [icon] => ReplaceableTextures\CommandButtons\BTNBrilliance.blp
                            [AURA_targetType] => TARGET_TYPE_CREEPS
                            [long_explain] => If a creep dies while under the effect of Strong Wind its living energy is converted in |cffFFFF80+35|r mana and boost this tower's abilities. Each death increases the triggerchance for Chaining Storm by |cffFFFF80+0.02%|r (maximum total triggerchance for Chaining Storm is |cffFFFF8075%|r) and also increase the damage dealt with Strong Winds by |cffFFFF800.05|r damage per |cffFFFF801%|r slow.
                            [AURA_targetSelf] => false
                            [name] => Storm Power
                            [AURA_level] => 0
                            [short_explain] => Strengthens the tower's abilities with each creep death.
                            [AURA_auraRange] => 900.0
                        )

                )

            [4] => Array
                (
                    [name] => On Tower Creation
                    [code] => set tower.userInt = 0 //Storm Power
                    [values] => Array
                        (
                            [visible] => false
                            [icon] => 
                            [name] => 
                            [short_explain] => 
                            [long_explain] => 
                        )

                )

        )

    [abilities] => Array
        (
        )

    [buffs] => Array
        (
            [0] => Array
                (
                    [id] => @@0@@
                    [derivedFrom] => Bprg
                    [oeValues] => Array
                        (
                            [EditorName] => Strong Wind
                            [Buffubertip] => This unit is affected by the Strong Wind.
                            [TargetArt] => Array
                                (
                                )

                            [Bufftip] => Strong Wind
                            [EditorSuffix] => ZV
                            [Buffart] => ReplaceableTextures\CommandButtons\BTNCyclone.blp
                        )

                )

        )

    [units] => Array
        (
        )

    [references] => Array
        (
        )

)