HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Items: Gold Coin/ Medallion of Wisdom - Bugs

02-03-2007, 06:39 PM#1
Fulla
Gold Coin - Generates 5 gold every 5 seconds.
Medallion of Wisdom - Generates 4 Xp every 4 seconds.

This is for an AoS/Dota map so obviously only 1 Hero per player.

Collapse JASS:
function Item_Slot_Check takes nothing returns boolean
    return GetItemTypeId(UnitItemInSlotBJ(udg_Player_Heroes[udg_tempinteger], udg_tempinteger2)) == 'I011'
endfunction

function Trig_Gold_Coin_Actions takes nothing returns nothing
    local integer i = 0
    local integer h = 1
    local integer c = 0
    local integer a = 0
    local texttag t = CreateTextTag()
    local real x
    local real y
    
    loop
        exitwhen i == 12
        set udg_tempinteger = i + 1
        
        loop
            exitwhen h == 7
            set udg_tempinteger2 = h
            
            if Item_Slot_Check() == true then
                call SetPlayerState(Player(i), PLAYER_STATE_RESOURCE_GOLD, GetPlayerState(Player(i), PLAYER_STATE_RESOURCE_GOLD) + 5)
                set c = c + 5
                set a = a + 1
            endif
            
            set h = h + 1
        endloop
        
        if c > 0 then
            set x = GetUnitX(udg_Player_Heroes[i + 1])
            set y = GetUnitY(udg_Player_Heroes[i + 1])
            
            call SetTextTagText(t, ("|CFFFFDC00+") + I2S(c), 0.024)
            call SetTextTagPos(t, x, y, 0.00)
            call SetTextTagVelocity(t, 0, 0.03)
            call SetTextTagVisibility(t, true)
            call SetTextTagFadepoint(t, 0)
            call SetTextTagLifespan(t, 3)
            call SetTextTagPermanent(t, false)
            set t = null
            set c = 0
        endif
        
        set i = i + 1
        set h = 1
    endloop

    //if a == 0 then
    //call DisableTrigger(gg_trg_Gold_Coin)
    //endif

endfunction

//===========================================================================
function InitTrig_Gold_Coin takes nothing returns nothing
    set gg_trg_Gold_Coin = CreateTrigger(  )
    call TriggerRegisterTimerEventPeriodic( gg_trg_Gold_Coin, 5.00 )
    call TriggerAddAction( gg_trg_Gold_Coin, function Trig_Gold_Coin_Actions )
endfunction

Collapse JASS:
function Item_Slot_Check2 takes nothing returns boolean
    return GetItemTypeId(UnitItemInSlotBJ(udg_Player_Heroes[udg_tempinteger], udg_tempinteger2)) == 'I03Z'
endfunction

function Trig_Medallion_of_Wisdom_Actions takes nothing returns nothing
    local integer i = 0
    local integer h = 1
    local integer c = 0
    local integer a = 0
    local texttag t = CreateTextTag()
    local real x
    local real y
    
    loop
        exitwhen i == 12
        set udg_tempinteger = i + 1
        
        loop
            exitwhen h == 7
            set udg_tempinteger2 = h
            
            if Item_Slot_Check2() == true then
                call SetHeroXP(udg_Player_Heroes[i + 1], GetHeroXP(udg_Player_Heroes[i + 1]) + 4, false)
                set c = c + 4
                set a = a + 1
            endif
            
            set h = h + 1
        endloop
        
        if c > 0 then
            set x = GetUnitX(udg_Player_Heroes[i + 1])
            set y = GetUnitY(udg_Player_Heroes[i + 1])
            
            call SetTextTagText(t, ("+") + I2S(c), 0.025)
            call SetTextTagPos(t, x, y, 0.00)
            call SetTextTagColor(t, 196, 196, 196, 0)
            call SetTextTagVelocity(t, 0, 0.03)
            call SetTextTagVisibility(t, true)
            call SetTextTagFadepoint(t, 0)
            call SetTextTagLifespan(t, 3)
            call SetTextTagPermanent(t, false)
            set t = null
            set c = 0
        endif
        
        set i = i + 1
        set h = 1
    endloop
    
    //if a == 0 then
    //call DisableTrigger(gg_trg_Medallion_of_Wisdom)
    //endif
    
endfunction

//===========================================================================
function InitTrig_Medallion_of_Wisdom takes nothing returns nothing
    set gg_trg_Medallion_of_Wisdom = CreateTrigger(  )
    call TriggerRegisterTimerEventPeriodic( gg_trg_Medallion_of_Wisdom, 4.00 )
    call TriggerAddAction( gg_trg_Medallion_of_Wisdom, function Trig_Medallion_of_Wisdom_Actions )
endfunction

When a guy picks a hero, ive dbl/tripple checked for certain it is:
Collapse JASS:
    local player o = GetOwningPlayer(c)
    local integer a = GetConvertedPlayerId(o)
   (set f = Hero Picked)
    set udg_Player_Heroes[a] = f

It works fine single player, but multiplayer alot of ppl have been complaining about it sometimes working, sometimes not.
I dont understand
02-03-2007, 08:16 PM#2
Naakaloh
I don't see any issues, but I'm curious to know why you worried about assigning 1 to i and h and then subtracting 1 when using the functions. Also, udg_tempinteger and udg_tempinteger2 don't look like their being used at all.

Edit: I'm not sure how the inventory slots are handled, but are you certain that they aren't index starting at 0?
02-03-2007, 09:08 PM#3
Fulla
aha thx think I got it now.

Just curious thou do I need to be destroying texts or something.
Taur, warned me about 100 text limit which may prohibit this?