Elin:Code Analysis/Hearthstone growth: Difference between revisions
(Page Creation, Code Analysis/Hearthstone growth) |
m (change display title) |
||
| Line 1: | Line 1: | ||
{{DISPLAYTITLE:Code Analysis/Hearthstone growth}} | |||
{{Spoiler}} | {{Spoiler}} | ||
| Line 284: | Line 285: | ||
|194 | |194 | ||
|}<!-- Someone please peer-review this. Math is my worst subject --> | |}<!-- Someone please peer-review this. Math is my worst subject --> | ||
{{DEFAULTSORT:Code_Analysis/Hearthstone_growth}} | |||
Revision as of 08:13, 23 June 2025
| 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.
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 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. So for an item with 0 selling price, it can now yield anywhere between 0.575 and 1.15 xp.
num2 = num2 / 2 + 1;
Now dividing the value by 2 and plus 1 to it. The 0 sell value item xp is now between 1.2875 - 1.575
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.
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 |
Medium Rng
Max Sell value item |
Best Rng
Max Sell value item | |||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Growth boost | ✔ | ❌ | ✔ | ❌ | ✔ | ❌ | ✔ | ❌ | ✔ | ❌ | ✔ | ❌ | |
| LV | 1 > 2 | 3,523 | 5,300 | 2,340 | 3,532 | 1,759 | 2,647 | 6 | 8 | 4 | 6 | 3 | 4 |
| 2 > 3 | 8,856 | 13,300 | 5,896 | 8,865 | 4,416 | 6,647 | 14 | 18 | 9 | 14 | 7 | 10 | |
| 3 > 4 | 17,745 | 26,634 | 11,822 | 17,754 | 8,860 | 13,314 | 27 | 40 | 18 | 27 | 14 | 20 | |
| 4 > 5 | 30,189 | 45,300 | 20,117 | 30,198 | 15,083 | 22,647 | 46 | 68 | 31 | 46 | 23 | 34 | |
| 5 > 6 | 46,189 | 69,300 | 30,785 | 46,198 | 23,083 | 34,647 | 70 | 104 | 47 | 70 | 34 | 52 | |
| 6 > 7 | 65,745 | 98,634 | 43,822 | 65,754 | 32,860 | 49,314 | 99 | 148 | 66 | 99 | 50 | 74 | |
| Total | 172,246 | 258,468 | 114,781 | 172,301 | 86,061 | 129,216 | 262 | 386 | 175 | 262 | 131 | 194 | |