• 🏆 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!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

Classifying Items

Status
Not open for further replies.
Level 5
Joined
Jul 2, 2009
Messages
112
Is there a way to efficiently classify items, such as using Custom Value?

I'm trying to make an equipment system that uses .KC's animation bank, and I want to make the attack animation change if you wield a different weapon. How would you detect the weapon? I have about 8 different weapon classes.
 
Level 7
Joined
Jul 18, 2009
Messages
272
If you aren't using it yet, I would use the item level. By holding down Shift while doubleclicking the entry, you can insert any value you want.

If there is nothing in your map that can damage items, you can also use the item's hitpoints.


In the map I'm working on, every item has a different level, and then I have arrays like
Item_Class[1] = sword
Item_Class[2] = dagger
Item_Class[3] = hammer
Item_Class[4] = sword
...


If you only need two values per item, I would stick with level and hitpoints, that way you won't need arrays.
 
Level 18
Joined
Jan 21, 2006
Messages
2,552
There are plenty of efficient ways to do this, you could:
  • Use the item's level to classify it (as meOme suggested[/b]).
  • Use the item's custom value (user-data) to classify it (as you hinted at in your first post).
  • vJass Structs

JASS:
struct s_item
    item subject    = null
    
    // By using 'SetItemUserData' we can reference the item's struct-value by doing 'GetItemUserData' on an item handle.
    // This would also allow you to include classification variables like I have done here:
    integer classification = 2
    // it even supports multiple classifications
    integer classification2 = 5

    static method create takes item i returns s_item
        local s_item idat=s_item.allocate()
        set idat.subject=i
        call SetItemUserData(i, idat)
        return idat
    endmethod
endstruct
 
Status
Not open for further replies.
Top