• 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.
  • Create a faction for Warcraft 3 and enter Hive's 19th Techtree Contest: Co-Op Commanders! Click here to enter!
  • Create a void inspired texture for Warcraft 3 and enter Hive's 34th Texturing Contest: Void! Click here to enter!
  • The Hive's 21st Texturing Contest: Upgrade is now concluded, time to vote for your favourite set of icons! Click here to vote!

Item morph system help

Status
Not open for further replies.
Level 4
Joined
Aug 7, 2007
Messages
75
Alright, I'm a little stumped at my structure for how I want my system to work. Here's the basics of it:

Several items as base 'ingredients', 30+.
One basic unit that transforms into another based on what items get put into him.

Current concept:
Each base ingredient has an integer label using custom value. When items get put together on the basic unit, trigger calculates total custom value and checks it against an array which hold integers that correspond to their CV total. (I.E. IntArray[1] = 19, UnitArray[1] = BigBossMan. BigBossMan is the unit that the basic unit becomes if his items total 19.)

Example:
Basic unit is given Item A, labelled with CV 7. He transforms into unit which has the array label of 7.
Basic unit is then given Item B, labelled with CV 12. Total CV is 19, unit transforms into the unit in the array with the label of 19.
So on and so forth up to 6 transformations for 6 items. Items are not allowed to be removed once added, but do carry over from one unit type to the upgraded version.

Problem:
The system works well so far, but I failed to notice a fatal flaw in the logic. Adding item 7 with item 12 to make the unit labelled 19 works fine... but any combination works as well. For example, item 6 plus item 13 would also make the unit labelled 19, when they are supposed to make something else.

So, I need to figure out how to make an efficient system to detect all items in the unit's inventory, and output the correct unit that matches that particular combination. Would greatly appreciate any help that I could get on this issue.

EDIT: After some re-thinking of my logic, I've figured out a way that appears to work. It uses the same system I had in place, but instead of adding integers as labels, I'm using 2-character strings instead, chopping up the string labels for the items and comparing them to an array of string labels for the units. If someone can come up with a better method, I'm still open to ideas.
 
Last edited:
Level 7
Joined
Jul 29, 2009
Messages
276
in my map i made a craft system that is a little limited but does its job. i used some arrays:
Craft_Item (Item-type, is the item created)
Craft_ing1 (Item-type, is the first ingridiante item)
Craft_ing1_Amount (Integer, is the amount of charges of that item needed)
Craft_ing2
Craft_ing2_Amount
and so on.. (i have 3)

so if spear needs 2 woods to make i do
Craft_Item[1] = spear
Craft_ing1[1] = wood
Craft_ing1_Amount[1] = 2

then, when the crafting starts i loop through the indexes, searching each inventory slot for the ingridients, if i find a matching receipe i remove the items or charges and create the item.

it suits me.
 
Status
Not open for further replies.
Top