Aller au contenu

Photo

Fix for spontaneous caster spell loss when equipping/unequipping CHA gear ?


  • Veuillez vous connecter pour répondre
60 réponses à ce sujet

#1
MrZork

MrZork
  • Members
  • 938 messages

My question: Is there a straightforward fix for this unfortunate behavior where unequipping and then reequipping CHA gear results in a net loss of spells for a sorcerer or bard? Can this be addressed without NWNX?

Some background for those who aren't familiar with this issue: Let's say a level 20 sorcerer with 23 natural charisma and a +7 charisma cloak rests. He will have the following spells per day at each level

spell level	1	2	3	4	5	6	7	8	9
spells/day	9	9	8	8	8	8	7	7	7

Note that the cloak has given him one bonus spell use at each level. If he were to remove the cloak, he would be down one spell at each level, and, if he puts the cloak back on, he doesn't get the slots back again until he re-rests. Seems fair: The cloak gave him some extra spells, he lost them when he took it off, and he doesn't get them back until he rests again with the cloak on. That's pretty much the same way if would work with a wizard doing something similar with INT gear or a divine caster doing the same with WIS gear. All is well.

But, let's say that same sorcerer removes the cloak again and then puts it back on another time. He loses a spell at each level again. If he were to do this several times, he would have no spells available, even though he has not cast a spell and his charisma has never fallen below 23. (Same issue for bards.)

Probably most players who play casting bards or sorcerers who ever have to switch gear know about this. And, it's for this reason that it's often counterproductive for such toons to use potions of Eagle's Splendor or for lower-level casters to even cast the spell, if they are in a rest-limited module and there is any possibility of being dispelled. And, it's obviously a nightmare for anyone interested in building a toon that polymorphs (via spell or druid/shifter levels).

 

(Same issue with direct spell slot granting gear, BTW.)

 

For non-spontaneous casters, the spells lost when unequipping gear come first from the slots "at the end" of the caster's available slots, so it's possible to arrange one's spellbook so that swapping gear only clears spells that have already been cast.

 

Back to my question: Is there a nice workaround for this? I have considered an OnPlayerUnequip script that temporarily buffs CHA whenever the toon removes a CHA-buffing item and remains until either he casts or rests. But, even that incomplete remedy doesn't actually work, since I think gear buffs go away before the event script fires. And there are other potential exploit issues. And, I don't know of a scriptable way to restore spell uses per day.



#2
Shadooow

Shadooow
  • Members
  • 4 465 messages

And did you try community patch 1.72beta+nwnx_patch/nwncx_patch?

 

I am not sure if it solves this issue exactly as its something else than losing spellslots for prepared sphelpahave sters but it could have some results.



#3
KMdS!

KMdS!
  • Members
  • 189 messages

Not that I am aware of, bonus spell slots are adjusted the instant there is a change to the ability score. even if you did the work around, ther would be an instant that the ability score would be modified.....no go, sorry. Unless you can find a way to do the buff BEFORE they remove the item....ya right, :)  :)  :) l.



#4
MrZork

MrZork
  • Members
  • 938 messages

Shadooow, I have not tried the beta. I was first trying for a non-NWNX approach. That may be an approach, though. The reality is it seems the way Bioware hardcoded spontaneous casters' spell slots is a little lazy. My guess is that they are storing only the remaining slots per level instead of the total available slots and the remaining slots. When a slot is lost, they just decrement the remaining slots, instead of recalculating the total available slots and only decrementing the remaining slots if there are more remaining slots than total slots. Would NWNX allow a hook that could replace that process?

 

KMdS!, at first I was thinking that the easiest work-around I have thought of is one where there is a compensating constant extraordinary CHA bonus applied when resting is done that goes away (perhaps via spellhook) for a round when the toon casts. That way, it would not apply to the DCs of spells he is casting, which is important. (If the latter weren't important, then simply applying a capped buff at all times between rests would probably work.) However, that presents the same problem as the original condition. When the buff is removed, the spell slots go poof.



#5
Shadooow

Shadooow
  • Members
  • 4 465 messages

Shadooow, I have not tried the beta. I was first trying for a non-NWNX approach. That may be an approach, though. The reality is it seems the way Bioware hardcoded spontaneous casters' spell slots is a little lazy. My guess is that they are storing only the remaining slots per level instead of the total available slots and the remaining slots. When a slot is lost, they just decrement the remaining slots, instead of recalculating the total available slots and only decrementing the remaining slots if there are more remaining slots than total slots. Would NWNX allow a hook that could replace that process?

Well my patch combines both non nwnx and nwnx solution. Basically nwnx handles bonus spell slots, while nwscript code handles losing slots from ability loss.

 

However that is only in polymorphing. So it will definitely not fix the continuous losing of spell slots upon re-equipping charisma cloak (which is something I wasn't aware of and might be able to fix it but this will definitely need nwnx).

 

Anyway the non-nwnx solution consists of merging all ability bonuses as effect bonus and removing this effect bonus after unpolymorph. I strongly advise to try my patch because if you try to code this from scratch you will soon find out several issues that you need to workaround first.



#6
WhiZard

WhiZard
  • Members
  • 1 204 messages

The reality is it seems the way Bioware hardcoded spontaneous casters' spell slots is a little lazy. My guess is that they are storing only the remaining slots per level instead of the total available slots and the remaining slots. When a slot is lost, they just decrement the remaining slots, instead of recalculating the total available slots and only decrementing the remaining slots if there are more remaining slots than total slots.

 

The reasoning behind this approach is that NPC spontaneous casters actually get an increment to spell slots when charisma is increased without the need to rest.  So PCs never get the increment but will suffer the decrement as if they had been given the increment.



#7
MrZork

MrZork
  • Members
  • 938 messages

Shadooow, if the beta handles the CHA loss from items during a polymorph properly, then it should be able to handle item property swaps, since the polymorph process involves item swaps (from the individual items to the skin or to a scripted effect). I guess that is the test: Does the CPP allow a spontaneous caster with a CHA buff from an item that merges to polymorph and unpolymorph without losing spells? BTW, I can tell you that adding a CHA buff to an effect before polymorph and then removing the effect after the polymorph is ended will not likely fix this by itself. (It's a solid approach for other casters, though.) The way the bookkeeping is done for spontaneous slots needs to be changed or the slots will still be lost when the effect disappears.

 

Thanks, WhiZard, I had not known that was an issue with NPC spontaneous casters. It sort of reinforces my view that Bioware should have done this by tracking both remaining slots and total slots. That way, when an NPC (or PC) gets a post-rest boost to slots, the total slots could be incremented without incrementing the remaining slots.



#8
Shadooow

Shadooow
  • Members
  • 4 465 messages

I don't understand why you are asking for a fix/solution when you don't even want to try the offered solution.



#9
WhiZard

WhiZard
  • Members
  • 1 204 messages

Shadooow, you seem to be misunderstanding something.  You already flat out claimed that your patch was not a solution to MrZork's issue and then seem to claim the opposite:

 

My question: Is there a straightforward fix for this unfortunate behavior where unequipping and then reequipping CHA gear results in a net loss of spells for a sorcerer or bard? Can this be addressed without NWNX?

 

 

However that is only in polymorphing. So it will definitely not fix the continuous losing of spell slots upon re-equipping charisma cloak (which is something I wasn't aware of and might be able to fix it but this will definitely need nwnx).

 

 

I don't understand why you are asking for a fix/solution when you don't even want to try the offered solution.

 

Are you trying to enlist MrZork to do Beta Testing for your patch?



#10
Shadooow

Shadooow
  • Members
  • 4 465 messages

I was reacting to this:

BTW, I can tell you that adding a CHA buff to an effect before polymorph and then removing the effect after the polymorph is ended will not likely fix this by itself.

There are two or maybe three separate issues. I already explained there is no fix I know of for the core issue MrZork asks for, but there is a fix for similar issue when polymorhing and I described how my method works. Thats because if this works, theoretically it could be used to fix the main issue here.

 

Afaik, my method works for spontaneous casters during polymorph as well and as a developer it is not my job to prove it. I have better things to do, maybe to fix the first issue mentioned by MrZork.



#11
MrZork

MrZork
  • Members
  • 938 messages

Shadooow, I am happy to test the beta CPP and see if the polymorph fix works for spontaneous casters. What I was trying to say above is that a scripted approach that adds a +CHA effect before the polymorph effect is started and then removes it after will likely not work for casters because the process will still involve momentarily raising and lowering the toon's CHA and, unless the underlying mechanics are changed, I suspect this will still result in lost spells.

 

(BTW, the link at the top of the beta page on the Vault doesn't link to the newest CPP beta, assuming that the newest is patch172_beta13.7z.)



#12
Shadooow

Shadooow
  • Members
  • 4 465 messages

Shadooow, I am happy to test the beta CPP and see if the polymorph fix works for spontaneous casters. What I was trying to say above is that a scripted approach that adds a +CHA effect before the polymorph effect is started and then removes it after will likely not work for casters because the process will still involve momentarily raising and lowering the toon's CHA and, unless the underlying mechanics are changed, I suspect this will still result in lost spells.

 

(BTW, the link at the top of the beta page on the Vault doesn't link to the newest CPP beta, assuming that the newest is patch172_beta13.7z.)

Well as far as I remember my scripted solution works on sorc/bard spells as well but I all of this was made for prepared casters mainly as those loses the whole spellslot and they must re-memorize spells after each polymorph. So its possible I am wrong, you need to try it.

 

If it will work, the same solution could theoretically be used to fix losing spellslots when re-equipping item manuallly, although this is probably not feasible since it would basically consist of keeping charisma bonus even when item was unequipped (this would have sense probably only when it would be temporary - ie. 4 rounds or so).

 

And thanks for headsup, yes 13is last I will fix the link.



#13
MrZork

MrZork
  • Members
  • 938 messages

So, initial tests seem to confirm what I was thinking. I grabbed a sorcerer druid toon and equipped him with a +8 CHA robe and rested. When shifting, it's clear that a +8 CHA effect was applied to him (bumping his bonus CHA temporarily to +12) and then removed. During both the shift and unshift, he lost spells at the levels that one would expect in going from a +12 bonus to +8. If these initial tests are indicative, the problem persists.

 

BTW, this is with CPP 1.71 and the rev 13 beta patch and starting with NWNCX_Loader.exe. I also tried it starting with the normal (non-NWNCX) loader with the same results.



#14
Shadooow

Shadooow
  • Members
  • 4 465 messages


#15
Shadooow

Shadooow
  • Members
  • 4 465 messages

I think I managed to fix it.

 

Here is nwncx_patch with this fix for testing.

 

I haven't test it very thoroughly. I don't know how it will work without the polymorph code from CPP and I don't know if it doesn't have any side effects. But so far it looks good. If you can check it out...


  • MrZork aime ceci

#16
MrZork

MrZork
  • Members
  • 938 messages

I have just run a few tests and it is looking good! :)

 

What approach did you take? Did you add an NWNX function?

 

Excellent!  :D

 

(BTW, is there some issue with NWNX and epic spells not showing up in the radial menu? I am seeing that and duplicated metamagic.)



#17
Shadooow

Shadooow
  • Members
  • 4 465 messages

I have just run a few tests and it is looking good! :)

 

What approach did you take? Did you add an NWNX function?

 

Excellent!  :D

 

(BTW, is there some issue with NWNX and epic spells not showing up in the radial menu? I am seeing that and duplicated metamagic.)

Its all automatic within NWNX. But I think it wil not fix losing spelluses in polymorph without my workaroud with ability increase effect in CPP. You can try it - to uninstall CPP you just need to restore original xp2patch.key (which can be download on CPP page). The plugin can be used without CPP, it just lose som of the extra funcionalities.

 

Basically in engine, I added special variable to the each charisma effect after resting and then checked for that variable everytime an effect try to decrease spells uses. If the variable is 1 then I let the original code to execute and set variable to 0, if variable isn't 1 then I cancel it. Thats for itemproperties. As for effects, I disabled that everytime.

 

What you mean exactly? Might be an issue caused by other features, theres too many of them atm and its hard to test it all. Anyway can you describe the issue more? How can I reproduce it?



#18
MrZork

MrZork
  • Members
  • 938 messages

I am fine leaving the CPP beta installed atm.
 
So, I think I am still getting the bonus slots from the item, even when I have rested without it on and don't re-equip it. In other words, my level 20 sorcerer with 25 CHA rests with his +8 CHA gear and wakes with the following spells slots available.

spell level	1	2	3	4	5	6	7	8	9
spells/day	9	9	9	8	8	8	8	7	7

Then, when he removes the gear and rests again, he still has the above slots available, though he should have lost one from each level.
 
Regarding the epic spells in the radial menu, I mean the following is what shows up when I go to where epic spells would be in the radial menu, if I load with NWNCX. It doesn't happen if I load with CPP, but not using the NWNCX loader. I got the screenshot to include the feat as well.
MissingEpicSpells.jpg
 



#19
Shadooow

Shadooow
  • Members
  • 4 465 messages

I am fine leaving the CPP beta installed atm.
 
So, I think I am still getting the bonus slots from the item, even when I have rested without it on and don't re-equip it. In other words, my level 20 sorcerer with 25 CHA rests with his +8 CHA gear and wakes with the following spells slots available.

spell level	1	2	3	4	5	6	7	8	9
spells/day	9	9	9	8	8	8	8	7	7

Then, when he removes the gear and rests again, he still has the above slots available, though he should have lost one from each level.

Hmm. I can't reproduce this. Maybe your issue is caused by loading a savegame? Note that the method I used to fix this rely on resting with this nwncx_patch plugin, so if you load old savegame, untill you rest it will not work correctly.

 

What I tried.

 

Sorc 38 pal 1 monk 1 with  30base charisma, slots 7/7/7/8/8/8/8/9/9/6

 

equip armor with +8charisma - no change in slots

rest, slots 8/8/8/9/9/9/9/10/10/6

unequip armor, slots 7/7/7/8/8/8/8/9/9/6

reequip armor and unequip again, slots 7/7/7/8/8/8/8/9/9/6

apply +8charisma bonus and remove it 6sec later, slots 7/7/7/8/8/8/8/9/9/6

rest without armor, slots 7/7/7/8/8/8/8/9/9/6

equip armor, 7/7/7/8/8/8/8/9/9/6

 

etc. it was consistent, only time it didn't work was when I loaded older save game where obviously the effects are not setup properly so game thinks it already reduced the spelluses for them. I am not sure if this can be fixed though...

 

BTW found the issue with epic spells and fixed it thanks.


  • MrZork et AndrueD aiment ceci

#20
Shadooow

Shadooow
  • Members
  • 4 465 messages

I found that the same problem as with old savegame happens when reloading a game (and very possibly when relogging in multiplayer too) so I reworked it and now it relies on variable on item instead of in effect (since effect are deleted and recreated).

 

Still it will not work correctly when loading savegame in which the player didn't rest with nwncx_patch.

 

I am not sure whether its worthwhile to try avoid that or not. It would be not so hard to provide this kind of backwards compatibility and make it so if the variable is not on item, the spell uses will be decreased as in vanilla over and over again when reequiiping until player rests. So is it?


  • MrZork aime ceci

#21
AndrueD

AndrueD
  • Members
  • 134 messages

Sweet werk, shadooow  ;)  Test like u did nd work perfect!



#22
MrZork

MrZork
  • Members
  • 938 messages

Shadooow, good call on the saved game. It looks like what I saw before is not a problem from a fresh module or from the saved game if I cycle through a rest first. :-)

 

Also, did you post the change that fixes the NWNCX issue with epic spells? I would like to check if an issue I am seeing with GetHasSpell is also fixed.

 

BTW, great work here. I started this thread without any great hope that there was nice way to address this.



#23
Shadooow

Shadooow
  • Members
  • 4 465 messages

Shadooow, good call on the saved game. It looks like what I saw before is not a problem from a fresh module or from the saved game if I cycle through a rest first. :-)

 

Also, did you post the change that fixes the NWNCX issue with epic spells? I would like to check if an issue I am seeing with GetHasSpell is also fixed.

 

BTW, great work here. I started this thread without any great hope that there was nice way to address this.

not yet, i discovered a new problem where if I polymorph and item gets unequipped automatically the spell uses are lowered anyway - once I fix this I can post new version

 

whats the problem with GetHasSpell?



#24
MrZork

MrZork
  • Members
  • 938 messages

whats the problem with GetHasSpell?

 

It's also related to NWNCX somehow. I have a script that checks GetHasSpell for a buffing rod. It seems to be returning 0, even when there are casts left. Actually, I just tested again with a wizard toon and the same thing happened, so it's not specific to spontaneous casters. Here is a quick script that tests the same thing that can be run from the console:

// TestGetHasSpell.nss

void main()
    {
    object oPC = GetFirstPC();
    int nHasSpell = GetHasSpell(SPELL_MAGE_ARMOR, oPC);
    // Do a quick check for a common spell
    SendMessageToPC(oPC, "Checking GetHasSpell for Mage Armor (spell ID "
        + IntToString(SPELL_MAGE_ARMOR) + ") returns "
        + IntToString(nHasSpell) + ".");
    }

When I start using NWNCX_Loader.exe, I always get (for sorcerer or wizard, both of whom have just rested)

    Checking GetHasSpell for Mage Armor (spell ID 102) returns 0.

Which is not correct (he can cast the spell right then). When I run from nwnmain.exe I get

    Checking GetHasSpell for Mage Armor (spell ID 102) returns 9.

for the sorcerer (the script returns the right number for the wizard as well).

 

And, there may be a related issue. Doing a little more testing and I think there may be an issue with spells that have subspells. When my sorcercer tries to cast one of the Protection from Alignment subspells or one of the Shadow Conjuration subspells, he gets a message saying, "No uses or preparations left for that spell." I also tested that with a wizard and got the same result. :huh:



#25
Shadooow

Shadooow
  • Members
  • 4 465 messages

my plugin hooks a awful lot of spellcasting functions to provide the possibility of makign custom spellcaster

 

unless you get this bug without nwncx_patch its definitely a bug in my code

 

can you send me a savegame ? would help me speed the bug hunt proccess