"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?
 
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.
 
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.
 
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?
 
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..
 
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?
 
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)
 ......
 
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
 
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
 
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.
 
Still you have to check if the acquired item is item type1 or item type2. What if the unit picks restoriation potion?
 
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.
 
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?
 
> 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.
 
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?
 
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
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.
  • V-SNES V-SNES:
    Happy Friday!
    +1
  • The Helper The Helper:
    News portal has been retired. Main page of site goes to Headline News forum now
  • The Helper The Helper:
    I am working on getting access to the old news portal under a different URL for those that would rather use that for news before we get a different news view.
  • Ghan Ghan:
    Easily done
    +1
  • The Helper The Helper:
    https://www.thehelper.net/pages/news/ is a link to the old news portal - i will integrate it into the interface somewhere when i figure it out
  • Ghan Ghan:
    Need to try something
  • Ghan Ghan:
    Hopefully this won't cause problems.
  • Ghan Ghan:
    Hmm
  • Ghan Ghan:
    I have converted the Headline News forum to an Article type forum. It will now show the top 20 threads with more detail of each thread.
  • Ghan Ghan:
    See how we like that.
  • The Helper The Helper:
    I do not see a way to go past the 1st page of posts on the forum though
  • The Helper The Helper:
    It is OK though for the main page to open up on the forum in the view it was before. As long as the portal has its own URL so it can be viewed that way I do want to try it as a regular forum view for a while
  • Ghan Ghan:
    Yeah I'm not sure what the deal is with the pagination.
  • Ghan Ghan:
    It SHOULD be there so I think it might just be an artifact of having an older style.
  • Ghan Ghan:
    I switched it to a "Standard" article forum. This will show the thread list like normal, but the threads themselves will have the first post set up above the rest of the "comments"
  • The Helper The Helper:
    I don't really get that article forum but I think it is because I have never really seen it used on a multi post thread
  • Ghan Ghan:
    RpNation makes more use of it right now as an example: https://www.rpnation.com/news/
  • The Helper The Helper:
  • The Helper The Helper:
    What do you think Tom?
  • tom_mai78101 tom_mai78101:
    I will have to get used to this.
  • tom_mai78101 tom_mai78101:
    The latest news feed looks good

      The Helper Discord

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top