• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

[JASS] Is this an item bug?

Status
Not open for further replies.
Level 2
Joined
Apr 25, 2008
Messages
17
Im having trouble assigning an item to a global array of items very weird, or i just dont understand items at all.

array is 0 - 10

i have a
set i = CreateItem (udg_nextItem, udg_itemlocx , udg_itemlocy )
set udg_item = i

if i run a BJDebugMsg
BJDebugMsg("Item p is " + GetItemName(udg_item)) it will return its name just fine.

Now if i run a BJDebugMsg Externally ie from another function say
function test
Loop
exitwhen i > 10
BJDebugMsg("Item " + I2S(i) + GetItemName(udg_item))
endloop
This will return
item 1 is "Item"
item 2 is <-- this is empty
item 3 is "item"
item 4 is "item"
item 5 is <--- empty
item 6 is <-- empty
*BTW* this is just off the top of my head not the actual results

etc all the way to 10. I seem to have noticed a pattern that every other item is a null. Figuring it could be a pointer issue, i type casted it to a handle and displayed all the handles *which were fine* each item had its own unique handle/pointer.

Then i tried type casting it back to item using the return bug. Still have the problem of some items being null.

This has bugged me for a good few days now ... im asking here as a last resort to this problem

I have uploaded the map i am working on which has the problem

this is code of problem
JASS:
function hz takes nothing returns nothing
    local integer p = GetPlayerId(GetOwningPlayer(GetEnumUnit())) 
    local item i = null
    if udg_debughz then
        call BJDebugMsg(GetPlayerName(Player(p)) + " is in home zone")
    endif
    set udg_idle = udg_idle + 1                                               
    // If cpu has been in hz for 20 seconds force him to make a choice                                               
    if udg_buying == false or udg_idle > 100 then
        // Player has enough gold for its next item, so go buy it
        if GetPlayerState(Player(p), PLAYER_STATE_RESOURCE_GOLD)  >= itemCosts(udg_nextItem) then 
            set udg_buying = true  
            // Create the item the unit is going to buy at a hidden location    
            
            call LockMutex("I")
            set udg_itemlocx = udg_itemlocx + 50 
            set i = CreateItem (udg_nextItem, udg_itemlocx , udg_itemlocy ) 
            call UnlockMutex("I")   
            set udg_item = H2I(i) 
            
            call GotoBuyZone2(p)       
            set udg_buying = false    
        elseif inHealZone(p) then
            set udg_buying = false
            call unitHealed(p)
        else
            set udg_buying = false
            set udg_idle = 0
            call GotoHealZone(p)    
        endif
    endif        
endfunction
 

Attachments

  • sotb.w3x
    807.6 KB · Views: 27
Status
Not open for further replies.
Top