| 11-07-2004, 03:21 PM | #1 |
This has been a month of item crafting here in the repository, it seems. First, volatile posted a simple item-merging trigger . Provoked by it's simplicity, Sorrento posted his slightly more complex system . The ensuing debate then provoked Lord Vexorian to teach us just how very nooby GUI triggering is. However, by then, I was already halway through the creation of my own item-system. It's nowhere near Lord Vexorian's JASS goodness, but it's probably close to the best that can be done in GUI. Features: - Can use multiple sizes of item combinations, from 2 to 6. - Can have more of the same items required for a single combination - Uses only two variable arrays, one item-type and one integer - Optimized engine verifies only combinations that include the acquired item - Database system allows simple addition or removal of item combinations Here's a peek at how the database looks: first the combined item, then all the items required for it; and so on, combination after combination. First the two-item combinations, last the six-item. But the system is designed so that you can easily squeeze in another two-item combo without having to modify the array indexes on all the three-, four-, five- and six-item combos. Trigger: item combination Initialization
![]() Conditions
![]() Actions
![]() ![]() Set ItemSystemInt[1] = 0
![]() ![]() -------- Ammount of each type of combinations - Set this accordingly to the items or the system will not function properly --------
![]() ![]() Set ItemSystemInt[2] = 4
![]() ![]() Set ItemSystemInt[3] = 1
![]() ![]() Set ItemSystemInt[4] = 0
![]() ![]() Set ItemSystemInt[5] = 0
![]() ![]() Set ItemSystemInt[6] = 1
![]() ![]() -------- 2-item combos --------
![]() ![]() Set ItemSystem[0] = Ring of Protection +2
![]() ![]() Set ItemSystem[1] = Ring of Protection +1
![]() ![]() Set ItemSystem[2] = Ring of Protection +1
![]() ![]() Set ItemSystem[3] = Ring of Protection +3
![]() ![]() Set ItemSystem[4] = Ring of Protection +2
![]() ![]() Set ItemSystem[5] = Ring of Protection +1
![]() ![]() Set ItemSystem[6] = Ring of Protection +4
![]() ![]() Set ItemSystem[7] = Ring of Protection +3
![]() ![]() Set ItemSystem[8] = Ring of Protection +1
![]() ![]() Set ItemSystem[9] = Ring of Protection +4
![]() ![]() Set ItemSystem[10] = Ring of Protection +2
![]() ![]() Set ItemSystem[11] = Ring of Protection +2
![]() ![]() Set ItemSystemInt[1] = (ItemSystemInt[1] + (ItemSystemInt[2] x 3))
![]() ![]() -------- 3-item combos --------
![]() ![]() Set ItemSystem[(0 + ItemSystemInt[1])] = Serathil
![]() ![]() Set ItemSystem[(1 + ItemSystemInt[1])] = Gloves of Haste
![]() ![]() Set ItemSystem[(2 + ItemSystemInt[1])] = Sturdy War Axe
![]() ![]() Set ItemSystem[(3 + ItemSystemInt[1])] = Claws of Attack +9
![]() ![]() Set ItemSystemInt[1] = (ItemSystemInt[1] + (ItemSystemInt[3] x 4))
![]() ![]() -------- 6-item combos --------
![]() ![]() Set ItemSystem[(0 + ItemSystemInt[1])] = Anduril
![]() ![]() Set ItemSystem[(1 + ItemSystemInt[1])] = Hilt of Narsil
![]() ![]() Set ItemSystem[(2 + ItemSystemInt[1])] = Blade of Narsil
![]() ![]() Set ItemSystem[(3 + ItemSystemInt[1])] = Shard of Narsil
![]() ![]() Set ItemSystem[(4 + ItemSystemInt[1])] = Shard of Narsil
![]() ![]() Set ItemSystem[(5 + ItemSystemInt[1])] = Shard of Narsil
![]() ![]() Set ItemSystem[(6 + ItemSystemInt[1])] = Shard of NarsilThat's all a user needs to really know, as the database trigger is all you'll ever need to modify, but anyway, here's the actual Core of the system: Trigger: The item combination Core
![]() Conditions
![]() Actions
![]() ![]() For each (Integer A) from 7 to 17, do (Set ItemSystemInt[(Integer A)] = 0)
![]() ![]() Set ItemSystemInt[1] = 0
![]() ![]() Set ItemSystemInt[11] = -1
![]() ![]() For each (Integer ItemSystemInt[10]) from 1 to 100000, do (Actions)
![]() ![]() ![]() Loop - Actions
![]() ![]() ![]() ![]() Set ItemSystemInt[7] = (ItemSystemInt[7] + 1)
![]() ![]() ![]() ![]() If (All Conditions are True) then do (Then Actions) else do (Else Actions)
![]() ![]() ![]() ![]() ![]() Then - Actions
![]() ![]() ![]() ![]() ![]() ![]() Set ItemSystemInt[7] = 1
![]() ![]() ![]() ![]() ![]() ![]() Set ItemSystemInt[8] = (ItemSystemInt[8] + 1)
![]() ![]() ![]() ![]() ![]() ![]() Set ItemSystemInt[10] = (ItemSystemInt[10] + 1)
![]() ![]() ![]() ![]() ![]() ![]() If (All Conditions are True) then do (Then Actions) else do (Else Actions)
![]() ![]() ![]() ![]() If (All Conditions are True) then do (Then Actions) else do (Else Actions)
![]() ![]() ![]() ![]() ![]() Then - Actions
![]() ![]() ![]() ![]() ![]() ![]() Set ItemSystemInt[11] = ItemSystemInt[8]
![]() ![]() ![]() ![]() ![]() ![]() For each (Integer A) from 1 to (ItemSystemInt[9] + 2), do (Actions)
![]() ![]() ![]() ![]() ![]() ![]() ![]() Loop - Actions
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() For each (Integer B) from 1 to 6, do (Actions)
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Loop - Actions
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() If (All Conditions are True) then do (Then Actions) else do (Else Actions)
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() If - Conditions
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() And - All (Conditions) are true
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Conditions
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() And - All (Conditions) are true
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Conditions
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ((Integer B) Not equal to ItemSystemInt[((Integer A) + 10)]) or ((Integer A) Less than 2)
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ((Integer B) Not equal to ItemSystemInt[((Integer A) + 9)]) or ((Integer A) Less than 3)
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ((Integer B) Not equal to ItemSystemInt[((Integer A) + 8)]) or ((Integer A) Less than 4)
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ((Integer B) Not equal to ItemSystemInt[((Integer A) + 7)]) or ((Integer A) Less than 5)
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ((Integer B) Not equal to ItemSystemInt[((Integer A) + 6)]) or ((Integer A) Less than 6)
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ItemSystem[((ItemSystemInt[10] - ItemSystemInt[7]) + (Integer A))] Equal to (Item-type of (Item carried by (Hero manipulating item) in slot (Integer B)))
|
| 11-16-2004, 06:47 PM | #2 |
Ok, the system looks great and all but im a complete triggering noob so i dont understand some of the stuff in it. Could you explain like, where i would put everything to set it up, meaning where to set the items n stuff. Thanks |
| 11-16-2004, 08:10 PM | #3 |
First of all, if you are comepletely unfamiliar with the trigger editor, this might not be the best system for you. As I wrote in the introduction of the topic, there are multiple of item-merging systems, each with their own strenghts and weaknesses. Generally, the more complex the systems get, the more difficult it is to use them despite all the effort put into making the databases as user-friendly as possible. Anyway, here's what the original post maybe lacked, a detailed instruction on how to use this system: All a user ever needs to modify is the first trigger, the database that organizes all the items into recipies. This trigger runs when the map starts and it assigns item-types to variables in a special order; the Core of the system can handle any item combinations, if they are properly input into the database. The combinations are stored into a single item-type variable array. It starts with Index 0 and then each next item you input must have the next index. When imputing a recipie, you must put in the end-result item first, and then all the items required for the recipie. This can clearly be seen in the example database: Code:
Set ItemSystem[0] = Ring of Protection +2
Set ItemSystem[1] = Ring of Protection +1
Set ItemSystem[2] = Ring of Protection +1The recipies in the database are divided into sections, based on how many items each recipie requires. You must follow this system: all the two-item recipies must be listed one after another before you start with the three-item recipies. In the example database given above, all 4 two-item combinations are listed first. For every section, you must specify, at the beggining of the database trigger, how many items are in it; the example database has 4 two-item combos, 1 three-item and 1 six-item: Code:
Set ItemSystemInt[2] = 4
Set ItemSystemInt[3] = 1
Set ItemSystemInt[4] = 0
Set ItemSystemInt[5] = 0
Set ItemSystemInt[6] = 1After each section (unless a section has 0 recipies, in that case it is not needed) comes the following line: Code:
Set ItemSystemInt[1] = (ItemSystemInt[1] + (ItemSystemInt[2([i]this number is different for every section, as is apparent from the example database[/i])] x 3([i]this number is also different for each section, see the example database[/i]))) This is done so that you can start each section with an array number 0 (actually, it's 0+ItemSystemInt[1]), no matter how long the previous section was. So, if you additionally add another two-item combo to the database, at the end of the first section, you don't need to modify the array indexes of all the items in other sections. Just don't forget to change the numbers specified at the beggining of the database when you add recipies! |
| 12-31-2004, 11:20 PM | #4 |
Guest | Or, you do like I do: Code:
Events
- A unit aquires an item.
Condition
- And - All (Conditions) are true
- Conditions
((Triggering unit) is A Hero) Equal to True
(Item-type of (Item carried by (Triggering unit) of type Huge Damage Booster)) Equal to Huge Damage Booster
(Item-type of (Item carried by (Triggering unit) of type Elven Bow: Tome)) Equal to Elven Bow: Tome
(Item-type of (Item carried by (Triggering unit) of type Minor Agility Booster)) Equal to Minor Agility Booster
Actions
- Item - Remove (Item carried by (Triggering unit) of type Huge Damage Booster)
- Item - Remove (Item carried by (Triggering unit) of type Minor Agility Booster)
- Item - Remove (Item carried by (Triggering unit) of type Elven Bow: Tome)
- Hero - Create Elven Bow and give it to (Triggering unit)Voila! (sp?) There you have it, a small, easy to read, item combiner. This trigger removes all 3 items when you have the 3 items in conditions, and creates the Elven Bow. |
| 01-02-2005, 01:59 PM | #5 |
If you were to check the links I provided at the beggining of the thread, you would have seen that a system using the same functions has already been proposed by Sorrento. Further reading would have enlightened you with the fact that this kind of system cannot handle item combinations which would require multiple items of the same type. Additionaly, you are replicating triggers, one for each item combination, like Volatile does. That can easily be used, but when you have many item combinations, it just isn't a very clean coding style. My system works with a database, and that automatically requires more complexity. |
| 03-16-2005, 02:12 PM | #6 |
But what is this supposed to do? There is a much easier way to combine items, lookie here. Code:
EVENT: Unit casts a spell CONDITIONS: (Triggering Spell) is equalt to (MIX) ACTIONS: If/Then/Else IF: AND (anything with one > is part of AND; >> means part of OR) > (Triggering Spell) is equalt to (MIX) >OR >>(Triggering Unit) Item slot (1) contains (Wood) >>(Triggering Unit) Item slot (2) contains (Wood) >>(Triggering Unit) Item slot (3) contains (Wood) >>(Triggering Unit) Item slot (4) contains (Wood) >>(Triggering Unit) Item slot (5) contains (Wood) >>(Triggering Unit) Item slot (6) contains (Wood) >OR >>(Triggering Unit) Item slot (1) contains (Steel) >>(Triggering Unit) Item slot (2) contains (Steel) >>(Triggering Unit) Item slot (3) contains (Steel) >>(Triggering Unit) Item slot (4) contains (Steel) >>(Triggering Unit) Item slot (5) contains (Steel) >>(Triggering Unit) Item slot (6) contains (Steel) Then: Create (Axe) for (Triggering Unit) Else: ( Do the next part) Now isn't that nice and clean? You must be trying to do something weird, because I don't understand how that script could become to complicated with something as simple as what I just wrote. To make what I just did check for Multiple Items of the same type, it's a little harder, but not much. Code:
FOR: IntA =1-6 >>(Triggering Unit) Item slot (A) contains (Steel) >> FOR IntB= 1-6 >>>>(Triggering Unit) Item slot (B) contains (Steel) >>>>IF: B is not equal to A >>>>>> Create= Steel Sword OMG! wasn't that easier? Please explain why your system isn't like the one I just made. What do you want yours to do? |
| 03-16-2005, 07:19 PM | #7 |
OK, wise guy, tell me, which is longer? Code:
EVENT: Unit casts a spell CONDITIONS: (Triggering Spell) is equalt to (MIX) ACTIONS: If/Then/Else IF: AND (anything with one > is part of AND; >> means part of OR) > (Triggering Spell) is equalt to (MIX) >OR >>(Triggering Unit) Item slot (1) contains (Wood) >>(Triggering Unit) Item slot (2) contains (Wood) >>(Triggering Unit) Item slot (3) contains (Wood) >>(Triggering Unit) Item slot (4) contains (Wood) >>(Triggering Unit) Item slot (5) contains (Wood) >>(Triggering Unit) Item slot (6) contains (Wood) >OR >>(Triggering Unit) Item slot (1) contains (Steel) >>(Triggering Unit) Item slot (2) contains (Steel) >>(Triggering Unit) Item slot (3) contains (Steel) >>(Triggering Unit) Item slot (4) contains (Steel) >>(Triggering Unit) Item slot (5) contains (Steel) >>(Triggering Unit) Item slot (6) contains (Steel) Then: Create (Axe) for (Triggering Unit) Else: ( Do the next part) Code:
Set ItemSystem[0] = Axe
Set ItemSystem[1] = Wood
Set ItemSystem[2] = SteelYou use up 15 more lines of code per item combination than me. With only 10 item combinations, that gives you 150 more lines of code: my "too complicated" Core that allows me to write down item combination in such a short way is about 100 lines long. With only 10 item combinations, your way already takes up more space than mine. Also, your trigger gets excessively longer with longer item combinations, and, as you said, it doesn't allow item combinations that require more instances of the same item. I never said my system was the best, that's why I also linked to all the others that were posted in the repository at that time. But I still claim my system is the most flexible (it allows any size of item combinations, and more items of the same type per combo), easy to use (you can just add an item combination into the database with 3-7 lines of code) GUI system (Lord Vexorian's is done in JASS) for large ammounts of item combinations. Lord Vexorian's system is the most advanced overall, Sorrento's is simpler, easier to understand, but offers less functionality, and Volatile's is the precursor of mine that is simple to implement for fewer item combinations, and is the same as you proposed last. Each of these systems is good for something. The triggers you posted are not. |
| 03-29-2005, 07:36 PM | #8 | |
Guest | Quote:
Beautiful system Anitarf. Definately not noob friendly as you probably can tell by earlier posts, but a system of award winning calibrations as far as shrinking map sizes goes. Once the core is setup, it's just a few small additions per item, unlike the other trigger set ups. I give it: |
| 04-10-2005, 03:39 AM | #9 | |
Guest | Quote:
sure it can: ex: Code:
item counter acquire
Events
Unit - A unit Acquires an item
Conditions
Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(Item-type of (Item being manipulated)) Equal to Ultimate Orb
Then - Actions
Set ultorbsowned[(Player number of (Owner of (Triggering unit)))] = (ultorbsowned[(Player number of (Owner of (Triggering unit)))] + 1)
Else - Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(Item-type of (Item being manipulated)) Equal to Broadsword
Then - Actions
Set broadswordsowned[(Player number of (Owner of (Triggering unit)))] = (broadswordsowned[(Player number of (Owner of (Triggering unit)))] + 1)
Else - Actions
Do nothingcontinued.. Code:
uber item
Events
Unit - A unit Acquires an item
Conditions
Or - Any (Conditions) are true
Conditions
(Item-type of (Item being manipulated)) Equal to Ultimate Orb
(Item-type of (Item being manipulated)) Equal to Recipe: uber item
Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
And - All (Conditions) are true
Conditions
ultorbsowned[(Player number of (Owner of (Triggering unit)))] Greater than or equal to 3
((Triggering unit) has an item of type Recipe: uber item) Equal to True
Then - Actions
Special Effect - Create a special effect attached to the overhead of (Hero manipulating item) using Abilities\Spells\Items\AIem\AIemTarget.mdl
Item - Remove (Item carried by (Hero manipulating item) of type Ultimate Orb)
Item - Remove (Item carried by (Hero manipulating item) of type Ultimate Orb)
Item - Remove (Item carried by (Hero manipulating item) of type Ultimate Orb)
Item - Remove (Item carried by (Hero manipulating item) of type Recipe: uber item)
Hero - uber item and give it to (Hero manipulating item)
Special Effect - Destroy (Last created special effect)
Else - Actions
Do nothing |
| 04-10-2005, 04:53 PM | #10 |
You are practically beging me to insult you. First of all, the triggers you posted are entirely different from the systems your quote refers to. Secondly, the triggers you posted are a goddamn mess. Let's not get into petty details like it only works if a player has only one hero. It would be enough to just point out that you are using up global variables to document how many items of a type a player has. Your triggers are not any kind of a system in particular, it's just a mess of if statements that gets excesively longer as you add new item combinations. Why is this thread such a noob magnet? I mean, it says "intermediate" right there in the title. Sorry, Erax0r, it's not just you, you're just the third person to post here with "better" triggers so I'm a bit annoyed. Actually, I should be thanking you guys instead for bumping my thread. :) |
| 04-15-2005, 09:27 PM | #11 |
You would have been able to cut back on the complexity of your trigger if you would have gone with a three arrays rather then two. array integer gRecipeItemNdx[50] array itemtype gRecipeItem[300] array itemtype gRecipeItem[50] Just a thought. I clearly understand why you would put all items togethor, which best represents a say a "struct" but you really gain nothing that is unless your recipe can return, say two items. But I can tell you are an education programmer, or have taken some programming classes. I have my own recipe script (Its in JASS) and I used the same indexing/item structures as you but, as recommened, I just put the new items into a second array. The offset location of index array matches one-to-one to the new item array. Secondly, I will leave this for you to add, is if you have say 30 recipes with an average of 3 items a piece, resulting in ~90 items and you pick up "A Rock", why do massive inventory comparison of the hero to recipes if "A Rock" is not even an ingreadent to ANY receipe? In theory, no item should enter the inventory that will not be checked against this trigger. You, the map developer, are the one with control over there inventory. You just need to be very "cautious" when programming to make sure that you have things aligned right. So just do a sequential scan of your item list to see if "A Rock" is part of that. If it is, then go into a more indepth comparison of THAT recipe and the heros items, otherwise, just keep scanning till you reach the end of your list and exit. That way, if you pick up say 100 Rocks in a game (items that are not in any inventory) the most you will waste is say is 9000 comparisons over the period of the game. Nothing great, but at least its not 648,000 (6*6*6*30*100) comparisons like another such recipe trigger I saw .. just to find out "Rocks" are not in recipes. 98.6% comparison reduction over 100 searches. Just a thought .... |
| 04-15-2005, 09:48 PM | #12 | |
I suppose I must have over-optimised the number of variables I use. I could just have 7 item-type arrays, or maybe 1, but with 7 spots reserved for each combination, so what if some minor part of memory is left empty because the array isn't fully filled with data... at least the core would be a lot simpler, the system more robust... I know. Maybe I wanted to do something more complex and challenging rather than just something usefull, and I overdid it. And it's not even that optimised, I still don't use gamecache although now that I'm exploring it it seems like so many things are possible with it... However, the system still does more than you give it credit for! :) A quote from my original post: Quote:
p.s.: I'm actually a self-taught programmer, as much as I am anyway, I played with q-basic when I was little and never got around to ever start programing for real. That's why I like warcraft moding, It's as close as I can get to making my own games without having to actually learn the syntax of a programming language... although the trigger editor took some time to getting used to as well, and I still don't use it to it's full potential, it was/is fun learning to work with it and I could do cool stuff with it from the very start. |
| 05-03-2005, 01:41 AM | #13 |
I'm a bit sad that you didn't mention my item system, I think it in a way kicked off this huge item creation system war By no means, however, am I saying it is anywhere near the most optimized. EDIT: And sorry if I'm mistaken, but I do believe it was you who I schooled on the use of arrays over mIRC one day, hehe. |
