Complex Math Problems

Azylaminaz

Vox Populi
Reaction score
91
Normally I can do the math by myself, but I am having major problems.

I am seeking a way to make it so instead of unit B attacking unit A directly, I want to make it so that unit B cuts off unit A, then attacks.

In my head, the math seems to be pretty simple... Here is a model of what should happen:
modelkr9.jpg

Unit B's speed is 420, Unit A's speed is 380, though they both can have speed modifiers.

Now, what I TRIED to do was make everything happen through distance and angle calculations between points, changing unit B's projectile target every X seconds (default is .25 seconds).
Code:
glblShepherdActions01
    Events
        Time - tmrLoop[1] expires
    Conditions
    Actions
        Unit Group - Pick every unit in ntgrpShepherds[1] and do (Actions)
            Loop - Actions
                Set pntTemp[0] = (Position of ntSheep[1])
                Set pntTemp[2] = (Position of (Picked unit))
                If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    If - Conditions
                         (((Current order of (Picked unit)) Equal to (Order(attack))) and ((Distance between pntTemp[0] and pntTemp[2]) Greater than or equal to 196.00)) or ((Distance between pntTemp[0] and pntTemp[2]) Greater than or equal to 1024.00)
                    Then - Actions
                        Set pntTemp[3] = (pntTemp[0] offset by (((Distance between pntTemp[0] and pntTemp[2]) / 1.50) x (Random real number between 0.90 and 1.10)) towards (Facing of ntSheep[1]) degrees)
                        Set pntTemp[1] = (pntTemp[2] offset by (((Distance between pntTemp[0] and pntTemp[2]) / 1.50) x (Random real number between 0.90 and 1.10)) towards ((Facing of (Picked unit)) + ((Angle from pntTemp[3] to pntTemp[2]) / 3.00)) degrees)
                        Unit - Order (Picked unit) to Move To pntTemp[1]
                        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                            If - Conditions
                                (Distance between pntTemp[0] and pntTemp[2]) Less than or equal to 128.00
                            Then - Actions
                                Unit - Order (Picked unit) to Attack ntSheep[1]
                            Else - Actions
                        Custom script:   call RemoveLocation (udg_pntTemp[2])
                        Custom script:   call RemoveLocation (udg_pntTemp[1])
                        Custom script:   call RemoveLocation (udg_pntTemp[0])
                    Else - Actions
Unit B (or in this case, every unit in ntgrpShepherds[1]), runs in circles or in a random direction. o_o

Can someone please tell me how I can make it arc correctly? ^.^ Circles = not good enough...

Also, I just need the forumla (one which will work with the angles used (±180±90-0).
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top