• 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.

Closest Tree?

Status
Not open for further replies.
Rrrright, so this is a question I asked before, but for some reason replicating the same instructions bugged out... mostly because GetClosestWidget doesn't seem to work anymore?

I'm trying to make a unit harvest a tree (all done via triggers), and once the harvesting is complete, the unit picks the nearest tree and repeats. I copied the code for GetClosestWidget and IsDestructableTree, but when I save with JNPG (5d), it tells me this:

116571-albums7711-picture91788.jpg


I'm also encountering some weird issues like the target tree not dying. I'm using Eat Tree as my base spell to target the tree, and store that tree in a variable with the custom value of the havester. The custom eat tree is removed and channeling ability is added to be ask when the harvester moves over the tree. When the channeling finishes, the tree is destroyed and lumber is harvested. Kill destructible doesn't seem to work though. I'm using Bribe's Unit Indexer.

Concerning the GetClosestWidget, I need it to pick up the nearest tree that isn't dead. Preferably a tree that isn't already being targeted/worked on by another harvester.
 
Well I stored the tree in a variable with the custom value of the harvester as the array (I'm using Bribe's Unit Indexer), and then using Kill Destructible, but nothing is happening. I tried picking the destructible or creating a unit with a modified eat tree to right-click on it - nothing worked. The only workaround I found that worked was to make a unit cast a custom Force of Nature at the tree's location. In the end this worked in my favour because the way I had triggered the harvesting, two harvesters could technically harvest the same tree once each (checking if the tree was alive after an alotted time did not work as well), so instead I made the FoN spawn a custom unit that provided the player with lumber as it entered the map.

I spose this thread can be closed now. Thankyou to both of you who took the time to respond :)
 
Status
Not open for further replies.
Top