Miner v1
500
ID:
622
Family ID:
Author:
drol
Rarity:
rare
Element:
iron
Attack Type:
Decay
Attack Range:
1000
Attack CD:
1.8
Damage:
614-633
Abil. Factor:
0.65
Status:
Approved

Description:

This loner has been searching for gold and treasure his entire life.

Latest Upload Comment:

Restored from 1.10
Specials:
+20% bounty collected (+0.8%/lvl)
Goldrush
The miner has a 20% chance on attack to go into a goldrush, increasing attackspeed by more than 20% depending on the player's gold and making each hit gain 1.0 gold. Goldrush lasts 5 seconds. Cannot retrigger while in goldrush!

Hint: Check multiboard to view exact attack speed bonus

Level Bonus:
+0.04 gold gained
+0.1 seconds duration
Excavation
Every 20 seconds the miner has a 25% chance to find 7.5 gold.

Level Bonus:
+0.3 gold
Download

Toggle Triggers

Header

    globals
        //@export
        BuffType drol_goldrush
        //@export
        MultiboardValues drol_excavationMulti
    endglobals

    //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 drol_goldrush = BuffType.create(5,0.1,true)
        
        call m.addModification(MOD_ATTACKSPEED, 0.2, 0.01)
        
        call drol_goldrush.setBuffIcon('@@0@@')
        call drol_goldrush.setBuffModifier(m)
        
        call drol_goldrush.setStackingGroup("drol_goldrush")

        set   drol_excavationMulti = MultiboardValues.create(2)
        call  drol_excavationMulti.setKey(0,"Gold gained") 
        call  drol_excavationMulti.setKey(1,"Goldrush bonus")
    
    endfunction

On Attack

ONATTACK_chance: 0.2 ONATTACK_chanceLevelAdd: 0.0
function onAttack takes Tower tower returns nothing
    if tower.getBuffOfGroup("drol_goldrush") == 0 then
        call drol_goldrush.applyCustomTimed(tower,tower,R2I(Pow(GetPlayerState(tower.getOwner().getThePlayer(), PLAYER_STATE_RESOURCE_GOLD),0.5) / 5.), 5. + tower.getLevel() * 0.1)
    endif
    
endfunction

On Damage

ONDAMAGE_chance: 1.0 ONDAMAGE_chanceLevelAdd: 0.0
function onDamage takes Tower tower returns nothing
    local real goldBonus = 1.0 + tower.getLevel() * 0.04
     
    if Event.isMainTarget() and tower.getBuffOfGroup("drol_goldrush") > 0 then
        set tower.userReal = tower.userReal + goldBonus
        call tower.getOwner().giveGold(goldBonus, tower.getUnit(), false, true)
    endif
endfunction

On Tower Creation

function onCreate takes Tower tower returns nothing
    
    local Tower preceding = Event.getPrecedingTower()  
    
    if(preceding.getFamily() == tower.getFamily()) then  
        set tower.userReal = preceding.userReal
    else  
        set tower.userReal = 0.0
    endif 
    
endfunction

On Tower Details

goldcost: 0
function onTowerDetails takes Tower tower returns MultiboardValues
    call   drol_excavationMulti.setValue(0,I2S(R2I(tower.userReal)))
    call   drol_excavationMulti.setValue(1,I2S(20 + R2I(Pow(GetPlayerState(tower.getOwner().getThePlayer(), PLAYER_STATE_RESOURCE_GOLD),0.5)/5)) + "%")
    return drol_excavationMulti
endfunction

Periodic

PERIODIC_period: 20
function periodic takes Tower tower returns nothing
    local real goldBonus = 7.5 + tower.getLevel() * 0.3
    local Effect targetEffect 

    set targetEffect = Effect.createScaled("Abilities\\Weapons\\AncientProtectorMissile\\AncientProtectorMissile.mdl", GetUnitX(tower.getUnit()), GetUnitY(tower.getUnit()), 0, 0, 0.8)
    call targetEffect.setLifetime(0.1) 
        
    if tower.calcChance(0.25) then
        set tower.userReal = tower.userReal + goldBonus
        call tower.getOwner().giveGold(goldBonus, tower.getUnit(), false, true)
    endif
endfunction