Bloodthirsty Wheel of Fortune v1
540
lvl: 20

ID:

181

Author:

Palandu

Rarity:

rare

Status:

Approved

Description:

This wheel can only be spun when oiled with a victim's blood.

Latest Upload Comment:

Restored from 1.10
Wheel of Fortune
With every kill there is a 25% chance to spin the wheel. Every spin will either increase (66% fixed chance) or decrease (33% fixed chance) the item find bonus by 4%. Total range: -24% to +48%. The bonus is bound to the item.
Download

Toggle Triggers

Header

goldcost: 540
    globals
        MultiboardValues slotMachineMB
    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 slotMachineMB = MultiboardValues.create(1)
        call slotMachineMB.setKey(0,"Wheel of Fortune Bonus")
    endfunction

On Item Creation

goldcost: 0
function onCreate takes Item itm returns nothing
    set itm.userReal=0.0
endfunction

On Item Drop

goldcost: 0
function onDrop takes Item itm returns nothing
    if itm.userReal !=0.0 then
        call itm.getCarrier().modifyProperty(MOD_ITEM_CHANCE_ON_KILL, -1*itm.userReal)
    endif
endfunction

On Item Pickup

goldcost: 0
function onPickup  takes Item itm returns nothing
    if itm.userReal !=0.0 then
        call itm.getCarrier().modifyProperty(MOD_ITEM_CHANCE_ON_KILL, itm.userReal)
    endif
endfunction

On Kill

goldcost: 0
function onKill takes Item itm returns nothing
    local Tower t
    set t = itm.getCarrier()
    if t.calcChance(0.25) then
        if ModuloInteger(GetRandomInt(1,99),3) == 0 then    //lower chance
            if(itm.userReal >= -0.20) then
                set itm.userReal = itm.userReal - 0.04
                call t.modifyProperty(MOD_ITEM_CHANCE_ON_KILL, -0.04)
                call t.getOwner().displaySmallFloatingText("Item Chance Lowered!",t,255, 0, 0,30)
            endif
        else                                                //raise chance
            if(itm.userReal <= 0.44) then
                set itm.userReal = itm.userReal + 0.04
                call t.modifyProperty(MOD_ITEM_CHANCE_ON_KILL, 0.04)
                call t.getOwner().displaySmallFloatingText("Item Chance Raised!",t,0, 0, 255,30)
            endif
        endif
    endif
endfunction

On Tower Details

goldcost: 0
function onTowerDetails takes Item itm returns MultiboardValues
    call slotMachineMB.setValue(0, formatPercentAddColor(itm.userReal, 0))
    return slotMachineMB
endfunction