Elin:Code Analysis/Unclassified: Difference between revisions

From Ylvapedia
No edit summary
 
(9 intermediate revisions by the same user not shown)
Line 7: Line 7:
'''For authors''': Please note the version of game tested on for each section added.
'''For authors''': Please note the version of game tested on for each section added.


==Sword Mage - Talisman Trait (EA23.54)==
== Drink from well (EA23.67)==
{{Version|23.67}}
<syntaxhighlight lang="c#" line="1">
<syntaxhighlight lang="c#" line="1">
    case MixType.Talisman:
public override void TrySetAct(ActPlan p)
{
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;
}
</syntaxhighlight>
 
* 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.
 
==Ether Diseases (EA23.61)==
===Depiction of Ether Disease in code: an Index===
<syntaxhighlight lang="c#" line="1">
public const int etherManaBattery = 1564;
public const int etherPoisonHand = 1565;
public const int etherProvoke = 1563;
public const int etherStupid = 1561;
public const int etherWeak = 1560;
public const int etherAddict = 1559;
public const int etherRain = 1558;
public const int etherHead = 1557;
public const int etherViolence = 1556;
public const int etherNeck = 1555;
public const int etherWing = 1554;
public const int etherEye = 1553;
public const int etherFeet = 1552;
public const int etherArmor = 1562;
public const int etherUgly = 1551;
public const int etherGravity = 1550;
</syntaxhighlight>
 
* All ether disease is depicted with integer (i.e. level). There are 16 kinds of diseases, and we will review each of them.
* If you want to see for the effect yourself, just search for that number in code.
 
=== Mana Battery ===
<syntaxhighlight lang="c#" line="1">
    case 1564:
ModBase(961, a * 5, hide: false);
break;
</syntaxhighlight>
 
* This disease increase your magic resistance (961) by 5 per level (there is only one level currently).
 
<syntaxhighlight lang="c#" line="1">
public void TryAbsorbRod(Thing t)
{
{
if (!IsPC || !(t.trait is TraitRod) || t.c_charges <= 0 || !HasElement(1564))
p.TrySetAct("actDrink", delegate
{
{
return;
if (Charges <= 0)
}
{
Say("absorbRod", this, t);
EClass.pc.Say("drinkWell_empty", EClass.pc, owner);
TraitRod rod = t.trait as TraitRod;
return false;
bool flag = false;
}
if (rod.source != null)
EClass.pc.Say("drinkWell", EClass.pc, owner);
{
EClass.pc.PlaySound("drink");
using IEnumerator<SourceElement.Row> enumerator = EClass.sources.elements.rows.Where((SourceElement.Row a) => a.id == rod.source.id).GetEnumerator();
EClass.pc.PlayAnime(AnimeID.Shiver);
if (enumerator.MoveNext())
if (IsHoly || EClass.rnd(5) == 0)
{
ActEffect.Proc(EffectId.ModPotential, EClass.pc, null, (!polluted && (IsHoly || EClass.rnd(2) == 0)) ? 100 : (-100));
}
else if (EClass.rnd(5) == 0)
{
BadEffect(EClass.pc);
}
else if (EClass.rnd(4) == 0)
{
ActEffect.Proc(EffectId.Mutation, EClass.pc);
}
else if (EClass.rnd(EClass.debug.enable ? 2 : 10) == 0 && !polluted && !EClass.player.wellWished)
{
{
SourceElement.Row current = enumerator.Current;
if (EClass.player.CountKeyItem("well_wish") > 0)
if (IsPC)
{
{
GainAbility(current.id, t.c_charges * 100);
EClass.player.ModKeyItem("well_wish", -1);
flag = true;
ActEffect.Proc(EffectId.Wish, EClass.pc, null, 10 + EClass.player.CountKeyItem("well_enhance") * 10);
EClass.player.wellWished = true;
}
else
{
Msg.SayNothingHappen();
}
}
}
}
}
else if (polluted)
if (!flag)
{
{
EClass.pc.Say("drinkWater_dirty");
mana.Mod(-50 * t.c_charges);
BadEffect(EClass.pc);
}
}
t.c_charges = 0;
else
LayerInventory.SetDirty(t);
}
    ...
    public void GainAbility(int ele, int mtp = 100)
{
Element orCreateElement = elements.GetOrCreateElement(ele);
if (orCreateElement.ValueWithoutLink == 0)
{
elements.ModBase(orCreateElement.id, 1);
}
if (orCreateElement is Spell)
{
int num = mtp * orCreateElement.source.charge * (100 + Evalue(307) + (HasElement(307) ? 20 : 0)) / 100 / 100;
if (orCreateElement.source.charge == 1)
{
{
num = 1;
EClass.pc.Say("drinkWater_clear");
}
}
orCreateElement.vPotential += Mathf.Max(1, num / 2 + EClass.rnd(num / 2 + 1));
ModCharges(-1);
}
return true;
Say("spell_gain", this, orCreateElement.Name);
}, owner);
LayerAbility.SetDirty(orCreateElement);
}
}
</syntaxhighlight>
</syntaxhighlight>


* Once detect PC have mana battery, it will take the charges in a rod, then call Gainability(this spell, 100 * charge number) to give PC this spell.
* These code explains what happens when you drink water from well.
* This does not mean you get 100 wish spells for 1 charge of wish rod! Each spell have a unique charge parameter (see SourceGame/Element for more), and depend on the charge number it will give you number of spell casting.
* These effects will be applied step by step.
** This value is modified by your memorization skill. If you have the skill, a flat 20% is added, then for each skill level, 1% added.
* In 1/5 chance, potential of a main attribute will increase (50%) or decrease (50%).
** For example, for a wish rod, and you have lvl 80 memorization, the num will equal to = 100 * 1 (Wish has a charge number of 1) * (80+100+20) / 100 / 100 = 2
** This will be forced to trigger if it i a holy well, and will be 100% increase.
** Which is pretty good, yes, you get 2 wishes out of 1 rod, but can you cast it, hum?
* Then in another 1/5 chance, bad effect will be applied to the PC, with equal chance of being one of the seven: Blind, Paralyze, Sleep, Poison, Faint, Disease, Confuse.
* After that, if you are not PC, your mana will be drained by 50 per charge of rod. Then the rod goes to 0 charges.
* Then in another 1/4 chance, a mutation will be applied to the PC.
* Then in another 1/10 chance, and when PC hasn't wished in this year, and when the well isn't polluted, a wish is granted.
** This chance is increased to 1/2 if user in debug mode.
** The strength of wish is 10 + 10 * the amount of saliva a PC have.
* Then, the normal effect will be triggered.
** If the well is polluted, debuff will be applied to the PC.
** If the well is clean, it is as if the PC drank real water.


=== Poison Hand ===
<syntaxhighlight lang="c#" line="1">
    case 1565:
ModBase(955, a * 20, hide: false);
break;
</syntaxhighlight>


* Each level of poison hand raise your poison resistance by 20 (there is only 1 level).
* Overall Chances for non-holy, non-polluted well:
<syntaxhighlight lang="c#" line="1">
** 10% Main Attribute Potential Increase
    if (conWeapon == null && weapon == null && (CC.MainElement != Element.Void || CC.HasElement(1565)))
** 10% Main Attribute Potential Decrease
{
** 16% 1 of 7 type of Bad effect on PC
num5 = (CC.HasElement(1565) ? 915 : CC.MainElement.id);
** 16% Random Mutation on PC
num6 = CC.Power / 3 + EClass.rnd(CC.Power / 2);
** '''4.8% Wish''' (if PC meet the requirement)
if (CC.MainElement != Element.Void)
** 43.2% Plain Water.
{
num6 += CC.MainElement.Value;
}
showEffect = false;
num7 = 50;
}
</syntaxhighlight>
 
* When you attack with no weapon, all your attack will be transformed into element Poison (915).
* We see in the code a -50% penalty will be applied to your damage as well but this '''need confirmation'''.
 
<syntaxhighlight lang="c#" line="1">
    public Thing TryPoisonPotion(Thing t)
{
if (t.trait is TraitPotion && t.id != "1165" && !t.source.tag.Contains("neg") && EClass.rnd(2) == 0 && HasElement(1565))
{
string text = EClass.sources.things.rows.Where((SourceThing.Row a) => a._origin == "potion" && a.tag.Contains("neg") && a.chance > 100).ToList().RandomItemWeighted((SourceThing.Row a) => a.chance)
.id;
Say("poisonDrip", this);
int num = t.Num;
t.Destroy();
t = ThingGen.Create(text).SetNum(num);
}
return t;
}
</syntaxhighlight>


* This is the code use to make all your potions in your bag poison.
* A random chance of 50% is applied first, so there is 50% chance your potion will be spared.
* It also looks like it will transform a whole stack of your potions at once.
===
[[Category:EN]]
[[Category:EN]]
[[Category:Elin Spoiler]]
[[Category:Elin Spoiler]]

Latest revision as of 15:09, 27 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.

Drink from well (EA23.67)

Version EA23.67: This article is behind the latest stable release of Elin, but maybe close enough to be reliable.
public override void TrySetAct(ActPlan p)
	{
		p.TrySetAct("actDrink", delegate
		{
			if (Charges <= 0)
			{
				EClass.pc.Say("drinkWell_empty", EClass.pc, owner);
				return false;
			}
			EClass.pc.Say("drinkWell", EClass.pc, owner);
			EClass.pc.PlaySound("drink");
			EClass.pc.PlayAnime(AnimeID.Shiver);
			if (IsHoly || EClass.rnd(5) == 0)
			{
				ActEffect.Proc(EffectId.ModPotential, EClass.pc, null, (!polluted && (IsHoly || EClass.rnd(2) == 0)) ? 100 : (-100));
			}
			else if (EClass.rnd(5) == 0)
			{
				BadEffect(EClass.pc);
			}
			else if (EClass.rnd(4) == 0)
			{
				ActEffect.Proc(EffectId.Mutation, EClass.pc);
			}
			else if (EClass.rnd(EClass.debug.enable ? 2 : 10) == 0 && !polluted && !EClass.player.wellWished)
			{
				if (EClass.player.CountKeyItem("well_wish") > 0)
				{
					EClass.player.ModKeyItem("well_wish", -1);
					ActEffect.Proc(EffectId.Wish, EClass.pc, null, 10 + EClass.player.CountKeyItem("well_enhance") * 10);
					EClass.player.wellWished = true;
				}
				else
				{
					Msg.SayNothingHappen();
				}
			}
			else if (polluted)
			{
				EClass.pc.Say("drinkWater_dirty");
				BadEffect(EClass.pc);
			}
			else
			{
				EClass.pc.Say("drinkWater_clear");
			}
			ModCharges(-1);
			return true;
		}, owner);
	}
  • These code explains what happens when you drink water from well.
  • These effects will be applied step by step.
  • In 1/5 chance, potential of a main attribute will increase (50%) or decrease (50%).
    • This will be forced to trigger if it i a holy well, and will be 100% increase.
  • Then in another 1/5 chance, bad effect will be applied to the PC, with equal chance of being one of the seven: Blind, Paralyze, Sleep, Poison, Faint, Disease, Confuse.
  • Then in another 1/4 chance, a mutation will be applied to the PC.
  • Then in another 1/10 chance, and when PC hasn't wished in this year, and when the well isn't polluted, a wish is granted.
    • This chance is increased to 1/2 if user in debug mode.
    • The strength of wish is 10 + 10 * the amount of saliva a PC have.
  • Then, the normal effect will be triggered.
    • If the well is polluted, debuff will be applied to the PC.
    • If the well is clean, it is as if the PC drank real water.


  • Overall Chances for non-holy, non-polluted well:
    • 10% Main Attribute Potential Increase
    • 10% Main Attribute Potential Decrease
    • 16% 1 of 7 type of Bad effect on PC
    • 16% Random Mutation on PC
    • 4.8% Wish (if PC meet the requirement)
    • 43.2% Plain Water.