Crimson Wyrm v2
4800
ID:
139
Family ID:
Author:
SirCoqaLot.
Rarity:
unique
Element:
fire
Attack Type:
Elemental
Attack Range:
950
Attack CD:
2
Damage:
90-10099
Abil. Factor:
0.60795
Status:
Approved

Description:

Ancient and greedy Wyrm which takes away most of your goldgain.

Latest Upload Comment:

Increased abil.factor, doubled hoard scaling, removed level bonus from hoard size: 30k+30k@25 to 90k
Flaming Inferno
Every 7th-11th attack releases 3 fireballs that fly towards random targets in 950 range, dealing 3750 spelldamage in 250 AoE around the target on impact.

Level Bonus:
+150 spelldamage
-1 minimum and maximum attack needed at levels 15 and 25
+1 fireball at level 10
+5% bonus crit chance at levels 5 and 20
Dragon's Hoard
Whenever the Crimson Wyrm kills a creep it hoards 75% of the bounty. The hoard has a maximum capacity of 90000 gold and grants [gold hoarded / 50]% spelldamage and base attackdamage. 

Hint: This ability is modified by both the creep's and this tower's bounty ratios.
Download

Toggle Triggers

Header

                globals
        MultiboardValues sir_wyrm_bonus
        ProjectileType sir_wyrm_projectile
    endglobals
    
    // function being called whenever the hoard is updated
    function sir_update takes Tower tower, real value returns nothing
        call tower.modifyProperty(MOD_DAMAGE_BASE_PERC, -tower.userReal / 5000)
        call tower.modifyProperty(MOD_SPELL_DAMAGE_DEALT, -tower.userReal / 5000)
        set tower.userReal = tower.userReal + value
        call tower.modifyProperty(MOD_DAMAGE_BASE_PERC, tower.userReal / 5000)
        call tower.modifyProperty(MOD_SPELL_DAMAGE_DEALT, tower.userReal / 5000)
    endfunction
    
    private function sir_wyrm_hit takes Projectile p, Unit u returns nothing
        local Tower t = p.getCaster()
        local integer l = t.getLevel()
        local real critmod 
        
        if l >= 20 then 
            set critmod = 0.1
        elseif l >= 5 and l < 20 then
            set critmod = 0.05
        else 
            set critmod = 0
        endif
        
        call t.doSpellDamageAoE(p.x,p.y,250,3750+l*150,t.calcSpellCrit(critmod,0),0)
    endfunction
    
    function releaseFireballs takes Tower tower, integer balls returns nothing
        local integer level = tower.getLevel()
        local Iterate it = Iterate.overUnitsInRangeOfCaster(tower,TARGET_CREEPS,950)
        local Unit target
        local Unit last = 0
        loop
            set target = it.nextRandom()
            exitwhen target == 0
            call Projectile.createBezierInterpolationFromUnitToUnit(sir_wyrm_projectile,tower,1,1,tower,target,0,GetRandomReal(-0.35,0.35),GetRandomReal(0.17,0.4),true).setScale(2.0)// gives the fireballs a slightly random trajectory
            set balls = balls - 1
            set last = target
            exitwhen balls == 0
        endloop
        if target != 0 then
            //Targets remain, so all balls must've been fired.
            call it.destroy()
        elseif balls > 0 then
            if last != 0 then
                //Shoot remaining balls at last target. (This is ALRIGHT, because there is a max of 4 balls all up.
                //So worst case scenario, there are two creeps in range: one of them is hit with one fireball, and the other with three.)
                loop
                    call Projectile.createBezierInterpolationFromUnitToUnit(sir_wyrm_projectile,tower,1,1,tower,last,0,GetRandomReal(-0.35,0.35),GetRandomReal(0.17,0.4),true).setScale(2.0)// gives the fireballs a slightly random trajectory
                    set balls = balls - 1
                    exitwhen balls == 0
                endloop
            else
                set tower.userInt = 0 //(shoot all fireballs on next attack.)
            endif
        endif
    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_wyrm_bonus = MultiboardValues.create(3)
        call sir_wyrm_bonus.setKey(0,"Gold Hoarded")
        call sir_wyrm_bonus.setKey(1,"Bonus Damage")
        call sir_wyrm_bonus.setKey(2,"Atks to Fireballs")
        set sir_wyrm_projectile = ProjectileType.createInterpolate("Abilities\\Weapons\\FireBallMissile\\FireBallMissile.mdl",700)
        call sir_wyrm_projectile.setEventOnInterpolationFinished(sir_wyrm_hit)
    endfunction
        

On Attack

ONATTACK_chance: 1.0 ONATTACK_chanceLevelAdd: 0.0
function onAttack takes Tower tower returns nothing
            
    local integer level = tower.getLevel()
    
    // check if 0 attacks remain till fireballs
    if tower.userInt > 0 then                  
        set tower.userInt = tower.userInt - 1
    else    
        // setting minimum number of attacks before next fireballs
        if level == 25 then
            set tower.userInt = 5
        elseif level >= 15 then
            set tower.userInt = 6
        else
            set tower.userInt = 7
        endif
        // set +0,+1 or +2 attacks and release bolts afterwards
        set tower.userInt = tower.userInt + GetRandomInt(0,4) 
        // setting the number of fireballs
        if level >= 10 then
            call releaseFireballs(tower, 4)
        else
            call releaseFireballs(tower, 3)
        endif
        
    endif
        
endfunction

On Kill

function onKill takes Tower tower returns nothing
            
    local Creep creep() = Event.getTarget()
    local integer level = tower.getLevel()
    local real value = 0.75*creep.getBaseBountyValue()*creep.getProp_BountyGranted()*tower.getProp_BountyReceived()
    local real hoardSize = 90000
    if tower.userReal >= hoardSize then
        set value = 0
    elseif tower.userReal + value > hoardSize then
        set value = hoardSize-tower.userReal
    endif
    if value != 0 then       
        call sir_update(tower,value)
        call tower.getOwner().giveGold(-value,tower.getUnit(), false, false)
        call SFXAtUnit("Abilities\\Spells\\Other\\Transmute\\PileofGold.mdl",tower.getUnit())
    endif
        
endfunction

On Tower Creation

function onCreate takes Tower tower returns nothing
            
    local Tower preceding = Event.getPrecedingTower()
    set tower.userReal = 0
    if preceding.getUnitType() == tower.getUnitType() then //This is kind of obsolete, but whatever; can't use family because no family
        call sir_update(tower,preceding.userReal)   //Somebody might replace this tower with this tower
    endif
    set tower.userInt = 9// mediocre cd for first wave of fireballs
        
endfunction

On Tower Details

goldcost: 0
function onTowerDetails takes Tower tower returns MultiboardValues
            
    call sir_wyrm_bonus.setValue(0,formatFloat(tower.userReal,0))
    call sir_wyrm_bonus.setValue(1,formatFloat(tower.userReal/100,0)+"%")
    call sir_wyrm_bonus.setValue(2,I2S(tower.userInt))
    return sir_wyrm_bonus
        
endfunction