Tutorial Random Item Drops

HydraRancher

Truth begins in lies
Reaction score
197
Random
Items!
By HydraRancher​

v1.0c​



Contents

  1. Introduction
  2. What does it do?
  3. What’s it for?
  4. Triggers
  5. Pros and Cons
  6. Q & A
  7. 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)
        • 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
      • Set Item_Size[1] = 4


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)
        • 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
      • 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)
        • 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)
        • 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
      • 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)
        • 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)
        • 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)
        • 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)
        • 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
      • Set Item_Size[3] = 48


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 in this case NumberCheck+7) and add 1 to that +7, to make +8, do this to all other loops in that level segment, add the numbers you end up with, and multiple it by 2.

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)


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 :D

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.
 

Attachments

  • Item System.w3x
    20.7 KB · Views: 306

GoGo-Boy

You can change this now in User CP
Reaction score
40
Yes indeed. Everyone likes serious tutorials with a light sense of humor. You however exaggerate and that distracts your audience from the real point of learning s.th.

Apart from that I have no use for this tutorial since it is in GUI, however it may be useful, since this is s.th. that many new mapper want.
However adding your own percentages doesn't seem spectacular at all, you over emphasis it...
 

HydraRancher

Truth begins in lies
Reaction score
197
Yes indeed. Everyone likes serious tutorials with a light sense of humor. You however exaggerate and that distracts your audience from the real point of learning s.th.

Apart from that I have no use for this tutorial since it is in GUI, however it may be useful, since this is s.th. that many new mapper want.
However adding your own percentages doesn't seem spectacular at all, you over emphasis it...

I see, I made it more "Proffesional"
 

Mr.Tutorial

Hard in the Paint.
Reaction score
42
Seems more of a "Mini-tutorial" to me. When you make a Tutorial, make it a general subject, and not so specific unless you know your going to plant a lot of information. Also, make sure you get in depth with the information and triggers you provide to create a better understanding for those who read it. Grammar and spelling can cause an issue as well, make sure that's all cleaned up.

A lot of your definitions aren't defined to the core either, and make sure you know what your talking about.

Take that for future reference, unless you make some big improvements I doubt this will be approved. However, good effort, just make sure you look at other tutorials and better improve yours from theirs.
 

HydraRancher

Truth begins in lies
Reaction score
197
Seems more of a "Mini-tutorial" to me. When you make a Tutorial, make it a general subject, and not so specific unless you know your going to plant a lot of information. Also, make sure you get in depth with the information and triggers you provide to create a better understanding for those who read it. Grammar and spelling can cause an issue as well, make sure that's all cleaned up.

A lot of your definitions aren't defined to the core either, and make sure you know what your talking about.

Take that for future reference, unless you make some big improvements I doubt this will be approved. However, good effort, just make sure you look at other tutorials and better improve yours from theirs.

Do you think it would be better off as a "Snippet/System"?
 

Mr.Tutorial

Hard in the Paint.
Reaction score
42
It would definitely fit more into a snippet or system, because a tutorial is more like a step by step process that people can go through to better understand something.
 

HydraRancher

Truth begins in lies
Reaction score
197
Itempools. Use them. Seriously. Itempools even offer weights (something you are missing).

Itempool = ?






Well I guess I just made this for the people who need help making random items with easy editibility. Personally, I much prefer my Skillbook Tutorial.
 

Avaleirra

Is back. Probably.
Reaction score
128
It's a nice tutorial. I actually enjoyed how it was laidback instead of proffesional. Good work! :thup:
 

Mr.Tutorial

Hard in the Paint.
Reaction score
42
It's a nice tutorial. I actually enjoyed how it was laidback instead of proffesional. Good work! :thup:

The problem with a laidback tutorial is people who are new to the editor can't do something like this. If it takes them through step by step, they can actually progress along with the tutorial.

Anyways, the triggering looks nice in my eyes. It actually seems like a great system a lot of mappers would like to implement.
 

HydraRancher

Truth begins in lies
Reaction score
197
The problem with a laidback tutorial is people who are new to the editor can't do something like this. If it takes them through step by step, they can actually progress along with the tutorial.

Anyways, the triggering looks nice in my eyes. It actually seems like a great system a lot of mappers would like to implement.

Thanks for the criticism, but I prefer this "laidback" attitude, I might try to make it easier to learn however.
 

Deaod

Member
Reaction score
6
itempool is a native type in WC3. Though i guess blizzard forgot to implement it in GUI.
 

cryowraith

New Member
Reaction score
7
Weights are something like a priority number for that item/unit/thing. It would affect their chance to be in the result of the randomness.

Example:
Item 1 has weight 1
Item 2 has weight 2

Then Item 2 will have a higher chance to be chosen as the random item. To be more precise, Item 2 has 66.67% (2/3) chance while Item 1 has 33.33% (1/3). I think it works like that.

However I have not seen this in GUI yet. I've used it in JASS though. Besides itempool there is also a unitpool.
 

HydraRancher

Truth begins in lies
Reaction score
197
Weights are something like a priority number for that item/unit/thing. It would affect their chance to be in the result of the randomness.

Example:
Item 1 has weight 1
Item 2 has weight 2

Then Item 2 will have a higher chance to be chosen as the random item. To be more precise, Item 2 has 66.67% (2/3) chance while Item 1 has 33.33% (1/3). I think it works like that.

However I have not seen this in GUI yet. I've used it in JASS though. Besides itempool there is also a unitpool.

Actually, if you read the tutorial, I HAVE put this in, I called it "Percentages" (I believe that the mathematical term). It is only structured in a different form.
 

cryowraith

New Member
Reaction score
7
I didn't say you didn't have that functionality. You asked what is it. I answered. =/

Anyway the correct mathematical term is indeed "Weight". Because if you add a new item in the pool/array, the "percentage that it will be selected" will change. Say in the above example I posted, if I add a new item, their percentage will not be 66.67 and 33.33 anymore. If you'd like to know more perhaps you could wiki about it.

And unitpool/itempool is a lot more easier to implement, assuming you are using JASS/vJass. Below is a snippet of the implementation. But I think your system will be fine for those who cant code in JASS.

JASS:
        private unitpool SpawnUnits

        set SpawnUnits = CreateUnitPool()
        call UnitPoolAddUnitType(SpawnUnits, 'h000', 1) //Footman
        call UnitPoolAddUnitType(SpawnUnits, 'h001', 1) //Gyrocopter
        call UnitPoolAddUnitType(SpawnUnits, 'h002', 1) //Knight
        call UnitPoolAddUnitType(SpawnUnits, 'h003', 1) //Rifleman
        call UnitPoolAddUnitType(SpawnUnits, 'h004', 1) //Sorceress

        call PlaceRandomUnit(SpawnUnits, p, x, y, 0.00)
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top