• 🏆 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!

[Solved] Unit comes within range of unit type

Status
Not open for further replies.
Level 7
Joined
Dec 9, 2014
Messages
89
Hi,

I want the computer player to cast an ability when a unit type with that ability enters the range of any unit.

I encountered the problem that you can't check for unit type, so I tried this workaround method of adding an event through a trigger:


  • trigger events
    • Events
      • Time - Elapsed game time is 0.00 seconds
    • Conditions
    • Actions
      • Unit Group - Pick every unit in (Units of type Troll Trapper) and do (Actions)
        • Loop - Actions
          • Trigger - Add to trap <gen> the event (Unit - A unit comes within 400.00 of (Picked unit))
  • trap
    • Events
    • Conditions
    • Actions
      • Unit - Order (Picked unit) to Orc Raider - Ensnare (Triggering unit)
This method works to fire the second trigger, but I can only refer to the unit entering range within the second trigger and not picked unit.

How do I get this working and is there another way? I thought about using periodical check, but too many periodical checks causes lag right?

I was also wondering if using unit group - pick every unit through an event add will leak once or every time the second trigger fires, and how to clean that up: if I use
  • Custom script: set bj_wantDestroyGroup = true
then the second trigger won't fire.
 
Status
Not open for further replies.
Top