Elin:Code Analysis/Unclassified: Difference between revisions

From Ylvapedia
Jump to navigation Jump to search
No edit summary
Line 98: Line 98:


=== How much does this food give you? ===
=== How much does this food give you? ===
'''WARNING''': This section is not based on empirical analysis.
Please beware the editor's understanding of this part of the code is rudimentary only.
* There are a few main contributing factor of a dish.
* There are a few main contributing factor of a dish.
** One of them is a overall modifier, in code this is depicted as '''num2'''
** One of them is a overall modifier, in code this is depicted as '''num2'''
Line 148: Line 152:


* With the previous value, if the food is blessed, increase 50%, if the food is cursed, cut by 50%.
* With the previous value, if the food is blessed, increase 50%, if the food is cursed, cut by 50%.
* If the consumer have canniblism and the dish is human, increase 50%, if dish is not human, cut by 50%.
* If the consumer have canniblism and the dish is human, increase 50%, if dish is not human, cut by 50%, while the nutrition of the dish is also cut by 50%.
* If the consumer doesn't have cannibilism and the dish is human, cut by 50%.
* If the consumer doesn't have cannibilism and the dish is human, cut by 50%.


Line 200: Line 204:
* If the food is not rotten:
* If the food is not rotten:
** If the food is raw, depend on the category, its value is further decreased: meat -30%, fish -10%, dough -10%.
** If the food is raw, depend on the category, its value is further decreased: meat -30%, fish -10%, dough -10%.
<syntaxhighlight lang="c#" line="1">
    int num3 = food.Evalue(10);
    float num6 = Mathf.Min(c.hunger.value, num3);
    if (c.hunger.GetPhase() >= 3)
{
num6 *= 1.1f;
}
if (flag5 && !c.HasElement(480))
{
c.ModExp(70, -300);
c.ModExp(71, -300);
c.ModExp(72, -200);
c.ModExp(73, -200);
c.ModExp(74, -200);
c.ModExp(75, 500);
c.ModExp(76, -200);
c.ModExp(77, -300);
}
</syntaxhighlight>
* The nutrition value (num3) of food is loaded, and the actual nutrition can be absorbed by a character cannot exceed its current hunger value.
* If the character is hungry, then the actual nutrition is increased by 10%.
** A reminder, what is increased is not efficiency, but nutrition amount. I.e. the food becomes more filling.
* If the food is rot and the character cannot take rotten food, each of the characters main attribute will be heavily penalized, except Will, which will have a heavy increase.
** Guess eating rotten food train your will.
<syntaxhighlight lang="c#" line="1">
    else
{
num2 = num2 * num6 / 10f;
if (c.HasCondition<ConAnorexia>())
{
num2 = 0.01f;
}
List<Element> list = food.ListValidTraits(isCraft: true, limit: false);
foreach (Element value in food.elements.dict.Values)
{
if (value.source.foodEffect.IsEmpty() || !list.Contains(value))
{
continue;
}
string[] foodEffect = value.source.foodEffect;
int id = value.id;
float num7 = num2 * (float)value.Value;
if (value.source.category == "food" && c.IsPC)
{
bool flag6 = num7 >= 0f;
string text = value.source.GetText(flag6 ? "textInc" : "textDec", returnNull: true);
if (text != null)
{
Msg.SetColor(flag6 ? "positive" : "negative");
c.Say(text);
}
}
</syntaxhighlight>
* The eventual gain of food is multiplied by its actual nutrition value, divided by 10.
* If the character is currently in Anorxeia, it can only gain 1% of the original benefit of eating.
<syntaxhighlight lang="c#" line="1">
switch (foodEffect[0])
{
case "exp":
{
id = ((foodEffect.Length > 1) ? EClass.sources.elements.alias[foodEffect[1]].id : value.id);
int a = (int)(num7 * (float)((foodEffect.Length > 2) ? foodEffect[2].ToInt() : 4)) * 2 / 3;
c.ModExp(id, a);
break;
}
case "pot":
{
id = ((foodEffect.Length > 1) ? EClass.sources.elements.alias[foodEffect[1]].id : value.id);
int vTempPotential = c.elements.GetElement(id).vTempPotential;
int num8 = EClass.rndHalf((int)(num7 / 5f) + 1);
num8 = num8 * 100 / Mathf.Max(100, vTempPotential * 2 / 3);
c.elements.ModTempPotential(id, num8, 8);
break;
}
</syntaxhighlight>
* The food effect for attribute experiences and attribute potential is different.
** For attribute experiences, the experience gained is (overall modifier (num2)) *  (actual nutrition (num6)) / 10 * dish exp level * 8 / 3.
** For potential increase, the increase is a value between 50% and 100% of (overall modifier (num2)) *  (actual nutrition (num6)) / 10 * dish exp level / 5 + 1.
*** However the value will be further penalized if the temporal potential is already over 150.
=== Is this food tasty? ===




[[Category:EN]]
[[Category:EN]]
[[Category:Elin Spoiler]]
[[Category:Elin Spoiler]]

Revision as of 11:59, 22 December 2024

This page is designed to feature code analysis that are currently unclassified into other pages, either due to being too minor detail, or don't have enough stuff to justify having its entire page.

Material in this page will be moved into other pages constantly. Please refrain from linking wiki articles onto this page.

For authors: Please note the version of game tested on for each section added.

Sword Mage - Talisman Trait (EA23.54)

    case MixType.Talisman:
		{
			int num2 = EClass.pc.Evalue(1418);
			Thing thing4 = ai.ings[1];
			SourceElement.Row source2 = (thing4.trait as TraitSpellbook).source;
			int num3 = thing4.c_charges * source2.charge * (100 + num2 * 50) / 500 + 1;
			int num4 = 100;
			Thing thing5 = ThingGen.Create("talisman").SetNum(num3);
			thing5.refVal = source2.id;
			thing5.encLV = num4 * (100 + num2 * 10) / 100;
			thing.ammoData = thing5;
			thing.c_ammo = num3;
			EClass.pc.Say("talisman", thing, thing5);
			thing4.Destroy();
			break;
		}
  • The "talisman mastery 2" trait of swordmage positively influence the effect of created talismans. Specifically:
    • The number of charges created by swordmage will be (magic_book_charges * num_of_charge_gained_if_read * 2 / 5) + 1.
    • For a normal PC, the number of charges will be (magic_book_charges * num_of_charge_gained_if_read * 1 / 5) + 1.
      • For example, for a magic book with 3 reads left with each read giving PC 10 charges, the number of talisman charge by swordmage would be 13, while by normal PC would be 7.
    • The talisman level created by swordmage is fixed at 120, while fixed at 100 by normal PC.

Food Effect (EA 23.62 Hotfix 1)

Food Effect is one of the most important part of Elin and Elona. As the saying goes "you are what you eat." We shall put the entire code here, and track any changes affecting the biggest part of the game: cooking and eating.

Human or not human?

    public static bool IsHumanFlesh(Thing food)
	{
		if (food.HasTag(CTAG.notHumanMeat))
		{
			return false;
		}
		if (food.id == "deadbody")
		{
			return true;
		}
		if (food.source._origin != "meat" && food.source._origin != "dish")
		{
			return false;
		}
		string[] components = food.source.components;
		for (int i = 0; i < components.Length; i++)
		{
			if (components[i].Contains("egg"))
			{
				return false;
			}
		}
		if (!IsHumanFlesh(food.refCard))
		{
			return IsHumanFlesh(food.refCard2);
		}
		return true;
	}
  • This part of the code controls whether the corpse is considered human flesh:
    • If the food has id of "deadbody", then it is automatically True.
    • If the food is not meat or dish, it is automatically False.
      • Probably want to disinclude milk, eggs, etc.
    • If the food components contains egg, then it is not considered human flesh.
      • This can potentially be exploited to put human flesh and egg together and create a non-human flesh dish.
      • Not many recipes put meat and egg together though.
    • The refCard effects need to be confirmed.

Undead or not?

	public static bool IsUndeadFlesh(Thing food)
	{
		if (food.source._origin != "meat" && food.source._origin != "dish")
		{
			return false;
		}
		if (!IsUndeadFlesh(food.refCard))
		{
			return IsUndeadFlesh(food.refCard2);
		}
		return true;
	}
  • The code for undead flesh is much more simple.
    • It checks if the food in question is raw meat or a complete dish. If not returns false.
    • It then checks the refCards of the food & components. (Need confirmation)

How much does this food give you?

WARNING: This section is not based on empirical analysis.

Please beware the editor's understanding of this part of the code is rudimentary only.

  • There are a few main contributing factor of a dish.
    • One of them is a overall modifier, in code this is depicted as num2
	bool flag = EClass._zone.IsPCFaction && c.IsInSpot<TraitSpotDining>();
	int num = (food.isCrafted ? ((EClass.pc.Evalue(1650) >= 3) ? 5 : 0) : 0);
    float num2 = (float)(100 + (food.HasElement(757) ? 10 : 0) + (flag ? 10 : 0) + num + Mathf.Min(food.QualityLv * 10, 100)) / 200f;
		if (num2 < 0.1f)
		{
			num2 = 0.1f;
		}
  • This value is first set start from 100, if just cooked +10, if consumed in the eating area in PC region +10, if crafted by PC with 3 level of gourmet +5. Each level of food quality +10 (Need confirmation if it is the value shown on screen), then divided by 200.
    • Example: A dish crafted by a normal PC, with food quality of lvl 5, consumed in the eating area, would have a value of 0.8.
    • If this value is less than 0.1, it is set at 0.1.
	bool flag2 = IsHumanFlesh(food);
	bool flag3 = IsUndeadFlesh(food);
	bool flag4 = c.HasElement(1205);
	bool flag5 = food.IsDecayed || flag3;
    if (food.IsBlessed)
		{
			num2 *= 1.5f;
		}
		if (food.IsCursed)
		{
			num2 *= 0.5f;
		}
		if (flag4)
		{
			if (flag2)
			{
				num5 *= 2f;
				num2 *= 1.5f;
			}
			else
			{
				num5 *= 0.5f;
				num2 /= 2f;
				num3 /= 2;
			}
		}
        else if (flag2)
		{
			num5 = 0f;
			num2 *= 0.5f;
		}
  • With the previous value, if the food is blessed, increase 50%, if the food is cursed, cut by 50%.
  • If the consumer have canniblism and the dish is human, increase 50%, if dish is not human, cut by 50%, while the nutrition of the dish is also cut by 50%.
  • If the consumer doesn't have cannibilism and the dish is human, cut by 50%.
		if (c.HasElement(1200))
		{
			num2 *= 1.25f;
		}
		if (!c.IsPC)
		{
			num2 *= 3f;
		}
  • If the PC have the trait of Efficient Feeder (Juere), the value is increase by 25%.
  • If the consumer is not PC, increased by 200%.
    • This is the main reason why pets outpaces PC really fast... They eat 3 times more efficient than PC!
			switch (food.source._origin)
			{
			case "meat":
				if (c.IsPC)
				{
					c.Say("food_raw_meat");
				}
				num2 *= 0.7f;
				num5 = 0.5f;
				break;
			case "fish":
				if (c.IsHuman)
				{
					if (c.IsPC)
					{
						c.Say("food_raw_fish");
					}
					num2 *= 0.9f;
					num5 = 0.5f;
				}
				break;
			case "dough":
				if (c.IsPC)
				{
					c.Say("food_raw_powder");
				}
				num2 *= 0.9f;
				num5 = 0.5f;
				break;
  • If the food is not rotten:
    • If the food is raw, depend on the category, its value is further decreased: meat -30%, fish -10%, dough -10%.
    int num3 = food.Evalue(10);
    float num6 = Mathf.Min(c.hunger.value, num3);
    if (c.hunger.GetPhase() >= 3)
		{
			num6 *= 1.1f;
		}
		if (flag5 && !c.HasElement(480))
		{
			c.ModExp(70, -300);
			c.ModExp(71, -300);
			c.ModExp(72, -200);
			c.ModExp(73, -200);
			c.ModExp(74, -200);
			c.ModExp(75, 500);
			c.ModExp(76, -200);
			c.ModExp(77, -300);
		}
  • The nutrition value (num3) of food is loaded, and the actual nutrition can be absorbed by a character cannot exceed its current hunger value.
  • If the character is hungry, then the actual nutrition is increased by 10%.
    • A reminder, what is increased is not efficiency, but nutrition amount. I.e. the food becomes more filling.
  • If the food is rot and the character cannot take rotten food, each of the characters main attribute will be heavily penalized, except Will, which will have a heavy increase.
    • Guess eating rotten food train your will.
    else
		{
			num2 = num2 * num6 / 10f;
			if (c.HasCondition<ConAnorexia>())
			{
				num2 = 0.01f;
			}
			List<Element> list = food.ListValidTraits(isCraft: true, limit: false);
			foreach (Element value in food.elements.dict.Values)
			{
				if (value.source.foodEffect.IsEmpty() || !list.Contains(value))
				{
					continue;
				}
				string[] foodEffect = value.source.foodEffect;
				int id = value.id;
				float num7 = num2 * (float)value.Value;
				if (value.source.category == "food" && c.IsPC)
				{
					bool flag6 = num7 >= 0f;
					string text = value.source.GetText(flag6 ? "textInc" : "textDec", returnNull: true);
					if (text != null)
					{
						Msg.SetColor(flag6 ? "positive" : "negative");
						c.Say(text);
					}
				}
  • The eventual gain of food is multiplied by its actual nutrition value, divided by 10.
  • If the character is currently in Anorxeia, it can only gain 1% of the original benefit of eating.
				switch (foodEffect[0])
				{
				case "exp":
				{
					id = ((foodEffect.Length > 1) ? EClass.sources.elements.alias[foodEffect[1]].id : value.id);
					int a = (int)(num7 * (float)((foodEffect.Length > 2) ? foodEffect[2].ToInt() : 4)) * 2 / 3;
					c.ModExp(id, a);
					break;
				}
				case "pot":
				{
					id = ((foodEffect.Length > 1) ? EClass.sources.elements.alias[foodEffect[1]].id : value.id);
					int vTempPotential = c.elements.GetElement(id).vTempPotential;
					int num8 = EClass.rndHalf((int)(num7 / 5f) + 1);
					num8 = num8 * 100 / Mathf.Max(100, vTempPotential * 2 / 3);
					c.elements.ModTempPotential(id, num8, 8);
					break;
				}
  • The food effect for attribute experiences and attribute potential is different.
    • For attribute experiences, the experience gained is (overall modifier (num2)) * (actual nutrition (num6)) / 10 * dish exp level * 8 / 3.
    • For potential increase, the increase is a value between 50% and 100% of (overall modifier (num2)) * (actual nutrition (num6)) / 10 * dish exp level / 5 + 1.
      • However the value will be further penalized if the temporal potential is already over 150.

Is this food tasty?