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

How can I make aquisition range ignore units behind?

Status
Not open for further replies.
Level 11
Joined
Jun 2, 2004
Messages
849
Impossible with base engine. Plausible to trigger if you're only using melee units. Difficult if not impossible to trigger for ranged units, since they need their object editor acquisition range to be greater than or equal to their attack range to actually fire their ranged attack.
 
Level 11
Joined
Oct 9, 2015
Messages
721
I have come up with the following triggers:
For both melee and ranged units,the unit holds it's position, but turns to face the other unit. If you come whithin attack range it will attack.

  • Stealth Debug
    • Events
      • Unit - A unit enters (Playable map area)
    • Conditions
    • Actions
      • Unit Group - Pick every unit in (Units in (Playable map area)) and do (Actions)
        • Loop - Actions
          • Trigger - Add to Stealth 1 <gen> the event (Unit - (Picked unit) Acquires a target)
  • Stealth 1
    • Events
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • ((Facing of (Triggering unit)) + 120.00) Greater than or equal to (Facing of (Targeted unit))
          • ((Facing of (Triggering unit)) - 120.00) Less than or equal to (Facing of (Targeted unit))
        • Then - Actions
          • Unit - Order (Triggering unit) to Hold Position
        • Else - Actions
 

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,286
It is set to 120 so the unit can't also see from it's sides, only in front.
It does not factor in angular wrap around and uses the facing of the targeted unit instead of the angle between triggering unit and target unit.

Try the single conditional test...
(Cos((angle_to_target) - (Facing of (Triggering unit)))) Less than or equal (Cos(120))

where angle_to_target is the angle from triggering unit position to target unit position. Since locations leak if not cleaned up it cannot be in lined into the test without at least assigning the points (locations) to variables for clean-up later. This works by using the symmetric nature of cosine around 0 and 180 degrees. It is also faster than other tests due to less JASS virtual machine overhead despite technically being a more complex operation.
 
Level 11
Joined
Oct 9, 2015
Messages
721
Dr Super Good condition returns true either if the unit is behind or front, maybe I did something wrong:
  • ((Cos((Angle from (Position of (Triggering unit)) to (Position of (Targeted unit))))) - (Facing of (Triggering unit))) Less than or equal to (Cos(120.00))
Fruit Forest: If I set the Sight Radius stat to 0 the unit still attacks because of it's aquisition range, if the acquisition range is set to 0, then the unit won't attack neither units in front or in the back
 
Level 11
Joined
Oct 9, 2015
Messages
721
I'll explore your suggestion, apparently it works on a clean test map, but not in my map. I'll see to it then come post the results.

EDIT: Ok, it works, however it only works if fog of war and black mask are activated. There's still the issue of how to set the vision of the dummy unit to be equal of the other unit. I needed it to work with black mask and fog of war desactivated too. I tried to deactivate blackmask and fog of war for 1 player only with GetLocalPlayer but had no success.
 
Last edited:
Level 11
Joined
May 16, 2016
Messages
730
It works now, who would dare to say it was such a easy sulution. Now the only problem is: How I will set the dummy unit vision (sight radius) to be equal to the unit's acquisition range?
The vision range can't be regulated with triggers, but you may use item bonus which increases vision sight. Create more such abilities and add it to dummy unit according to their acquistion range.
 
Level 11
Joined
May 16, 2016
Messages
730
you know which ability has that? I look for goblin scope and found nothing.
Goblin scope item ability is the right ability. (Find Goblin scope in the item list and determine its item ability) It doesn't leveled so you have to create more abilities with various values of vision sight.

EDIT or create few dummies with various vision range values.
 
Last edited:
Level 11
Joined
Oct 9, 2015
Messages
721
All right, so I have come up with the following triggers and it's working agaisnt non-user controlled players. Maybe we can post this on resource section as an Stealth System, but of course it may need some adjustments. To make it work with user-controlled units we just need to ignore the Stealth Debug trigger, the fog of war and black mask will be enabled and the units will be able to see only at front to the limit of their acquisition range. Maybe we can post this on resource section as a Stealth System, after doing the necessary adjustments if needed.

Trigger to configure user controlled player's vision
  • Stealth Debug
    • Events
      • Time - Elapsed game time is 1.00 seconds
    • Conditions
    • Actions
      • Player Group - Pick every player in (All players controlled by a User player) and do (Actions)
        • Loop - Actions
          • Visibility - Create an initially Enabled visibility modifier for (Picked Player) emitting Visibility across (Playable map area)
Periodic trigger that creates and adjusts the dummy unit's vision
  • Stealth Periodic
    • Events
      • Time - Every 0.50 seconds of game time
    • Conditions
    • Actions
      • Unit Group - Pick every unit in (Units in (Playable map area)) and do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • DummyVision[(Custom value of (Picked unit))] Equal to No unit
            • Then - Actions
              • Set Loc1 = ((Position of (Picked unit)) offset by (Current acquisition range of (Picked unit)) towards (Facing of (Picked unit)) degrees)
              • Unit - Create 1 Dummy Unit for (Owner of (Picked unit)) at Loc1 facing Default building facing degrees
              • Set DummyVision[(Custom value of (Picked unit))] = (Last created unit)
              • Custom script: call RemoveLocation(udg_Loc1)
            • Else - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • VisionAdjust[(Custom value of DummyVision[(Custom value of (Picked unit))])] Equal to False
                • Then - Actions
                  • Set Loc1 = ((Position of (Picked unit)) offset by (Current acquisition range of (Picked unit)) towards (Facing of (Picked unit)) degrees)
                  • Unit - Move DummyVision[(Custom value of (Picked unit))] instantly to Loc1
                  • Set VisionInteger = (Integer((Current acquisition range of (Picked unit))))
                  • Set Some_Unit = DummyVision[(Custom value of (Picked unit))]
                  • Trigger - Run Stealth Vision <gen> (ignoring conditions)
                  • Custom script: call RemoveLocation(udg_Loc1)
                • Else - Actions
Trigger to make the sight radius of the dummy unit be equal to the acquisition range of the unit it follows
  • Stealth Vision
    • Events
    • Conditions
    • Actions
      • Set VisionInteger = (VisionInteger - (Integer((Current acquisition range of Some_Unit))))
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • VisionInteger Greater than 0
        • Then - Actions
          • Set Loop_Integer = ((VisionInteger - (VisionInteger mod 100)) / 100)
          • For each (Integer A) from 1 to Loop_Integer, do (Actions)
            • Loop - Actions
              • Unit - Add Vision to Some_Unit
              • Unit - Set level of Vision for Some_Unit to 4
              • Unit - Remove Vision from Some_Unit
          • Set VisionInteger = (VisionInteger mod 100)
          • Set Loop_Integer = ((VisionInteger - (VisionInteger mod 10)) / 10)
          • For each (Integer A) from 1 to Loop_Integer, do (Actions)
            • Loop - Actions
              • Unit - Add Vision to Some_Unit
              • Unit - Set level of Vision for Some_Unit to 3
              • Unit - Remove Vision from Some_Unit
          • Set VisionInteger = (VisionInteger mod 10)
          • For each (Integer A) from 1 to Max_Hp, do (Actions)
            • Loop - Actions
              • Unit - Add Vision to Some_Unit
              • Unit - Set level of Vision for Some_Unit to 2
              • Unit - Remove Vision from Some_Unit
        • Else - Actions
          • Set VisionInteger = (0 - VisionInteger)
          • Set Loop_Integer = ((VisionInteger - (VisionInteger mod 100)) / 100)
          • For each (Integer A) from 1 to Loop_Integer, do (Actions)
            • Loop - Actions
              • Unit - Add Vision to Some_Unit
              • Unit - Set level of Vision for Some_Unit to 7
              • Unit - Remove Vision from Some_Unit
          • Set VisionInteger = (VisionInteger mod 100)
          • Set Loop_Integer = ((VisionInteger - (VisionInteger mod 10)) / 10)
          • For each (Integer A) from 1 to Loop_Integer, do (Actions)
            • Loop - Actions
              • Unit - Add Vision to Some_Unit
              • Unit - Set level of Vision for Some_Unit to 6
              • Unit - Remove Vision from Some_Unit
          • Set VisionInteger = (VisionInteger mod 10)
          • For each (Integer A) from 1 to Max_Hp, do (Actions)
            • Loop - Actions
              • Unit - Add Vision to Some_Unit
              • Unit - Set level of Vision for Some_Unit to 5
              • Unit - Remove Vision from Some_Unit
      • Set VisionAdjust[(Custom value of Some_Unit)] = True
 
Last edited:
Level 11
Joined
Oct 9, 2015
Messages
721
I think there's no need for getlocalplayer on the stealth debug trigger anyway (if that's what will cause OOS). how can we improve stealth periodic ?

By the way this system isn't working with neutral hostile units, can anyone guess why ?
 
Last edited:
Status
Not open for further replies.
Top