View Full Version : [Solved] Good way to let units move to points.
Sephalo
07-29-2012, 01:18 PM
Heya,
I'm looking for a good way to order a unit to move somewere. For some reason units I give the "attack" command to a specific x/y location will return to their spawn spot after some time before even reaching the point I wanted them to go to.
This happens to Neutral Hostile creatures but also to player controlled creatures so I don't know what's causing this.
How do people here handle stuff like this?
defskull
07-29-2012, 02:02 PM
Once you have ordered a unit to attack to a certain location/coordinates, they won't turn back, because it does not have orders to turn back (unless you ordered them to), lol.
Can you provide a test map so I can see the situation example you're talking about ?
Sephalo
07-29-2012, 02:08 PM
Well all I do is:
set u = CreateUnit(p, 'H02A', x, y, 0.)
call IssuePointOrder(u, "attack", 9730., 8445.)
set u = null
after a few seconds when the hero is halfway he returns to the spot he spawned. Or when I move with units in front of him so that he tries to attack my units, then after a while of being unable to attack me (cus I outrun him) he returns, but he returns to his spawn point instead of returning to his order to attack move to the given area.
Can't post a testmap.
But the player owning the summoned unit is in this case Player(10) with that player having the normal computer AI. But as I said, this also happens to Neutral Hostile creatures.
I can only guess this is from the Gameplay Constants:
Creeps - Guard Return Distance - 10000.00
Creeps - Guard Return Time (sec) - 8.00
But there should be away to ignore this whenever I want to with some triggers... Any idea's?
gorillabull
08-01-2012, 08:22 AM
the order needs to be attack- move to and dont use neutrals use player units, if you just issue an attack order then the guard distance is still saved to their original starting location where as when you issue them to move the guard location changes
mckill2009
08-01-2012, 08:36 AM
set u = CreateUnit(p, 'H02A', x, y, 0.)
call RemoveGuardPosition(u)
call IssuePointOrder(u, "attack", 9730., 8445.)
set u = null
although it may/may not work on heroes...
OR just put the unit in a group loop, then order it to attack at the designated point...
Sephalo
08-01-2012, 01:08 PM
Well Gorillabull, that's not really helpful.
The order 'attack move' doesn't excist. If you get a GUI function and order a unit to attack-move and you convert it to jass, you will see it will come out as the "attack" order on a location instead of a unit. So attack order on ground will come out as attack ground, obviously.
Anyways. I don't have the luxury to use player units because a few units have to be owned by neutral hostile. And with player owned units the same problem occurs, so it doesn't even make sence that it will help.
Currently I found some kind of a solution. I just had to gamble, but the units dont seem to be able to remember their order for more then a few seconds, let's say 5. So I put down a few rects and made 'unit enters rect' events. Then when they enter the rects I use this:
SetUnitX(GetUnitX(unit)) and same for Y. For some reason resetting their position resets the few seconds they can remember their order. However if they move after an enemy and therefor don't walk in a new rect, they will forget their order and return all the way to their spawn position... So it's pretty fucked up...
My map needs pretty much automated unit movements.. i call this unit AI just for the simplicity. However... I don't want to have to create a loop and group for every unit... Also because if I order a unit to attack move to a point while he is in combat, he will automatically get a new attack target, in most cases the closest unit. While he maybe was supposed to attack an other target because of a taunt spell or whatever... So this could fuckup taunts or other unit orders...
So hmm... I was hoping anyone really knew how the wc3 engine handles these things, because it's a bit weird at the moment. (I repeat, it's not just Neutral Hostile, but this problem is also with Player 9, 10, 11... or 10, 11, 12 in GUI)
rulerofiron99
08-02-2012, 09:59 AM
Forgive me if I've missed something, but would it be possible for those AI units to not have Computer (Normal) controlling them?
IIRC that can make a difference, since computer-controlled units have minds of their own.
You should also test again with Guard Distance, Guard Return Distance and Guard Return Time all set to 999999.
If all else fails, use that looping system as you mentioned, and add a system that checks if the unit currently has a target or not. This can be done fairly easily by:
- indexing system for units
- a int/real variable per unit to keep track of its "attack cooldown"
- "attack cooldown" variable reset whenever the unit attacks
- if this variable reaches 5, it gets added to the loop that moves them around
Starquizer
08-02-2012, 10:17 AM
I guess you will have to manipulate the Blizzard.J file it contains lots of functions which may be related to creeps returning to their initial position.
Sephalo
08-02-2012, 01:25 PM
Didnt read mckill2009's post, but that might be a solution for it. I'm going to try that out when I'm home again.
And as rulerofiron99 said, it might be a good idea if, in any case, I cant find a solution, to use a system that orders units to return and get guard distance to a high value. Think it's easier to order units to return to their spawn spot, then to avoid some units to not do this automatically.
Deffo gonna try some things out and who knows something good comes out of it.
mckill2009
08-02-2012, 03:45 PM
Forgive me if I've missed something, but would it be possible for those AI units to not have Computer (Normal) controlling them?
it's possible but non-computer controlled AI cannot cast spells on their own, you have to trigger them, which is more complicated unless you have a cast system...
Sephalo
08-02-2012, 04:16 PM
Forgot to reply to that yeah, but they have to be owned by Computer (something) because I want them to automatically use spells like Stormbolt, Curse, Slow etc... Else I would have to make a spell-cast AI system in addition to all other AI stuff.
-Kobas-
08-02-2012, 11:30 PM
Hmm I made small test, this work fine:
function Trig_Untitled_Trigger_002_Actions takes nothing returns nothing
local unit u = CreateUnit(Player(1), 'hfoo', 0., 0., 0.)
call RemoveGuardPosition(u)
call IssuePointOrder(u, "attack", 2000., 0.)
set u = null
endfunction
//===========================================================================
function InitTrig_Untitled_Trigger_002 takes nothing returns nothing
set gg_trg_Untitled_Trigger_002 = CreateTrigger( )
call TriggerRegisterPlayerEventEndCinematic( gg_trg_Untitled_Trigger_002, Player(0) )
call TriggerAddAction( gg_trg_Untitled_Trigger_002, function Trig_Untitled_Trigger_002_Actions )
endfunction
and this won't:
function Trig_Untitled_Trigger_002_Actions takes nothing returns nothing
local unit u = CreateUnit(Player(1), 'hfoo', 0., 0., 0.)
//call RemoveGuardPosition(u)
call IssuePointOrder(u, "attack", 2000., 0.)
set u = null
endfunction
//===========================================================================
function InitTrig_Untitled_Trigger_002 takes nothing returns nothing
set gg_trg_Untitled_Trigger_002 = CreateTrigger( )
call TriggerRegisterPlayerEventEndCinematic( gg_trg_Untitled_Trigger_002, Player(0) )
call TriggerAddAction( gg_trg_Untitled_Trigger_002, function Trig_Untitled_Trigger_002_Actions )
endfunction
with Computer controllable player.
Sephalo
08-03-2012, 01:39 PM
Alright great! Thanks Kobas.
I'm currently still enjoying my heath-wave holiday in turkey. But once I get back I will use this in my map.
Let's treat this thread as solved!;-)
vBulletin® v3.8.7, Copyright ©2000-2013, vBulletin Solutions, Inc.
Search Engine Optimization by
vBSEO 3.5.1 PL2