///////////////////////////////////////////
// Arbitrary Score header functions
///////////////////////////////////////////
// functions used by the advisor to make guesses as to how you are doing.
///////////////////////////////////////////
int fnLevel(object oPC)
{ // return level
  int nRet=GetLevelByPosition(1,oPC);
  nRet=nRet+GetLevelByPosition(2,oPC);
  nRet=nRet+GetLevelByPosition(3,oPC);
  return nRet;
} // fnLevel()

int fnCountUnits(object oPC)
{ // return Units*cr
  float fCR;
  float fTotal;
  string sID=GetLocalString(oPC,"sTeamID");
  int nRet;
  object oWP=GetWaypointByTag(sID+"_RESOURCES");
  object oTemp=CreateObject(OBJECT_TYPE_CREATURE,sID+"0",GetLocation(oWP));
  object oNPC=GetFirstFactionMember(oTemp,FALSE);
  while(oNPC!=OBJECT_INVALID)
  { // count
    if (GetLocalString(oNPC,"sTeamID")==sID&&oNPC!=oTemp)
    { // count
      fCR=GetChallengeRating(oNPC);
      fTotal=fTotal+fCR;
    } // count
    oNPC=GetNextFactionMember(oTemp,FALSE);
  } // count
  DestroyObject(oTemp);
  nRet=FloatToInt(fTotal);
  return nRet;
} // fnCountUnits()

int fnPlayerPower(string sID)
{ // get strength of players
  int nRet=0;
  object oPC=GetFirstPC();
  while(oPC!=OBJECT_INVALID)
  { // !OI
    if (GetLocalString(oPC,"sTeamID")==sID)
      nRet=nRet+(fnLevel(oPC)*2);
    oPC=GetNextPC();
  } // !OI
  return nRet;
} // fnPlayerPower()

int fnMilitaryMight(object oPC)
{ // return total military might
  int nRet=0;
  nRet=fnPlayerPower(GetLocalString(oPC,"sTeamID"));
  nRet=nRet+fnCountUnits(oPC);
  return nRet;
} // fnMilitaryMight()

int fnScore(object oPC)
{ // raw score
  int nRet=0;
  nRet=fnMilitaryMight(oPC);
  nRet=nRet+GetGold(oPC);
  nRet=nRet+(GetLocalInt(oPC,"nSoulStore")*50);
  nRet=nRet+GetLocalInt(oPC,"nManaStore");
  return nRet;
} // fnScore()