• 🏆 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!

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 63
Joined
Jan 18, 2005
Messages
27,197
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.
 
Level 29
Joined
Oct 24, 2012
Messages
6,543
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
 
Status
Not open for further replies.
Top