NPCs and subradial spells

Has anyone else noticed it isnt possible for NPCs to use subradial spells? The master spell is available as a special ability in the toolset to give them, but they will not use it. The subspells cant be give to them either. Take Shadow Conjuration for example or Polymorph Self.

You can give them those spells as special abilities, but they will never use them.

Are we talking about AI or possessing? if you possess the npc you should be able to find the spell and use it as normal. If this is about AI then, first of all vanilla AI cannot handle polymorphing spells, most of them is disabled in vanilla, and those which aren’t are causing quite stupid behavior. I think shadow conjuration should be possible to use by vanilla AI though.

Either way, if you want this to be fixed use either community patch (1.72) or TonyK Henchmen AI, but I am not sure if TonyK can do this exactly. Even with community patch, by default creatures cannot use polymorphing, to enable it you must set variable 70_ALLOW_SHAPECHANGE int 1.

I have custom spells in sub-radials. They’re basic attack spells and categorized as such. The spells as subradial entries are not used by NPCs who possess the master spell and those subspells can not be given to them individually. They will use those same spells if I make duplicate entries of them in spells.2da without the master/subspell entries.

Also you want to check this - https://neverwintervault.org/article/tutorial/tutorial-vanilla-community-patch-ai-depth

btw, what is Category of your master spell and sub spells?

It doesn’t matter which category I use. Ive tried, 1, 2 and 11. Like I said though, they use them right away when theyre not master/subspells. So, for whatever reason them being subspells the NPC cant see them.

Oh yeah. Additionally, if I give a category to the feat itself the NPC will use that feat, but it doesn’t do anything since it normally cant be used by a PC. They can only use a subspell of that feat.

It’s been a while since I touched vanilla AI.

What I do know is that npcs can actually use some polymorph abilities with subspells. From what I remember, I’ve seen npcs to use at least druidic wild shape, though it was always into badger (first subspell). I don’t remember if they can use normal spells though (wild shape is feat and those have some special treatment in talent engine it seems).

Either way, even if vanilla AI would be able to use subspells and you just had something setup badly (which it doesn’t really seems to), still vanilla AI can only use the first subspell anyway.

So if you want npcs to use such spells you need to make modifications into AI and write it for specific spells directly.

I appreciate you trying to help. But, you’re not understanding what I’m saying. I’m saying that you cant give them spells that are feats with sub-spells. Forgot polymorph since it isnt relevant other than it’s a spell with sub spells. Shadow Conjuration is a spell with various different subspells that NPCs would normally use. If you give them Shadow Conjuration they won’t use any of those spells it gives them. You also can not give them those spells individually either. You have to create duplicates of those individual spells and delete the masterfeat information and give those to the NPCs. When an NPC has a spell with subspells, it doesn’t know it has those subspells.

I understand it - so again.

AFAIK npcs can use feats or spells with subspells. I’ve seen them use druidic wild shape. But even if they can use them, they always select the first subspell which renders this quite useless. To fix that you need to modify AI scripting.

Now for why it doesn’t work for you at all. Either you are not giving these feats as feats or you are not giving them as special abilities (not sure which of the methods works). If they refuse to cast it either way then it has either bad category or something else like maybe bad featid reference or this only work with vanilla feats with subspells.

Either way, feats with subspells has just too many issues, if you can avoid them.

So I gave the same NPCs Wildshape and they use it and they also select a random animal. Ive seen them use bear, wolf and boar already. And according to the combat log they’re using “Wild Shape, Wolf” etc not the feat or master spell.

To summarize. They use wildshape if they have it using the default AI. However, when I give them attack spells in a subradial they dont use them. They use the master spell instead which doesnt do anything.

There’s an issue with the accepted formula for calculating subspell feat IDs.
Wildshape is Feat 305.
The FeatID on Wildshape, Brown Bear is 66060288
If you subtract 305 from 66060288 and divide the result by 65536 you get 1005.999984741211.
You can not possibly get 66060288 with a FeatId of 305. But you do get 66060288 if you use 304.

Make sure your master spell has no category then.

The formula is right. Some of the entries in the bioware 2da are off. The horse menu ones aren’t quite right either. The given formula works correctly and is what you should use if you are adding your own. I never dug into it far enough to see why the others are off from that. For example horse mount 71369516 = (65536 * 1089) + 812. 812 is the spell ID for the horse menu.
The one you cited is really broken as it’s 0x03f0 0000 which is (65536 * 1008 ) + 0.

The 65536 is really just to make the high order 16 bits be the subradial number - which you pick - and the low order bits should be the featid, which is added.

I suspect the engine is not as picky about this as the spec suggests. I think as long as the subradial ID (the high-order 16 bits) is different it makes it work.

Yeah, it works for the player so it must be right. I suppose it doesnt have anything to do with why the NPCs dont use them though.

I tried that. If it doesnt have a category they won’t use it at all. If it does have a category they will use it approriately but theyre using the main spell instead of one of the subspells.

Im beginning to think that the wildshape feats etc are hardcoded to work correctly. If I make a duplicate of wildshape and its subspells it doesnt work anymore. They will then only use the wildshape spell itself instead of one of the wildshape subspells.

Well this then actually match with what I was saying about npcs choosing first spell everytime. But it is weird they don’t do that in case of wildshape, I must have remembered incorrectly.

Either way, there is a workaround - add a spellscript to master spell, in it you can do random(4) and executescript for one of the subspells, alternatively you can code something more sophisticated - as this will only be called by NPCs, you can check whats the situation around NPC and by that choose the best spell from subspells to use.

On Wildshape:
Just make any NPC and give them Wildshape. using vanilla AI or any AI calling them to use spells of that category (I believe it’s 10) they will use a random subspell of Wilshape and never wildshape itself (if they did they’d become polymorph 0 which is a were rat).

On the alternative:
I was messing around with that idea earlier. I couldn’t get it to work but I’ll have to revisit it and report back.

BTW one more time, how do you grant the ability to npc? as a feat or as a special ability? If you look at wildshape, it has no category in spells.2da (meaning, npcs should never use it if you give it as special ability) but has a category as a feat. Try duplicate this.

I gave them wildshape as a feat. Youll notice that feats like this cant be given as special abilities or spells anyway, only as feats.

nvm

The master spell has no category. They will still try to use it even though it doesnt do anything. If I make the impact script of the master spell cast a random subspell the NPCs will need to cast two spells each spell or I can make it “instant” but then the vfx etc will always be the same.

I see, thats not a solution either if the subspells differ a lot…