GetSkillRank(int, object, int)

Determines a creature's rank in particular skill.

int GetSkillRank(
    int nSkill,
    object oTarget = OBJECT_SELF,
    int nBaseSkillRank = FALSE
);

Parameters

nSkill

SKILL_*

oTarget

The creature to check what rank they have in nSkill. (Default: OBJECT_SELF)

nBaseSkillRank

If set to TRUE returns the number of base skill ranks oTarget has. (Default: FALSE)


Description

Returns the number of ranks that oTarget has in nSkill. If you want the number of base ranks put in on level up, set nBaseSkillRank to be TRUE. Otherwise the total returned will include bonuses from things like ability scores, feats, etc.

If nSkill is untrained this function returns 0, and -1 if oTarget doesn't have nSkill. See known bugs for why it might never return -1.



Remarks

Use GetHasSkill to see if they have the skill and can use it, for example, to check if they have a useable Animal Empathy in a conversation. This mearly returns the value of ranks they have - therefore, it normally does return at least 0, you can't make yourself have negative ranks!

The fact that it returns the ranks may mean it never returns -1, as noted below, even though the description says it.

The ranks of a skill (with nBaseSkillRank = FALSE) is what is on the character sheet - thusly, it includes all bonuses (items, spells, area-affecting, etc) and penalties, into one number. Obviously, this might be why it returns 0 for untrained skills, or even negative numbers if, I guess.


Known Bugs

Its been remarked that it appears to be returning 0, not -1, if a PC does not have any ranks in a skill and it it one that requires training.

This is reported to not include synergy bonuses from skills that work together - for example, Set Trap and Disarm Trap.


Version

1.67

Example

// This script would be placed in a conversation
// where the player challenges the Master Bard to
// a performance duel.

void main()
{
    // Initialize Objects
    object oPlayer = GetPCSpeaker();
    // Determine skill checks
    int iPPerCheck = d20(1) + GetSkillRank(SKILL_PERFORM, oPlayer);
    int iMPerCheck = d20(1) + GetSkillRank(SKILL_PERFORM, OBJECT_SELF);
    // Compare the two skill checks
    if (iPPerCheck > iMPerCheck)
    {
         // Player wins perform duel
         // Place reward code here
    }
    else
    {
         //Player looses perform duel
         //Place failure code here
    }
}

See Also

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


 author: Tom Cassiotis, editor: Jasperre, Mistress, additional contributor(s): Jasperre, John Baker