Spellbook of Item Mastery v1
1500
lvl: 44

ID:

200

Author:

Majildian

Rarity:

unique

Status:

Approved

Description:

This spellbook contains a variety of spells for items.

Latest Upload Comment:

Restored from 1.10
Cast a Spell
Casts one of these spells on attack:
 -Target drops a very high quality item
 -Two high quality items
 -Three normal quality items
 -Two low quality items and spellbook gains +10% item chance and item quality
 -Spellbook gains +25% item quality or item chance

Cooldown of 15 waves.
Download

Toggle Triggers

Header

goldcost: 0
    globals
        MultiboardValues Maj_spellbook
    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 Maj_spellbook = MultiboardValues.create(3)
        call Maj_spellbook.setKey(0,"Waves Left")
        call Maj_spellbook.setKey(1,"Item Quality")
        call Maj_spellbook.setKey(2,"Item Chance")
    endfunction

On Attack

goldcost: 1500 ONATTACK_chance: 1.0 ONATTACK_chanceLevelAdd: 0.0
function onAttack takes Item itm returns nothing
local integer choose
local Creep target
local Tower tower
local Playor owner

if itm.userInt <= 0 then
    set tower = itm.getCarrier()
    set owner = itm.getOwner()
    set choose = GetRandomInt(1,6)
    if choose <= 4 then
        set target = Event.getTarget()
    endif
    if choose == 1 then
        call tower.modifyProperty(MOD_ITEM_QUALITY_ON_KILL, 1)
        call target.dropItem(tower,false)
        call tower.modifyProperty(MOD_ITEM_QUALITY_ON_KILL, -1)
        call owner.displayFloatingText("One Item",tower,0,0,255)
    elseif choose == 2 then
        call tower.modifyProperty(MOD_ITEM_QUALITY_ON_KILL, 0.5)
        call target.dropItem(tower,false)
        call target.dropItem(tower,false)
        call tower.modifyProperty(MOD_ITEM_QUALITY_ON_KILL, -0.5)
        call owner.displayFloatingText("Two Items",tower,0,0,255)
    elseif choose == 3 then
        call target.dropItem(tower,false)
        call target.dropItem(tower,false)
        call target.dropItem(tower,false)
        call owner.displayFloatingText("Three Items",tower,0,0,255)
    elseif choose == 4 then
        call tower.modifyProperty(MOD_ITEM_QUALITY_ON_KILL, -0.25)
        call target.dropItem(tower, false)
        call target.dropItem(tower, false)
        call tower.modifyProperty(MOD_ITEM_QUALITY_ON_KILL, 0.35)
        call tower.modifyProperty(MOD_ITEM_CHANCE_ON_KILL, 0.1)
        set itm.userReal = itm.userReal + 0.1
        set itm.userReal2 = itm.userReal2 + 0.1
        call owner.displayFloatingText("Two Items + Bonus!", tower, 0, 0, 255)
    elseif choose == 5 then
        call tower.modifyProperty(MOD_ITEM_CHANCE_ON_KILL,.25)
        set itm.userReal2 = itm.userReal2+0.25
        call owner.displayFloatingText("Item Chance",tower,0,255,0)
    elseif choose == 6 then
        call tower.modifyProperty(MOD_ITEM_QUALITY_ON_KILL,.25)
        set itm.userReal = itm.userReal+0.25
        call owner.displayFloatingText("Item Quality",tower,0,255,0)
    endif
    set itm.userInt = 15
endif
endfunction

On Item Creation

goldcost: 0
function onCreate takes Item itm returns nothing
    set itm.userInt = 0
    set itm.userInt2 = itm.getOwner().getTeam().getLevel()
    set itm.userReal = 0.00
    set itm.userReal2 = 0.00
endfunction

On Item Drop

goldcost: 0
function onDrop takes Item itm returns nothing
local Tower tower = itm.getCarrier()
call tower.modifyProperty(MOD_ITEM_QUALITY_ON_KILL, -itm.userReal)
call tower.modifyProperty(MOD_ITEM_CHANCE_ON_KILL, -itm.userReal2)
endfunction

On Item Pickup

goldcost: 0
function onPickup  takes Item itm returns nothing
    local Tower tower = itm.getCarrier()
    call tower.modifyProperty(MOD_ITEM_QUALITY_ON_KILL, itm.userReal)
    call tower.modifyProperty(MOD_ITEM_CHANCE_ON_KILL, itm.userReal2)
endfunction

On Tower Details

goldcost: 0
function onTowerDetails takes Item itm returns MultiboardValues
call Maj_spellbook.setValue(0,I2S(itm.userInt))
call Maj_spellbook.setValue(1,formatPercent(itm.userReal, 0))
call Maj_spellbook.setValue(2,formatPercent(itm.userReal2, 0))
return Maj_spellbook
endfunction

Periodic

PERIODIC_period: 5 goldcost: 0
function periodic takes Item itm returns nothing
    local integer level = itm.getOwner().getTeam().getLevel()
    if itm.userInt2 < level then
        set itm.userInt = itm.userInt - (level - itm.userInt2)
        set itm.userInt2 = level
    endif
endfunction