Alternative AutoDC Skill Rolls

What it does

The original AutoDC routine that nw_i0_tool supplies in script wizards isn't a proper skill roll - rather, it just does some math on the conversee's level, and checks if the player's skill rank is above the number it comes at.

This replacement is meant to go into nw_i0_tool, and conducts an actual Skill Roll.


You can use the script wizard with this AutoDC routine just as before. A DC is calculated based on the level of the NPC the player is talking to, modified by the 'easy/medium/hard' constants you add, and rolled against.

There are two extra parameters you can add. The first is an 'assumed level' of the player that's rolling, that can be used instead of the NPC's level to set difficulty. The second is a boolean asking if you want the roll to be shown to the player.

Also, the first parameter can be replaced with a number instead of a constant, to represent a chance out of 20 of making the roll. (EASY, MEDIUM, and HARD constants give the numbers 15,10, and 5 to this parameter.)


AutoDC (14, SKILL_HEAL, GetPCSpeaker(),5,TRUE);

means 'Make a roll against the player's Heal Skill. The DC is set so that a Level 5 player would have a 70% (14/20) chance of success. Show the player the roll.'


means 'The player makes a concentration roll. Get the level of the NPC the player is speaking with, and if the player's level is equal, this test is "easy".'

The player is assumed to be a 'competent' user of the skill. Competence is defined as having a skill of 3 ranks + the character's level, plus a 2 rank bonus from the character's ability scores. Most characters who stay within their roles should be competent.

The code below is meant to replace the code in nw_i0_tool. The constants should replace the old constants in the file; AutoDC should replace the old AutoDC; and GetSkillName and GetSkillAbility are new.

Since nw_i0_tool is an include file, just save it, rather than saving and compiling. Also, if you have already used AutoDC in your module, choose 'Build Module' from the menu to recompile everything using the new includes.

Whew! Here's the code:

The Script

// These are the new DC_constants for the edited AutoDC
int DC_EASY = 15;
int DC_MEDIUM = 10;
int DC_HARD = 5;

// Get Skill Name: return a string that describes
// the skill.
string GetSkillName(int nSkill)
   switch (nSkill)
        case SKILL_ANIMAL_EMPATHY: return "Animal Empathy";
        case SKILL_CONCENTRATION: return "Concentration";
        case SKILL_DISABLE_TRAP: return "Disable Trap";
        case SKILL_DISCIPLINE: return "Discipline";
        case SKILL_HEAL: return "Heal";
        case SKILL_HIDE: return "Hide";
        case SKILL_LISTEN: return "Listen";
        case SKILL_LORE: return "Lore";
        case SKILL_MOVE_SILENTLY: return "Move Silently";
        case SKILL_OPEN_LOCK: return "Open Lock";
        case SKILL_PARRY: return "Parry";
        case SKILL_PERFORM: return "Perform";
        case SKILL_PERSUADE: return "Persuade";
        case SKILL_PICK_POCKET: return "Pick Pocket";
        case SKILL_SEARCH: return "Search";
        case SKILL_SET_TRAP: return "Set Trap";
        case SKILL_SPELLCRAFT: return "Spellcraft";
        case SKILL_SPOT: return "Spot";
        case SKILL_TAUNT: return "Taunt";
        case SKILL_USE_MAGIC_DEVICE: return "Use Magic Device";
    return "Unknown";

// Get Skill Ability; find the ability that governs
// a particular skill.
int GetSkillAbility(int nSkill)
    switch (nSkill)
        case SKILL_ANIMAL_EMPATHY: return ABILITY_CHARISMA       ;
        case SKILL_DISCIPLINE: return ABILITY_STRENGTH           ;
        case SKILL_HEAL: return ABILITY_WISDOM                   ;
        case SKILL_HIDE: return ABILITY_DEXTERITY                ;
        case SKILL_LISTEN: return ABILITY_WISDOM                 ;
        case SKILL_LORE: return ABILITY_INTELLIGENCE             ;
        case SKILL_MOVE_SILENTLY: return ABILITY_DEXTERITY       ;
        case SKILL_OPEN_LOCK: return ABILITY_DEXTERITY           ;
        case SKILL_PARRY: return ABILITY_DEXTERITY              ;
        case SKILL_PERFORM: return ABILITY_CHARISMA            ;
        case SKILL_PERSUADE: return ABILITY_CHARISMA          ;
        case SKILL_PICK_POCKET: return ABILITY_DEXTERITY     ;
        case SKILL_SEARCH: return ABILITY_INTELLIGENCE      ;
        case SKILL_SET_TRAP: return ABILITY_DEXTERITY      ;
        case SKILL_SPOT: return ABILITY_WISDOM;
        case SKILL_TAUNT: return ABILITY_CHARISMA;

int AutoDC(int Chance20, int nSkill, object oTarget, int nAssumedLevel = 0, int bShowRoll = FALSE)
    // Assuming a skilled user
    int level;
    int DC;
    int success;
    if (nAssumedLevel == 0)
        level = GetHitDice(OBJECT_SELF);
        level = nAssumedLevel;
    // Level 1 (has 6 points: 3 skill + 2 ability + 1 level)
    // a 20/20 chance would be DC 7.  (since minimum roll of 1)
    // so a 10/20 chance would be DC 17..
    DC = (5 + level) + (20 - Chance20) + 1;
    string message;
    message = GetName(oTarget) + " checks " + GetSkillName(nSkill) + ": " ;
    if (GetHasSkill(nSkill,oTarget) == FALSE)
        success = FALSE;
        message = message + "Does not have skill (Failure)";
        // Make the roll
        int roll;
        int bonuses;
        int total;
        roll = Random(20) + 1;
        bonuses = GetSkillRank(nSkill,oTarget);
        // What is the ability?  Get the modifier.
        int ability;
        ability = GetSkillAbility(nSkill);
        bonuses = bonuses + GetAbilityModifier(ability);
        total = roll + bonuses;
        message = message + IntToString(roll) + " + " + IntToString(bonuses)
                + " = " + IntToString(total) + " vs DC " + IntToString(DC) + " : " ;
        if (total >= DC)
            success = TRUE;
            message = message + "(Success)";
            success = FALSE;
            message = message + "(Failure)";

    if (bShowRoll)
    return success;

Second Script

Here's another quick one I use a lot. I do most of my ability checks myself, and it's handy to be able to get the ability modifier on the fly.

int GetAbilityBonus(int nScore)
  int n;
  int nBonus = -6;
  for (n=1;n<nScore;n+2)
    nBonus = nBonus+1;
  return nBonus;

This will return the correct modifier for their current ability score.

eg: Str 12. so GetAbilityBonus(12) returns +1 I most commonly call it like so: int nStrBonus = GetAbilityBonus( GetAbilityScore(oPC,ABILITY_STRENGTH) );

Ad blocker interference detected!

Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers

Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.