A simpler inventory system?

M

MikeTheGuy

Guest
I'm sure I'm not the first one to think of this.

I was looking at the inventory systems and it seems that most require either finding substrings or making a ton of triggers. Mine, if the trigger works, would only need 1 trigger. Basically, my idea is to assign an item type (ie. sword, shield, helm, etc.) to each item class. So, for example: Artifact: Helmet, Purchasable: Armor, Permanent: Weapon, Charged: Shield (or weapon 2), Campaign: Leggings, Miscellaneous: Boots. And then Powerup (obviously remove the "use automatically when acquired" if you need to) for your general items, like quest items, potions, etc. Then, this trigger would be used to restrict the items:

PHP:
inventory
    Events
        Unit - A unit Acquires an item
    Conditions
        Or - Any (Conditions) are true
            Conditions
                (Item-class of (Item being manipulated)) Equal to Artifact
                (Item-class of (Item being manipulated)) Equal to Purchasable
                (Item-class of (Item being manipulated)) Equal to Permanent
                (Item-class of (Item being manipulated)) Equal to Charged
                (Item-class of (Item being manipulated)) Equal to Campaign
                (Item-class of (Item being manipulated)) Equal to Miscellaneous
    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-class of (Item carried by (Hero manipulating item) in slot (Integer A))) Equal to (Item-class of (Item being manipulated))
                    Then - Actions
                        Hero - Drop the item from slot (Integer A) of (Hero manipulating item)
                        Game - Display to (All players) the text: Sorry, you can only...
                    Else - Actions
                        Do nothing

However, the trigger does not work. It will not allow you to pick up any item of those classes, even if there is no other item of that class in your inventory.
 

Ghan

Administrator - Servers are fun
Staff member
Reaction score
889
It might be that since the trigger fires after the unit has already picked up the item, it counts that item in its evaluation, so it will always drop it, due to the fact that it is comparing the item to itself at some point. Add a comparison in the loop that the item in the Integer A slot is NOT the item being manipulated and see if that works.
 
M

MikeTheGuy

Guest
That's what I got to thinking as well. So I did what you said and added that comparison, but now the trigger doesn't display the message or drop the item when two items of the same class are picked up. This is the new trigger, all I added was that comparison.

PHP:
inventory
    Events
        Unit - A unit Acquires an item
    Conditions
        Or - Any (Conditions) are true
            Conditions
                (Item-class of (Item being manipulated)) Equal to Artifact
                (Item-class of (Item being manipulated)) Equal to Purchasable
                (Item-class of (Item being manipulated)) Equal to Permanent
                (Item-class of (Item being manipulated)) Equal to Charged
                (Item-class of (Item being manipulated)) Equal to Campaign
                (Item-class of (Item being manipulated)) Equal to Miscellaneous
    Actions
        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            If - Conditions
                (Item-class of (Item carried by (Hero manipulating item) in slot (Integer A))) Equal to (Item-class of (Item being manipulated))
                (Item-type of (Item carried by (Hero manipulating item) in slot (Integer A))) Not equal to (Item-type of (Item being manipulated))
            Then - Actions
                Hero - Drop the item from slot (Integer A) of (Hero manipulating item)
                Game - Display to (All players) the text: Sorry, you can only...
            Else - Actions
                Do nothing

I think the problem might have something to do with that comparison. I think that the program is thinking that, yes, the item is of the same class but it is not the same item type as the one that was found, so therefore it is allowed to be picked up.
 

Ghan

Administrator - Servers are fun
Staff member
Reaction score
889
Try a straight item comparison like this:

Code:
(Item carried by <Unit> in slot (Integer A)) Not equal to (Item being manipulated)
 
M

MikeTheGuy

Guest
Hmm...I just tried that and it doesn't work either. This is really confusing. I've looked over the trigger many times but I can't tell why it's doing this.
 
M

MikeTheGuy

Guest
Alright, the way it's set up is there's a hero surrounded by items. The items are sorted so that they're all in pairs of the same class. For example, the two in front of the hero are Artifacts, etc. I did this so I could see if the system worked.
 

Attachments

  • MTG Inventory.w3x
    17.5 KB · Views: 69

Ghan

Administrator - Servers are fun
Staff member
Reaction score
889
Oh, I could kick myself, but I won't. :p You don't have a loop. You need to add a For Each Integer A loop like this:

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-class of (Item carried by (Hero manipulating item) in slot (Integer A))) Equal to (Item-class of (Item being manipulated))
                (Item carried by (Hero manipulating item) in slot (Integer A)) Not equal to (Item being manipulated)
            Then - Actions
                [COLOR="Red"]Hero - Drop (Item being manipulated) from (Hero manipulating item)[/COLOR]
                Game - Display to (All players) the text: Sorry, you can only...
            Else - Actions
                Do nothing

I also changed the thing in red because otherwise it would switch items.
 
M

MikeTheGuy

Guest
lol I JUST realized that when I looked at the trigger after I posted. And when I tested after adding the loop back in it worked, but yeah I noticed the bug where it switches items, I'll change that. Thanks for your help, it should work now. +rep
 
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