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

nearest hero problem

Status
Not open for further replies.
Level 11
Joined
Jul 12, 2005
Messages
764
Hi!
I have 2 questions:
1- How can i order my hero (with an ability of course) to teleport to the NEAREST enemy hero? I made an ability based on thunder clap, and reduced its data (AoE, damage, etc..) to 0. Then I tried to make a trigger to teleport my hero, but i don't know how to give the point of the nearest enemy hero...
2- The ability i seek acts this way: If its turned on, my hero morphs into a tree (like the destructible one) and gains an aura that damages nearby enemies. I couldn't get a unit, that has a tree model, so i did this way:
I based the ability on Burrow. The alternate form is my hero without a model file, so it becomes invisible when it is morphed. Then comes the trigger. When the ability is on, the trigger creates a tree in the position of the hero. But the problem is that the created tree is not exactly above my "invisible hero" in the game. And i couldn't add that aura to my hero.

i know it's a bit confusing but help me plz!!!
 
Level 11
Joined
Jul 20, 2004
Messages
2,760
1. I'll assume just as Daminon says. And so, you need to use two variables for this. One must be a real variable with the initial value of 0.00 (call it DistanceVal). The other one must be an unit variable (call it TargVal) And now:

Pick up every unit matching conditions (((MatchingUnit) is a Hero equal to true) and ((Matching Unit) is an enemy of (Triggering Unit) equal to true) and do actions
-> If Distance Between Position of ((Triggering Unit)) and Position of ((Picked Unit)) is less than DistanceVal then set VarValue=Distance Between (Triggering Unit) and (Picked Unit)
-> set TargVal = (Picked Unit)

- Move (Triggering Unit) to (Position of TargVal)

This should do it.

2. Ask for a modeler to help you get a tree as an unit. Then you only have to base your ability off bear form (or something similar), make sure that you have in fields the right unit types, make sure that the alternate form has dependency equivalent the first form. And of course, make sure that the second form has your aura. I would base it off cyclone damage aura (which damages buildings), and make it damage any units. If you want an icon for the aura itself (because this one doesn't have...), then you can just give the unit an unholy aura or some other passive with the right description, but no effect.

And you've done it, without triggers.

Do you have any other questions? Don't hesitate to post.

~Daelin
 
Level 11
Joined
Jul 20, 2004
Messages
2,760
Ooops, sorry, it doesn't work because I accidently searched for the nearest unit but I gave the initial value to 0, and of course there is no value less than 0. Give the variable an initial value of 9999999. This will solve your problem. Sorry again!

And I found another problem. You need to set this value at the beginning of the trigger (not only initial value) or the next time you cast the spell, it might not work, because the value at which the last closest hero was found will remain in the variable.

~Daelin
 
Level 11
Joined
Jul 12, 2005
Messages
764
Daelin!
"And so, you need to use two variables for this. One must be a real variable with the initial value of 0.00 (call it DistanceVal). The other one must be an unit variable (call it TargVal) And now:

Pick up every unit matching conditions (((MatchingUnit) is a Hero equal to true) and ((Matching Unit) is an enemy of (Triggering Unit) equal to true) and do actions
-> If Distance Between Position of ((Triggering Unit)) and Position of ((Picked Unit)) is less than DistanceVal then set VarValue=Distance Between (Triggering Unit) and (Picked Unit)
-> set TargVal = (Picked Unit)

- Move (Triggering Unit) to (Position of TargVal) "

You wrote that I have to use two variables. You wrote about DistanceVal, and TargVal. But then what is VarValue??

Thanx for the JASS, but first I'll try the triggered one! :)
 
Level 11
Joined
Jul 20, 2004
Messages
2,760
paskovich said:
You wrote that I have to use two variables. You wrote about DistanceVal, and TargVal. But then what is VarValue??

Probably a mistake... Sorry that I messed it up. I really didn't mean to. ;) Let's try this once again:

You need to use two variables for this. One must be a real variable (call it DistanceVal). The other one must be an unit variable (call it TargVal) And now:

set DistanceVal = 99999999
Pick up every unit matching conditions (((MatchingUnit) is a Hero equal to true) and ((Matching Unit) is an enemy of (Triggering Unit) equal to true) and do actions
-> If Distance Between Position of ((Triggering Unit)) and Position of ((Picked Unit)) is less than DistanceVal then set DistanceVal=Distance Between (Triggering Unit) and (Picked Unit)
-> set TargVal = (Picked Unit)

- Move (Triggering Unit) to (Position of TargVal) "- Move (Triggering Unit) to (Position of TargVal) "

Hopefully it works this time. Try once again please.

~Daelin
 
Level 11
Joined
Jul 12, 2005
Messages
764
I can't do that, 'cause warcraft is installed on an other computer. but i did exactly the same way how you've written. it teleports my hero to the first placed unit/hero in the editor, but not to the nearest one. so if i'd place for example an archmage in the corner of the map, and after that i'd place a warden or sg near my hero, the ability would teleport my hero to the archmage!
 
Level 13
Joined
Dec 29, 2004
Messages
597
I think Daelin's version works, even i don't use a compiler. Make sure to make it like this:

set DistanceVal = 99999999 //make sure to make this

Pick up every unit matching conditions (((MatchingUnit) is a Hero equal to true) and ((Matching Unit) is an enemy of (Triggering Unit) equal to true) and do actions
//The following 2 actions is IN the loop
-> If Distance Between Position of ((Triggering Unit)) and Position of ((Picked Unit)) is less than DistanceVal then set DistanceVal=Distance Between (Triggering Unit) and (Picked Unit)
-> set TargVal = (Picked Unit)
//END OF LOOP

//this action OUTSIDE the loop
- Move (Triggering Unit) to (Position of TargVal)
 
Status
Not open for further replies.
Top