//#include "nw_i0_tool"
//#include "jhr_i0_skillchek"

int DC_EASY = 0;
int DC_MEDIUM = 1;
int DC_HARD = 2;
int AutoDC(int DC, int nSkill, object oTarget)
{
    /*
    Easy = Lvl/4 ...rounded up
    Moderate = 3/Lvl + Lvl ...rounded up
    Difficult = Lvl * 1.5 + 6 ...rounded up
    */
    int nLevel = GetHitDice(oTarget);
    int nTest = 0;
    switch (DC)
    {
    case 0: nTest = nLevel / 4 + 1; break;
        // * minor tweak to lower the values a little
    case 1: nTest = (3 / nLevel + nLevel) - abs( (nLevel/2) -2); break;
    case 2: nTest = FloatToInt(nLevel * 1.5 + 6) - abs( ( FloatToInt(nLevel/1.5) -2));   break;
    }
    if (GetSkillRank(nSkill, oTarget) >= nTest)
    {
       return TRUE;
    }
       return FALSE;
}
int SkillCheck(int DC, int nSkill, object oTarget, int bUntrainedAllowed=TRUE)
{
    int nRank = GetSkillRank(nSkill, oTarget);
    //SendMessageToPC(GetFirstPC(), "Rank=" + IntToString(nRank));
    // Exit if oTarget doesn't have this skill
    //if (nRank = -1)
    //    return FALSE;
    // Exit if untrained and bUntrainedAllowed == FALSE
    //if ((bUntrainedAllowed == FALSE) &&  (nRank == 0))
    //    return FALSE;
    // Roll!
    //int nRoll = d20();
    //SendMessageToPC(GetFirstPC(), "Roll=" + IntToString(nRoll));
    if (d20() + nRank >= DC)
        return TRUE;

    return FALSE;
}
void main()
{
    object oPC = GetEnteringObject();
    if (GetIsPC(oPC) && (GetIsInCombat(oPC) == FALSE) && (GetLocalInt(GetObjectByTag("ot_BoulderWithSecret"), "nStateDiscovered") == 0))
    {
        if(SkillCheck(14, SKILL_SPOT, oPC))
        {
            SendMessageToPC(oPC, "You notice a small, dark opening behind the boulder to the west.");
            SendMessageToAllDMs(GetName(oPC) + " hears: You notice a small, dark opening behind the boulder to the west.");
        }
    }
}
