Author Topic: RE: Any Way to Stop Spell Replenishment When Resting?  (Read 457 times)

Legacy_Pstemarie

  • Hero Member
  • *****
  • Posts: 4368
  • Karma: +0/-0
RE: Any Way to Stop Spell Replenishment When Resting?
« on: August 11, 2011, 07:28:59 pm »


               Anyone know of a way to stop a wizard from regaining spells when resting? I have added a "Wizard's Spellbook" item and need to stop spell replenishment when resting if the wizard does not have the spellbook.
               
               

               
            

Legacy_Greyfort

  • Sr. Member
  • ****
  • Posts: 442
  • Karma: +0/-0
RE: Any Way to Stop Spell Replenishment When Resting?
« Reply #1 on: August 11, 2011, 07:43:06 pm »


               NWNXFuncs_SetMemorizedSpellSlot which is a nwnx plugin for windows.  You can find all info here http://www.nwnx.org/

You may have to set the spell slots to zero after the rest, but it may be possible.
               
               

               
            

Legacy_Pstemarie

  • Hero Member
  • *****
  • Posts: 4368
  • Karma: +0/-0
RE: Any Way to Stop Spell Replenishment When Resting?
« Reply #2 on: August 11, 2011, 08:14:46 pm »


               I was hoping for something within the constraints of the standard game functions without having to use something like NWNX - which confounds me to no small end.
               
               

               
            

Legacy_lordofworms

  • Sr. Member
  • ****
  • Posts: 422
  • Karma: +0/-0
RE: Any Way to Stop Spell Replenishment When Resting?
« Reply #3 on: August 11, 2011, 09:12:11 pm »


               I too felt that way with nwnx2, but sincerely, its no more difficult than telling someone who never uses haks to use a hak. it SEEMS difficult but if you use the built in sqlite database (instead of setting up a MySQL) thats part of the nwnx2 files its a simple as setting some ini files
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.
               
               

               
            

Legacy_Greyfort

  • Sr. Member
  • ****
  • Posts: 442
  • Karma: +0/-0
RE: Any Way to Stop Spell Replenishment When Resting?
« Reply #4 on: August 11, 2011, 09:39:32 pm »


               Yes worm is right...You dont have to set up MySQL it will work all by its self with SQLite, and the plugins are great. I looked into it a little more and found the functions would help you do what you spoke of:

//:://////////////////////////////////////////////////////////////
//:: 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.
               
               

               
            

Legacy_Pstemarie

  • Hero Member
  • *****
  • Posts: 4368
  • Karma: +0/-0
RE: Any Way to Stop Spell Replenishment When Resting?
« Reply #5 on: August 11, 2011, 10:41:29 pm »


               Well I guess I'm going to have to take the plunge. Maybe someone can point me to some NWNX tutorials or such...
               
               

               
            

Legacy_Shadooow

  • Hero Member
  • *****
  • Posts: 7698
  • Karma: +0/-0
RE: Any Way to Stop Spell Replenishment When Resting?
« Reply #6 on: August 11, 2011, 11:37:32 pm »


               You dont need NWNX for that. Simpy use DecreaseRemainingSpellUses command with spell id from 0 to the last 569 in (double) loop. Could make you script a bit later if noone else does. But as I know you it wont be neccessary.
               
               

               


                     Modifié par ShaDoOoW, 11 août 2011 - 10:38 .
                     
                  


            

Legacy_Lightfoot8

  • Hero Member
  • *****
  • Posts: 4797
  • Karma: +0/-0
RE: Any Way to Stop Spell Replenishment When Resting?
« Reply #7 on: August 11, 2011, 11:46:57 pm »


               You can also do it all from the rest event.  

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.
               
               

               
            

Legacy_Pstemarie

  • Hero Member
  • *****
  • Posts: 4368
  • Karma: +0/-0
RE: Any Way to Stop Spell Replenishment When Resting?
« Reply #8 on: August 12, 2011, 12:07:13 am »


               ShaDoOoW, Lightfoot - actually working on an amalgam of both your suggestions '<img'>
               
               

               
            

Legacy_Pstemarie

  • Hero Member
  • *****
  • Posts: 4368
  • Karma: +0/-0
RE: Any Way to Stop Spell Replenishment When Resting?
« Reply #9 on: August 12, 2011, 01:36:12 am »


               Maybe someone could take a look at this and tell me where I went wrong? Spells are NOT decrementing to pre-rest levels like they should. Note that it should only fire for Wizards AND only if they do NOT have the item indicated.

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 .
                     
                  


            

Legacy_Pstemarie

  • Hero Member
  • *****
  • Posts: 4368
  • Karma: +0/-0
RE: Any Way to Stop Spell Replenishment When Resting?
« Reply #10 on: August 12, 2011, 02:02:20 am »


               Nevermind, its working. I tied it in with the HotU Wandering Monster system since I'm planning on using that - only I hadn't activated the system yet 'Image
               
               

               


                     Modifié par Pstemarie, 12 août 2011 - 01:02 .
                     
                  


            

Legacy_henesua

  • Hero Member
  • *****
  • Posts: 6519
  • Karma: +0/-0
RE: Any Way to Stop Spell Replenishment When Resting?
« Reply #11 on: August 12, 2011, 05:39:59 pm »


               Pstemarie, if you have trouble posting code, a utility like pastebin is really helpful. http://pastebin.com/

[edit - the rest removed as I was responding to the wrong thread.]
               
               

               


                     Modifié par henesua, 12 août 2011 - 05:12 .
                     
                  


            

Legacy_Pstemarie

  • Hero Member
  • *****
  • Posts: 4368
  • Karma: +0/-0
RE: Any Way to Stop Spell Replenishment When Resting?
« Reply #12 on: August 15, 2011, 06:48:09 pm »


               Thanks Henesua
               
               

               
            

Legacy_Mad.Hatter

  • Full Member
  • ***
  • Posts: 156
  • Karma: +0/-0
RE: Any Way to Stop Spell Replenishment When Resting?
« Reply #13 on: August 16, 2011, 02:29:29 am »


               I don't have the code in front of me, but I know that Ed Beck's HCR2 for NWN1 limits regaining spells to once per day regardless of how many times you sleep. It decouples the two completely.

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 .
                     
                  


            

Legacy_Pstemarie

  • Hero Member
  • *****
  • Posts: 4368
  • Karma: +0/-0
RE: Any Way to Stop Spell Replenishment When Resting?
« Reply #14 on: August 16, 2011, 12:50:03 pm »


               I have the HCR, but its a little too advanced and subsystem intensive for what we're trying to achieve. Anyway, I have the problem solved and with just a small block of code and two subscripts.