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

#26
MrZork

MrZork
  • Members
  • 938 messages

Here is a saved game. Fresh start of the NWN OC prelude. You can see (even in the quickbar) that this sorcerer has no casts of Protection from Evil, even though he has Mage Armor. As mentioned before, the script above will show the issue with GetHasSpell().

 

As noted, this only seems to be an issue when the NWNCX extension is loaded.



#27
Shadooow

Shadooow
  • Members
  • 4 465 messages

Here is a saved game. Fresh start of the NWN OC prelude. You can see (even in the quickbar) that this sorcerer has no casts of Protection from Evil, even though he has Mage Armor. As mentioned before, the script above will show the issue with GetHasSpell().

 

As noted, this only seems to be an issue when the NWNCX extension is loaded.

Okay. Found out why. My new code is reading values from 2da and subspells doesn't have spell levels provided in 2da. This should be easy to fix.

 

Also GetHasSpell was fixed. I don't know how, but in my newest version it works correctly while in the older version that function returned 0 as you say.



#28
MrZork

MrZork
  • Members
  • 938 messages

Excellent! :)



#29
Shadooow

Shadooow
  • Members
  • 4 465 messages

here is todays version for testing

- fixed the epic spells and subradial spells

- reworked the fix for losing spell uses

+ minor optimalizations

 

however it is still not working properly with polymorphing, not only it decreases spell uses upon polymorph, but also after unpolymorph and manual reequipping the item, the spell uses are decreased then the item is equipped (which makes no sense to me, will be hard to fix)

 

anyway, if someone wants to test this here it is



#30
MrZork

MrZork
  • Members
  • 938 messages

Thank you for that patch. I just had a chance to plunk in the new DLL (modified 2016/06/01 4:25 PM PDT, size 109,056 bytes) and to do a fresh test with NWNCX with my mongrel sorcerer druid. But, I am getting mostly similar behavior as with the previous version I tested: shifting (using the druid's wildshape) seems to work fine and spell loss hysteresis from equipping/unequipping is gone. And, spells with subspells are working. But, epic spells still aren't showing in the radial menu and GetHasSpell() is returning all 0s.



#31
Shadooow

Shadooow
  • Members
  • 4 465 messages

Thank you for that patch. I just had a chance to plunk in the new DLL (modified 2016/06/01 4:25 PM PDT, size 109,056 bytes) and to do a fresh test with NWNCX with my mongrel sorcerer druid. But, I am getting mostly similar behavior as with the previous version I tested: shifting (using the druid's wildshape) seems to work fine and spell loss hysteresis from equipping/unequipping is gone. And, spells with subspells are working. But, epic spells still aren't showing in the radial menu and GetHasSpell() is returning all 0s.

could you send me the savegame with a character you are testing this with? Since I cant reproduce this, maybe its character related.

 

EDIT: found the issue with GetHasSpell - it worked with sorcerer but not with wizard, still even on wizard epic spells shows to me properly

 

are you trying this in singleplayer or multiplayer?



#32
MrZork

MrZork
  • Members
  • 938 messages

Here is another save (the archive has the same file name). Again, the NWN OC Prelude, but with my druid sorcerer. You can see that his Epic Mage Armor isn't in the radial menu when run with NWNCX, though it's in his character sheet feat list.
 



#33
Shadooow

Shadooow
  • Members
  • 4 465 messages

Here is another save (the archive has the same file name). Again, the NWN OC Prelude, but with my druid sorcerer. You can see that his Epic Mage Armor isn't in the radial menu when run with NWNCX, though it's in his character sheet feat list.
 

in the save you sent me the character doesnt have epic mage armor

if i level up a take it it shows for me, tested with the version in the link above

 

can you clarify this? :)



#34
MrZork

MrZork
  • Members
  • 938 messages

Sorry about that. I clicked an earlier version of my test toon when I started the module. The archive linked above now has a save with the correct toon in it. Also, the quick script for testing GetHasSpell() is also in the archive.



#35
Shadooow

Shadooow
  • Members
  • 4 465 messages

I still see the epic spells. Try temporarily disable override and patch haks. Other than that I have no clue why we get different results with same savegame and plugin version.

 

I fixed GetHasSpell function, however since my current development version is a mess (still trying to fix losing spell uses when polymorphing which is totally messed up) I won't upload it today.



#36
MrZork

MrZork
  • Members
  • 938 messages

I just reverted my override folder to the Bioware default. I am getting the same results. The Prelude doesn't use any normal HAKs. Is there something else I should disable in terms of patch HAKs?

 

I look forward to the GetHasSpell fix, since that is preventing me from running an SP module with a quick buffing rod.

 

BTW, as far as I can tell, polymorph is working for me. I am not losing spells when I shift.



#37
Shadooow

Shadooow
  • Members
  • 4 465 messages

I just reverted my override folder to the Bioware default. I am getting the same results. The Prelude doesn't use any normal HAKs. Is there something else I should disable in terms of patch HAKs?

 

I look forward to the GetHasSpell fix, since that is preventing me from running an SP module with a quick buffing rod.

 

BTW, as far as I can tell, polymorph is working for me. I am not losing spells when I shift.

The only thing that comes into my mind is log. Check in logs/nwncx_patch.txt if there are these lines:

o Initializing classes.2da.
o  classes.2da loaded.

The spell uses works when polymorphing, however after once polymorphed its totally bugged and re-equipping the item (that wasn't re/equipped before polymorh) causes weird behavior.



#38
Shadooow

Shadooow
  • Members
  • 4 465 messages

Hmm I think I understand now why the spontaneous casters are losing spell uses everytime they lose charisma ability effect bonus or itemproperty.

 

Its extremely complicated to correctly determine when the caster should lose spell uses because of all these effects:

- ability bonus itemproperty

- ability decrease itemproperty

- ability bonus effect

- ability decrease effect

- curse effect

 

When everything is combined togeher its impossible to determine when the spell uses should be lost and when not and Im really lost in it as well.

 

For example, lets say I have +8 charisma armor, and +12 charisma bonus from some spell ability. Then I will get -6 charisma ability penalty from somewhere.

At this moment I still have +12 bonus so spell uses should not be affected, but then +12 ability bonus will run out and I will drop to +2 and should lose spell uses. However lets say I get +12 bonus again and again lose it. Well there I should not lose spell uses because its the same ability decrease over there.... meh its so complicated...



#39
KMdS!

KMdS!
  • Members
  • 189 messages

I implemented a runestone workaround where the stones keep going through rests and resets and no effects are lost....I use a playerskinn to set an ability binus property while the stones are in effect and removes the ability bonus when not.  Did a similar effect with pnp rings of wizard. No change to to bonus slots ever. Even during resets as I have tag based scripts and items in inventory are processed on first enter into a sever before any game calcs occur.



#40
MrZork

MrZork
  • Members
  • 938 messages

KMdS!, that approach sounds good for any effect that should last through rests. The problem here is hysteresis when the effects that affect the number of spell slots should not always be in effect, such as when the toon removes an item with a CHA bonus or bonus spell slot.



#41
Shadooow

Shadooow
  • Members
  • 4 465 messages

For example, lets say I have +8 charisma armor, and +12 charisma bonus from some spell ability. Then I will get -6 charisma ability penalty from somewhere.

At this moment I still have +12 bonus so spell uses should not be affected, but then +12 ability bonus will run out and I will drop to +2 and should lose spell uses. However lets say I get +12 bonus again and again lose it. Well there I should not lose spell uses because its the same ability decrease over there.... meh its so complicated...

Similarly, should charisma decrease itemproperty from same item reduce spell uses again and again when re-equipped?



#42
MrZork

MrZork
  • Members
  • 938 messages

The only thing that comes into my mind is log. Check in logs/nwncx_patch.txt if there are these lines:

o Initializing classes.2da.
o  classes.2da loaded.

 
Those lines are in the log. The nwncx_patch.txt below is for starting the game and loading the save posted above. Then the PC rests, shifts to badger form, unshifts, unequips and reequips his +8 CHA gear twice, rests, unequips and reequips his +8 CHA gear twice, then shifts and unshifts again, then finally unequips and reequips his +8 CHA gear twice.
Spoiler


#43
MrZork

MrZork
  • Members
  • 938 messages
Regarding how to compute the spell uses, IMO it should go like this: Assume that a function exists (may need to be written) that computes the total number of spell slots for a character at a given spell level, accounting for current CHA, caster class level, and bonus slots from items with the bonus spell slot property. (Level drain effect shouldn't come into it.) Let's call that function GetSpontaneousSlots(object oChar, int nSpellLevel, int nClass). Then, there are (at least) two cases to use that function.

1) At completion of rest, set the available spell slots at each level to the result of GetSpontaneousSlots.

2) When there is a net change to CHA or bonus slots (e.g. due to gear swap or some effect that changes CHA), check that the available spell slots at each level is not greater than the current value of GetSpontaneousSlots.

I think that approach takes care of changes to CHA or bonus slots without the hysteresis problem.
  • meaglyn aime ceci

#44
KMdS!

KMdS!
  • Members
  • 189 messages

KMdS!, that approach sounds good for any effect that should last through rests. The problem here is hysteresis when the effects that affect the number of spell slots should not always be in effect, such as when the toon removes an item with a CHA bonus or bonus spell slot.

This is programmed for, unequip...drop....etc....affects effect and all resulting effect effects. I always try to cover all bases.



#45
MrZork

MrZork
  • Members
  • 938 messages

KMdS!, I may not be understanding your approach completely. It was sounding like you have implemented a system where the bonus slots never go away. I was just pointing out that there are times when bonus slots should go away. For instance, if a toon with a natural charisma of 22 equips +8 CHA gear and rests, he gets a bonus slot at every spell level (compared to no gear). But, if he removes that gear, he should not still have access to as many casts as he did when he had it equipped. IMO, he shouldn't have the benefits of extra CHA from gear if he isn't wearing the gear. That's why I was saying that your approach sounds good for CHA bonuses that aren't dependent on equipped gear (like runes), but I am not sure how it works for gear bonus CHA.

 

As Shadooow notes, it's a little complicated. The character shouldn't keep CHA bonuses for equipped gear when the gear is not equipped, but he also shouldn't lose slots just for removing gear. The latter is what the default (Bioware) system does and that leads to the hysteresis, where removing gear several times means he eventually has no available slots, even if he has never fallen below his base CHA and never cast any spells. He should only lose available slots if the gear removal takes leaves him with more available slots than he should have at his current CHA. The approach I outline in my last post is a pretty straightfoward one that I think avoids that issue. But, I don't know how to use it in place of Bioware's default system. Shadooow's NWNCX approach seems pretty close to me, but apparently there may still be a couple of issues to sort.



#46
KMdS!

KMdS!
  • Members
  • 189 messages

KMdS!, I may not be understanding your approach completely. It was sounding like you have implemented a system where the bonus slots never go away. I was just pointing out that there are times when bonus slots should go away. For instance, if a toon with a natural charisma of 22 equips +8 CHA gear and rests, he gets a bonus slot at every spell level (compared to no gear). But, if he removes that gear, he should not still have access to as many casts as he did when he had it equipped. IMO, he shouldn't have the benefits of extra CHA from gear if he isn't wearing the gear. That's why I was saying that your approach sounds good for CHA bonuses that aren't dependent on equipped gear (like runes), but I am not sure how it works for gear bonus CHA.

The slots go away when they are suppose to...it is exactly as you would like it to be.  As to the hysteresis, I may actually hve come accross this a while ago and found a way around it....will check tonight...

 

Funny thing is that it involved the creation of a rod of Splendor, per pnp...a CHA item



#47
Shadooow

Shadooow
  • Members
  • 4 465 messages

Regarding how to compute the spell uses, IMO it should go like this: Assume that a function exists (may need to be written) that computes the total number of spell slots for a character at a given spell level, accounting for current CHA, caster class level, and bonus slots from items with the bonus spell slot property. (Level drain effect shouldn't come into it.) Let's call that function GetSpontaneousSlots(object oChar, int nSpellLevel, int nClass). Then, there are (at least) two cases to use that function.

1) At completion of rest, set the available spell slots at each level to the result of GetSpontaneousSlots.

2) When there is a net change to CHA or bonus slots (e.g. due to gear swap or some effect that changes CHA), check that the available spell slots at each level is not greater than the current value of GetSpontaneousSlots.

I think that approach takes care of changes to CHA or bonus slots without the hysteresis problem.

After several hours of debugging, printing player stats before and after each function I understood where this is coded and how this is coded.

 

I rescripted the function within nwnx with my own code and first I did it so it match vanilla and tested if I get same results which matched. Then I tried to fix the issue in there (previously I was blocking this function instead).

 

Out of curiosity it looks like this:

 

 

void __fastcall CNWSCreatureStats__AdjustSpellUsesPerDay_Hook(CNWSCreatureStats *pThis, void*)
{
    for(unsigned char cls_pos=0;cls_pos<3;cls_pos++)
    {
        if(cls_cast_type[pThis->cs_classes[cls_pos].cl_class] & CAST_TYPE_SPONTANEOUS)
        {
            for(unsigned char spell_lvl=0;spell_lvl<10;spell_lvl++)
            {
                unsigned char spell_gain = pThis->GetSpellGainWithBonus(cls_pos,spell_lvl);
                unsigned char spell_max = pThis->cs_classes[cls_pos].cl_spells_max[spell_lvl];
                /*if(spell_gain > spell_max)//this is a reason why its bugged
                {
                    //pThis->cs_classes[cls_pos].cl_spells_max[spell_lvl] = spell_gain;
                }*/
                if(spell_gain < spell_max)
                {
                    pThis->cs_classes[cls_pos].cl_spells_max[spell_lvl] = spell_gain;
                    pThis->cs_classes[cls_pos].cl_spells_left[spell_lvl]-= spell_max-spell_gain;
                }
            }
        }
    }
}

As you can see vanilla uses a "max_spells" structure to store the maximum spells available and this is changed everytime charisma ability is changed. The problem is it increases the max_spells with charisma bonuses even when the spell uses are not increased (as we know). So I removed this code and it looks like it works as it should now. No issues at all.

 

One weird thing is that when I applied charisma decrease on my character and he lost spell uses, after this decrease was removed, unequipping the armor with charisma bonus (of same value or lower as was decrease) didn't reduce spell uses. This is a bit weird on the first look but I think its correct behavior. Player already lost spel uses for losing 8charisma, and even this came from different source, losing 8charisma again should not reduce spell uses.

 

Anyway, here is the new version for download.

 

It fixes the GetHasSpell issue as well.

 

I couldn't reproduce the missing epic spells radial and also in your log there were these lines:

 

o CNWCCreatureStats__GetSpellUsesLeft_Hook: new calculation doesnt match with vanilla! cls_id 9, spell_id 344, domain_lvl: 0, metamagic: 0, oldval 8, newval: 0

which also didn't happen to me with savegame you provided. (this debug message indicates the subspells spell uses calculation is still wrong).

 

So I hope this gets fixed with new version, let me know.


  • MrZork aime ceci

#48
MrZork

MrZork
  • Members
  • 938 messages

Shadooow, thanks for that update. I did a quick bit of testing and it looks much improved. The epic spell (EMA) is now appearing in the radial menu and GetHasSpell() is returning the correct results.

 

Two potential issues are still there, both seem to be related to shifting. First, if I rest with my +8 CHA gear equipped and then remove the gear, I lose spells and don't get them back, which is perfect. But, if I rest with the gear, then shift, then unshift, then remove the gear, I don't lose the spells, which I should. I wonder if this has something to do with how with your scripted shifting fix interacts with the new mechanics?

 

Second, the toon doesn't have access to epic spells from the quickbar when shifted. Since they are feats like bard song or summon familiar, I think he should.

 

Anyway, thanks, this is looking good. :-)



#49
Shadooow

Shadooow
  • Members
  • 4 465 messages

 

First, if I rest with my +8 CHA gear equipped and then remove the gear, I lose spells and don't get them back, which is perfect. But, if I rest with the gear, then shift, then unshift, then remove the gear, I don't lose the spells, which I should. I wonder if this has something to do with how with your scripted shifting fix interacts with the new mechanics?

I tested it with your character you sent me. Its not instant, its with a bit delay but the spell uses are lowered for me. Can you clarify this?



#50
Shadooow

Shadooow
  • Members
  • 4 465 messages
Secoon doesn't have access to epic spells from the quickbar when shifted. Since they are feats like bard song or summon familiar, I think he should.

This is afaik vanilla behavior.