Level Drain effect

I have a situation where I want only the PC to face an NPC in a duel. The NPC (which later becomes a companion) is a fighter and the same level as the PC. Chances are that since the NPC is a fighter, he might be a bit too tough for the PC to handle. That’s why I thought to incorporate the Level Drain spell through scripting. That’s possible, right? I want to temporarily have the Level Drain on the NPC so he becomes level 1, or something like that. Then after the duel I remove the Level Drain effect so that he’s the same level as the PC again.

I looked in the Script Assist and found EffectNegativeLevel which might be what I’m searching for, I don’t know… I tried this but it didn’t seem to work that well:

effect eFXDamage = EffectNegativeLevel(2);
ApplyEffectToObject(DURATION_TYPE_PERMANENT, eFXDamage, oTarget);

But why don’t you just make him level 1 to begin with and then level him up after the duel, you may ask? Well, for reasons I won’t go into, I would like to not do this 'cause then the player has to level him up (at least that’s how I understand it) and can then choose all sort of things that I don’t want for this character, like choose a different class and so on…At least I don’t think (but I could be totally wrong here) that you can level up a character and automatically give him the default skills for that level (or maybe you can)…

1 Like

Once you set the class, starting feats, and level up package on a companion, the player can’t change them without going into the toolset. I’ve hit several mods with mistakes in the way a companion was set up and those are really the only two options. Even Clangeddin’s Character Rebuild tool will not the change characters class, starting feats, or level up package. On a spell caster I could see a problem here but on a Fighter I don’t think the player could do much to screw it up.

So, you mean if I have this character on level 1 from the beginning, with a start package (I tend to use the Creature Creator for this) there should be no problem then?

I guess I could just test it pretty easily. Still, the player has control of the leveling up of the character with choosing skills and whatnot (I’m not sure this is a problem here but…)…
I see that I’ve just chosen Default Fighter for this guy…

EDIT: I see there’s a function called SetLevelUpPackage. Could I use that and then just before the character joins the party I level him up automatically to level 3 or something like that? or SetUnrestrictedLevelUp? I’ve never done it like this before so I’m not sure how to go about it.

Well, I would just have 2 instances of the NPC.

  • The first one at level 1 just for the fight, pre placed in the fighting area, forced exit after the fight.
  • The companion one at planned level spawned wherever relevant after the fight.

Both can share the same convo if you wish so, or have their own ones. For sake of clarity I would use different tags such as “joe_fight” for the first one and “joe” for the companion.

2 Likes

Hmmm, yeah, that’s one way to do it. Maybe it’s the easiest. Just destroy the level 1 one after the fight and when he joins the party spawn the other.

1 Like

there’s also level up w/ package

/*
// ResetCreatureLevelForXP
//
// Created By:  Brock Heinz - OEI
// Created On:  05/07/06
// Description: This command will set a creature back to level 0, and
//              award him experience the experience passed to the function.
//              s/he will then auto-level up to the highest level
//              allowed by the experience he has based on his current level-up
//              package.
// Arguments:
// oTargetCreature  - The creature to reset and auto-level
// nExperience      - The amount of experience to give the creature
// bUseXPMods       - If TRUE, then the creatures experience modifires will be
//                    applied before the experience is awarded.
//////////////////////////////////////////////////////////////////////////////*/
void ResetCreatureLevelForXP( object oTargetCreature, int nExperience, int bUseXPMods );
2 Likes

Yeah, I guess I could have used that too.

I went with what @Claudius33 suggested since I noticed that I had a lot more freedom of putting stuff on the other “joe” then. I could customize hitpoints and whatnot and get the fight more balanced (well, it’s still really hard to balance a fight like this and I’ve only tried with a fighter myself, so hopefully a magic user won’t have too much trouble, we’ll see).
I’ve done a lot of testing now and had to alter many scripts and other stuff, but I believe it works satisfactory now.

EDIT: I’m still curious if it’s possible to put the Level Drain effect on a creature through scripting though.

1 Like

have a look at the spellscript – nw_s0_enedrain.nss

2 Likes

Alright, I’ll do that.

EDIT: I see they are actually using the same function I found: EffectNegativeLevel but there just seems to be a bit more code for it to actually work, like making it a SupernaturalEffect. Still, looking at it more closely I think that my code should have worked, but it’s hard to tell when it’s cast on an NPC (you can’t see the sqaure thing beside the portrait, of course).

EDIT2: I tested my code from my first post here on a companion, and it worked perfectly, so maybe I just didn’t notice it working the first time around. In any case, I believe the way I have it now with:

, without the level drain, is better.

1 Like