"If unit has this item then do this" question

OuTLawZ-GoSu

New Member
Reaction score
0
I'm making a trigger that does this,

There's 2 items, item 1 and item 2.

When a unit tries to pick up item1, the trigger will check to see if Item 2 is in the unit's inventory. If the unit has Item 2, then the unit can't pick up Item 1.

Is there a way to do this?
 

the_ideal

user title
Reaction score
61
Don't have WE open right now, buy something like this should work:

Event -
unit aquires item

Condition -
Boolean: triggering item = item type: item 2
- unit has item of type item 1 in inventory

Action -
order unit to drop item 2

If that doesn't work, just browse through the item-related events, conditions and actions and you're bound to find an easy solution.
 

Choppa

www.warcraft-gamers.po.gs
Reaction score
59
If hero has item type of itemA and item being manipualted equal to itemB then drop item being manipulated.

And make another but switch the itema and b around.
 

OuTLawZ-GoSu

New Member
Reaction score
0
I got this so far, but it's not workin.

Code:
Events
    Unit - A unit Acquires an item
Actions
    If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        If - Conditions
            (Item carried by (Triggering unit) of type Assult Riffle) Equal to (Item being manipulated)
        Then - Actions
            Hero - Drop (Item being manipulated) from (Triggering unit)
        Else - Actions

I also tried:
Code:
Actions
    If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        If - Conditions
            (Item carried by (Triggering unit) of type Assult Riffle) Equal to (Item carried by (Triggering unit) of type (Item-type of (Item being manipulated)))
        Then - Actions
            Hero - Drop (Item being manipulated) from (Triggering unit)
        Else - Actions

What am I doing wrong?
 

denmax

You can change this now in User CP.
Reaction score
155
Code:
Event
    Unit - A unit Acquires an Item
Conditions
    (Item type of (Item being manipulated)) Equal to Assault Rifle
Actions
    Hero - Drop (Item being manipulated) from (Hero manipulating item)

I dun' have my WE open so I'll edit this..
 

OuTLawZ-GoSu

New Member
Reaction score
0
Ok, I tried this. When the hero picks up the Assault Rifle item, it drops right away.

I still can't get this to compare the item in the unit's inventory to the item being picked up. Where's the trigger that checks the hero's inventory?
 

denmax

You can change this now in User CP.
Reaction score
155
Ok, I tried this. When the hero picks up the Assault Rifle item, it drops right away.

I still can't get this to compare the item in the unit's inventory to the item being picked up. Where's the trigger that checks the hero's inventory?

This

Add condition that Or (any conditions are true) and put this..
(Item carried by (Hero manipulating item) in slot [num]) Equal to (Item of type (ITEM 2)

Code:
Or (Any Conditions) are true
    (Item carried by (Hero manipulating item) in slot 1) Equal to (Item of type (ITEM 2)
    (Item carried by (Hero manipulating item) in slot 2) Equal to (Item of type (ITEM 2)
 ......
 
Reaction score
456
Or then simply loop through the whole inventory, making the progress much easier.

Code:
Trigger01
    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-type of (Item being manipulated)) Equal to <item1 type>
            Then - Actions
                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 (Item carried by (Triggering unit) in slot (Integer A))) Equal to <item2 type>
                            Then - Actions
                                Hero - Drop (Item being manipulated) from (Triggering unit)
                            Else - Actions
            Else - Actions
                If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    If - Conditions
                        (Item-type of (Item being manipulated)) Equal to <item2 type>
                    Then - Actions
                        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 (Item carried by (Triggering unit) in slot (Integer A))) Equal to <item1 type>
                                    Then - Actions
                                        Hero - Drop (Item being manipulated) from (Triggering unit)
                                    Else - Actions
                    Else - Actions
 
Reaction score
456
Never knew GUI had one.

Code:
Trigger01
    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-type of (Item being manipulated)) Equal to <item1 type>
            Then - Actions
                If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    If - Conditions
                        ((Triggering unit) has an item of type <item2 type>) Equal to True
                    Then - Actions
                        Hero - Drop (Item being manipulated) from (Triggering unit)
                    Else - Actions
            Else - Actions
                If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    If - Conditions
                        (Item-type of (Item being manipulated)) Equal to <item2 type>
                    Then - Actions
                        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                            If - Conditions
                                ((Triggering unit) has an item of type <item1 type>) Equal to True
                            Then - Actions
                                Hero - Drop (Item being manipulated) from (Triggering unit)
                            Else - Actions
                    Else - Actions
 

Choppa

www.warcraft-gamers.po.gs
Reaction score
59
Actually, on second though, you can do this...
Code:
Trigger01
    Events
        Unit - A unit Acquires an item
    Conditions
    Actions
        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            If - Conditions
                ((Triggering unit) has an item of type <item1 type>) Equal to True
                ((Triggering unit) has an item of type <item2 type>) Equal to True
            Then - Actions
                Hero - Drop (Item being manipulated) from (Triggering unit)
            Else - Actions

That should work, probably the shortest code possible, either that or i'm ub3r tired.
 
Reaction score
456
Still you have to check if the acquired item is item type1 or item type2. What if the unit picks restoriation potion?
 

OuTLawZ-GoSu

New Member
Reaction score
0
I cant find this, "((Triggering unit) has an item of type <item2 type>) Equal to True".

I looked at the item triggers and and unit triggers. Then closest thing I found was "(Item carried by (Triggering unit) of type Assult Riffle) Equal to (Item being manipulated)"


btw, I'm using the original world editor and I didn't add advanced triggers or anything.
 

Vestras

Retired
Reaction score
249
Actually, on second though, you can do this...
Code:
Trigger01
    Events
        Unit - A unit Acquires an item
    Conditions
    Actions
        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            If - Conditions
                ((Triggering unit) has an item of type <item1 type>) Equal to True
                ((Triggering unit) has an item of type <item2 type>) Equal to True
            Then - Actions
                Hero - Drop (Item being manipulated) from (Triggering unit)
            Else - Actions

That should work, probably the shortest code possible, either that or i'm ub3r tired.

That leaks.
If we say, that I got both item1 and item2, and I pick up item3, then it will drop item3. See?
 

AceHart

Your Friendly Neighborhood Admin
Reaction score
1,495
> I can't find this

It's hidden under Boolean, Hero - Hero has item of type.

Yes, it works on anything with an inventory, not just Heroes.
 

OuTLawZ-GoSu

New Member
Reaction score
0
Nice, it works. Thx alot.

I modified it for 4 weapons, Assult Riffle, Shotgun, Minigun, and Heavy Support Riffle.

Code:
Events
    Unit - A unit Acquires an item

Actions
    -------- assult rifle --------
    If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        If - Conditions
            ((Triggering unit) has an item of type Assult Riffle) Equal to True
            ((Triggering unit) has an item of type Shotgun) Equal to True
        Then - Actions
            Hero - Drop (Item being manipulated) from (Triggering unit)
        Else - Actions
    If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        If - Conditions
            ((Triggering unit) has an item of type Assult Riffle) Equal to True
            ((Triggering unit) has an item of type Minigun) Equal to True
        Then - Actions
            Hero - Drop (Item being manipulated) from (Triggering unit)
        Else - Actions
    If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        If - Conditions
            ((Triggering unit) has an item of type Assult Riffle) Equal to True
            ((Triggering unit) has an item of type Heavy Support Riffle) Equal to True
        Then - Actions
            Hero - Drop (Item being manipulated) from (Triggering unit)
        Else - Actions
    -------- heavy --------
    If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        If - Conditions
            ((Triggering unit) has an item of type Heavy Support Riffle) Equal to True
            ((Triggering unit) has an item of type Shotgun) Equal to True
        Then - Actions
            Hero - Drop (Item being manipulated) from (Triggering unit)
        Else - Actions
    If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        If - Conditions
            ((Triggering unit) has an item of type Heavy Support Riffle) Equal to True
            ((Triggering unit) has an item of type Minigun) Equal to True
        Then - Actions
            Hero - Drop (Item being manipulated) from (Triggering unit)
        Else - Actions
    -------- shotgun --------
    If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        If - Conditions
            ((Triggering unit) has an item of type Shotgun) Equal to True
            ((Triggering unit) has an item of type Minigun) Equal to True
        Then - Actions
            Hero - Drop (Item being manipulated) from (Triggering unit)
        Else - Actions


But now there's a new problem. I got 2 assult riffles in the map. I need to make it so a unit can't pickup both of them.

I tried this:
Code:
    If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        If - Conditions
            ((Triggering unit) has an item of type Assult Riffle) Equal to True
            ((Triggering unit) has an item of type Assult Riffle) Equal to True
        Then - Actions
            Hero - Drop (Item being manipulated) from (Triggering unit)
        Else - Actions

But right when the unit picks up the item, it drops. I cant figure out a way around this. Any ideas?
 

Choppa

www.warcraft-gamers.po.gs
Reaction score
59
That leaks.
If we say, that I got both item1 and item2, and I pick up item3, then it will drop item3. See?

No, you shouldn't even be able to have item2 in the first place, and that's not even what a leak is.

Here's my map, it has those systems and everything...
 

Attachments

  • Choppa IfHeroHasItemThenDrop.w3x
    13.5 KB · Views: 126

OuTLawZ-GoSu

New Member
Reaction score
0
Thx alot everyone. Works mad good now:

Code:
weapons pickup Trigger
    Events
        Unit - A unit Acquires an item
    Conditions
    Actions
        -------- assult rifle --------
        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            If - Conditions
                ((Triggering unit) has an item of type Assult Riffle) Equal to True
                ((Triggering unit) has an item of type Shotgun) Equal to True
            Then - Actions
                Hero - Drop (Item being manipulated) from (Triggering unit)
                Game - Display to (Player group((Triggering player))) the text: Can't pick up more ...
            Else - Actions
        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            If - Conditions
                ((Triggering unit) has an item of type Assult Riffle) Equal to True
                ((Triggering unit) has an item of type Minigun) Equal to True
            Then - Actions
                Hero - Drop (Item being manipulated) from (Triggering unit)
                Game - Display to (Player group((Triggering player))) the text: Can't pick up more ...
            Else - Actions
        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            If - Conditions
                ((Triggering unit) has an item of type Assult Riffle) Equal to True
                ((Triggering unit) has an item of type Heavy Support Riffle) Equal to True
            Then - Actions
                Hero - Drop (Item being manipulated) from (Triggering unit)
                Game - Display to (Player group((Triggering player))) the text: Can't pick up more ...
            Else - Actions
        -------- heavy --------
        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            If - Conditions
                ((Triggering unit) has an item of type Heavy Support Riffle) Equal to True
                ((Triggering unit) has an item of type Shotgun) Equal to True
            Then - Actions
                Hero - Drop (Item being manipulated) from (Triggering unit)
                Game - Display to (Player group((Triggering player))) the text: Can't pick up more ...
            Else - Actions
        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            If - Conditions
                ((Triggering unit) has an item of type Heavy Support Riffle) Equal to True
                ((Triggering unit) has an item of type Minigun) Equal to True
            Then - Actions
                Hero - Drop (Item being manipulated) from (Triggering unit)
                Game - Display to (Player group((Triggering player))) the text: Can't pick up more ...
            Else - Actions
        -------- shotgun --------
        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            If - Conditions
                ((Triggering unit) has an item of type Shotgun) Equal to True
                ((Triggering unit) has an item of type Minigun) Equal to True
            Then - Actions
                Hero - Drop (Item being manipulated) from (Triggering unit)
                Game - Display to (Player group((Triggering player))) the text: Can't pick up more ...
            Else - Actions


Same item pickup:

Code:
    Events
        Unit - A unit Acquires an item
    Conditions
    Actions
        Set numberOfItems = 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-type of (Item carried by (Hero manipulating item) in slot (Integer A))) Equal to (Item-type of (Item being manipulated))
                    Then - Actions
                        Set numberOfItems = (numberOfItems + 1)
                        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                            If - Conditions
                                numberOfItems Greater than or equal to 2
                            Then - Actions
                                Set numberOfItems = (numberOfItems + 1)
                                Hero - Drop (Item being manipulated) from (Hero manipulating item)
                                Game - Display to (Player group((Triggering player))) the text: Can't pick up two o...
                            Else - Actions
                    Else - Actions

Thx choppa, I used your Same Item Drop code in my map, hope you don't mind.
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top