Hi.
Im making a map where unit get minerals for being within range to an enemy unit. At the moment, I use
Unit Enters/Leaves Range Of Unit
Unit: Any Unit
State: Enters
Range: 15.0
From Unit: Immortal [67.36, 64.04]
But there are 2 problems with this, first of all, this only works when I enter range of the one spesific unit, how can I set this to "Any unit enters within 15 range from Nearest enemy unit"?
Another issue I have, how can I make the range a variable? The variable I wanna use is the attack range of the nearest enemy unit.
Unit - heroes[(Triggering player)] Enters a distance of 15.0 from (Closest unit to (Position of heroes[(Triggering player)]) in (Any units in (Entire map) owned by player Any Player matching No Unit Filter, with at most Any Amount))
Note that
Unit - heroes[(Triggering player)] Enters a distance of 15.0 From Unit: Immortal [67.36, 64.04]
works perfectly, but as soon as I add any form of variable, it doesn't work.
Heroes is an array of units that each player own (player only owns one unit).
Glancing at your second post:
Unit - heroes[(Triggering player)] Enters a distance of 15.0 from (Closest unit to (Position of heroes[(Triggering player)]) in (Any units in (Entire map) owned by player Any Player matching No Unit Filter, with at most Any Amount))
Is this an event? Like, if you consider what you wrote there, you're saying if heroes[1] enters a distance of 15.0 from (closest unit to (position of heroes[1])).. I'm not sure this will ever trigger since the only way it would is if the unit some how enters a distance of 15 from itself.
Maybe try: Unit - Any Unit enters a distance of 15.0 from (Closest unit to (Position of heroes[1]) in (Any units in (Entire map) owned by player Any Player matching No Unit Filter, with at most Any Amount))
Unit - Any Unit enters a distance of 15.0 from (Closest unit to (Position of heroes[2]) in (Any units in (Entire map) owned by player Any Player matching No Unit Filter, with at most Any Amount))
Unit - Any Unit enters a distance of 15.0 from (Closest unit to (Position of heroes[3]) in (Any units in (Entire map) owned by player Any Player matching No Unit Filter, with at most Any Amount))
etc, do it for each "heroes" in your array, basically saying if anyone gets 15 from your hero, run this event.
Actually though, you may have to split up the events since I don't see a traceback to identify which unit the triggering unit entered, so yeah. seperate into multiple events for each hero, and do your mineral generation based on that.
I don't know what entirely you're trying to do, personally I'd recommend using a persistent Search Area effect looking for enemies with a sort option of nearest enemy, then use an effect to modify miinerals (generate) based on that, but I don't know all your conditions to meet this scenario, it'd just be easier to manage in the long run I think if it's a general universal thing.
You can also consider using Attach Region to Unit, and then using the region as a means to identify units entering, but that probably won't be much different than the above.
I tried Unit - Any Unit enters a distance of 15.0 from (Closest unit to (Position of heroes[1]) in (Any units in (Entire map) owned by player Any Player matching No Unit Filter, with at most Any Amount))
and it did work. Just the way I wanted. But this seems to be a little too "static".. Ill have to make a bunch of triggers for each team then?
Another issue I have is, I have 2 enemies on the map, when I enter distance of 15 for the closest enemy upon start, it works, but when I move away from him and enter distance of 15 to the second enemy, nothing happens. Does it mean that I have to "refresh" this function and run it, say every 1 sec?
Thanks.
Edit: Also could you explain the "Search Area effect"?
Since I'm taking a break, I'll show you two different ways. Attached a map example file with lots of comments.
Rundown on what I did:
Attached a radius to each hero unit.
Made an event if you type in "type" it will change the generating type
Type1 (simple): Every 1 second, generate resources if an enemy is within the radius.
Type2 (more complex): Every 1 second, generate resources if an enemy is within a specified range (by unit type).
I ended up using the unit type filtration because grabbing the attack range of a unit inside triggers is not easy (consider that you can have multiple weapons on a unit, so doing a catalog grab is not easy, plus I tried to make this pretty simple).
In my example the radius around the hero units is 10. I purposely made the mule's distance check 15 to show this won't work, ideally set the region radius to the maximum range you'll ever do a check on, then use unit type to filter what units will trigger the radius.
Edit: Actually, I did a slight error while breezing this example. The radius size of the region is set to 5, not 10. But it still works and the general idea still applies. Only wanted to clarify so you aren't sitting there puzzled. :)
Good luck.
Hi. Im making a map where unit get minerals for being within range to an enemy unit. At the moment, I use
Unit Enters/Leaves Range Of Unit Unit: Any Unit State: Enters Range: 15.0 From Unit: Immortal [67.36, 64.04]
But there are 2 problems with this, first of all, this only works when I enter range of the one spesific unit, how can I set this to "Any unit enters within 15 range from Nearest enemy unit"?
Another issue I have, how can I make the range a variable? The variable I wanna use is the attack range of the nearest enemy unit.
Any thoughts?
Thanks in advance.
So this is what I recently did;
Unit - heroes[(Triggering player)] Enters a distance of 15.0 from (Closest unit to (Position of heroes[(Triggering player)]) in (Any units in (Entire map) owned by player Any Player matching No Unit Filter, with at most Any Amount))
Note that
Unit - heroes[(Triggering player)] Enters a distance of 15.0 From Unit: Immortal [67.36, 64.04]
works perfectly, but as soon as I add any form of variable, it doesn't work. Heroes is an array of units that each player own (player only owns one unit).
Ideas?
Glancing at your second post:
Unit - heroes[(Triggering player)] Enters a distance of 15.0 from (Closest unit to (Position of heroes[(Triggering player)]) in (Any units in (Entire map) owned by player Any Player matching No Unit Filter, with at most Any Amount))
Is this an event? Like, if you consider what you wrote there, you're saying if heroes[1] enters a distance of 15.0 from (closest unit to (position of heroes[1])).. I'm not sure this will ever trigger since the only way it would is if the unit some how enters a distance of 15 from itself.
Maybe try: Unit - Any Unit enters a distance of 15.0 from (Closest unit to (Position of heroes[1]) in (Any units in (Entire map) owned by player Any Player matching No Unit Filter, with at most Any Amount))
Unit - Any Unit enters a distance of 15.0 from (Closest unit to (Position of heroes[2]) in (Any units in (Entire map) owned by player Any Player matching No Unit Filter, with at most Any Amount))
Unit - Any Unit enters a distance of 15.0 from (Closest unit to (Position of heroes[3]) in (Any units in (Entire map) owned by player Any Player matching No Unit Filter, with at most Any Amount))
etc, do it for each "heroes" in your array, basically saying if anyone gets 15 from your hero, run this event.
Actually though, you may have to split up the events since I don't see a traceback to identify which unit the triggering unit entered, so yeah. seperate into multiple events for each hero, and do your mineral generation based on that.
I don't know what entirely you're trying to do, personally I'd recommend using a persistent Search Area effect looking for enemies with a sort option of nearest enemy, then use an effect to modify miinerals (generate) based on that, but I don't know all your conditions to meet this scenario, it'd just be easier to manage in the long run I think if it's a general universal thing.
You can also consider using Attach Region to Unit, and then using the region as a means to identify units entering, but that probably won't be much different than the above.
Hi, thanks a lot for replying:)
I tried Unit - Any Unit enters a distance of 15.0 from (Closest unit to (Position of heroes[1]) in (Any units in (Entire map) owned by player Any Player matching No Unit Filter, with at most Any Amount))
and it did work. Just the way I wanted. But this seems to be a little too "static".. Ill have to make a bunch of triggers for each team then?
Another issue I have is, I have 2 enemies on the map, when I enter distance of 15 for the closest enemy upon start, it works, but when I move away from him and enter distance of 15 to the second enemy, nothing happens. Does it mean that I have to "refresh" this function and run it, say every 1 sec?
Thanks.
Edit: Also could you explain the "Search Area effect"?
Since I'm taking a break, I'll show you two different ways. Attached a map example file with lots of comments.
Rundown on what I did:
Attached a radius to each hero unit.
Made an event if you type in "type" it will change the generating type
Type1 (simple): Every 1 second, generate resources if an enemy is within the radius.
Type2 (more complex): Every 1 second, generate resources if an enemy is within a specified range (by unit type).
I ended up using the unit type filtration because grabbing the attack range of a unit inside triggers is not easy (consider that you can have multiple weapons on a unit, so doing a catalog grab is not easy, plus I tried to make this pretty simple).
In my example the radius around the hero units is 10. I purposely made the mule's distance check 15 to show this won't work, ideally set the region radius to the maximum range you'll ever do a check on, then use unit type to filter what units will trigger the radius.
Good luck.
This. Is. Awesome! THANKS!
This is just what I've been looking for, thanks a lot! Topic solved.
Thanks! =)