First off, while CR determines XP, it is not necessarily a good indication of difficulty. Leveling up a creature by script does not improve upon special abilities, nor does it improve the creature's skin. If you want to level up a creature to your liking as far as difficulty is concerned, you are often best at creating your own level up packages which you would define in packages.2da.
Secondly, this will not work on most toolkit creatures. Creatures that have more than one HD will typically fail the LevelUpHenchman() command, as the command assumes a starting level of one. Thus you will need to create one HD variants of the creatures you want to be leveled up.
With that said, the below script demonstrates leveling a creature to the point just above 20.0 CR. It uses a one HD creature (the skeleton). In this script the delay command is important as there are problems with leveling up when the creature is just created.
void LevelToCR(object oCreature, float fCRLimit, int nclass, int nLevelUpPackage = PACKAGE_INVALID)
{
float fCR = GetChallengeRating(oCreature);
int nHD = GetHitDice(oCreature);
while(fCR < fCRLimit)
{
LevelUpHenchman(oCreature, nclass, TRUE, nLevelUpPackage);
fCR = GetChallengeRating(oCreature);
nHD++;
//Cut the loop if no longer leveling up
if(nHD != GetHitDice(oCreature)) return;
}
}
void main()
{
object oSkel = CreateObject(OBJECT_TYPE_CREATURE, "nw_skeleton", GetLocation(OBJECT_SELF));
DelayCommand(0.5, LevelToCR(oSkel, 20.0, CLA
SS_TYPE_FIGHTER));
}
Modifié par WhiZard, 02 décembre 2012 - 06:57 .