• 🏆 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!

Unique item groups

Status
Not open for further replies.
Level 10
Joined
Jun 6, 2007
Messages
392
Hello! I'd like to create "unique item groups" and I'm wondering what would be a good data structure for it. The idea is that a unit can only hold one item per group. There can be any number of groups, and an item can belong to multiple groups. So somehow I should map from item type to multiple integers (group number).
 
Level 17
Joined
Mar 21, 2011
Messages
1,597
i'd recommend you to use a hashtable there which saves a boolean value.
each line is for a specific item type and each column of that line is a group. if the item has to be in the group, just save TRUE in there, else FALSE (or leave it as default)
 
Level 17
Joined
Nov 13, 2006
Messages
1,814
Hello! I'd like to create "unique item groups" and I'm wondering what would be a good data structure for it. The idea is that a unit can only hold one item per group. There can be any number of groups, and an item can belong to multiple groups. So somehow I should map from item type to multiple integers (group number).

i dont got, item could part of multiple group ?
why? i would understand if every item part of 1 item group but multiple group

item - item variable
ID = integer variable
GroupId = integer variable, if u want sort like group1,2 etc then GroupId = 1 or 2 etc
Hash_Table = hashtable variable
A = integer - so u can list it
  • Set Item = (Picked item)
  • Custom script: set udg_ID = GetItemTypeId(udg_Item)
  • Hashtable - Save ID as A of GroupId in Hash_Table
or if it is item type directly then

  • Set Item_Type = Tome of Experience
  • Custom script: set udg_ID = udg_Item_Type
  • Hashtable - Save ID as A of GroupId in Hash_Table
example u save 3 item id to group 1, and 3 to group 2
  • -------- this group 1 --------
  • -------- items: 'pmna' = pendant of mana, 'ciri' = robe of magi +6, 'stel' = staff of teleportation --------
  • -------- u get these raw code in object editor if raw code is checked in --------
  • Custom script: set udg_ID = 'pmna'
  • Hashtable - Save ID as 1 of 1 in (Last created hashtable)
  • Custom script: set udg_ID = 'ciri'
  • Hashtable - Save ID as 2 of 1 in (Last created hashtable)
  • Custom script: set udg_ID = 'stel'
  • Hashtable - Save ID as 3 of 1 in (Last created hashtable)
  • -------- if you want u can save how much item (3) is in group 1 to 0 --------
  • Hashtable - Save 3 as 0 of 1 in (Last created hashtable)
  • -------- this group 1 --------
  • -------- items: 'pmna' = pendant of mana, 'rwiz' = sobi mask, 'ssil' = staff of silence, 'penr' = pendant of energy --------
  • Custom script: set udg_ID = 'rwiz'
  • Hashtable - Save ID as 1 of 2 in (Last created hashtable)
  • Custom script: set udg_ID = 'pmna'
  • Hashtable - Save ID as 2 of 2 in (Last created hashtable)
  • Custom script: set udg_ID = 'ssil'
  • Hashtable - Save ID as 3 of 2 in (Last created hashtable)
  • Custom script: set udg_ID = 'penr'
  • Hashtable - Save ID as 4 of 2 in (Last created hashtable)
  • -------- if you want u can save how much item (4) is in group 2 to 0 --------
  • Hashtable - Save 4 as 0 of 2 in (Last created hashtable)
also if u want then save invers, instead of group number u can save the item raw code, then number (1-x) and saved value the group number, to 0 position save how much group contain this item like

  • -------- set ID = raw code -------
  • -------- we save group 1 to 1st position --------
  • Hashtable - Save 1 as 1 of ID in (Last created hashtable)
  • -------- we save group 4 to 2nd position --------
  • Hashtable - Save 4 as 2 of ID in (Last created hashtable)
  • -------- we save group 10 to 3rd position --------
  • Hashtable - Save 10 as 3 of ID in (Last created hashtable)
  • -------- we save how much group was assigned to id to 0th position --------
  • Hashtable - Save 3 as 0 of ID in (Last created hashtable)
 

sentrywiz

S

sentrywiz

You can just check in condition if a unit has any of your "unique" items and if it does, remove the item bought instead.
 
Status
Not open for further replies.
Top