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: 422
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...
 
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"
 
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.
 
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"?
 
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.
 
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.
 
It's a nice tutorial. I actually enjoyed how it was laidback instead of proffesional. Good work! :thup:
 
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.
 
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.
 
itempool is a native type in WC3. Though i guess blizzard forgot to implement it in GUI.
 
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.
 
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.
 
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.
  • Varine Varine:
    Or even third party. Like if you don't have an original one in a functional condition, you cannot play this game properly. Like yeah the keyboard mods exist, but I think those are BARELY functional
  • Varine Varine:
    And since almost all of my programming experience is with defunct shit now, I figure my best place is helping preserve legacy stuff. Which I don't know how to do necessarily, but I need some kind of a hobby and figuring out how older things worked is the only shit that really interests me. Well soldering and restoration is fun too, but no one is bringing me new stuff to fix and restore, so it's mostly old shit, and I LOVE OG Xbox so much. I want to make sure it can function as long as possible, until someone can effectively emulate it at least. I have like 15 I was going to fix over the winter and didn't get to.
    +1
  • Varine Varine:
    I also have a couple OG gameboys, but idk if I can do that without like, manufacturing new parts that no one makes anymore and I can't do that right now
  • tom_mai78101 tom_mai78101:
    Currently in the middle of getting the probate process going. We're doing the informal probate process.
    +3
  • Varine Varine:
    A probate is usually done with a will, yes? If so I am sorry for your loss
    +1
  • The Helper The Helper:
    Yeah Tom, me too sorry for your loss buddy my mom told me she finds out her olds friend died from Google searching them. She had not talked to one of her old friends in a year and found out she died from Google. Also another one in the same session. RIP all of them my sincere condolences Tom
    +1
  • Varine Varine:
    We have some elderly guests that regularly come hang out at the bar at the end of the night, and every once in a while we don't see someone for a few weeks and then someone shows up with their obituary.
  • Varine Varine:
    We usually let them do their memorials there in the morning if they want to and I'll make them some snacks and drinks. There was one guy named Tom that came in like every night and would sit by himself and get a bunch of soup and a glass of wine. idk why but he LOVED our fucking soup, like he would order a fucking quart of it at a time and would always get so sad when we stop doing it for the summer.
    +1
  • Varine Varine:
    But he also loved our calamari, which is another thing I hate but it sells super well so I can't change it. There was one day he came in and was asking me how to make it, because he tried to at home once in the off season when we stop running it and he really wanted it lol
  • Varine Varine:
    I think he's one of the only people I've made recipes for for free because he really wanted a broccoli cheddar, and it was like dude I don't have a recipe, it's just whatever I have, but here, this is how you do it
  • Varine Varine:
    I don't think he ever figured out how to do the calamari in a pan though, like idk how to do that either. He was afraid of the at home deep fryers though and it's like yeah, that's fair, I am too
  • Varine Varine:
    He was just such a sweet old man, we had two servers pregnant and they held a baby shower together, he was soooooo fucking excited to get to see a baby. Unfortunately he died a month or so before they were born
  • The Helper The Helper:
    So I decided to Google some people that I had not seen or heard from in a while and sure enough one of my old best friends, we had a falling out years ago but whatever, find out he died of Pancreatic Cancer in January. I have also lost a few of my closer acquaintances from growing up the last year. Getting old - people die - I kinda thought it was going to be this way a few years ago....
    +2
  • The Helper The Helper:
    Forum running super slow again
  • Ghan Ghan:
    Not really clear from the stats as to what is causing the slowness.
  • Ghan Ghan:
    We get a lot of guest traffic so it may just be the load is getting too high and not from any particular source.
  • Ghan Ghan:
    Looks like the server is maxed out on CPU.
  • Ghan Ghan:
    Oh it looks like a lot of the traffic is Silkroad Forums. That domain isn't protected by Cloudflare.
  • Ghan Ghan:
    But the old Silkroad site is still on its own server. I just had a test site set up on this server for it.
  • Ghan Ghan:
    I just disabled that test site. Let's see if that helps the load.
  • Ghan Ghan:
    Looks much better already.
  • The Helper The Helper:
    I had actually forgot about the Silkroad site. I had asked
  • The Helper The Helper:
    SD Ryoko about it and he said the couple of people left on there really like it, that was a few years ago, maybe I should check back
  • jonas jonas:
    I guess when you're getting old, and the last day of soup season draws near, you start wondering
  • jonas jonas:
    will I make it to the start of the next season? or was this the last time I'll ever have my favorite dish?

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials
      Top