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

moving idle units

Status
Not open for further replies.

zzc

zzc

Level 3
Joined
Apr 25, 2016
Messages
20
i have tried to find a trigger/s to perform the above but cant seem to find or understand so I created a set of trigs to move ai units.

the non hero units enter via dark portal ability cast by the hero, then after attacking nearby enemy they would be standing around.

the hero units of the same owner have their own move trigger.

so is the following correct?

  • function Trig_move_along_start_Conditions takes nothing returns boolean
    • if ( not ( IsUnitType(GetEnteringUnit(), UNIT_TYPE_HERO) == false ) ) then
      • return false
    • endif
    • if ( not ( GetOwningPlayer(GetEnteringUnit()) == Player(6) ) ) then
      • return false
    • endif
    • return true
  • endfunction
  • function Trig_move_along_start_Actions takes nothing returns nothing
    • call GroupAddUnitSimple( GetEnteringUnit(), udg_movegroup )
  • endfunction
  • //===========================================================================
  • function InitTrig_move_along_start takes nothing returns nothing
    • set gg_trg_move_along_start = CreateTrigger( )
    • call TriggerRegisterEnterRectSimple( gg_trg_move_along_start, GetPlayableMapRect() )
    • call TriggerAddCondition( gg_trg_move_along_start, Condition( function Trig_move_along_start_Conditions ) )
    • call TriggerAddAction( gg_trg_move_along_start, function Trig_move_along_start_Actions )
  • endfunction
that is to catch entering units and put them in a variable

  • function Trig_move_along_Conditions takes nothing returns boolean
    • if ( not ( CountUnitsInGroup(udg_movegroup) > 0 ) ) then
      • return false
    • endif
    • return true
  • endfunction
  • function Trig_move_along_Actions takes nothing returns nothing
    • call GroupPointOrderLocBJ( udg_movegroup, "attack", GetRectCenter(gg_rct_EndArchimondeAtTree01) )
  • endfunction
  • //===========================================================================
  • function InitTrig_move_along takes nothing returns nothing
    • set gg_trg_move_along = CreateTrigger( )
    • call TriggerRegisterTimerEventPeriodic( gg_trg_move_along, 30.00 )
    • call TriggerAddCondition( gg_trg_move_along, Condition( function Trig_move_along_Conditions ) )
    • call TriggerAddAction( gg_trg_move_along, function Trig_move_along_Actions )
  • endfunction
see if the unit group has at least 1 unit then get them to attack

  • function Trig_move_along_idle_Conditions takes nothing returns boolean
    • if ( not ( CountUnitsInGroup(udg_movegroup) > 0 ) ) then
      • return false
    • endif
    • if ( not ( GetIssuedOrderIdBJ() == String2OrderIdBJ("none") ) ) then
      • return false
    • endif
    • return true
  • endfunction
  • function Trig_move_along_idle_Actions takes nothing returns nothing
    • call GroupPointOrderLocBJ( udg_movegroup, "attack", GetRectCenter(gg_rct_EndArchimondeAtTree01) )
  • endfunction
  • //===========================================================================
  • function InitTrig_move_along_idle takes nothing returns nothing
    • set gg_trg_move_along_idle = CreateTrigger( )
    • call TriggerRegisterTimerEventPeriodic( gg_trg_move_along_idle, 30.00 )
    • call TriggerAddCondition( gg_trg_move_along_idle, Condition( function Trig_move_along_idle_Conditions ) )
    • call TriggerAddAction( gg_trg_move_along_idle, function Trig_move_along_idle_Actions )
  • endfunction
get the idle units moving

all trigs are gui converted to text

the cycle is 30 secs - too fast?
any leaks to fix?
 
Level 37
Joined
Jul 22, 2015
Messages
3,485
Oh lord, you used the wrong tags. Since you are posting JASS code, please use [code=jass][/code] tags (the same tags will work for vJASS).

Also, why would you convert GUI to text...? That really kills readability. Please just keep the normal GUI code the way it is. Sorry if this didn't really help with your question, but I really don't remember what natives are called from the BJ functions.
 

zzc

zzc

Level 3
Joined
Apr 25, 2016
Messages
20
ok here goes the trigs
 

Attachments

  • Clipboard04.jpg
    Clipboard04.jpg
    99.4 KB · Views: 81
  • Clipboard05.jpg
    Clipboard05.jpg
    100.6 KB · Views: 81
  • Clipboard06.jpg
    Clipboard06.jpg
    103.7 KB · Views: 83

zzc

zzc

Level 3
Joined
Apr 25, 2016
Messages
20
There more neat now



  • move along start
    • Events
      • Unit - A unit enters (Playable map area)
    • Conditions
      • ((Entering unit) is A Hero) Equal to False
      • (Owner of (Entering unit)) Equal to Player 7 (Green)
    • Actions
      • Unit Group - Add (Entering unit) to movegroup

  • move along
    • Events
      • Time - Every 30.00 seconds of game time
    • Conditions
      • (Number of units in movegroup) Greater than 0
    • Actions
      • Unit Group - Order movegroup to Attack-Move To (Center of EndArchimondeAtTree01 <gen>)

  • move along idle
    • Events
      • Time - Every 30.00 seconds of game time
    • Conditions
      • (Number of units in movegroup) Greater than 0
      • (Issued order) Equal to (Order(none))
    • Actions
      • Unit Group - Order movegroup to Attack-Move To (Center of EndArchimondeAtTree01 <gen>)
 
You can try something like this

  • init
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Set EndArchLoc = (Center of EndArchimondeAtTree01 <gen>)
  • trig
    • Events
      • Time - Every 5.00 seconds of game time
    • Conditions
    • Actions
      • Unit Group - Pick every unit in movegroup and do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Current order of (Picked unit)) Not equal to (Order(attack))
              • (Current order of (Picked unit)) Not equal to (Order(smart))
            • Then - Actions
              • Unit - Order (Picked unit) to Attack-Move To EndArchLoc
            • Else - Actions

Destroy EndArchLoc if you ever stop using it.
 

zzc

zzc

Level 3
Joined
Apr 25, 2016
Messages
20
ok so i just input those 2 trigs?

no destroy cause it will run until end of mission
 
Status
Not open for further replies.
Top