Speed Demon's Reward v1
144
lvl: 4

ID:

191

Author:

Palandu

Rarity:

uncommon

Status:

Approved

Description:

Rewards the player with gold and exp for fighting non-stop

Latest Upload Comment:

Restored from 1.10
Speed Award
Any time the carrier manages to attack the next creep wave within 12 seconds of attacking the current one, it receives bonus exp and gold as a Speed Award. The gold award amount is equal to 12 minus the time interval between attacking the different creep waves. The exp award is half of the gold award.
Download

Toggle Triggers

Header

goldcost: 144
    globals
        MultiboardValues palandu_SpeedBoard
    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
        set palandu_SpeedBoard = MultiboardValues.create(1)
        call palandu_SpeedBoard.setKey(0, "Total Gold Awarded")
    endfunction

On Attack

goldcost: 0 ONATTACK_chance: 1.0 ONATTACK_chanceLevelAdd: 0.0
function onAttack takes Item itm returns nothing
    local Creep c = Event.getTarget()
    local integer creepLevel = c.getSpawnLevel()
    local real rewardValue
    local Unit t
    
    if itm.userInt > 0 and itm.userInt < creepLevel then
        set rewardValue = 12.0 - (Game.getGameTime() - itm.userInt2)/25
        if rewardValue > 0 then
            set t = itm.getCarrier()
            call t.getOwner().giveGold(rewardValue, t.getUnit(), true, true)
            call t.addExp(rewardValue/2)
            set itm.userReal = itm.userReal + rewardValue
        endif
    endif
    
    set itm.userInt = IMaxBJ(itm.userInt, creepLevel) //so that it can only go up
    set itm.userInt2 = Game.getGameTime()
endfunction

On Item Creation

goldcost: 0
function onCreate takes Item itm returns nothing
   set itm.userInt = -101
   set itm.userInt2 = -101
   set itm.userReal = 0
endfunction

On Tower Details

goldcost: 0
function onTowerDetails takes Item itm returns MultiboardValues
    call palandu_SpeedBoard.setValue(0, formatFloat(itm.userReal,1))
    return palandu_SpeedBoard
endfunction