Hey im working on a defense type map where units spawn and the player defends etc etc
my problem is that when the units spawn they just move to where ever triggered and just ignore attackers. what would be a way to make it so they move to the players base and attack the players turrets, units, structures etc etc instead of just ignoring them
I'll try my best, I'm at work with my phone, so no editor.
If I was at my pc I would link you to where I learned this method an give credit where it was due.
Im assuming you are using a periodic trigger to spawn units. Instead of creating the unit Inside this trigger, make it call upon an action definition.
This pretty cool, let's try to walk through it.
On the left near triggers right click and choose new action definition.
At the bottom there should be a bunch of check boxes, the first talking about running an independant thread while at the end saying used for action definentions... Click that one only.
Now you need to create your parameters. There is a place for it there. Make one for type player and assign it the number that is the player number of the spawning unit (if the spawning unit will be owned by player 15(hostile) then make this parameter equal 15)
then you should make a local variable, call it regionAttack but this time do not assign a value.
I'm going to post here since along with the slow typing of my phone, watching out for the boss, and doing my job might make this take a bit longer, and I want you to know I'm responding.
I may have missed a parameter and/or variable so I may add one later.
Now in actions go ahead and create your unit at whatever location you'd like.
Then issue the order to move to (last created unit) to whatever location.
Now create a region, make ita circular region with a radius of whatever distance you want the created unit to detect a target. Experiment here but maybe start with 4.
Now set the region as regionAttack
Now make a new action from the general category called if then else
in the if part put (unit enters region) set region to attackRegion
in the 'then' part put (issue order) set order type to 'order with target,
Then make the ability ordered to be attack. Then set the target to triggering unit.
This 'should' do it. If not you'll have to allow me to get home around 4am to look at my own. Also you can add other stuff after like if triggering unit dies>issue order.
Before trying this you should save as a new file so you don't break your existing stuff.
And let me know if it works or not.
I forgot to mention when making the unit and ordering the unit make the owner the parameter variable.
And when making it with player group play with the playergroup functions to equal the player number.
And I forgot the important step. In your periodic trigger when it is suppose to spawn a unit, put in a new action then go to the top and you should find your action definition in 'general'
Could you not just tell them to "attack" the target location, and they will attack-move towards the destination, stopping to destroy anything they see along the way?
Seems a lot more straightforward than coding in extra behaviour, and it's how the attack order works normally (if you read the tooltip).
Instead of the "move" command, you should use "scan-move". This will make the units defend and attack while moving.
So what's the difference between scan-move and the attack move then do you know? It sounds like both those commands behave the same way. I've always used attack->point for these sorts of things.
I think scan move is just the ability that units w/o attacks have to fill in the slot for attacking. But I think its just a copy of move. I just issue the attack command on a point normally...so does scan move actually acquire targets and stuff?
Hey im working on a defense type map where units spawn and the player defends etc etc
my problem is that when the units spawn they just move to where ever triggered and just ignore attackers. what would be a way to make it so they move to the players base and attack the players turrets, units, structures etc etc instead of just ignoring them
any ideas?
@TheRupturedD: Go
After the move order-> attach local variable region to unit with radius.
If (unit matching condition(enemy of last created unit) enters localRegion) Issue order with target(attack) triggering unit.
@BasicGear: Go
could u explain a little more still rusty with triggers
@TheRupturedD: Go
I'll try my best, I'm at work with my phone, so no editor. If I was at my pc I would link you to where I learned this method an give credit where it was due.
Im assuming you are using a periodic trigger to spawn units. Instead of creating the unit Inside this trigger, make it call upon an action definition.
This pretty cool, let's try to walk through it.
On the left near triggers right click and choose new action definition. At the bottom there should be a bunch of check boxes, the first talking about running an independant thread while at the end saying used for action definentions... Click that one only.
Now you need to create your parameters. There is a place for it there. Make one for type player and assign it the number that is the player number of the spawning unit (if the spawning unit will be owned by player 15(hostile) then make this parameter equal 15)
then you should make a local variable, call it regionAttack but this time do not assign a value.
I'm going to post here since along with the slow typing of my phone, watching out for the boss, and doing my job might make this take a bit longer, and I want you to know I'm responding.
@BasicGear: Go
for the parameter it only has PlayerColor and PlayerGroup
@TheRupturedD: Go
I may have missed a parameter and/or variable so I may add one later.
Now in actions go ahead and create your unit at whatever location you'd like. Then issue the order to move to (last created unit) to whatever location.
Now create a region, make ita circular region with a radius of whatever distance you want the created unit to detect a target. Experiment here but maybe start with 4.
Now set the region as regionAttack
Now make a new action from the general category called if then else in the if part put (unit enters region) set region to attackRegion in the 'then' part put (issue order) set order type to 'order with target, Then make the ability ordered to be attack. Then set the target to triggering unit.
This 'should' do it. If not you'll have to allow me to get home around 4am to look at my own. Also you can add other stuff after like if triggering unit dies>issue order.
Before trying this you should save as a new file so you don't break your existing stuff. And let me know if it works or not.
Gl Hf
@TheRupturedD: Go
I forgot to mention when making the unit and ordering the unit make the owner the parameter variable.
And when making it with player group play with the playergroup functions to equal the player number.
And I forgot the important step. In your periodic trigger when it is suppose to spawn a unit, put in a new action then go to the top and you should find your action definition in 'general'
Could you not just tell them to "attack" the target location, and they will attack-move towards the destination, stopping to destroy anything they see along the way?
Seems a lot more straightforward than coding in extra behaviour, and it's how the attack order works normally (if you read the tooltip).
@TTFTCUTS: Go
Agreed. I was just facilitating his request. ^_^
Instead of the "move" command, you should use "scan-move". This will make the units defend and attack while moving.
@Orbiter1987: Go
ill give it a shot
@Orbiter1987: Go
It worked thanks!
So what's the difference between scan-move and the attack move then do you know? It sounds like both those commands behave the same way. I've always used attack->point for these sorts of things.
I think scan move is just the ability that units w/o attacks have to fill in the slot for attacking. But I think its just a copy of move. I just issue the attack command on a point normally...so does scan move actually acquire targets and stuff?