• 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.

unit group attacking unit group

Status
Not open for further replies.
Level 4
Joined
Jun 14, 2008
Messages
72
i was wondering if it was posable to make a unit group attack a unit group
and they are both nutral hostile
  • Untitled Trigger 004
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Unit Group - Add all units of (Units in Region 010 <gen>) to attkingguards1
      • Unit Group - Add all units of (Units in Region 011 <gen>) to defendingoutlaws1
      • Unit Group - Order attkingguards1 to Attack Enforcer 0048 <gen>
      • Unit Group - Order defendingoutlaws1 to Attack Footman 0008 <gen>
 
Level 4
Joined
Jul 24, 2008
Messages
108
I'm sorry :) i just felt like making a super complicated way of doing what you asked

JASS:
function groupattacks takes nothing returns nothing
    local group g = GetUnitsInRectAll(udg_region1)
    local group h = GetUnitsInRectAll(udg_region2)
    local unit u
    local location loc
    loop
        set u = FirstOfGroup(g)
        exitwhen u == null
        set loc = GetUnitLoc(GroupPickRandomUnit(h))
        call IssuePointOrderLocBJ(u , "attack" , loc )
        call GroupRemoveUnit(g, u)
        set loc = null
    endloop
    set g = GetUnitsInRectAll(udg_region1)
    set h = GetUnitsInRectAll(udg_region2)
    loop
        set u = FirstOfGroup(h) 
        exitwhen u == null
        set loc = GetUnitLoc(GroupPickRandomUnit(g))
        call IssuePointOrderLocBJ(u , "attack" , loc )
        call GroupRemoveUnit(g, u)
        set loc = null
    endloop
    set g = null
    set h = null
    set u = null
    call DestroyGroup(g)
    call DestroyGroup(h)
    call RemoveLocation(loc)
endfunction

Just put that into ur custom text initialization area and to call it using custom script "call groupattacks()" replace region1 and region2 with the regions you want.

This tells every unit in one region to attack a random unit in the other and vice versa and they will meet in the middle
 
Level 4
Joined
Jul 24, 2008
Messages
108
Well i guess i fail...oh purple i got this super epic site you should check out

www.purple.com

Thanks for telling me about the leaks tho, honestly, i use something similar in my map and had my beta map lag like hell. so now i know why :)


but to help the origenal poster
  • Untitled Trigger 004
  • Events
  • Time - Elapsed time is 5 seconds
  • Conditions
  • Actions
  • Unit Group - Add all units of (Units in Region 010 <gen>) to attkingguards1
  • Unit Group - Add all units of (Units in Region 011 <gen>) to defendingoutlaws1
  • Unit Group - Pick every unit in attkingguards1 and do order picked units to attack-move to position of a random unit in defendingoutlaws1
  • Unit Group - Pick every unit in defendingoutlaws1 and do order picked units to attack-move to position of a random unit in attkingguards1
 
Last edited:

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,258
The optimum way for syncronized non random asssults that are done efficently is to loop though both groups at the same time and asign the units to target each other. If one group runs out of units before the other, then you get it to target a random unit.

Mapping the groups to an unit array would make this process even more efficent as the get random unit process would then be O(1) (direct random integer to unit slot) as apposed to blizzards slow O(n) (loops though all units in the group getting a random integer each time and setting tons of variales) method. The disadvantage of mapping the group to an unit array would be it is initially slow as it has to loop through the group to asign each unit a slot (probably faster than one of blizzards random unit from group calls lol), but after that it would be faster as you can loop through all units simply by using an integer comparison and opperation.
 
Status
Not open for further replies.
Top