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

Unit within range (continued)

Status
Not open for further replies.
Level 9
Joined
Mar 27, 2009
Messages
309
I am making a trigger that checks for units within range of a unit.

There are 2 units that are checking for units within range.

I am spawning units and sending them between the two units.

The problem is that when units spawn at one side, they get picked up by that unit, instead of by the one they are going to.

I tried adding a custom value, making units from point A have an ID of 1 and B ID of 2, but they still instantly get recognized.

Sry if this is vague, it's pretty late.

I plan on adding like 100 units to the within range events, so I would imagine there could be a lot of units being picked up by the wrong... units..
 
What doesnt work? You set the custom value to the index of unit it has go to?

Unit[1] = UnitA //unit 1 that checks unit in range
Unit[2] = UnitB //unit 2 that checks unit in range
__________________________________

  • Unit - Create Unit U at Point P1
  • Unit - Set Custom Value of LastCreatedUnit = 1 or 2
  • Unit - Order LastCreatedunit to move to P2
And if you check units in range of Unit[1] and Unit[2] -->
  • For each Integer I from 1 to 2
    • Unit Group - Pick.....
    • If - Conditions
      • CustomValueOf(PickedUnit) == I
        • Then - Actions
          • Game - Successfully recognized
        • Else - Actions
          • Game - Unit is in wrong area
 
Level 9
Joined
Mar 27, 2009
Messages
309
  • Events
    • Unit - A unit comes within 175.00 of Mars 0012 <gen>
    • Unit - A unit comes within 175.00 of Starbase 0008 <gen>
    • Unit - A unit comes within 175.00 of Earth 0000 <gen>
  • Unit Group - Pick every unit in (Units within 200.00 of (Position of INDEXPlanet[Target Planet][(Integer((Mana of (Entering unit))))]) matching ((Unit-type of (Matching unit)) Equal to Single Fleet)) and do (Actions)
    • Loop - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Mana of (Picked unit)) Equal to (Mana of INDEXPlanet[Target Planet][(Integer((Mana of (Entering unit))))])
        • Then - Actions
          • Game - Success
          • Else - Actions
          • Game - Not at right planet, dont do anything
I'm using mana actually, since custom values are for something else.

As so in addition to having each unit have it's own range event, you also need a local check as well once it gets there, I see...

I made the local check a bit bigger, since things can move abit, and it can miss the unit in the check.

The problem was that without the local check, each planet would fire this trigger, and the unit would register as at the target planet when it spawned at the starting planet.

Another day, another way to break the editor! :D

+rep (if i could, it won't let me lol)
 
Status
Not open for further replies.
Top