• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!

Item classification

Status
Not open for further replies.
Level 4
Joined
Feb 12, 2016
Messages
71
Hello,

I am working on a simple item-slot system, where a unit can't have more than one of each slot (helm, weapon, ...).

Now, I have a Jass trigger that checks every inventory slot for its item type and compares that to the item that is being picked up.

I have noticed that items with miscellaneous as item classification always bug for me and trigger a drop despite an empty inventory.


Am I assuming right that itemtype is an enumeration starting from 0, and when I use GetItemType on an empty inventory slot, I am returned 0, as no item is found and thus just some default value is returned?
And 0 most likely represents the itemtype miscellaneous then, I guess?
Otherwise I can't understand why items of this type bug out.

Anyone ever noticed this behavior?
 
Last edited:
Level 24
Joined
Aug 1, 2013
Messages
4,657
Ussually when you have types and classify them with a number, you start at 0, then 1, then 2, etc
You can use 1, then 2, then 3, etc and use 0 as a "nothing" item type (or a bug), but its not really necessary.

In any case we cant really tell you what is happening because we have no idea how "a Jass trigger" is working.

It could be that Miscellaneous is an item classification that it doesnt support.
In fact, there are 7 item classifications, and there are 6 item slots at max.
The creator of that system most probably thought it was a good idea to use item classifications to define in which slot the items belong.
So slot 1 is permanent, slot 2 is charged, slot 3 is powerup, slot 4 is artifact, slot 5 is purchable and slot 6 is campaign... then we are left with miscellaneous... so we just ignore those and drop the items of that type whenever we pick them up.

Damnit, how did I knew how "a Jass trigger" works without having seen it?
 
Level 4
Joined
Feb 12, 2016
Messages
71
Hello and thanks for your answer!

I asked the question a little shady, which explains why you missunderstood the nature of the question.

See, i wrote a simple trigger, which serves the purpose of forbidding a unit to have 2 or more items of the same Item-Classification in their inventory.

To achieve this, i trigger on the event that a unit acquires an item, then loop through the unit's inventory and check every slot's Item-Classification and compare this to the item being picked up.
If i find a slot that has an item of equal Item-Classification, i issue the unit to drop the item it tried to pick up.

Now, the trigger is working fine for all item types except for Miscellaneous.

Since i have a hard time debugging JASS-Code, due to missing conversion of types to string, i assumed that this might be a known problem, which is why i posted on here with only this short description.

Now, i put the effort into it and added some Debug-Functionality to my code, and it turns out that if i give an item the Item-Classification "Miscellaneous" in the Object Editor, inside of my Jass-Code i am returned ITEM_TYPE_UNKNOWN for these items.


Here is a stripped down, basic Debug-purpose Jass function that demonstrates what i mean:

JASS:
function IT2S takes itemtype theType returns string
    if theType == ITEM_TYPE_ANY then
        return "ANY"
    elseif theType == ITEM_TYPE_ARTIFACT then
        return "ARTIFACT"
    elseif theType == ITEM_TYPE_CAMPAIGN then
        return "CAMPAIGN"
    elseif theType == ITEM_TYPE_CHARGED then
        return "CHARGED"
    elseif theType == ITEM_TYPE_MISCELLANEOUS then
        return "MISCELLANEOUS"
    elseif theType == ITEM_TYPE_PERMANENT then
        return "PERMANENT"
    elseif theType == ITEM_TYPE_POWERUP then
        return "POWERUP"
    elseif theType == ITEM_TYPE_PURCHASABLE then
        return "PURCHASABLE"
    elseif theType == ITEM_TYPE_TOME then
        return "TOME"
    elseif theType == ITEM_TYPE_UNKNOWN then
        return "UNKNOWN"
    else
        return "No Fucking Idea"
    endif   
endfunction


function Trig_Untitled_Trigger_001_Actions takes nothing returns nothing
    call BJDebugMsg("- Picked up item has type " + IT2S(GetItemType(GetManipulatedItem())))
endfunction

//===========================================================================
function InitTrig_Untitled_Trigger_001 takes nothing returns nothing
    set gg_trg_Untitled_Trigger_001 = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_Untitled_Trigger_001, EVENT_PLAYER_UNIT_PICKUP_ITEM )
    call TriggerAddAction( gg_trg_Untitled_Trigger_001, function Trig_Untitled_Trigger_001_Actions )
endfunction

With this trigger turned on, i pick up and item, which i gave the Item-Classification "Miscellaneous" in the Object Editor and get a Debug-Message, saying that the itemtype is UNKNOWN.

So what exactly is going on?
 
Level 4
Joined
Feb 12, 2016
Messages
71
Alright, i just wanted this confirmed, might have missed some kind of settings in the Object Editor.

Only problem is that empty Inventory-Slots also return UNKNOWN, as there is no item in them.
But i can fix that by checking if UnitItemInSlot returns something != null first.

Thanks for your input :)
 
Status
Not open for further replies.
Top