Valor v1
3000
ID:
262
Family ID:
Author:
cedi
Rarity:
unique
Element:
iron
Status:
Approved

Description:

A truly inspiring sight.
Valor's Light
Whenever a creep comes within 800 range of this tower it takes an initial 2000 spell damage per second and its movement speed is decreased by 30%. The damage and slow of this ability decay by 50% every second. Lasts 5 seconds.

Level Bonus:
+80 spell damage
+1.2% slow
Last Line of Defense
Any creep passing this tower twice will take 1% more spell and attack damage for each tower within 400 range of this tower. This effect is goldcost adjusted, towers with a goldcost of 2500 provide the full bonus.

Level Bonus:
+0.08% spell and attack damage taken per tower
We Will Not Fall! - Aura
Increases the attack and spell damage of all towers in 400 range by 0.5% for each percent of lost lives. If the team has more than 100% lives, towers will deal less damage!

Level Bonus:
+0.02% more spell and attack damage
Download

Toggle Triggers

Header

    globals
        //Dummy buff to count times the creep walked past.
        BuffType Last_Line_Prob
        //Real effect of the last line ability
        BuffType Last_Line_Buff
        
        //Buff Type for we will not fall
        BuffType We_Will
        
        //Valor's Light damage and slow
        BuffType Valor
    endglobals
    
    //Periodic adjustment for the effect granted through we will not fall
    //If this is buggy, it's glow's fault. :P
    function We_WillAdjust takes Buff B returns nothing
        local Unit U = B.getBuffedUnit()
        local real newBonus = (100 - U.getOwner().getTeam().getLivesPercent()) / 100.0 * (0.5 + 0.02 * B.getCaster().getLevel())
        local real delta = newBonus - B.userReal
        if delta != 0 then
            call U.modifyProperty(MOD_SPELL_DAMAGE_DEALT, delta)
            call U.modifyProperty(MOD_DAMAGE_ADD_PERC, delta)
            set B.userReal = newBonus
        endif
    endfunction
    
    //Init for we will not fall 
    function We_WillInit takes Buff B returns nothing
        set B.userReal = 0.00
        call We_WillAdjust( B )
    endfunction
    
    //Cleanup for the we will not fall effect
    function We_WillEnd takes Buff B returns nothing
        local Unit U = B.getBuffedUnit()
        call U.modifyProperty( MOD_SPELL_DAMAGE_DEALT, -B.userReal )
        call U.modifyProperty( MOD_DAMAGE_ADD_PERC, -B.userReal )
    endfunction
    
    //Valor Buff damage and slow. First time should work now.
    function ValorEffect takes Buff B returns nothing
        local Unit U = B.getBuffedUnit()
        if B.userInt == 0 then
            //First time, only slow, flag being first
            set B.userInt = 1
        else
            //additional times, decrease slow effect!
            call B.setPower(B.getPower()/2)
        endif
        
        //Deal the right amount of damage
        call B.getCaster().doSpellDamage( U, B.userReal, B.getCaster().calcSpellCritNoBonus() )
        //Adjust the amount of damage dealt.
        set B.userReal = B.userReal * 0.5
        
        //Some sfx to pretty it up
        call DestroyEffect( AddSpecialEffectTarget( "Abilities\\Spells\\Human\\Heal\\HealTarget.mdl", U.getUnit(), "origin" ) )
    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 m = Modifier.create()
        //Set up dummy. No icon, no effect
        set Last_Line_Prob = BuffType.create( -1.0, 0.00, false ) //Dummy Buff, to count the times a unit entered
        //Set up the buff and icon.
        set Last_Line_Buff = BuffType.create( -1.0, 0.00, false ) //Real buff, adding the damage bonus.
        call Last_Line_Buff.setBuffIcon( '@@0@@' )
        
        //Set up for we will not fall
        //Init and adjust are noew two parts to allow for initiation
        set We_Will = BuffType.createAuraEffectType( true )
        call We_Will.setBuffIcon( '@@1@@' )
        call We_Will.addPeriodicEvent( We_WillAdjust, 15.0 )
        call We_Will.addEventOnCreate( We_WillInit )
        call We_Will.addEventOnCleanup( We_WillEnd )
        
        //Valor's light, damage and slow
        set Valor = BuffType.create( 5.0, 0.0, false )
        call Valor.setBuffIcon( '@@2@@' )
        //call Valor.addEventOnCreate( ValorEffect )
        call Valor.addPeriodicEvent( ValorEffect, 1.0 )
        call m.addModification(MOD_MOVESPEED,0,-0.001)
        call Valor.setBuffModifier(m)    
    endfunction

On Tower Creation

function onCreate takes Tower tower returns nothing
    call SetUnitFacing( tower.getUnit(), 270.00 - 45.00 )
    call SetUnitAnimationByIndex( tower.getUnit(), 5 )
    call TriggerSleepAction( 0.3 )
    call SetUnitTimeScale( tower.getUnit(), 0.0 )
endfunction

On Unit Comes In Range

UNITINRANGE_targetType: TARGET_TYPE_CREEPS UNITINRANGE_range: 800
function onUnitInRange takes Tower tower returns nothing
    local Unit U = Event.getTarget()
    local Tower T
    local Buff B 
    local Buff V
    local real amount = 0
    local Iterate I
    
    //setup
    set V = Valor.apply( tower, U, 300+12*tower.getLevel() )
    set V.userReal = 2000.0 + 80.0 * tower.getLevel()
    set V.userInt = 0
    
    //call it myself to ensure that the setup has already run.
    call ValorEffect( V )
    
    set B = U.getBuffOfType( Last_Line_Prob )
    
    //Second time walking past?
    if B != 0 then
        //Yes!
        call B.removeBuff()
        //Apply the last line buff. (Only visuals, effect is permanent, no cleanup required)
        set B = Last_Line_Buff.apply( tower, U, tower.getLevel() )
        
        set I = Iterate.overUnitsInRangeOfCaster( tower, TARGET_TOWERS, 400.0 )
        
        //Calculate the amount of additional damage they should take.
        loop
            set T = I.next()
            exitwhen T == 0
            if T != tower then
                set amount = amount + RMinBJ(I2R(T.getGoldcost())  / 2500.,1) * ( 0.01 + 0.0008 * tower.getLevel() )
            endif
        endloop
        
        //Modify the damage they take.
        call U.modifyProperty( MOD_SPELL_DAMAGE_RECEIVED, amount )
        call U.modifyProperty( MOD_ATK_DAMAGE_RECEIVED, amount )
    else
        //No, check if it already has the last line buff
        set B = U.getBuffOfType( Last_Line_Buff )
        if B == 0 then
            //No? Okay, let's add the dummy.
            call Last_Line_Prob.apply( tower, U, 0 )
        endif
    endif
endfunction

Tower Aura

AURA_powerAdd: 1 AURA_auraEffect: We_Will AURA_levelAdd: 1 AURA_power: 0 AURA_targetType: TARGET_TYPE_TOWERS AURA_targetSelf: false AURA_level: 0 AURA_auraRange: 400