Elin:Code Analysis/Feats

From Ylvapedia
Revision as of 01:46, 28 December 2024 by Inno (talk | contribs)
Version EA23.67: This article is up to date for the latest stable release of Elin.

Feat can mean a few things at the same time:

  1. Racial feat, which is gained at race selection;
  2. Class feat, which is gained with different character class;
  3. Gained feat, which is gained through level up and spending feat points.

This page review some of the feats, which have their actual effects hidden from player view.

Depiction of Feats in code: an Index

public const int featStamina = 1612; x
public const int featCHA = 1627; x
public const int featWIL = 1626; x
public const int featMAG = 1625; x
public const int featLER = 1624; x
public const int featPER = 1623; x
public const int featEND = 1622; x
public const int featDEX = 1621; x
public const int featSTR = 1620; x
public const int featLuck = 1628; x
public const int featSwordsage = 1418; *
public const int featLife = 1610; x
public const int featManaMeat = 1421; *
public const int featExecutioner = 1420; *
public const int featMilitant = 1419; *
public const int featWitch = 1417; x
public const int featInquisitor = 1416; x
public const int featFoxMaid = 1415;
public const int featWhiteVixen = 1414;
public const int featFairysan = 1413;
public const int featLuckyCat = 1412;
public const int featSPD = 1629; x
public const int featMana = 1611; x
public const int featHardy = 1630; x
public const int featLonelySoul = 1646; 
public const int featEvade = 1632; x
public const int featEarthStrength = 1411;
public const int featChef = 1658;
public const int featManaCost = 1657; x
public const int featScavenger = 1656; 
public const int featModelBeliever = 1655; x
public const int featDreamWaker = 1653;
public const int featRapidArrow = 1652;
public const int featMagicManner = 1651;
public const int featGourmet = 1650;
public const int featDefender = 1649;
public const int featDefense = 1631;
public const int featRapidMagic = 1648;
public const int featParty = 1645;
public const int featBodyParts = 1644;
public const int featSorter = 1643;
public const int featSleeper = 1642;
public const int featResCurse = 1641;
public const int featAnimalLover = 1640;
public const int featFaith = 1636;
public const int featMartial = 1635;
public const int featNegotiate = 1634;
public const int featSpotting = 1633;
public const int featSummoner = 1647;
public const int featReboot = 1410;
public const int featHeavyCasting = 1654;
public const int featPaladin2 = 1408; *
public const int featShiva = 1224;
public const int featLoyal = 1225;
public const int featUnderground = 1226;
public const int featServant = 1227;
public const int featDemigod = 1228;
public const int featLittleOne = 1229;
public const int featAdam = 1230;
public const int featNirvana = 1231;
public const int featCosmicHorror = 1233;
public const int featAcidBody = 1223;
public const int featHeavyEater = 1234;
public const int featNorland = 1236;
public const int featRoran = 1237;
public const int featGod_element1 = 1300;
public const int featGod_earth1 = 1305;
public const int featGod_wind1 = 1310;
public const int featGod_machine1 = 1315;
public const int featGod_healing1 = 1320;
public const int featGod_harvest1 = 1325;
public const int featGod_luck1 = 1330;
public const int featGod_moonshadow1 = 1350;
public const int featGod_trickery1 = 1345;
public const int featGod_strife1 = 1355;
public const int featGod_harmony1 = 1335;
public const int featGod_oblivion1 = 1340;
public const int featLightEater = 1235;
public const int featSplit = 1222;
public const int featSpike = 1221;
public const int featFate = 1220;
public const int featBoost = 1409;
public const int featSlowFood = 1200;
public const int featManaBond = 1201;
public const int featFastLearner = 1202;
public const int featGrowParts = 1203;
public const int featFairyWeak = 1204;
public const int featCannibalism = 1205;
public const int featMelilithCurse = 1206;
public const int featFoxBless = 1207;
public const int featFoxLearn = 1208;
public const int featFluffyTail = 1209;
public const int featUndead = 1210;
public const int featSnail = 1211;
public const int featFairyResist = 1212;
public const int featElea = 1213;
public const int featManaPrecision = 1214;
public const int featDwarf = 1215; *
public const int featSuccubus = 1216; x
public const int featGolem = 1217; x
public const int featMetal = 1218; *
public const int featElderCrab = 1219;
public const int featBaby = 1232; 
public const int featWarrior = 1400; *
public const int featThief = 1401; x
public const int featFarmer = 1403; *
public const int featArcher = 1404; *
public const int featPianist = 1405; *
public const int featTourist = 1406; *
public const int featWizard = 1402; x 
public const int featPaladin = 1407; *
  • All feats are depicted with integer (i.e. level). There are 111 kinds of feats. We will only review the ones with "*" mark beside it. If there is a "x" beside it, all the effects are shown to the player in game. If there is nothing beside it, then the code analyzer hasn't get to that feat yet.
  • If you want to see for the effect yourself, just search for that number in code.

Class feats

featSwordsage (Talisman Mastery)

    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.

featManameat (Mana Body)

	if (Evalue(1421) >= 2 && base.hp <= MaxHP / (9 - Evalue(1421) * 2))
		{
			num4 /= 2;
		}
	PlayEffect("cast");
	mana.Mod(-num4);
  • If the feat Mana body is at least level 2, then if the character's HP is lower than a threshold, all mana cost is cut by 50%.
    • Specifically, if feat Level is 2, when HP <= 20% Maximum HP, if feat Level is 3, when HP <= 33% Maximum HP.
    if (Evalue(1421) > 0)
		{
			int num6 = 0;
			int num7 = dmg;
			if (hp > 0)
			{
				num7 = dmg - hp;
				hp -= dmg;
				num6 += dmg;
				if (hp < 0 && Chara.mana.value >= 0)
				{
					num6 += hp;
					hp = 0;
				}
			}
			if (hp <= 0)
			{
				if (Evalue(1421) >= 2)
				{
					num7 /= 2;
				}
				dmg = num7;
				if (Chara.mana.value > 0)
				{
					num7 -= Chara.mana.value;
					Chara.mana.value -= dmg;
					num6 += dmg;
				}
				if (Chara.mana.value <= 0)
				{
					hp -= num7;
					num6 += num7;
				}
			}
			dmg = num6;
		}
  • It seems, that this mana cost reduction by 50% is also applied when HP is equal or less than 0 (only when Mana body >= level 2).
    • This effectively cut the damage these character recieved when HP is 0 by 50%.

featExecutioner (Heart of Death)

    if (CC.Evalue(1420) > 0)
		{
			int num3 = Mathf.Min(100, 100 - CC.hp * 100 / CC.MaxHP);
			if (num3 >= 50 && num3 * num3 * num3 * num3 / 3 > EClass.rnd(100000000))
			{
				return Crit();
			}
		}
	return true;
  • This is calculated after ALL other calculation is done. Such as Natural 20 hit, Natural 1 miss, etc.
    • A number (num3) is calculated through the percentage of HP left of a character. For example, if a character has 10% HP, that number is 90.
  • If the number is >= 50 (Character have less than 50% Max HP), we generate a random number, and test if num3^4 /3 is bigger than that number.
    • This effectively translate to a 33% Critical chance at 0 HP, and about 2% Critical chance at 50% HP.
  • Remember, this calculation is done after all other calculations, including all evasions. If player doesn't have this feat, this attack will hit anyway.
    • In other words, in order to trigger this effect, you have to first hit the enemy.

featPaladin (Devout)

	public void RefreshFaithElement()
	{
        ...
		SourceElement.Row row2 = EClass.sources.elements.alias.TryGetValue("featGod_" + row.id + "1");
		if (row2 != null)
		{
			faithElements.SetBase(row2.id, 1);
		}
		if (!HasCondition<ConExcommunication>())
		{
			int[] array = row.elements;
			int num = GetPietyValue() * (120 + Evalue(1407) * 15) / 100;
			for (int i = 0; i < array.Length; i += 2)
			{
				int num2 = array[i + 1] * num / 50;
				if (array[i] == 79)
				{
					num2 = EClass.curve(num2, array[i + 1] * 2, 10, 50);
				}
				if (num2 >= 20 && array[i] >= 950 && array[i] < 970)
				{
					num2 = 20;
				}
				faithElements.SetBase(array[i], Mathf.Max(num2, 1));
			}
		}
		faithElements.SetParent(this);
	}
  • The benefit of feat Devout is about 12.5% per level of that feat (15 of 120).

featTourist (Vacation Vibe)

		case 1406:
			featRef[0] = (a * 20).ToString() ?? "";
			featRef[1] = (a * 5).ToString() ?? "";
			break;
        ...
		if (!sell)
			{
				p *= 1f + 0.2f * (float)c.Evalue(1406);
			}
		break;
        ...
        num = num * (float)(100 + EClass.pc.Evalue(1406) * 5) / 100f;
  • The price for tourist will be increase by 100% (0.2f * lvl 5), the stock of shops will be increased by 25% (100 + 5 * 5)/100.

featPianist (Musician)

	if (p.progress > 2 && (EClass.rnd(100 + 50 * owner.Evalue(1405)) == 0 || 
           EClass.rnd(4 + (int)MathF.Max(0f, song.lv - playing.index * 25 - playing.index * playing.index / 2)) == 0))
			{
					playing.mistakes++;
					if (EClass.rnd(2) == 0)
					{
						LevelSong(2 + 2 * EClass.rnd(owner.Evalue(1405) + 1));
					}
					if (playing.mistakes >= 10)
					{
						playing.index = 0;
					}
					Cancel();
			}
    ...
    num = (EClass.rnd(c.LV * 2 + 1) + 1) * (100 + toolLv * 2 + owner.Evalue(1405) * 10) / 100;
  • The feat of Musician (lvl 2 by default) decrease the mistakes made by players
    • Specifically, if the song is of progress more than 2, the mistake possibility is decreased by 50%.
    • By a possibility of 50%, the experience of player's song is increased.
      • If normal player, the number of increase is 2.
      • If Musician, the number of increase is a number among 2, 4, 6.
  • This feat also increase the reward earned by player.
    • Specifically, increase 10% per level of feat (i.e. 20% total).

featArcher (Ranged Mastery) & featWarrior (Weapon Mastery)

	dMulti = 0.6f + (float)(weaponSkill.GetParent(CC).Value + weaponSkill.Value / 2 + CC.Evalue(flag3 ? 304 : (IsRanged ? 133 : 132))) / 50f;
	dMulti += 0.05f * (float)CC.Evalue(IsRanged ? 1404 : 1400);
  • This feat increase the damage multiplier of ranged attack/melee attack by 0.05 per level of feat.
    • Not 5% flat, mind you. The default damage multiplier is 0.6, and with more skills, the effect of this feat is diminished.

featFarmer (Farming Legs)

    int num = BaseStats.CC.Evalue(1403);
	if (a < 0 && num > 0)
		{
			a = a * 100 / (100 + EClass.rnd(num + 1) * 20);
			if (a == 0)
			{
				return;
			}
		}
  • For the feat of farmer "Farming Legs 2", the stamina cost of actions is randomly 100%, 83%, 72%.

featPaladin2 (Defensive Instinct)

	foreach (Chara chara3 in EClass._map.charas)
		{
			if (Chara.IsFriendOrAbove(chara3) && chara3.HasElement(1408) && chara3.faith == EClass.game.religions.Healing && EClass.world.date.GetRawDay() != chara3.GetInt(58) && (!chara3.IsPCFaction || IsPCFaction))
					{
						Msg.alwaysVisible = true;
						Msg.Say("layhand", chara3, this);
						Msg.Say("pray_heal", this);
						hp = MaxHP;
						Chara.AddCondition<ConInvulnerable>();
						PlayEffect("revive");
						PlaySound("revive");
						chara3.SetInt(58, EClass.world.date.GetRawDay());
						return;
					}
				}
  • Remember that you can only use layhand ability on a character that is friend or above.

Race Feats

featMetal (Metal 999)

		case 1218:
			ModBase(950, a / 40, hide: false);
			ModBase(952, a / 40, hide: false);
			ModBase(955, a / 40, hide: false);
			ModBase(953, a / 40, hide: false);
			ModBase(958, a / 40, hide: false);
			ModBase(956, a / 40, hide: false);
			ModBase(954, a / 40, hide: false);
			ModBase(959, a / 40, hide: false);
			ModBase(964, a / 40, hide: false);
			ModBase(961, a / 40, hide: false);
			break;
       ...
	   if (HasElement(1218))
			{
				dmg = dmg * (1000 - Evalue(1218)) / 1000;
				if (dmg <= 0 && EClass.rnd(4) == 0)
				{
					dmg++;
				}
			}
  • The resistance granted to metal races only work when the feat is at very, very high level.
    • Specifically, level 999 grant 24 level resistance for each type of damage.
  • Furthermore, for any damage done, the damage is decreased sharply.
    • Specifically, level 999 grant a damage reduction of 99.9%, rounded down to nearest integer.
      • 1000 damage will become 1, and anything less than 999 is shrugged off.
    • But if the damage is reduced to 0 at last step, in 1/4 chances the damage is returned to 1.

featDwarf (Mead Blood)

		int orgPower = power;
		if (blessed || flag)
		{
			power *= 2;
		}
		case EffectId.Booze:
			TC.AddCondition<ConDrunk>(power);
			if (TC.HasElement(1215))
			{
				TC.Say("drunk_dwarf", TC);
				TC.AddCondition(Condition.Create(power + EClass.rnd(power), delegate(ConBuffStats con)
				{
					con.SetRefVal(Element.List_MainAttributes.RandomItem(), (int)id);
				}));
			}
			break;
  • The power of the random buff hillfolks receive is based on the power of alcohol (but if the alcohol power is always static, then it is static. Need Confirmation.). The base power of alcohol is further increased by a randomized 0 to 100% amount.
    • If the alcohol is blessed, its base power is also multiplied by 2. Try that next time when you are in a pinch.
  • One of your main attributes will be buffed. this include the major eight, and speed.
			if (host != null && host.ride == this && ((host.isConfused && EClass.rnd(2) == 0) || (host.isDrunk && EClass.rnd(IsIdle ? 2 : 8) == 0 && !host.HasElement(1215))))
			{
				flag = true;
			}
			if (flag && newPoint.Distance(pos) <= 1)
			{
				Point randomNeighbor = pos.GetRandomNeighbor();
				if (CanMoveTo(randomNeighbor, allowDestroyPath: false))
				{
					newPoint = randomNeighbor;
					if (isDrunk)
					{
						Talk("drunk");
					}
				}
  • When a person is drunk, there is a 50% chance of randomly moving to a neighboring position if this character is Idle (not moving), and 12.5% if the character is moving.
  • When a person is confused, there is a 50% chance of randomly moving too.
  • The Mead Blood feat negates the drunk part, but not the confused part.

featMilitant (Frontline Commander)

    int num = 0;
    if (owner.IsPCParty)
			{
				int id = e.id;
				if (id == 70 || (uint)(id - 72) <= 1u)
				{
					int num2 = 0;
					foreach (Chara member in EClass.pc.party.members)
					{
						if (member.Evalue(1419) > 0)
						{
							num2 += member.Evalue(1419);
						}
					}
					if (num2 > 0)
					{
						int num3 = 0;
						foreach (Chara chara in EClass._map.charas)
						{
							if (chara.IsHostile(EClass.pc))
							{
								num3++;
							}
						}
						if (num3 > 0)
						{
							num += Mathf.Max(1, (e.ValueWithoutLink + e.vLink) * (int)Mathf.Clamp(4f + Mathf.Sqrt(num3) * (float)num2 * 2f, 5f, 30f) / 100);
						}
					}
				}
			}
  • The Frontier Commander feat is applied to STR, DEX, PER. (70, 72,73)
  • For each character with the feat, num2 is increased by the level of that feat (1).
  • For each hostile character to PC in the current map, num3 is increased by 1.
  • The final bonus to that stat is calculated by:
    • At least 1,
    • The current value * Clamp(4 + sqrt(num3) * num2 * 2, 5, 30) / 100
      • At least 5% of the current value of that stat, at most 30%.
      • the bonus is determined by the Square root of number of enemy, times the amount of NPC with the feat, times 2, plus 4.
      • The maximum bonus is reached at 169 enemies if 1 character with feat, but only about 39 enemies if 2 characters.