Multiple Path Brain-fart

Get help using Construct 2

Post » Wed May 20, 2015 8:20 am

Hello there fellow beans. I've been up all night trying to find a way to solve this issue i'm having. I cant even think anymore so forgive me if its a simple one.

Turret A is on a set path (in a straight line) to Turret B when it is spawned. I have another Turret, lets call this guy Turret E because its an awkward bastard.

Turret E is located outside Turret A's range when 'A' moves along its path.

What i need to do is get A to target E and then move within firing range (I cannot increase Turret A's firing range). After the illusive E is deceased, i then need 'A' to carry on his merry way to Turret B.

Basically, i need a 'detect and move to' range, that is separate from the turrets actual fire range.

Thanks in advance for any replies, peace.
Posts: 104
Reputation: 1,033

Post » Wed May 20, 2015 2:55 pm

You can do that with the distance function
Code: Select all
//Check for nearby enemies
Turret_A.In_combat = False                                             (Only Turret_A's that are not in combat)
For each Turret_A
    Distance(Turret_A.X, Turret_A.Y, Turret_E.X, Turret_E.Y) <= 500
               Turret_A.Go_to_Turret_B = False                     (Variable to make sure that turret don't go towards B)
               Turret_A.Attack_Turret_E = Turret_E.UID       (Store the UID of Turret_E that A is attacking)
               Turret_A find path to (Turret_E.X, Turret_E.Y)

(If Turrent_E is stationary you don't have to keep finding a path to it, so you could add a variable to make sure of that.)

//Move Turret_A
On path found Turret_A         
                Turret_A.Move along path

//Turret A is attacking Turret_E
Turret_A.Attack_Turret_E != -1                                             (Only pick A's that have a target)
For each Turret_A
       Turret_E.UID = Turret_A.Attack_Turret_E                     (Pick correct Turret_E)
       Distance(Turret_A.X, Turret_A.Y, Turret_E.X, Turret_E.Y) <= Firing_range
       Turret_A.In_combat = true                                      (Makes sure that Turret_A wont keep looking for path to E or B)

//When Turret A destroys E
      Turret_A.Attack_Turret_E  = Turret_E.UID              (Select all Turret_A that have the destroyed E as target)
      For each Turret_A       
           Set Turret_A.Attack_Turret_E = -1                       (Reset so there are no target selected)
           Turret_A.In_combat = False
//Return to going to B
Turret_A.In_Combat = False
Turret_A.Go_to_B = False
For each Turret_A
       Turret_A Find path to (Turret_B.X, Turret_B.Y)
       Turret_A.Go_to_B = True                                         (Make sure that it doesn't keep looking for a path)

Minor adjustments might be needed, but I think it would work.
Posts: 1,209
Reputation: 7,537

Post » Thu May 21, 2015 6:33 am

Thanks for the help, got it sorted now. Kinda very new at this and from staring at your reply for a good few hours scratching my head, ive discovered the power of using 1's and 0's to trip the fuck out of a computer and make it do crazy things that only Neo himself would dream of. I am now the Matrix.

Posts: 104
Reputation: 1,033

Return to How do I....?

Who is online

Users browsing this forum: Google [Bot] and 1 guest