# Handling

<mark style="color:red;">Handling</mark> is crucial for navigating various terrains and environments. It includes specific handling stats such as <mark style="color:red;">Sand Handling</mark>, <mark style="color:red;">Mud Handling</mark>, <mark style="color:red;">Rock Handling</mark>, <mark style="color:red;">Ice Handling</mark>, <mark style="color:red;">Wind Handling</mark>, <mark style="color:red;">Rain Handling</mark>, <mark style="color:red;">Heat Handling</mark>, <mark style="color:red;">Cold Handling</mark>, <mark style="color:red;">Tundra Handling</mark>, <mark style="color:red;">Tropical Handling</mark>, <mark style="color:red;">Desert Handling</mark>, <mark style="color:red;">Mountainside Handling</mark>, <mark style="color:red;">Turn Handling</mark>, and <mark style="color:red;">Speed Restrict Handling</mark>. <mark style="color:red;">Handling</mark> is separated for each [<mark style="color:red;">**Obstacle**</mark>](https://docs.almightyalpacas.com/readme/obstacles), [<mark style="color:green;">**Environment**</mark>](https://docs.almightyalpacas.com/readme/environment-types), [<mark style="color:red;">**Turn**</mark>](https://docs.almightyalpacas.com/readme/obstacles/turns), and [**Weather**](https://docs.almightyalpacas.com/readme/weather-types), providing variety in alpaca performance. This means that two alpacas with the same overall <mark style="color:red;">Handling</mark> stat will perform differently depending on the specific challenges they encounter.\
\
**Handling Stat Conversion**

| Stat                    | Min - 0 | Max - 100 |
| ----------------------- | ------- | --------- |
| Sand Handling           | 0       | 1         |
| Mud Handling            | 0       | 1         |
| Rock Handling           | 0       | 1         |
| Ice Handling            | 0       | 1         |
| Wind Handling           | 0       | 1         |
| Rain Handling           | 0       | 1         |
| Heat Handling           | 0       | 1         |
| Cold Handling           | 0       | 1         |
| Tundra Handling         | 0       | 1         |
| Tropical Handling       | 0       | 1         |
| Desert Handling         | 0       | 1         |
| Mountainside Handling   | 0       | 1         |
| Turn Handling           | 0       | 1         |
| Speed Restrict Handling | 0       | 1         |

$$
AnyHandling = (Handling ± 15) / 100
$$

***

### Alpaca Genes and Randomization

Each alpaca starts with five primary [Stats](https://docs.almightyalpacas.com/readme/alpaca-stats), one of which is <mark style="color:red;">Handling</mark>. <mark style="color:red;">Handling</mark> is randomized by ±15% only once in its lifetime, a characteristic known as the alpaca gene. This means that while two alpacas might have a base Handling stat of 70, their specific handling stats for different conditions (e.g., <mark style="color:red;">Rock Handling</mark>) will differ within the ±15% range, leading to varied performance on the same terrain.

***

## Handling Effect Percentage

Each alpaca has a *handlingEffect*, known as **`HANDLING_STATS_EFFECT_PERCENTAGE.`**\
Where **`HANDLING_STATS_EFFECT_PERCENTAGE=0.17`**. This percentage impacts how different handling stats are applied.

#### Applying Handling Effects

Handling effects influence the alpaca’s performance across various race conditions:

* [<mark style="color:red;">**Obstacles**</mark>](https://docs.almightyalpacas.com/readme/obstacles)**,** [**Weather**](https://docs.almightyalpacas.com/readme/weather-types)**,** [<mark style="color:red;">**Turns**</mark>](https://docs.almightyalpacas.com/readme/obstacles/turns)**, and** [<mark style="color:red;">**Speed Restrictions**</mark>](https://docs.almightyalpacas.com/readme/obstacles)**:** Each condition has specific handling requirements. The handling determines how effectively the alpaca navigates these challenges.

#### General Logic

1. **Determine Handling Effect:** Calculate the *handlingEffect* by multiplying the specific handling stat by **`HANDLING_STATS_EFFECT_PERCENTAGE`**.
2. **Adjust Performance:** Apply the *handlingEffect* to modify the alpaca's capabilities, enhancing its ability to manage obstacles, weather conditions, turns, and speed restrictions.

#### Example Calculation

For a better understanding, here’s how the *handlingEffect* modifies the alpaca's stats:

**Turn Handling Example:**

1. **Handling Effect Calculation:**

$$
handlingEffect = turnHandling \* Handling Stats Eeffect Percentage
$$

* For a Turn Handling stat of 80 (converted to 0.8):

$$
handlingEffect = 0.8 \* 0.17 = 0.136
$$

1. **Speed Adjustment During a Turn:**

$$
newTurnSpeed = startingTurnSpeed \* (1 − (turnFraction \* (1 − handlingEffect)))
$$

* For example, with a turn fraction reducing speed by 40%:

$$
newTurnSpeed = startingTurnSpeed \* (1 − (0.4 \* (1 − 0.136)))
$$

$$
newTurnSpeed=startingTurnSpeed \* 0.7456
$$

This demonstrates how *handlingEffect* and turn fractions work together to modify the alpaca's speed and performance during turns.
