Unit comes in range of Unit-Type?

Status
Not open for further replies.
Is there a way to set up an event for when a unit comes close enough to another unit, but making it generic so I can pick a unit-type instead of a unit pre-placed on the map?

And a follow-up question, can individual objects be revealed in the Fog of War?

Which event are you using?

A naive approach might be to just pick every unit within your range, and check it's unit type.
 
No, I need to be able to pick the unit that the other units are coming in range of. That isn't pre-placed on the map, like how the event normally works.

Basically, what I want to do is -

This unit has a normal sight range, but slightly beyond that sight range it can detect units in the Fog of War without actually having to see them, but not actually revealing the unit itself that's being seen. Just showing that something is in fact there.

Like the Sensor Tower in StarCraft II

EDIT:

"Enemies under fog of war within the range of the Sensor Tower are marked with a red symbol displaying an exclamation mark."

EDIT2: Maybe I could use an Aura? We'll see. If I can get this functioning, I'll edit this post again for Future References.
 
Last edited:
No, I need to be able to pick the unit that the other units are coming in range of. That isn't pre-placed on the map, like how the event normally works.

Basically, what I want to do is -

This unit has a normal sight range, but slightly beyond that sight range it can detect units in the Fog of War without actually having to see them, but not actually revealing the unit itself that's being seen. Just showing that something is in fact there.

Like the Sensor Tower in StarCraft II

EDIT:

"Enemies under fog of war within the range of the Sensor Tower are marked with a red symbol displaying an exclamation mark."

The units don't have to be preplaced to do this, depending on the event you are choosing. How is the trigger firing off? Here is some half-JASS code to illustrate my point.

JASS:
private function main takes nothing returns boolean
  local unit u
  //code for figuring out how to get the unit
  ...
  //now pick out every unit in your defined ranged
  for each unit within someDistance of u do:
     ...
  endfor
  ...
  return false
endfunction

endfunction

private function init takes nothing returns nothing
 local trigger t = CreateTrigger()
 call TriggerRegisterSomeEvent(t, ...)
 call TriggerAddCondition(t, Condition(function main))
endfunction

It will depend on what kind of event you are using to fire off the trigger. If it's not one that involves a (player) unit event, then you need to search for the unit from one of your data structures.
 
  • Trigger
    • Events
      • Unit - A unit enters (Playable map area)
    • Conditions
      • (Unit-type of (Triggering unit)) Equal to Your Unit Type
    • Actions
      • Trigger - Add to (Your Trigger) the event (Unit - A unit comes within 1000.00 of (Triggering unit))
 
Here is my finished trigger to do what I wanted to do. This is for future references, in case anybody comes searching for this.

  • Sense Effect P1
    • Events
      • Time - Every 0.10 seconds of game time
    • Conditions
    • Actions
      • Set UnitsOnMap = (Units in (Playable map area))
      • Unit Group - Pick every unit in UnitsOnMap and do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • ((Picked unit) has buff Sense ) Equal to False
            • Then - Actions
              • Custom script: call DestroyGroup(udg_UnitsOnMap)
              • Custom script: call RemoveLocation(udg_UnitPositionP1)
              • Custom script: call DestroyGroup(udg_CreatedUnit)
            • Else - Actions
              • Set UnitPositionP1 = (Position of (Picked unit))
              • Unit - Create 1 Dummy Sense Unit for ArcherSightP1 at UnitPositionP1 facing UnitPositionP1
              • Set CreatedUnit = (Last created unit group)
              • Unit - Kill (Random unit from CreatedUnit)
              • Custom script: call DestroyGroup(udg_UnitsOnMap)
              • Custom script: call DestroyGroup(udg_CreatedUnit)
              • Custom script: call RemoveLocation(udg_UnitPositionP1)
 
Status
Not open for further replies.
Back
Top