| 04-20-2005, 10:14 PM | #1 |
I was just wondering if there's a way to deflect shots back to the attacker if the attacked unit is facing about the same direction? I've messed around with it a little bit, but havent gotten anything that works. |
| 04-20-2005, 10:58 PM | #2 |
Another fun system to trigger (unless you just use the defend ability, it can deflect attacks, can't it?)! Well, when triggering this solution, you would probably use the "unit takes damage" event (it's a specific unit event, so you have a whole procedure to get things working generaly). Determining if the damaged unit is facing towards the attacker would be a matter of real comparisons of angles, unit's facing angle and the angle between the position of damaged unit and damage source. Then return the projectile by creating the same unit as the attacker for the owner of the attacked, give it locust and make it transparent and order it to shoot back... Meh, it's such a messy solution... don't know if I should even post this... |
| 04-20-2005, 11:14 PM | #3 |
use darky27's chilling armor ability it reflects missiles on ranged units who shoots on the enemy |
| 04-21-2005, 12:37 PM | #4 |
Defend and the like can only deflect piercing and possibly magic attacks. It doesn't seem to work for other attack types like siege. |
| 04-21-2005, 01:32 PM | #5 |
Guest | This may partly help you... two units are facing eachother if the angle that unit A is facing minus the angle that unit B is facing equals to 180 Which means that you should do "Angle(UnitA) - Angle(UnitB) = 180 is TRUE" in a comparaison |
| 04-21-2005, 01:40 PM | #6 |
itll never be 180 exactly. Furthermore that you are saying sounds like a boolean comparison ... it doesnt exist. Real comparison would do. just do something like if the angle between them is between 170 and 190 then run the trigger. |
| 04-21-2005, 05:59 PM | #7 | |
Quote:
you're on the right track but theres more to consider: since angles start from 0 and end at 360, you have to take care of some special cases, in where 359 - 10 = 349, but the real angle between the 2 units is 11 thus, Code:
angleA = (facing angle of unit A) - (facing angle of unit B)
if angleA > 180 then
angleA = 360 - angleA
endifnow if angleA > 165, then the units are almost facing each other (the reason for the if, is because comparing angles, the maximum angle between 2 units is 180 no matter what, beyond that they start reducing in the opposite direction) btw, not to be insulting, nor does it matter, but how did badfurday get so much rep with those kind of answers? |
| 04-21-2005, 07:50 PM | #8 |
thanks guys, worked perfectly, you get some rep raptor also, how do i make it so once it hits him it shoots the same missle art back dealing the damage to the shooter? would i just spawn a dummy unit with locust and make them shoot it back? it doesnt look very good as it is right now with the dummy unit. Is there a way to move special effects to the attackers? |
| 04-21-2005, 08:37 PM | #9 |
There are even more issues to consider. When I was doing a backstab trigger very similar to this, I discovered that units that attack a unit that's not directly in front of them may begin their attack before they fully turn around to face their target. So, just comparing the facing angles of units didn't give me accurate enough results. Instead, I then compared the facing angle of the attacked unit and the angle of the line between two points, the positions of the attacked and the attacking unit. |
