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

[JASS] AoS Spawned Unit Movement

Status
Not open for further replies.
Level 4
Joined
Aug 1, 2007
Messages
66
My movement system works fine as is, but I'm trying to make it more efficient. Right now I've got the whole map (it straight from top to bottom) layed out with regions like a football field and 3 triggers for movement.

Trigger 1:

JASS:
function Trig_Move_Conditions takes nothing returns boolean
    if ( not MovementPrimaryConditionConditions() ) then
        return false
    endif
    return true
endfunction

function Trig_Move_Actions takes nothing returns nothing
    if ( MovementTriggeringUnitIsNonAncientKingNPC() ) then
        call IssuePointOrderLocBJ( GetTriggerUnit(), "attack", GetRectCenter(gg_rct_Queen_Target) )
    else
    endif
    if ( MovementTriggeringUnitIsNonAncientQueenNPC() ) then
        call IssuePointOrderLocBJ( GetTriggerUnit(), "attack", GetRectCenter(gg_rct_King_Target) )
    else
    endif
endfunction

//===========================================================================
function InitTrig_Move takes nothing returns nothing
    set gg_trg_Move = CreateTrigger(  )
    call TriggerRegisterEnterRectSimple( gg_trg_Move, gg_rct_Move_1 )
    call TriggerRegisterEnterRectSimple( gg_trg_Move, gg_rct_Move_2 )
    call TriggerRegisterEnterRectSimple( gg_trg_Move, gg_rct_Move_3 )
    call TriggerRegisterEnterRectSimple( gg_trg_Move, gg_rct_Move_4 )
    call TriggerRegisterEnterRectSimple( gg_trg_Move, gg_rct_Move_5 )
    call TriggerRegisterEnterRectSimple( gg_trg_Move, gg_rct_Move_6 )
    call TriggerRegisterEnterRectSimple( gg_trg_Move, gg_rct_Move_7 )
    call TriggerRegisterEnterRectSimple( gg_trg_Move, gg_rct_Move_8 )
    call TriggerRegisterEnterRectSimple( gg_trg_Move, gg_rct_Move_9 )
    call TriggerRegisterEnterRectSimple( gg_trg_Move, gg_rct_Move_10 )
    call TriggerRegisterEnterRectSimple( gg_trg_Move, gg_rct_Move_12 )
    call TriggerRegisterEnterRectSimple( gg_trg_Move, gg_rct_Move_13 )
    call TriggerRegisterEnterRectSimple( gg_trg_Move, gg_rct_Move_16 )
    call TriggerRegisterEnterRectSimple( gg_trg_Move, gg_rct_Move_17 )
    call TriggerRegisterEnterRectSimple( gg_trg_Move, gg_rct_Move_18 )
    call TriggerRegisterEnterRectSimple( gg_trg_Move, gg_rct_Move_19 )
    call TriggerRegisterEnterRectSimple( gg_trg_Move, gg_rct_Move_20 )
    call TriggerRegisterEnterRectSimple( gg_trg_Move, gg_rct_Move_21 )
    call TriggerRegisterEnterRectSimple( gg_trg_Move, gg_rct_Move_22 )
    call TriggerRegisterEnterRectSimple( gg_trg_Move, gg_rct_Movd_23 )
    call TriggerRegisterEnterRectSimple( gg_trg_Move, gg_rct_Move_24 )
    call TriggerRegisterEnterRectSimple( gg_trg_Move, gg_rct_Movd_25 )
    call TriggerAddCondition( gg_trg_Move, Condition( function Trig_Move_Conditions ) )
    call TriggerAddAction( gg_trg_Move, function Trig_Move_Actions )
endfunction

Trigger 2:

JASS:
function MovementTriggeringUnitIsTheKing takes nothing returns boolean
    return ( GetUnitTypeId(GetTriggerUnit()) == 'n000' )
endfunction

function MovementTriggeringUnitIsThePrince takes nothing returns boolean
    return ( GetUnitTypeId(GetTriggerUnit()) == 'n00D' )
endfunction

function MovementTriggeringUnitIsTheDuke takes nothing returns boolean
    return ( GetUnitTypeId(GetTriggerUnit()) == 'n00G' )
endfunction

function Trig_Move_11_Conditions takes nothing returns boolean
    if ( not MovementPrimaryConditionConditions() ) then
        return false
    endif
    return true
endfunction

function Trig_Move_11_Actions takes nothing returns nothing
    if ( MovementTriggeringUnitIsNonAncientKingNPC() ) then
        call IssuePointOrderLocBJ( GetTriggerUnit(), "attack", GetRectCenter(gg_rct_Queen_Target) )
    else
    endif
    if ( MovementTriggeringUnitIsNonAncientQueenNPC() ) then
        call IssuePointOrderLocBJ( GetTriggerUnit(), "attack", GetRectCenter(gg_rct_King_Target) )
    else
    endif
    if ( MovementTriggeringUnitIsTheKing() ) then
        call IssuePointOrderLocBJ( GetTriggerUnit(), "move", GetRectCenter(gg_rct_The_King) )
    else
    endif
    if ( MovementTriggeringUnitIsThePrince() ) then
        call IssuePointOrderLocBJ( GetTriggerUnit(), "move", GetRectCenter(gg_rct_The_Prince) )
    else
    endif
    if ( MovementTriggeringUnitIsTheDuke() ) then
        call IssuePointOrderLocBJ( GetTriggerUnit(), "move", GetRectCenter(gg_rct_The_Duke) )
    else
    endif
endfunction

//===========================================================================
function InitTrig_Move_11 takes nothing returns nothing
    set gg_trg_Move_11 = CreateTrigger(  )
    call TriggerRegisterEnterRectSimple( gg_trg_Move_11, gg_rct_Move_11 )
    call TriggerRegisterEnterRectSimple( gg_trg_Move_11, gg_rct_Move_14 )
    call TriggerAddCondition( gg_trg_Move_11, Condition( function Trig_Move_11_Conditions ) )
    call TriggerAddAction( gg_trg_Move_11, function Trig_Move_11_Actions )
endfunction

Trigger 3:

JASS:
function MovementTriggeringUnitIsTheQueen takes nothing returns boolean
    return ( GetUnitTypeId(GetTriggerUnit()) == 'n001' )
endfunction

function MovementTriggeringUnitIsThePrincess takes nothing returns boolean
    return ( GetUnitTypeId(GetTriggerUnit()) == 'n00F' )
endfunction

function MovementTriggeringUnitIsTheBaron takes nothing returns boolean
    return ( GetUnitTypeId(GetTriggerUnit()) == 'n00E' )
endfunction

function Trig_Move_15_Conditions takes nothing returns boolean
    if ( not MovementPrimaryConditionConditions() ) then
        return false
    endif
    return true
endfunction

function Trig_Move_15_Actions takes nothing returns nothing
    if ( MovementTriggeringUnitIsNonAncientKingNPC() ) then
        call IssuePointOrderLocBJ( GetTriggerUnit(), "attack", GetRectCenter(gg_rct_Queen_Target) )
    else
    endif
    if ( MovementTriggeringUnitIsNonAncientQueenNPC() ) then
        call IssuePointOrderLocBJ( GetTriggerUnit(), "attack", GetRectCenter(gg_rct_King_Target) )
    else
    endif
    if ( MovementTriggeringUnitIsTheQueen() ) then
        call IssuePointOrderLocBJ( GetTriggerUnit(), "move", GetRectCenter(gg_rct_The_Queen) )
    else
    endif
    if ( MovementTriggeringUnitIsThePrincess() ) then
        call IssuePointOrderLocBJ( GetTriggerUnit(), "move", GetRectCenter(gg_rct_The_Princess) )
    else
    endif
    if ( MovementTriggeringUnitIsTheBaron() ) then
        call IssuePointOrderLocBJ( GetTriggerUnit(), "move", GetRectCenter(gg_rct_The_Baron) )
    else
    endif
endfunction

//===========================================================================
function InitTrig_Move_15 takes nothing returns nothing
    set gg_trg_Move_15 = CreateTrigger(  )
    call TriggerRegisterEnterRectSimple( gg_trg_Move_15, gg_rct_Move_15 )
    call TriggerAddCondition( gg_trg_Move_15, Condition( function Trig_Move_15_Conditions ) )
    call TriggerAddAction( gg_trg_Move_15, function Trig_Move_15_Actions )
endfunction


The reason for the 2 longer triggers is to keep the bosses from being drug to the other side of the map, but I'm trying to fix that with locking guard positions. The main problem is the spawned units running back to the base.
 
Level 14
Joined
Jul 1, 2008
Messages
1,314
Its useless to convert GUI into jass without modifying it.

Your "System" could be optimized, delete "else" and store GetTriggerUnit() in a unit variable and dont use those BJs.
Use jass-craft, you can see the functions, that are called by BJ-functions there.
 
Level 4
Joined
Aug 1, 2007
Messages
66
I understand that it's not really jass yet, I'm just starting to learn jass so I'm changing things one piece at a time and learning as I go. My main problem is keeping the spawned units from running back to the base, if I could stop that I could eliminate these triggers all together and just send them straight to the enemy base since it's a straight line. I spawn like this:

JASS:
    set u = CreateUnit( Player(0), 'h00T', -2.4, -11838.0, 492.3 )
     call IssuePointOrderLoc(u,"attack",k)
     set u = CreateUnit( Player(6), 'h011', -9.8, 11785.3, 476.7 )
     call IssuePointOrderLoc(u,"attack",q)
     call TriggerSleepAction( 1.00 )
     set u = CreateUnit( Player(0), 'e004', -2.4, -11838.0, 492.3 )
     call IssuePointOrderLoc(u,"attack",k)
     set u = CreateUnit( Player(6), 'e00K', -9.8, 11785.3, 476.7 )
     call IssuePointOrderLoc(u,"attack",q)
     call TriggerSleepAction( 1.00 )
     set u = CreateUnit( Player(0), 'h006', -2.4, -11838.0, 492.3 )
     call IssuePointOrderLoc(u,"attack",k)
     set u = CreateUnit( Player(6), 'h018', -9.8, 11785.3, 476.7 )
     call IssuePointOrderLoc(u,"attack",q)
     call TriggerSleepAction( 1.00 )
     set u = CreateUnit( Player(0), 'h010', -2.4, -11838.0, 492.3 )
     call IssuePointOrderLoc(u,"attack",k)
     set u = CreateUnit( Player(6), 'h016', -9.8, 11785.3, 476.7 )
     call IssuePointOrderLoc(u,"attack",q)
     call RemoveLocation (k)
     call RemoveLocation (q)
     set u = null
     set k = null
     set q = null

K and q are set earlier in the trigger, but there's alot of other stuff between so I just copied this part. This can send them straight to the end if they wouldn't run back. I'm mainly trying to get rid of some regions to improve load times. Is there a way to stop units from running back or trigger movement without having regions preplaced on the map?
 
Level 14
Joined
Jul 1, 2008
Messages
1,314
also there is something called "creeps - guard distance" in the Game Options in the main Window --> Game Interface.

You could try to modify those values, so the creeps are not running back. Maybe you could try to set the "Max. Guard Distance" to "10000", i think your problem should be solved there.

Greets
 
Level 23
Joined
Nov 29, 2006
Messages
2,482
The AI of the computer is not turned off completely even though you dont have a melee script enabled. You could try, that everytime the spawned unit is created disable AI for it:
  • AI - Ignore <Insert unit here>'s guard position
It should work, thus it does in my own map. It should also prevent them from trying to move back to base after they've reached the final region

If it doesn't you can also try to uncheck the field 'stats - can flee' in the unit editor. But do the first one first...
 
Level 4
Joined
Aug 1, 2007
Messages
66
The problem isn't that they run back after they reach the base, they move forward until they get in combat and run back to the base as soon as they don't have a target anymore. So I can send them straight to the enemy base when they spawn, but without more movement triggers they just end up standing where they spawned unless the never get out of cambat once they get into combat.

When I use the ignore guard position they don't run back but they just stand whereever they're at when they get out of combat. Uncheck the "can flee" doesn't seem to change anything.

I'm sorry if I'm confusing you and I aprreciate you guys trying to help.
 
Level 4
Joined
Aug 1, 2007
Messages
66
My problem isn't keeping them at the target once they get there, it's getting them there without a bunch of back and forth. Here's what happens. Point A is the home base, point C is the enemy base, and point B is somewhere inbetween. The spawn at point A with an order to attack move direcetly to point C, but at point B they meet enemies and fight. As soon as they're done fighting and have no more enemy targets, they turn around and run back to point A. I've dealt with it so far by laying out the entire map in zones like a football field so they can't go very far back before they're sent forward again and it works fine, but it just seems like there's gotta be a better way. And I'm changing my map now to be more focused on capturing zones and flags and some other things so I'll have more lanes and more creeps and I'd like to figure out a better way to move them.
 
Level 5
Joined
Jan 6, 2006
Messages
106
Hmm... I see. Or you may try using a constantly looping trigger which orders the spawned units to continually attack-move towards the targeted point. Specify a directional code for each region. Assign a custom value to all spawned creeps as a directional code, and every about 5 seconds order all creeps of each directional code to attack-move to their specified regions. As soon as they reach the specified region, change their directional codes accordingly.. You may want a global unit group for those creeps.

That may result in a little performance downfall but it's confirmed to be working. That's what I use in my map. Hope this helps. :)
 
Status
Not open for further replies.
Top