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

Aura that gives nearby units an ability?

Status
Not open for further replies.
Level 31
Joined
Apr 17, 2009
Messages
3,572
Hey Guys, following problem:

I have some kind of berry picking system for what I have a Berry Picking ability that can be used on a berry bush.

What I need is, that you only get this ability if you are close to a bush. So my idea was to make an aura for the berry bush that gives nearby units the ability berry picking.

Is that possible? If not, how do I detect if a unit gets in range of the berry bush?

Greets chilla_killa
 
Level 12
Joined
Feb 22, 2010
Messages
1,115
I think with aura method, you should check if the units have aura or no.

BerryPickers unitgroup variable
  • Detect Berry
    • Events
      • Time - Every 1.00 seconds of game time
    • Conditions
    • Actions
      • -------- Check if there are any units near bushes --------
      • Unit Group - Pick every unit in (Units in (Playable map area) matching ((((Matching unit) has buff BERRYAURABUFF) Equal to True) and ((Unit-type of (Matching unit)) Equal to GATHERER))) and do (Actions)
        • Loop - Actions
          • Unit - Add BERRYPICK to (Picked unit)
          • Unit Group - Add (Picked unit) to BerryPickers
      • -------- If a unit goes away from bushes, remove picking ability --------
      • Unit Group - Pick every unit in BerryPickers and do (Actions)
        • Loop - Actions
          • Unit - Remove BERRYPICK from (Picked unit)
          • Unit Group - Remove (Picked unit) from BerryPickers
 
Level 28
Joined
Sep 26, 2009
Messages
2,520
You can save point of each bush into variable array. Periodically (like every second) make a trigger where you pick unit, save its position into another variable, set some random bool to false and iterate through each point in the variable array and check the distance between the unit and saved point. If distance is close enough, set bool to true.
Once the loop is finished, check if bool == true - if yes, add ability; if no, remove ability.
 
Nichilus' idea.
Or you can give the berry bushes a dummy aura and run a periodic trigger which checks if a unit has the aura buff. If true then add the pick ability and set a boolean to true.
If not, set the boolean to false and remove the buff.

The reason for the boolean is to check if the unit already has the ability when staying near a bush.
 
Level 12
Joined
May 20, 2009
Messages
822
Nichilus' idea.
Or you can give the berry bushes a dummy aura and run a periodic trigger which checks if a unit has the aura buff. If true then add the pick ability and set a boolean to true.
If not, set the boolean to false and remove the buff.

The reason for the boolean is to check if the unit already has the ability when staying near a bush.

You actually don't need to set a variable or even check if the unit already has the ability, because if the ability being added to the unit has the same ID, it won't do anything. Or at least that's from my experience. I have several abilities in my mod that adds a new ability to a unit in a spellbook, and it never seems to interrupt things or stack or reset cooldowns or cause lag.
 
You actually don't need to set a variable or even check if the unit already has the ability, because if the ability being added to the unit has the same ID, it won't do anything. Or at least that's from my experience. I have several abilities in my mod that adds a new ability to a unit in a spellbook, and it never seems to interrupt things or stack or reset cooldowns or cause lag.

Probably. I wasn't sure so I just threw in the boolean for safety.
 
Status
Not open for further replies.
Top