# Pet Experience

If you make define a pet as a [**living pet**](../../../config-templates/pet-config#living-pet-config), then it will unlock personal statistics and namely experience.

Experience is the way for pets to go from one level to the other and unlock new statistics that you can tune into your living pet config ([see the template for the implementation](../../../config-templates/pet-config#living-pet-config)).

### How can my pet get experience ?

MCPets provide **2 major ways** for your pet to gain experience.

First is using[ Pet Food](pet-food) with experience candies. Check out the [Pet Food page](pet-food) to see how to implement EXP food to boost the pet experience manually.

Second, and most general way of gaining experience, is to use a mechanic called _"PetExperience"_ listed in the [MythicMobs features](../../../mythicmobs-features#mechanics). This mechanic gives a given amount of experience to the pet, which is also tunable through[ advanced maths](https://git.mythiccraft.io/mythiccraft/MythicMobs/-/wikis/Skills/Math) thanks to MythicMobs.

Like every MythicMobs mechanic, it can be triggered through all possible [MythicMobs triggers](https://git.mythiccraft.io/mythiccraft/MythicMobs/-/wikis/Skills/Triggers), so you're free to make pets gain experience your own unique way and have a complete control on it.

Here is the format of the mechanic:

<table><thead><tr><th width="228">Usage</th><th width="210">Requirement</th><th>Example</th></tr></thead><tbody><tr><td>petExperience{exp=#}</td><td>target must be a pet</td><td>petExperience{exp=10} @self</td></tr></tbody></table>

### Examples of usage

Since you have a complete control of the experience of the pets through the dedicated mechanic, it can be quite overwhelming and hard to find the right way to do so.

Here we provide a few example situations and how we would address them from our perspective: in a way, how to make pets gain experience according to our vision (which is by no mean universal).

Note that you can find a list of classic triggers that you can use to give experience to pets on [MythicMobs wiki: Triggers section](https://git.mythiccraft.io/mythiccraft/MythicMobs/-/wikis/Skills/Triggers).

#### 1. Time experience

While the pet is being summoned, we can imagine that it would be nice if it was learning a little of experience every minutes for instance, just for being around and summoned.

This would be implemented in the following way:

* Go into your MythicMob pet's file ("_./plugins/MythicMobs/Mobs_")
* Add the following line in the `Skills` section :\
  `- petExperience{exp=5} @self ~onTimer:200`

This specific script will give 5xp every 10s (200 ticks) to the pet.

You could make this script much more advanced using a skill with conditions, because maybe you would like the pet to gain experience only if it's incombat, then you would using the [incombat{} condition](https://git.mythiccraft.io/mythiccraft/MythicMobs/-/wikis/Skills/conditions) of MythicMobs into a skill to achieve that.

#### 2. Participation to combat experience

Maybe you want to reward the pet for participating to a combat with the player. Therefore we could think of giving experience to the pet when a mobs dies around.

This would be implemented in the following way:

* Select a monster that would deliver experience when dying
* Go into the MythicMob monster's file ("_./plugins/MythicMobs/Mobs_")
* Add the following line in the `Skills` section:\
  `- petExperience{exp=30} @ENO{r=40} ~onDeath`

This would give 30xp to every pet in a range of 40 blocks around.

However, you could also want that the experience the pet gains is not dependent of the mob it kills, but more of various formulas you want to implement yourself.

This could be done in the following way:

* Open a Skill file or create one into "_./plugins/MythicMobs/Skills_"
* Add the following skill:

<pre class="language-yaml"><code class="lang-yaml"><strong>Pet_Experience_Custom:
</strong>  Skills:
  - petExperience{xp=100*(1+exp(-&#x3C;pet.experience>))} @self
</code></pre>

* Go into your MythicMob pet's file ("_./plugins/MythicMobs/Mobs_")
* Add the following line in the `Skills` section :\
  `- skill{s=Pet_Experience_Custom} ~onSignal:EXP_CUSTOM`

This specific script will give up to 200xp to the pet when the signal `EXP_CUSTOM` is triggered (for instance, when a pet dies), with an exponential decrease to 100xp depending of the pet's current experience.. every 5s (200 ticks) to the pet.

Of course, you can make this even more advanced thanks to the [Math module of MythicMobs](https://git.mythiccraft.io/mythiccraft/MythicMobs/-/wikis/Skills/Math) and the[ placeholders](../../../mythicmobs-features#placeholders) that are provided, as well as the [conditions](../../../mythicmobs-features#conditions) of MCPets.

