Author Sticky: Post Working Scripts Here
Desslok81 Posted: Monday, 08 July 08:17PM
3rd Edition Ability and Skill Check Functions

Name: jg_i001
Name means: Jeff Gonzalez include file 001

Purpose: This script follows the 3rd Edition rules to doing difficulty class skill and ability check(DC Check). It take in to consideration your ability modifier, your training(ranks) and your class when using skills. Also it allows for Atuo success (roll of 20) and auto failure (roll of 1). Parameter to call allow you to override wether or not a skill has to be train.

Returns: TRUE or FALSE

Special Instructions: This is an Include file. once you have put this script into your mod you use it by first putting a #include "jg_i001". Also debug code left in and can be turned on and off thru parameters

NWScript:
//Used to Print Debug info
void PrintDebug001(object oObject, string sDebugMsg);
// DCAbilityCheck - Difficulty Class Ability Check
// This is use to do a DC check against the PC,NPC or Monster Abilities
//======================================================================
// Parameters
// oCreature - Object of the Creature(PC,NPC or Monster) you want to test
// iTheAbility are ability constants defined as followed:
//   Strength      = ABILITY_STRENGTH
//   Dexterity     = ABILITY_DEXTERITY
//   Constitiution = ABILITY_CONSTITUTION
//   Intelligence  = ABILITY_INTELLIGENCE
//   Wisdom        = ABILITY_WISDOM
//   Charisma      = ABILITY_CHARISMA
// iDCFactor - Difficulty Class or How hard you want the task to be
//   Example 0 - SImple, 5 - Easy, 10 - Average, 15 - Hard,
//           20 - Difficult
// debug_me - Set to true to have oCreature shout debug messages
//======================================================================
// **Note a D20 Roll of a 1 always fails and a d20 roll of a 20 always
//   succeeds. This Function does not have a take 10 or take 20 feature
int DCAbilityCheck(object oCreature, int iTheAbility, int iDCFactor=10, int debug_me = FALSE);
// DCSkillCheck - Difficulty Class Skill Check
// This is use to do a DC check against the PC,NPC or Monster Skill
//======================================================================
// Parameters
// oCreature - Object of the Creature(PC,NPC or Monster) you want to test
// iTheSkill are skill constants defined as followed:
//    SKILL_ANIMAL_EMPATHY     SKILL_CONCENTRATION
//    SKILL_DISABLE_TRAP       SKILL_DISCIPLINE
//    SKILL_HEAL               SKILL_HIDE
//    SKILL_LISTEN             SKILL_LORE
//    SKILL_MOVE_SILENTLY      SKILL_OPEN_LOCK
//    SKILL_PARRY              SKILL_PERFORM
//    SKILL_PERSUADE           SKILL_PICK_POCKET
//    SKILL_SEARCH             SKILL_SET_TRAP
//    SKILL_SPELLCRAFT         SKILL_SPOT
//    SKILL_TAUNT              SKILL_USE_MAGIC_DEVICE
// iDCFactor - Difficulty Class or How hard you want the task to be
//   Example 0 - SImple, 5 - Easy, 10 - Average, 15 - Hard,
//           20 - Difficult
// bCheckUse - Check to see if skill is usable. If set to FALSE the
//             function will not check to see if oCreature can use
//             the skill. If set to TRUE the function will check to
//             see if oCreature can use the skill. This is based on
//             whether or not the Skill can be used untrained and/or
//             the skill requires a specific class like BARD with
//             the skill perform. (based on D&D 3rd Edition rules)
// debug_me - Set to true to have oCreature shout debug messages
//======================================================================
// **Note a D20 Roll of a 1 always fails and a d20 roll of a 20 always
//   succeeds. This Function does not have a take 10 or take 20 feature
int DCSkillCheck(object oCreature, int iTheSkill, int iDCFactor=10, int bCheckUse=TRUE, int debug_me = FALSE);
// Checks the Ability for a DC Roll in occurdance to D&D 3rd Edtion
// Rule
int DCAbilityCheck(object oCreature, int iTheAbility, int iDCFactor=10, int debug_me = FALSE)
{
  int iAbilityMod;
  int iDCRoll;
  int iModRoll;
  // Get Ability modifier for
  iAbilityMod = GetAbilityModifier(iTheAbility,oCreature);
  // Roll the dice
  iDCRoll = d20(1);
  iModRoll = iDCRoll + iAbilityMod;
// debug code
  if (debug_me == TRUE)
  {
    PrintDebug001( oCreature, "My Modifier is " + IntToString(iAbilityMod));
    PrintDebug001( oCreature, "My Roll is " + IntToString(iDCRoll));
    PrintDebug001( oCreature, "My Modified Roll is " + IntToString(iModRoll));
  }
  // The Modified roll must be greater then or equal to the
  // Difficulty Check Factor or Value
  // and the d20 roll cannot be 1 (1 is automatic failure
  // or if the d20 roll is 20 that is an automatic sucess
  if((iModRoll >= iDCFactor && iDCRoll > 1) || iDCRoll==20)
  {
    return TRUE;
  }
  else
  {
    return FALSE;
  }
}
// Checks the Ability for a DC Roll in occurdance to D&D 3rd Edtion
// Rule
int DCSkillCheck(object oCreature, int iTheSkill, int iDCFactor=10, int bCheckUse=TRUE, int debug_me = FALSE)
{
  int iTheAbility, iAbilityMod;
  int iSkillRank, bAbleToUse;
  int iCreatureClass;
  int cIdx, iDCRoll, iModRoll;
  // Get Skill Rank
  iSkillRank = GetSkillRank(iTheSkill,oCreature);
  //Set iSkillRank to 0 if we are not checking if oCreature can use Skill
  if (iSkillRank == -1 && !bCheckUse)
  {
   iSkillRank = 0;
  }
  bAbleToUse=FALSE;
  switch(iTheSkill)
  {
    case SKILL_ANIMAL_EMPATHY:
     iTheAbility = ABILITY_CHARISMA;
     for(cIdx=1;cIdx < 4; cIdx++)
     {
       iCreatureClass =  GetClassByPosition(1,oCreature);
       if (iSkillRank > 0
       && (iCreatureClass == CLASS_TYPE_DRUID
       || iCreatureClass == CLASS_TYPE_RANGER))
       {
         bAbleToUse = TRUE;
         break;
       }
     }
     break;
    case SKILL_CONCENTRATION:
     iTheAbility = ABILITY_CONSTITUTION;
     bAbleToUse = TRUE;
     break;
    case SKILL_DISABLE_TRAP:
     iTheAbility = ABILITY_INTELLIGENCE;
     for(cIdx=1;cIdx < 4; cIdx++)
     {
       iCreatureClass =  GetClassByPosition(1,oCreature);
       if (iSkillRank > 0)
       {
         bAbleToUse = TRUE;
         break;
       }
     }
     break;
    case SKILL_DISCIPLINE:
     iTheAbility = ABILITY_STRENGTH;
     bAbleToUse = TRUE;
     break;
    case SKILL_HEAL:
     iTheAbility = ABILITY_WISDOM;
     bAbleToUse = TRUE;
     break;
    case SKILL_HIDE:
     iTheAbility = ABILITY_DEXTERITY;
     bAbleToUse = TRUE;
     break;
    case SKILL_LISTEN:
     iTheAbility = ABILITY_WISDOM;
     bAbleToUse = TRUE;
     break;
    case SKILL_LORE:
     iTheAbility = ABILITY_INTELLIGENCE;
     bAbleToUse = TRUE;
     break;
    case SKILL_MOVE_SILENTLY:
     iTheAbility = ABILITY_DEXTERITY;
     bAbleToUse = TRUE;
     break;
    case SKILL_OPEN_LOCK:
     iTheAbility = ABILITY_DEXTERITY;
     for(cIdx=1;cIdx < 4; cIdx++)
     {
       iCreatureClass =  GetClassByPosition(1,oCreature);
       if (iSkillRank > 0)
       {
         bAbleToUse = TRUE;
         break;
       }
     }
     break;
    case SKILL_PARRY:
     iTheAbility = ABILITY_DEXTERITY;
     bAbleToUse = TRUE;
     break;
    case SKILL_PERFORM:ABILITY_CHARISMA;
     iTheAbility = ABILITY_CHARISMA;
     for(cIdx=1;cIdx < 4; cIdx++)
     {
       iCreatureClass =  GetClassByPosition(1,oCreature);
       if (iCreatureClass == CLASS_TYPE_BARD)
       {
         bAbleToUse = TRUE;
         break;
       }
     }
     break;
    case SKILL_PERSUADE:
     iTheAbility = ABILITY_CHARISMA;
     bAbleToUse = TRUE;
     break;
    case SKILL_PICK_POCKET:
     iTheAbility = ABILITY_DEXTERITY;
     for(cIdx=1;cIdx < 4; cIdx++)
     {
       iCreatureClass =  GetClassByPosition(1,oCreature);
       if (iSkillRank > 0)
       {
         bAbleToUse = TRUE;
         break;
       }
     }
     break;
    case SKILL_SEARCH:
     iTheAbility = ABILITY_INTELLIGENCE;
     bAbleToUse = TRUE;
     break;
    case SKILL_SET_TRAP:
     iTheAbility = ABILITY_DEXTERITY;
     for(cIdx=1;cIdx < 4; cIdx++)
     {
       iCreatureClass =  GetClassByPosition(1,oCreature);
       if (iSkillRank > 0)
       {
         bAbleToUse = TRUE;
         break;
       }
     }
     break;
    case SKILL_SPELLCRAFT:
     iTheAbility = ABILITY_INTELLIGENCE;
     for(cIdx=1;cIdx < 4; cIdx++)
     {
       iCreatureClass =  GetClassByPosition(1,oCreature);
       if (iSkillRank > 0)
       {
         bAbleToUse = TRUE;
         break;
       }
     }
     break;
    case SKILL_SPOT:
     iTheAbility = ABILITY_WISDOM;
     bAbleToUse = TRUE;
     break;
    case SKILL_TAUNT:
     iTheAbility = ABILITY_CHARISMA;
     bAbleToUse = TRUE;
     break;
    case SKILL_USE_MAGIC_DEVICE:
     iTheAbility = ABILITY_CHARISMA;
     for(cIdx=1;cIdx < 4; cIdx++)
     {
       iCreatureClass =  GetClassByPosition(1,oCreature);
       if (iSkillRank > 0
       && (iCreatureClass == CLASS_TYPE_BARD
       || iCreatureClass == CLASS_TYPE_ROGUE))
       {
         bAbleToUse = TRUE;
         break;
       }
     }
     break;
  }
  // Get Ability modifier for that Skill
  iAbilityMod = GetAbilityModifier(iTheAbility,oCreature);
// debug code
  if (debug_me == TRUE)
  {
    PrintDebug001( oCreature, "Function bCheckUse = " + IntToString(bCheckUse));
    PrintDebug001( oCreature, "bAbleToUse " + IntToString(bAbleToUse));
  }

  // Roll the dice
  if(!bCheckUse
  || (bCheckUse && bAbleToUse))
  {
    iDCRoll = d20(1);
    iModRoll = iDCRoll + iAbilityMod + iSkillRank;
  }
  else
  {
    iDCRoll = 1;
    iModRoll = -1;
  }
// debug code
  if (debug_me == TRUE)
  {
    PrintDebug001( oCreature, "My Modifier is " + IntToString(iAbilityMod));
    PrintDebug001( oCreature, "My Rank is " + IntToString(iSkillRank));
    PrintDebug001( oCreature, "My Roll is " + IntToString(iDCRoll));
    PrintDebug001( oCreature, "My Modified Roll is " + IntToString(iModRoll));
  }
  // The Modified roll must be greater then or equal to the
  // Difficulty Check Factor or Value
  // and the d20 roll cannot be 1 (1 is automatic failure
  // or if the d20 roll is 20 that is an automatic sucess
  if((iModRoll >= iDCFactor && iDCRoll > 1) || iDCRoll==20)
  {
    return TRUE;
  }
  else
  {
    return FALSE;
  }
}

//=============================
void PrintDebug001(object oObject, string sDebugMsg)
{
  AssignCommand(oObject,SpeakString(sDebugMsg,TALKVOLUME_SHOUT));
}



Example on how to use it

NWScript:
#include "jg_i001"
void main()
{
//  DC check on SEARCH skill
    int iDCCheck = DCSkillCheck(oPC, SKILL_SEARCH, 15);
    if(iDCCheck)
    {
     //success code goes here
    }
    else
    {
     //success code goes here
    }
//  DC check on Strength Ability
    int iDCCheck = DCSkillCheck(oPC, ABILITY_STRENGTH, 15);
    if(iDCCheck)
    {
     //success code goes here
    }
    else
    {
     //success code goes here
    }
}



The Fool on

Author Sticky: Post Working Scripts Here
Desslok81 Posted: Tuesday, 09 July 12:08AM
Quote: Posted 07/08/02 21:55:59 (GMT) by Repod

Quote: Posted 07/08/02 20:17:29 (GMT) by Desslok81


Name: jg_i001
Name means: Jeff Gonzalez include file 001

Purpose: This script follows the 3rd Edition rules to doing difficulty class skill and ability check(DC Check). It take in to consideration your ability modifier, your training(ranks) and your class when using skills. The Fool on the Hill
Desslok81

[ Edited By Desslok81: Monday, 08 July 08:44PM (GMT) ]


Do you really need to get the Rank, Ability modifier, Class modifier and Race modifier (you forgot that one)?

I thought the total that is recorded for the character/NPC/monster is the total result of ranks, class, ability, race. Also this number can be negative or 0 and still be usable (IE climb, spot, listen). You don't have to be trained in some of the skills to user them either, but you seem to have covered that in your code. A negative skill just means it's harder to use that skill (some creatures/pc's/npcs have all the dumb luck...)

Nice Idea though I hope you don't mind If I um plagerize I mean borrow some of what you've done :shades



-Repod


Yeah I see it now. didn't see it at 3 am this morning but you know us programmers. Went in and checked it again and your right the SkilRank is all your mods together. As for Race is Calculated already into your stats and with Stats modifier already Calulate in the Rank. Just need to modify it a bit. But the Ability DC check is good. NWN returns a -1 if you are untrained in that skill. These are change to 0 since according to D&D rule book a trained skill is on with at least 1 Rank. But that can easily be modified to your taste. Thanks for pointing this out. Now how do I get the new code up to that post. BTW take all the code you want.

3rd Edition Ability and Skill Check Functions
Fixed from a reported Bug

I only change 2 lines and deleted 1 debug line

NWScript:
//Used to Print Debug info
void PrintDebug001(object oObject, string sDebugMsg);
// DCAbilityCheck - Difficulty Class Ability Check
// This is use to do a DC check against the PC,NPC or Monster Abilities
//======================================================================
// Parameters
// oCreature - Object of the Creature(PC,NPC or Monster) you want to test
// iTheAbility are ability constants defined as followed:
//   Strength      = ABILITY_STRENGTH
//   Dexterity     = ABILITY_DEXTERITY
//   Constitiution = ABILITY_CONSTITUTION
//   Intelligence  = ABILITY_INTELLIGENCE
//   Wisdom        = ABILITY_WISDOM
//   Charisma      = ABILITY_CHARISMA
// iDCFactor - Difficulty Class or How hard you want the task to be
//   Example 0 - SImple, 5 - Easy, 10 - Average, 15 - Hard,
//           20 - Difficult
// debug_me - Set to true to have oCreature shout debug messages
//======================================================================
// **Note a D20 Roll of a 1 always fails and a d20 roll of a 20 always
//   succeeds. This Function does not have a take 10 or take 20 feature
int DCAbilityCheck(object oCreature, int iTheAbility, int iDCFactor=10, int debug_me = FALSE);
// DCSkillCheck - Difficulty Class Skill Check
// This is use to do a DC check against the PC,NPC or Monster Skill
//======================================================================
// Parameters
// oCreature - Object of the Creature(PC,NPC or Monster) you want to test
// iTheSkill are skill constants defined as followed:
//    SKILL_ANIMAL_EMPATHY     SKILL_CONCENTRATION
//    SKILL_DISABLE_TRAP       SKILL_DISCIPLINE
//    SKILL_HEAL               SKILL_HIDE
//    SKILL_LISTEN             SKILL_LORE
//    SKILL_MOVE_SILENTLY      SKILL_OPEN_LOCK
//    SKILL_PARRY              SKILL_PERFORM
//    SKILL_PERSUADE           SKILL_PICK_POCKET
//    SKILL_SEARCH             SKILL_SET_TRAP
//    SKILL_SPELLCRAFT         SKILL_SPOT
//    SKILL_TAUNT              SKILL_USE_MAGIC_DEVICE
// iDCFactor - Difficulty Class or How hard you want the task to be
//   Example 0 - SImple, 5 - Easy, 10 - Average, 15 - Hard,
//           20 - Difficult
// bCheckUse - Check to see if skill is usable. If set to FALSE the
//             function will not check to see if oCreature can use
//             the skill. If set to TRUE the function will check to
//             see if oCreature can use the skill. This is based on
//             whether or not the Skill can be used untrained and/or
//             the skill requires a specific class like BARD with
//             the skill perform. (based on D&D 3rd Edition rules)
// debug_me - Set to true to have oCreature shout debug messages
//======================================================================
// **Note a D20 Roll of a 1 always fails and a d20 roll of a 20 always
//   succeeds. This Function does not have a take 10 or take 20 feature
int DCSkillCheck(object oCreature, int iTheSkill, int iDCFactor=10, int bCheckUse=TRUE, int debug_me = FALSE);
// Checks the Ability for a DC Roll in occurdance to D&D 3rd Edtion
// Rule
int DCAbilityCheck(object oCreature, int iTheAbility, int iDCFactor=10, int debug_me = FALSE)
{
  int iAbilityMod;
  int iDCRoll;
  int iModRoll;
  // Get Ability modifier for
  iAbilityMod = GetAbilityModifier(iTheAbility,oCreature);
  // Roll the dice
  iDCRoll = d20(1);
  iModRoll = iDCRoll + iAbilityMod;
// debug code
  if (debug_me == TRUE)
  {
    PrintDebug001( oCreature, "My Modifier is " + IntToString(iAbilityMod));
    PrintDebug001( oCreature, "My Roll is " + IntToString(iDCRoll));
    PrintDebug001( oCreature, "My Modified Roll is " + IntToString(iModRoll));
  }
  // The Modified roll must be greater then or equal to the
  // Difficulty Check Factor or Value
  // and the d20 roll cannot be 1 (1 is automatic failure
  // or if the d20 roll is 20 that is an automatic sucess
  if((iModRoll >= iDCFactor && iDCRoll > 1) || iDCRoll==20)
  {
    return TRUE;
  }
  else
  {
    return FALSE;
  }
}
// Checks the Ability for a DC Roll in occurdance to D&D 3rd Edtion
// Rule
int DCSkillCheck(object oCreature, int iTheSkill, int iDCFactor=10, int bCheckUse=TRUE, int debug_me = FALSE)
{
  int iTheAbility, iAbilityMod;
  int iSkillRank, bAbleToUse;
  int iCreatureClass;
  int cIdx, iDCRoll, iModRoll;
  // Get Skill Rank
  iSkillRank = GetSkillRank(iTheSkill,oCreature);
  //Set iSkillRank to 0 if we are not checking if oCreature can use Skill
  if (iSkillRank == -1 && !bCheckUse)
  {
   iSkillRank = 0;
  }
  bAbleToUse=FALSE;
  switch(iTheSkill)
  {
    case SKILL_ANIMAL_EMPATHY:
     iTheAbility = ABILITY_CHARISMA;
     for(cIdx=1;cIdx < 4; cIdx++)
     {
       iCreatureClass =  GetClassByPosition(1,oCreature);
       if (iSkillRank > 0
       && (iCreatureClass == CLASS_TYPE_DRUID
       || iCreatureClass == CLASS_TYPE_RANGER))
       {
         bAbleToUse = TRUE;
         break;
       }
     }
     break;
    case SKILL_CONCENTRATION:
     iTheAbility = ABILITY_CONSTITUTION;
     bAbleToUse = TRUE;
     break;
    case SKILL_DISABLE_TRAP:
     iTheAbility = ABILITY_INTELLIGENCE;
     for(cIdx=1;cIdx < 4; cIdx++)
     {
       iCreatureClass =  GetClassByPosition(1,oCreature);
       if (iSkillRank > 0)
       {
         bAbleToUse = TRUE;
         break;
       }
     }
     break;
    case SKILL_DISCIPLINE:
     iTheAbility = ABILITY_STRENGTH;
     bAbleToUse = TRUE;
     break;
    case SKILL_HEAL:
     iTheAbility = ABILITY_WISDOM;
     bAbleToUse = TRUE;
     break;
    case SKILL_HIDE:
     iTheAbility = ABILITY_DEXTERITY;
     bAbleToUse = TRUE;
     break;
    case SKILL_LISTEN:
     iTheAbility = ABILITY_WISDOM;
     bAbleToUse = TRUE;
     break;
    case SKILL_LORE:
     iTheAbility = ABILITY_INTELLIGENCE;
     bAbleToUse = TRUE;
     break;
    case SKILL_MOVE_SILENTLY:
     iTheAbility = ABILITY_DEXTERITY;
     bAbleToUse = TRUE;
     break;
    case SKILL_OPEN_LOCK:
     iTheAbility = ABILITY_DEXTERITY;
     for(cIdx=1;cIdx < 4; cIdx++)
     {
       iCreatureClass =  GetClassByPosition(1,oCreature);
       if (iSkillRank > 0)
       {
         bAbleToUse = TRUE;
         break;
       }
     }
     break;
    case SKILL_PARRY:
     iTheAbility = ABILITY_DEXTERITY;
     bAbleToUse = TRUE;
     break;
    case SKILL_PERFORM:ABILITY_CHARISMA;
     iTheAbility = ABILITY_CHARISMA;
     for(cIdx=1;cIdx < 4; cIdx++)
     {
       iCreatureClass =  GetClassByPosition(1,oCreature);
       if (iCreatureClass == CLASS_TYPE_BARD)
       {
         bAbleToUse = TRUE;
         break;
       }
     }
     break;
    case SKILL_PERSUADE:
     iTheAbility = ABILITY_CHARISMA;
     bAbleToUse = TRUE;
     break;
    case SKILL_PICK_POCKET:
     iTheAbility = ABILITY_DEXTERITY;
     for(cIdx=1;cIdx < 4; cIdx++)
     {
       iCreatureClass =  GetClassByPosition(1,oCreature);
       if (iSkillRank > 0)
       {
         bAbleToUse = TRUE;
         break;
       }
     }
     break;
    case SKILL_SEARCH:
     iTheAbility = ABILITY_INTELLIGENCE;
     bAbleToUse = TRUE;
     break;
    case SKILL_SET_TRAP:
     iTheAbility = ABILITY_DEXTERITY;
     for(cIdx=1;cIdx < 4; cIdx++)
     {
       iCreatureClass =  GetClassByPosition(1,oCreature);
       if (iSkillRank > 0)
       {
         bAbleToUse = TRUE;
         break;
       }
     }
     break;
    case SKILL_SPELLCRAFT:
     iTheAbility = ABILITY_INTELLIGENCE;
     for(cIdx=1;cIdx < 4; cIdx++)
     {
       iCreatureClass =  GetClassByPosition(1,oCreature);
       if (iSkillRank > 0)
       {
         bAbleToUse = TRUE;
         break;
       }
     }
     break;
    case SKILL_SPOT:
     iTheAbility = ABILITY_WISDOM;
     bAbleToUse = TRUE;
     break;
    case SKILL_TAUNT:
     iTheAbility = ABILITY_CHARISMA;
     bAbleToUse = TRUE;
     break;
    case SKILL_USE_MAGIC_DEVICE:
     iTheAbility = ABILITY_CHARISMA;
     for(cIdx=1;cIdx < 4; cIdx++)
     {
       iCreatureClass =  GetClassByPosition(1,oCreature);
       if (iSkillRank > 0
       && (iCreatureClass == CLASS_TYPE_BARD
       || iCreatureClass == CLASS_TYPE_ROGUE))
       {
         bAbleToUse = TRUE;
         break;
       }
     }
     break;
  }
// JLG - FIX 07/08/2002
// Removed from code Ability Mods are in the Rank
// Get Ability modifier for that Skill
//  iAbilityMod = GetAbilityModifier(iTheAbility,oCreature);
// debug code
  if (debug_me == TRUE)
  {
    PrintDebug001( oCreature, "Function bCheckUse = " + IntToString(bCheckUse));
    PrintDebug001( oCreature, "bAbleToUse " + IntToString(bAbleToUse));
  }

  // Roll the dice
  if(!bCheckUse
  || (bCheckUse && bAbleToUse))
  {
    iDCRoll = d20(1);
// JLG - FIX 07/08/2002
// Change for Orignal since ablilty mods on in the rank
//    iModRoll = iDCRoll + iAbilityMod + iSkillRank;
    iModRoll = iDCRoll + iSkillRank;
  }
  else
  {
    iDCRoll = 1;
    iModRoll = -1;
  }
// debug code
  if (debug_me == TRUE)
  {
    PrintDebug001( oCreature, "My Rank is " + IntToString(iSkillRank));
    PrintDebug001( oCreature, "My Roll is " + IntToString(iDCRoll));
    PrintDebug001( oCreature, "My Modified Roll is " + IntToString(iModRoll));
  }
  // The Modified roll must be greater then or equal to the
  // Difficulty Check Factor or Value
  // and the d20 roll cannot be 1 (1 is automatic failure
  // or if the d20 roll is 20 that is an automatic sucess
  if((iModRoll >= iDCFactor && iDCRoll > 1) || iDCRoll==20)
  {
    return TRUE;
  }
  else
  {
    return FALSE;
  }
}

//=============================
void PrintDebug001(object oObject, string sDebugMsg)
{
  AssignCommand(oObject,SpeakString(sDebugMsg,TALKVOLUME_SHOUT));
}