need help with tower defence

MissKerrigan

Active Member
Reaction score
23
Hi I need some help with a tower defence, I don't want that poison towers or slow towers hit the same enemy

Does anyone knows how to solve this?
 

Dave312

Censored for your safe viewing
Reaction score
269
You could add an effect to the attack which orders the tower to attack a random unit within its range. You could add the target unit to the exclude property to ensure it doesn't attack the same unit twice. The only problem is that if the player wants the tower to only attack a specific unit, it will always attack once then move onto another target.

To implement, go to the Effects data type and create a new effect of the type Issue Order. Set the Ability: Ability property to Attack, set Target: Target + to Target Unit, and set Unit: Unit + to Caster. Now create another new effect of the type Search Area and open up the Search: Areas + property. Add a new area and set the Effect to the issue order effect you just created, Maximum Count to 1, and Radius to the attack range of your tower. Close the window and add Target to the Search: Exclude + property. Edit the Search: Search Filters property and uncheck Player and Ally (you probably want to make this the same as the Weapon: Target Filters property on the towers weapon). Finally set the Target: Impact Location + property to Caster Unit/Point.

Now I assume that to add the special effects (ie slow and poison) to your towers weapon, you are using a Set effect? Find this set effect and add the Search Area effect you just created.


I have tested this and have come across an issue that I haven't been able solve. The tower will keep attacking the same two units because of the way the game engine executes search area effects. Since we only want the tower to attack one unit, I have set the maximum count on the Search Area effect to 1. But the engine seems to count objects from Top Left to Bottom Right, so since the Search Area effect is limited to selecting one unit, it will always select the unit that is in the most Top Left (because it finds this unit first), hence the selection is not random but rather fixed. I do remember seeing something about selecting a random unit in the data editor but can't for the life of me remember where that was (maybe someone else might know?). However because you are working on a TD, and typically the creeps always keep moving, the unit in the Top Left should always keep changing, thus this issue might not be a problem for you.
 

MissKerrigan

Active Member
Reaction score
23
Alright Dave, thx at first !

I tell you what I found out so far and what crazy things I tried! haha


I edited the 'poison weapon' targets excluded: hidden
I create a trigger:

event: any player using effect 'poison'
condition: none
action 1: modify triggering effected 'target' unit 'hidden' on
action 2: wait 5 seconds (poison time)
action 3: modify triggering effected 'target' unit 'hidden' off

Now my poison tower will attack some other target when poisoned a unit but here is a problem!
Because I set the triggering effected 'target' unit to 'hidden' the unit disappears!! haha

Does anybody know why I cannot change the unit attribute by trigger?
For example trigger: switch unit to 'light' 'biological' or 'armored'
This would make it possible to solve my problem because I set the poison weapon excluded targets 'biological' or 'armored' then


I also tried to make a validator 'poison validator' but can't find anywhere in the editor to let the poisno weapon excluded this targets
The only possibility for edit the weapon seems attributes, only here you can program which target your weapon can hit



Another thing I tried is searching for unit priority but I can't find anywhere in the editor to make a trigger which increase the poisoned unit to a higher priority

I hope Siretu reads this and know some anwser to it
Come on, it's a starcraft 2 editor with like 100.000 possibilities, don't tell me this is not possible :)

MissKerrigan
 

Dave312

Censored for your safe viewing
Reaction score
269
There probably is a data based solution, but I just don't know. In the meantime, below is a trigger based solution. It just orders the tower to attack another random unit within range of the tower

Trigger:
  • Tower Redirect
    • Events
      • Unit - Any Unit is attacked
    • Local Variables
      • Unit Group = (Empty unit group) <Unit Group>
    • Conditions
      • (Unit type of (Attacking Unit)) == Poison Tower
    • Actions
      • Variable - Set Unit Group = (Units in (Region((Position of (Attacking Unit)), 7.0)) having alliance Enemy with player (Owner of (Attacking Unit)) matching Excluded: Missile, Dead, Hidden, with at most Any Amount)
      • Unit Group - Remove (Triggering unit) from Unit Group
      • Unit - Order (Attacking Unit) to ( Attack targeting (Random Living unit from Unit Group)) (Replace Existing Orders)
 

Siretu

Starcraft 2 Editor Moderator
Reaction score
293
Okay, I've been a little inactive lately due to a very busy week. However, I always read everything in this forum the same day. I messed around with this today and I learned a lot. I'm not completely sure of the issues you're still having but I think Target sorts are the solution to all of them.

Let's recap your problems(tell me if I got this wrong):

1. You want to prioritize poisoned units differently.

2. You don't want the poison tower and slow tower to target the same unit.

First of all, from what I know, target sorts are available in weapons and search effects. They might be available elsewhere but I haven't really gone around and searched for them. However there is one problem, I can't get the weapon's target sorts to work. I don't know if I'm doing something wrong or if they just don't work. From what I can gather on the internet, they used to not work so that is probably still the case.

Target sorts are kind of what they sound like. They're a way to handle how something chooses in what order to target units. If you for example have a search effect that selects ONLY one unit in a 6 radius and you want it to pick the one with the lowest shield, you could do it pretty easily with a standard target sort.

For this we will need to create a custom target sort, don't worrry though. They're pretty easy to make and they have very few fields.

1. Prioritize poisoned units
I assume all poisoned units have some sort of behavior that acts as a debuff. I didn't really understand if you want the poison tower to target a non-poisoned target or if you wanted other towers to target a poisoned tower. Hopefully, when you understand target sorts you'll be able to figure out both cases. I'll explain how to make the poison tower target a non-poisoned target.

Open up the data editor and open the "Edit Advanced Data>Target sorts" tab. Create a new target sort named "TSPoison" of the "Behavior count type"

In the ":Behavior" field set it to your poison behavior. This means it'll sort the units with 0 poison debuffs first(since ":Value" is 0). That's all we need to do in the Target Sorts tab.

Now we have a problem. Your tower probably has a weapon but since I can't get the target sorts to work for weapons, we'll have to make the weapon use a search effect. First go into your poison tower's weapon. Remember the effect in the "Effect: Effect" field.

Go to the effect tab and create a new search effect called something like "Poison Weapon (Search)". Open the "Search: Areas +" field and create a new area.

Set the Maximum count to 1, radius to the range of the tower and Effect to the effect from the "Effect: Effect" field on the weapon. Press okay.

Next, change the "Search: Maximum Count" to 1. Open up the "Target: Target Sorts + " field.

There are 3 fields here. "Request Count", "Request Percentage" and "Sorts". "Request Count" is how many targets will be acquired with a target sorts. If you have a weapon that shoots 5 projectiles each time and you want one to target normally and the other to use targets sorts.

"Request Percentage" is the chance that you use a target sort. "Sorts" is what kind of target sort to use. Since we only have one target we don't have to worry too much. Set "Request Count" and "Request percentage" to 1. Add a target sort to the "Sorts" list. Add the "TSPoison" target sort you added earlier.

Make sure you set the "Search: Search Filters" to the same thing as the weapons target filters. Otherwise you might fire upon yourself or your allies.

Finally, go back to the weapons tab and change the "Effect: Effect" field to "Poison Weapon (Search)" (the search effect you created)

2. Prevent Poison and Slow Tower from firing on the same target.
I would do something similar to what we just did. First of all, create two hidden behaviors with a duration around 5 seconds. This will be used to reserve a target. Each tower will use this to reserve a target. Each weapon will have its own target sort that gives units with the other tower's reservation buff lower priority.

This is very similar to what we just did for the poison tower but done twice. You will also need each tower to apply its own behavior. I would create an "Apply Behavior" effect and a "Set" effect. Change the weapon's effect to the set effect and add the "Apply Behavior" effect and the old weapon's effect to the Set effect.

This was a kind of short explanation and I you'll likely run into some problem on the way that I didn't think of. Tell me how far you get and what problems you run into and we'll solve it from there.
 

MissKerrigan

Active Member
Reaction score
23
Thx Siretu for all your explaination but I already figured it out

HOW EASY CAN THIS BE!!

I just created a validator 'compare behavior count' and selected the poison behavior
I went to the hydralisk weapon (poison tower) and just added the validator to the weapon

Got 2 questions for Dave:

1. How old are you?
2. Did you really didn't know this?

MissKerrigan
 

Siretu

Starcraft 2 Editor Moderator
Reaction score
293
The problem with your solution is that if all targets are poisoned, it wont fire at all. I thought you wanted it to fire at all times but giving higher priority to units that aren't poisoned.

As for Dave, I think it's possible he didn't think of it as a solution as you mentioned trying to use a validator without success.
 

MissKerrigan

Active Member
Reaction score
23
Yes Siretu you are right, the poison tower won't fire if all creeps are poisoned, but the poison tower wont hit all creeps before they all passed unless it's a boss

But I triggered so that the poison tower only does poison damage and not an additional poison for Example:

poison tower deals 25 damage + 10 x 5 poison damage
In this case my solution wont work but I also figured out that!

I got a stun tower that deals 250 damage + 10% chance to stun targeted creep (stun for 5 seconds)
So if I would use my validator trick with the stun tower, it wouldn't be able to fire when a creep got stunned

So I created 2 behaviors:

1. stun (normal behavior)
2. target change

I created a validator 'compare behavior count' and added target change in this
I modified the behavior 'target change' duration to 0.5 seconds

So this means if a creep got stunned, the stun tower wont be able for 0.5 seconds to fire at the stunned creep and it will automatically after it stunned search for another creep
If there is no other creep, it will fire at the stunned target again because the period of the stun tower is set to 1.5

I starting to understand this editor now!

MissKerrigan


note: I don't use 'suspress movement' in the stun behavior because the creep wont continue moving after stunned time running out so I set a speed multiplyer to 0.01 :) :)
 

Dave312

Censored for your safe viewing
Reaction score
269
Thx Siretu for all your explaination but I already figured it out

HOW EASY CAN THIS BE!!

I just created a validator 'compare behavior count' and selected the poison behavior
I went to the hydralisk weapon (poison tower) and just added the validator to the weapon

Got 2 questions for Dave:

1. How old are you?
2. Did you really didn't know this?

MissKerrigan

1) why do you ask?
2) I did know about this, but as Siretu said, the weapon will stop attacking if all units in range have been poisoned (that just seems backwards to me). What I was trying to do was make it such that the tower preferred attacking non-poisoned units but would still attack poisoned units if it had to.
 

Siretu

Starcraft 2 Editor Moderator
Reaction score
293

MissKerrigan

Active Member
Reaction score
23
Well Dave, it's a poison tower so it wont need to fire if a target got poisoned
And if it must target poisoned units, I'll make a validator behavior compare with a behavior for like 0.5 seconds so it will find other target and if it doesn't it finally will target the same creep
 

MissKerrigan

Active Member
Reaction score
23
Alright Siretu,

It is working now, my tower first shoots the targets which are not poisoned

But the tower is NOT facing to it's target
It's facing to the target it should fire at normally
But the launch-missile goes to the target which is told by the target sort

anyway, it feels like I learned another thing in the editor :)
 

MissKerrigan

Active Member
Reaction score
23
Alright let me give a good example:

- 1 roach followed by 9 stalkers walking pass my marine-tower
- my marine tower has the priority to shoot the stalker rather than the roach
- so the marine shoots at the roach, facing the roach and damages the roach
- but as soon the stalkers coming in range, the marine STILL facing the roach but the STALKER is taking damage

so the target sort I created IS working but the only problem I've left is that the marine must FACE to the unit it fires at

Anything unclear about this?



(the post above was just a few months old)
 
General chit-chat
Help Users
  • Varine Varine:
    I ordered like five blocks for 15 dollars. They're just little aluminum blocks with holes drilled into them
  • Varine Varine:
    They are pretty much disposable. I have shitty nozzles though, and I don't think these were designed for how hot I've run them
  • Varine Varine:
    I tried to extract it but the thing is pretty stuck. Idk what else I can use this for
  • Varine Varine:
    I'll throw it into my scrap stuff box, I'm sure can be used for something
  • Varine Varine:
    I have spare parts for like, everything BUT that block lol. Oh well, I'll print this shit next week I guess. Hopefully it fits
  • Varine Varine:
    I see that, despite your insistence to the contrary, we are becoming a recipe website
  • Varine Varine:
    Which is unique I guess.
  • The Helper The Helper:
    Actually I was just playing with having some kind of mention of the food forum and recipes on the main page to test and see if it would engage some of those people to post something. It is just weird to get so much traffic and no engagement
  • The Helper The Helper:
    So what it really is me trying to implement some kind of better site navigation not change the whole theme of the site
  • Varine Varine:
    How can you tell the difference between real traffic and indexing or AI generation bots?
  • The Helper The Helper:
    The bots will show up as users online in the forum software but they do not show up in my stats tracking. I am sure there are bots in the stats but the way alot of the bots treat the site do not show up on the stats
  • Varine Varine:
    I want to build a filtration system for my 3d printer, and that shit is so much more complicated than I thought it would be
  • Varine Varine:
    Apparently ABS emits styrene particulates which can be like .2 micrometers, which idk if the VOC detectors I have can even catch that
  • Varine Varine:
    Anyway I need to get some of those sensors and two air pressure sensors installed before an after the filters, which I need to figure out how to calculate the necessary pressure for and I have yet to find anything that tells me how to actually do that, just the cfm ratings
  • Varine Varine:
    And then I have to set up an arduino board to read those sensors, which I also don't know very much about but I have a whole bunch of crash course things for that
  • Varine Varine:
    These sensors are also a lot more than I thought they would be. Like 5 to 10 each, idk why but I assumed they would be like 2 dollars
  • Varine Varine:
    Another issue I'm learning is that a lot of the air quality sensors don't work at very high ambient temperatures. I'm planning on heating this enclosure to like 60C or so, and that's the upper limit of their functionality
  • Varine Varine:
    Although I don't know if I need to actually actively heat it or just let the plate and hotend bring the ambient temp to whatever it will, but even then I need to figure out an exfiltration for hot air. I think I kind of know what to do but it's still fucking confusing
  • The Helper The Helper:
    Maybe you could find some of that information from AC tech - like how they detect freon and such
  • Varine Varine:
    That's mostly what I've been looking at
  • Varine Varine:
    I don't think I'm dealing with quite the same pressures though, at the very least its a significantly smaller system. For the time being I'm just going to put together a quick scrubby box though and hope it works good enough to not make my house toxic
  • Varine Varine:
    I mean I don't use this enough to pose any significant danger I don't think, but I would still rather not be throwing styrene all over the air

      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