GetIsSkillSuccessful(object, int, int)

Determines if a skill roll is successful.

int GetIsSkillSuccessful(
    object oTarget,
    int nSkill,
    int nDifficulty
);

Parameters

oTarget

Creature who is using the skill.

nSkill

Skill to use (SKILL_*).

nDifficulty

Difficulty check to beat in order to be successful.


Description

Standard difficulty check (DC). Returns true if 1d20 roll plus skill rank is greater to or equal to the difficulty rating specified.



Remarks

Unlike AutoDC, the hitdice of the caller isn’t taken into consideration for this function, and you have to specify the absolute difficulty yourself, ie the number that must be rolled against, using d20 + skill rank. The previously noted bug concerning the AutoDC function has been fixed, and I'd say it is now an open choice if you want to use one function or the other.

It is unknown if other factors, such as encumberance, are taken into account automatically by this function.


Version

1.30

Example

//Test if the PC is able to use a potion creating
//item device. Put OnUsed.

void main()
{
object oPC=GetLastUsedBy();

if (GetIsSkillSuccessful(oPC, SKILL_USE_MAGIC_DEVICE, 30))
   {
   effect eVis=EffectVisualEffect(VFX_FNF_STRIKE_HOLY);
   ApplyEffectToObject(DURATION_TYPE_INSTANT, eVis, OBJECT_SELF);

   //Get resref of random potion
   int nNum=Random(23)+1;
   string sNum=IntToString(nNum);
   if (GetStringLength(sNum)==1) sNum="00"+sNum;
   else if (GetStringLength(sNum)==2) sNum="0"+sNum;
   sNum="nw_it_mpotion"+sNum;
   CreateItemOnObject(sNum, oPC, d10());
   }
else
   {
   AssignCommand(oPC, ActionSpeakString("How the heck do you use this thing?!?"));
   }
}

See Also

functions: AutoDC
categories: Talents/Skills/Feats Functions
constants: SKILL_* Constants


 author: Charles Feduke, editor: Lilac Soul
 Send comments on this topic.