• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

[Solved] Good way to let units move to points.

Status
Not open for further replies.
Level 19
Joined
Oct 12, 2007
Messages
1,821
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?
 
Level 33
Joined
Mar 27, 2008
Messages
8,035
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 ?
 
Level 19
Joined
Oct 12, 2007
Messages
1,821
Well all I do is:

JASS:
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?
 
Level 19
Joined
Oct 12, 2007
Messages
1,821
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)
 
Level 25
Joined
Jul 10, 2006
Messages
3,315
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
 
Level 19
Joined
Oct 12, 2007
Messages
1,821
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.
 
Level 19
Joined
Oct 12, 2007
Messages
1,821
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.
 
Hmm I made small test, this work fine:
JASS:
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:

JASS:
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.
 
Level 19
Joined
Oct 12, 2007
Messages
1,821
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!;-)
 
Status
Not open for further replies.
Top