• 🏆 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!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

[Spell] Dummy Angle help

Status
Not open for further replies.
Level 3
Joined
Feb 15, 2015
Messages
26
Hi! I need help with the initiation of my spell. Basically what it does is releasing 7 arrows flying towards and damaging enemy. I know how to slide the dummy units already, I just don't know how to make them face the desired angle. I have attached an image for clarification

If you still aren't clear, let me explain. The arrow (4) faces the angle between the caster and the targeted point, while other arrows are symmetrical pairs. Suppose that the angle mentioned above is 0 degree:

+ Arrow (5) flies toward 20 degree, Arrow (3) flies toward 340 degree.
+ Arrow (6) flies toward 40 degree, Arrow (2) flies toward 320 degree.
+ Arrow (7) flies toward 60 degree, Arrow (1) flies toward 300 degree.

Is there any formula to achieve this? I'm kinda lost when it comes to math
7 arrows.png
 

Wrda

Spell Reviewer
Level 26
Joined
Nov 18, 2012
Messages
1,887
Something like this:
  • Cast
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Storm Bolt
    • Actions
      • Set Point = (Position of (Triggering unit))
      • Set Point2 = (Target point of ability being cast)
      • Set Facing = (Angle from Point to Point2)
      • Set Point3 = (Point offset by 10.00 towards Facing degrees)
      • Unit - Create 1 Missile for (Owner of (Triggering unit)) at Point3 facing Facing degrees
      • -------- set a unit variable for dummy I suppose? --------
      • Custom script: call RemoveLocation(udg_Point2)
      • Custom script: call RemoveLocation(udg_Point3)
      • For each (Integer IntLoop) from 1 to 3, do (Actions)
        • Loop - Actions
          • Set Deviation = (Deviation x (Real(IntLoop)))
          • Set Point2 = (Point offset by 10.00 towards (Facing + Deviation) degrees)
          • Unit - Create 1 Missile for (Owner of (Triggering unit)) at Point2 facing (Facing + Deviation) degrees
          • -------- same here --------
          • Custom script: call RemoveLocation(udg_Point2)
          • Set Deviation = 20.00
      • For each (Integer IntLoop) from 1 to 3, do (Actions)
        • Loop - Actions
          • Set Deviation = (Deviation x (Real(IntLoop)))
          • Set Point2 = (Point offset by 10.00 towards (Facing - Deviation) degrees)
          • Unit - Create 1 Missile for (Owner of (Triggering unit)) at Point2 facing (Facing - Deviation) degrees
          • -------- same here --------
          • Custom script: call RemoveLocation(udg_Point2)
          • Set Deviation = 20.00
 
Level 39
Joined
Feb 27, 2007
Messages
5,010
The Set Deviation = 20.00 lines need to be the first ones in the loops, not the last. (First time deviation is 0 so the first deviated arrow isn't and goes straight down the middle.)

You can use the Integer A/B variable loops instead of the specific integer variable loop Wrda wrote, it makes no difference.
 
Level 3
Joined
Feb 15, 2015
Messages
26
The Set Deviation = 20.00 lines need to be the first ones in the loops, not the last. (First time deviation is 0 so the first deviated arrow isn't and goes straight down the middle.)

You can use the Integer A/B variable loops instead of the specific integer variable loop Wrda wrote, it makes no difference.

So if I use integer loop, I presume I have to loop from -3 through 3 right? Will the system be able to read negative degrees? Thanks a lot.
 
Level 10
Joined
Apr 18, 2009
Messages
576
"Math - Angle Between Points" is a very nice function which returns the angle from point A to point B.

You can input the position of the caster as the first point, and the target position of the spell as the second point. You will get a real number which is the angle a unit on caster position would have if facing the target position.

So, create your first dummy facing this angle (angle from position of caster to target position).

If you store this facing value in a temporary variable "middleArrowFacing", then the other dummies would be created with the following facing angles:

middleArrowFacing - 20 * 3
middleArrowFacing - 20 * 2
middleArrowFacing - 20
middleArrowFacing + 20
middleArrowFacing + 20 * 2
middleArrowFacing + 20 * 3
 
Status
Not open for further replies.
Top