• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!

[General] Item removal, if the item is nt collected

Status
Not open for further replies.
Level 6
Joined
Aug 10, 2010
Messages
77
Hello guys , I am working on map where i have over 200 item drops. Now i need to make something to solve items that are not collected.

How to do trigger to items?
If the unit dies it creates item
If a player do not collects the item till 60 seconds it would remove.
CONDITION : only items from player 3 has to be removed.
I cant make trigger, any ideas?

I ve tried to make last created item remove by timing but it removed also mine items in invetory :D .
 
Level 7
Joined
May 14, 2019
Messages
255
Im not exactly sure of what you want and why triggers dont work to accomplish it, but alternatively you can create a unit with a huge range that only targets items and destroys them if they are not collected within 60 seconds, but again I may not understand what you're trying to do.
 
Level 20
Joined
Aug 29, 2012
Messages
837
Alternatively you could create a trigger that removes every item on the ground every X seconds (like every 2 minutes or so). Simply add a warning message beforehand so people could collect stuff they need in time. You could even create a command only usable by the host so that they can clear the map when there's too much stuff when they want.

That's not ideal but pretty easy to do.
 
Level 22
Joined
Sep 7, 2013
Messages
235
Maybe you could take advantage of the expiration timer you can put on units:
- On item drop, create a dummy (invisible) unit at item position, and set a 60s expiration timer to this unit
- On dummy unit death, remove items within close range of dying unit
 
Level 9
Joined
Jul 30, 2018
Messages
445
Items have Custom Value, you can easily use that.

  • Item Drop
    • Events
      • Unit - A unit Dies
    • Conditions
      • (Owner of (Triggering unit)) Equal to Player 3 (Teal)
    • Actions
      • Set TempPoint = (Position of (Triggering unit))
      • Item - Create (Random level (Random integer number between 1 and 8) item-type) at TempPoint
      • Custom script: call RemoveLocation(udg_TempPoint)
      • Item - Set the custom value of (Last created item) to 60
  • Item Destroy
    • Events
      • Time - Every 1.00 seconds of game time
    • Conditions
    • Actions
      • Item - Pick every item in (Playable map area) and do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Custom value of (Picked item)) Greater than 0
            • Then - Actions
              • Item - Set the custom value of (Picked item) to ((Custom value of (Picked item)) - 1)
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Custom value of (Picked item)) Equal to 0
                • Then - Actions
                  • Item - Remove (Picked item)
                • Else - Actions
            • Else - Actions
Now this way if you leave the Custom Value to 0 (as it is normally), it will never be destroyed.

Alternatively, item's life is also pretty useless, because items are rarely attacked, so that can be used as well same way I just used Custom Value above.
 
Last edited:
Level 8
Joined
May 21, 2019
Messages
435
Items have Custom Value, you can easily use that.

  • Item Drop
    • Events
      • Unit - A unit Dies
    • Conditions
      • (Owner of (Triggering unit)) Equal to Player 3 (Teal)
    • Actions
      • Set TempPoint = (Position of (Triggering unit))
      • Item - Create (Random level (Random integer number between 1 and 8) item-type) at TempPoint
      • Custom script: call RemoveLocation(udg_TempPoint)
      • Item - Set the custom value of (Last created item) to 60
  • Item Destroy
    • Events
      • Time - Every 1.00 seconds of game time
    • Conditions
    • Actions
      • Item - Pick every item in (Playable map area) and do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Custom value of (Picked item)) Greater than 0
            • Then - Actions
              • Item - Set the custom value of (Picked item) to ((Custom value of (Picked item)) - 1)
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Custom value of (Picked item)) Equal to 0
                • Then - Actions
                  • Item - Remove (Picked item)
                • Else - Actions
            • Else - Actions
Now this way if you leave the Custom Value to 0 (as it is normally), it will never be destroyed.

Alternatively, item's life is also pretty useless, because items are rarely attacked, so that can be used as well same way I just used Custom Value above.

This system doesn't differentiate between items dropped by player 3 and items dropped by anyone else, it also doesn't reset the expiration timer, meaning that items picked up after a long time on the ground would expire quickly if put back down. In addition, it also leaks an item group every 1 second.
This system would be a lot better with a minor change. Simply add the created item to an item group, and then run through that item group instead. Then, you'd simply remove items from the item group whenever they are picked up. This solves both the leak and the items only expiring after being created.
 
Level 9
Joined
Jul 30, 2018
Messages
445
This system doesn't differentiate between items dropped by player 3 and items dropped by anyone else

It does, right there on the first trigger the condition:

  • (Owner of (Triggering unit)) Equal to Player 3 (Teal)
Though, yes, this system would require the item drop system to be triggered rather than done through the Editor's item drop table system, but that's a crappy system anyway, so I'd suggest people to trigger item drops (from monsters' deaths) nevertheless.

it also doesn't reset the expiration timer, meaning that items picked up after a long time on the ground would expire quickly if put back down.

Fair point, didn't think about that. But that's easily fixed: just make a trigger that when a unit acquires an item, set its Custom Value to zero.

In addition, it also leaks an item group every 1 second.
This system would be a lot better with a minor change. Simply add the created item to an item group, and then run through that item group instead. Then, you'd simply remove items from the item group whenever they are picked up. This solves both the leak and the items only expiring after being created.

Item "groups" don't leak - or at least there is nothing you can do about it. There is no variable of type "Item Group" like there are Unit Groups and Player Groups.
 
Last edited:
Level 8
Joined
May 21, 2019
Messages
435
It does, right there on the first trigger the condition
No, what that states is who the owner of the unit causing the item to be created is (in rpg terms you could say "dropped" as in a loot drop, but in editor terms, dropping is literally the carrying unit dropping it on the ground, so I guess I caused that confusion by being a bit unclear).

Though, yes, this system would require the item drop system to be triggered rather than done through the Editor's item drop table system, but that's a crappy system anyway, so I'd suggest people to trigger item drops (from monsters' deaths) nevertheless.
Totally on board with this. I use a similar system with item arrays as loot tables.

Item "groups" don't leak - or at least there is nothing you can do about it. There is no variable of type "Item Group" like there are Unit Groups and Player Groups.
I may be remembering wrong, but isn't it possible to add items to unit groups, as they are technically a unit?
Also, I tried researching if Pick Every Item leaks a group, but I couldn't find any concrete proof of either case. The only argument that I found was that there is no "Item Group" variable, which is hardly proof that the game doesn't leak memory, nor that the concept doesn't exist (think of the many things we weren't able to access in the GUI for so incredibly long). I may be overly cautious here, but I'd wanna know something like this for sure before running this trigger once every single second.
 
Level 9
Joined
Jul 30, 2018
Messages
445
I may be remembering wrong, but isn't it possible to add items to unit groups, as they are technically a unit?

I thought of this too, but at least I couldn't find a way to add items to Unit Groups, as at least Unit Group - Add Unit takes only unit variables.

Also, I tried researching if Pick Every Item leaks a group, but I couldn't find any concrete proof of either case. The only argument that I found was that there is no "Item Group" variable, which is hardly proof that the game doesn't leak memory, nor that the concept doesn't exist (think of the many things we weren't able to access in the GUI for so incredibly long). I may be overly cautious here, but I'd wanna know something like this for sure before running this trigger once every single second.

This is true. But at least there is nothing you can do about it, if it does leak. Actually, inspired by this I made a little test map - I picked all items (dozens of them) in playable map area every 0.02 second and let it run on. After 296 seconds it crashed:

nimetön.png



So, it seems that it does leak something :p
 
Level 2
Joined
May 28, 2019
Messages
13
You could have a trigger:

Unit dies
Wait X time
Spawn invisible unit that can only attack items at position of dying unit
order last created unit to attack ground at position of dying unit
Wait .5? seconds or however long it takes to kill the item
remove last created unit from the game

I could see this going wrong still but maybe an idea to branch out from
 
Level 9
Joined
Jul 30, 2018
Messages
445
You could have a trigger:

Unit dies
Wait X time
Spawn invisible unit that can only attack items at position of dying unit
order last created unit to attack ground at position of dying unit
Wait .5? seconds or however long it takes to kill the item
remove last created unit from the game

I could see this going wrong still but maybe an idea to branch out from

Umm, what's the point of the dummy unit attacking the item if you are going to remove it anyway?
 

Uncle

Warcraft Moderator
Level 64
Joined
Aug 10, 2018
Messages
6,576
I attached a map with a working system.

Items dropped by player 3 will be removed after 60 seconds unless picked up. If you pick up and drop one of these items then it's timer resets and it starts to expire again. You can turn that part off.

All you have to do is import the triggers over (copy and paste the 2 folders, you can ignore the Variables folder) and make sure that "Automatically create unknown variables" is enabled in your map file preferences.

Once you have it imported, edit the Spawn Items trigger to work with the trigger you already have.
You can post your trigger on here and I can show you how to make it work with this. Anyway, these are the actions that are important. Whenever you create an item that you want to be removed after 60 seconds, run these actions after it.
  • Item - Set the custom value of (Last created item) to -1
  • Custom script: call IndexItem(GetLastCreatedItem())
  • Set ItemExpirationTimer[IDex] = ItemExpireTimer
  • Set ItemIsCarried[IDex] = False
  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
    • If - Conditions
      • (Remove Items Timer <gen> is on) Equal to False
    • Then - Actions
      • Trigger - Turn on Remove Items Timer <gen>
    • Else - Actions
And here's the whole trigger just for reference. Since I don't know how the items are created in your map, I just created an example that spawns Claws of Attack +15.
  • Spawn Items
    • Events
      • Unit - A unit Dies
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Owner of (Triggering unit)) Equal to Player 3 (Teal)
        • Then - Actions
          • -------- Create your Item. --------
          • Item - Create Claws of Attack +15 at (Position of (Triggering unit))
          • -------- - --------
          • -------- The system will only Index items with a custom value of -1. (I edited the system to do this) --------
          • Item - Set the custom value of (Last created item) to -1
          • -------- - --------
          • -------- All this Custom Script does is tell the system to Index the item. --------
          • Custom script: call IndexItem(GetLastCreatedItem())
          • -------- - --------
          • -------- Here we set the duration of our item's expiration timer and mark the item as not being carried. --------
          • Set ItemExpirationTimer[IDex] = ItemExpireTimer
          • Set ItemIsCarried[IDex] = False
          • -------- - --------
          • -------- We turn this timer on if it's off. It's nice to turn off timers that aren't being used. --------
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Remove Items Timer <gen> is on) Equal to False
            • Then - Actions
              • Trigger - Turn on Remove Items Timer <gen>
            • Else - Actions
        • Else - Actions
          • -------- If the item wasn't dropped from Player 3 then it won't have an expiration timer and we create it like we normally would. --------
          • Item - Create Claws of Attack +15 at (Position of (Triggering unit))

Edit: I don't think Pick Every Item leaks, but I'll upload a version that doesn't use it just in case. [URL='https://www.hiveworkshop.com/attachments/item-expiration-and-indexer-v2-w3x.324221/?temp_hash=ed55b91beff099effd8dd1e3590a803f']Item Expiration and Indexer v2 [/URL]is safe to use.
 

Attachments

  • Item Expiration and Indexer.w3x
    32.7 KB · Views: 17
  • Item Expiration and Indexer v2.w3x
    32.9 KB · Views: 20
Last edited:
Status
Not open for further replies.
Top