DecrementRemainingSpellUses(object, int)
Decrease the number of spell uses of a particular spell for a given creature.
void DecrementRemainingSpellUses(
object oCreature,
int nSpell
);
Parameters
- oCreature
- Creature to decrement the remaining spell uses of a particular spell.
- nSpell
- SPELL_*
Description
Decreases the remaining number of spell uses per day for a creature by one. A creature must have at least one spell use for this function to work. To make this work correctly, it should be used with GetHasSpell().
nSpell doesn't have to be a spell. It can be any entry in the spells.2da file.
If they do not have any castings of nSpell memorized, then nothing will happen.
Note that this has to be added into a loop, with GetHasSpell(), to remove all the available castings of nSpell.
Remarks
This is most useful for removing uses of spells that, for example, get used up in special ways (sacrificing spells to power an item for example).
EE has added a few ways to increment spells - mainly ReadySpellLevel and SetMemorizedSpellReady - or you can use ForceRest (also increases HP/removes effects).
Note: There is no way with this function to specify which classes spells go first. The order is the class order taken, eg a Sorcerer 5 / Wizard 5 uses the Sorcerer sources of spells first. You can instead use ReadySpellLevel and SetMemorizedSpellReady.
Cannot decrement spell that creature have memorized but shouldn't be able to use, for example if creature has a sixth level memorized under Spells tab but has caster ability only 15 or less, this function fails. Same spell given as Special ability is decremented properly.
Example
// Decrement their remaining magic missile uses by 1, in a
// conversation.
// * Note: A conversation conditional script should check if they
// have magic missile memorized to start with, before this fires.
void main()
{
// Get the PC
object oPC = GetPCSpeaker();
// Decrement the spell uses
DecrementRemainingSpellUses(oPC, SPELL_MAGIC_MISSILE);
}
See Also
| constants: | SPELL_* Constants |
author: Charles Feduke, editor: Jasperre, additional contributor(s): Justin Koch, Jasperre