HydraRancher
Truth begins in lies
- Reaction score
- 197
Random
Items!
Items!
By HydraRancher
v1.0c
Contents
- Introduction
- What does it do?
- What’s it for?
- Triggers
- Pros and Cons
- Q & A
- Test map
1. Introduction
Welcome to my second tutorial, where I will teach you how to make...Random Items!
I have made this tutorial independently, using the power of 2D arrays, I learnt this myself and I am sharing this with TheHelper.net
2. What does it do?
This system can randomly drop one upon a unit’s death! You can also add your own percentages. Now let’s get started!
Triggers
Now this section is very long.
First, let’s start with the initialization trigger.
Trigger:
- Items Initialization
- Events
- Map initialization
- Conditions
- Actions
- -------- This is the last level's item size; this is here to make changing easier. --------
- Set MainItemSize = 48
- -------- Level 1 --------
- -------- Level 1 --------
- Do Multiple ActionsFor each (Integer A) from 1 to 1, do (Actions)
- Loop - Actions
- Set Item[((1 x MainItemSize) + (Integer A))] = Grenade
- Set ItemNumberCheck = ((Integer A) + 1)
- Loop - Actions
- Do Multiple ActionsFor each (Integer A) from ItemNumberCheck to (ItemNumberCheck + 0), do (Actions)
- Loop - Actions
- Set Item[((1 x MainItemSize) + (Integer A))] = Biting Kitty Level 1
- Loop - Actions
- Do Multiple ActionsFor each (Integer A) from 1 to 1, do (Actions)
- Set Item_Size[1] = 4
- Events
Now you're probably thinking, why do that? Well, I will explain it as clearly as possible.
MainItemSize This is for later, I will tell you what later.
For each integer A I can imagine you saying “lol” that’s stupid why do 1 to 1? Well, my answer is that it makes it easily customizable, as the loop will be larger later. Also, the larger the loop, the higher percentage the item will appear, keep note of that.
Set Item What this does is sets all the loop integers (in this case only 1) to a certain item. It may look a bit weird but that’s a 2D array for you!
Set Item Number Check This is so if you want to raise the percentages, you don’t have to change EVERY item.
Set Item (Second one) As you can see, it starts from Item Number Check this time, this is once again to make it easily customizable.
Rest of the trigger:
Trigger:
- Items Initialization
- Events
- Map initialization
- Conditions
- Actions
- -------- This is the last level's item size, this is here to make changing easier. --------
- Set MainItemSize = 48
- -------- Level 1 --------
- -------- Level 1 --------
- Do Multiple ActionsFor each (Integer A) from 1 to 1, do (Actions)
- Loop - Actions
- Set Item[((1 x MainItemSize) + (Integer A))] = Grenade
- Set ItemNumberCheck = ((Integer A) + 1)
- Loop - Actions
- Do Multiple ActionsFor each (Integer A) from ItemNumberCheck to (ItemNumberCheck + 0), do (Actions)
- Loop - Actions
- Set Item[((1 x MainItemSize) + (Integer A))] = Biting Kitty Level 1
- Loop - Actions
- Do Multiple ActionsFor each (Integer A) from 1 to 1, do (Actions)
- Set Item_Size[1] = 4
- -------- Level 2 --------
- -------- Level 2 --------
- Do Multiple ActionsFor each (Integer A) from 1 to 2, do (Actions)
- Loop - Actions
- Set Item[((2 x MainItemSize) + (Integer A))] = Grenade
- Set ItemNumberCheck = ((Integer A) + 1)
- Loop - Actions
- Do Multiple ActionsFor each (Integer A) from ItemNumberCheck to (ItemNumberCheck + 1), do (Actions)
- Loop - Actions
- Set Item[((2 x MainItemSize) + (Integer A))] = Biting Kitty Level 1
- Set ItemNumberCheck = ((Integer A) + 1)
- Loop - Actions
- Do Multiple ActionsFor each (Integer A) from ItemNumberCheck to (ItemNumberCheck + 0), do (Actions)
- Loop - Actions
- Set Item[((2 x MainItemSize) + (Integer A))] = Potion of Healing
- Loop - Actions
- Do Multiple ActionsFor each (Integer A) from 1 to 2, do (Actions)
- Set Item_Size[2] = 10
- -------- Level 3 --------
- -------- Level 3 --------
- Do Multiple ActionsFor each (Integer A) from 1 to 8, do (Actions)
- Loop - Actions
- Set Item[((3 x MainItemSize) + (Integer A))] = Grenade
- Set ItemNumberCheck = ((Integer A) + 1)
- Loop - Actions
- Do Multiple ActionsFor each (Integer A) from ItemNumberCheck to (ItemNumberCheck + 7), do (Actions)
- Loop - Actions
- Set Item[((3 x MainItemSize) + (Integer A))] = Biting Kitty Level 1
- Set ItemNumberCheck = ((Integer A) + 1)
- Loop - Actions
- Do Multiple ActionsFor each (Integer A) from ItemNumberCheck to (ItemNumberCheck + 3), do (Actions)
- Loop - Actions
- Set Item[((3 x MainItemSize) + (Integer A))] = Potion of Healing
- Set ItemNumberCheck = ((Integer A) + 1)
- Loop - Actions
- Do Multiple ActionsFor each (Integer A) from ItemNumberCheck to (ItemNumberCheck + 2), do (Actions)
- Loop - Actions
- Set Item[((3 x MainItemSize) + (Integer A))] = Potion of Mana
- Set ItemNumberCheck = ((Integer A) + 1)
- Loop - Actions
- Do Multiple ActionsFor each (Integer A) from ItemNumberCheck to (ItemNumberCheck + 0), do (Actions)
- Loop - Actions
- Set Item[((3 x MainItemSize) + (Integer A))] = Blood Rush Potion
- Loop - Actions
- Do Multiple ActionsFor each (Integer A) from 1 to 8, do (Actions)
- Set Item_Size[3] = 48
- Events
I'll explain the main ones
Item_Size[#] This is hard to work out. First you find the FIRST loop in each level segment in this case,
Trigger:
- -------- Level 3 --------
- -------- Level 3 --------
- Do Multiple ActionsFor each (Integer A) from 1 to 8, do (Actions)
- Loop - Actions
the number is 8 (the second number)
Find all the other loops
Trigger:
- Do Multiple ActionsFor each (Integer A) from ItemNumberCheck to (ItemNumberCheck + 7), do (Actions)
- Loop - Actions
So... ((First Loop Second Number) + (Number of other loops) + (Second number in each of those loops)) * 2
Main Item Size This is very helpful, without it, it would take AGES to add a new level. As you can see it is equivalent to Item_Size[Last].
Bonus Feature:
If you make an integer variable called "TwoDimensionalArraySetting" or something like that, you can set it to one upon initialization, and increase it by one every level, (so every time I split it up with ------Level #------------) and replace all your # X MainItemSize with that variable, it once again makes it alot more easily customizable, so you can copy the level section every time and for it to be fine to add new items.
And now for the next trigger.
Trigger:
- Item Drop
- Events
- Unit - A unit Dies
- Conditions
- ((Triggering unit) is A Hero) Not equal to (!=) True
- (Owner of (Triggering unit)) Equal to (==) Neutral Hostile
- Actions
- Set Temp_Point = (Position of (Triggering unit))
- Item - Create Item[(((Level of (Triggering unit)) x MainItemSize) + (Random integer number between 1 and Item_Size[(Level of (Triggering unit))]))] at Temp_Point
- Custom script: call RemoveLocation (udg_Temp_Point)
- Events
Unit - Dies You can work that out - A unit dies.
Boolean - Hero Just so heroes don’t drop items - removable of course.
Player Condition Change this player to whoever you want to drop the item.
Set Temp_Point/Custom Script: Leak Removal
Item - Create Item Ok, like my other Tut I'll break this down for you
Level x MainItemSize This is so you know which 2D array value to use.
Plus random number Picks a random number from that specific 2D array table.
That was nice and easy.
Anything you didnt understand? Well just say so.
5.Pros & Cons
Pros:
-GUI-Friendly for all you GUI-ers
-Adds a percentage
-Very easily customizable
Cons:
-Initialization is big
6.Q & A
Here is my Q&A
Q: Erm how do I add a percentage
A: Read the trigger section again thoroughly
A2: Increase the values of the loops
Q: Your tut's suck.
A: Got any special points?
Q: No I just hate you.
A: Ok...
Q: Does this leak?
A: No
Q: You sure?
A: Yes
Q: What is a 2D array?
A:Look it up.
Q: Where’s the Test Map
A: Coming up
Q: Help! I dont understand something!
A: Tell me what and I'll make it clearer in future
Q: Your Q&A's Suck!
A: I know.
Q: End this Q & A please!
A:
Changelog And Test Map
v1.0: Created
v1.0a: Added Bonus Feature into the Tutorial
v1.0b: Fixed Spelling, Made more proffesional etc.
v1.0c: Added more information
Test map below.
Please tell me all I can improve on this tutorial, thanks for listening.