Inverted Locations

A unit is registered as inside a location if any part of the unit is right of the location's left border, left of the right border, below the top border and above the bottom border. Under normal circumstances, of course, this creates a rectangular area that units can enter.

## What it is and how it works

Inverted locations are locations that have any borders that have been flipped (you can do this in SCMDraft by manually setting the location parameters in the location's properties window)¹. The same principle given before applies in this situation- if the left and right borders are inverted (the right border is left of the left border) a unit still needs to be right of the location's left border and left of the right border- in other words, the unit's 'area' must be outside both the left and the right borders and within the top and bottom. For a location with both the top and bottom and left and right borders inverted a unit must be outside all four sides of the rectangle to be 'inside' it.

A simple way of saying it, is that with a regular location, a piece of the unit merely needs to be inside the location. With an inverted location, the entire location needs to be inside the unit.

The advantage of using inverted locations is that they can be used to detect if a unit is in an exact position (if fitted to that specific unit) and thus can be deployed for near instant unit movement detection. They can also be centered on units near the edges of the map without being pushed off the edges. Other uses include varying degrees of unit movement.

A "newb-friendly" three step guide for creating inverted locations:

1. Create a location in your map editor (SCMDraft 2)
2. Go to its properties (double click or select and press 'Enter')
3. Swap the values of right and left borders and swap the top and bottom border values. (It should no longer be selectable in the map window- you must find it in the Location listing at the left and press enter to edit it now).

## Graphic depiction

In this normal (not inverted) location, the Goliath is inside the location

In this horizontally inverted location (left and right borders are flipped) the red Ultralisk is 'inside'
the location because it is outside both the left and right borders. The blue Ultralisk is not inside.

In this inverted location (all borders are flipped) the Ultralisk is inside the location because it is outside
all four borders (above the bottom border, left of the right, right of the left, and below the top border)

## Specific application triggers

### Detecting unit movement

One of the reasons why inverted locations are used is because they can detect if a unit has moved much faster than with a 1x1 pixel location. To do so, you must make it so the inverted locations' edges is exactly (or a bit smaller) the same size as the unit's one (which is represented by the green rectangular surrounding the unit when you're placing it).

Then, with this, you must use two little triggers:

*StarCraft* Trigger [template]
Description
Trigger 1: Center the location over the unit ONCE
Players

* Player 1

Conditions

* Always.

Actions

* Center location labelled 'inverted location' on 'custom unit' owned by 'Player x' at 'Anywhere'

*StarCraft* Trigger [template]
Description
Trigger 2: Detect when the unit leaves the location
Players

* Player 1

Conditions

* 'Player x' bring 'at most' '0' 'custom unit' to 'inverted location'

Actions

* Move '1' 'custom unit' at 'Anywhere' to 'inverted location'
* Set' 'custom unit has moved'
* Preserve trigger.

You may now use the 'custom unit has moved' switch as 'Set' like if it was the same thing as if the unit has moved.

### Detecting unit stopping

The second most common use for inverted location is to make life easier when you want to detect when a unit has stopped moving. To do so, you must have these triggers (in this order):

*StarCraft* Trigger [template]
Description
Trigger 1: Detect if the unit is STILL in the location
Players

* Player 1

Conditions

* 'Player x' bring 'at least' '1' 'custom unit' at 'inverted location'

Actions

* 'Set' switch 'unit has stopped'
* Preserve trigger.

*StarCraft* Trigger [template]
Description
Trigger 2: Center the location
Players

* Player 1

Conditions

* Always.

Actions

* Center location labelled 'inverted location' on 'custom unit' owned by 'Player x' at 'Anywhere'
* Preserve trigger.

You may now use the 'unit has stopped' switch as 'Set' like if it was the same as if the unit has stopped.