Jump to content

the "Faiths and Powers" mod


subtledoctor

Recommended Posts

Where's Jarno, because he recently said something about 1st level CLAB spells getting applied twice. I don't recall what thread that was in.

It's not (just) twice, it's in all the level ups, and the ToBEx/EE games have even more. Which is why you really need to think about the timers the spells and effects have that you apply in the GLAB files...

But that usually hasn't to do with the double spells. The usual reason is that the .cre has two samelike spells is but the spells are actually different, the difference can be a minute, but it's there and they don't have the same .spl file name either. Also adding two ADD_SPELL mods that add similar spells with a different script variable, you get a lot of same like spells that are, actually different. As the functionality is not actually intellegent. It would be so easy with an AI. :devil: Ouh, yeah, we wouldn't need proigrammer, nevermind.

Link to comment

 

Where's Jarno, because he recently said something about 1st level CLAB spells getting applied twice. I don't recall what thread that was in.

It's not (just) twice, it's in all the level ups, and the ToBEx/EE games have even more. Which is why you really need to think about the timers the spells and effects have that you apply in the GLAB files...

But that usually hasn't to do with the double spells. The usual reason is that the .cre has two samelike spells is but the spells are actually different, the difference can be a minute, but it's there and they don't have the same .spl file name either. Also adding two ADD_SPELL mods that add similar spells with a different script variable, you get a lot of same like spells that are, actually different. As the functionality is not actually intellegent. It would be so easy with an AI. :devil: Ouh, yeah, we wouldn't need proigrammer, nevermind.

 

Question is now, does this mod discussed here do such a thing or is it from some other tweak, so they may forget the comment right here.

Link to comment

Nice - let's get into a really good in-depth technical discussion. I'll tell you exactly what the mod is doing and how it all works.

Firstly, I think Jarno is wrong, or at least imprecise, about the CLAB effect running multiple times. Think about a kit in the vanilla game, like the Archer: at first level it gets +1 to ranged thac0/damage, and one use of Charm Animal. At 2nd level, the game does not run the level 1 CLAB effects again - if it did, the Archers would get +2 to thac0/damage and 2 uses of Charm Animal at 2nd level. But they only get one, which is how it should be. What the game does at 2nd level, is run the 2nd-level CLAB effects. Which in the case of an Archer, is nothing.

This mod adds all 1st-level spells for a kit's spheres as a 1st level CLAB effect. So it should only run once, at 1st level, and nothing should be doubled. If there was an issue with CLAB effects running twice, then you would see doubles of every spell - not just a few.

Second: of course, the game does have some quirks relating to CLABs, and the EEs are worse. Generally this has to do with dual-classing and NPCs joining the party. When stuff like that happens, all CLAB effects sometimes get run twice.

An easy way to deal with this is to add a permanent opcode 206 effect, protecting against itself, so that it could only ever work once. This wouldn't work with the Archer's bonuses, because they get repeated every 3 levels. But it would work fine here, since spells only need to be added to the spellbook once.

BUT, I think it's still not necessary. This mod adds spells by using opcode 171 "add innate ability" to add priest spells to the character. In my testing (albeit, limited testing), doing this twice with the same spell does not result in doubles in your spellbook. Each spell file will only show up once. I'm pretty sure this is how it works - the easiest way I've tested is rolling a multiclass ranger/cleric and leveling up. The ranger and cleric CLABs give duplicate access to certain spheres, but I have not seen duplicate spells as a result. (I've only tested this in the EE engine though, maybe BGT behaves differently...) That's why Jarno said:

The usual reason is that the .cre has two samelike spells is but the spells are actually different, the difference can be a minute, but it's there and they don't have the same .spl file name either. Also adding two ADD_SPELL mods that add similar spells with a different script variable, you get a lot of same like spells that are, actually different.


Third: ADD_SPELL should not be a problem here. In fact other mods using ADD_SPELL is great for me, and mods that don't use it, like SR, present a huge headache because they screw up the IDS spell table, so CLERIC_SUNSCORCH is actually Strength of Stone, and CLERIC_CAUSE_LIGHT_WOUNDS is actually Regenerate Light Wounds, etc. Install SR and IWDification, or install SR on IWDEE, and take a look in NI, you'll see that ~3-4 spells of each level have there IDS names screwed up. IDS names matter a lot for this mod. I'll explain how the mod works, so you can see why:

 

- Step 1: the mod identifies all .spl files tagged as priest spells, and ticks the usability flags for both druids and clerics, so no priests can use any priest spells. This means no priest spells will be available for memorization during character generation, and no spells will appear in your spellbook.

 

- Step 2: now, something needs to be available during character generation, so the mod takes 7 spells - just one of each level - and re-enables their use by clerics and druids. Now you can successfully roll a character.

 

- Step 3: the mod creates an effect to remove those 7 spells from your spellbook, because some kits should not get those spells. E.g. one of them is Heal... but a kit that has only minor access to the sphere of Healing should not be able to cast Heal. This removal effect has to be applied at every level, since every spell tagged as usable by clerics will get automatically added to cleric spellbooks every time they level up. The removal effect is on a 1-second delay, so every time you level up, one spell at each level will appear in your spellbook, and then disappear a second later.

 

- Step 4: the mod looks through SPELL.IDS, and compares the IDS names to a list of spells in an array. Every match gets copied, and the copy gets assigned to a sphere designated in the array. (The filename of the copy .SPL gets added to a 171 effect for that sphere.) This is why it's so important that the IDS table be accurate.

 

- Step 5: each kit that the mod is aware of has certain sphere-based .SPLs added to its CLAB. Currently this handles the vanilla kits, kits added by this mod, and kits from Divine Remix. This process means that the only spells that get added to your spellbook are the copies that have been produced by the process above. That's why there should be no doubles. But, obviously the process needs to be perfected!

 

- Step 6: the mod looks for any cleric/druid/paladin/ranger kits that have not already been handled, and assigns them a default set of spheres. This way, you avoid the problem that DRv7 had where other mod kits wouldn't be able to cast any spells.

 

- Step 7: finally, the mod looks for any .SPL or .ITM file that contains an effect identifying a particular spell resource name (opcodes 206, 318, 321, and 324), and adds a duplicate effect identifying my spell copies. So if, say, Defensive Spin protects against Free Action, it will also protect against my new copy of Free Action. If Death Ward specifically protects against the Finger of Death spell, it will now also protect against my new cloned Finger of Death spell. Etc.

 

So, you can see that there are a few possible points of failure.

- If any mod adds priest spells to the game after this one is installed, they will be skipped by step 1. This might be what is causing duplicates in Roxanne's game.

- If any mod adds divine caster kits after this one is installed, those kits will be skipped by step 6 and have no spells. These things are simply install order issues.

The solution for those two problems is to simply make sure this mod is installed after any other kits and spells. (But this should go before SCS.)

- Another possible problem is if a mod messes up spells' IDS names, since that will screw up step 4. This is much harder to deal with.

Link to comment

Nice - let's get into a really good in-depth technical discussion. I'll tell you exactly what the mod is doing and how it all works.

 

Firstly, I think Jarno is wrong, or at least imprecise, about the CLAB effect running multiple times. Think about a kit in the vanilla game, like the Archer: at first level it gets +1 to ranged thac0/damage, and one use of Charm Animal. At 2nd level, the game does not run the level 1 CLAB effects again - if it did, the Archers would get +2 to thac0/damage and 2 uses of Charm Animal at 2nd level. But they only get one, which is how it should be. What the game does at 2nd level, is run the 2nd-level CLAB effects. Which in the case of an Archer, is nothing.

 

This mod adds all 1st-level spells for a kit's spheres as a 1st level CLAB effect. So it should only run once, at 1st level, and nothing should be doubled. If there was an issue with CLAB effects running twice, then you would see doubles of every spell - not just a few.

 

Second: of course, the game does have some quirks relating to CLABs, and the EEs are worse. Generally this has to do with dual-classing and NPCs joining the party. When stuff like that happens, all CLAB effects sometimes get run twice.

 

An easy way to deal with this is to add a permanent opcode 206 effect, protecting against itself, so that it could only ever work once. This wouldn't work with the Archer's bonuses, because they get repeated every 3 levels. But it would work fine here, since spells only need to be added to the spellbook once.

 

BUT, I think it's still not necessary. This mod adds spells by using opcode 171 "add innate ability" to add priest spells to the character. In my testing (albeit, limited testing), doing this twice with the same spell does not result in doubles in your spellbook. Each spell file will only show up once. I'm pretty sure this is how it works - the easiest way I've tested is rolling a multiclass ranger/cleric and leveling up. The ranger and cleric CLABs give duplicate access to certain spheres, but I have not seen duplicate spells as a result. (I've only tested this in the EE engine though, maybe BGT behaves differently...) That's why Jarno said:

The usual reason is that the .cre has two samelike spells is but the spells are actually different, the difference can be a minute, but it's there and they don't have the same .spl file name either. Also adding two ADD_SPELL mods that add similar spells with a different script variable, you get a lot of same like spells that are, actually different.

Third: ADD_SPELL should not be a problem here. In fact other mods using ADD_SPELL is great for me, and mods that don't use it, like SR, present a huge headache because they screw up the IDS spell table, so CLERIC_SUNSCORCH is actually Strength of Stone, and CLERIC_CAUSE_LIGHT_WOUNDS is actually Regenerate Light Wounds, etc. Install SR and IWDification, or install SR on IWDEE, and take a look in NI, you'll see that ~3-4 spells of each level have there IDS names screwed up. IDS names matter a lot for this mod. I'll explain how the mod works, so you can see why:

 

- Step 1: the mod identifies all .spl files tagged as priest spells, and ticks the usability flags for both druids and clerics, so no priests can use any priest spells. This means no priest spells will be available for memorization during character generation, and no spells will appear in your spellbook.

 

- Step 2: now, something needs to be available during character generation, so the mod takes 7 spells - just one of each level - and re-enables their use by clerics and druids. Now you can successfully roll a character.

 

- Step 3: the mod creates an effect to remove those 7 spells from your spellbook, because some kits should not get those spells. E.g. one of them is Heal... but a kit that has only minor access to the sphere of Healing should not be able to cast Heal. This removal effect has to be applied at every level, since every spell tagged as usable by clerics will get automatically added to cleric spellbooks every time they level up. The removal effect is on a 1-second delay, so every time you level up, one spell at each level will appear in your spellbook, and then disappear a second later.

 

- Step 4: the mod looks through SPELL.IDS, and compares the IDS names to a list of spells in an array. Every match gets copied, and the copy gets assigned to a sphere designated in the array. (The filename of the copy .SPL gets added to a 171 effect for that sphere.) This is why it's so important that the IDS table be accurate.

 

- Step 5: each kit that the mod is aware of has certain sphere-based .SPLs added to its CLAB. Currently this handles the vanilla kits, kits added by this mod, and kits from Divine Remix. This process means that the only spells that get added to your spellbook are the copies that have been produced by the process above. That's why there should be no doubles. But, obviously the process needs to be perfected!

 

- Step 6: the mod looks for any cleric/druid/paladin/ranger kits that have not already been handled, and assigns them a default set of spheres. This way, you avoid the problem that DRv7 had where other mod kits wouldn't be able to cast any spells.

 

- Step 7: finally, the mod looks for any .SPL or .ITM file that contains an effect identifying a particular spell resource name (opcodes 206, 318, 321, and 324), and adds a duplicate effect identifying my spell copies. So if, say, Defensive Spin protects against Free Action, it will also protect against my new copy of Free Action. If Death Ward specifically protects against the Finger of Death spell, it will now also protect against my new cloned Finger of Death spell. Etc.

 

So, you can see that there are a few possible points of failure.

- If any mod adds priest spells to the game after this one is installed, they will be skipped by step 1. This might be what is causing duplicates in Roxanne's game.

- If any mod adds divine caster kits after this one is installed, those kits will be skipped by step 6 and have no spells. These things are simply install order issues.

The solution for those two problems is to simply make sure this mod is installed after any other kits and spells. (But this should go before SCS.)

- Another possible problem is if a mod messes up spells' IDS names, since that will screw up step 4. This is much harder to deal with.

Later mod overwriting can be excluded - your mod is the last, installed on top of a full installation (just in case there are issues and I decide to uninstall the mod but not to loose my mega installand saves.)

 

With that information in hand I took a look at those double spells in a savegame

Here an example Curse - one is Sppr125 the other is D5S1125

Same for the others - SPPRxxx other is D5S1xxx

 

So - you will know if the D5S1 copies are yours - the ones I have at this level seem to be functionally identical.

Link to comment

... I think Jarno is wrong, or at least imprecise, about the CLAB effect running multiple times.

Ahh, yeah, well I forgot something. You need to use the opcode 177 to have the cumulative increases ...

Create a kit that adds a +1 to STR at level 1 via an effect using opcode 177 that has use opcode 44 in it. Or this is as close as I can remember it to be right now...

 

What I was referring in with the ADD_SPELL's is that you use a different, but very same like IDS name, one mod uses CLERIC_LIGHT_WOUNDS and another uses CLERIC_WOUNDS_LIGHT as the same original spells addon fuction and you get 2 same spells icons in the spell level, and even if you remove one of them with ShadowKeeper, the level up will restore it(for priests/druids).

 

Nothing labeled "SPPR" should be in a player's spellbook. Those are relegated for AI only.

Did you add them all to the hidespl.2da -file list ? If not, you failed to do that and thus they are still visible for the player.
Link to comment

Another question

Since my NPC is a priestess specialized in healing skills, I use her healing a party member continously as a trigger for some related banter or even quest start. For this I evaluate the other NPC having been healed by her with something like

IF

.....some NPC relevant conditions

InParty("CVSandr") >>> My healer
OR(6)
SpellCastOnMe("CVSandr",CLERIC_CURE_LIGHT_WOUNDS) >>>those now being your spell copies?
SpellCastOnMe("CVSandr",CLERIC_CURE_MEDIUM_WOUNDS)
SpellCastOnMe("CVSandr",CLERIC_CURE_CRITICAL_WOUNDS)
SpellCastOnMe("CVSandr",CLERIC_HEAL)
SpellCastOnMeRES("Spin109","CVSandr")
SpellCastOnMeRES("SanHand","CVSandr")
THEN

,,,,something done

 

Will that still work?

Link to comment

Since my NPC is a priestess specialized in healing skills, I use her healing a party member continously as a trigger for some related banter or even quest start.

 

...

 

Will that still work?

No. None of the spells in players' divine spellbooks have IDS names.

 

Oo: that raises a good point, does that sort of thing happen in the game? Like, in the Unseeing Eye quest, when you have to heal the demon: does it check whether you use something from a list of IDS names? Or does it just look for any healing effect, i.e. the use of opcode 17? Can scripts do that, check for a sell using a particular effect?

Link to comment

What I was referring in with the ADD_SPELL's is that you use a different, but very same like IDS name, one mod uses CLERIC_LIGHT_WOUNDS and another uses CLERIC_WOUNDS_LIGHT as the same original spells addon fuction and you get 2 same spells icons in the spell level, and even if you remove one of them with ShadowKeeper, the level up will restore it(for priests/druids).

Yes but that doesn't matter here. In IWDEE there is both CLERIC_GOODBERRY and CLERIC_GOODBERRIES. I render them *both* unavailable to the player. Then I pick one, make a clone of it, and give the player access to the clone spell only.

 

 

Nothing labeled "SPPR" should be in a player's spellbook. Those are relegated for AI only.

Did you add them all to the hidespl.2da -file list ? If not, you failed to do that and thus they are still visible for the player.
No. You only need to add them to hidespl.2da if the spell is otherwise usable by priests - i.e. if it is marked as a priest spell (type=1) and it is usable by clerics or druids. Here, I make all spells unusable by clerics and druids, so nothing shows up at all. Hidespl.2da is thus useless in this context.
Link to comment

Oo: that raises a good point... Does that sort of thing happen in the game? Like, in the Unseeing Eye quest, when you have to heal the demon: does it check whether you use something from a list of IDS names?

Yes, just fire up your Near Infinity and search scripts for: CLERIC_CURE_LIGHT_WOUNDS ... mod-less game has 115 hits. Bye bye this solution.
Link to comment

 

Oo: that raises a good point... Does that sort of thing happen in the game? Like, in the Unseeing Eye quest, when you have to heal the demon: does it check whether you use something from a list of IDS names?

Yes, just fire up your Near Infinity and search scripts for: CLERIC_CURE_LIGHT_WOUNDS ... mod-less game has 115 hits. Bye bye this solution.

 

The Emphatic Demon is not affected

 

 

He is a creature with 2HP out of 5 only (Has a minhp1.itm so you cannot kill him)

When he has HPGT 2 he destroys the itm and kills himself

Thus it does not matter what you cast on him, just do anything that raises his hp by 1 or more

 

Link to comment

just fire up your Near Infinity and search scripts for: CLERIC_CURE_LIGHT_WOUNDS ... mod-less game has 115 hits. Bye bye this solution.

Okay, I searched BCS files for "CLERIC_CURE" in NI, and got 607 hits. But, importantly, BALDUR.BCS is not one of them. I didn't see any area scripts either. Basically it's all AI scripts. And that's fine, because with this mod the AI *does* have the SPPR spells with IDS names. So those will be fine.

 

I suppose player scripts written that way won't work (hasspell 'CLERIC_CUTE_LIGHT_WOUNDS' will always return false) but that's honestly okay with me since I never use player AI anyway.

 

I'm not sure what to do about Roxanne's script.

 

Maybe I can use the original spl files - the early builds of the mod did. I don't fully recall now, but there was a very good reason I switched to using clones. It might have had something to do with changing some spells' levels, which breaks their IDS resrefs and could therefore break AI scripts - like SCS, most importantly.

Link to comment

 

just fire up your Near Infinity and search scripts for: CLERIC_CURE_LIGHT_WOUNDS ... mod-less game has 115 hits. Bye bye this solution.

Okay, I searched BCS files for "CLERIC_CURE" in NI, and got 607 hits. But, importantly, BALDUR.BCS is not one of them. I didn't see any area scripts either. Basically it's all AI scripts. And that's fine, because with this mod the AI *does* have the SPPR spells with IDS names. So those will be fine.

 

I suppose player scripts written that way won't work (hasspell 'CLERIC_CUTE_LIGHT_WOUNDS' will always return false) but that's honestly okay with me since I never use player AI anyway.

 

I'm not sure what to do about Roxanne's script.

 

Maybe I can use the original spl files - the early builds of the mod did. I don't fully recall now, but there was a very good reason I switched to using clones. It might have had something to do with changing some spells' levels, which breaks their IDS resrefs and could therefore break AI scripts - like SCS, most importantly.

 

I think your analysis missed the problem quite a bit and it is not the Roxanne problem but it is in a much more global sense

SpellCastOnMe(SomeofPC_PARTY,CLERIC_xxxx)

SpellCastOnMe(SomeofPC_PARTY,DRUID_xxxx)

etc (maybe also true for your sister mods affecting Wizards and Sorcerers.)

 

Loads of AI script use this SpellCastOnMe (this is what you should do a search for).

So if the script is like

IF

PC _or_rpartymember casts a spell on me

THEN

I drink a potion or use my deflection...

 

However if the triggering spell is one of yours and the AI does not recognize it, all those blocks are never called.

 

My healer script was just one specific example for a much wider issue.

Link to comment

I think your analysis missed the problem quite a bit and it is not the Roxanne problem but it is in a much more global sense

 

Loads of AI script use this SpellCastOnMe (this is what you should do a search for).

So if the script is like

IF

PC _or_rpartymember casts a spell on me

THEN

I drink a potion or use my deflection...

 

However if the triggering spell is one of yours and the AI does not recognize it, all those blocks are never called.

 

My healer script was just one specific example for a much wider issue.

I searched BG2EE for "castonme" and it basically turned up 3 new NPCs added in the EE. They seem to set local variables for when their defenses are down, stuff like that. It is almost completely unused in the base game. The only plot-connected issue I saw is that in the Tradesmeet quest with the skinchangers, it looks for whether you cast Restoration on the girl.

 

If you can point me to other AI examples representing this "much wider issue" it would be helpful. (This is useful discussion - this is why we have betas and discussion forums!)

 

I took a look at a game with SCS and it looks like DavidW may be using this to deal with contingencies. I can't tell exactly, need to play with it to be sure. I'm doing an actual run through BG now, which is really needed.

etc (maybe also true for your sister mods affecting Wizards and Sorcerers.)

If you play with any of my mods, or look at the .tp2 code or read the readmes, I very much welcome feedback. But right now we're talking about a specific technique for a specific result (a divine sphere system) used in a single mod. Heck, I don't even have a mod that affects sorcerers - the most I've done is run a COPY_KIT command to give them their own CLAB file.

Link to comment

I must say, as I think about this, it appears to be a huge problem (or, at least whatever size problem it already is) not just for this mod, but for *any*mod that adds spells. Want clerics to be able to cast Breach, or some kit have it as an innate ability? (Like Wizard Slayer Rebalancing.) Any script structured like this will fail.

 

I'm not sure what the answer is. If scripts are written to rely on this then it means mods can basically never add new spells with similar effects to existing ones, and can never change existing spells to a different level. That would be terrible.

 

An obvious solution from the other side of the coin is not to write scripts that way. Instead of looking for particular spells, look for the effects of spells. But, this depends on what script triggers are available and what would work in any given situation. A script trigger to detect *effects* instead of spells would be ideal, and would basically solve all of this. But alas, it doesn't exist. :(

Link to comment

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...