Energy Junction v1
500
ID:
99
Family ID:
Author:
SirCoqalot.
Rarity:
uncommon
Element:
iron
Attack Type:
Energy
Attack Range:
500
Attack CD:
0.7
Damage:
455-455
Abil. Factor:
0.2
Status:
Approved

Description:

Support tower which only attacks air. Buffs other units attackspeed and adds some spell and normal damage.

Latest Upload Comment:

Restored from 1.10
Specials:
Attacks AIR only
Jolt
Buffs a tower in 500 range for 10 seconds increasing its attackspeed by 20%. The buffed tower deals 150 attack damage and 150 spell damage on attack multiplied with its base attackspeed. 

Level Bonus:
+6 attack and spell damage 
+0.2% attackspeed
Download

Toggle Triggers

Autocast

AUTOCAST_cooldown: 8 AUTOCAST_autoRange: 500 AUTOCAST_manacost: 15 AUTOCAST_range: 500 AUTOCAST_targetType: TARGET_TYPE_TOWERS AUTOCAST_numBuffsBeforeIdle: 0 caster_art: target_art: AUTOCAST_autocastType: AC_TYPE_ALWAYS_BUFF AUTOCAST_buffType: sir_junction_buff AUTOCAST_isExtended: false AUTOCAST_targetSelf: true
private function onAutocast takes Tower tower returns nothing

endfunction

Header

    globals
        //@export
        BuffType sir_junction_buff
    endglobals
    
    function junctionOnCreate takes Buff b returns nothing
        local Tower tower = b.getCaster()
        local Tower buffee = b.getBuffedUnit()
        set b.userInt = 0
        if tower != buffee then
            set b.userInt = Lightning.createFromPointToUnit("CLPB", tower.getX(), tower.getY(), tower.getZ() - 60, buffee)
        endif
        //Add & save attackspeed
        set b.userReal = tower.userReal + tower.userReal2 * tower.getLevel()
        call buffee.modifyProperty(MOD_ATTACKSPEED, b.userReal)
    endfunction
    
    function junctionOnDamage takes Buff b returns nothing
        local Tower caster = b.getCaster()
        local Tower buffee = b.getBuffedUnit()
        local Creep creep  = Event.getTarget()
        local real damage = caster.userReal3 * (1 + caster.getLevel() / 25.0) * buffee.getBaseAttackspeed()
        
        call buffee.doSpellDamage(creep, damage, buffee.calcSpellCritNoBonus())
        call buffee.doAttackDamage(creep, damage, buffee.calcAttackMulticrit(0,0,0))
        call SFXAtUnit("Abilities\\Spells\\Orc\\Purge\\PurgeBuffTarget.mdl", creep.getUnit())
    endfunction
    
    function junctionOnCleanup takes Buff b returns nothing
        if b.userInt != 0 then
            call Lightning(b.userInt).destroy()
        endif
        call b.getBuffedUnit().modifyProperty(MOD_ATTACKSPEED, -b.userReal)
    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
        set sir_junction_buff = BuffType.create(10,0,true)
        call sir_junction_buff.setBuffIcon('@@0@@')
        call sir_junction_buff.addEventOnCreate(EventHandler.junctionOnCreate)
        call sir_junction_buff.addEventOnAttack(EventHandler.junctionOnDamage,1.0,0.0)
        call sir_junction_buff.addEventOnCleanup(EventHandler.junctionOnCleanup)
    endfunction

On Tower Creation

function onCreate takes Tower tower returns nothing
    set tower.userReal = 0.2 //base attackspeed boost
    set tower.userReal2 = 0.002 //attackspeed boost add
    set tower.userReal3 = 150.0 //base dmg & spelldmg per attack (/25 for level bonus)
endfunction

On Tower Destruction

function onDestruct takes Tower tower returns nothing
    //Kill all buffs made by this tower in aoe, so that all lightnings get removed
    local Iterate it = Iterate.overUnitsInRangeOfCaster(tower, TARGET_TOWERS, 500)
    local Tower cur = it.next()
    local Buff b
    
    loop
        exitwhen cur == 0
        set b = cur.getBuffOfType(sir_junction_buff)
        if b != 0 then
            if b.getCaster() == tower then
                call b.removeBuff()
            endif
        endif
        set cur = it.next()
    endloop
endfunction