Difference between revisions of "GetSkillRank"

From NWN Lexicon
Jump to: navigation, search
(Created page with " =GetSkillRank(int, object, int)= Determines a creature's rank in particular skill. int  GetSkillRank(      int  nSkill,     [[o...")
 
Line 7: Line 7:
 
Determines a creature's rank in particular skill.
 
Determines a creature's rank in particular skill.
  
 +
<nwscript>
 
  [[int | int ]] GetSkillRank(
 
  [[int | int ]] GetSkillRank(
 
      [[int | int ]] nSkill,
 
      [[int | int ]] nSkill,
Line 12: Line 13:
 
      [[int | int ]] nBaseSkillRank = FALSE
 
      [[int | int ]] nBaseSkillRank = FALSE
 
  );
 
  );
 +
</nwscript>
  
 
====Parameters====
 
====Parameters====
Line 53: Line 55:
 
====Example====
 
====Example====
  
<font color="#007f00">// This script would be placed in a conversation
+
<nwscript>
  </font><font color="#007f00">// where the player challenges the Master Bard to
+
// This script would be placed in a conversation
  </font><font color="#007f00">// a performance duel.
+
  // where the player challenges the Master Bard to
  </font>
+
  // a performance duel.
  <font color="#0000ff">void</font> main()
+
   
 +
  void main()
 
  {
 
  {
     <font color="#007f00">// Initialize Objects
+
     // Initialize Objects
</font>    <font color="#0000ff">object</font> oPlayer = GetPCSpeaker();
+
    object oPlayer = GetPCSpeaker();
     <font color="#007f00">// Determine skill checks
+
     // Determine skill checks
</font>    <font color="#0000ff">int</font> iPPerCheck = d20(1) + GetSkillRank(SKILL_PERFORM, oPlayer);
+
    int iPPerCheck = d20(1) + GetSkillRank(SKILL_PERFORM, oPlayer);
     <font color="#0000ff">int</font> iMPerCheck = d20(1) + GetSkillRank(SKILL_PERFORM, <font color="#0000ff">OBJECT_SELF</font>);
+
     int iMPerCheck = d20(1) + GetSkillRank(SKILL_PERFORM, OBJECT_SELF);
     <font color="#007f00">// Compare the two skill checks
+
     // Compare the two skill checks
</font>    <font color="#0000ff">if</font> (iPPerCheck &gt; iMPerCheck)
+
    if (iPPerCheck &gt; iMPerCheck)
 
     {
 
     {
           <font color="#007f00">// Player wins perform duel
+
           // Player wins perform duel
</font>        <font color="#007f00">// Place reward code here
+
          // Place reward code here
</font>    }
+
    }
     <font color="#0000ff">else</font>
+
     else
 
     {
 
     {
           <font color="#007f00">//Player looses perform duel
+
           //Player looses perform duel
</font>        <font color="#007f00">//Place failure code here
+
          //Place failure code here
</font>    }
+
    }
 
  }
 
  }
 +
</nwscript>
  
 
====See Also====
 
====See Also====

Revision as of 21:45, 25 August 2012



GetSkillRank(int, object, int)

Determines a creature's rank in particular skill.

 [[int | int ]] GetSkillRank(
     [[int | int ]] nSkill,
     [[object | object ]] oTarget = OBJECT_SELF,
     [[int | 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 &gt; iMPerCheck)
     {
          // Player wins perform duel
          // Place reward code here
     }
     else
     {
          //Player looses perform duel
          //Place failure code here
     }
 }

See Also

functions: 

ActionUseSkill

constants: 

SKILL_* Constants



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