• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

preventing item destruction trigger

Status
Not open for further replies.
Level 30
Joined
Nov 29, 2012
Messages
6,637
Well you need to store the item's position and the item into a variable.

You will have to make many triggers for each time then you will have to set some variables:

  • Set LastCreated_Item = (Last created item)
  • Set Item_Position = (Position of Last created_Item)
I think after this you will have to scan if the item got destroyed equal to your Last created item, create again the last Created item at the Item_Position
 
Level 20
Joined
Apr 14, 2012
Messages
2,901
  • Item Creation
  • Events
  • Conditions
  • Actions
  • Set Point = (Center of Playable Ma Area)
  • For Each Integer A from 1 to 10, do Actions
    • Loop - Actions
      • Item - Create 1 Item at Point
      • Set Item[Real(Integer A)] = Last Created Item
      • Set ItemPoint[Real(Integer A)] = Position of Item[Real(IntegerA)]
There to make it simple. If you want to refer to the item just do so by Item[1], Item[2]... Just make another loop for another item.
 

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,258
Store all such items in an item array as a list.
Every 1 to 5 seconds you get an item from the list and check where it is or if it is alive. If such checks fail, you remove/recreate or move it to the safe position. The reason you check a single item at a time is the polling does not require a high period (as long as it eventually respawns the item) and if there are a lot of items it could cause performance problems every time the check is run in parallel to other reasonable demanding triggers.

The best way to get items is to cycle through the list 1 element each period.
 
here this should work.
this will work with up to 8190 items in ur map.

use these 2 functions to add and remove the items from the items to keep.
  • Register
    • Events
    • Conditions
    • Actions
      • -------- --------
      • -------- Use this to store item into the index --------
      • -------- --------
      • Custom script: endfunction
      • Custom script: function StoreItemToKeep takes item tempItem returns nothing
      • Set itemToKeepIndex = (itemToKeepIndex + 1)
      • Set itemToKeepItem[itemToKeepIndex] = tempItem
      • Set itemToKeepPosition[itemToKeepIndex] = (Position of itemToKeepItem[itemToKeepIndex])
      • -------- --------
      • -------- Use this to remove item from the index --------
      • -------- --------
      • Custom script: endfunction
      • Custom script: function RemoveItemToKeep takes item tempItem returns nothing
      • For each (Integer tempInt) from 1 to itemToKeepIndex, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • itemToKeepItem[tempInt] Equal to tempItem
            • Then - Actions
              • Set itemToKeepItem[tempInt] = itemToKeepItem[itemToKeepIndex]
              • Custom script: call RemoveLocation( udg_itemToKeepPosition[ udg_tempInt])
              • Custom script: set udg_itemToKeepPosition[ udg_tempInt] = null
              • Set itemToKeepIndex = (itemToKeepIndex - 1)
            • Else - Actions
this is how u store items.
just set item to an item variable then change the urItem word.
  • Custom script: call StoreItemToKeep( udg_urItem)
this is how u remove an item that u dont want to keep alive anymore.
Same concept as above
  • Custom script: call StoreItemToKeep( udg_urItem)
this one checks the items health to see if it is alive every .25 seconds. if it isnt it removes the old item to make sure there are no leaks then places a new item of the same type at the location it was originally at.
  • Check
    • Events
      • Time - Every 0.25 seconds of game time
    • Conditions
    • Actions
      • For each (Integer tempInt) from 1 to itemToKeepIndex, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Current life of itemToKeepItem[tempInt]) Less than 0.41
            • Then - Actions
              • Item - Remove itemToKeepItem[tempInt]
              • Item - Create (Item-type of itemToKeepItem[tempInt]) at itemToKeepPosition[tempInt]
              • Set itemToKeepItem[tempInt] = (Last created item)
            • Else - Actions
 
deathismyfriend, the polling period is far too high and it will not pick up items that have fallen into inaccessible places (such as the bottom of water).

im not sure how fast he wanted this he can change the time to fit his needs.

as for moving the items that are in water i didnt know thats what he wanted ?
 
Status
Not open for further replies.
Top