• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

Item-drop-system

Level 9
Joined
Aug 21, 2008
Messages
533
Only 1 item of every type- the item-drop system

only 1 item of every type- the Item-drop-system

I know there is already a tutorial about this somewhere but if you follow it correctly you would need for every item class as many triggers as players are aviable. So 5 itemclasses*8players=40Triggers.
I was able do that in one trigger.(without jass and only 1 variable):grin:


What is a item-drop-system?

If you ever have played one of the (o)rpg's you know that you are only allowed to carry only 1 item per type. So if you have 2 weapons 1 will be dropped and a message apears.In my system you are able to have 6 items classes.

How to start?


First of all you have to decide which item classes you will need.Lets say: weapon,offhand,armor,helmet,boots.
There are some standard item classes(called permanent ,campaign etc...). Now you just have to give them new names(note: only in your head they still have their names). So all weapons are artifacts, all armors are campaign etc... . Now give all your items their item class.
In this case every time you create a weapon you have to give it the class artifact.
Then you have to make a integer variable named item_integer.
(Thanks septimus for this)

The trigger

  • test all in one Copy
    • Events
      • Unit - A unit Acquires an item
    • Conditions
      • Or - Any (Conditions) are true
        • Conditions
          • (Item-class of (Item being manipulated)) Equal to Permanent
          • (Item-class of (Item being manipulated)) Equal to Artifact
          • (Item-class of (Item being manipulated)) Equal to Charged
          • (Item-class of (Item being manipulated)) Equal to Campaign
    • Actions
      • Set iteminteger = 0
      • For each (Integer A) from 1 to 6, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Item-class of (Item carried by (Hero manipulating item) in slot (Integer A))) Equal to (Item-class of (Item being manipulated))
            • Then - Actions
              • Set iteminteger = (iteminteger + 1)
            • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • iteminteger Greater than 1
        • Then - Actions
          • Hero - Drop (Item being manipulated) from (Hero manipulating item)
          • Game - Display to (Owner of (Triggering unit)), at offset (0.00, 0.00) the text: |cffCE2919You cant ...
        • Else - Actions
What have we done? First off all we made a event and some conditions. This will make the trigger fire every time a hero acquieres a item which have one of the classes in the conditions. If you don't understand this please go to a easier tutorial.


The next step is to set our integer to 0. Wy? Cause we change it in the trigger, but need it as 0 again when the trigger fires again.

  • Set iteminteger = 0
Now lets start the important step.Now we make a loop which cheks the inventory for items with the same class as the acquired item. everytime it found a item our integer is growing bigger. So at least 1 time cause of the item itself.
  • For each (Integer A) from 1 to 6, do (Actions)
    • Loop - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Item-class of (Item carried by (Hero manipulating item) in slot (Integer A))) Equal to (Item-class of (Item being manipulated))
        • Then - Actions
          • Set iteminteger = (iteminteger + 1)
        • Else - Actions
After this our integer could be only 1 or 2.
Now ,depending on the integer, we do nothing(integer=1) or we make the acquired item drop(integer=2).

  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
    • If - Conditions
      • iteminteger Greater than 1
    • Then - Actions
      • Hero - Drop (Item being manipulated) from (Hero manipulating item)
      • Game - Display to (Owner of (Triggering unit)), at offset (0.00, 0.00) the text: |cffCE2919You cant ...
    • Else - Actions
Don't forget a nice message like: You cant carry 2 items of the same class.

Hope everything is clear.
 
Last edited:
Level 31
Joined
May 3, 2008
Messages
3,155
I would give 3 reason of why this tutorial would likely to be rejected.

1) Lot's of spelling/grammar error.
2) There is a existense of such a tutorial.
3) The trigger wasn't at optimize and most efficient way.

Making it this way is much efficient and smooth.

  • Melee Initialization
    • 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-class of (Item being manipulated)) Equal to Permanent
        • Then - Actions
          • Set Item_Integer = 0
          • For each (Integer Slot_Integer) from 1 to 6, do (Actions)
            • Loop - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Item-class of (Item carried by (Hero manipulating item) in slot Slot_Integer)) Equal to Permanent
                • Then - Actions
                  • Set Item_Integer = (Item_Integer + 1)
                • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • Item_Integer Greater than 1
            • Then - Actions
              • Hero - Drop (Item being manipulated) from (Hero manipulating item)
            • Else - Actions
        • Else - Actions
 
Level 9
Joined
Aug 21, 2008
Messages
533
@septimus

1) ok i try to make this better today.
2) I said this at the beginning of my tutorial.(i only found TaaZ's one)
3) nice trigger but in that case i would have to copy it and change it for evry class. But i m going to test your idea with the integer instead of the bolean which should make the trigger even shorter and smoother. Ty for your ggod reply.
You forgot the message :wink:

Little question to you; is the Slot_item integer more efficent as the A integer at the loop?
 
Last edited:
Level 31
Joined
May 3, 2008
Messages
3,155
Little question to you; is the Slot_item integer more efficent as the A integer at the loop?

They are both the same. However, it was always recommend to make variable integer for it.

It was quite difficult to be explain, to make it simple. I would just said "You cannot have your cake and eat it at the same time"

Ask Dr Super Good about it, he can elaborate about this matter better than I do.
 
Level 9
Joined
May 10, 2009
Messages
542
A mistake? This is almost the same style of inventory I was gonna use for my canceled ORPG - and I made lots of mistakes.

Try this (note, not sure if it will work...): In lose item trigger, turn off acquire item trigger, then turn on acquire trigger to prevent getting 2 of a kind able to be picked up. And, In acquire item trigger, turn off lose item trigger then turn on lose item trigger.
 
Level 13
Joined
Mar 4, 2009
Messages
1,156
im not sure is this a write palace to post but.....

is it possible to drop item being manipulated if he already has one of that (item being manipulated in his inventory?

so you stop heroes from having 2 same item type in inventory
 
Level 13
Joined
Mar 4, 2009
Messages
1,156
Thats exactly what the tutorial tries to teach you :con:

sry,i didn´t read it at all xD

i did my trigger on this way i think its good

  • HERO ACQUIRES AN ITEM
    • Events
      • Unit - A unit Acquires an item
    • Conditions
    • Actions
      • Hero - Drop (Item being manipulated) from (Hero manipulating item)
      • 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 (Last dropped item))) Not equal to True
        • Then - Actions
          • Set HERO = (Hero manipulating item)
          • Trigger - Run GIVE ITEM <gen> (checking conditions)
        • Else - Actions
          • Set PLAYER_G = (Player group((Owner of (Hero manipulating item))))
          • Game - Display to PLAYER_G the text: You cannot have 2 items of same type!
          • Custom script: call DestroyForce(udg_PLAYER_G)
  • GIVE ITEM
    • Events
    • Conditions
    • Actions
      • Trigger - Turn off HERO ACQUIRES <gen>
      • Hero - Give (Last dropped item) to HERO
      • Trigger - Turn on HERO ACQUIRES <gen>
 
Level 9
Joined
Aug 21, 2008
Messages
533
i would add a contidion to avoid droping consumables.
and there shouldn't be a problem writing all in one trigger instead of using the run trigger function-there is no problem turning off the whole trigger .
In this case you also dont have use variables.
(players dont leak so you dont have to save him in a player group)

ermm and your trigger only drops if its exactly the same item if you want to drop for example a item of the same class lets say weapon you have to use my trigger at the begiining but maybe thats noz what you want.
 
Level 13
Joined
Mar 4, 2009
Messages
1,156
i tried doing it all in one trigger but it cant work,all i get is fast crashing of warcraft
its because without turn off,on action trigger is runing 10000 times second

(condition- (hero manipulating) an item has an item of type (last dropped item) didnt work too)
 
Level 9
Joined
Aug 21, 2008
Messages
533
i write it wait shortly...
edit:
  • Untitled Trigger 005
    • Events
      • Unit - A unit Acquires an item
    • Conditions
      • -------- whatever you want... --------
    • Actions
    • Hero - Drop (Item being manipulated) from (Triggering unit)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • ((Triggering unit) has an item of type (Item-type of (Last dropped item))) Equal to True
        • Then - Actions
          • -------- message and that it was.... --------
        • Else - Actions
          • Trigger - Turn off (This trigger)
          • Hero - Give (Last dropped item) to (Triggering unit)
          • Trigger - Turn on (This trigger)
Thsis hould work-outherwise try out my trigger in the tutrial but use item type instaed of item class
 
Level 13
Joined
Mar 4, 2009
Messages
1,156
i write it wait shortly...
edit:
  • Untitled Trigger 005
    • Events
      • Unit - A unit Acquires an item
    • Conditions
      • -------- whatever you want... --------
    • Actions
    • Hero - Drop (Item being manipulated) from (Triggering unit)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • ((Triggering unit) has an item of type (Item-type of (Last dropped item))) Equal to True
        • Then - Actions
          • -------- message and that it was.... --------
        • Else - Actions
          • Trigger - Turn off (This trigger)
          • Hero - Give (Last dropped item) to (Triggering unit)
          • Trigger - Turn on (This trigger)
Thsis hould work-outherwise try out my trigger in the tutrial but use item type instaed of item class

warcraft crash.....

BTW are you sure player groups don´t leak?,lot of people said that they do
i also don´t believe sound can leak -.-
 
Level 19
Joined
Aug 8, 2007
Messages
2,765
The whole system ur basing that off of is crashy and glitchy. I tried that once. i picked up a campaign item and got 5 errors. Try using item HP ;) that allows for more consistant values and a smoother runtume.
 
Level 19
Joined
Aug 8, 2007
Messages
2,765
No actually, mine was identical to yours. Yours leaks soooooo much tho and its soooo inefficient. A person with no gui experiance can make that.
 
Level 9
Joined
Aug 21, 2008
Messages
533
There is no leak which you could remove with gui. Sry gui is inefficent and i did this when i was inexpeinced with gui. And still it should work, i used this quite along time. Curently im using a much better system, but it is jass and everyone who knows jass could do the system for himself.

lol you said i should use item HP. Its liek you say to an bill gates that he should sell Computers:razz: seriously, look at the data. i wrote this last year when i start mapping.

And now stop flaming with no reason. This never should get approved and i am the author, do this something say to you?:con:
 
Top