The Steam Engine v1
4000
ID:
391
Family ID:
Author:
Glowackos/cedi
Rarity:
unique
Element:
iron
Attack Type:
Magic
Attack Range:
0
Attack CD:
10
Damage:
1-1
Abil. Factor:
0.00
Status:
Approved

Description:

One of the greatest inventions of the dwarves.

Latest Upload Comment:

Restored from 1.10
Specials:
+10 mana/lvl
+5% mana regen/lvl
Speed Up
Increases the power level of the engine by 1. Maximum power level is 50.
Speed Down
Decreases the power level of the engine by 1.
Power Surge
Towers under the effect of Steam Power have a 1% base attackspeed adjusted chance to cause a surge in the Steam Engine, granting it 1 exp.

Level Bonus:
+0.04 exp
Steam Power
Increases attackdamage of towers in 450 AOE by [6 x power level]% and attackspeed by half this amount. In order to sustain this, the engine consumes a lot of mana. Mana regeneration is reduced by [10 x power level x squareroot(towers powered)]%. If the mana of the engine reaches zero it will deactivate itself for 120 seconds. Does not stack with other Steam Engines!
Download

Toggle Triggers

Autocast

caster_art: AUTOCAST_cooldown: 0.5 AUTOCAST_numBuffsBeforeIdle: 0 AUTOCAST_isExtended: false AUTOCAST_autocastType: AC_TYPE_NOAC_IMMEDIATE AUTOCAST_manacost: 0 AUTOCAST_range: 0 AUTOCAST_buffType: 0 AUTOCAST_targetSelf: true AUTOCAST_targetType: 0 target_art: AUTOCAST_autoRange: 0.00
private function onAutocast takes Tower tower returns nothing
    if tower.userInt < 50 then
        set tower.userInt = tower.userInt + 1
        call engine_UpdateManaUse(tower)
        call engine_UpdateAnims(tower)
    endif
    call tower.getOwner().displayFloatingText("Power Level: " + I2S(tower.userInt), tower, 50+4*tower.userInt, 150-3*tower.userInt, 100-2*tower.userInt)
endfunction

Autocast

caster_art: AUTOCAST_cooldown: 5.00 AUTOCAST_numBuffsBeforeIdle: 0 AUTOCAST_isExtended: false AUTOCAST_autocastType: AC_TYPE_NOAC_IMMEDIATE AUTOCAST_manacost: 0 AUTOCAST_range: 0 AUTOCAST_buffType: 0 AUTOCAST_targetSelf: true AUTOCAST_targetType: 0 target_art: AUTOCAST_autoRange: 0.00
private function onAutocast takes Tower tower returns nothing
    if tower.userInt > 0 then
        set tower.userInt = tower.userInt - 1
        call engine_UpdateManaUse(tower)
        call engine_UpdateAnims(tower)
    endif
    call tower.getOwner().displayFloatingText("Power Level: " + I2S(tower.userInt), tower, 50+4*tower.userInt, 150-3*tower.userInt, 100-2*tower.userInt)
endfunction

Header

    globals
        BuffType cedi_steam_buff
        MultiboardValues cedi_steam_MB
    endglobals
    
    function engine_UpdateAnims takes Tower tower returns nothing
        local Effect e = tower.userInt3
        local unit u = tower.getUnit()
        call SetUnitTimeScale(u, I2R( tower.userInt) / 10.0)
        call e.setAnimationSpeed(0.5 + I2R( tower.userInt) / 20.0)
        call e.setScale(I2R(tower.userInt) / 20.0)
        set u = null
    endfunction
    
    function engine_UpdateManaUse takes Tower tower returns nothing
        local real manaDeg = tower.userInt * SquareRoot(tower.userInt2) * 10 / 100.0
        call tower.modifyProperty(MOD_MANA_REGEN_PERC, tower.userReal - manaDeg)
        set tower.userReal = manaDeg
    endfunction
    
    function steam_buff_onCreate takes Buff B returns nothing
        local Tower tower = B.getCaster()
        set B.userReal = 0.06 * tower.userInt
        set tower.userInt2 = tower.userInt2 + 1
        call engine_UpdateManaUse(tower)
        call B.getBuffedUnit().modifyProperty(MOD_DAMAGE_ADD_PERC, B.userReal)
        call B.getBuffedUnit().modifyProperty(MOD_ATTACKSPEED, B.userReal / 2.0)
    endfunction
    
    function steam_buff_onAttack takes Buff B returns nothing
        local Tower caster = B.getCaster()
        local Tower tower = B.getBuffedUnit()
        local integer lvl = caster.getLevel()
        if caster.calcChance(0.01 * tower.getBaseAttackspeed()) then
            call caster.addExp(1 + 0.04 * lvl)
            call Effect.createScaled("Objects\\Spawnmodels\\Human\\FragmentationShards\\FragBoomSpawn.mdl",tower.getX() + 11, tower.getY() + 56, 40.0, 0.0, 3).destroy()
        endif
    endfunction
    
    function steam_buff_periodic takes Buff B returns nothing
        local real r = 0.06 * Unit(B.getCaster()).userInt - B.userReal
        set B.userReal = B.userReal + r
        call B.getBuffedUnit().modifyProperty( MOD_DAMAGE_ADD_PERC, r)
        call B.getBuffedUnit().modifyProperty( MOD_ATTACKSPEED, r / 2.0)
    endfunction
    
    function steam_buff_onCleanup takes Buff B returns nothing
        local Tower tower = B.getCaster()
        set tower.userInt2 = tower.userInt2 - 1
        call engine_UpdateManaUse(tower)
        call B.getBuffedUnit().modifyProperty(MOD_DAMAGE_ADD_PERC, -B.userReal)
        call B.getBuffedUnit().modifyProperty(MOD_ATTACKSPEED, -B.userReal / 2.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 cedi_steam_buff = BuffType.createAuraEffectType(true)
        call cedi_steam_buff.setBuffIcon('@@0@@')
        call cedi_steam_buff.addEventOnCreate(steam_buff_onCreate)
        call cedi_steam_buff.addEventOnAttack(steam_buff_onAttack, 1.0, 0.0)
        call cedi_steam_buff.addPeriodicEvent(steam_buff_periodic, 1.0)
        call cedi_steam_buff.addEventOnCleanup(steam_buff_onCleanup)
        set cedi_steam_MB = MultiboardValues.create(2)
        call cedi_steam_MB.setKey(0,"Power Level") 
        call cedi_steam_MB.setKey(1,"Towers Powered")
    endfunction

On Tower Creation

function onCreate takes Tower tower returns nothing
    local Effect e = Effect.createAnimatedScaled("Doodads\\Cinematic\\FireTrapUp\\FireTrapUp.mdl",tower.getX() - 4, tower.getY() + 41, 75.0, 0.0 ,0.55)
    //Power level
    set tower.userInt = 0
    //Num towers in AOE
    set tower.userInt2 = 0
    //Store effect
    set tower.userInt3 = e
    //Mana degen
    set tower.userReal = 0.0
    call engine_UpdateAnims(tower)
endfunction

On Tower Destruction

function onDestruct takes Tower tower returns nothing
    local Effect e = tower.userInt3
    call e.destroy()
endfunction

On Tower Details

function onTowerDetails takes Tower tower returns MultiboardValues
    call cedi_steam_MB.setValue(0,I2S(tower.userInt))
    call cedi_steam_MB.setValue(1,I2S(tower.userInt2))
    return cedi_steam_MB    
endfunction

Periodic

PERIODIC_period: 1.0
function periodic takes Tower tower returns nothing
    local unit u = tower.getUnit()
    if tower.userInt != 0 and GetUnitState(u, UNIT_STATE_MANA) <= 1.0 then
        set tower.userInt = 0
        call engine_UpdateManaUse(tower)
        call engine_UpdateAnims(tower)
        call tower.getOwner().displayFloatingText("Power Level: 0", tower, 50, 150, 100)
        call cb_stun.applyOnlyTimed( tower, tower, 120.0 )
    endif
    set u = null
endfunction

Tower Aura

AURA_auraEffect: cedi_steam_buff AURA_power: 1 AURA_level: 1 AURA_auraRange: 450.0 AURA_targetType: TARGET_TYPE_TOWERS AURA_levelAdd: 1 AURA_powerAdd: 1 AURA_targetSelf: false