| 10-24-2004, 07:00 PM | #1 |
Guest | I made this for my own map ages ago, but as I promised I would release codes from my map as I believe in open-source. My map is Tales of a Frozen Realm, or TOFU for short. It was being hosted at RTSgames.com (Same place as DoTa Allstars) but seeing they cannot get their act together I have asked to move it here. Some things I believe in: Do not post codes to the Repository if you do not know what you are doing >> Example. I do not like posting maps, only code. If you are too lazy to not write the code by hand you should not be map making. Keep my Quest acknowledgements. I do it for people when I use their codes, you should do it for me. I will never offer support - why? Because my codes will never need any. I do not like scripts which are too long, too complex, or contain too much stuff. Mine will always be simple, effective and of course original. ~~~~ Download below ~~~~ -------------------------------------------------------------- Script Name: Item Recipe Creation v1.1 Author: Sorrento (www.envyoflaziness.com) [email protected] Variables: 8 -- 1 Integer -- 7 Item-Type Arrays Scripts: 2 Complexity: Easy Usefulness: Extreme How Smart Am I?: Very :) -------------------------------------------------------------- Version Changes: 1.1 - Added Skip Remaining Actions -------------------------------------------------------------- Variables: ITM_MaxItemRecipes - Integer ITM_ItemSlot1 - Item-Type Array (Size as many items as you add) ITM_ItemSlot2 - Item-Type Array (Size as many items as you add) ITM_ItemSlot3 - Item-Type Array (Size as many items as you add) ITM_ItemSlot4 - Item-Type Array (Size as many items as you add) ITM_ItemSlot5 - Item-Type Array (Size as many items as you add) ITM_ItemSlot6 - Item-Type Array (Size as many items as you add) ITM_ReplacementItem - Item-Type Array (Size as many items as you add) -------------------------------------------------------------- Setting the Items! This is simple - see the stuff between the -------- -------- lines, just copy and paste that going down the page. Easy, Kapesh? Look I have done two for you: (THESE ARE EXAMPLES) Mask of Death and Power Treads (From DOTA) And no I did not steal this code from Dota. Code:
Set Item Recipes
Events
Time - Elapsed game time is 0.10 seconds
Conditions
Actions
Set ITM_MaxItemRecipes = 0
-------- --------
Set ITM_MaxItemRecipes = (ITM_MaxItemRecipes + 1)
Set ITM_ReplacementItem[ITM_MaxItemRecipes] = Mask of Death
Set ITM_ItemSlot1[ITM_MaxItemRecipes] = Crown of Kings +5
Set ITM_ItemSlot2[ITM_MaxItemRecipes] = Skeletal Artifact
-------- --------
-------- --------
Set ITM_MaxItemRecipes = (ITM_MaxItemRecipes + 1)
Set ITM_ReplacementItem[ITM_MaxItemRecipes] = Power Treads
Set ITM_ItemSlot1[ITM_MaxItemRecipes] = Boots of Speed
Set ITM_ItemSlot2[ITM_MaxItemRecipes] = Gloves of Haste
Set ITM_ItemSlot3[ITM_MaxItemRecipes] = Boots of Elvenskin
-------- --------
--//--
Quest - Create a Required quest titled Item Recipe Creation v1.0! with the description
Item Recipe Creation v1.0 Script created by Sorrento.
[email][email protected][/email]
Download it free at:
[url]www.envyoflaziness.com[/url]
using icon path ReplaceableTextures\CommandButtons\BTNPossession.blp
---//---
-------------------------------------------------------------- The Engine! This is the brain of the script - DO NOT EDIT THIS! Code:
Events
Unit - A unit Acquires an item
Conditions
((Triggering unit) is A Hero) Equal to True
Actions
For each (Integer A) from 1 to ITM_MaxItemRecipes, 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
(Item-type of (Item carried by (Triggering unit) of type ITM_ItemSlot1[(Integer A)])) Equal to ITM_ItemSlot1[(Integer A)]
(Item-type of (Item carried by (Triggering unit) of type ITM_ItemSlot2[(Integer A)])) Equal to ITM_ItemSlot2[(Integer A)]
(Item-type of (Item carried by (Triggering unit) of type ITM_ItemSlot3[(Integer A)])) Equal to ITM_ItemSlot3[(Integer A)]
(Item-type of (Item carried by (Triggering unit) of type ITM_ItemSlot4[(Integer A)])) Equal to ITM_ItemSlot4[(Integer A)]
(Item-type of (Item carried by (Triggering unit) of type ITM_ItemSlot5[(Integer A)])) Equal to ITM_ItemSlot5[(Integer A)]
(Item-type of (Item carried by (Triggering unit) of type ITM_ItemSlot6[(Integer A)])) Equal to ITM_ItemSlot6[(Integer A)]
Then - Actions
Special Effect - Create a special effect attached to the origin of (Triggering unit) using Abilities\Spells\Demon\DarkPortal\DarkPortalTarget.mdl
Item - Remove (Item carried by (Triggering unit) of type ITM_ItemSlot1[(Integer A)])
Item - Remove (Item carried by (Triggering unit) of type ITM_ItemSlot2[(Integer A)])
Item - Remove (Item carried by (Triggering unit) of type ITM_ItemSlot3[(Integer A)])
Item - Remove (Item carried by (Triggering unit) of type ITM_ItemSlot4[(Integer A)])
Item - Remove (Item carried by (Triggering unit) of type ITM_ItemSlot5[(Integer A)])
Item - Remove (Item carried by (Triggering unit) of type ITM_ItemSlot6[(Integer A)])
Hero - Create ITM_ReplacementItem[(Integer A)] and give it to (Triggering unit)
Game - Display to (Player group((Owner of (Triggering unit)))) the text: (|cff00FFFFGame Messege:|r Item Created: + (Name of (Last created item)))
Skip Remaining Actions
Else - Actions
Do nothing
-------------------------------------------------------------- DOWNLOAD IT HERE! |
| 10-24-2004, 07:19 PM | #2 |
Guest | Here ... Don't say I am not nice to you guys ... I added it to a map for you. DOWNLOAD IT HERE! |
| 10-24-2004, 09:48 PM | #3 |
hmm looks like you forgot an item array, ITM_ReplacementItem. cool sytem though. kind of wierd the way it's built though. in jass, a lot of nulls would be returned, and i dont like nulls.. but thats besides the point. In my big loop functions (like this one would be if ITM_MaxItemRecipes was big) i like to set a way to end the loop early once it does what its supposed to. so at the end of the then part, either put skip remaining actions or set Integer = ITM_MaxItemRecipes. |
| 10-25-2004, 01:10 AM | #4 |
Guest | Thanks mate for picking up that typo, I value your input and hurry up with your map ;) Good point about the skip remaining actions, it was 3am when I posted that and I was extremely tired. I also use to have code after it but since that is now gone I will update the map. As for Nulls, in the original way it was built it would check to see how many items there were and then did the appropriate referencing against the item database. However, I figured that seeing this way cuts the trigger size by 5/6ths, it was worth the sacrafice. Anyways, this was just like a gift to the community because I was bored ... :) That and I saw the other item recipe that was released and it sucked out the ass ... and I had this sitting here which I promised I would release to the community at rtsgames.com so yah. Enjoy. |
| 10-26-2004, 07:03 AM | #5 |
umm, this is just a thought, but you should also destroy the special effect to clear up memory and what-not. just a little note.. looks like a really good and efficient way to make an items and store them in a database. |
| 10-26-2004, 07:57 AM | #6 |
Guest | Well yah the special effect is just there to show people what can be done, it can easily be removed, as can the display messege, on a map by map basis :) I might actually remove the special effect all together ... But yah I am suprised there has been so little replies to this thread thus far, I would have thought alot of people would have wanted it ... especially since I have written it so simply and left it in GUI. |
| 10-26-2004, 08:03 AM | #7 |
well traffic varies i suppose... i like the system, it helped me realise a better form of databasing stuff (for my spell system)... i meant when destroying the effect is that, after you show the effect have a trigger afterwards going "special effect - destroy last created special effect" - as that creates memory leaks and will build up over time. - if u already know that, soz. but anyways great system, i might use it or base some systems off it.. either way, credit for u's |
| 10-27-2004, 01:41 AM | #8 |
Guest | Yah I know that but as there would have to be a slight delay before deletion I would have to throw in a local variable. I will get around to it today when I get time, it is only a two second job. :) |
| 10-27-2004, 03:00 PM | #9 | ||
Quote:
I'd say the same about you, the code is really unefficient, Quote:
That action actually iterates from 0 to 5 checking every single slot of the hero, you repeat it 6 times per item set, meaning you iterate the inventory 36 times per set. If you have like 10 sets it will browse the same slots 360 times |
| 10-27-2004, 03:57 PM | #10 | |
Quote:
I can't imagine how that will matter. As far as I can see loops don't really take noticeable effects in game until it reaches points of 3000 and more. for my save code I probably loop in total about 9,000 times in the trigger, 1000-1500 each loop (yes inefficient, but it can save up to 3k items/spells/heros), and it shows only a little lag from it (my computer is hardly top of the line and it gets over the lag spike in about half a second). The only problem I came across was when I set the loops to the maximum amount of possibilities for each variable, which was about 3,000 per loop to try to make the code universal (so people can CnP it into their maps). That caused an overload to the trigger and the entire trigger just crashed from the point of the loop, but it was easily fixed (I just set the loop to the amount of items/spells/heros I entered into the variable instead of the amx amount I could have). So as far as I can see as long as there isn't HUGE loops in the code it shouldn't matter (but if there is a problem that is probably why) Also remember even when using jass to do an if statement to end a loop, that still won't lower the loop any more then it would by putting the maximum value for the loop. All it does is makes the loop do the action until it meets the condition; it will still have to loop until it finds it, and if that happens to be the end of the loop it won't lessen it anymore (not to mention you can do exactly the same thing in the GUI by "skipping remaining actions" when it does find what it needs). In any case there is not much chance of getting past doing the loop-if statements. |
| 10-27-2004, 04:01 PM | #11 |
The difference between 360 calls, and 12 calls is big anyways , JASS isn't precompiled , so any extra call saved is worth it. |
| 10-27-2004, 05:59 PM | #12 |
Yes, but how can you possibly optimize this? I mean, every recepie needs to be checked against every item the hero caries, right? So with a 3 item recipie, you have to do 18 comparisons. Well, not really, you could optimize further and eliminate comparisons between items that no longer need to be checked once the right item is already found, but that still gives you 3 - 15 comparisons, and you have to run in addition to the item-type comparisons a bunch of other code that is in charge of "optimization". But you didn't mean to do all that, because event with such optimisation, you can't get 12 item-type comparisons per 10 item combinations. Perhaps you meant just the inquieries, which item the hero carries in which slot and not the actual comparisons (why, do such inquireies take a lot more time than other code?)? In such a case, it's simple, just store all the hero-carried item-types to a variable-array first, right? |
| 10-28-2004, 01:12 AM | #13 |
Guest | I did not spend $4000 on this computer only 4 months ago to worry about a couple of extra calls. The original way it was scripted is there was another variable called 'HowManyItems' - integer; whom the script then used to check how many items were needed in the script and then did the referencing ... This made the script 6 times as big, I do not like having complicated messy scripts in my maps, this script in my Tofu map, with an item database of 200, does not cause any problems at all. Not one tiny winy piece of lag. You can easily change it so it references it to an item-type array for each player but why would you do that? It is just going to add more variables for wc3 to check, if there was any lag ... which there is not ... it would be the same as the same amount of variables are getting checked time and time over again. By the way I have added the local variable to remove the special effect, I will upload that later today when I get the time. You are like a guy who spends 100,000$ on his car to make it go 1mph faster you know, I do not have the time to sit down all day and work my ass off on making my script working 1% more effiecient - the cons outweigh the pros. Anyways, its open-source, do what you want. I kept it in GUI so people could easily read it ... |
| 10-28-2004, 01:05 PM | #14 |
You started all of this by harrasing volatile with no reason. The big calls will happen every single time you pick up an item, which is plain wrong, and fixing this issue wouldn't need a bigger script, it can just use a shorter script, It seems I will have to release the system used in my arena afterall. |
| 10-28-2004, 01:45 PM | #15 |
Guest | So be it... |
