• 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.

[System] Item Recipe

Just name the struct recipe bro :D

Your indention is messed up again :(
JASS:
globals
    private Table recipeTable
endglobals

    struct RecipeList extends array

    private static method onInit takes nothing returns nothing
        local trigger t = CreateTrigger()
        set recipeTable = TableArray[0x2000]
        call TriggerRegisterAnyUnitEventBJ( t, EVENT_PLAYER_UNIT_PICKUP_ITEM)
        call TriggerAddCondition( t, function thistype.recipeCheck)
        set t = null
    endmethod
    
    endstruct

see that?


call TriggerAddCondition( t, function thistype.recipeCheck)

Did you not use JNGP? TriggerAddCondition takes boolexpr, not code.This will cause syntax error.

and also this :
JASS:
        set this.i1 = i1
        set this.i2 = i2
        set this.i3 = i3
        set this.i4 = i4
        set this.i5 = i5
        set this.i6 = i6
JASSHelper doesn't allow that kind of syntax :(

I also rather use private integer array item to take up some space.

edit

I will like this if this features Disassemble item :D
 
i used JNGP even tested and it works fine w the boolexpr lol.

as for the things like this.i1 = i1 thats because of the way i named it.
heres what i mean
JASS:
static method create takes integer i1, integer i2, integer i3, integer i4, integer i5, integer i6, integer itmToBeMade returns thistype
and this
JASS:
    struct RecipeList extends array
        implement Alloc
        
        private integer i1
        private integer i2
        private integer i3
        private integer i4
        private integer i5
        private integer i6

i will change the name to recipe. will try to make a dissasemble item shouldn't be hard at all will just make another struct to do it should be very easy that way if i cant think of a better way using what i already have lol.

and wow sry about the indentation lol i keep doing tht. really stupid haha

edit: i updated changed name like suggested changed syntax a little so it does not confuse someone. ex this.i1 = i1 changed to this.i1 = id1
hopefully updated the indentation the right way haha
 
u mean for the thing in the struct ? my struct extends array so i cant use variables like that and i dont want to make it a global as it could cause some bugs. thts why i take the variables from the struct and change them to a local variable array in the method then use the array. if thts not what u meant could u plz explain more ? ill have to look at it tomorrow tho as im about to fall asleep i will also add an option to pause and resume the the recipes from being made right when u pick up an item that way the user can change that a little easier if they want to
 
I really wonder why people still submit recipe systems? Those things are never useful for the common mapmakers, as the event-cross-interactions with other inventory systems are fatal.
For example, removing items from the inventory to create the crafted item fires the item drop event, which might cause bugs when used together with other inventory systems.

People are usually better off using an inventory system that does all-in-one, not using different resources collected from different places.

This or someone finally creates an item event handler that allows to turn off events globally for all inventory systems used when using AddItem and RemoveItem.

Plus, this is so damn simple that any mapmaker can do this on his own. Even with GUI.
 
Level 14
Joined
Dec 12, 2012
Messages
1,007
Did you not use JNGP? TriggerAddCondition takes boolexpr, not code.This will cause syntax error.

Just to mention it, you can use TriggerAddCondition with code as an argument:

JASS:
scope test initializer Init
    private function testFunction takes nothing returns nothing
    endfunction

    private function Init takes nothing returns nothing
        local code c = function testFunction
    
        call TriggerAddCondition(CreateTrigger(), Filter(c))
    endfunction
endscope

Then you don't have to return false in the condtion function.

Why does this work by the way?
With this techinque you can even pass functions that return anything you want which doesn't really make sense^^
 
If ur tlking about all in one zwiebelchen then what do u mean ? What other functionality does this system need to be all in one ? And this was a system tht I made to be very simple to use w a nice outcome of allowing a lot of recipes. That r easy to change since creating a recipe only uses one line of code. U can also easily make multiple recipes that use one or more of the same ingredient. I code also make a method that can be used to turn off those other systems tht use drop item to fire if they have a trigger to turn off or if they use a Boolean to make them stop working like how mine is. I am also gonna put a pause and resume method so people can pause this when needed.
 
added a pause and resume in case anyone needs to turn off the system

added 2 methods that u add things to to turn off other systems that run on the event EVENT_PLAYER_UNIT_DROP_ITEM
this way if u have any adverse effects when running it will temporarily turn off those systems for u at the right time then turn them back on after the items have been created and removed the old item/s
 
Last edited:
Would you add to this system the functionality of working with such events as Unit enters rect?

i hope to since that is a way of combining ive seen a lot. im fixing the error i had for combining 2 items of same kind. then i will try to find a way to allow for both unit enters region or unit picks up item.

edit: got it to work w 2 or more of the same item just need to fix a small bug now. should be up in under an hr i hope
 
Last edited:
oops i knew it looked funny lol gonna change that immediately. give me about 10 min

edit: now availiable for multiple rects

to add heres example heres what it looks like at first
JASS:
private static method setRect takes region r returns region
            call RegionAddRect( r, gg_rct_urRectName)
            return r
        endmethod

here it is w multiple rects
JASS:
private static method setRect takes region r returns region
            call RegionAddRect( r, gg_rct_urRectName)
            call RegionAddRect( r, gg_rct_urRectName1)
            call RegionAddRect( r, gg_rct_urRectName2)
            call RegionAddRect( r, gg_rct_urRectName3)
            return r
        endmethod
 
Level 18
Joined
Oct 17, 2012
Messages
849
I believe with multiple rects, users should be able to set a specific rect for each recipe because the variety of rects now is useless without a "owner". This does NOT mean preventing multiple recipes from requiring the same rect.
 
Last edited:
I believe with multiple rects, users should be able to set a specific rect for each recipe because the variety of rects now is useless without a "owner".

that makes sense i will update w ownership of regions. not sure if i will get it done in time only have 20 minutes. if i cant it will be done in about 6 hrs or so.
 
I think you should make it irrelevant to rects.
Make the system only handle the recipes themselves.

The API would be something as simple as:

JASS:
function CreateRecipe takes Table inputs, integer inputSize, Table outputs, integer outputSize returns Recipe
function CompileRecipe takes Table itemIds, integer tableSize returns Table // returns output table
 
I think you should make it irrelevant to rects.
Make the system only handle the recipes themselves.

The API would be something as simple as:

JASS:
function CreateRecipe takes Table inputs, integer inputSize, Table outputs, integer outputSize returns Recipe
function CompileRecipe takes Table itemIds, integer tableSize returns Table // returns output table

so ur suggesting to make something that will forcible create recipes. like when unit enters region. the reason i included the rects is just an option if someone doesnt want to use rects all they do is set rect to null. and just use false for the create item recipe method.

edit: i think i will change it back to what u say that way all they will have to call is forceRecipe to manullay create it w event and condition of there choosing

edit 2: i updated the recipe system to not use rects and added a method called forceRecipe. i kept the rest of the API the same
 
Last edited:
I'm still not sure if this cuts it :/

You should allow this to take in any number of item ids.
It should take a Table with a size representing an array.

I think this would be good if it used a plugin approach.
Look at Nestharus' DDS system to see a cool plugin design.

Your core would be nothing but a Recipe data storage unit that allows a user to call one function: createRecipe(Table input, integer size, Table output)

I was going to do this at one point, but I don't have Windows for now.

I was envisioning a plugin that takes a list of item ids and returns an item id for the resultant item. You would also provide an example plugin that uses the assembly plugin to assemble items in the unit's inventory upon picking up an item just to show them how to use this for the regular wc3 inventory (people might want to use a custom inventory after all)

The disassemble plugin would require the assemble plugin. It just maps a resultant item back to one of the possible combinations. You can also expand it with a plugin to disassemble specific items. This plugin would return the exact recipe used to compile a certain item because it would store the recipe data instance in a hashtable using the handle id of the item.

THAT would be the perfect recipe system.
 
i dont like the idea of plugins for a Recipe system. For a damage detection system thats a great idea. It is just meant to make a recipe and create the item when the recipe is present. The disassemble could be a little better but the only problem is how to know which item to disassemble to ? i would have to store all the info whenever a unit creates that item. And still i have no idea what u r referring to w the Table input / output things.
 
My Recipe System sucks though.
See that post I made before about modularity? I've been attempting to modularize it in ways less superior than that before and I've failed because I didn't know how to make it user-friendly. Nes showed me through DDS how to make the recipe system of my dreams.

Too bad I'm probably never going to update it which is why I was counting on you guys to make something of the sort :(
 
i might have the time when the summer is over. atm i do not.
i also dont think that this recipe system is a bad one. it is pretty user friendly and pretty fast. as for the disassemble of the recipes, yes it could be better. also the items with requirement of item charge requirements should be added. i just havent had the time. even my own map has been in limbo for the last 2 to 3 months now.

updated. Now allows for item recipes that require items with charges.
 
Last edited:
Top