Towers attacking creeps in tower defense

MissKerrigan

Active Member
Reaction score
23
Hello,

Does anyone know how I can program the towers so, that they will fire at the farest creep in the wave?

MissKerrigan
 

X-maul

AKA: Demtrod
Reaction score
201
Okay? I'll admit it, I dont knowo_O I asume it will have something to do with the turret and some validators, but as I do not have the editor at my side I wont be able to test it.
 

Siretu

Starcraft 2 Editor Moderator
Reaction score
293
You use target sorts, just as I explained to you in this post.

This time you'll have to go to target sorts in the data editor and copy TSDistance. Change :Descending to Enabled. To use this new target sort for your unit, go to the unit's weapon and open up the Weapon: Acquired Target Sorts + field. Set Request Count and Request Percentage to 1 and add a new sort. Set the new sort to your new copy of the TSDistance sort.
 

MissKerrigan

Active Member
Reaction score
23
I've red all stuff about this TSDistance sort but this sounds very difficould!

I might be wrong, but didn't you explained about how to fire poisoned/slowed and non-poisoned/non-slowed creeps?

I'm talking here about hitting the (current) first creep of the wave, is this also possible via your explanation (TSDistance sorts)?


The way I solved the poison/slow targets now is a little weird but might work:

I created a validator 'no poison attack' and put in the behavior which I called 'no poison attack'
I added this validator to the roach-launch-missile effect (roach is the poison tower)
So you might think the roach can't fire to poisoned units but I also solved that! (haha)

I set the duration of the 'no poison attack' behavior to 0.5 and made the next trigger:


event: behavior 'poison' is used
conditions: none
actions: general-repeat actions forever
-actions: add 1 'no poison attack' at 'triggering effected unit (target)
-actions: wait 1 game seconds


This solution is works in START of the game but I think I should be better of to use your way of doing it because the next 2 things:

- when the poison tower is upgraded or some other 'fire rate' aura's is on the tower, it shoots FASTER
(because it shoots faster, I'm getting trouble with this validator)

- sometimes when the poison tower JUST fire before the trigger puts the 'no poison attack' effect on the creep, the launch missile wont impact the creep for some reason


I think I just should take a look in this TSDistance sorts


MissKerrigan
 

GFreak45

I didnt slap you, i high 5'd your face.
Reaction score
130
you could also do this via trigger:
Trigger:
  • Target Farthest
    • Events
      • A unit is attacked
    • Conditions
      • Unit Type of Attacking Unit == Your Tower
    • Local Variables
      • real Range = 0
      • unit Target = Attacked Unit
    • Actions
      • Unit Group - Pick every unit in (Tower attack range) and do actions
        • Loop - Actions
          • If
            • If (Conditions)
              • Distance Between Position of Attacking Unit and Position of Picked unit >= Range
            • Then (Actions)
              • Range = Distance Between Position of Attacking Unit and Position of Picked unit
              • Target = Picked Unit
      • Unit - Order Attacking unit to Attack Target


This is an example, probably has the attack glitch in it because its a start and its hand written, but it is relatively simple
 

Siretu

Starcraft 2 Editor Moderator
Reaction score
293
I've red all stuff about this TSDistance sort but this sounds very difficould!
I might be wrong, but didn't you explained about how to fire poisoned/slowed and non-poisoned/non-slowed creeps?

I'm talking here about hitting the (current) first creep of the wave, is this also possible via your explanation (TSDistance sorts)?

MissKerrigan



Yes I talked about poison/slow. It's the same concept. You sort the targets and pick the best one depending on how you sorted it. You could for example make it attack the one with most energy, if you want that.

Note that it's not TSDistance that you want. You want a custom version of it. Just follow these instructions I posted here:

This time you'll have to go to target sorts in the data editor and copy TSDistance. Change : Descending to Enabled. To use this new target sort for your unit, go to the unit's weapon and open up the Weapon: Acquired Target Sorts + field. Set Request Count and Request Percentage to 1 and add a new sort. Set the new sort to your new copy of the TSDistance sort.

However, you need to clarify something for me. Do you want it to hit the FIRST creep it sees and keep attacking it until it's out of range or do you want it to attack the creep that is farthest away?
 

Syndrome

You can change this now in User CP.
Reaction score
126
@GFreak, correct me if I'm wrong, but wouldn't giving every unit on the field + 1 priority every second a better idea? No calculations, no checking every unit within every tower's range for every tower. You just add + 1 every second. Seems a whole lot easier IMO.

This way, older units who lasted longer have more priority than the others.
 

MissKerrigan

Active Member
Reaction score
23
- priority seems not to work because I gave bosses priority '1' and the creeps priority 10+ but it seems to ignore the bosses even if I tried giving bosses a higer prority

Another thing about priority is which kind of creeps the towers must fire

1. protoss towers hit zerg creep 150%, terran creeps 125% and protoss creeps 50%

2. terran towers hit zerg creeps 75%, terran creeps 100% and protoss creeps 75%

3. zerg towers hit zerg creeps 50%, terran creeps 100% and protoss creeps 100%


so it would be nice if:

-protoss towers always try to hit the zerg creeps if they are in range (farest)
- zerg towers always try to hit protoss creeps if they are in range (farest)


Yes Siretu, I mean the creep which are the farest on the path, not the creep which is the farest in range

And no Syndrome, it seems impossible to change unit priorities by trigger, if this was possible I would create all regions part by part till the end and program the priority gets higher the further the creeps are on the path

MissKerrigan
 

X-maul

AKA: Demtrod
Reaction score
201
Please do not necro bumb. There is no reason for responding to this 5 month old thread to tell him his method did not work...
 

MissKerrigan

Active Member
Reaction score
23
I was just searching at the forum for 'target sorts' and found this thread, so why I should create a new thread if I can reply this one
 

Siretu

Starcraft 2 Editor Moderator
Reaction score
293
X-maul is right. You're not actually contributing anything to the discussion if you bump a 5 month old thread saying that he's wrong. You've also bumped a 7 month old thread, created a new thread AND bumped your recent thread on the subject. I know you want an answer, but focus on one thread. It's much easier for us to keep track of.

Also, don't be rude to people who are trying to help you.
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Staff online

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top