• 🏆 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!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

Item Remove System Need Help!

Status
Not open for further replies.
Level 5
Joined
May 27, 2007
Messages
126
Hello,

I would like to get straight to business, I tried alot and alot but I just couldn't find a way to make the following:

A trigger that removes every item in the entire map X seconds after it was created. This trigger can't use the "last created item" function, cause that would mean that if another item is dropped in that X seconds, that new item will be removed and not the old one.

So basically every single created item that is not picked up (and thus lying there in the landscape) must be destroyed, if it isn't owned, X seconds AFTER it has been created! I want this, cause I got this JASS system in my map that works with itempools and drops items according to chances everytime you kill a creep of player 7. But the problem is, that when people dont pick the items up, the items remain there forever... UNLESS you regulate the system!

Hope someone can tell me a good way, cause I am lost out of ideas, I would very much appreciate it if you could make a picture of the trigger in this topic.

Thanks sincerely,

Syntic
 
Level 3
Joined
Dec 1, 2008
Messages
21
^ Yeah Pick all the items in the map
go to the actions part unit-remove
now remove PICKED UNIT

and it should remove them all no?

Or time it

like events-time elapsed in game is 40 seconds
actions-Remove-unit Remove picked unit or remove triggering unit?

maybe anyway good luck!
 
Level 5
Joined
May 27, 2007
Messages
126
no!!! im not stupid! that could cause players to be annoyed, cause what happens if an important item drops right on that point that it refreshes? excactly! people get pissed, so can you help me answering my dilemma?
 
Level 17
Joined
Nov 18, 2008
Messages
1,538
You could make it every time an item dropped, 20 or w/e is saved to a real variable and then a timer is run for that amount of time, and if another item is dropped the timer starts over
 
Level 9
Joined
Nov 28, 2008
Messages
704
Why not do a simple MUI Jass Trigger?

Something vaguely like:

JASS:
local item tempItem = GetLastCreatedItem()
call TriggerSleepAction( 20.00 ) //20 seconds :D
call RemoveItem(tempItem)
set tempItem = null

I dont think thats the actual function calls, but why not use something like that?

Oh, and yeah, if they pick it up.. well, I guess the simplest way would be to add a location variable, set it to the location of that item, then when it goes to destroy the item, check if the item is still in the same location. If it is, then destroy it.

JASS:
local item tempItem = GetLastCreatedItem()
local location tempPoint = LocationOf(tempItem) // By the way, that isnt the right function call, and I doubt anything else is. Dont use this code :D
call TriggerSleepAction( 20.00 ) //20 seconds :D
if LocationOf(tempItem) == tempPoint then // Again, not right function call.
    call RemoveItem(tempItem)
end if
call RemoveLocation(tempPoint)
set TempPoint = null
set tempItem = null

The trigger would be whenever a unit enters the map, or else you could pick every item on the map every 20 seconds and kill it on the ground.
 
Level 9
Joined
Nov 28, 2008
Messages
704
Most definitely not. Uhm, I guess I could make you the actual trigger, I coulld play with world edit.

To coppy the trigger you would have to make a trigger with the event a unit enters Playable Map Area, the Conidition being Unit = Item, or some such thing, then I would have to actually fix my JASS trigger.

Ill work on that if you want, Ill give it later.

Edit: uniit entering map would not work. Every 5 seconds you would just have to choose every item in the map and give it an expiration timer. Ill make the trigger for you.

Edit: Good trigger located at my next post.
 
Last edited:
Level 9
Joined
Nov 28, 2008
Messages
704
Which mistakes? :p

I cant find THAT many, and I found out that removing the wait causes it to actually reach the if function.

How can I properly get it to compare the two? This is confusing the heck out of me.

Edit: Worked it out. Using X and Y instead of Location works perfect. Ill post code in a minute.

By the way, how do you null a local real at the end of a function? you cant do set X = null, so Im assuming that its impossible, and they dont leak?

Edit: UGH, PolledWait still causes it to mess up. How the heck do you fix that? The system works fine, except the instant you add PolledWait, it doesnt even make it to the if!

JASS:
function Trig_Item_Removal_Func001A takes nothing returns nothing
    local item TempItem = GetEnumItem()
    local real TempItemLocX = GetItemX(TempItem)
    local real TempItemLocAfterX
    local real TempItemLocY = GetItemY(TempItem)
    local real TempItemLocAfterY
    //call PolledWait(15)
    set TempItemLocAfterX = GetItemX(TempItem)
    set TempItemLocAfterY = GetItemY(TempItem)
    if (TempItemLocX == TempItemLocAfterX) and (TempItemLocY == TempItemLocAfterY) then
         call RemoveItem( TempItem )
    endif
    set TempItem = null
endfunction

function Trig_Item_Removal_Actions takes nothing returns nothing
    local rect TempMap = GetEntireMapRect()
    call EnumItemsInRectBJ( TempMap, function Trig_Item_Removal_Func001A )
    call RemoveRect(TempMap)
    set TempMap = null
endfunction

//===========================================================================
function InitTrig_Item_Removal takes nothing returns nothing
    set gg_trg_Item_Removal = CreateTrigger(  )
    call TriggerRegisterTimerEventPeriodic( gg_trg_Item_Removal, 5.00 )
    call TriggerAddAction( gg_trg_Item_Removal, function Trig_Item_Removal_Actions )
endfunction

I want to kill myself for this trigger. the PolledWait (part with double line slashes) ruins it, so i disabled it. I need to find a way to stop it from messing up strangely like it is.

Dont use this until we find out a way to stop PolledWait from sucking.
 
Level 12
Joined
Aug 22, 2008
Messages
911
I offer another idea.
Select each item as it is created and add to it an expiration timer via triggers.
  • YourTrigger
    • Events
      • Unit - A unit drops an item
      • (Or whatever you want)
    • Conditions
    • Actions
      • Countdown Timer - Add an expiration timer to (Dropped Item)
      • ------ Note that (Dropped Item) will have to change with your event. -----
On second thought, that probably won't work with items, but it's worth the try.
 
Level 9
Joined
Nov 28, 2008
Messages
704
Your method is probably way simpler, but i forsee problems, because then he has to add expiration timers manually every time he makes an item, and if he makes an item through triggers, eh..

Whatever, Im just hoping the stupid PolledWait will go away.

Oh, and your method would require another trigger to stop the item from disappearing when a unit picks it up :O.
 
Level 8
Joined
Feb 20, 2007
Messages
338
Two triggers are needed:

  • ItemDrop
    • Events
      • Unit - A unit Acquires an item
      • Unit - A unit Loses an item
    • Conditions
      • Or - Any (Conditions) are true
        • Conditions
          • (Item-class of (Item being manipulated)) Not equal to Powerup
    • Actions
      • Item - Set the custom value of (Item being manipulated) to 60
And

  • ItemRemove
    • 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
              • ((Picked item) is owned) Equal to False
              • ((Picked item) is invulnerable) Equal to False
            • Then - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Custom value of (Picked item)) Less than or equal to 0
                • Then - Actions
                  • Item - Remove (Picked item)
                • Else - Actions
                  • Item - Set the custom value of (Picked item) to ((Custom value of (Picked item)) - 1)
                  • Floating Text - Create floating text that reads (String((Custom value of (Picked item)))) at (Position of (Picked item)) with Z offset 48.00, using font size 10.00, color (0.00%, 100.00%, 0.00%), and 50.00% transparency
                  • Floating Text - Set the velocity of (Last created floating text) to 32.00 towards 90.00 degrees
                  • Floating Text - Change (Last created floating text): Disable permanence
                  • Floating Text - Change the lifespan of (Last created floating text) to 0.50 seconds
            • Else - Actions
The first one assigns a 'custom' value to items created/dropped whatever. That value is in this case 60. The second trigger picks all the items every second, sets the custom value one point lower - after 60 seconds the item 'expires' and is removed.

You can change the conditions, for instance I have items created on my map that are immediately made invulnerable. They can still be picked up, they are just not given a custom value or removed.

I have items that drop from 'boss' mobs - where and item is created at their location when they drop, I make the item invulnerable upon its creation. The second trigger rules out via the If/and/else condition:

  • ((Picked item) is invulnerable) Equal to False
When items drop that I want to remain I use the function upon its creation

  • Item - Make (Last created item) Invulnerable
You can use
  • ((Triggering unit) belongs to an enemy of Player 1 (Red)) Equal to True
in the first trigger - thus any item manipulated by player red (in this instance) will have a custom value of 60.

If you want player reds items to remain forever then you would set that function to 'false'.

In this trigger I made a 'timer' that shows the remaining life of the item (the numbers spawn and rise up from the item - showing the player that s/he has x amount of time to claim the item.

In conditions you can select type of item (consumable, permanent, power-up, etc) thus you can set the custom value of different types of items to different numbers - if you want power-ups to remain for 2 minutes you assign their custom value as 120. consumables can have a 30 second life.

If you do not want this triggering firing every second, then change it to 5 seconds, change the custom value minus 20 per firing.

  • Item - Set the custom value of (Picked item) to ((Custom value of (Picked item)) - 20)
thus you get 60, 55, 50, 45, 40....10, 5.

For a ten second firing (60, 50, 40, 30...10) set the custom value to minus 10 and the event to every 10 seconds.

Any further than that and you may have items vanishing too soon.
 
Level 9
Joined
Jul 3, 2008
Messages
495
You only need two simpel short triggers.

First: This will prevent the item to be removed if it has been picked up, and
then dropped again.
  • Events
    • Unit - A unit Acquires an item
  • Actions
    • Item - Set the custom value of (Item being manipulated) to 1
And this trigger will remove the item after 5 seconds if its not owned or have
been picked up before

JASS:
    local item i = CreateItem('ratc',0,0)
    call PolledWait(5)
    if GetItemUserData(i) == 0 then
        call RemoveItem(i)
    endif
    set i = null
 
Status
Not open for further replies.
Top