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

Crafting system

Status
Not open for further replies.
Level 18
Joined
Feb 19, 2009
Messages
800
I'm in way over my head here and I need some help.

In my newest map, I'm trying to include a crafting system for my newest map. The idea is that the player puts certain items into a "horadric cube" and a new, stronger item is created. An example would be the player puts a health potion and a mana potion into the cube and it creates a mana potion.

I thought this would be way easier than it actually is. I need help. How the hell do I do this?
 
First step,is to give your "cube" an inventory ability.For instance,I'll use a 2 inventory slot for the horadric cube.
This is one of the crafting triggers,created by yours truly.Not the best one but still might work.
  • Crafting 1
    • Events
      • Unit - A unit Acquires an item
    • Conditions
      • And - All (Conditions) are true
        • Conditions
          • ((Hero manipulating item) has an item of type Red Body) Equal to True
          • ((Hero manipulating item) has an item of type Red Organs) Equal to True
    • Actions
      • Set the cube = (Hero manipulating item)
      • Item - Remove (Item carried by the cube of type Red Body)
      • Item - Remove (Item carried by the cube of type Red Organs)
      • Hero - Create Full Working Red Body and give it to the cube
      • Hero - Drop the item from slot 1 of the cube
That way,the cube will remove the red body/organs after the craft,and replace it with a full working red body.I'm not sure which slot the item will be hold on to the cube's inventory.
 
Last edited:
Level 18
Joined
Feb 19, 2009
Messages
800
First step,is to give your "cube" an inventory ability.For instance,I'll use a 2 inventory slot for the horadric cube.
This is one of the crafting triggers,created by yours truly.Not the best one but still might work.
  • Crafting 1
    • Events
      • Unit - A unit Acquires an item
    • Conditions
      • And - All (Conditions) are true
        • Conditions
          • ((Hero manipulating item) has an item of type Red Body) Equal to True
          • ((Hero manipulating item) has an item of type Red Organs) Equal to True
    • Actions
      • Set the cube = (Hero manipulating item)
      • Item - Remove (Item carried by the cube of type Red Body)
      • Item - Remove (Item carried by the cube of type Red Organs)
      • Hero - Create Full Working Red Body and give it to the cube
      • Hero - Drop the item from slot 1 of the cube
That way,the cube will remove the red body/organs after the craft,and replace it with a full working red body.I'm not sure which slot the item will be hold on to the cube's inventory.

Gonna give this a try in the morning and report the results. Thanks!
 
Level 4
Joined
Feb 12, 2016
Messages
71
You will have to take this a step further than manually setting up triggers for every recipe combination.

I wrote a small system that allows me to define recipes in the map header or wherever, just by calling a function with the corresponding IDs and desired stacks.

Basically i just keep filling an array with the ids, another one with the stacks and whenever a unit acquires an item i loop through the array of IDs and check if the picked up item is mentioned somewhere.
If it is mentioned somewhere i check if the unit has all other items with the required stacks - if thats the case, then i do basically the same that was done in above trigger as well.

So creating a recipe for me basically takes
JASS:
call createRecipe2(id1,id2,id3, stack1, stack2, stack3) // 2 as in 2 required items
Where the last id and stack is that of the resulting item.
0 stacks means its a non-stacked item (no stacks show ingame) and the rest is logical.

You can do it yourself, it really is no magic - are you familiar with Jass-Coding or programming in general?
 

TKF

TKF

Level 19
Joined
Nov 29, 2006
Messages
1,266
Indexing item-types is a way. But its some work if you haven't done that already.

I made one for Naval Battle which makes it very easy to create cannons projectiles from the cannons you carry in inventory using hashtable, also assigning unique index number to each item-type you need (put that in a initialization trigger). Then you got you items organized for further use for other things as well.

In my example I assigned some data and unit type attached to each item, while I can connect some abilities to some items. (If you want an item to cause bonus to a certain ability for example).
 
Level 4
Joined
Feb 12, 2016
Messages
71
Yea, to some things that applies and it makes no sense to reinvent it

But especially when you can use the practice of doing it yourself you should do it - IMHO.

I googled around and came across some of the systems there and as far as I remember one was missing consideration of stacks and the other was over complicated code wise, so I did it myself.

I'm sure there are some very clean ones out there, in case the original poster really has no intention of doing it himself.
 
Status
Not open for further replies.
Top