[Trigger] Pick Units and Revive at Nearest?

Status
Not open for further replies.
Level 6
Joined
Aug 12, 2007
Messages
201
I'm trying to make a revive system for my Heroes, when they die I want it to pick all Chapels or Altars in the map, pick the nearest one, and resurrect the Hero there. Picking the buildings is no problem, but I can't find a trigger for something like a a Nearest command, how would you do this normally?

EDIT: I found somewhat of a example here, except I get stuck at "Set Distance[2] = (Distance between Point[1] and Point[2])", I can't find a difference between function to set by.
 
Level 11
Joined
Dec 31, 2007
Messages
780
here is the main idea:

you use a unit group and pick every building that can ress him.

now you search inside the unit group for all of the buildings inside the unit group you made doing this
  • set X position of dying unit
  • set building = random unit from (ress buildings group)
  • set Z = position of building
  • unit group- pick every unit in (ress buildings group) and do
    • loop
      • set Y position of picked unit
      • if distance between X and Y less than (distance between X and Building)
        • then
          • ----building is the nearest
        • else
          • set building = picked unit
      • custom script: call RemoveLocation(udg_Y)
  • custom script: call RemoveLocation(udg_X)
  • custom script: call RemoveLocation(udg_Z)
  • ress unit at Building <--- the nearest
 
Status
Not open for further replies.
Top