From NWN Lexicon
Jump to navigationJump to search


Returns the challenge rating of the target creature.

float GetChallengeRating(
    object oCreature




Returns the challenge rating of the target creature to determine how tough it is.

Returns 0.0 if oCreature is invalid.


Challenge ratings are stand alone. In other words, the value is not in comparison to anything, but rather a straight up value.

Challenge ratings are made up of a number of different aspects; a creatures hit dice, feats, spells, abilities, maximum health, items equipped and so forth. There is also a manual adjustment setting in each creatures blueprint. If you have an exhaustive list of stuff that contributes to it let us know.

It appears it is only ever calculated in the toolset, and there is little to no way to change it in-game (no SetChallengeRating is available), and adding new items to a creature (or removing them) doesn't recaculate it.

If you run LevelUpHenchman (which can be done on any creature) the challenge rating after each usage should change upwards by 1.




// Example 1 - Get the challenge rating of the creature that last
// attacked me (whatever creature this script is called by) and
// check it against my challenge rating to see if I should be
// worried or not.

void main(){

  // Make sure script isn't misplace...will only work on creatures.
  if (GetObjectType(OBJECT_SELF) != OBJECT_TYPE_CREATURE) return;
  // Get the creature that last attacked me.
  object oCreature = GetLastAttacker(OBJECT_SELF);
  // Get out if it is not a creature (PC or mob)
  if (GetObjectType(oCreature) != OBJECT_TYPE_CREATURE) return;
  // Get the challenge rating of the creature.
  float fChallenge = GetChallengeRating(oCreature);
  // Get my challenge rating.
  float fMe = GetChallengeRating(OBJECT_SELF);
  // Just for fun...
  if (fMe <= fChallenge)
    SpeakString("Ok, I'm scared!",TALKVOLUME_TALK);
    SpeakString("I'm gonna whoop 'em good!",TALKVOLUME_TALK);

See Also

 author: Brett Lathrope