[Trigger] Items with the same name don't stack

Status
Not open for further replies.
Level 6
Joined
Oct 5, 2012
Messages
86
I want to make a map, where no one could own a item twice (or the second one will have no effect). Is there a way to do this by triggers?
 
To prevent a unit from having the same item twice you hve to
  • Events
    • Unit - A unit acquires an item
  • Conditions
    • Unit has item of type(Item-Type of (Item Being Manipulated))
  • Actions
    • Hero - Drop (Item Being Manipulated)
To make it have no effect, you need a Hashtable, a disabled item for each item you have, and replace the enable with the disabled if the unit already owns one item of that type, and turn that disabled item again to enabled when it's dropped.
 
Better to just drop the same item rather than creating each copy of it (inefficient).
For the same item prevention, here is the code;
  • SSIPS Event
    • Events
      • Unit - A unit Acquires an item
    • Conditions
    • Actions
      • Set ItemCounter = 0
      • Set TempUnit = (Triggering unit)
      • Set TempItem = (Item being manipulated)
      • For each (Integer LoopingInteger) from 1 to 6, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Item-type of TempItem) Equal to (Item-type of (Item carried by TempUnit in slot LoopingInteger))
            • Then - Actions
              • Set ItemCounter = (ItemCounter + 1)
            • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • ItemCounter Greater than 1
        • Then - Actions
          • Hero - Drop TempItem from TempUnit
        • Else - Actions
Here is the test mapz.
 

Attachments

EDITED:

  • SSIPS Event
    • Events
      • Unit - A unit Acquires an item
    • Conditions
    • Actions
      • Set TempUnit = (Triggering unit)
      • Set TempItem = (Item being manipulated)
      • 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-type of TempItem) Equal to (Item-type of (Item carried by TempUnit in slot (Integer A))
              • TempItem Not Equal to (Item carried by TempUnit in slot (Integer A))
            • Then - Actions
              • Hero - Drop TempItem from TempUnit
            • Else - Actions
defskull is right, but this is just enough
 
Last edited:
Simple solution without a counter is to drop the item from the hero at the start of the trigger, and give it back to the hero later on when it is determined that they don't have it. Don't forget to turn off/turn on the trigger before/after giving the item back to prevent an infinite loop.

That won't work with drop order though,cuz
since the unit recieves the order the trigger continues and finishes before actually the unit drops the item:S
 
But there is a main problem with all of these triggers.
Are you sure it includes my trigger as well ?

Also,
If you repeatedly pick up two items, occasionally it ends with picking one up even if you already have 1 like it:P
What do you meant by "repeatedly pick up two items" ?
Do you mean to pick that item in a quick manner ?
You do know that all of that triggers are instant ?
No delay occurs, therefore it will run as single-thread as it intended, no bugs will occur such as having 1 item leak (event leak) because of "too fast event".
 
EDITED:

  • SSIPS Event
    • Events
      • Unit - A unit Acquires an item
    • Conditions
    • Actions
      • Set TempUnit = (Triggering unit)
      • Set TempItem = (Item being manipulated)
      • For each (Integer LoopingInteger) from 1 to 6, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Item-type of TempItem) Equal to (Item-type of (Item carried by TempUnit in slot (Integer A))
              • TempItem Not Equal to (Item carried by TempUnit in slot (Integer A))
            • Then - Actions
              • Hero - Drop TempItem from TempUnit
            • Else - Actions
defskull is right, but this is just enough

doesn't work
 
Status
Not open for further replies.
Back
Top