A more efficient method would be to use nwnx_funcs - but of course, that prob wont serve your needs if this is single player.
nwnx_funcs allows you to retrieve a ¬ delimitated string, containing the spell numbers of the spells the player currently possesses.
Meaning instead of looping 560+ times for all the spells in the game, you only loop about 40 or so, depending on how many spells the player actually has.
eg - At level 1, the loops would be maybe 3-6 for the cantrip spells.
Then nwnx_funcs also allows you to get the remaining uses of the spells, and even set them.
I would store the spell uses on Rest as a local int on the player
SPELL_USES_#### (#### = The spell id)
and then at the end of rest - when it is finished, we set the spell uses back to the value attached to the local ints.
for (nSpell = 0; nSpell < 599; nSpell ++)
Why???
Inefficiency incarnate.
Only seeing now, that
Greyfort has posted the nwnx_funcs stuff already.
Modifié par Baaleos, 16 août 2011 - 12:11 .