Making unit able to only hold one of one type of item

P

Pronoun

Guest
I have a certain type of item which I want heros only able to have one of. I tried using triggers, but to no avail. Is there something in the specific item configuration that I have to do? However, I want it to only work with the certain item type, no other kind.
 

AceHart

Your Friendly Neighborhood Admin
Reaction score
1,495
AFAIK, there is no Item setting that would do it...

You could, of course, only ever create the Item once in the entire game :)


More seriously though, you could count them:
Code:
OnceOnly
    Events
        Unit - A unit Acquires an item
    Conditions
        (Item-type of (Item being manipulated)) Equal to Tome of Experience
    Actions
        Set TmpCounter = 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 Tome of Experience
                    Then - Actions
                        Set TmpCounter = (TmpCounter + 1)
                    Else - Actions
        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            If - Conditions
                TmpCounter Greater than 1
            Then - Actions
                Hero - Drop (Item being manipulated) from (Hero manipulating item)
            Else - Actions

Have a look through all the item slots,
if the item found there matches, add 1 to some counter.
If counter > 1...



A somewhat simpler way would be to make use of the "custom value" that every unit has.

Code:
OnlyOnce
    Events
        Unit - A unit Acquires an item
    Conditions
        (Item-type of (Item being manipulated)) Equal to Tome of Experience
    Actions
        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            If - Conditions
                (Custom value of (Hero manipulating item)) Equal to 42
            Then - Actions
                Hero - Drop (Item being manipulated) from (Hero manipulating item)
            Else - Actions
                Unit - Set the custom value of (Hero manipulating item) to 42

Much simpler :)

Unless, of course, you're already using the unit's custom value...
You just need to add another trigger that resets the custom value to 0 if the item gets lost, used up, dropped or sold.


HTH
AceHart
 
P

Pronoun

Guest
Thanks, its just that I have three diferent items, of which a unit can only hold one of them, not all three at once. I just thought there was some item setting that would allow this, but I'll try using the custom value trigger you provided, since I don't know what else I may use custom values for. Thanks again.
 

AceHart

Your Friendly Neighborhood Admin
Reaction score
1,495
Well, it's easily adaptable to one-out-of-many.

Add "Or - multiple conditions" as condition,
and place all the "(Item-type of (Item being manipulated)) Equal to ...)"
you may need inside the "or".

Done :)


HTH
AceHart
 
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