Aller au contenu

Photo

GetRealHD


  • Veuillez vous connecter pour répondre
3 réponses à ce sujet

#1
ultima03

ultima03
  • Members
  • 38 messages
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>

#2
Alex Warren

Alex Warren
  • Members
  • 179 messages
This is from pwfxp script:

int GetRealHD(object oPC)
{
return FloatToInt(0.5 + sqrt(0.25 + ( IntToFloat(GetXP(oPC)) / 500 )));
}

#3
ultima03

ultima03
  • Members
  • 38 messages
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
ultima03

ultima03
  • Members
  • 38 messages

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 )));
    }