| 08-19-2006, 12:44 AM | #1 |
For my map I have GUI triggers that check whenever items are aquired and it does the necessary if statements and item swapping etc. But the GUI is very cumbersome and it feels stupid specifying the required items once and then specifying them again to remove them. What I need is some simple function where I can pass the required items and it will do all the work, instead of copying GUI triggers with similar code but different items. My requirements are a little special though. Some items can be built from a choice of ingredients. For example the Stun stick requires Claws of Attack + (Well-Made Bow OR Fine-Crafted Hatchet). The ideal system could handle any combination of ANDs and ORs but I might only need to specify "Items you must have all of" and "Items you must have one of". Some recipes require only 1 ingredient, some will require up to 3 seperate ingredients. Also, some items have a recipe version to show their ingredients when you look at them in the store. On other items with simpler recipes I can get away with explaining the recipe in the "Purchase [Item]" text field of the real item. I think those are all the issues to be aware of. I can keep using my clumsy GUI triggers but it is slow to add new items and probably slow running as well. If somebody could come up with a fancy function or clever database system for my needs I would be very greatful. |
| 08-19-2006, 02:36 AM | #2 |
hmnn you are almost screaming me to release the set system that used to be included in the pools system map Edit: After checking it out I figured out it is not as flexible as the horadric cube, I thought it was as good but I was wrong |
| 08-19-2006, 07:01 AM | #3 |
I'm not sure a set data structure is the right thing for the logic he wants. You need a parser for logic trees to implement the and or stuff, which could be a big pain. But! We have boolexprs. Unfortunately we don't have closures, so it's still a major pain. Your base boolexpr will be something like: JASS:function unithasme takes nothing returns boolean set udg_itemindex = udg_itemindex + 1 return unithasitem(udg_invunit,udg_items[udg_itemindex]) endfunction Create the logic tree of items, like And(I000,Or(I001,I002)) Then put them in a list in the order the leaves appear, from left to right. rewrite the tree with unithasme in the leaves: JASS:local boolexpr b = Condition(function unithasme) local boolexpr tree = And(b,Or(b,b)) gee.. maybe it is easier to just implement the tree parser ;) still there might be a way to use boolexprs that isn't an unholy mess. also, a set structure may still be appropriate, in the sense that you filter out all the recipes it could be, then you pick out of that list with some priority for which gets the cheese. |
| 08-19-2006, 01:02 PM | #4 |
The recipe would be in conjunction of disjunctions form. I doubt there would be need for a recipe more complicated than that. And Pools simply worked, if we think a little a pool of pools is kinda a tree that has hashing to easily notice if an item is in a branch. |
| 08-19-2006, 01:26 PM | #5 |
You could just go the brute force way and split the ORs into multiple AND-only recipies. I wonder what happened to the trigger repository forum, I remember posting an item merging system there once - there were like 4 different systems there at the time. Edit: Ah, found it. It's over 2 years old, though, terribly outdated, and it wasn't all that great to begin with. Actually, with many item combinations, you could even reach the array size limit. It would take over a thousand 6-item combos, but still... |
| 08-20-2006, 12:31 AM | #6 |
I figured this would require some logic a little beyond my capabilities. PipeDream's idea seems interesting but I don't really get it. Are you saying I could fashion arguments to pass to a function or something? Cuz, that would be cool if I could just have a trigger when the recipe is sold and then do like JASS:items_arg = And(I000,Or(I001,I002)) call ItemTransaction(items_arg, GetSoldItem()) and then the ItemTransaction function could be like JASS:function ItemTransaction takes boolexpr has_items item sold_item returns nothing if CheckItems(has_items) then //get real item else //unsell sold_item, sim error endif endfunction and then CheckItems would be some magical function that parses has_items. And I could add on a few more flags on the function such as a boolean for if the item is the real thing or a recipe version or an integer for how many of that item you are allowed. At least that would be fairly convenient for me to make recipes. All I would have to do then is create a trigger for each recipe - changing the condition of the trigger to match the sold item in question - change the ands, ors and item ids of the item_args variable and specify the flags for the ItemTransaction function. Maybe there is an easier way still. And maybe that could get laggy with a lot of recipes, assuming this is possible at all? I have no idea. EDIT:Anitarf I saw your system in my searches before I posted this thread. That style, with a database of items is also a cool idea. I imagine something like that might be more effecient then a trigger for every recipe. But I don't get that system either. Could it be adapted for my special conditions? |
| 08-21-2006, 06:21 PM | #7 |
Hello? Still don't know what to do here. Could somebody explain to me or point me to an explanation of boolexpr's cuz I think they might be useful. |
