Lucky Gem v1
550
lvl: 13

ID:

282

Author:

Boekie

Rarity:

unique

Status:

Approved

Description:

This gem gives the tower random effects.

Latest Upload Comment:

Restored from 1.10
Luck!
The carrier of this item has a 20% attackspeed adjusted chance to get a random effect on damage: 
 Gain 1 experience 
 Gain 10 gold 
 Stun for 0.5 seconds 
 Slow by 10% for 3 seconds. 
 Decrease armor by 5 for 3 seconds.
Download

Toggle Triggers

Header

goldcost: 0
    globals
    BuffType boekie_gem_slow 
    BuffType boekie_gem_armor
    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() 
    local Modifier k = Modifier.create()
    call m.addModification(MOD_MOVESPEED,0,-0.001) 
    set boekie_gem_slow = BuffType.create(0,0,false) // apply custom timed  
    call boekie_gem_slow.setBuffIcon('@@0@@')  
    call boekie_gem_slow.setBuffModifier(m) 
    call boekie_gem_slow.setStackingGroup("boekieGemSlow") 
    
    call k.addModification(MOD_ARMOR,0,-1) 
    set boekie_gem_armor = BuffType.create(0,0,false) // apply custom timed  
    call boekie_gem_armor.setBuffIcon('@@1@@')  
    call boekie_gem_armor.setBuffModifier(k) 
    call boekie_gem_armor.setStackingGroup("boekieGemArmor")
    endfunction

On Damage

ONDAMAGE_chance: 1.00 goldcost: 550 ONDAMAGE_chanceLevelAdd: 0.0
function onDamage takes Item itm returns nothing
local Unit target = Event.getTarget() 
local integer a = GetRandomInt(0,4) 
local Tower tower = itm.getCarrier()
local real speed = tower.getBaseAttackspeed()

if tower.calcChance(0.20*speed) and Event.isMainTarget()==true then 

if a < 1 then 
call cb_stun.applyOnlyTimed(tower,target,0.5) 
call tower.getOwner().displaySmallFloatingText("Stun!",tower,255, 165, 0,30) 
elseif a < 2 then 
call boekie_gem_slow.applyCustomTimed(tower,target,100,3) 
call tower.getOwner().displaySmallFloatingText("Slow!",tower,255, 165, 0,30)
elseif a < 3 then 
call tower.getOwner().giveGold( 10,tower.getUnit(), true, true) 
call tower.getOwner().displaySmallFloatingText("Gold!",tower,255, 165, 0,30)
elseif a < 4 then 
call tower.addExp(1.0) 
call tower.getOwner().displaySmallFloatingText("Exp!",tower,255, 165, 0,30)
elseif a < 5 then 
call boekie_gem_armor.applyCustomTimed(tower,target,5,3) 
call tower.getOwner().displaySmallFloatingText("Armor!",tower,255, 165, 0,30)
endif 

endif
endfunction