GiveXPToCreature(object, int)

From NWN Lexicon
Jump to navigationJump to search

Gives an amount of experience to the specified creature.

void GiveXPToCreature(
    object oCreature,
    int nXpAmount
);

Parameters

oCreature
Specific creature to give experience to.
nXpAmount
Amount of experience to give.


Description

Gives nXpAmount to oCreature, adjusted by any multiclass penalty. If the penalty adjusts the XP granted to 0 nothing will happen.

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


Remarks

This will always take into account anything that the default XP from killing creatures (settable in the module properties) would - thusly, multiclassing. To not have multiclass XP penalties use SetXP instead.

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.


Example

// 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

functions: 

SetXP



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