| 03-26-2005, 10:48 PM | #1 |
So here's what I want to happen. The combat system uses 8-directional key movement and a dummy spell to initiate the attack. I want to know how to detect when a unit enters the area within range of the hero between two angles. Here is what the attack trigger is so far: combatSwingEffect Events Unit - A unit Begins casting an ability Conditions (Ability being cast) == Attack Actions Unit - Order (Casting unit) to Stop Sound - Play BristleBackMissileLaunch3 <gen> at 100.00% volume, attached to (Casting unit) Set attackangle = ((Facing of (Casting unit)) - 35.00) Set attackloop = 1 Custom script: loop Custom script: (exitwhen (attackloop == 28)) Special Effect - Create a special effect at ((Position of (Casting unit)) offset by 175.00 towards attackangle degrees) using Abilities\Spells\Items\AIda\AIdaTarget.mdl Set attackfx = (Last created special effect) Set attackangle = (attackangle + 2.50) Set attackloop = (attackloop + 1) Special Effect - Destroy attackfx Custom script: endloop Set attackangle = ((Facing of (Casting unit)) - 35.00) Set attackloop = 1 Custom script: loop Custom script: (exitwhen (attackloop == 14)) Special Effect - Create a special effect at ((Position of (Casting unit)) offset by 75.00 towards attackangle degrees) using Abilities\Spells\Items\AIda\AIdaTarget.mdl Set attackfx = (Last created special effect) Set attackangle = (attackangle + 5.00) Set attackloop = (attackloop + 1) Special Effect - Destroy attackfx Custom script: endloop Set attackangle = ((Facing of (Casting unit)) - 35.00) Set attackloop = 1 Custom script: loop Custom script: (exitwhen (attackloop == 21)) Special Effect - Create a special effect at ((Position of (Casting unit)) offset by 125.00 towards attackangle degrees) using Abilities\Spells\Items\AIda\AIdaTarget.mdl Set attackfx = (Last created special effect) Set attackangle = (attackangle + (3.00 + (1.00 / 3.00))) Set attackloop = (attackloop + 1) Special Effect - Destroy attackfx Custom script: endloop If a unit enters between -35 and +35 degrees of hero's facing angle at a distance of 200 or less, it will be hit. How can I determine that? Also how can I elevate the special effect so it's not on the ground? |
| 03-27-2005, 01:53 AM | #2 |
just do unit comes within range, then check if it's at the right angle. |
| 03-27-2005, 02:33 AM | #3 |
That's exactly what I asked. HOW? |
| 03-27-2005, 11:31 AM | #4 |
1 - Use the event "A Units starts the effect of ability" and not begins casting 2 - You should use the Unit Group - Pick every unit in range of 200 from hero position. In the "Pick Units in range" loop make a "Real Comparsion" condition and check if "Math - Angle between 2 points" (position of casting and position of picked unit) is included in the 70° angle depending from the facing of the casting hero. If this condition is true start the effect on this unit, else do nothing (the unit is not in front of the hero) WARNING!!! The distance between points goes from -180° to +180° soo you must check if the angle is negative add +360° to it or it could give some problems because the facing rotation of the caster unit goes from 0 to 360°. 3 - To add a special effect on a different heigth you can: a - If the effect is on a unit use the special animation string: overhead b - If the effect is on ground you should use a unit with the effect model and with the locust ability (soo it cant be selected) |
| 03-28-2005, 12:00 AM | #5 |
I don't get what the difference of the 2 angles does. Could you give an example please? |
| 03-28-2005, 02:00 AM | #6 |
Okay Val, the custom attack system I told you I had made, does exactly what this does. Just change the variables to arrays, to make it playable online(using the Player Number to get data from), and it will work fine. I know it will because the system originally started out in B.Net form before I moved it into the campaign I was making. Anyway, here is the attached map. Use A to attack. I know you're smart enough how to look and test it out on everything. And if you have a question about it, you know how to contact me. *Note: Reason the file is so large is because I have alot of models in it. Don't mind them. |
| 03-28-2005, 09:37 AM | #7 |
"Math - Angle between 2 points" trace a line between 2 points and calculates its angle. If your Hero is faced top-left and the enemy is in front of him the line will have this orientation: \ The angle start with 0° starting from right. (0° -->) (180° <--) The angle between the hero and the enemy will be 90° + 45° = 135° |
| 03-28-2005, 09:03 PM | #8 |
That doesn't make any sense as 2 points make a straight line forming a 180 degree angle everytime. But I see what you're sayin. Thanks for the explanation. |
| 03-28-2005, 10:00 PM | #9 |
Mmmm imagine that you always have a horizontal line that goes from left to right. When you trace another line from point 1 to point 2 you form another line. The intersection between them creates an angle. The "Math - Angle between 2 points" functions calculates the angulation difference between the line formed by the 2 points and the horizontal line. |
| 03-29-2005, 09:10 PM | #10 |
ahhh |
| 03-29-2005, 09:59 PM | #11 |
Got it? ;) |
