Removing A Spell From Memorized List (PART RESOLVED: Using Remove All Spells Instead)

Hi All,

I have a rare situation where I would like to remove a custom wiz/sor spell from their memorized list of spells.

I have effectively been able to remove it from their spell book (to learn again) (*), and also to remove it from there immediate spells available (F key), but it remains in their “memorized” list.

This happens if a PC of higher level is de-leveled upon entering a game, who had memorized it prior import.

Alternatively, does anybody know how I can add this custom spell to the spells that a first level wiz/sor has in their spell book from the start. (*) De-levelling automatically removes it, so I need the de-levelling without this particular spell removal if possible.

Thanks in advance. (I may not be around until Monday now.)

1 Like

what about this

// Decrement the remaining uses per day for this creature by one.
// - oCreature: creature to modify
// - nSpell: constant SPELL_*
void DecrementRemainingSpellUses(object oCreature, int nSpell);

@kevL_s

Thanks for looking.

Yes, I have tried that already, and while it removes the current spell available ( f key), it still remains in this gui.

I think there must be something about the way level reset works that cannot remove from this gui.

I’ll check back here later.

1 Like

ah, another bug ;p

It is not a bug, DecrementRemainingSpellUses, decreases the number of ready spells, does not remove them from memorization.

I also needed to fiddle with the spellbook, but in the end, scripted doesn’t have enough options, and I gave up.

isn’t memorization a ready spell?

and when it’s decremented, shouldn’t it disappear (or be decremented) from the Memorized list ?

1 Like

No.
Ready spell is a spell that is ready to cast.
A memorized spell is a spell inserted in the book slot which, once the character rests, becomes a ready spell.

2 Likes

@kevL_s
@Sean_Maxhell

Yes, this is the issue I am experiencing.

One would have thought that logically DecrementRemainingSpellUses would have also removed the memorized spell as well, as normal usage of a spell removes it from both the “f” key area and the memorized lists … oh, now there’s a thought! … maybe I can just force cast the spell upon area enter until exhausted.

I will let you know how I get on …

No good. The spell casts but is still not decremented removed from the memorized lists. Personally, I would add that if I am not using the “cheat” parameter (which I was not), then I would have thought it should remove it from the memorized listings as well as the spell ready GUI. Actually, I also just realised why this is not a bug, as we would not want the player to have to reset their spells to learn on each rest, which is what the Memorised GUI keeps track of.

Copied here at OP’s request, as it is related:

“I want to set all spell uses for any class of character to zero when they enter an area (as if they had cast all the spells they have, requiring a rest to restore them). Not really sure where to start as it’s not an area of scripting I’ve ever really played with.”

@MERP_UK

Just to clarify your needs here … It is possible to decrement all spells to be “used” (not show up in your “f” key" GUI) by using the DecrementRemainingSpellUses function in a loop for all spells. However, are you also requiring the spell to be “removed” from the memorized sheet as well?

See my image above … NOTE: There are two first level spells in the “Memorized Spells” list, but you can see that only one (Magic Missile) remains in the “F” list.

Spells can easily be removed from the “F” key list, but not so easily from the “Memorized” list. It may be that is all you are after.

NB: Even in my case, where I wanted to remove the spell from the “Memorized” list, it was purely cosmetic, as the player cannot cast this memorized spell for the PC as it is no longer set in the “F” key GUI. However, it is also now removed from their spell book too, so I wanted it removed to avoid confusion.

@kevL_s
@MERP_UK
@Sean_Maxhell

My guess is that the error may be here:

OnUpdate=‘UIListBox_OnUpdate_MemorizedSpellGrid(“SPELL_GRID”)’

As it looks like this XML call should refresh the memorized spell grid. I am looking at adding my own callback to refresh spells known here - removing any no longer known. We will see if that pans out or not.

UPDATE: I was unable to extract any data to work with and so will now try approaching from the other angle (for my case at least) of seeing if I can add “memorized” spells to the character development options (2da). Or maybe force a removal of spells some other way.

For those interested, Travus has a solution for removing all spells

So now, I will just continue working at removing specific if possible, or as I say, work backwards.

Done!

I decided to work backwards and just remove all (as per an edited version of Travus script) and add them back again for first level PCs. As this only affects first level PCs, that works for me. Thanks to Travus for saving me some time here!

It would be great to be able to remove a specific spell only, but if I really need that, I may come back and look again later, but that’s it for me now.

EDITED VERSION OF TRAVUS SCRIPT (Called just before a slightly delayed ResetCreatureLevelForXP function to allow changes to take effect.)

///////////////////////////////////////////////////////////////////////////////
// REMOVE MEMORIZED SPELLS (IN PREPARATION OF ANY RESETS)
// AN ADAPTION OF A SCRIPT BY TRAVUS
///////////////////////////////////////////////////////////////////////////////
void RemoveAllMemorized(object oPC, int iAllParty = 0);
void RemoveAllMemorized(object oPC, int iAllParty = 0)
{
	object oFM = GetFirstFactionMember(oPC, FALSE);
	
	effect eEffect;
	int n, nReduce;
		
	while(oFM != OBJECT_INVALID)
	{
		if(oFM == oPC || iAllParty)
		{		
			for (n = ABILITY_INTELLIGENCE; n <= ABILITY_CHARISMA; n++)
			{
				nReduce = GetAbilityScore(oFM, n) - 9;
				
				if (nReduce < 1) nReduce = 0;
				
				eEffect = EffectAbilityDecrease(n, nReduce);
				ApplyEffectToObject(DURATION_TYPE_TEMPORARY, eEffect, oFM, 0.1f);
			}
		}
		
		oFM = GetNextFactionMember(oPC, FALSE);
	}
}
4 Likes

Im sorry I couldn’t have engaged more after posting, work beckoned!

I’m so pleased we have both found a solution and can now push on! Really nice work :grin:

2 Likes