• 🏆 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!
  • 🏆 Hive's 6th HD Modeling Contest: Mechanical is now open! Design and model a mechanical creature, mechanized animal, a futuristic robotic being, or anything else your imagination can tinker with! 📅 Submissions close on June 30, 2024. Don't miss this opportunity to let your creativity shine! Enter now and show us your mechanical masterpiece! 🔗 Click here to enter!

Checking if target unit is accessable?

Status
Not open for further replies.
Level 6
Joined
Apr 23, 2009
Messages
94
I have a trigger that makes certain units cast a close range spell on another unit-type, problem is, there are a LOT of units that will be targeted and not all of them will be reachable. Is there a way to check if unit is accessable?
 
Level 6
Joined
Apr 23, 2009
Messages
94
I don't think you guys understand what i'm saying, so i'll use an example. Say i have trigger that orders all Footman to attack all units within distance every .50 seconds.. And then a Griphon flys in. The Footman will be ordered to attack the Griphon, thus making them stand underneath it.. Unable to do anything.

Same concept with this idea..

||
||
||
|| 0
||
||
||


Imagine the lines in the figure above are Cannon Towers, and the 0 next to them is a unit with a melee attack. If he is ordered to attack Units Within 600 range of Type (Cannon Tower), then eventually he's going to be standing next to a Cannon Tower on the first set of line, trying to attack one that is inaccessable.

How do i make it so he only attacks ones that are accessable to him, without limiting the units targeted in range by like 200. I need him to attack every unit that is accessable on the map, if possible.
 
Are you looking for the short version or the long version? The short version is to guess at it and just filter out air units from the units he's sent to attack, as well as filter out units that have an elevation different than his, but to detect if a unit is inaccessible because there is a wall there, now that is a bit of coding which has several approaches.

1. The only one I am comfortable with:
Check pathability every 24 clicks from where the footman is standing towards his targetted unit. If one of those clicks fails (say, lies over a rock doodad) he will not be issued the order. A flaw in this is that maybe the rock is barely blocking him, yet this system wouldn't know that.

2. Create an item on those clicks, check its x,y position to see if they match the x,y position you assigned it to be at; if it's not, then the pathing is unwalkable.

This requires JASS coding, my friend. Are you ready for that?
 
Status
Not open for further replies.
Top