"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: 124

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.
  • Ghan Ghan:
    Howdy
  • Ghan Ghan:
    Still lurking
    +3
  • The Helper The Helper:
    I am great and it is fantastic to see you my friend!
    +1
  • The Helper The Helper:
    If you are new to the site please check out the Recipe and Food Forum https://www.thehelper.net/forums/recipes-and-food.220/
  • Monovertex Monovertex:
    How come you're so into recipes lately? Never saw this much interest in this topic in the old days of TH.net
  • Monovertex Monovertex:
    Hmm, how do I change my signature?
  • tom_mai78101 tom_mai78101:
    Signatures can be edit in your account profile. As for the old stuffs, I'm thinking it's because Blizzard is now under Microsoft, and because of Microsoft Xbox going the way it is, it's dreadful.
  • The Helper The Helper:
    I am not big on the recipes I am just promoting them - I use the site as a practice place promoting stuff
    +2
  • Monovertex Monovertex:
    @tom_mai78101 I must be blind. If I go on my profile I don't see any area to edit the signature; If I go to account details (settings) I don't see any signature area either.
  • The Helper The Helper:
    You can get there if you click the bell icon (alerts) and choose preferences from the bottom, signature will be in the menu on the left there https://www.thehelper.net/account/preferences
  • The Helper The Helper:
    I think I need to split the Sci/Tech news forum into 2 one for Science and one for Tech but I am hating all the moving of posts I would have to do
  • The Helper The Helper:
    What is up Old Mountain Shadow?
  • The Helper The Helper:
    Happy Thursday!
    +1
  • Varine Varine:
    Crazy how much 3d printing has come in the last few years. Sad that it's not as easily modifiable though
  • Varine Varine:
    I bought an Ender 3 during the pandemic and tinkered with it all the time. Just bought a Sovol, not as easy. I'm trying to make it use a different nozzle because I have a fuck ton of Volcanos, and they use what is basically a modified volcano that is just a smidge longer, and almost every part on this thing needs to be redone to make it work
  • Varine Varine:
    Luckily I have a 3d printer for that, I guess. But it's ridiculous. The regular volcanos are 21mm, these Sovol versions are about 23.5mm
  • Varine Varine:
    So, 2.5mm longer. But the thing that measures the bed is about 1.5mm above the nozzle, so if I swap it with a volcano then I'm 1mm behind it. So cool, new bracket to swap that, but THEN the fan shroud to direct air at the part is ALSO going to be .5mm to low, and so I need to redo that, but by doing that it is a little bit off where it should be blowing and it's throwing it at the heating block instead of the part, and fuck man
  • Varine Varine:
    I didn't realize they designed this entire thing to NOT be modded. I would have just got a fucking Bambu if I knew that, the whole point was I could fuck with this. And no one else makes shit for Sovol so I have to go through them, and they have... interesting pricing models. So I have a new extruder altogether that I'm taking apart and going to just design a whole new one to use my nozzles. Dumb design.
  • Varine Varine:
    Can't just buy a new heatblock, you need to get a whole hotend - so block, heater cartridge, thermistor, heatbreak, and nozzle. And they put this fucking paste in there so I can't take the thermistor or cartridge out with any ease, that's 30 dollars. Or you can get the whole extrudor with the direct driver AND that heatblock for like 50, but you still can't get any of it to come apart
  • Varine Varine:
    Partsbuilt has individual parts I found but they're expensive. I think I can get bits swapped around and make this work with generic shit though
  • Ghan Ghan:
    Heard Houston got hit pretty bad by storms last night. Hope all is well with TH.
  • The Helper The Helper:
    Power back on finally - all is good here no damage
    +2
  • V-SNES V-SNES:
    Happy Friday!
    +1

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top