Elin:Code Analysis/Faith: Difference between revisions

Line 2: Line 2:


==Piety and Gift==
==Piety and Gift==
===Gift at which piety level?===
<syntaxhighlight lang="c#" line="1">
<syntaxhighlight lang="c#" line="1">
     int num = EClass.pc.Evalue(85);
     int num = EClass.pc.Evalue(85);
Line 28: Line 29:
</syntaxhighlight>
</syntaxhighlight>
* As of EA23.61, there are two Gift ranks for each god, and each of them is hardcoded at piety level 15 and 30. You will recieve a gift after reach each of these levels then manually pray to the god.
* As of EA23.61, there are two Gift ranks for each god, and each of them is hardcoded at piety level 15 and 30. You will recieve a gift after reach each of these levels then manually pray to the god.
===What messages are shown at which threshold?===
<syntaxhighlight lang="c#" line="1">
<syntaxhighlight lang="c#" line="1">
     int num = Mathf.Max(c.Evalue(306), 1);
     int num = Mathf.Max(c.Evalue(306), 1);
Line 51: Line 53:
* Then depend on num2, different message will be played.
* Then depend on num2, different message will be played.
* If you are at maximum piety (num2 = 4), then a message will always be shown.
* If you are at maximum piety (num2 = 4), then a message will always be shown.
===What message is shown at which offer value?===
<syntaxhighlight lang="c#" line="1">
public int GetOfferingValue(Thing t, int num = -1)
{
if (num == -1)
{
num = t.Num;
}
int num2 = 0;
if (t.source._origin == "meat")
{
num2 = Mathf.Clamp(t.SelfWeight / 10, 1, 1000);
if (t.refCard == null)
{
num2 /= 10;
}
}
else
{
string[] cat_offer = source.cat_offer;
foreach (string key in cat_offer)
{
if (t.category.IsChildOf(key))
{
num2 = Mathf.Clamp(t.SelfWeight / 10, 50, 1000);
num2 *= EClass.sources.categories.map[key].offer / 100;
break;
}
}
}
if (num2 == 0)
{
return 0;
}
if (t.IsDecayed)
{
num2 /= 10;
}
num2 *= (t.LV * 2 + 100) / 100;
return Mathf.Max(num2, 1) * num;
}
</syntaxhighlight>
* The offer value is calculated with the following
* num is the number of items you offered.
* num2 will be the offering value per item, with minimum value of "1".
* If the item is meat, then;
** The weight of meat is divided by 10 (to know that 1000 weight = 1.0s), with minimum value of 1 and maximum value of 1000.
** If this meat is unlabelled (i.e. not being a meat drop by entity) the value is further divided by 10. ('''Need confirmation''')
*** So a labelled, 0.7s meat will generate a offer value of 70.
* If the item is of category a god will take, then:
** The weight of item is divided by 10, but with a minimum value of 50 and maximum value of 1000.
*** The weight of item will still count, but anything less than 0.5s will count as 0.5s.
** The number is then multiplied by the category value ('''Need investigation''').
* If the item is decayed (rotten), the offer value is further divided by 10.
* The offer value will '''increase by 2%''' per each level of the item. ('''What is the level of an item?''')
<syntaxhighlight lang="c#" line="1">
public void _OnOffer(Chara c, Thing t, int takeoverMod = 0)
{
bool @bool = t.GetBool(115);
int offeringValue = Deity.GetOfferingValue(t, t.Num);
offeringValue = offeringValue * (c.HasElement(1228) ? 130 : 100) / 100;
if (takeoverMod == 0)
{
if (offeringValue >= 200)
{
Msg.Say("god_offer1", t);
EClass.pc.faith.Talk("offer");
}
else if (offeringValue >= 100)
{
Msg.Say("god_offer2", t);
}
else if (offeringValue >= 50)
{
Msg.Say("god_offer3", t);
}
else
{
Msg.Say("god_offer4", t);
}
}
else
{
Msg.Say("god_offer1", t);
offeringValue += Deity.GetOfferingValue(t, 1) * takeoverMod;
}
        int num = Mathf.Max(c.Evalue(306), 1);
Element orCreateElement = c.elements.GetOrCreateElement(85);
int value = orCreateElement.Value;
c.elements.ModExp(orCreateElement.id, offeringValue * 2 / 3);
</syntaxhighlight>
* The previously calculated offeringValue will return to this function, then the message displayed will be determined.
* But first, if the character is demigod, the offeringValue will be further offset by 30%.
* The offering value threshold for each message is 200, 100, 50.
** So a piece of meat of 2.2s should generate the best possible message...should it?
* HOWEVER, the experience gained towards Piety is only calculated at two-thirds of the offering value.


==Ehekatl's School of Magic==
==Ehekatl's School of Magic==
381

edits