Add most objects within an area of the map to a group...

In need of technical review - looks like some stuff has changed in WZ 3.2.

Also, looks like the x,y params were world coords instead of tile coords in 3.1.0 and earlier.

 

Syntax

groupAddArea(group, x1, y1, x2, y2);

Parameters

ParameterTypeMandatoryDescriptionGame version
groupNumber(tick)

The ID of the group to add the objects to.

If any of the objects are already in a group, they will be moved to this group and removed from their old group.

3.1 Beta 1
x1Number(tick)The x co-ordinate of the top-left corner3.1 Beta 1
y1Number(tick)The y co-ordinate of the top-left corner3.1 Beta 1
x2Number(tick)The x co-ordinate of the bottom-right corner3.1 Beta 1
y2Number(tick)The y co-ordinate of the bottom-right corner3.1 Beta 1

Return value

ValueTypeDescriptionGame version
undefinedUndefinedThe droids, if any, were added to the group3.1 Beta 1
<error>ErrorEither the group doesn't exist, you don't own the group, or you don't own the droid.3.1 Beta 1

Notes

This function will only add droids owned by the player your script is associated with ('me') to the group. (not sure if this is still true on WZ 3.2)

There are some types of droid which will not be added:

This means that you can locate a commander or transport, and then grab all droids around it and assign them to the commander or embark them on a transport.

Example

var basePos = startPositions[playerData[me].position];
 
var baseGroup = newGroup();
 
groupAddArea(
	baseGroup,
	Math.max(basePos.x-20, 0),
	Math.max(basePos.y-20, 0),
	Math.min(basePos.x+20, mapWidth),
	math.min(basePos.y+20, mapHeight)
);
Availability

Requires:

  • Warzone 3.1 Beta 1 or above
Contents

Jump to: