Jump to content

Elin:Code Analysis/Unclassified: Difference between revisions

m
Move the beekeeping code from the Bee hive page.
m (Move the beekeeping code from the Bee hive page.)
 
Line 156: Line 156:
* The minimum orens you can win is half of the maximum.
* The minimum orens you can win is half of the maximum.
* The winning chance is based on the total number of gamble chests opened, allowing players to exploit it through save scumming. For example, if you save your progress, open chests, and win on the 9th one, reloading will always result in a win on the 9th chest.
* The winning chance is based on the total number of gamble chests opened, allowing players to exploit it through save scumming. For example, if you save your progress, open chests, and win on the 9th one, reloading will always result in a win on the 9th chest.
== Honeycomb production <ref>The code was obtained from [https://www.reddit.com/r/ElinsInn/comments/1k10qxh/question_about_beehives/ u/grenadier42's decompilation of the Nightly code as of 18 Apr 2025.]</ref> ==
<syntaxhighlight lang="c#" line="1">
int soilCost = EClass._zone.GetSoilCost();
CS$<>8__locals1.flower = 5;
int num = Mathf.Min(100, 70 + (this.MaxSoil - soilCost));
int num2 = 0;
foreach (Thing thing3 in EClass._map.things)
{
    if (thing3.IsInstalled && thing3.trait is TraitBeekeep && !thing3.things.IsFull(0))
    {
        CS$<>8__locals1.flower -= 3 + EClass.rnd(5 + num2 * 4);
        num2++;
        if (CS$<>8__locals1.flower < 0)
        {
            break;
        }
        if (EClass.rnd(100) <= num)
        {
            Thing thing4 = ThingGen.Create("honey", -1, -1);
            thing4.SetEncLv(CS$<>8__locals1.lv / 10);
            thing4.elements.SetBase(2, EClass.curve(CS$<>8__locals1.lv, 50, 10, 80), 0);
            thing3.AddThing(thing4, true, -1, -1);
        }
    }
}
</syntaxhighlight>
Every day a base is updated, the above code runs, which causes each beehive to process whether a honeycomb is produced or not depending on the number of flowers remaining on the map.
To be eligible to run the code, the beehive must be installed on the map (rather than in a container or dropped on the floor) and it must have free slots in its inventory, otherwise it will be treated as if it does not exist.
As a tent is not a 'base', beehives do not work within tents.
The base 'flower power' of each map is 5, to which the sum total of the Flower, Blue Flower, Yellow Flower, White Flower and Cotton plants on the map is added; i.e. three eligible flowers results in a 'flower power' of 8.
Each successive hive deducts 3 + random (0 to 5 + 4(n-1)) 'flower power' to produce one honeycomb - so the first takes 3 to 8 'flower power', the second takes 3 to 12 'flower power', and so on and so forth.
Finally, eligible hives have a probability ([Available Fertility] + 70%) of creating honeycombs; hives on maps with 30 Fertility will have a 100% chance of producing honeycombs if enough 'flower power' is available, while maps with -70 Fertility have a close to 0% chance (the random number generated has to be exactly zero to produce a honeycomb). Because growing flowers takes Fertility in itself, adding flowers increases the maximum number of beehives that can potentially produce honeycombs at the same time it also reduces the probability each beehive actually produces any honeycombs. As the required 'flower power' increases with the number of hives on a map in a geometric manner but the fertility effect is linear, honeycomb production tends to be flower-limited at smaller numbers and Fertility-limited at large numbers.
When honeycombs are produced, their quality is dependent on the quality of the best eligible flower on the map; a single +70 flower in a field of +0 flowers will still result in all hives producing stacks of +7 honeycombs.
Flowers can still contribute to honeycomb production even if defertilized (e.g. to survive winter without the usage of sun lamps).
Bee hives spawn neutral bees around them. Killing the bees has no effect on hives or honeycomb production, and there does not need to be a valid path from the beehive to the flowers for honeycombs to be produced.
See the table below for a summary of the number of flowers each hive requires as per the above formula.
Remember to deduct the base 'flower power' of 5 from these numbers; for instance, 25 flowers has a non-zero chance of producing honeycombs from the 10th beehive.
[[File:Beehive.jpg|alt=Table of hive number vs flower count|Number of flowers needed for each hive]]


[[Category:EN]]
[[Category:EN]]
[[Category:Elin Spoiler]]
[[Category:Elin Spoiler]]
<references />