RE: Any Way to Stop Spell Replenishment When Resting?
#1
Posté 11 août 2011 - 06:28
#2
Posté 11 août 2011 - 06:43
You may have to set the spell slots to zero after the rest, but it may be possible.
#3
Posté 11 août 2011 - 07:14
#4
Posté 11 août 2011 - 08:12
and trust me, i would never go back not when I have sooooo many new great options that are just not possible (or easy) any other way.
give it a try and I assure you, you wont think twice about ever not using it again.
#5
Posté 11 août 2011 - 08:39
//:://////////////////////////////////////////////////////////////
//:: Title : spells_1
//:: Author: Greyfort
//:: Module: any who need
//:: Date : Aug 11, 2011
//:: Vers : 1.0
//:: Info :
//:://////////////////////////////////////////////////////////////
#include "nwnx_events2"
void main()
{
//1)first get known spells with
//NWNXFuncs_GetKnownSpells
// returns a string delimited by sDelimiter of all known spells of a given class and spell level
//string NWNXFuncs_GetKnownSpells(object oCreature, int iclass, int iSpellLevel, string sDelimiter=",")
//NWNXFuncs_GetKnownSpellCount
// returns the number of spells known for a given class and spell level
//int NWNXFuncs_GetKnownSpellCount(object oCreature, int iclass, int iSpellLevel)
//NWNXFuncs_GetMemorizedSpellSlot
// Returns information about a memorized spell (spell id, meta magic and whether the spell is ready to be cast)
//struct MemorizedSpellSlot NWNXFuncs_GetMemorizedSpellSlot(object oCreature, int iclass, int iSpellLevel, int iIndex)
//2)then setmemorized spells with
//NWNXFuncs_SetMemorizedSpellSlot
// Sets information about a spell in a memorized spell slot (spell id, meta magic and whether the spell is ready to be cast);
//void NWNXFuncs_SetMemorizedSpellSlot(object oCreature, int iclass, int iSpellLevel, int iIndex, struct MemorizedSpellSlot spell)
}
this is not a working script just a basic layout, If I have the time I will try to make a working one, but it would mean you need to install nwnx.
#6
Posté 11 août 2011 - 09:41
#7
Posté 11 août 2011 - 10:37
Modifié par ShaDoOoW, 11 août 2011 - 10:38 .
#8
Posté 11 août 2011 - 10:46
in the REST_EVENTTYPE_REST_STARTED section check to see what spells they still have.
in the REST_EVENTTYPE_REST_FINISHED section decrease the uses to what they where stored at above.
#9
Posté 11 août 2011 - 11:07
#10
Posté 12 août 2011 - 12:36
Note - BioWare forums seems to dislike the class constants. The word class will only display in lowercase. This block of code does compile.
if (GetLastRestEventType()==REST_EVENTTYPE_REST_STARTED)
{
if (GetLevelByclass(class_TYPE_WIZARD, oPC) > 0)
{
if (GetItemPossessedBy(oPC, "m1_it_spellbk001") == OBJECT_INVALID)
{
//Store pre-rest values for all memorized spells
int nSpell, nUses;
for (nSpell = 0; nSpell < 599; nSpell ++)
{
nUses = GetHasSpell(nSpell, oPC);
if (nUses > 0)
{
SetLocalInt(oPC, IntToString(nSpell), nUses);
}
}
}
}
}
else if (GetLastRestEventType()==REST_EVENTTYPE_REST_FINISHED)
{
if (GetLevelByclass(class_TYPE_WIZARD, oPC) > 0)
{
if (GetItemPossessedBy(oPC, "m1_it_spellbk001") == OBJECT_INVALID)
{
//Reset spells to their pre-rest values
int nSpell, nUses, nStored;
for (nSpell = 0; nSpell < 599; nSpell ++)
{
nUses = GetHasSpell(nSpell, oPC);
nStored = GetLocalInt(oPC, IntToString(nSpell));
nStored = nUses - nStored;
for (nUses = 0; nUses < nStored; nUses ++)
{
DecrementRemainingSpellUses(oPC, nSpell);
}
DeleteLocalInt(oPC, IntToString(nSpell));
}
}
}
Modifié par Pstemarie, 12 août 2011 - 12:52 .
#11
Posté 12 août 2011 - 01:02
Modifié par Pstemarie, 12 août 2011 - 01:02 .
#12
Posté 12 août 2011 - 04:39
[edit - the rest removed as I was responding to the wrong thread.]
Modifié par henesua, 12 août 2011 - 05:12 .
#13
Posté 15 août 2011 - 05:48
#14
Posté 16 août 2011 - 01:29
You might want to take a look at that package. It does exactly what you're describing (w/o NWNX).
Modifié par Mad.Hatter, 16 août 2011 - 01:30 .
#15
Posté 16 août 2011 - 11:50
#16
Posté 16 août 2011 - 12:08
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.
Why???for (nSpell = 0; nSpell < 599; nSpell ++)
Inefficiency incarnate.
Only seeing now, that Greyfort has posted the nwnx_funcs stuff already.
Modifié par Baaleos, 16 août 2011 - 12:11 .
#17
Posté 16 août 2011 - 12:21
#include "x0_i0_stringlib"
string sSpellsKnown = NWNXFuncs_GetKnownSpells(oPC, 9, 0, "¬");
string sSpell = "a Spell"; // Just to kick of the initial loop
int iPos = 0;
while(sSpell != "")
{
sSpell = GetTokenByPosition(sSpellsKnown,"¬"iPos);
//Do whatever you want to do to sSpell between here
// And here
iPos++;
}
#18
Posté 17 août 2011 - 03:46
Baaleos wrote...
#include "x0_i0_stringlib" string sSpellsKnown = NWNXFuncs_GetKnownSpells(oPC, 9, 0, "¬"); string sSpell = "a Spell"; // Just to kick of the initial loop int iPos = 0; while(sSpell != "") { sSpell = GetTokenByPosition(sSpellsKnown,"¬"iPos); //Do whatever you want to do to sSpell between here // And here iPos++; }
That in itself is a little ineffecent. Where GetTokenByPosition is great (At leas in My book, I know The Krit cringed every time I used it.) for getting a single token from a string. To use it in a loop is highly ineffecent. The loop through all the 500+ spells is possiable more effecent then using this function in a loop. it would be better to use the base functions from that libary instead of the By position one.
#include "x0_i0_stringlib"
void main()
{
struct sStringTokenizer sSpellsKnown =
GetStringTokenizer(NWNXFuncs_GetKnownSpells(oPC, 9, 0, "¬"), "¬");
string sSpell;
while(HasMoreTokens(sSpellsKnown))
{
AdvanceToNextToken(sSpellsKnown);
sSpell = GetNextToken(sSpellsKnown); // Or sSpell = sSpellsKnown.sLastTok;
//Do whatever you want to do to sSpell between here
// And here
}
}
Still even with that using StringParse from x3_inc_string would prabable be even more effecent.
Modifié par Lightfoot8, 17 août 2011 - 03:47 .
#19
Posté 17 août 2011 - 08:43
Iterating through 500 rows can cause a slight freeze in server performance, and if multiple players were doing it, it would be really noticable.
#20
Posté 17 août 2011 - 03:30
Baaleos wrote...
Still, I just think its better to loop through the spells we know we have, rather than the 500+ that we dont have.
Iterating through 500 rows can cause a slight freeze in server performance, and if multiple players were doing it, it would be really noticable.
Agreed.
#21
Posté 17 août 2011 - 03:37





Retour en haut







