# Create Sensations

There are multiple ways of creating [sensations](https://owo-game.gitbook.io/owo-api/welcome/what-is-a-sensation):

**Microsensation**

These are the smallest units that can be felt. A sensation is composed of one or more of them.

{% tabs %}
{% tab title="C#" %}

```csharp
var daggerEntry = SensationsFactory.Create(60, 0.1f, 90, 0, 0, 0);
var bleeding = SensationsFactory.Create(50, 0.5f, 50, 0, 0.4f, 0);
```

{% endtab %}

{% tab title="C++" %}

```cpp
auto daggerEntry = SensationsFactory::Create(60, 0.1f, 90, 0, 0, 0);
auto bleeding = SensationsFactory::Create(50, 0.5f, 50, 0, 0.4f, 0);
```

{% endtab %}
{% endtabs %}

{% hint style="info" %}
The parameters correspond with the following microsensation attributes:

1. Frequency
2. Duration (seconds)
3. Intensity (%)
4. Ramp up (seconds)
5. Ramp down (seconds)
6. Exit delay (seconds)
   {% endhint %}

**Sensations Sequence**

{% tabs %}
{% tab title="C#" %}

```csharp
var stab = daggerEntry.Append(bleeding);
```

{% endtab %}

{% tab title="C++" %}

```cpp
auto stab = SensationsFactory::CreateSequence({ daggerEntry, bleeding });
```

{% endtab %}
{% endtabs %}

{% hint style="info" %}
All subtypes of `Sensation` can be chained together, so it would also be possible to chain Sensation sequences.
{% endhint %}

**Import a sensation**

Sensations are exported in its own format from the [Sensations Creator](https://owo-game.gitbook.io/owo-api/tools/sensations-creator), you can import them using the `Parse` function.

{% hint style="info" %}
You can find the sensations code by opening the files (.owo) exported by the sensations creator. Otherwise you could load the file through code.&#x20;
{% endhint %}

{% tabs %}
{% tab title="C#" %}

```csharp
var ball = Sensation.Parse("100,1,100,0,0,0,Impact");
```

{% endtab %}

{% tab title="C++" %}

```cpp
auto ball = SensationsParser::Parse("100,1,100,0,0,0,Impact");
```

{% endtab %}
{% endtabs %}

A baked sensation can be imported using the same function.

{% tabs %}
{% tab title="C#" %}

```csharp
var bakedBall = Sensation.Parse("0~Ball~100,1,100,0,0,0,Impact~impact-0~");
```

{% endtab %}

{% tab title="C++" %}

```cpp
auto bakedBall = SensationsParser::Parse("0~Ball~100,1,100,0,0,0,Impact~impact-0~");
```

{% endtab %}
{% endtabs %}

### Muscles

#### Declaration

You can assign a muscle or group of muscles to any sensation. Muscles are defined like this:

{% tabs %}
{% tab title="C#" %}

```csharp
var rightPectoral = Muscle.Pectoral_R;
var bothPectorals = new Muscle[] { Muscle.Pectoral_R, Muscle.Pectoral_L };
var all = Muscle.All;
```

{% endtab %}

{% tab title="C++" %}

```cpp
auto rightPectoral = Muscle::Pectoral_R();
auto bothPectorals = MusclesGroup({ Muscle::Pectoral_R(), Muscle::Pectoral_L() });
auto all = MusclesGroup::All();
```

{% endtab %}
{% endtabs %}

The intensity percentage can be changed per muscle:

{% tabs %}
{% tab title="C#" %}

```csharp
var atMinIntensity = rightPectoral.WithIntensity(1);
var eachWithItsOwnIntensity = new Muscle[] { Muscle.Pectoral_R.WithIntensity(25), 
                                             Muscle.Pectoral_L.WithIntensity(50) };
var atHighIntensity = Muscle.All.WithIntensity(80);
```

{% endtab %}

{% tab title="C++" %}

```cpp
auto atMinIntensity = Muscle::Pectoral_R().WithIntensity(1);
auto eachWithItsOwnIntensity = MusclesGroup({ Muscle::Pectoral_R().WithIntensity(25), 
                                              Muscle::Pectoral_L().WithIntensity(25) });
auto atHighIntensity = MusclesGroup::All().WithIntensity(80);
```

{% endtab %}
{% endtabs %}

You can obtain the opposite muscles of a muscles group (or single) by calling the mirror method:

{% tabs %}
{% tab title="C#" %}

```csharp
var leftPectoral = Muscle.Pectoral_R.Mirror();
var rightSide = new[] { Muscle.Abdominal_L, Muscle.Pectoral_L, }.Mirror();
```

{% endtab %}

{% tab title="C++" %}

```cpp
auto leftPectoral =  Muscle::Pectoral_R().Mirror();
auto rightSide = MusclesGroup({ Muscle::Abdominal_L(), Muscle::Lumbar_L(), Muscle::Pectoral_L() }).Mirror();
```

{% endtab %}
{% endtabs %}

#### Assignation

You can assign muscles to any subtype of `Sensation`.

{% tabs %}
{% tab title="C#" %}

```csharp
var ballWithMuscles = ball.WithMuscles(Muscle.Pectoral_R);
```

{% endtab %}

{% tab title="C++" %}

```cpp
auto ballWithMuscles = ball->WithMuscles({ Muscle::Pectoral_R() });
```

{% endtab %}
{% endtabs %}

So it would be also possible to assign muscles to a sensations sequence, or to a baked sensation.

{% tabs %}
{% tab title="C#" %}

```csharp
var frontStab = stab.WithMuscles(Muscle.Abdominal_R);
var crossStab = daggerEntry.WithMuscles(Muscle.Abdominal_R)
                           .Append(bleeding.WithMuscles(Muscle.Dorsal_R));
```

{% endtab %}

{% tab title="C++" %}

```cpp
auto frontStab = stab->WithMuscles({ Muscle::Abdominal_R() });
auto crossStab = SensationsFactory::CreateSequence({ daggerEntry->WithMuscles({Muscle::Abdominal_R()}), 
                                          bleeding->WithMuscles({Muscle::Dorsal_R()}) });
```

{% endtab %}
{% endtabs %}

After assigning muscles to a sensation, it becomes a `SensationWithMuscles`, and it will not be possible to override the muscles that were assigned to it initially.

{% tabs %}
{% tab title="C#" %}

```csharp
var ballWithMuscles = ball.WithMuscles(Muscle.Pectoral_R);
var keepingSameMuscles = ballWithMuscles.WithMuscles(Muscle.Lumbar_L); //Keeps only the right pectoral
```

{% endtab %}

{% tab title="C++" %}

```cpp
auto ballWithMuscles = ball->WithMuscles({ Muscle::Pectoral_R() });
auto keepingSameMuscles = ballWithMuscles->WithMuscles({ Muscle::Lumbar_L() }); //Keeps only the right pectoral
```

{% endtab %}
{% endtabs %}

You can use this as an advantage to define sensation sequences that have sensation with fixed muscles but others with dynamic muscles:

{% tabs %}
{% tab title="C#" %}

<pre class="language-csharp"><code class="lang-csharp"><strong>var incompleteStab = daggerEntry.WithMuscles(Muscle.Abdominal_R).Append(bleeding);
</strong><strong>var stabWithBackExit = crossStab.WithMuscles(Muscle.Dorsal_R); //The right dorsal will only be assigned to the bleeding
</strong></code></pre>

{% endtab %}

{% tab title="C++" %}

```cpp
auto incompleteStab = new SensationsSequence({ daggerEntry->WithMuscles({Muscle::Abdominal_R()}), bleeding});
auto stabWithBackExit = incompleteStab->WithMuscles({Muscle::Dorsal_R()}); //The right dorsal will only be assigned to the bleeding
```

{% endtab %}
{% endtabs %}

**Multiply intensity**

{% hint style="info" %}
This feature is only available in the .Net version of the API, it allows you to multiply the existing sensation of a muscle or sensation by a percentage.
{% endhint %}

Muscles

{% tabs %}
{% tab title="C#" %}

```csharp
// NOTE: The intensity of the muscle would be multiplied by 0.2f
var softer = Muscle.Abdominal_R.MultiplyIntensityBy(20);
```

{% endtab %}
{% endtabs %}

Sensations

{% tabs %}
{% tab title="C#" %}

<pre class="language-csharp"><code class="lang-csharp">// Microsensation with a intensity of 100
var higher = SensationFactory.Create(intensityPercentage: 25).MultiplyIntensityBy(400);
// Sensation with muscles with a intensity of 50
var half = SensationFactory.Create().WithMuscles(Arm_L).MultiplyIntensityBy(50);
// Sensation sequence with a intensity of 30
<strong>var softer = Sensation.Ball.WithMuscles(Abdominal_R).Append(Dart).MultiplyIntensityBy(30);
</strong></code></pre>

{% endtab %}
{% endtabs %}
