///////////cheat_config/////////////
////////////////////////////////////
//Created by Genisys / Guile 5/2/08
////////////////////////////////////

//Do not delete this include!!
#include "setxp_inc"

/////////////////////////OPTIONS SETTINGS//////////////////////////////////////
//(All Currently Disabled!)

//  0 = Turn Off This Option
//  1 = Turn On This Option

//This Switch will disallow the feats Devastating Criticals on any weapon!
const int DissallowDevastatingCritical = 0; // 0 = Off / 1 = On

//This Switch will disallow the feat Epic Dodge on your module.
const int DissallowEpicDodge = 0; // 0 = Off / 1 = On

//This Switch will Dissallow the feat Hide In Plain Sight on your module.
//Note this will prevent Player From Selecting the Shadow Dancer Class!
const int DissallowHideInPlainSight = 0; // 0 = Off / 1 = On

//////////////////Punishment Settings////////////////////////////

//Note all players playing a completely illegal character are Banned!!!
//Banned but they don't lose anything(just in case a mistake was made!)
//This can be reversed, see the "oncliententer" script. (Banned Token)

//If set to 1 the PC will lose all items & gold when punished
const int PunishmentA = 0; // 0 = Off / 1 = On

//If the int below is set to 1, the PC will be teleported to prison
//You must place a new waypoint in your module and give it the tagname "prison"
const int PunishmentB = 0; // 0 = Off / 1 = On

//If the int below is set to 1, the PC will be releveled till they lose
//the above feats(see above settings). (Also see PunishmentE below!)
const int PunishmentC = 0; // 0 = Off / 1 = On

//If the int below is set to 1, the player found with the above feats will not
//be allowed to play that character on the server any more.(Character Banned)
//(This can be reversed, see the OnClientEnter script.)  (Player not Banned)
const int PunishmentD = 0; // 0 = Off / 1 = On

//If the int below is set to 1 the player will lose ALL XP Permanently!
//Do not use this with PunishmentC set to 1 !!!(Use this or C not both!)
const int PunishmentE = 0; // 0 = Off / 1 = On

//////////////////////////SETTINGS OPTIONS END/////////////////////////////////


//////////////DON'T TOUCH ANYTHING BELOW THIS LINE!!!///////////////


////////////////////////////////////////////////////////////////////////////////
///Prototypes Defined:
////////////////////////////////////////////////////////////////////////////////

const string cMsg = "Your character was scanned and found legal, thank you.";

//////////////////////////////////////////

int HasDevestatingCritical(object oPC)
 {
    int i = 495;
    int nHas = FALSE;
    //495-532  Are constants for devestating criticals
    while(i <= 532)
    {
          if(GetHasFeat(i, oPC))
          {
             //If the PC has one of the Devastating Critical feats...
             nHas = TRUE;
          }
          i++;
    }

    //Dev crit on Dwarven Waraxe.  (Seperate Check Required)
    if(GetHasFeat(955, oPC))
    {
        //If they have this Devastating Critical feat...
        nHas = TRUE;
    }

    return nHas;
 }

////////////////////////////////////////////////////

void BannPC(object oTarget)
{
string pBad;
pBad = " ";
pBad += GetName(oTarget);
pBad += "w/ Player ID: ";
pBad += GetPCPlayerName(oTarget);
pBad += "/";
pBad += GetPCIPAddress(oTarget);
pBad += "/";
pBad += GetPCPublicCDKey(oTarget);
pBad += "  ";
pBad += "Might be playing an illegal character";

string sMzg;
sMzg = "You are playing an illegal character!";
sMzg += "Return with a legal character or you will be banned!!";

CreateItemOnObject("banned", oTarget);
SendMessageToPC(oTarget, sMzg);
SendMessageToAllDMs(pBad);
PrintString(pBad);
DelayCommand(5.0, BootPC(oTarget));
}

//////////////////////////////////////////////

void DoLowLevelCheck(object oPC)
{
 if(GetHitDice(oPC)<21)
 {
  if(GetHasFeat(FEAT_EPIC_ARMOR_SKIN, oPC)){BannPC(oPC);PrintString("1");}
  if(GetHasFeat(FEAT_EPIC_AUTOMATIC_QUICKEN_1, oPC)){BannPC(oPC);PrintString("2");}
  if(GetHasFeat(FEAT_EPIC_AUTOMATIC_QUICKEN_2, oPC)){BannPC(oPC);PrintString("3");}
  if(GetHasFeat(FEAT_EPIC_AUTOMATIC_QUICKEN_3, oPC)){BannPC(oPC);PrintString("4");}
  if(GetHasFeat(FEAT_EPIC_AUTOMATIC_STILL_SPELL_3, oPC)){BannPC(oPC);PrintString("5");}
  if(GetHasFeat(FEAT_EPIC_DAMAGE_REDUCTION_3, oPC)){BannPC(oPC);PrintString("6");}
  if(GetHasFeat(FEAT_EPIC_DAMAGE_REDUCTION_6, oPC)){BannPC(oPC);PrintString("7");}
  if(GetHasFeat(FEAT_EPIC_DAMAGE_REDUCTION_9, oPC)){BannPC(oPC);PrintString("8");}
  if(GetHasFeat(FEAT_EPIC_DODGE, oPC)){BannPC(oPC);PrintString("9");}
  if(GetHasFeat(FEAT_EPIC_ENERGY_RESISTANCE_ACID_1, oPC)){BannPC(oPC);PrintString("10");}
  if(GetHasFeat(FEAT_EPIC_ENERGY_RESISTANCE_ACID_10, oPC)){BannPC(oPC);PrintString("11");}
  if(GetHasFeat(FEAT_EPIC_ENERGY_RESISTANCE_ACID_2, oPC)){BannPC(oPC);PrintString("12");}
  if(GetHasFeat(FEAT_EPIC_ENERGY_RESISTANCE_ACID_9, oPC)){BannPC(oPC);PrintString("13");}
  if(GetHasFeat(FEAT_EPIC_ENERGY_RESISTANCE_COLD_1, oPC)){BannPC(oPC);PrintString("14");}
  if(GetHasFeat(FEAT_EPIC_ENERGY_RESISTANCE_COLD_10, oPC)){BannPC(oPC);PrintString("15");}
  if(GetHasFeat(FEAT_EPIC_ENERGY_RESISTANCE_COLD_2, oPC)){BannPC(oPC);PrintString("16");}
  if(GetHasFeat(FEAT_EPIC_ENERGY_RESISTANCE_COLD_4, oPC)){BannPC(oPC);PrintString("17");}
  if(GetHasFeat(FEAT_EPIC_ENERGY_RESISTANCE_COLD_5, oPC)){BannPC(oPC);PrintString("18");}
  if(GetHasFeat(FEAT_EPIC_FORTITUDE, oPC)){BannPC(oPC);PrintString("19");}
  if(GetHasFeat(FEAT_EPIC_GREAT_SMITING_10, oPC)){BannPC(oPC);PrintString("20");}
  if(GetHasFeat(FEAT_EPIC_GREAT_SMITING_9, oPC)){BannPC(oPC);PrintString("21");}
  if(GetHasFeat(FEAT_EPIC_IMPROVED_COMBAT_CASTING, oPC)){BannPC(oPC);PrintString("22");}
  if(GetHasFeat(FEAT_EPIC_IMPROVED_KI_STRIKE_5, oPC)){BannPC(oPC);PrintString("23");}
  if(GetHasFeat(FEAT_EPIC_IMPROVED_SNEAK_ATTACK_10, oPC)){BannPC(oPC);PrintString("24");}
  if(GetHasFeat(FEAT_EPIC_IMPROVED_SPELL_RESISTANCE_10, oPC)){BannPC(oPC);PrintString("25");}
  if(GetHasFeat(FEAT_EPIC_IMPROVED_STUNNING_FIST_10, oPC)){BannPC(oPC);PrintString("26");}
  if(GetHasFeat(FEAT_EPIC_PROWESS, oPC)){BannPC(oPC);PrintString("27");}
  if(GetHasFeat(FEAT_EPIC_SELF_CONCEALMENT_50, oPC)){BannPC(oPC);PrintString("28");}
  if(GetHasFeat(FEAT_EPIC_SPELL_FOCUS_EVOCATION, oPC)){BannPC(oPC);PrintString("29");}
  if(GetHasFeat(FEAT_EPIC_SPELL_PENETRATION, oPC)){BannPC(oPC);PrintString("30");}
  if(GetHasFeat(FEAT_EPIC_WEAPON_SPECIALIZATION_SCIMITAR, oPC)){BannPC(oPC);PrintString("31");}
  if(GetHasFeat(FEAT_EPIC_WEAPON_SPECIALIZATION_RAPIER, oPC)){BannPC(oPC);PrintString("32");}
  if(GetHasFeat(FEAT_EPIC_OVERWHELMING_CRITICAL_RAPIER, oPC)){BannPC(oPC);PrintString("33");}
  if(GetHasFeat(FEAT_EPIC_OVERWHELMING_CRITICAL_SCIMITAR, oPC)){BannPC(oPC);PrintString("34");}
  if(GetHasFeat(FEAT_EPIC_OVERWHELMING_CRITICAL_KAMA, oPC)){BannPC(oPC);PrintString("35");}
  if(GetHasFeat(FEAT_EPIC_OVERWHELMING_CRITICAL_LONGBOW, oPC)){BannPC(oPC);PrintString("36");}
  if(GetHasFeat(FEAT_EPIC_OVERWHELMING_CRITICAL_LONGSWORD, oPC)){BannPC(oPC);PrintString("37");}
 }
}

///////////////////////////////////////////

void PunishPC(object oPC)
{
//If the above int Punishment A is set to 1 they lose all items.
 if(PunishmentA == 1)
  {
   object oItem;
   oItem = GetFirstItemInInventory(oPC);

   while (GetIsObjectValid(oItem))
   {
   if (GetPlotFlag(oItem))
      SetPlotFlag(oItem, FALSE);

   DestroyObject(oItem);

   oItem = GetNextItemInInventory(oPC);
   }

   int nInt;
   for (nInt=0; nInt<NUM_INVENTORY_SLOTS; nInt++)
   {
   oItem = GetItemInSlot(nInt, oPC);

   if (GetPlotFlag(oItem))
         SetPlotFlag(oItem, FALSE);

   DestroyObject(oItem);
   }

  TakeGoldFromCreature(GetGold(oPC), oPC, TRUE);
 }

//if the above int PunishmentB is set to 1 teleport the PC to the waypoint "prison"
 if(PunishmentB == 1)
  {
  object bTarget;
  location lTarget;

  //Create a waypoint in the module and give it the tagname "prison"
  //This waypoint may be place anywhere you deem appropriate (muahahah!)
  bTarget = GetWaypointByTag("prison");

  lTarget = GetLocation(bTarget);

  if (GetAreaFromLocation(lTarget)!=OBJECT_INVALID)
  {
  AssignCommand(oPC, ClearAllActions());

  AssignCommand(oPC, ActionJumpToLocation(lTarget));
  }
 //End PunishmentB Check
 }

 //if the above int PunishmentC is set to 1, the PC is releveled till
 //they lose the above feats not allowed on the server.(if set to 1)
 if(PunishmentC == 1)
 {

 int cXP = GetXP(oPC);
 SetLocalInt(oPC, "exactxp", cXP);

 //If Devastating Critical is not allowed delevel the PC till it's gone!!
 //Then set thier XP back to where it was (only if they originally had the feat!)
  if(DissallowDevastatingCritical == 1)
  {
   if(HasDevestatingCritical(oPC))
   {
    int i = FALSE;
    //Delevel them till they don't have Devestating Critical
    while(i == FALSE)
    {
     if(HasDevestatingCritical(oPC))
     {
     Take1Level(oPC);
     i = FALSE;
     }
     else
     {
     i = TRUE;
     //Stop the loop here.
     }

    }
   //Then give them back thier levels
   cXP = GetLocalInt(oPC, "exactxp");
   SetXP(oPC, cXP);
   DelayCommand(1.0, SendMessageToPC(oPC, "Devestating Critical Is Not Allowed!!"));
   DelayCommand(2.0, SendMessageToPC(oPC, "Relevel your character."));
   }
  //end dev crit check
  }

 //If Epic Dodge is not allowed delevel the PC till it's gone!!
 //Then set thier XP back to where it was (only if they originally had the feat!)
 if(DissallowEpicDodge == 1)
 {
    if(GetHasFeat(FEAT_EPIC_DODGE, oPC))
    {
     int d = FALSE;
     while(d == FALSE)
      if(GetHasFeat(FEAT_EPIC_DODGE, oPC))
      {
       Take1Level(oPC);
       d = FALSE; //Continue the loop.
      }
     else
      {
      d = TRUE;
      //Otherwise stop the loop if they don't have Epic Dodge Anymore
      }

    //Give them back the XP they had before the delevel started.
    //If they never lost XP then they don't get any :)
    cXP = GetLocalInt(oPC, "exactxp");
    SetXP(oPC, cXP);
    DelayCommand(1.0, SendMessageToPC(oPC, "Epic Dodge Is Not Allowed!!"));
    DelayCommand(2.0, SendMessageToPC(oPC, "Relevel your character."));
   }

 //end epic dodge check
 }

  //If Hide In Plain Sight is not allowed delevel the PC till it's gone!!
  //Then set thier XP back to where it was (only if they originally had the feat!)
  if(DissallowHideInPlainSight == 1)
  {
   if(GetHasFeat(FEAT_HIDE_IN_PLAIN_SIGHT, oPC))
   {
    int e = FALSE;
     while(e == FALSE)
      if(GetHasFeat(FEAT_HIDE_IN_PLAIN_SIGHT, oPC))
       {
       Take1Level(oPC);
       e = FALSE; //Continue the loop!
       }
       else
       {
       e = TRUE; //If they don't have the feat stop the loop!
       }
    //Set the PC's XP back to where it was before they were deleveled.
    cXP = GetLocalInt(oPC, "exactxp");
    SetXP(oPC, cXP);
    DelayCommand(1.0, SendMessageToPC(oPC, "Hide In Plain Sight Is Not Allowed!!"));
    DelayCommand(2.0, SendMessageToPC(oPC, "Relevel your character."));
   }
 //end hips check
 }

//end PunushinmentC check
}


 if(PunishmentD == 1)
 {
 BannPC(oPC);//Get rid of this character forever!
 }

 if(PunishmentE == 1)
 {
 SetXP(oPC, 0);//Take all of thier levels permanently!
 }

//End Punishment Function
}

///////////////////////////The End WOOSH!!////////////////////////////////////////