Hi Wisdom-HELLy,
I've given this some thought, as I plan to implement similar features in an upcoming example map. There are of course several ways to do what you ask, but here's how I'd do it. Since you already have a cover array that knows the direction of the cover (pregenerated I assume, since that would be most efficient), finding whether the attacker is between an attacker and the target should be very easy. Just subtract the X and Y locations of the attacker from the targets X and Y location. If X is positive the attacker is to the east, if Y is negative the attacker is to the north etc. No trace needed in this case.
For cone tracing I think that might also be more complicated than what you need. What I would do is to periodically do line traces to all enemy units currently on overwatch. Doing this on tick is probably overkill, but probably not that bad on performance, since there will probably not be a massive amount of units on overwatch in a given level. Either way I'd probably set it up to fire an event every time a unit enters a new tile. If any of the traces (using range trace) are not blocked (get hit result returns false), check the look at rotation between the unit on overwatch and the target. If it is a reasonably small number, trigger your overwatch event. The result should be pretty much identical to a cone trace, I think.
I've given this some thought, as I plan to implement similar features in an upcoming example map. There are of course several ways to do what you ask, but here's how I'd do it. Since you already have a cover array that knows the direction of the cover (pregenerated I assume, since that would be most efficient), finding whether the attacker is between an attacker and the target should be very easy. Just subtract the X and Y locations of the attacker from the targets X and Y location. If X is positive the attacker is to the east, if Y is negative the attacker is to the north etc. No trace needed in this case.
For cone tracing I think that might also be more complicated than what you need. What I would do is to periodically do line traces to all enemy units currently on overwatch. Doing this on tick is probably overkill, but probably not that bad on performance, since there will probably not be a massive amount of units on overwatch in a given level. Either way I'd probably set it up to fire an event every time a unit enters a new tile. If any of the traces (using range trace) are not blocked (get hit result returns false), check the look at rotation between the unit on overwatch and the target. If it is a reasonably small number, trigger your overwatch event. The result should be pretty much identical to a cone trace, I think.
Comment