//Created by Guile 4/1/08

//////////////////////////I-M-P-O-R-T-A-N-T////////////////////////////
//Open the script "cheat_config" to configure important options
//The options whether or not to allow PCs to have certain feats
//--------------------------------------------------------------------//
//The include below is required to run this script, do not remove!
                                                 #include "cheat_config"
///////////////////////////////////////////////////////////////////////

//This script scans the PC entering an area or tracks trigger to see if
//they are playing a legal character, it checks many instances.


void main()
{
object oTarget;
object oPC;
oPC = GetExitingObject();
oTarget = oPC;

if(!GetIsPC(oPC)) return; //Stop the script here if not a PC!

//Major Variables Defined
int eAC = GetAC(oPC);
int nLvl = GetHitDice(oPC);
int dLvl = nLvl/2;


//This returns thier base ability score with no bonuses added in
int sAby = GetAbilityScore(oTarget, ABILITY_STRENGTH, TRUE);
int dAby = GetAbilityScore(oTarget, ABILITY_DEXTERITY, TRUE);
int cAby = GetAbilityScore(oTarget, ABILITY_CONSTITUTION, TRUE);
int iAby = GetAbilityScore(oTarget, ABILITY_INTELLIGENCE, TRUE);
int wAby = GetAbilityScore(oTarget, ABILITY_WISDOM, TRUE);
int pAby = GetAbilityScore(oTarget, ABILITY_CHARISMA, TRUE);


int sMax = dLvl + 26;
int dMax = dLvl + 20;
int cMax = dLvl + 22;
int iMax = dLvl + 22;
int wMax = dLvl + 20;
int pMax = dLvl + 22;

/////////Check for Feats/////////
//If the PC is a bonafied PC lets begin the check

//Lets make sure the PC isn't a DM or a DM possessed Monster etc.
if(!GetIsDM(oPC))
{
if(!GetIsDMPossessed(oPC))
{

//////////////////Check if PC Character Is Legal////////////////////
//These are module switches to dissallow certain feats
//Please open cheat_config to set these switchs!!!
//These switches verify settings in the cheat_config script
if(DissallowDevastatingCritical == 1)
{
if(HasDevestatingCritical(oPC)){PunishPC(oPC);}
}

if(DissallowEpicDodge == 1)
{
if(GetHasFeat(FEAT_EPIC_DODGE, oPC))
{PunishPC(oPC);}
}

if(DissallowHideInPlainSight == 1)
{
if(GetHasFeat(FEAT_EPIC_DODGE, oPC))
{PunishPC(oPC);}
}

//Epic Damage Reduction Check
if(GetHasFeat(FEAT_EPIC_DAMAGE_REDUCTION_3, oPC))
{if(cAby<=20) {BannPC(oTarget);PrintString("EDR");}}
if(GetHasFeat(FEAT_EPIC_DAMAGE_REDUCTION_6, oPC))
{if(cAby<=20) {BannPC(oTarget);PrintString("EDR");}}
if(GetHasFeat(FEAT_EPIC_DAMAGE_REDUCTION_9, oPC))
{if(cAby<=20) {BannPC(oTarget);PrintString("EDR");}}

if(GetHasFeat(FEAT_EPIC_DAMAGE_REDUCTION_3, oPC))
{if(nLvl<=20) {BannPC(oTarget);PrintString("EDR");}}
if(GetHasFeat(FEAT_EPIC_DAMAGE_REDUCTION_6, oPC))
{if(nLvl<=20) {BannPC(oTarget);PrintString("EDR");}}
if(GetHasFeat(FEAT_EPIC_DAMAGE_REDUCTION_9, oPC))
{if(nLvl<=20) {BannPC(oTarget);PrintString("EDR");}}

if(GetHitDice(oPC)<21)
{
DoLowLevelCheck(oPC);

//If They have Greater than 84 AC at level 2-20
if(GetAC(oPC)>84) {BannPC(oPC);}

//If less than level 21 & Has Devastating Critical
if(HasDevestatingCritical(oPC)) {BannPC(oPC);}

//If They have greater than 23 AC at level 3 or less
if(nLvl<=3){if(eAC>67) {BannPC(oPC);}}  //(Max AC with +6 gear as a monk!)

if(nLvl<=5)
{
//& Has more than 25 Strength (No Bonuses Considered)
if(sAby>25) {BannPC(oTarget); PrintString("<6");}

//& Has more than 24 Dexterity (No Bonuses Considered)
if(dAby>24) {BannPC(oTarget); PrintString("<6");}

//& Has more than 24 Constitution (No Bonuses Considered)
if (cAby>24){BannPC(oTarget); PrintString("<6");}

//& Has more than 24 Intelligence (No Bonuses Considered)
if(iAby>24) {BannPC(oTarget); PrintString("<6");}

//& Has more than 24 Wisdom (No Bonuses Considered)
if(wAby>24) {BannPC(oTarget); PrintString("<6");}

//& Has more than 24 Charisma (No Bonuses Considered)
if(pAby>24) {BannPC(oTarget); PrintString("<6");}
}
}

//If Has 24 or less Strength & Has Devastating Critical
if(HasDevestatingCritical(oPC))
{if(sAby <=24) {BannPC(oTarget);PrintString("if dev");}}

//If Has Epic Dodge & Less than level 24 Dexterity
if(GetHasFeat(FEAT_EPIC_DODGE, oPC))
{if(dAby<=24) {BannPC(oTarget);PrintString("ED1");}}

//If Has Epic Dodge and Less than 30 Base Skill Ranks
if(GetHasFeat(FEAT_EPIC_DODGE, oPC))
{if(GetSkillRank(SKILL_TUMBLE, oPC, TRUE)<=29)
{BannPC(oTarget);PrintString("ED2");}}

//If Strength is Greater than the maximum allowed at thier level
if(sAby>sMax) {BannPC(oTarget);PrintString("STR");}

//If Dexterity is Greater than the maximum allowed at thier level
if(dAby>dMax) {BannPC(oTarget);PrintString("DEX");}

//If Constitution is Greater than the maximum allowed at thier level
if(cAby>cMax) {BannPC(oTarget);PrintString("CON");}

//If Intelligence is Greater than the maximum allowed at thier level
if(iAby>iMax) {BannPC(oTarget);PrintString("INT");}

//If Wisdom is Greater than the maximum allowed at thier level
if(wAby>wMax) {BannPC(oTarget);PrintString("WIS");}

//If Charisma is Greater than the maximum allowed at thier level
if(pAby>pMax){BannPC(oTarget);PrintString("CHA");}

//Lets check multiple ability scores here to see if they are cheating.
if(sAby>=34 & dAby >=34) {BannPC(oTarget);PrintString("F");} //Check Fighters
if(iAby>=34 & cAby >=34) {BannPC(oTarget);PrintString("W");} //Check Wizards
if(wAby>=34 & cAby >=34) {BannPC(oTarget);PrintString("C");} //Check Clerics
if(cAby>=34 & cAby >=34) {BannPC(oTarget);PrintString("S");} //Check Sorcerers

//If they have greater than 105 AC at level 21-40
if (nLvl>20 & eAC>105) {BannPC(oTarget);PrintString("EAC");}

//Otherwise let them know they passed the test (Discourages Cheating)
else {SendMessageToPC(oTarget, cMsg);}
}
}
//The end woosh!
}