There are guides out there for this, but I’m being blonde and I’ve spent a day on this, so…
I want to create a feat that is used to represent the Energy Resistance ability of a Favoured Soul.
They gain 10 resist to a given element of their choice, at 3 different levels.
I have two problems:
If possible, I’d like to have it be like one of the focus feats, for example Weapon Focus or Specialization, where you choose the given option from a list, instead of having one feat for each type. Is it possible to script this? If so, how?
I want to have the feat apply a passive ability that grants a resistance to this energy type, but I’m not grasping how to hook up the “feat” and its actual effect. The guides I found don’t seem to approach this step by step, and the test feat does not appear to create the appropriate resistance. I feel like I’ve probably missed a step but don’t have the knowledge to know what I’ve missed.
Not sure off-hand how it looks in game right now but I’m pretty sure all the weapon focus and specialization etc are actually a feat for each weapon. Energy resistance too.
For #2 I’d apply the bonus to the PC’s skin on enter (if not already there) and when the feat is gained (maybe check at the end of level up). Otherwise I think you’d have to change all the relevant spell and effect scripts.
Well if that’s how they are in the backend that’s fine, I suppose. I wonder if it’s possible to run a conversation post level up? The idea I have now is to have it check if you’re now the relevant level, and if so have it have a conversation or NUI interface to choose the energy resistance to gain, and then just apply the relevant feat.
The feats vs. the 5 basic energies are already there, line 533 ff of feats.2da. To offer them to a specific class on level up, you need to mess around with the 2da of the class.
A feat vs. positive energy (for example) seems not to be there. I don’t know if it’s possible to create a custom feat, but I fear it’s hardcoded.
You can always provide “feats” as item properties, just burn it on the pelt of the PC. Needs a bit of scripting. The downside of this is: it will not show up in the level up selection.
It not showing up is what I’m trying to get around, if I can. I was also hoping maybe I could include all the damage resistance possibilities except the physical ones:
Even if the feats are placeholders to an effect that we put on the PC skin that could work… but are effects on the PC skin persistent, ie kept across connecting/disconnecting and restarts, of the server?
I don’t recall if effects on skin are persistent. But as I said, apply it on enter, if not there, and you are done. The added feat (either on skin or on PC proper) would be persistent so you can just look for it and apply the effect.
The feat is not a placeholder. The effect, and the code that checks and applies it, is the implementation of the feat.
You want to have the PC get 10 resistance to foo. That’s an effect. So you let the player pick the appropriate feat then apply the effect to the skin, or the PC directly I suppose, now that I think about it.
This doesn’t even need the skin except maybe to add the feat itself. I don’t remember if EE has made that easier. If you get it in the class feat lists I suppose then it doesn’t need the skin for that part either.
Totally hacky pseudo code follows:
Onclienter() {
...
if (GetHasFeat(oPC, foo_feat)) {
// check for existence of effect. (using getfirsteffect and checking the effecttag)
// then
if (not found) {
eF = createeffect(resistance, foo, 10);
eF = TagEffect(eF, "foo_feat_tag");
eF = SupernaturalEfffect(eF);
applyeffecttocreature(oPC, eF, permanent);
// I think you can also hide the effect if you don't want an icon on the screen
}
}
I suppose you could also just set a variable on the PC instead of checking but this is probably safer in case it gets out of sync.
I might put that code in a library so I could call it on level up too.
in short you need to (re)apply the bonuses in following events:
onenter
level up
level down (which is tricky since there is no level down)
and possibly other events depending on what method do you use to apply the bonuses
one option is PC Skin, but I highly recommend to avoid that, it has far too many issues and side effects
second option is effect like @meaglyn suggested, this method has a disadvantage of icons effects showing off and the effects needs to be reapplied when player respawns.
However since recently EE allows to hide effect and also make an effect to persist over death, so combine HideEffectIcon with Unyielding|Effect functions and then all you need are the three events.
You can see specifics of this approach in my project PRC Lite. It has only few prestige classes unlike original PRC and is much more readable and thus you can learn the basics in it and use it as a resource. prc_featcheck is the script you are looking for if you decide to download and look at it.
Oh and OnLevelDown you can get by hooking all SetXP calls, replacing vanilla XP reward system and check level before and level after, if it is lower then player just lost a level or two.
If this is for singleplayer, and you want to make it available to anyone even players who for some reason didnd’t buy EE, then you either need to use skin to make the effect invisible or just live with the fact that the effects will show in effect list. There is a workaround I found out that can hide effects in 1.69, but this workaround was fixed in EE I believe and no longer works so it is pointless to use I suppose - it won’t wotk for everyone anyway.
And if you plan something like my PRC Lite, a separate single prestige class for peoples to download into their SPs and MP servers, then don’t. Or you will end up like me on the PRC’s black list and not just them