- Joined
- Jan 17, 2010
- Messages
- 6,109
Item Drop System by -Kobas-Item Drop System
by -Kobas-
Requirements
* Basic knowledge of the Object Editor
* Basic knowledge of the Trigger Editor
* Poor knowledge in variables.
* A moment of your time(Around 5 min).
Introduction
Have you ever wondered what the Item Drop System (IDS) is? If your answer is ‘no’, then allow me to explain it for you:
If you’ve ever played a map such as Gaia's retaliation, you know that you are allowed to carry only 1 item of the same type (Weapon, Armor, etc.). Meaning, that if a player picks up an item of a type which was already in his inventory, it will be automatically dropped, and therefore player will be un-able to carry two items of this type simultaneously. It's simple as that!
How does my system works?
My system utilizes item levels in order to make item classes which you will use in your map. Therefore, the number of your item classes will greatly increase! How is that possible?
Let me explain: You can only have 7 item classes (by default in World Editor) whereas item levels can be indefinite!
And here’s an example:
Worse Way Better Way 1. Permanent = Weapon
2. Campaign = Armor
3. Power Up = Helm
4. Purchasable = Shield
5. Miscellaneous = Misc
6. Artifact = Artifact
7. Charged = Potion1. Level 1 = Weapon
2. Level 2 = Armor
3. Level 3 = Helm
10. Level 10 = Shield
25. Level 25 = Misc
10. Level 100 = Artifact
999. Level 999 = Material
You must be wondering: “That sounds great, but isn’t 8th a maximum item level?” Allow me to show you some magic:
1) Select any item (class and item level in this case doesn't matter)
2) Select the field that indicates the item level
3) Press Shift+Enter
4) Now enter any value you want to be the new maximum item level
Using that, you can also set many other options as well, such as: negative hit and mana point regeneration, influence of auras (to reduce or increase damage, attack or movement speed, armor…), ect. You’ll agree with me when I say that it’s a very useful thing!
And for the end I will show you how to stack some items
Let's start!
1. Okay, let’s start making our IDS now! I know, you will maybe be surprised as how to make an entire system and pack it into a single trigger, well it’s impossible! And here’s an example why:
A) Imagine we have a 100 item classes; that means that the trigger would have a 100 parts with each one containing at least 5 commands; that’s 500 commands (or 100 Microsoft Word pages if you want)! Therefore, it’s impossible to make the IDS, not to mention what happens with 1 000 or 1 000 000 item classes.
B) On the other hand, a system can be made with more ways than one: it can be sqeezed into a lot smaller and much more complicated code (I really don’t want to get into that), or it can be separated into several, simpler, triggers. Basically, it can be exactly like you need (want) it to be which is a plus because you can adjust it to your needs.
That’s why I’ll try my best to explain to you the essense of making a IDS trigger!
2. You can now open your map to test the new code we’re making.
3. Create a new trigger and, of course, choose a name for it.
4. Once you’ve done that, copy this code in it (in other words, make your trigger looking like this one here).
5. You noticed that this trigger uses item level 1. So let’s set the levels of all items on which the trigger will affect to a value of 1 (other levels are not important to us right now)
Item System
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 level of (Item being manipulated)) Equal to 1
Then - Actions
Set Item = 0
For each (Integer Item_Slot) from 1 to 6, do (Actions)
Loop - Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(Item level of (Item carried by (Hero manipulating item) in slot (Item_Slot))) Equal to 1
Then - Actions
Set Item = (Item + 1)
Else - Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
Item Greater than 1
Then - Actions
Hero - Drop (Item being manipulated) from (Hero manipulating item)
Game - Display to (All players) the text: You can carry only one level 1 item!
Else - Actions
Else - Actions
6. Save the map and go ahead and test it. You will notice that the trigger doesn’t allow you to carry two items of level 1! If that’s the case, then you succeeded in making an IDS! Congratulations!
Now you might be thinking:
1. “Hey, this is so easy! How come I didn’t think of it before?!” If you’re thinking like this, then you already know enough about IDS to make one yourself. And there are a few ways to do it from this tutorial:
A) Copy the trigger several times and only set your own item levels for your item classes (the easiest, but the most unprofessional way to do it).
B) Copy the actions inside the trigger and set item levels there (easier, but still an unprofessional way).
C) Copy the parts of the actions and the rest put under a same condition for all items you can carry in hero’s inventory once or two or even tree or four times... (the hardest, but the most professional way)
2. “Well I kind of understand what’s all this about, but how to make and set up a trigger by myself?” Well, I made the rest of the tutorial especially for you guys! So read carefully and I’m sure that with a little effort you will learn how the whole system works once you try to set up the trigger I attached on this tutorial.
1. Trigger Event
This option can be changed so that it affects a special unit(s) or all units that are controlled by Red (Blue,Teal...Dark Green) player.
Events
Unit - A unit Acquires an item
2. Trigger Condition
I usually don't use this option but you can add something here as well!
Conditions
Example: Add something like this so it only affects Undead units!
3. Making The Main Part of The Trigger
Conditions
((Hero manipulating item) is Undead) Equal to True
This is the main part of the trigger were you can change values of item Levels which you use like item Classes
Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(Item level of (Item being manipulated)) Equal to 1
Then - Actions
Set Item = 0
You can change 1 into (0,1...n)
Also we are now seeing the first variable in our trigger: Item
You can press Ctrl+B to open a Variable window and then create one simple integer variable (You can name it 'Item' (I use that name here) or anything else you want)
Note: Will we meet another variable soon!
4. Item Counter
This part of the trigger is used to count the number of items that hero carries (in our case it will count all level 1 items)
For each (Integer Item_Slot) from 1 to 6, do (Actions)
Loop - Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(Item level of (Item carried by (Hero manipulating item) in slot (Item_Slot))) Equal to 1
Then - Actions
Set Item = (Item + 1)
Else - Actions
We can now see another variable: Item_Slot (create it like the first one (Item Integer))
I don't have the time to explain why I use that custom variable instead of just the well known one Integer A, but I will only say that: Integer A (I'm going to ignore Integer B since it is the same as Integer A and both function alike) is a predefined global variable. Thus, the information it might carry while looping could be changed due to any interception by other triggers which also contain Integer A. What happens then - once the looping of the original trigger resumes - is that the value of Integer A is different leading to faulty looping - i.e. bug! (We don't want that now do we)
5. Item drop + Text message (or not)
Finally we've come to the last part of the trigger!
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
Item Greater than 1
Then - Actions
Hero - Drop (Item being manipulated) from (Hero manipulating item)
Game - Display to (All players) the text: You can carry only one weapon!
Else - Actions
Else - Actions
Item Greater than 1 condition defines how many items per class will your hero carry!
Example: You can change it to 2 for Misc items
Hero - Drop (Item being manipulated) from (Hero manipulating item)
This Action will drop the item when a hero tries to pick it up. (Ground below Hero)
You can also add triggers that can:
Instantly move an item to any location that you want
Destroy Item (Why that?)
Create another item (You have crazy map who knows)
Game - Display to (All players) the text: You can carry only one weapon!
In this case, a text message will be shown to all players who tried to carry two weapon items.
Can be changed to show:
Any message to your allies
Any message to you
Any message in format of Floating Text
Any message in Format of Quest Message (Hint, Warning, Quest Update,...)
Also, you can even delete it if you don't want anything to be written on the screen!
This is simple and easy to understand I think
6. Example
This is only one of the many examples of how your trigger can look. This one is used in one silly map!
This trigger affect only 1 Player is not MUI!
(MUI what is that? For example: Multi Unit Instanceable (MUI) spell is a spell which would function normally if it's cast while another instance of the same spell is running.)
This trigger affect only melee units!
This tutorial works with items level 1,2 and 3
It is only example! Main trigger is above!
Are you creating RPG map and you want to stack some more items into single one increasing it's charges!
Item System
Events
Unit - A unit owned by Player 5 (Yellow) Acquires an item
Conditions
((Hero manipulating item) is A melee attacker) Equal to True
Actions
Set Item = 0
-------- Setting value of Item from random to 0 --------
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(Item level of (Item being manipulated)) Equal to 1
Then - Actions
For each (Integer Item_Slot) from 1 to 6, do (Actions)
Loop - Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(Item level of (Item carried by (Hero manipulating item) in slot Item_Slot)) Equal to 1
Then - Actions
Set Item = (Item + 1)
-------- It will increase to 1 if hero have 1 item level 1, to 2 if hero have 2 items level 1... --------
Else - Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
Item Greater than 1
Then - Actions
Hero - Drop (Item being manipulated) from (Hero manipulating item)
Set LeakDestroy = Center of (Position of Circle of Power 0014 <gen>)
Item - Move (Last dropped item) to (LeakDestroy)
Custom script: call RemoveLocation(udg_LeakDestroy)
-------- You can see one new action: It will instantly move item to Circle of Power 0014! --------
-------- You can also see that I created another variable LeakDestroy (Variable Type: Point). Trigger can work without it but we need it because we want to destroy memory leak! --------
-------- What is memory leak, again I don't have time to explain what memory leak is because this tutorial want to teach you different thing --------
-------- But I can tell you that we clean (destroy) memory leaks only for one reason, we reduce lag, if you want to learn more, find tutorials about memory leaks on this site --------
Game - Display to (All enemies of (Owner of (Hero manipulating item))) for 10.00 seconds the text: Wanted to carry 2 F...
-------- It show enemy players for 10 seconds that Player who pick item wanted to carry 2 Flags at same time! --------
Else - Actions
Else - Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(Item level of (Item being manipulated)) Equal to 2
Then - Actions
For each (Integer Item_Slot) from 1 to 6, do (Actions)
Loop - Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(Item level of (Item carried by (Hero manipulating item) in slot Item_Slot)) Equal to 2
Then - Actions
Set Item = (Item + 1)
Else - Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
Item Greater than 3
Then - Actions
Hero - Drop (Item being manipulated) from (Hero manipulating item)
Game - Display to (Player group((Owner of (Hero manipulating item)))) for 10.00 seconds the text: Hero can carry only...
-------- It show to player for 10 seconds that he can't pick more than 3 potion items! --------
Else - Actions
Else - Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(Item level of (Item being manipulated)) Equal to 3
Then - Actions
For each (Integer Item_Slot) from 1 to 6, do (Actions)
Loop - Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(Item level of (Item carried by (Hero manipulating item) in slot Item_Slot)) Equal to 3
Then - Actions
Set Item = (Item + 1)
Else - Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
Item Greater than 3
Then - Actions
Hero - Drop (Item being manipulated) from (Hero manipulating item)
Game - Display to (Player group((Owner of (Hero manipulating item)))) for 10.00 seconds the text: Hero can carry only...
-------- It show to player for 10 seconds that he can't pick more than 3 potion items! --------
Else - Actions
Else - Actions
-------- Trigger can go to oo --------
Check this trigger example then:
Author's notes:
Events
Unit - A unit Acquires an item
Conditions
Or - Any (Conditions) are true
Conditions
(Item-type of (Item being manipulated)) Equal to Greater Potion of Healing
(Item-type of (Item being manipulated)) Equal to Greater Potion of Mana
(Item-type of (Item being manipulated)) Equal to Lesser Potion of Healing
(Item-type of (Item being manipulated)) Equal to Lesser Potion of Mana
(Item-type of (Item being manipulated)) Equal to Potion of Healing
(Item-type of (Item being manipulated)) Equal to Potion of Mana
Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
((Hero manipulating item) has an item of type (Item-type of (Item being manipulated))) Equal to True
(Item being manipulated) Not equal to (Item carried by (Hero manipulating item) of type (Item-type of (Item being manipulated)))
Then - Actions
Item - Set charges remaining in (Item carried by (Hero manipulating item) of type (Item-type of (Item being manipulated))) to ((Charges remaining in (Item carried by (Hero manipulating item) of type (Item-type of (Item being manipulated)))) + (Charges remaining in (Item being manipulated)))
Hero - Drop (Item being manipulated) from (Hero manipulating item)
Item - Remove (Last dropped item)
Else - Actions
This IDS is not perfect! You can find a lot better systems than mine (as well as a lot of worse ones! And I do mean A LOT!!!)
If this tutorial helped you to understand how the IDS works (or at least gave you a glimpse of it), then my job here is done!
If you want to learn more about Memory Leaks or Integer A check this tutorial
THIS MESSAGE HAS BEEN SPOOFED FOR GRAMMAR AND ETHICAL ERRORS BY: The_Mirai
Attachments
Last edited: