Grenade

Grenades can effectively clear a large group of enemies quickly or provide additional utility. You can only purchase them through Apartment shop. Grenades are randomized, having always random name, stat, shape and color - the color can be changed in Wardrobe.

## Stats

Grenades have several stats, as other things in DDS, these are as follow:

* **Level** - Ranges from 1 to 9 and determines the ceiling values for other stats.

* **Damage (DMG)** - The amount of damage the grenade deals in it's explosion radius, duh.

* **Duration (DUR)** - Replaces **DMG** if the grenade is an utility type and determines how long it's effect will last for.

* **Speed (SPD)** - How quickly the grenade will reach it's destination once thrown.

* **Radius (RAD)** - Determines how big the explosion is.

* **Cooking Time (COOK)** - The countdown to the explosion after activation.

* **Noise (NOI)** - How far the explosion is "heard", this stat is measured in line-of-sight distance, 1 line-of-sight distance is equal to the size of the vision circle around your agent.

* **Spare (SPR)** - The maximum amount of grenades you can have.

* **Type** - Determines the behavior of a grenade.

## Grenade types

Grenade types affects the type of explosion a grenade has.

* **Blast** - Default grenade type. It does the deadly boom.

* **Sight** - Reveals an area equal to **RAD** in size for the **DUR** on the point of explosion that slowly shrinks. This type's **NOI** value is always **0**.

* **Smoke** - Creates a rhombus shaped smoke **RAD** in size for the **DUR** on the point of explosion that slowly shrinks. Smoke is treated as a separate room, meaning you can't see inside from outside and vice versa. This type's **NOI** value is always **0**.

* **Sleep** - Puts an enemy to sleep for the **DUR**.

## Stats generation

Whenever a grenade is created the game runs the following algorithm:

1. Generate **5** numbers (n1, n2, n3...), each ranging from **0.001** to **10.0**.
2. **Each** number is then **divided** by the **sum** of all numbers, **multiplied** by **0.5** and then **multiplied** by **5**. Therefore the lowest possible number it can generate is **0.00006249843** while the highest is **2.49900039984**.
3. Those numbers are then used to generate each stat using linear Interpolation (**a** + (**b** — **a**) \* **t**) . The formulas are as follows:
	1. **SPR** = (**1** + ((**level** + **1**) - **1**) \* **n1**);
	2. **RAD** = (**4** + (**(level + 8)** - **4**) \* **n2**);
	3. **DMG** =
		* **Sleep** type: (**1** + ((**level + 3)** - **1**) \* **n3**);
		* **Other** types: (**3** + ((**level \* 8)** - **3**) \* **n3**), if it's **Sight** type grenade, the **DMG** is then multiplied by **2**;
	4. **SPD** = (**0.4**+ (**1.25** - **0.4**) \* **n4**);
	5. **NOI** = (**4** + (**1.5** - **4**) \* **n5**);
	6. **DUR** = **DMG**.
	7. **COOK**:
		1. **N** = Random number ranging from **1.0** to **3.0**;
		2. ***p*** = **1** + (**1.5** - **1**) \* **N / 3.0**;
		3. **N** is divided by 2 with a **50%** chance;
		4. **N** is raised to the power of ***p**;*
		5. If **N** is less than **1**, then **N = 1**;
	8. Some adjustments are made based on grenade type:
		1. **Sight**: **NOI** = **0**, **SPR** = **SPR** + **SPR** / **2**, **RAD = RAD** \* **2**, **COOK =** Random number ranging from 1.0 to 2.0;
		2. **Sleep**: **NOI** = **NOI** / **3**;
		3. **Smoke**: **NOI = 0**, **SPR** = **SPR +** (**SPR** + **1)** / **2**, **COOK =** Random number ranging from 1.0 to 2.0, **DMG** = **DMG \* 2**;