• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

is in range of unit type a possibility question

Level 7
Joined
Nov 6, 2019
Messages
186
ok is it possible to set up a condition, to check if for example

udg_Hero[bjloopaindex] comes within range of "unit Type Footman" Then, kill Footman, heal uda_hero

  • (Distance between (Position of Unit1[1]) and (Position of Unit2[(Player number of (Player((Integer A))))])) Greater than or equal to 400.00
Like this but instead of unit2, position of a unit type.


Basically i am trying to set up a mechanic

at one side of the room 1 of 5 dif creatures will spawn, there set to locust so cant kill
they will travel across the room, and if a players hero comes within 25 range of the creature, the creature will die making a effect happen

the effect depends on what creature it is that spawns as it random out of 5

1 gonna heal the boss, 1 will damage the boss, 1 will damage the player, 1 will heal the player, 1 will give the player score basically

1 will spawn each time the creature hits the center and when the creature hits other side it will despawn, so they will be 3 active at a time, and it be random.
 
Last edited:
Level 24
Joined
Jun 26, 2020
Messages
1,852
For that you will need to check every unit of type in that range, also you want "Greater than or equal to 400.00" or "Lesser than or equal to 400.00"?:
  • Set VariableSet TempBool = False
  • -------- --------
  • Set VariableSet TempPoint = (Position of Unit[1])
  • Set VariableSet TempGroup = (Units within 400.00 of TempPoint matching ((Unit-type of (Matching unit)) Equal to Soldado).)
  • Unit Group - Pick every unit in TempGroup and do (Actions)
    • Loop - Actions
      • Set VariableSet TempBool = True
  • Custom script: call DestroyGroup(udg_TempGroup)
  • Custom script: call RemoveLocation(udg_TempPoint)
  • -------- --------
  • -------- Now use TempBool --------
 
Level 7
Joined
Nov 6, 2019
Messages
186
Within 25 range basically you to run over it

I assume bool is a real variable

And how would I get it to work for multiple players

And does it have to be on a time to keep checking, then for use bool is it unit in range of bool
 
Level 24
Joined
Jun 26, 2020
Messages
1,852
Ok, that is another story, you will need to do something different, like nested group loops:
  • Set VariableSet TempGroup = (Units of type <Your locust>)
  • Unit Group - Pick every unit in TempGroup and do (Actions)
    • Loop - Actions
      • Set VariableSet TempPoint = (Position of (Picked unit))
      • Set VariableSet TempGroup2 = (Units within 25.00 of TempPoint matching (((Owner of (Matching unit)) controller) Equal to User).)
      • Custom script: call RemoveLocation(udg_TempPoint)
      • Unit Group - Pick every unit in TempGroup2 and do (Actions)
        • Loop - Actions
          • Unit - Kill (Picked unit) // Or some other action
      • Custom script: call DestroyGroup(udg_TempGroup2)
  • Custom script: call DestroyGroup(udg_TempGroup)
 

Uncle

Warcraft Moderator
Level 64
Joined
Aug 10, 2018
Messages
6,543
An addition to Herly's suggestion.

For efficiency purposes it would be nice to track the Locust creatures manually in their own unique Unit Group variable:
  • Unit - Create 1 Locust Creature...
  • Unit Group - Add (Last created unit) to Boss_Locusts
Then you don't need to create TempGroup over and over again:
  • Unit Group - Pick every unit in Boss_Locusts and do (Actions)
Don't forget to Remove them from the group when they're killed.

It's a minor change but something to think about when designing these types of triggers. You could even use a Unit Group for your Heroes (you probably already have one), assuming that you only want Heroes to be able to "step on" these creatures. That would eliminate the need to create new Unit Groups over and over again.
 
Top