FANDOM



This is a replacement for the original AutoDC() routine supplied by nw_i0_tool.nss. The original author is Kinsman.

Notes Edit

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.)

Example Edit

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.'

AutoDC (DC_EASY, SKILL_CONCENTRATION, GetPCSpeaker());

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, and AutoDC() should replace the old AutoDC.

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.

Here's the code:

The script Edit

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

int AutoDC(int nChance20, int nSkill, object oTarget, int nAssumedLevel = 0, int bShowRoll = FALSE)
{
    // Assuming a skilled user
    if ( nAssumedLevel == 0 )
        nAssumedLevel = GetHitDice(OBJECT_SELF);
    // For level 1 (assumed skill of 6: (level+3) ranks + 2 ability),
    // a 20/20 chance would be DC 7  (since the minimum roll is 1).
    // So a 10/20 chance would be DC 17.
    int nDC = (5 + nAssumedLevel) + (20 - nChance20) + 1;

    if ( bShowRoll )
        // Let the game engine provide feedback.
        return GetIsSkillSuccessful(oTarget, nSkill, nDC);

    // Can only use skills that are available for use.
    if ( !GetHasSkill(nSkill,oTarget) )
        return FALSE;

    // Make the roll
    return d20() + GetSkillRank(nSkill, oTarget) >= nDC;
}

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.