Destroy a specific item when another is picked up?

maldruzard

Member
Reaction score
2
Hey there!

I am making a map with weapons that randomly spawn in regions periodically, and then despawn if not taken. The problem I'm facing is that I don't know how to make it so weapons cannot be stacked, but at the same time keeping the 6 inventory slots.

Is there some way to destroy or drop a weapon being carried when another weapon is picked up? I'm using claws of attack as base items with custom effects and models, and I don't want the effects/models stacked up. Is it possible to trigger this sort of thing? From all of the item conditions I could see, it would require me to choose a specific item placed on the map to use in the trigger, but being as my items spawn and despawn every so often, I can't use specific items on the map in the trigger :(

Edit: Now I have seen the item type condition, but still not sure howpicking up say 'Item A' would then check if any Items "A, B, C, or D' were present in the inventory of the person picking up the item, and if so, to destroy or drop that item.
 

death_knight

Dark is the heart of a corrupted man.
Reaction score
24
Well what you could do is when a hero/unit picks up a item that you would classify as a weapon, you can use triggers to assign the acquired item to a variable so that when the hero/unit picks up another item which you would classify as a weapon, the current weapon assigned to the variable is destroyed/dropped using triggers and the newly acquired item is set to the variable.

I hope I answered your question (unless I misinterpreted what you asked :p).
 

maldruzard

Member
Reaction score
2
Well what you could do is when a hero/unit picks up a item that you would classify as a weapon, you can use triggers to assign the acquired item to a variable so that when the hero/unit picks up another item which you would classify as a weapon, the current weapon assigned to the variable is destroyed/dropped using triggers and the newly acquired item is set to the variable.

I hope I answered your question (unless I misinterpreted what you asked :p).
That did kinda help :D But what conditions could I use to classify it as an item? Item type doesn't work as you cant do 'Picked item equal to [ITEM TYPE]', you can only do '[ITEM TYPE] equal to [ITEM TYPE]. Im so confused :(
 

death_knight

Dark is the heart of a corrupted man.
Reaction score
24
It's not really something you can assign to the item in world editor, but it is something you can do manually using variables.What you could do is have a set of actions that check the acquired item against all items you would consider a weapon and look for a match. Here's the way that I would do it:

You would need to set up a few variables first.

Weapons:
Var type -- 'Item-Type'
Is Array? -- Yes
Purpose -- This variable array will contain all the item-types which you consider weapons

nWeapons:
Var type -- 'Integer'
Is Array? -- No
Purpose -- This represents the number of items you consider to be weapons

isWeapon:
Var Type -- 'Boolean'
Is Array? -- No
Purpose -- This variable (initially set to 'false') represents whether or not the acquired item is a weapon or not.

acquiredWeapon:
Var Type -- 'Item-Type'
Is Array? -- No
Purpose -- This represents the item type of the acquired item.

To check whether or not the item is a weapon, the following actions mus be employed in a trigger:

Trigger:
  • Actions
    • For each (Integer A) from 1 to nWeapons, do (Actions)
      • Loop - Actions
        • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
          • If - Conditions
            • acquiredWeapon Equal to Weapons[(Integer A)]
          • Then - Actions
            • Set isWeapon = True
          • Else - Actions


For example, you could have 3 items you consider weapons and those item types (e.g Claws of Attack +9, Gauntlets of Ogre Strength +3, and Warsong Battle Drums) would be saved in the 'Weapons' array variable and the 'nWeapons' integer variable would be set to 3.

I hope that helps you a little bit more. Let me know if you are still confused.
 

maldruzard

Member
Reaction score
2
Right! I have got as far as you have described, but now I need something to determine whether there is already a 'Weapon' classed item in the inventory of the hero, and if so, to drop/remove that when the new 'Weapon' is picked up... my head hurts :(
 

death_knight

Dark is the heart of a corrupted man.
Reaction score
24
hahaha I know the feeling.

So as you said, the next step is to find another weapon in your inventory (if any) and remove it. This can get slightly complicated, depending on how you do it, but it definitely isn't impossible. Since we already have a basis for doing this by having the trigger above, what I'm going to do is expand a little on the actions used above and search through the inventory to check whether or not there's another weapon in the hero's inventory.

Just a couple of new variables:

acqItem:
Var Type -- 'Item'
Is Array? -- No
Purpose -- This represents the actual item that you picked up. This is so that when we check for any other weapons in the inventory, the trigger doesn't identify this one as a weapon and remove it.

Hero:
Var Type -- 'Unit'
Is Array? -- No
Purpose -- This variable just represents the unit/hero that will be manipulating the items (i.e. picking up the weapons).

Here's the modified set of actions:

Trigger:
  • Actions
    • For each (Integer B) from 1 to 6, do (Actions)
      • Loop - Actions
        • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
          • If - Conditions
            • acqItem Not equal to (Item carried by Hero in slot (Integer B))
          • Then - Actions
            • For each (Integer A) from 1 to nWeapons, 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 in slot (Integer B))) Equal to Weapons[(Integer A)]
                  • Then - Actions
                    • Item - Remove (Item carried by Hero in slot (Integer B))
                  • Else - Actions
          • Else - Actions


I haven't tested that, but it should work.
 

maldruzard

Member
Reaction score
2
Hey there! You have been such a great help so far :) I've done everything you said, but methinks that somewhere along in the process of doing so, I completely screwed something up :( It's probably something super simple that I've missed, but I can't pinpoint it no matter how many times I go over it, though it's probably staring me right in the face!

I've uploaded a /zip with my map inside of it, if you have any spare time/if you are super bored, do you think you would please be able to check over the triggers and test them to see what's wrong? The weapons still stack when I test the map :(

Thank you so much!
 

Attachments

  • Help this map.zip
    112.9 KB · Views: 143

chukky-jr

Member
Reaction score
15
i suggest just use 'items class' as indexer and set something like

Artifact = weapon
Power Up = armour
Charged = Accessory

then use this simple trigger for checking if there is any instance of weapon/armour/accessory in unit's inventory

like this

Though that one compares particular items, not classes.
Post #3 had a decent try.

Or, some more inspiration:
Code:
Item Once Classes
    Events
        Unit - A unit Acquires an item
    Conditions
        (Item-class of (Item being manipulated)) Equal to Artifact
    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))
                        (Item carried by (Hero manipulating item) in slot (Integer A)) Not equal to (Item being manipulated)
                    Then - Actions
                        Item - Remove (Item being manipulated)
                        Game - Display to (Player group((Owner of (Hero manipulating item)))) the text: Sorry.
                    Else - Actions


That said, "It doesn't work" is not a very good problem description.

If you tried a trigger and it's not really doing what it should, post it.

^sorry this one particular item, not class, but you'll get the idea
 

maldruzard

Member
Reaction score
2
i suggest just use 'items class' as indexer and set something like

Artifact = weapon
Power Up = armour
Charged = Accessory

then use this simple trigger for checking if there is any instance of weapon/armour/accessory in unit's inventory

like this
Well I posted the actual map with the triggers, but they are pretty much word for word what Death Knight posted, so that is why I am not sure why when I test it, I am still able to stack weapons. :-(
 

chukky-jr

Member
Reaction score
15
okay here it is, i made Slingshot and Wooden Bow classified as Artifact, which means your unit can only carry 1 kind of Artifact in your inventory (either Slingshot or Wooden Bow), just study the trigger and modify it into your liking :)

http://www.mediafire.com/?0by6d76c7ntcbkd

btw i disabled your 'weapons' category since i have no idea what are you trying to achieve lol



why can't we upload w3x file into a mapmaking forum again?
 

death_knight

Dark is the heart of a corrupted man.
Reaction score
24
Maldruzard, I think I've pinpointed the issue. I haven't tested it, but I'm pretty sure that it's where you're going wrong. In you trigger called 'Weapon Variables', you have this:

Trigger:
  • Weapon Variables
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Set Weapons[nWeapons] = Iron Dagger
      • Set Weapons[nWeapons] = Iron Longsword
      • Set Weapons[nWeapons] = Iron BASTARDO Sword
      • Set Weapons[nWeapons] = Dark Iron Waraxe
      • Set Weapons[nWeapons] = Stone Cudgel
      • Set Weapons[nWeapons] = Slingshot
      • Set Weapons[nWeapons] = Wooden Bow

When instead you should have something like this:
Trigger:
  • Weapon Variables
    • Events
      • Time - Elapsed game time is 0.00 seconds
    • Conditions
    • Actions
      • Set Weapons[1] = Iron Dagger
      • Set Weapons[2] = Iron Longsword
      • Set Weapons[3] = Iron BASTARDO Sword
      • Set Weapons[4] = Dark Iron Waraxe
      • Set Weapons[5] = Stone Cudgel
      • Set Weapons[6] = Slingshot
      • Set Weapons[7] = Wooden Bow
      • Set nWeapons = 7

That should fix the problem.
 

maldruzard

Member
Reaction score
2
okay here it is, i made Slingshot and Wooden Bow classified as Artifact, which means your unit can only carry 1 kind of Artifact in your inventory (either Slingshot or Wooden Bow), just study the trigger and modify it into your liking :)

http://www.mediafire.com/?0by6d76c7ntcbkd

btw i disabled your 'weapons' category since i have no idea what are you trying to achieve lol



why can't we upload w3x file into a mapmaking forum again?

If you pick up a weapon first, this trigger also doesn't allow you then to pick up any item of any kind after that unless you put it down first... :(
 

chukky-jr

Member
Reaction score
15
oh so you meant you want to drop the weapon that already inventory, rather than dropping the one that is currently being taken? is that right?
 

death_knight

Dark is the heart of a corrupted man.
Reaction score
24
Chukky, that is the idea. So if a hero had a Iron Dagger in its inventory and picks up a Long Bow, the idea is to keep the Long Bow and drop the Iron Dagger.
 

maldruzard

Member
Reaction score
2
so you meant like this?

http://www.mediafire.com/?n0qii5bq61mim5d

if anyone is confused, currently my trigger only checks for Artifact-type items, on that map, it is Slingshot and Wooden Bow, anyone can only take either Slingshot or Wooden Bow

Yes, that is much more along the lines of what I want :) However, there is still a problem with that, being as if you have a weapon in your inventory and try to pick up a normal item (non-artifact), it still replaces and drops the weapon, even though another weapon has not been picked up. Any idea why that is happening? :-(
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Staff online

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top