Small Bug Nest v1
600
ID:
24
Family ID:
Author:
Majildian
Rarity:
uncommon
Element:
darkness
Attack Type:
Physical
Attack Range:
725
Attack CD:
1.5
Damage:
724-823
Abil. Factor:
0.7
Status:
Approved

Description:

A small colony of bugs.

Latest Upload Comment:

Restored from 1.10
Swarm of Bugs
On kill, produces bugs that increase the base damage of this tower by 6. The damage gain decreases by 1 for every 12 productions, down to a minimum of 1.

Number of produced bugs is retained through upgrade and applied with the upgrade's values. Replacing a tower from a different family will produce bugs from 60% of its total kills.
Download

Toggle Triggers

On Kill

function onKill takes Tower tower returns nothing
    call tower.modifyProperty(MOD_DAMAGE_BASE,IMaxBJ(6 - tower.userInt/12,1))
    set tower.userInt = tower.userInt+1
endfunction

On Tower Creation

function onCreate takes Tower tower returns nothing
    local Tower prev = Event.getPrecedingTower()
    local integer N
    local integer mults
    if prev != 0 then
        if prev.getFamily() == tower.getFamily() then
            set tower.userInt  = prev.userInt
        else
            set tower.userInt  = R2I(prev.getKills()*0.6)
        endif
    
        //sadly, using inlined constants gives us things like 6-1 and 6+0.5 instead of 5 and 6.5
        set mults = tower.userInt /12 //full growth multiples in all kills
        if mults >= 6 then //mults until minimum of 1
            set mults = 6-1
        endif
        
        //Since the equation is linear:
        //[Average growth over N] * N + remaining growth * (total kills - N)
        set N = mults*12
        set N = R2I((6 + 0.5-mults/2.0)*N) + (tower.userInt-N)*(6-mults)
        call tower.modifyProperty(MOD_DAMAGE_BASE,N)
    else
        //if no predecessor, initialize with zeros
        set tower.userInt = 0 //counted kills
    endif
endfunction