I've been struggling with this custom spell I have been working on. It's supposed to let you target a location, and then a series of explosions will happen every half a second towards where I targeted until it has happened 15 times. There's also another trigger to change the target point after the spell has already been cast, so I can make it switch directions to chase a fleeing enemy. The problem comes calculating the angle before it chooses where the next detection point will be. Instead of taking time to change directions, it can turn full 180 on a dime. I added a couple variables so that it can remember the old angle and detection point, and use that to calculate the new one.
I'm awful at math (I failed more than once in highschool
) and have no idea how to calculate the new angle! I just want it to be a smooth curve that loops back around to where I targeted instead of sharp sudden turns. Any insights would be greatly appreciated!
I'm awful at math (I failed more than once in highschool

-
WaterDragon1 Init
-
Events
-
Unit - A unit Starts the effect of an ability
-
-
Conditions
-
WD_Init Equal to False
-
(Ability being cast) Equal to Water Dragon
-
-
Actions
-
Set WD_Init = True
-
Set WD_Caster = (Triggering unit)
-
Set WD_Target_Point = (Target point of ability being cast)
-
Set WD_Old_Angle = (Angle from (Position of WD_Caster) to WD_Target_Point)
-
Set WD_Player = (Owner of WD_Caster)
-
Set WD_Allies = (Units owned by WD_Player)
-
Set WD_Explosion_Count = 0.00
-
Set WD_Detection_Point = ((Position of WD_Caster) offset by WD_Config_JumpLength towards WD_Old_Angle degrees)
-
Set WD_Old_Detection_Point = WD_Detection_Point
-
Special Effect - Create a special effect at WD_Detection_Point using Objects\Spawnmodels\Naga\NagaDeath\NagaDeath.mdl
-
Special Effect - Destroy (Last created special effect)
-
Unit Group - Add all units of (Units within WD_Config_Radius of WD_Detection_Point) to WD_Targets
-
Unit Group - Pick every unit in WD_Allies and do (Unit Group - Remove (Picked unit) from WD_Targets)
-
Unit Group - Pick every unit in WD_Targets and do (Unit - Cause WD_Caster to damage (Picked unit), dealing WD_Config_Damage damage of attack type Spells and damage type Normal)
-
Unit Group - Remove all units from WD_Targets
-
-
-
WaterDragon2 Main
-
Events
-
Time - Every 0.50 seconds of game time
-
-
Conditions
-
WD_Init Equal to True
-
-
Actions
-
Set WD_Angle = (Angle from WD_Detection_Point to WD_Target_Point)
-
Set WD_Angle = (WD_Angle + WD_Old_Angle)
-
Set WD_Angle = (WD_Angle / 2.00)
-
Set WD_Detection_Point = (WD_Detection_Point offset by WD_Config_JumpLength towards WD_Angle degrees)
-
Special Effect - Create a special effect at WD_Detection_Point using Objects\Spawnmodels\Naga\NagaDeath\NagaDeath.mdl
-
Special Effect - Destroy (Last created special effect)
-
Unit Group - Add all units of (Units within WD_Config_Radius of WD_Detection_Point) to WD_Targets
-
Unit Group - Pick every unit in WD_Allies and do (Unit Group - Remove (Picked unit) from WD_Targets)
-
Unit Group - Pick every unit in WD_Targets and do (Unit - Cause WD_Caster to damage (Picked unit), dealing WD_Config_Damage damage of attack type Spells and damage type Normal)
-
Unit Group - Remove all units from WD_Targets
-
Set WD_Explosion_Count = (WD_Explosion_Count + 1.00)
-
Set WD_Old_Angle = (Angle from WD_Old_Detection_Point to WD_Detection_Point)
-
Set WD_Old_Detection_Point = WD_Detection_Point
-
If (WD_Explosion_Count Greater than or equal to WD_Config_Max_Explosions) then do (Set WD_Init = False) else do (Do nothing)
-
-