From NWN Lexicon
Revision as of 08:18, 24 June 2019 by Shadguy (talk | contribs) (Spelling fix(es))
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigationJump to search

GiveXPToCreature(object, int)

Gives an amount of experience to the specified creature.

void GiveXPToCreature(
    object oCreature,
    int nXpAmount



Specific creature to give experience to.


Amount of experience to give.


Gives nXpAmount to oCreature, adjusted by any multiclass penalty.

nXpAmount cannot be negative, however, SetXP() can make a PC lose experience to, for example, make a PC de-level to level 1.


This will always take into account anything that the default XP from killing creatures (settable in the module properties) would - thusly, multiclassing.

It reports a message to the PC getting the experience too, with the amount nXpAmount being given.

This function will not do anything to NPCs (even henchmen) or Dungeon Masters (they do not "level" at all). This begs the question why it is even oCreature at all, when oPC would be more appropriate and less confusing.

Also note that there are several functions which automatically give appropriate party experience and so on, check the lexicon under "Experience".

Known Bugs

Bugs with Prestiege classes and multiclass experience points are/were fixed in 1.64. The problem with "You have gained 0 experience" appearing for any type of experience giving now has the message remove in the 1.64 patch.




// Give the PC (and only the one PC) 50 experience in a
// conversation action event.

void main()
    // Get the PC
    object oPC = GetPCSpeaker()

    // Give the experience
    GiveXPToCreature(oPC, 50);

See Also



 author: Jody Fletcher, editor: Jasperre, additional contributor(s): Alec Usticke, Charles Feduke, Jasperre