Shard of Souls v1
750
ID:
220
Family ID:
Author:
Der_kleine_Tomy
Rarity:
rare
Element:
darkness
Mana:
75
Mana regen:
4
Status:
Approved

Description:

This mystical crystal shard can link souls together.
Specials:
+2% buff duration/lvl
Soul Link
Links 3 enemies' souls together for 2.5 seconds. If a linked unit takes damage all other linked units will take 12.5% of this damage. This tower does not benefit from damage increasing items or oils.

Level Bonus:
+0.3% damage
+1 target at level 15 and 25

AC_TYPE_ALWAYS_BUFF
 50, 1000.0 range, 5.0s cooldown
Soul Consumption
Whenever a unit under the effect of Soul Link dies, the Shard of Souls consumes its soul granting 1 experience to the tower.
Download

Toggle Triggers

Autocast

caster_art: AUTOCAST_cooldown: 5.0 AUTOCAST_numBuffsBeforeIdle: 1 AUTOCAST_isExtended: false AUTOCAST_autocastType: AC_TYPE_ALWAYS_BUFF AUTOCAST_manacost: 50 AUTOCAST_range: 1000.0 AUTOCAST_buffType: tomy_SoulLink AUTOCAST_targetSelf: false AUTOCAST_targetType: TARGET_TYPE_CREEPS target_art: AUTOCAST_autoRange: 1000.0
private function onAutocast takes Tower tower returns nothing
    local Unit target = Event.getTarget()
    local integer level = tower.getLevel()
    local integer counter = 1
    local integer maxTargets = 3
    local Iterate iterator
    local Unit next
    local lightning array effects
    
    if level == 25 then
        set maxTargets = maxTargets + 2
    elseif level >= 15 then
        set maxTargets = maxTargets + 1
    endif
    
    set effects[0] = AddLightningEx("DRAL", false, tower.getX(), tower.getY(), tower.getZ(), target.getX(), target.getY(), target.getZ())
    if target.getBuffOfType(tomy_SoulLink) == 0 then
        call tomy_SoulLink.apply(tower, target, level)
    endif
    
    loop
        exitwhen counter == maxTargets
        set iterator = Iterate.overUnitsInRangeOfUnit(tower, TARGET_CREEPS, target, 600.0 )
        loop
            set next = iterator.next()
            exitwhen next == 0 or next.getBuffOfType(tomy_SoulLink) == 0
        endloop
        
        exitwhen next == 0
        
        if next != 0 then
            call iterator.destroy()
        endif
        
        call tomy_SoulLink.apply(tower, next, level)
        set effects[counter] = AddLightningEx("DRAL", false, GetUnitX(next.getUnit()), GetUnitY(next.getUnit()), GetUnitFlyHeight(next.getUnit()), GetUnitX(target.getUnit()), GetUnitY(target.getUnit()), GetUnitFlyHeight(target.getUnit()))
        set target = next
        set counter = counter + 1
    endloop
    
    call TriggerSleepAction(0.20)
    loop
        set counter = counter - 1
        exitwhen counter == -1
        call DestroyLightning(effects[counter])
        set effects[counter] = null // Not sure if this is needed
    endloop
    
endfunction

Header

    globals
        //@export
        BuffType tomy_SoulLink
        boolean tomy_isSoulLinkDamage
    endglobals
    
    function tomy_SoulLink_OnCreate takes Buff b returns nothing
        local Unit caster = b.getCaster()
        local Buff firstBuff = caster.userInt
        
        set caster.userInt = b // Points to first buff
        set b.userInt = 0
        
        // Link buffs (Double linked list)
        // b.userInt  = previousBuff
        // b.userInt2 = nextBuff
        if firstBuff == 0 then
            set b.userInt2 = 0
        else 
            set firstBuff.userInt = b
            set b.userInt2 = firstBuff
        endif
        
    endfunction
    
    function tomy_SoulLink_OnCleanup takes Buff b returns nothing
        local Buff nextBuff = b.userInt2
        local Buff prevBuff = b.userInt
        local Unit caster = b.getCaster()
        
        // Link the buffs in the linked list correctly (prev <-> next)
        if prevBuff == 0 then
            set caster.userInt = nextBuff
        else
            set prevBuff.userInt2 = nextBuff
        endif
        
        if nextBuff != 0 then
            set nextBuff.userInt = prevBuff
        endif
        
    endfunction
    
    function tomy_SoulLink_OnDamaged takes Buff b returns nothing
        local Tower damageSource = Event.getTarget()
        local Unit caster = b.getCaster()
        local real damage = Event.damage * (caster.userReal + caster.userReal2 * caster.getLevel())
        local Buff currentBuff
        
        // If the damage comes from Soul Link nothing will happen
        if tomy_isSoulLinkDamage then
            return
        endif
        
        set tomy_isSoulLinkDamage = true
        set currentBuff = caster.userInt
        loop
            exitwhen currentBuff == 0
            if currentBuff != b then // Don't deal extra damage to the damaged creep
                if Event.isSpellDamage() then
                    set damage = damage / damageSource.getProp_SpellDmgDealt() // prevent the damage from being increased twice by spell damage
                    call damageSource.doSpellDamage(currentBuff.getBuffedUnit(), damage, 1) 
                else
                    call damageSource.doAttackDamage(currentBuff.getBuffedUnit(), damage, 1) 
                endif
            endif
            set currentBuff = currentBuff.userInt2 // next buff
        endloop
        set tomy_isSoulLinkDamage = false
        
    endfunction
    
    function tomy_SoulLink_OnDeath takes Buff b returns nothing
        call b.getCaster().addExp(1.0)
    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 tomy_SoulLink = BuffType.create(2.5, 0, false)
        call tomy_SoulLink.addEventOnCreate(EventHandler.tomy_SoulLink_OnCreate)
        call tomy_SoulLink.addEventOnCleanup(EventHandler.tomy_SoulLink_OnCleanup)
        call tomy_SoulLink.addEventOnDeath(EventHandler.tomy_SoulLink_OnDeath)
        call tomy_SoulLink.addEventOnDamaged(EventHandler.tomy_SoulLink_OnDamaged, 100.0, 0.00)
        call tomy_SoulLink.setBuffIcon('@@0@@')
        
        set tomy_isSoulLinkDamage = false
    endfunction

On Tower Creation

function onCreate takes Tower tower returns nothing
    set tower.userInt = 0 // Linked List (points to the first buff)
    set tower.userReal = 0.125
    set tower.userReal2 = 0.003
endfunction
Crystal of Souls v1
2250
ID:
222
Family ID:
Author:
Der_kleine_Tomy
Rarity:
rare
Element:
darkness
Mana:
75
Mana regen:
4
Status:
Approved

Description:

This mystical crystal can link souls together.
Specials:
+2% buff duration/lvl
Soul Link
Links 3 enemies' souls together for 2.5 seconds. If a linked unit takes damage all other linked units will take 15% of this damage. This tower does not benefit from damage increasing items or oils.

Level Bonus:
+0.4% damage
+1 target at level 15 and 25

AC_TYPE_ALWAYS_BUFF
 50, 1000.0 range, 4.0s cooldown
Soul Consumption
Whenever a unit under the effect of Soul Link dies, the Crystal of Souls consumes its soul granting 1 experience to the tower.
Download

Toggle Triggers

Autocast

caster_art: AUTOCAST_cooldown: 4.0 AUTOCAST_numBuffsBeforeIdle: 1 AUTOCAST_isExtended: false AUTOCAST_autocastType: AC_TYPE_ALWAYS_BUFF AUTOCAST_manacost: 50 AUTOCAST_range: 1000.0 AUTOCAST_buffType: tomy_SoulLink AUTOCAST_targetSelf: false AUTOCAST_targetType: TARGET_TYPE_CREEPS target_art: AUTOCAST_autoRange: 1000.0
private function onAutocast takes Tower tower returns nothing
    local Unit target = Event.getTarget()
    local integer level = tower.getLevel()
    local integer counter = 1
    local integer maxTargets = 3
    local Iterate iterator
    local Unit next
    local lightning array effects
    
    if level == 25 then
        set maxTargets = maxTargets + 2
    elseif level >= 15 then
        set maxTargets = maxTargets + 1
    endif
    
    set effects[0] = AddLightningEx("DRAL", false, tower.getX(), tower.getY(), tower.getZ(), target.getX(), target.getY(), target.getZ())
    if target.getBuffOfType(tomy_SoulLink) == 0 then
        call tomy_SoulLink.apply(tower, target, level)
    endif
    
    loop
        exitwhen counter == maxTargets
        set iterator = Iterate.overUnitsInRangeOfUnit(tower, TARGET_CREEPS, target, 700.0 )
        loop
            set next = iterator.next()
            exitwhen next == 0 or next.getBuffOfType(tomy_SoulLink) == 0
        endloop
        
        exitwhen next == 0
        
        if next != 0 then
            call iterator.destroy()
        endif
        
        call tomy_SoulLink.apply(tower, next, level)
        set effects[counter] = AddLightningEx("DRAL", false, GetUnitX(next.getUnit()), GetUnitY(next.getUnit()), GetUnitFlyHeight(next.getUnit()), GetUnitX(target.getUnit()), GetUnitY(target.getUnit()), GetUnitFlyHeight(target.getUnit()))
        set target = next
        set counter = counter + 1
    endloop
    
    call TriggerSleepAction(0.20)
    loop
        set counter = counter - 1
        exitwhen counter == -1
        call DestroyLightning(effects[counter])
        set effects[counter] = null // Not sure if this is needed
    endloop
    
endfunction

Header

    globals
        //@import
        BuffType tomy_SoulLink
    endglobals
    
    //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

    endfunction

On Tower Creation

function onCreate takes Tower tower returns nothing
    set tower.userInt = 0 // Linked List (points to the first buff)
    set tower.userReal = 0.15
    set tower.userReal2 = 0.004
endfunction