• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

[Trigger] I guess easy to make trigger Attack move

Status
Not open for further replies.
Level 19
Joined
Jan 12, 2011
Messages
1,522
  • Move Attack
    • Events
      • Unit - A unit Begins casting an ability
    • Conditions
      • (Ability being cast) Equal to (==) Attack Move
    • Actions
      • Set TempAttack = (Target point of ability being cast)
      • Set TempGroup = (Units owned by (Owner of (Triggering unit)) of type (Unit-type of (Triggering unit)))
      • Unit Group - Pick every unit in TempGroup and do (Unit - Order (Picked unit) to Attack-Move To TempAttack)
      • Custom script: call RemoveLocation(udg_TempAttack)
      • Custom script: call DestroyGroup(udg_TempGroup)

But i don't want it to select ALL units in the map just the units currently in your selection, for example you have a 12 unit selection and you highlight the grunts and use the ability (it's based on far sight so you can click anywhere) when you use it, it should only send the current highlighted grunts but instead it sends every grunt in the map...
 
Level 28
Joined
Sep 26, 2009
Messages
2,520
  • Untitled Trigger 001
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Attack Move
    • Actions
      • Set u = (Triggering unit)
      • Set p = (Target point of ability being cast)
      • Set g = (Units currently selected by (Owner of u))
      • Unit Group - Pick every unit in g and do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Unit-type of (Picked unit)) Equal to (Unit-type of u)
            • Then - Actions
              • Unit - Order (Picked unit) to Attack-Move To p
            • Else - Actions
      • -------- ------------------------------------------------------------------------------ --------
      • Set u = No unit
      • Custom script: call DestroyGroup(udg_g)
      • Custom script: call RemoveLocation(udg_p)
      • Custom script: set udg_g = null
      • Custom script: set udg_p = null
u = unit variable
g = unit group variable
p = point variable

tbh there may not even be a need to use unit group as I did, but instead use custom script "set bj_wantDestroyGroup = true"
 
Level 19
Joined
Jan 12, 2011
Messages
1,522
  • Untitled Trigger 001
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Attack Move
    • Actions
      • Set u = (Triggering unit)
      • Set p = (Target point of ability being cast)
      • Set g = (Units currently selected by (Owner of u))
      • Unit Group - Pick every unit in g and do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Unit-type of (Picked unit)) Equal to (Unit-type of u)
            • Then - Actions
              • Unit - Order (Picked unit) to Attack-Move To p
            • Else - Actions
      • -------- ------------------------------------------------------------------------------ --------
      • Set u = No unit
      • Custom script: call DestroyGroup(udg_g)
      • Custom script: call RemoveLocation(udg_p)
      • Custom script: set udg_g = null
      • Custom script: set udg_p = null
u = unit variable
g = unit group variable
p = point variable

tbh there may not even be a need to use unit group as I did, but instead use custom script "set bj_wantDestroyGroup = true"

What do you mean? by removing destroy group or removing the unit group variable? also which one is faster?
 
Level 28
Joined
Sep 26, 2009
Messages
2,520
What do you mean? by removing destroy group or removing the unit group variable? also which one is faster?
I meant what Maker wrote
basically not using any unit group variable, removing custom script which destroys unit group and instead using actions in this order
  • Custom script: set bj_wantDestroyGroup = true
  • Unit Group - Pick every unit in (Conditions for your unit group) and do (Actions)
    • Loop - Actions
 
Level 19
Joined
Jan 12, 2011
Messages
1,522
I meant what Maker wrote
basically not using any unit group variable, removing custom script which destroys unit group and instead using actions in this order
  • Custom script: set bj_wantDestroyGroup = true
  • Unit Group - Pick every unit in (Conditions for your unit group) and do (Actions)
    • Loop - Actions

Like this?
  • Move Attack
    • Events
      • Unit - A unit Begins casting an ability
    • Conditions
      • (Ability being cast) Equal to (==) Attack Move
    • Actions
      • Set Unit11 = (Triggering unit)
      • Set TempAttack = (Target point of ability being cast)
      • Custom script: set bj_wantDestroyGroup = true
      • Unit Group - Pick every unit in (Units currently selected by (Owner of Unit11)) and do (Actions)
        • Loop - Actions
          • Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Unit-type of (Picked unit)) Equal to (==) (Unit-type of Unit11)
            • Then - Actions
              • Unit - Order (Picked unit) to Attack-Move To TempAttack
            • Else - Actions
              • Do nothing
      • Set Unit11 = No unit
      • Custom script: call RemoveLocation(udg_TempAttack)
      • Custom script: set udg_TempAttack = null
 

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,255
Be aware that getting player unit selection requires synchronization so will pause the thread for an extended period of time based on latency. Thus you may have MUI problems with the globals you are using as another instance of the ability could be cast before the selection group is synchronized for the first cast.
 
Status
Not open for further replies.
Top