Restricting all heros to only one of the same of any item type

dashival

New Member
Reaction score
11
Is there a really simple trigger or something I can use to keep all heros from having two of the same of an item-type? Like, the heros can hold one Potato Chip, and one Chocolate Milk, but not two potato chips nor two chocolate milks, nor two broomsticks or two cows or two of any item.
I have a trigger that runs when an item is aquired, and if the total number of items of that type in the inventory exceeds 1, it drops the item back down. However, players can trick this by picking up the item really fast, and it somehow stays in the inventory.

Edit: And, I don't want to do the 'item classification' thing, I just want only one item of each item-type allowed.
 
M

Mythic Fr0st

Guest
Mmm

Dont know if this would work not, but perhaps its possible to every 2 seconds or so, check if a Hero has 2 of the same item, and if he has, drop one?
Perhaps even do a trigger that, when a unit acquires item, you set a integer = 1, and when he picks up the same item, set it to 2, and if integer = 2, drop 1 item... and set integer back to 1 lol, dunno if that would work or not:p
 

Duwenbasden

Ver 6 CREATE energy AS SELECT * FROM u.energy
Reaction score
165
put in "hero use item/aquires item/drop item" to it, and check their item box on every single order they give to the hero.
 

dashival

New Member
Reaction score
11
Fr0zen, I think there would be an easier way than that, and Duwen, I don't understand what you mean. =s

I don't want the heros to be able to move the items at all from where they are. Meaning, I need the hero to drop the item back where it was as soon as he picks it up. I can't check every few seconds and make him drop the items, because then if he moved, the item would move.

I also tried, Hero Aquires Item as event, (or any conditions) if item-type of picked-up item = item-type type of item in slot 1, slot 2, etc for conditions, and 'order hero to drop picked up item' as action, but then the hero drops the item even if he only picks up one.

Edit: This is the trigger I'm using. It works, but it can be tricked by ordering another order right as you pick up the item, such as moving or stopping.

Code:
Only One
    Events
        Unit - A unit Acquires an item
    Conditions
    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 being manipulated)) Equal to (Item-type of (Item carried by (Hero manipulating item) in slot (Integer A)))
                    Then - Actions
                        Item - Set the custom value of (Item being manipulated) to ((Custom value of (Item being manipulated)) + 1)
                    Else - Actions
        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            If - Conditions
                (Custom value of (Item being manipulated)) Greater than 1
            Then - Actions
                Set L = (Position of (Item being manipulated))
                Unit - Order (Hero manipulating item) to drop (Item being manipulated) at L
                Custom script:   call RemoveLocation(udg_L)
                Game - Display to (Player group((Owner of (Hero manipulating item)))) the text: (You can't have two of that item)
            Else - Actions
 

Effane

Save/Load Code Tutorial
Reaction score
51
You can assign more than one event to a trigger, and only one event has to be true for the trigger to activate. So you can make it have Acquires Item and Uses Item as the trigger and then check the status from there. Too bad you cant have a ItemGroup like Unit and Player Groups, that would make it much easier.
 
W

Wyvernoid

Guest
dashival said:
Code:
        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 being manipulated)) Equal to (Item-type of (Item carried by (Hero manipulating item) in slot (Integer A)))
                    Then - Actions
                        Item - Set the custom value of (Item being manipulated) to ((Custom value of (Item being manipulated)) + 1)
                    Else - Actions
To check this, you needn't do that at all. Just check if "Hero has (Item-type of (Item being Manipulated)) Equal to True". Making it faster, and he may not trick this time ^^
 

dashival

New Member
Reaction score
11
Wyvernoid said:
To check this, you needn't do that at all. Just check if "Hero has (Item-type of (Item being Manipulated)) Equal to True". Making it faster, and he may not trick this time ^^
I was unaware of that condition, thanks, I'll try it. :)

Edit: Wait, that would not work. If I checked for if the hero has the item, it would be true because this trigger runs after the hero picks up the item. I need a function like an integer comparison, to compare the number of items the hero has of that item-type.
 
W

Wazat

Guest
OYE it's late! But, I got it working for ya.

Code:
Test item enforcement
    Events
        Unit - A unit Acquires an item
        Unit - A unit Is issued an order targeting an object
    Conditions
    Actions
        For each (Integer A) from 1 to 6, do (Actions)
            Loop - Actions
                For each (Integer B) from (Integer A) to 6, do (Actions)
                    Loop - Actions
                        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                            If - Conditions
                                (Integer A) Not equal to (Integer B)
                                (Item carried by (Triggering unit) in slot (Integer A)) Not equal to No item
                                (Item carried by (Triggering unit) in slot (Integer B)) Not equal to No item
                                (Item-type of (Item carried by (Triggering unit) in slot (Integer A))) Equal to (Item-type of (Item carried by (Triggering unit) in slot (Integer B)))
                            Then - Actions
                                Game - Display to (Player group((Owner of (Triggering unit)))) the text: You can only have o...
                                Unit - Order (Triggering unit) to drop (Item carried by (Triggering unit) in slot (Integer B)) at (Position of (Triggering unit))
                                Skip remaining actions
                            Else - Actions

I discovered I could NOT use "Hero - Drop the item from slot (Integer B) of (Triggering unit)" because the game would crash violently. I don't know why. However, by adding "Unit - A unit Is issued an order targeting an object" to the events, this trigger manages to do the same thing. The player can't break the rule (so far as I can see) by simply clicking like crazy, because each click reenforces the rule.

I hope that helps!

Good night.
 

dashival

New Member
Reaction score
11
Jeez.. I just looked through that trigger, and I just gotta say, if you say it works, I'll believe you. I honestly can't follow what it does, too much looping and whatnot. But, thanks for putting hard work into something you didn't need to. :)

But, er, one question. This will allow the hero to have more than one item, right, just not more than one of the same type? I can't see at all what the trigger actually does, so I'm forced to ask. Also, can I replace the location in the 'Unit - Order Triggering Unit to Drop..' line so it uses a variable set to the position of the item being manipulated? I want the item to be dropped where it was picked up from, so the hero can't move it.
 
W

Wazat

Guest
Yes, try the trigger out. He can have 6 different items, but if he tries to grab a duplicate it'll just fall out of his inventory.

The hero will drop it at his feet, but you can easily change that to somewhere else, as you said... assuming the position of the manipulated item is going to correctly refer to the item's location before the hero grabbed it (I'm not sure). I'm also not sure that location will be valid when the trigger is set off by the "Unit - A unit Is issued an order targeting an object" event.


All this trigger does is:
* Look through each item slot (1-6)
* Compare it to each other item slot (1-6, but skip those already checked).
* Check:
1) If they're not the same slot
2) neither slot is empty
3) both items in those slots are the same type
* Then drop the second item. It does this by printing a message to the player and ordering the unit to drop the item where he stands (which you can change to another location).

Hope that helps... and sorry to confuse you.
 

dashival

New Member
Reaction score
11
It's not a problem :p

The thing, though.. I still can pick up multiple items, except with this trigger, if I have multiples of an item, I can't pick up any other items. It's odd. :S Thanks, though, I'm going to use that trigger, it's fine. :D
 
W

Wazat

Guest
You mean you can manage to pick up multiple of the same type, but once those are in your inventory, they stay and you can't pick up other items? Hmm... it was intended to immediately force the unit to drop the item out. *shrugs*

I couldn't get the "Hero - Drop the item from slot (Integer B) of (Triggering unit)" action to work (it crashed the game), so using orders is all that I could do. I hope it works well for ya.
 
General chit-chat
Help Users
  • No one is chatting at the moment.
  • 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 The Helper:
    New recipe is another summer dessert Berry and Peach Cheesecake - https://www.thehelper.net/threads/recipe-berry-and-peach-cheesecake.194169/

      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