The Omnislasher v3
3400
ID:
159
Family ID:
Author:
KublaiKhan1
Rarity:
unique
Element:
fire
Attack Type:
Physical
Attack Range:
1200
Attack CD:
5
Damage:
7109-7109
Status:
Approved

Description:

Faster than the wind, faster than Sonic, even faster than light!
Specials:
+8% damage/lvl
Omnislash
On each attack the Omnislasher moves with insane speed towards the battlefield. There, he deals damage up to 10 times before returning to his triumphant pedestal. Each such damage instance deals 10% of this tower's normal attack damage and permanently increases the damage its target takes from Physical type attacks by 4%.

Level Bonus:
+2 slashes every 5 levels
Download

Toggle Triggers

Header

            globals
        BuffType DamageIncreaseBT
    endglobals
    
    function onDamaged takes Buff b returns nothing
        local Tower tower = Event.getTarget()
        if tower.getAttackType() == AttackType.PHYSICAL then
            if Event.isSpellDamage() == false then
                set Event.damage = Event.damage * b.userReal
            endif
        endif
    endfunction
    
    function damage takes Tower tower, Unit target returns nothing
        
        local real range = 80.00
        local real angle = GetRandomReal(0.00, 360.00)
        local real x = target.getX() + Cos(angle) * range
        local real y = target.getY() + Sin(angle) * range
        local real z = target.getZ()
        
        local Effect blademaster = Effect.createAnimated("units\\demon\\HeroChaosBladeMaster\\HeroChaosBladeMaster.mdl", x, y, z, angle + 180 * bj_DEGTORAD)
        local Effect mirrorimage = Effect.create("Abilities\\Spells\\Orc\\MirrorImage\\MirrorImageCaster.mdl", x, y, z, angle + 180 * bj_DEGTORAD)
        local Buff b = target.getBuffOfType(DamageIncreaseBT)
        
        call blademaster.setLifetime(.4)
        call blademaster.setAnimation("attack")
        call blademaster.setScale(0.4)
        call blademaster.noDeathAnimation()
        call mirrorimage.setLifetime(.4)
        call mirrorimage.setScale(0.4)
        
        call tower.doAttackDamage(target, tower.getCurrentAttackDamageWithBonus()/10, tower.calcAttackMulticrit(0.0, 0.0, 0) )
        if b == 0 then
            set b = DamageIncreaseBT.apply(tower, target, tower.getLevel())
            set b.userReal = 1.0
        else
            set b.userReal = b.userReal + 0.04
        endif
    endfunction
    
    function onHit takes nothing returns nothing
        local timer t = GetExpiredTimer()
        local Tower tower = GetTimerData(t)
        local unit u = tower.getUnit()
        local Unit target = tower.userInt
        local integer uid = R2I(tower.userReal)
        local integer towerUID = R2I(tower.userReal2)
        local Iterate iterate = tower.userInt3
        local integer numAttacks = tower.userInt2

        // The tower has changed (sold or replaced)
        if (tower.getUID() != towerUID) then
            call ReleaseTimer(t)
            set t = null
            set u = null
            call iterate.destroy()
            return
        endif
        
        // The target died
        if (target.getUID() != uid) then
            set target = iterate.next()
            set tower.userInt = target
            set tower.userReal = target.getUID()
        endif
        
        if (target != 0 and numAttacks > 0) then
            call damage(tower, target)
            set tower.userInt2 = numAttacks - 1
        else
            if (target != 0) then
                call iterate.destroy()
            endif 
            call ReleaseTimer(t)
            call SetUnitVertexColor(u, 255, 255, 255, 255)
            call PauseUnit(u, false)
            call SFXOnUnit("Abilities\\Spells\\Orc\\MirrorImage\\MirrorImageCaster.mdl", u, "origin")
            set tower.userInt3 = -1
        endif
        set t = null
        set u = null
    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 DamageIncreaseBT = BuffType.create(-1, 0.0, false)
        call DamageIncreaseBT.setBuffIcon('@@0@@')
        call DamageIncreaseBT.addEventOnDamaged(onDamaged, 1.0, 0.0)
    endfunction
        

On Attack

ONATTACK_chance: 1.0 ONATTACK_chanceLevelAdd: 0.0
function onAttack takes Tower tower returns nothing
            
local unit u 
    local Iterate iterate = tower.userInt3
    local timer t 
    local Unit target = Event.getTarget()
    local integer numAttacks = 10 + tower.getLevel() * 2/5
    local real fun
    if iterate == -1 then
        set u = tower.getUnit()
        set iterate = Iterate.overUnitsInRangeOfUnit(tower, TARGET_CREEPS, Event.getTarget(), 1200.00)
        set t = NewTimer()
        call TimerStart(t, tower.getCurrentAttackspeed() / numAttacks, true, function onHit)
        call SetTimerData(t,tower)
        
        call SFXOnUnit("Abilities\\Spells\\Orc\\MirrorImage\\MirrorImageCaster.mdl", u, "origin")
        call SetUnitVertexColor(u, 255, 255, 255, 0)
        call PauseUnit(u, true)
        
        set tower.userInt = target // Save current target
        set tower.userInt2 = numAttacks
        set tower.userInt3 = iterate
        set tower.userReal = target.getUID()
        call damage(tower, target)
        
        set fun= GetRandomReal(0,1)
        if fun< 0.03 then
            call tower.getOwner().displayFloatingTextX("I'm faster than LIGHT!", tower, 50, 150, 255, 255, 0.05, 2, 3)
        elseif fun< 0.02 then
            call tower.getOwner().displayFloatingTextX("Don't listen to Einstein's lies!", tower, 50, 150, 255, 255, 0.05, 2, 3)
        elseif fun< 0.01 then
            call tower.getOwner().displayFloatingTextX("I'm debunking relativity. Just watch me!", tower, 50, 150, 255, 255, 0.05, 2, 3)
        endif
        set u = null
        set t = null
    endif
        
endfunction

On Tower Creation

function onCreate takes Tower tower returns nothing
            
set tower.userReal2 = tower.getUID()
    set tower.userInt3 = -1
        
endfunction