Difference between revisions of "DecrementRemainingSpellUses"

From NWN Lexicon
Jump to: navigation, search
m (Prettified article formatting)
Line 1: Line 1:
=DecrementRemainingSpellUses(object, int)=
+
{{DISPLAYTITLE:DecrementRemainingSpellUses(object, int)}}
 
 
 
Decrease the number of spell uses of a particular spell for a given creature.
 
Decrease the number of spell uses of a particular spell for a given creature.
 
 
<nwscript>
 
<nwscript>
 
void DecrementRemainingSpellUses(
 
void DecrementRemainingSpellUses(
Line 11: Line 9:
  
 
====Parameters====
 
====Parameters====
 +
;oCreature
 +
:Creature to decrement the remaining spell uses of a particular spell.
  
''oCreature''
+
;nSpell
 +
:[[ spell | SPELL_* ]]
  
Creature to decrement the remaining spell uses of a particular 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''
+
nSpell doesn't have to be a spell. It can be any entry in the spells.2da file.
  
[[ spell | SPELL_* ]]
+
If they do not have any castings of nSpell memorised, then nothing will happen.
  
<br />
+
Note that this has to be added into a loop, with GetHasSpell(), to remove all the avalible castings of nSpell.
  
====Description====
+
====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).
  
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(). <br /><br /> nSpell doesn't have to be a spell. It can be any entry in the spells.2da file. <br /><br /> If they do not have any castings of nSpell memorised, then nothing will happen. <br /><br /> Note that this has to be added into a loop, with GetHasSpell(), to remove all the avalible castings of nSpell.
+
There is NO WAY to increment a spell, and there is no way to check if a spell *was* memorised either (so, there is no way to check if they *had* magic missile, but cast it earlier on). This will likely never be added - the only way to get back spells is resting (or ForceRest()).
  
<br /><br />
+
Note: There is no way to specifiy which classes spells go first. If anyone knows the order (wether it is in order of primary class, secondary class, or order of Cleric, Druid etc.) please report it so everyone can know, although it is rarely important.
 
 
====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). <br /><br /> There is NO WAY to increment a spell, and there is no way to check if a spell *was* memorised either (so, there is no way to check if they *had* magic missile, but cast it earlier on). This will likely never be added - the only way to get back spells is resting (or ForceRest()). <br /><br /> Note: There is no way to specifiy which classes spells go first. If anyone knows the order (wether it is in order of primary class, secondary class, or order of Cleric, Druid etc.) please report it so everyone can know, although it is rarely important.
 
  
 
Cannot decrement spell that creature have memorised but shouldn't be able to use, for example if creature has a sixth level memorised under Spells tab but has caster ability only 15 or less, this function fails. Same spell given as Special ability is decremented properly.
 
Cannot decrement spell that creature have memorised but shouldn't be able to use, for example if creature has a sixth level memorised under Spells tab but has caster ability only 15 or less, this function fails. Same spell given as Special ability is decremented properly.
 
<br />
 
  
 
====Known Bugs====
 
====Known Bugs====
 +
Prior to patch 1.28 this function did not work properly with spontaneously cast spells. Prior to 1.61, it didn't work with metamagic spells. Prior to 1.64, it didn't work with clerical domain spells.
  
Prior to patch 1.28 this function did not work properly with spontaneously cast spells. Prior to 1.61, it didn't work with metamagic spells. Prior to 1.64, it didn't work with clerical domain spells. <br /><br /> Whew! After all of that, it should now work correctly for any spells.2da entry, including all domain spells, sub-spells, metamagic spells, and spontaneous spells.
+
Whew! After all of that, it should now work correctly for any spells.2da entry, including all domain spells, sub-spells, metamagic spells, and spontaneous spells.
 
 
<br />
 
  
 
====Version====
 
====Version====
 
 
1.64
 
1.64
  
 
====Example====
 
====Example====
 
 
<nwscript>
 
<nwscript>
 
// Decrement thier remaining magic missile uses by 1, in a  
 
// Decrement thier remaining magic missile uses by 1, in a  
Line 67: Line 61:
  
 
{| class="seealso"
 
{| class="seealso"
|-
 
 
| width="1px" align="right" valign="top" | <font color="gray">constants: </font>
 
| width="1px" align="right" valign="top" | <font color="gray">constants: </font>
|
+
|[[spell|SPELL_* Constants]]
[[ spell | SPELL_* Constants ]]
+
|}<br />
|}
 
 
 
<br />
 
 
----
 
----
<font color="gray">  author: Charles Feduke, editor: Jasperre, additional contributor(s): Justin Koch, Jasperre</font><br />  <br />
+
<font color="gray">  author: Charles Feduke, editor: Jasperre, additional contributor(s): Justin Koch, Jasperre</font>
 
[[Category:Functions]]
 
[[Category:Functions]]
 
[[Category:Spells_Functions]]
 
[[Category:Spells_Functions]]

Revision as of 21:29, 16 January 2016

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 memorised, then nothing will happen.

Note that this has to be added into a loop, with GetHasSpell(), to remove all the avalible 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).

There is NO WAY to increment a spell, and there is no way to check if a spell *was* memorised either (so, there is no way to check if they *had* magic missile, but cast it earlier on). This will likely never be added - the only way to get back spells is resting (or ForceRest()).

Note: There is no way to specifiy which classes spells go first. If anyone knows the order (wether it is in order of primary class, secondary class, or order of Cleric, Druid etc.) please report it so everyone can know, although it is rarely important.

Cannot decrement spell that creature have memorised but shouldn't be able to use, for example if creature has a sixth level memorised under Spells tab but has caster ability only 15 or less, this function fails. Same spell given as Special ability is decremented properly.

Known Bugs

Prior to patch 1.28 this function did not work properly with spontaneously cast spells. Prior to 1.61, it didn't work with metamagic spells. Prior to 1.64, it didn't work with clerical domain spells.

Whew! After all of that, it should now work correctly for any spells.2da entry, including all domain spells, sub-spells, metamagic spells, and spontaneous spells.

Version

1.64

Example

// Decrement thier remaining magic missile uses by 1, in a 
// conversation.
// * Note: A conversation conditional script should check if they
//    have magic missile memorised 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