Pet Training

**Pet Training** is done in-game by choosing Pet actions to perform with a "frequency slider" (*see #Pet Behavior*) and a specialized diet. A pet has to initiate an action on their own for their behavior to be adjusted.

## Pet Behavior

### Behavior loop

Pets have the following sequence of actions, where any action fulfilling a need is skipped if that need is already met :

> Sleep > Drink > Shit > Eat > EatHigh (delicacies) > Atk > Learn > Help > HelpInner > Carry > Train > Free (it's how they play).
>
>

When a sequence ends, another follows immediately. Some actions can interrupt the current sequence, most notably sect attacks. Moreover, actions can have conditions attached to them. In particular, training requires a certain amount of fun (depending on the pet's maturity) to not be skipped, and training depletes the entire fun bar of the pet.

In addition, when an action can be fulfilled in several ways the pet will choose among these depending on the behavior frequency adjustments and the conditions attached to some of those - for example the action to "Sleep in its own bed" is not considered if no bed has been built for the pet.

### Behavior frequency

Behavior frequency can be adjusted between:

> never > rarely > occasionally > sometimes > often
>
>

Some actions can't be adjusted and have a fixed chance of happening. Pets have an initial propensity to do certain actions. This matters as it affects their Bless/Curse rating until they are set by the player.

## Food Nutrition

As part of their behavior loop, pets will try to consume two types of food, regular and high quality (rare items like Earth Flux), one after the other.

### Nutrition value

Different types of Food provide different bonuses to Pets, mostly in the form of nutrition. Nutrition is a value attached to one of the pet's 5 main stats (INT, Qi, Core, Protect and Spell) and varying between -100 and 100. It drastically increases the efficiency of the related training and is consumed by that training, whereas having negative nutrition will decrease the stat instead. The nutrition value storage for a particular stat can be accessed in-game as the image shows.

It is thus very important to choose food boosting the stats one wishes to train on the pet. For easier management, boosting one stat at a time is also easier.

Food also affects the two secondary stats "Fatness" and "Strength", providing direct bonuses or maluses to those stats each time the pet is fed. If the food is common, the stats are affected by the reducing multiplier explained below in the same way Nutrition values are.

In addition, the WuDang DLC pet Miao has specific nutrition rules depending on their Bless/Curse attribute.

### Food extra effects

The Food need is filled by the consumed food nutrition value as usual. The extra Needs provided by the food, like Leisure for Amber Fruit or Water for Simple Meal are ignored.

However, the modifiers applied by the food will apply to the pet. This does not necessarily have an effect on them however, as their needs aren't affected by the same properties as non-pet NPCs. For example, the Amber Fruit's hunger immunity is applied by the property Food Consumption Bonus, but the Food need of the pet doesn't make use of it so they'll have the modifier active without it doing anything.

### High Quality food

Whenever the pet eats a High Quality food, they'll get a "Medicine Absorbing" debuff of 1200s (2 in-game days). Moreover, eating any more food of that type during the debuff won't result in any nutrition gain, and the pet behavior is adjusted not to try againbefore the cooldown expires.

In compensation, the nutrition value of the high quality food is always at full strength, and the values are sometimes higher than similar common food.

### Common food

Common food do not have a cooldown and can always be eaten. If they have no nutrition value, they always give their full nutrition strength. Otherwise, their nutrition strength is reduced by the following ratio :

m
a
x
W
a
t
e
r
N
e
e
d
−
c
u
r
r
e
n
t
W
a
t
e
r
N
e
e
d

f
o
o
d
N
u
t
r
i
t
i
o
n
V
a
l
u
e

{\displaystyle \frac{maxWaterNeed - currentWaterNeed}{foodNutritionValue}}

, with a maximum of 1 (so no bonus can be acquired that way). The maximum water need of the pet depends on its growth stage, it is 50 at the child stage and 100 otherwise.

Moreover, in the Fat and Physique case, if the bonus is strictly between -1 and 1, it will not apply, which means, as most common food only affect those factors by 1, that you'll only modify those stats when the above factor is at 1. In practice, this means that food's effect on nutrition gets progressively lower as the pet's thirstiness increases, unless the nutrition value of the food is particularly high or 0.

## Stat training

Pets will train a stat whenever their Leisure (Fun) is high enough, and as long as their stats are not already maxed. Their velleity to train depends on their maturity :

* **Child Stage :** 50 fun needed
* **Learning Stage :** 100 fun needed (yes it's counterintuitive)
* **Mature Stage :** 75 fun needed

The activity they choose to train is decided by the player's behavior choices, where non-forbidden activities will be weighted depending on the player's encouragement. Note that the stat being maxed does not prevent the pet to try to train it (they'll then cancel the activity, and do another loop before trying to train again).

The stats are gained in full at the end of a successful training session, not progressively during that session. Depending on the nutrition value for that training, the base boost is :

* Nutrition between -1 and 1 : 0.
* Nutrition < -1 :

N
u
t
r
i
t
i
o
n

100

−
0.1

{\displaystyle \frac{Nutrition}{100} - 0.1}

. As Nutrition is negative, this is a decrease in stat.
* Nutrition > 1 :

C
o
s
t

5

0.2

{\displaystyle \frac{Cost}{5} + 0.2}

 where Cost is

M
a
x
(

N
u
t
r
i
t
i
o
n

5

,
1
)

{\displaystyle Max(\frac{Nutrition}{5}, 1)}

, and the division on Nutrition is rounded up. This means a minimum base boost of 0.4.

If Nutrition is >1, the nutrition value is reduced by Cost. A multiplier is then applied to the base boost, equal to

I
n
t
e
l
l
i
g
e
n
c
e

200

{\displaystyle \frac{Intelligence}{200}}

%, for a maximum boost of 50%. The value is finally rounded down to the nearest decimal and added to the stat. Finally, the entire Leisure of the pet is depleted, no matter its starting value.

## Recommendations

* A Pet's idle behavior can be interrupted (default: ALT+S) to train them faster.
* Training Intelligence as the first stat is optimal, given it makes training other stats 50% faster
* Training one stat at a time makes food management easier

## References

1. ↑ 1.0 1.1 `Settings/LingShou/Tree/Tree2.txt [Train]`
2. ↑ 2.0 2.1 `XiaWorld.Npc.AddFoodNutir()`
3. ↑ 3.0 3.1 `XiaWorld.JobLsTrain.OnToilFinish()`
4. ↑ The game defines a particular Food Nutrition value in `Settings/LingShou/FoodNutrition/nutrition.txt` but doesn't actually make use of it when eating
5. ↑ `Settings/Modifiers/Modifier_System.xml [Modifier_Dan_ColdDown]`
6. ↑ Specifically, this isn't because they have that modifier but because they have no nutrition value, which means the check in `XiaWorld.Npc.GetNeedV()` returns false
7. ↑ `XiaWorld.LsNeedBase.MaxValue`