Chaining Storm v1
4000
ID:
303
Family ID:
Author:
SternBogen
Rarity:
unique
Element:
storm
Attack Type:
Energy
Attack Range:
1100
Attack CD:
1.5
Damage:
946-952
Abil. Factor:
0.15
Status:
Approved

Description:

A mighty storm surrounds this tower to crush enemies in range!

Latest Upload Comment:

Restored from 1.10
Specials:
+50% dmg to air (+2%/lvl)
+15 mana/lvl
+0.1 mana regen/lvl
Strong Wind
All creeps in 900 range are affected by Strong Winds. Every second a creep is under this effect, it loses 3% of its movespeed and it is dealt 10% of towers attack damage for every 1% of movespeed it is missing. Slow effect stacks up to 15 times. Slow effect and damage is doubled for air units.

Level Bonus:
+0.08% slow
+5 damage per 1% slow
Chaining Storm
Whenever this tower attacks, it has a 25% chance to cast a Chaining Storm at the position of the attacked creep for the cost of 100 mana. All creeps in 350 range of the Chaining Storm suffer 200 spelldamage multiplied by the number of creeps hit. They are also weakened to receive 2% more damage from Storm, Ice and Astral Towers for each hitted creep. All effects of this ability are doubled and a 25% higher spell critical chance is applied whenever the main target hit is an air unit.

Level Bonus:
+1.25% trigger chance
+65 damage
+0.12% received damage
Storm Power
If a creep dies while under the effect of Strong Wind its living energy is converted in +35 mana and boost this tower's abilities. Each death increases the triggerchance for Chaining Storm by +0.02% (maximum total triggerchance for Chaining Storm is 75%) and also increase the damage dealt with Strong Winds by 0.05 damage per 1% slow.
Download

Toggle Triggers

Header

    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

On Attack

ONATTACK_chance: 1.0 ONATTACK_chanceLevelAdd: 0.0
function onAttack takes Tower tower returns nothing
    
    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
endfunction

On Tower Creation

function onCreate takes Tower tower returns nothing
    set tower.userInt = 0 //Storm Power
endfunction

On Tower Details

goldcost: 0
function onTowerDetails takes Tower tower returns MultiboardValues
    call stern_stormPowerMB.setValue(0, I2S(tower.userInt))
    return stern_stormPowerMB
endfunction

Tower Aura

AURA_powerAdd: 1 AURA_auraEffect: stern_slowBuffCS AURA_levelAdd: 1 AURA_power: 0 AURA_targetType: TARGET_TYPE_CREEPS AURA_targetSelf: false AURA_level: 0 AURA_auraRange: 900.0