• Check out the results of the Techtree Contest #19!
  • 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.
  • Create a void inspired texture for Warcraft 3 and enter Hive's 34th Texturing Contest: Void! Click here to enter!
  • The Hive's 22nd Icon Contest: Creep Abilities is now concluded, time to vote for your favourite set of icons! Click here to vote!

[Trigger] Squad system problem:

Status
Not open for further replies.
Level 4
Joined
Mar 26, 2008
Messages
100
I have been making my own squad system and I got a few questions:

I've using custom values (all members of a squad have the same custom value and so I can select them), is there another way?

When a squad moves, how can I get the offsets of where it should go ?
Like, I don't want them to mass up humping each other while trying to go at a single point, I want to go in a formation or something.
I think this can be accomplished only with JASS, though.

Can someone give me a list of all orders (the unprocessed version,like "move" or "attack") ?

Thanks!
 
You mean, I should use two indexed variables, one for the angle and the other for the position, and then refer to them in a for loop ?
I've tried and it didn't work because some units blocked off others and made a mess.
 
No only 1 indexed variable.

Like:
funtion groupmove takes unit array u, integer unitsInGroup returns nothing
local real x
local real y
local real dist
local real angle
loop
exitwhen index>unitsInGroup
set dist=GetRandomReal(100,400)
set angle=index*(360/unitsInGroup)
set x=GetUnitX(u[index])+dist*Cos(angle*bj:DEGTORAD)
set y=GetUnitY(u[index])+dist*Sin(angle*bj:DEGTORAD)
call SetUnitX(u[index],x)
call SetUnitY(u[index],y)
set index=index+1
endloop
endfunction

I don't usually write code without an editor, so that of course is not real code that will work.
 
No only 1 indexed variable.

Like:
funtion groupmove takes unit array u, integer unitsInGroup returns nothing
local real x
local real y
local real dist
local real angle
loop
exitwhen index>unitsInGroup
set dist=GetRandomReal(100,400)
set angle=index*(360/unitsInGroup)
set x=GetUnitX(u[index])+dist*Cos(angle*bj:DEGTORAD)
set y=GetUnitY(u[index])+dist*Sin(angle*bj:DEGTORAD)
call SetUnitX(u[index],x)
call SetUnitY(u[index],y)
set index=index+1
endloop
endfunction
What's bj ?
 
This should do it:
JASS:
//g is the group you want to move
//targetX is the x point you want the group to move to
//targetY is the y point you want the group to move to
//dist is the distance from the target you want each unit to be

function GroupMove takes group g, real targetX, real targetY, real dist returns nothing
    local integer i = 0
    local unit u
    local real x
    local real y
    local real angle
    local integer numUnits = CountUnitsInGroup(g)
    local group g2 = CreateGroup()
    call GroupAddGroup(g, g2)
    loop
        set u = FirstOfGroup(g2)
        exitwhen u == null
        
        set angle=i*((2*bj_PI)/numUnits)
        set x=targetX+dist*Cos(angle)
        set y=targetY+dist*Sin(angle)
        call IssuePointOrder(u, "move", x, y)
        
        set i = i + 1
        call GroupRemoveUnit(g2, u)
    endloop
    
    set u = null
    call DestroyGroup(g2)
    set g2 = null
endfunction
It puts the units in a circle formation around the target X/Y

EDIT: Oops, declared a local that was taken as a parameter. Fixed.
 
Last edited:
About moving in formation, DSG already once told that is impossible in warcraft because of pathing implementation.

Not using custom value is possible. But it will require a little more time (it shouldn't be so demanding though). Just make a function which cycle through all groups in the array where are the groups stored and it returns the array position in which is the group containing that unit stored.
 
an array has limited slots though.
Also, I don't really know how to write JASS, I know a few other languages, but not JASS. I'm too lazy to open up the function library and start testing with stuff.
 
Is it in vjass ?

What the hell, the map makes warcraft 3 crash when I try ordering something.
Apart from the numerous leaks (I will fix them once this is finished), anyone knows why ?
 

Attachments

No, it's not vJass. I might have got some syntax errors. Let me check it over.

EDIT: I just downloaded the map, I think the reason it gives errors is you put it in a trigger on its own. Unless you use JassNewGenPack it should go in the map header (click on the name of the map in the trigger editor, there is a section you can type into there)

EDIT2: I just looked over your code, and, quite frankly, it fails. It simply won't work at all.
 
Status
Not open for further replies.
Back
Top