Ripped from Infamous (My emulator):
Code:
private static void LoadFormula(ref float[] mulTable)
{
XmlReader reader = new XmlTextReader("formula.xml");
int low = 0, high = 0;
float value = 0.0f;
while (reader.Read())
{
switch (reader.Name)
{
case "LM":
low = int.Parse(reader.GetAttribute("lower"));
high = int.Parse(reader.GetAttribute("upper"));
value = reader.ReadElementContentAsFloat();
for (; low < high; low++)
mulTable[low] = value;
break;
case "FORMULA_TABLE":
if (reader.GetAttribute("id") != "NeedExpLM")
return;
break;
}
}
}
private static void CalculateEXP()
{
float[] MulTable = new float[100];
LoadFormula(ref MulTable);
for (int i = 1; i < 100; ++i)
{
UInt32 exp = (UInt32)((double)(i * i) * MulTable[i] * 100.0 + .5f);
EXP.EXPTable[i] = Convert.ToUInt32(EXP.EXPTable[i - 1] + 2 * exp);
}
}
Standard multiplier was 1.