• 🏆 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!
  • 🏆 Hive's 6th HD Modeling Contest: Mechanical is now open! Design and model a mechanical creature, mechanized animal, a futuristic robotic being, or anything else your imagination can tinker with! 📅 Submissions close on June 30, 2024. Don't miss this opportunity to let your creativity shine! Enter now and show us your mechanical masterpiece! 🔗 Click here to enter!

[JASS] AI Movement problems

Status
Not open for further replies.
Level 9
Joined
Jun 7, 2008
Messages
440
I've been reworking this multiple times and yet, for some reason, 20% of the ai returns back to the intial spawn point. Im stumped. :vw_wtf:

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

function Trig_Light_Imperial_Top_Actions takes nothing returns nothing 
    local unit u = GetTriggerUnit()
    local real x
    local real y
    if RectContainsUnit(gg_rct_Imperial_Waypoint_1_Top, u) == true then
        set x = (GetRandomReal(GetRectMinX(gg_rct_Imperial_Waypoint_1_Top), GetRectMaxX(gg_rct_Imperial_Waypoint_1_Top)))
        set y = (GetRandomReal(GetRectMinY(gg_rct_Imperial_Waypoint_1_Top), GetRectMaxY(gg_rct_Imperial_Waypoint_1_Top)))
    endif
    if RectContainsUnit(gg_rct_Imperial_WP_Bottom, u) == true then
        set x = (GetRandomReal(GetRectMinX(gg_rct_Imperial_Waypoint_1_Bottom), GetRectMaxX(gg_rct_Imperial_Waypoint_1_Bottom)))
        set y = (GetRandomReal(GetRectMinY(gg_rct_Imperial_Waypoint_1_Bottom), GetRectMaxY(gg_rct_Imperial_Waypoint_1_Bottom)))
    endif
    if RectContainsUnit(gg_rct_Imperial_WP_Top, u) == true or RectContainsUnit(gg_rct_Imperial_WP_Bottom, u) then
        set x = (GetRandomReal(GetRectMinX(gg_rct_Imperial_WayPoint_Mid), GetRectMaxX(gg_rct_Imperial_WayPoint_Mid)))
        set y = (GetRandomReal(GetRectMinY(gg_rct_Imperial_WayPoint_Mid), GetRectMaxY(gg_rct_Imperial_WayPoint_Mid)))
    endif
    if RectContainsUnit(gg_rct_Imperial_WayPoint_Mid, u) == true then
        set x = (GetRandomReal(GetRectMinX(gg_rct_Imperial_Corner_Left), GetRectMaxX(gg_rct_Imperial_Corner_Left)))
        set y = (GetRandomReal(GetRectMinY(gg_rct_Imperial_Corner_Left), GetRectMaxY(gg_rct_Imperial_Corner_Left)))
    endif
    if RectContainsUnit(gg_rct_Imperial_Corner_Left, u) == true then
        set x = (GetRandomReal(GetRectMinX(gg_rct_Imperial_Corner), GetRectMaxX(gg_rct_Imperial_Corner)))
        set y = (GetRandomReal(GetRectMinY(gg_rct_Imperial_Corner), GetRectMaxY(gg_rct_Imperial_Corner)))
    endif
    if RectContainsUnit(gg_rct_Imperial_Corner, GetTriggerUnit()) == true then
        set x = (GetRandomReal(GetRectMinX(gg_rct_Imperial_Corner_Top), GetRectMaxX(gg_rct_Imperial_Corner_Top)))
        set y = (GetRandomReal(GetRectMinY(gg_rct_Imperial_Corner_Top), GetRectMaxY(gg_rct_Imperial_Corner_Top)))
    endif
    if RectContainsUnit(gg_rct_Imperial_Corner_Top, GetTriggerUnit()) == true then
        set x = (GetRandomReal(GetRectMinX(gg_rct_Nuetral), GetRectMaxX(gg_rct_Nuetral)))
        set y = (GetRandomReal(GetRectMinY(gg_rct_Nuetral), GetRectMaxY(gg_rct_Nuetral)))
    endif
    if RectContainsUnit(gg_rct_Nuetral, GetTriggerUnit()) == true then
        set x = (GetRandomReal(GetRectMinX(gg_rct_Sylvan_Corner), GetRectMaxX(gg_rct_Sylvan_Corner)))
        set y = (GetRandomReal(GetRectMinY(gg_rct_Sylvan_Corner), GetRectMaxY(gg_rct_Sylvan_Corner)))
    endif
    if RectContainsUnit(gg_rct_Sylvan_Corner, GetTriggerUnit()) == true then
        set x = (GetRandomReal(GetRectMinX(gg_rct_Sylvan_WayPoint_Mid), GetRectMaxX(gg_rct_Sylvan_WayPoint_Mid)))
        set y = (GetRandomReal(GetRectMinY(gg_rct_Sylvan_WayPoint_Mid), GetRectMaxY(gg_rct_Sylvan_WayPoint_Mid)))
    endif
    if RectContainsUnit(gg_rct_Sylvan_WayPoint_Mid, GetTriggerUnit()) == true then
        set x = (GetRandomReal(GetRectMinX(gg_rct_Sylvan_Concluder), GetRectMaxX(gg_rct_Sylvan_Concluder)))
        set y = (GetRandomReal(GetRectMinY(gg_rct_Sylvan_Concluder), GetRectMaxY(gg_rct_Sylvan_Concluder)))
    endif
    if RectContainsUnit(gg_rct_Sylvan_Concluder, GetTriggerUnit()) == true then
        set x = GetUnitX(gg_unit_h00J_0199)
        set y = GetUnitY(gg_unit_h00J_0199)
    endif
    call IssuePointOrder(u, "attack", x, y)
    set u = null 
endfunction

//===========================================================================
function InitTrig_Imperial_AI_Move takes nothing returns nothing
    local trigger t = CreateTrigger()
    call TriggerRegisterEnterRectSimple( t, gg_rct_Imperial_WP_Top )
    call TriggerRegisterEnterRectSimple( t, gg_rct_Imperial_WP_Bottom )
    call TriggerRegisterEnterRectSimple( t, gg_rct_Imperial_Waypoint_1_Top )
    call TriggerRegisterEnterRectSimple( t, gg_rct_Imperial_Waypoint_1_Bottom )
    call TriggerRegisterEnterRectSimple( t, gg_rct_Imperial_WayPoint_Mid )
    call TriggerRegisterEnterRectSimple( t, gg_rct_Imperial_Corner_Left )
    call TriggerRegisterEnterRectSimple( t, gg_rct_Imperial_Corner )
    call TriggerRegisterEnterRectSimple( t, gg_rct_Imperial_Corner_Top )
    call TriggerRegisterEnterRectSimple( t, gg_rct_Nuetral )
    call TriggerRegisterEnterRectSimple( t, gg_rct_Sylvan_Corner )
    call TriggerRegisterEnterRectSimple( t, gg_rct_Sylvan_WayPoint_Mid )
    call TriggerRegisterEnterRectSimple( t, gg_rct_Sylvan_Concluder )
    call TriggerAddCondition( t, Condition( function Trig_Light_Imperial_Top_Conditions ) )
    call TriggerAddAction( t, function Trig_Light_Imperial_Top_Actions )
endfunction
 
Status
Not open for further replies.
Top