• 🏆 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!

[JASS] Units Stop Moving

Status
Not open for further replies.
Level 9
Joined
Jun 7, 2008
Messages
440
Good Morning. I've been having trouble with my AI unit movement.

The trigger(s) work perfect. Basically what happens is the units spawn every second and move accordingly. Once they reach a rect they move on. The problem is, once in a blue moon, a unit will stop moving, and it doesn't happen at just one rect, it happens at all of them. Is it possible that the trigger could be interrupted (there is no wait times. Its just - unit reaches rect, and move on)? And if so, is there a way to get around that?
 
Level 37
Joined
Mar 6, 2006
Messages
9,240
Your unit is in region check may fail, you may have too many units controlled by one player, or the unit stops because the surrondings are too crowded.

So you need a script that finds units that are not moving? It's pretty simple. Store the current x and y of the unit and check them again after a small period, about 0.03 seconds. If they match, the unit is not moving. I bet there's that kind of system in the spell section.
 
Level 9
Joined
Jun 7, 2008
Messages
440
I can show you, but you really know what it looks like. I got a bunch of rects listed in the events function. and the actions a bunch of if/endif points.

EDIT : I checked out the link you provided. wow. Thats way above my ability to understand that. :sad:
 
Level 9
Joined
Jun 7, 2008
Messages
440
okay here it is:
JASS:
function Trig_Light_Waypoint_1_Conditions takes nothing returns boolean
    return GetOwningPlayer(GetEnteringUnit()) == Player(9)
endfunction

function Trig_Light_Waypoint_1_Actions takes nothing returns nothing 
    local unit u = GetTriggerUnit()
    local real x = (GetRandomReal(GetRectMinX(gg_rct_Light_WayPoint_2), GetRectMaxX(gg_rct_Light_WayPoint_2)))
    local real y = (GetRandomReal(GetRectMinY(gg_rct_Light_WayPoint_2), GetRectMaxY(gg_rct_Light_WayPoint_2)))
    call IssuePointOrder(u, "attack", x, y) 
    set u = null 
endfunction

//===========================================================================
function InitTrig_Light_Waypoint_1 takes nothing returns nothing
    set gg_trg_Light_Waypoint_1 = CreateTrigger(  )
    call TriggerRegisterEnterRectSimple(gg_trg_Light_Waypoint_1, gg_rct_Light_WayPoint_1)
    call TriggerAddCondition( gg_trg_Light_Waypoint_1, Condition( function Trig_Light_Waypoint_1_Conditions ) )
    call TriggerAddAction( gg_trg_Light_Waypoint_1, function Trig_Light_Waypoint_1_Actions )
endfunction

JASS:
function Trig_Light_Waypoint_2_Conditions takes nothing returns boolean
    return GetOwningPlayer(GetEnteringUnit()) == Player(9)
endfunction

function Trig_Light_Waypoint_2_Actions takes nothing returns nothing 
    local unit u = GetTriggerUnit()
    local real x = (GetRandomReal(GetRectMinX(gg_rct_Light_WayPoint_3), GetRectMaxX(gg_rct_Light_WayPoint_3)))
    local real y = (GetRandomReal(GetRectMinY(gg_rct_Light_WayPoint_3), GetRectMaxY(gg_rct_Light_WayPoint_3)))
    call IssuePointOrder(u, "attack", x, y) 
    set u = null 
endfunction

//===========================================================================
function InitTrig_Light_Waypoint_2 takes nothing returns nothing
    set gg_trg_Light_Waypoint_2 = CreateTrigger(  )
    call TriggerRegisterEnterRectSimple( gg_trg_Light_Waypoint_2, gg_rct_Light_WayPoint_2 )
    call TriggerAddCondition( gg_trg_Light_Waypoint_2, Condition( function Trig_Light_Waypoint_2_Conditions ) )
    call TriggerAddAction( gg_trg_Light_Waypoint_2, function Trig_Light_Waypoint_2_Actions )
endfunction

This goes on 7 more times. A random unit will stop at the beginning of a random rect. :vw_sad:
 
Level 20
Joined
Feb 24, 2009
Messages
2,999
Right well, one way would be to make a function/trigger for every rect that runs on a periodic timer at say... every 0.75s?

Loop for every unit in that rect, parse set coordinates which should be pre-stored in a string array (0-8) [These will be the centre coordinates of said rect] and when ordering to 'attack' the coordinates use; storedcoordinatestring(rnd num between 0-8*).

This is not the most efficient way, 9 timers at 0.75s... but it will ensure you don't get any 'dawdlers'.

*No idea what the actual syntax/function is for random integer in JASS

Hope that helps somewhat =/

EDIT: Noticed a problem with that, units will be in the rect for longer than 0.75s, so you'd somehow need to classify them and condition them out of the call until they've left a rect, at which point remove it and allow for reordering.
 
Status
Not open for further replies.
Top