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

Attack Range of Unit

Status
Not open for further replies.
Level 12
Joined
Sep 11, 2011
Messages
1,176
Not possible.

But you can check the distances between attacking and attacked unit.
  • Untitled Trigger 001
    • Events
      • Unit - A unit Is attacked
    • Conditions
    • Actions
      • Set tempPoint = (Position of (Triggering unit))
      • Set tempPoint2 = (Position of (Attacking unit))
      • Set Distance = (Distance between tempPoint and tempPoint2)
      • Custom script: call RemoveLocation(udg_tempPoint)
      • Custom script: call RemoveLocation(udg_tempPoint2)
 
Level 6
Joined
Nov 24, 2012
Messages
218
If it's just one unit, you do this:
  • Set Get_Attack_Range = ((Current acquisition range of Target_Unit) - 400.00)
In this example, the Target_Unit's Acquisition Range is 1000 and it's Attack Range is 600 (Which is why you subtract 400 here).

If it's lots of units, you must set acquisition range to be proportional to attack range so that you can subtract 400 to all or something like that.
If you don't want to make proportional, you can use unit point-values as a multiplier to calculate attack range (eg. Range = (Acquisition - 400 )(0.01 * unit point value)), or something along those lines.
 
Last edited:
Level 6
Joined
Nov 24, 2012
Messages
218
Hmm.. I see. Then, is there any way to check range? Just like in Element TD; where you type "-range xxx", you can see the light there indicating the range of it from the unit that you select if I'm not mistaken.

Yup. Just do what I said. Use Acquisition Range.
Edit: I am suddenly confused.
Do you want to check for tower attack ranges? Or.... do you want a -range xxx indication trigger?
 
Level 6
Joined
Nov 24, 2012
Messages
218
Yeah, you can cache all of your units like that.
What I did when I coded for a TD before was set all tower Acquisition Range = Attack Range.
Here is a copy paste of Attack Range indicator spell on TD towers I made a while ago:
  • Range Checker
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Range Checker
    • Actions
      • Set Attack_Range = (Default acquisition range of (Casting unit))
      • Set NumberOfRangeIndicators = 20
      • For each (Integer A) from 1 to NumberOfRangeIndicators, do (Actions)
        • Loop - Actions
          • Set TempReal = (TempReal + (360.00 / (Real(NumberOfRangeIndicators))))
          • Set TempPoint = ((Position of (Casting unit)) offset by (Attack_Range + 50.00) towards TempReal degrees)
          • -------- I added extra 50 range because the dummies visuals were showing range to be slightly less than what it really was. --------
          • Unit - Create 1 DummyIndicator for (Triggering player) at TempPoint facing Default building facing degrees
          • Unit - Add a 4.00 second Generic expiration timer to (Last created unit)
          • Custom script: call RemoveLocation (udg_TempPoint)
For -range xxx trigger, the trigger is almost the same, but incorporate something like this to it:
  • Set Attack_Range = (Real((Substring((Entered chat string), 8, (Length of (Entered chat string))))))
(why 8? because -range xxx : - = 1, r = 2, a = 3, n = 4, g = 5, e = 6, space = 7, integer value = 8 to end of chat string)
 
Last edited:
Status
Not open for further replies.
Top