Arcane Storm v1
3400
ID:
436
Family ID:
Author:
Ashbringer
Rarity:
unique
Element:
storm
Attack Type:
Energy
Attack Range:
1200
Attack CD:
1.5
Damage:
998-998
Abil. Factor:
0.2
Status:
Approved

Description:

Chaotic magical energy that primes enemies for disintegration.

Latest Upload Comment:

Restored from 1.10
Surge
The tower's main attacks have a 1% chance per Attraction stack on the target to send a surge of energy that deals 200% of attack damage to the target and then attempts to jump from enemy to enemy within 750 range of the original target. At each enemy, the chance to jump is calculated based on the next target's Attraction stacks. Can only hit each target once and benefits from Mana Storm's damage bonus.

Level Bonus:
+0.02% chance per stack
+4% attack damage
Arcane Attraction
Attacks apply a stack of Attraction on hit and generate 1 mana per stack on each target. Can only gain mana once per target hit on each attack. When an enemy dies, all stacks of Attraction on it will distribute evenly to nearby targets within 500 range and deal 20% attack damage per stack transferred. Attraction lasts indefinitely.

Level Bonus:
+10 range
+0.4% attack damage per stack
Mana Storm
Attacks hit up to 2 additional enemies within attack range and consume all mana to deal [mana consumed]% increased damage. Mana Storm gains an additional attack for every 75 mana consumed. If at least 100 mana is consumed, the tower's multicrit is increased by 3 for 2 seconds. If there are less creeps than attacks, the remaining attacks will hit the main target.

Level Bonus:
-1 mana per extra attack
Download

Toggle Triggers

Header

    globals
        BuffType ashbringer_attraction_buff
        BuffType ashbringer_manastorm_buff
        Cast ashbringer_surge_cast
        Cast ashbringer_manastorm_cast
    endglobals
    
    function ashbringer_attraction_apply takes Tower tower, Creep target, integer stacks returns integer
        local Buff b
        local integer i
        
        if stacks<1 then
            set stacks = 1
        endif
        set b = target.getBuffOfType(ashbringer_attraction_buff)
        if ( b != 0 ) then
            set i = b.getPower() + stacks
            call ashbringer_attraction_buff.applyCustomPower(tower, target, 1, i)
        else
            set i = 1
            call ashbringer_attraction_buff.applyCustomPower(tower, target, 1, i)
        endif
        
        return i
    endfunction
    
    function ashbringer_attraction_ondeath takes Buff b returns nothing
        local Tower tower = b.getCaster()
        local Creep target = b.getBuffedUnit()
        local Iterate i = Iterate.overUnitsInRangeOfUnit(tower, TARGET_TYPE_CREEPS, target, 500 + (tower.getLevel() * 10))
        local integer count = i.count()
        local Creep next
        local integer stacks = b.getPower()
        local integer stacks_spare = 0
        local integer stacks_each = 0
        local integer applied = 0
        local real damage_per_stack = tower.getCurrentAttackDamageWithBonus() * (0.2 + (tower.getLevel() * 0.004))
        
        if stacks < count then
            set stacks_spare = stacks
        else
            set stacks_spare = ModuloInteger(stacks, count)
            set stacks_each = (stacks - stacks_spare) / count
        endif
        
        set next = i.next()
        loop
            exitwhen next==0
            if stacks_spare>0 then
                set applied = stacks_each + 1
                set stacks_spare = stacks_spare - 1
            else
                set applied = stacks_each
            endif
            call ashbringer_attraction_apply(tower, next, applied)
            call tower.doAttackDamage(next, applied * damage_per_stack, tower.calcAttackMulticrit(0,0,0))
            call Effect.createSimpleOnUnit("Abilities\\Spells\\Human\\Feedback\\ArcaneTowerAttack.mdl", next, "origin").destroy()
            set next = i.next()
        endloop
    endfunction
    
    function ashbringer_surge_start takes Tower tower, Creep target, real mana returns nothing
        local Buff b
        local Iterate i = Iterate.overUnitsInRangeOfUnit(tower, TARGET_TYPE_CREEPS, target, 750)
        local Unit next = i.next()
        local real damage = tower.getCurrentAttackDamageWithBonus() * (2.0 + (tower.getLevel() * 0.04)) * (1 + (mana/100))
        local real chance_per_stack = 0.01 + (tower.getLevel() * S2R("disintegrate_chance_pl"))
        local Unit prev = target
        local boolean jump = true
        
        call ashbringer_surge_cast.targetCastFromCaster(tower, target, 0.0, 0.0)
        call tower.doAttackDamage(target, damage, tower.calcAttackMulticrit(0,0,0))
        
        loop
            exitwhen next==0
            if next == target then
            else
                set b = next.getBuffOfType(ashbringer_attraction_buff)
                
                if b!=0 then
                    if tower.calcChance(I2R(b.getPower())*chance_per_stack) then
                        call ashbringer_surge_cast.targetCastFromCaster(prev, next, 0.0, 0.0)
                        call tower.doAttackDamage(next, damage, tower.calcAttackMulticrit(0,0,0))
                        set prev = next
                    endif
                endif
            endif
            
            set next = i.next()
        endloop
    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 ashbringer_manastorm_modifier = Modifier.create()
    
        set  ashbringer_attraction_buff = BuffType.create(-1, 0, false)
        call ashbringer_attraction_buff.setBuffIcon('@@3@@')
        call ashbringer_attraction_buff.addEventOnDeath(ashbringer_attraction_ondeath)
        
        set ashbringer_manastorm_buff=BuffType.create(2.0, 0.0, true)
        call ashbringer_manastorm_modifier.addModification(MOD_MULTICRIT_COUNT, 3, 0)
        call ashbringer_manastorm_buff.setBuffIcon('@@2@@')
        call ashbringer_manastorm_buff.setBuffModifier(ashbringer_manastorm_modifier)
        
        set ashbringer_surge_cast = Cast.create('@@0@@',"chainlightning",1.0)
        call ashbringer_surge_cast.setSourceHeight(90.0)
        
        set ashbringer_manastorm_cast = Cast.create('@@1@@',"chainlightning",1.0)
        call ashbringer_manastorm_cast.setSourceHeight(90.0)
    endfunction

On Damage

ONDAMAGE_chance: 1.0 ONDAMAGE_chanceLevelAdd: 0.0
function onDamage takes Tower tower returns nothing
    local Buff b
    local Unit main_target = Event.getTarget()
    local real chance_per_stack = 0.01 + (tower.getLevel() * S2R("disintegrate_chance_pl"))
    local Unit target
    local real mana = GetUnitState(tower.getUnit(), UNIT_STATE_MANA)
    local real extra_per = 75 - (tower.getLevel() * 1)
    local integer extra_attacks = 2 + R2I((mana - ModuloReal(mana, extra_per)) / extra_per)
    local real original_damage = Event.damage
    local real damage = original_damage * (1 + (mana/100))
    local Iterate i = Iterate.overUnitsInRangeOfCaster(tower, TARGET_TYPE_CREEPS, tower.getRange())
    local boolean iterate_destroyed = false
    local Effect e
    local integer stacks = 0
    local integer total_stacks = 0
    
    set Event.damage = damage
    call tower.subtractMana(mana, true)
    
    if mana>=100 then
        call ashbringer_manastorm_buff.apply(tower, tower, 1)
        call Effect.createColored("Doodads\\Cinematic\\Lightningbolt\\Lightningbolt.mdl", tower.getX(), tower.getY(), 0.0, 270.0, 1.3, 255, 90, 255, 255).setLifetime(0.3)
    endif
    
    loop
        exitwhen extra_attacks == 0
        
        if not iterate_destroyed then
            set target = i.nextRandom()

            if target == 0 then
                set iterate_destroyed = true
                set target = main_target
            endif
        endif
  
        if iterate_destroyed or target != main_target then
            
            set stacks = ashbringer_attraction_apply(tower, target, 1)
            
            if target != main_target then
                call ashbringer_manastorm_cast.targetCastFromCaster(tower, target, 0.0, 0.0)
                set total_stacks = total_stacks + stacks
            endif
            
            call tower.doAttackDamage(target, damage, tower.calcAttackMulticrit(0,0,0))
            
            set extra_attacks = extra_attacks - 1
        endif
    endloop
 
    if not iterate_destroyed then
        call i.destroy()
    endif
    
    call ashbringer_manastorm_cast.targetCastFromCaster(tower, main_target, 0.0, 0.0)
    set stacks = ashbringer_attraction_apply(tower, main_target, 1)
    set total_stacks = total_stacks + stacks
    
    if tower.calcChance(I2R(stacks)*chance_per_stack) then
        call ashbringer_surge_start(tower, main_target, mana)
    endif
    
    call tower.addMana(total_stacks)
endfunction

On Tower Creation

function onCreate takes Tower tower returns nothing

endfunction