Data/Turrets

## Turrets

A **Turret** is a data object that tells the engine how it should make certain units behave in terms of how they aim their model in respect to any projectiles it may fire. Alternatively, they are sometimes used to constantly rotate a unit, much like a **Site Operation** would. An example of the former would be the **Photon Cannon** Protoss Structure: A turret controls the movement of the floating beach ball. A Terran **Auto-Turret** can only turn 180 Degrees while a **Photon Cannon** can turn a full 360 degrees. This does not mean that EVERY unit in the game needs a turret. It's just an easy way to control aiming properties for a unit.
You can choose what turret a unit should have by going to the **Unit Tab** and picking your unit, then choosing **Combat - Weapons**. Models used by the unit require a **TurretZ** attachment point for this to work.

* What happens when you set a turret on a unit, without a turret actor attached with it? The unit's model part that should turn (based on Turret Z) will remain still, but the weapon will fire as if an invisible turret, with the yaw rate of it, would turn. This is why Turret actor need an actor on creation. In other words, the turret data is this invisible rotative weapon angle (or a rotation point, such as pylons use for animating their rotating crystal), and the actor is the link that connects this turret to the unit's model, rotating it. Unfortunatly, as the editor is limited, only "Turret Enable" events will successfully create and attach the actor to the turret, relative to the unit. Other events creating it wouldn't be able to have it stick to the \_Unit, causing some issues.
* A unit using having different turrets on it causes some issues. If the modder wishes to have the turret swap to another, he should read the part about Swapping turret in the Buff Behavior early section.
* Take note that in the default multi dependencies, Photon Cannon uses a bugged turret. This is caused by its unit model "PhotonCannonEx2.m3" which seems to have a broken/misfit part in its file, causing hard coded errors. To fix this, Blizzard dissociated the Photon Cannon **Turret** from any Turret Actor and it seems to work on its own for some reasons. Associating any turret actor (creating the actor from "TurretEnable" msg) does a weird interaction, causing the turret to aim away when attempting to turn to target. If this is problematic in a way that you would want to use the Photon Cannon turret for other purposes, here is how to fix it:
	1. Swap the model on the default Photon Cannon to "PhotonCannon" (it already exist and it is unused; It is unknown why they kept the bugged one by default).
	2. Associate any turret actor to the Photon Cannon turret.

Be advised that using any other turret (linked with actor) for the photon cannon while keeping the bugged m3 file will still result into a bugged turret, for as long as the Photon Cannon (or any other unit for that matter) uses"PhotonCannonEx2.m3".

## Idle

What the turret does when it does not have a target.

### Reset If Moving

Resets to default position if the unit is moving.

### Follow Movement Reverse

Follows the opposite of the movement of the unit.

## Yaw Arc

Total Angle of movement for the Turret (0 to 360 Degrees).

## Yaw Idle Rate

Speed of the turret's movements when it does not have a target.

## Yaw Rate

Speed of the turret's movements when it has a target.

## Fidget

While Idle, the units has a chance to do certain actions.

### Chance Array: Animation

If the unit has an **Idle** animation, this plays it. You can set a chance that it'll happen.

### Chance Array: Idle

The unit performs the **Idle** command under **Unit - Idle Command**. You can set a chance that it'll happen.

### Chance Array: Move

Move makes the unit twitch a small amount. You can set a chance that it'll happen.

### Chance Array: Turn

Turn makes the unit change direction. You can set a chance that it'll happen.

### Delay Max

The maximum amount of time that can pass before the fidget will occur.

### Delay Min

The amount of time that is required to pass before the fidget will occur.

### Distance Maximum

How far the turret can twitch for the **Move** animation.

### Distance Minimum

How far the unit must twitch for the **Move** animation.

### Turn Angle

How far the turret can turn for the **Turn** animation.

### Turning Rate

How fast the turret turns during the **Turn** animation.