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

[Trigger] Add/remove ability when range

Status
Not open for further replies.
Level 15
Joined
Jan 27, 2007
Messages
948
How do I achieve this? I want to make that units get an ability whenever they are close to another unit with that ability. Kind of a plague system.

But i'm struggling with the event.

  • Unit - A unit comes within 256.00 of No unit
Only options are "No unit" or a variable... what??? where is "any unit" or unit group D:

Any help is appreciated! thanks :(
 
Last edited:
Level 14
Joined
Nov 30, 2013
Messages
926
Is this will work for you?
  • Trigger - Add to (What Trigger) the event (Unit - A unit comes within 256.00 of (Ability-Gaining unit))
Add that when the unit is made through initialization or when created in Unit Action.
If the unit is non-hero, I guess that event can leak.
 

Chaosy

Tutorial Reviewer
Level 40
Joined
Jun 9, 2011
Messages
13,183
There is no solution in GUI.

What bear shows works but it leaks because the event will remain even after the unit is dead.
What you would want to do is to create one trigger (with code) per unit. And when a unit dies destroy the entire trigger. You can attach the trigger to a unit easily with a hashtable if you know how to use those.
 
Level 15
Joined
Jan 27, 2007
Messages
948
ackkk, but it's a melee/strategy map, there are so many units

-edit-

alright i managed to do something about it, i'm sharing it in case someone else needs it :)
thanks for the help guys!

  • Plague spread and damage
    • Events
      • Time - Every 3.00 seconds of game time
    • Conditions
    • Actions
      • Set UnitGroup = (Units in (Playable map area) matching (((Matching unit) has buff Sickness ) Equal to True))
      • Unit Group - Pick every unit in UnitGroup and do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Level of Plague Bearer for (Picked unit)) Equal to 0
            • Then - Actions
              • Unit - Add Plague Bearer to (Picked unit)
            • Else - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Life of (Picked unit)) Greater than 5.00
                  • (Unit-type of (Picked unit)) Not equal to Undead
                  • (Unit-type of (Picked unit)) Not equal to Rat
                • Then - Actions
                  • Unit - Set life of (Picked unit) to ((Life of (Picked unit)) - 3.00)
                • Else - Actions
      • Custom script: call DestroyGroup(udg_UnitGroup)
 
Last edited:
Status
Not open for further replies.
Top