Clone of PhatAC @ https://github.com/floaterxk/PhatAC

Vitals.cpp 1.3KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. #include "StdAfx.h"
  2. #include "vitals.h"
  3. #include "TurbineXPTable.h"
  4. #include "Rules.h"
  5. const char *GetVitalName(eVital index)
  6. {
  7. switch (index)
  8. {
  9. case eHealth: return "Health";
  10. case eStamina: return "Stamina";
  11. case eMana: return "Mana";
  12. default: return "";
  13. }
  14. }
  15. DWORD GetVitalMaxXP()
  16. {
  17. XPTABLE* pXPTable = g_pGameRules->GetXPTable();
  18. if (pXPTable)
  19. return pXPTable->GetVitalMaxXP();
  20. else
  21. return 0;
  22. }
  23. DWORD GetVitalXP(DWORD Level)
  24. {
  25. XPTABLE* pXPTable = g_pGameRules->GetXPTable();
  26. if (pXPTable)
  27. return pXPTable->GetVitalXP(Level);
  28. else
  29. return 0;
  30. }
  31. DWORD GetVitalLevel(DWORD XP)
  32. {
  33. XPTABLE* pXPTable = g_pGameRules->GetXPTable();
  34. if (pXPTable)
  35. return pXPTable->GetVitalLevel(XP);
  36. else
  37. return 0;
  38. }
  39. float GetVitalPercent(VITAL *pVital, float fVitae)
  40. {
  41. DWORD dwMin = GetVitalMin(pVital, fVitae);
  42. DWORD dwMax = GetVitalMax(pVital, fVitae);
  43. DWORD dwCurrent = GetVitalCurrent(pVital, fVitae);
  44. DWORD dwRange = dwMax - dwMin;
  45. if (!dwRange)
  46. return 0;
  47. float flFraction = (dwCurrent - dwMin) / (float)dwRange;
  48. return flFraction;
  49. }
  50. DWORD GetVitalCurrent(VITAL *pVital, float fVitae)
  51. {
  52. return pVital->data.current;
  53. }
  54. DWORD GetVitalMin(VITAL *pVital, float fVitae)
  55. {
  56. return 0;
  57. }
  58. DWORD GetVitalMax(VITAL *pVital, float fVitae)
  59. {
  60. return (pVital->data.raises);
  61. }