1. Updated Resource Submission Rules: All model & skin resource submissions must now include an in-game screenshot. This is to help speed up the moderation process and to show how the model and/or texture looks like from the in-game camera.
    Dismiss Notice
  2. DID YOU KNOW - That you can unlock new rank icons by posting on the forums or winning contests? Click here to customize your rank or read our User Rank Policy to see a list of ranks that you can unlock. Have you won a contest and still havn't received your rank award? Then please contact the administration.
    Dismiss Notice
  3. We have recently started the 16th edition of the Mini Mapping Contest. The theme is mini RPG. Do check it out and have fun.
    Dismiss Notice
  4. Dismiss Notice
  5. The Highway to Hell has been laid open. Come along and participate in the 5th Special Effect Contest.
    Dismiss Notice
  6. Check out the Staff job openings thread.
    Dismiss Notice
Dismiss Notice
60,000 passwords have been reset on July 8, 2019. If you cannot login, read this.

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

Discussion in 'World Editor Help Zone' started by slovak27, May 15, 2019.

Tags:
  1. slovak27

    slovak27

    Joined:
    Aug 10, 2010
    Messages:
    64
    Resources:
    0
    Resources:
    0
    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 .
     
  2. Zepher

    Zepher

    Joined:
    May 14, 2019
    Messages:
    263
    Resources:
    0
    Resources:
    0
    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.
     
  3. Chaosium

    Chaosium

    Joined:
    Aug 29, 2012
    Messages:
    416
    Resources:
    2
    Models:
    2
    Resources:
    2
    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.
     
  4. Freddyk

    Freddyk

    Joined:
    Sep 7, 2013
    Messages:
    221
    Resources:
    10
    Models:
    9
    Icons:
    1
    Resources:
    10
    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
     
  5. Sabe

    Sabe

    Joined:
    Jul 30, 2018
    Messages:
    431
    Resources:
    1
    Spells:
    1
    Resources:
    1
    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: May 18, 2019
  6. Cespie

    Cespie

    Joined:
    May 21, 2019
    Messages:
    434
    Resources:
    0
    Resources:
    0
    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.
     
  7. Sabe

    Sabe

    Joined:
    Jul 30, 2018
    Messages:
    431
    Resources:
    1
    Spells:
    1
    Resources:
    1
    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.

    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.

    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: May 23, 2019
  8. Cespie

    Cespie

    Joined:
    May 21, 2019
    Messages:
    434
    Resources:
    0
    Resources:
    0
    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).

    Totally on board with this. I use a similar system with item arrays as loot tables.

    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.
     
  9. Sabe

    Sabe

    Joined:
    Jul 30, 2018
    Messages:
    431
    Resources:
    1
    Spells:
    1
    Resources:
    1
    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.

    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
     
  10. Barbaric Emu

    Barbaric Emu

    Joined:
    May 28, 2019
    Messages:
    13
    Resources:
    0
    Resources:
    0
    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
     
  11. Sabe

    Sabe

    Joined:
    Jul 30, 2018
    Messages:
    431
    Resources:
    1
    Spells:
    1
    Resources:
    1
    Umm, what's the point of the dummy unit attacking the item if you are going to remove it anyway?
     
  12. Barbaric Emu

    Barbaric Emu

    Joined:
    May 28, 2019
    Messages:
    13
    Resources:
    0
    Resources:
    0
    There's no trigger AFAIK to remove the item so the unit kills the item then the unit is removed.
     
  13. Sabe

    Sabe

    Joined:
    Jul 30, 2018
    Messages:
    431
    Resources:
    1
    Spells:
    1
    Resources:
    1
    There is. It's under Item -> Remove.
     
  14. Uncle

    Uncle

    Joined:
    Aug 10, 2018
    Messages:
    753
    Resources:
    0
    Resources:
    0
    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. Item Expiration and Indexer v2 is safe to use.
     

    Attached Files:

    Last edited: May 30, 2019
  15. slovak27

    slovak27

    Joined:
    Aug 10, 2010
    Messages:
    64
    Resources:
    0
    Resources:
    0
    Thank you guys , worked :p, sorry for late respone but I was abroad and working in a job all days , now I am back and I can finish mine work in world editor, thank you again.
    #closerequest