Code Analysis/Hearthstone growth
| This page does not contain information obtained through legitimate play, but rather through Elin's data analysis, debug mode, and internal file viewing. It may contain serious spoilers or information that may detract from the enjoyment of playing the game. please summarize the content in a way that is easy to understand for people who cannot read the code, rather than posting the code as it is. |
Residents EXP
From FactionBranch.cs
public void OnAdvanceDay()
{
int num = 0;
foreach (Chara member in members)
{
if (member.IsPC || member.isDead)
{
continue;
}
...
if (member.memberType == FactionMemberType.Default)
{
if (EClass.rnd(3) == 0)
{
num++;
}
if (member.GetWork("Pioneer") != null)
{
num += 3;
}
}
}
ModExp(num);
}
Analysis:
Every alive resident that is not livestock has 1 in 3 chance of giving out 1 xp of hearthstone level every day.
If they have a Pioneer job, they are guaranteed to provide 3 additional points of xp everyday on top of the normal random chance one.
Shipping EXP
From GameDate.cs
public void ShipGoods()
{
...
int num2 = 0;
...
foreach (Thing thing3 in container_shipping.things)
{
if (thing3.trait.CanBeShipped)
{
int price = thing3.GetPrice(CurrencyType.Money, sell: true, PriceType.Shipping);
...
num2 += EClass.rndHalf(thing3.Num * Mathf.Min(15 + price, 10000) / 100 + 1);
...
}
}
...
num2 = num2 / 2 + 1;
if (zone.branch.policies.IsActive(2515))
{
num2 = 0;
}
...
zone.branch.ModExp(num2);
...
}
Analysis:
int price = thing3.GetPrice(CurrencyType.Money, sell: true, PriceType.Shipping);
…
num += thing3.Num;
num2 += EClass.rndHalf(thing3.Num * Mathf.Min(15 + price, 10000) / 100 + 1);
The bases of shipping xp is the price of item sold by shipping.
There's a maximum price of an item when used to determine the exp gain due to Mathf.Min() functions.
That is to say, for the purpose of Hearthstone growth, any item with a shipping price more than 9985 is considered the same.
At the same time, every item, even if it is sold for nothing, will also have the minimum exp of 1.15 (Which will be rounded down to 1 due to being int value) thanks to the +15 of the price in the formula and +1 at the end of it.
But keep in mind, due to the order of operation, the +1 at the end is only applied once per type of item.
So it incentivizes shipping many kinds of items to reap more hearthstone exp.
Now, we must look at what EClass.rndHalf() do.
public static int rndHalf(int a)
{
return a / 2 + Rand.rnd(a / 2);
}
In essence, it returns the value at 50-100% of the input rounding down again.
num2 = num2 / 2 + 1;
Now dividing the value by 2 and plus 1 to it, rounding down for the third time.
This time, the plus one is only applied once per shipment of item.
Which means that technically speaking, you’ll get more hearthstone exp from the same number of items by shipping items every day
rather than shipping in a big batch at once from time to time.
if (zone.branch.policies.IsActive(2515))
{
num2 = 0;
}
Growth Suppression policy effect will set the xp to 0 if it is turned on.
Growth Boost Policy
When the Hearthstone gains EXP from the above pathways, the EXP number will further increase by the Growth Boost policy if you have it enabled.
From FactionBranch.cs
public void ModExp(int a)
{
...
if (policies.IsActive(2516))
{
a = a * 150 / 100 + EClass.rnd(2);
}
exp += a;
...
}
It essentially multiplies the EXP by 1.5 and randomly add 0-1 to it. Rounding down again down to being an int.
EXP require for each level
Dictated by the following formula in FactionBranch.cs:
public int GetNextExp(int _lv = -1)
{
if (_lv == -1)
{
_lv = lv;
}
return _lv * _lv * 100 + 100;
}
Which mean the require exp for each of hearthstone are:
| Level | EXP require |
|---|---|
| 1 > 2 | 200 |
| 2 > 3 | 500 |
| 3 > 4 | 1000 |
| 4 > 5 | 1700 |
| 5 > 6 | 2600 |
| 6 > 7 | 3700 |
Amount of items require to level up
With all the aforementioned code analyzed, we can calculate the theoretical ceiling and floor of the amount of item required to be shipped to level up each hearthstone level in one go, using a singular type of item. The result is the following table.
As a reminder, Max sell value is something that can be sold for 9985 oren or more.
| Scenario | Worst Rng
0 sell value item |
Average Rng
0 Sell value item |
Best Rng
0 Sell value item |
Worst Rng
Max Sell value item |
Average Rng
Max Sell value item |
Best Rng
Max Sell value item | |||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Growth boost | ✔ | ❌ | ✔ | ❌ | ✔ | ❌ | ✔ | ❌ | ✔ | ❌ | ✔ | ❌ | |
| LV | 1 > 2 | 3,540 | 5,300 | 2,634 | 3,974 | 1,754 | 2,647 | 6 | 8 | 4 | 6 | 3 | 4 |
| 2 > 3 | 8,874 | 13,300 | 6,634 | 9,974 | 4,420 | 6,647 | 14 | 20 | 10 | 15 | 7 | 10 | |
| 3 > 4 | 17,754 | 26,634 | 13,314 | 19,974 | 8,860 | 13,314 | 27 | 40 | 20 | 30 | 14 | 20 | |
| 4 > 5 | 30,207 | 45,300 | 22,634 | 33,974 | 15,087 | 22,647 | 46 | 68 | 31 | 51 | 23 | 34 | |
| 5 > 6 | 51,540 | 77,300 | 38,634 | 57,974 | 25,754 | 38,647 | 78 | 116 | 58 | 87 | 39 | 58 | |
| 6 > 7 | 65,754 | 98,647 | 49,314 | 73,974 | 32,860 | 49,314 | 99 | 148 | 74 | 111 | 50 | 74 | |
| Total | 177,669 | 266,481 | 133,164 | 199,844 | 88,735 | 133,216 | 270 | 400 | 197 | 300 | 136 | 200 | |