Uncle
Warcraft Moderator
- Joined
- Aug 10, 2018
- Messages
- 7,375
Hello, I'm terrible at math and wondering if anyone could help me with this trigger. I'm creating a Multishot ability that fires multiple projectiles towards a target point. I want the system to detect how many arrows are to be fired (a variable I want to be able to adjust freely) and then spread them over a 90 degree angle, with one arrow ALWAYS guaranteed to face the targeted point.
So an ideal setup would be that if you fired 3 arrows then one would go down the center, one would face the casters angle -45 degrees and the last one would face the casters angle +45 degrees. The way I have it setup in the trigger below can achieve something close to this but only for an EVEN numbers of arrows. I realize that when dealing with an even number of projectiles it will always look a little weird since there will be 1 extra arrow on either side of the hero, but as long as the center arrow is always aimed towards the targeted point then that's all I care about. This trigger is just an example so don't worry about the leaks and missing variables:
With the trigger above, if you fired 2 arrows and your hero was facing 90 degrees then the first arrow would face 90 degrees and the second would face 90 + 45 degrees.
So an ideal setup would be that if you fired 3 arrows then one would go down the center, one would face the casters angle -45 degrees and the last one would face the casters angle +45 degrees. The way I have it setup in the trigger below can achieve something close to this but only for an EVEN numbers of arrows. I realize that when dealing with an even number of projectiles it will always look a little weird since there will be 1 extra arrow on either side of the hero, but as long as the center arrow is always aimed towards the targeted point then that's all I care about. This trigger is just an example so don't worry about the leaks and missing variables:
-
multishot test
- Events
- Conditions
-
Actions
- -------- Starting Angle --------
- Set TempReal1 = ((Angle from (Position of TempUnit1) to ProjectilePoint[(Custom value of TempUnit1)]) - 45.00)
- -------- Angle Increments --------
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
- HeroStatProjectiles[(Custom value of TempUnit1)] Equal to 1
-
Then - Actions
- Set TempReal2 = 45.00
-
Else - Actions
- Set TempReal2 = (90.00 / (Real(HeroStatProjectiles[(Custom value of TempUnit1)])))
-
If - Conditions
- -------- Create Projectiles --------
-
For each (Integer A) from 1 to HeroStatProjectiles[(Custom value of TempUnit1)], do (Actions)
-
Loop - Actions
- Set ProjectileCount = (ProjectileCount + 1)
- Set ProjectileAngle[ProjectileCount] = (TempReal1 + TempReal2)
- Unit - Create 1 Projectile for TempPlayer1 at TempPoint1 facing ProjectileAngle[ProjectileCount] degrees
- Set TempReal1 = (TempReal1 + TempReal2)
-
Loop - Actions
With the trigger above, if you fired 2 arrows and your hero was facing 90 degrees then the first arrow would face 90 degrees and the second would face 90 + 45 degrees.
Last edited: