Just want some thought or suggestions on how to get the the HD corresponding to the current available XP of creatures/pc's. (ie : returning 40 for a level 1 holding 780.000 xp)
I have my own, wich process level by level, so I'm kind of concerned about its efficiency, and I would appreciate any lighter way to achieve it. I do not want that version wich is a switch-case stating each lvl, nor the version with a lot of if else statments.
Just to let you know my current version
<code>
int GetRealHD(object oPC)
{
int i,x,f;
int nXP = GetXP(oPC);
if(nXP < 780000)
{
for (x = 0; x <= 40; x ++)
{
i = ((x * (x - 1)) / 2) * 1000;
if(nXP < i)
{
f = x-1; break;
}
}
}
else{f = 40;}
return f;
}
</code>
GetRealHD
Débuté par
ultima03
, janv. 08 2012 07:45
#1
Posté 08 janvier 2012 - 07:45
#2
Posté 08 janvier 2012 - 07:50
This is from pwfxp script:
int GetRealHD(object oPC)
{
return FloatToInt(0.5 + sqrt(0.25 + ( IntToFloat(GetXP(oPC)) / 500 )));
}
int GetRealHD(object oPC)
{
return FloatToInt(0.5 + sqrt(0.25 + ( IntToFloat(GetXP(oPC)) / 500 )));
}
#3
Posté 08 janvier 2012 - 07:54
Thanks. I see that it's from Knat, that guy rocks, I'll let him know once more.
Modifié par ultima03, 08 janvier 2012 - 07:55 .
#4
Posté 08 janvier 2012 - 08:14
Alex Warren wrote...
This is from pwfxp script:
int GetRealHD(object oPC)
{
return FloatToInt(0.5 + sqrt(0.25 + ( IntToFloat(GetXP(oPC)) / 500 )));
}
Just tested and it worked perfectly. Just one addition because it goes beyond 40. (I got level 103)
int GetRealHD(object oPC)
{
int nXP = GetXP(oPC);
if(nXP >= 780000){return 40;}
return FloatToInt(0.5 + sqrt(0.25 + ( IntToFloat(nXP) / 500 )));
}





Retour en haut






