logo logo

 Back to main page

The NWNX Community Forum

 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
 
Polymorph and Spells: Funcs plugin

 
Post new topic   Reply to topic    nwnx.org Forum Index -> Scripts and Modules
View previous topic :: View next topic  
Author Message
metagamer



Joined: 30 Nov 2014
Posts: 20

PostPosted: Mon Mar 16, 2015 12:13    Post subject: Polymorph and Spells: Funcs plugin Reply with quote

Details: NWN1, NWNX 2, Ubuntu machine

Hello everybody,

I would like to ask you about a system to "Save Spells and Restore them after Polymorph".

I will try to better explain.
One of the most nasty problems is the lose of spells when you polymorph (example: Tenser Transformation or shifter's spells).
Basically, the spell slot bonus gained with objects or whatever are lost.

The idea is easy:
- Save the available spells loaded in the book
- Do polymorph
- Do un-polymorph
- Reload the spells TO the slot
- Restore them if they were not used

I have seen that NWN Funcs plugin provides some functions

Quote:
int AddKnownSpell (object oCreature, int nClass, int nSpellLevel, int nSpellId);
int ClearMemorizedSpell (object oCreature, int nClass, int nLevel, int nIndex);
string GetAllMemorizedSpells (object oCreature);
int GetBonusSpellSlots (object oCreature, int nClass, int nSpellLevel);
int GetKnownSpell (object oCreature, int nClass, int nSpellLevel, int nIndex);
int GetKnowsSpell (int nSpellId, object oCreature, int nClass=CLASS_TYPE_INVALID);
int GetMaxSpellSlots (object oCreature, int nClass, int nSpellLevel);
int GetRemainingSpellSlots (object oCreature, int nClass, int nSpellLevel);
int GetTotalKnownSpells (object oCreature, int nClass, int nSpellLevel);
struct MemorizedSpellSlot GetMemorizedSpell (object oCreature, int nClass, int nLevel, int nIndex);
int RemoveKnownSpell (object oCreature, int nClass, int nSpellId);
int ReplaceKnownSpell (object oCreature, int nClass, int nOldSpell, int nNewSpell);
int RestoreReadySpells (object oCreature, string sSpells);
int SetKnownSpell (object oCreature, int nClass, int nSpellLevel, int nIndex, int nSpellId);
int SetMemorizedSpell (object oCreature, int nClass, int nLevel, int nIndex, struct MemorizedSpellSlot mss);
int SetRemainingSpellSlots (object oCreature, int nClass, int nSpellLevel, int nSlots);


In particular I guess I need these ones:

int RestoreReadySpells (object oCreature, string sSpells);
int SetKnownSpell (object oCreature, int nClass, int nSpellLevel, int nIndex, int nSpellId);
int SetMemorizedSpell (object oCreature, int nClass, int nLevel, int nIndex, struct MemorizedSpellSlot mss);

But I am not able to make them working.
There exist a documentation?

Can somebody give me some feedback?

I admit that this work is fantastic and I really thank you.
However, it really needs documentation!

Smile
Back to top
View user's profile Send private message Visit poster's website
Lokey



Joined: 02 Jan 2005
Posts: 158

PostPosted: Mon Mar 30, 2015 9:34    Post subject: Reply with quote

It's difficult because the spells are dropped from the spell list when casting stat or bonus spell slot is lost if you use the engine polymorph (can't hide on a non-accessible item slot either and there's no effect for spell slot AFAIK). So it's hard to grab all the data you need and you lack a script hook to return those uses (item acquire or equip scripts fire for polymorph, forget which it is).

Easiest is just to drop polymorph and use other functions to simulate it, that way it's easy to turn spell casting on/off for example. Adding functionality is always nicer than doing a huge amount of work to make the existing thing slightly less bad Wink
_________________
Neversummer PW NWNx powered mayhem Wink
Back to top
View user's profile Send private message
elven



Joined: 28 Jul 2006
Posts: 259
Location: Germany

PostPosted: Mon Mar 30, 2015 15:07    Post subject: Reply with quote

I don't think there's any documentation past on what is in the include.

However, I did something similar in the past; allowing users to save/restore spellbooks to a database so they can have presets.

https://github.com/silm/silm/blob/master/mod/nss/includes/inc_spbookmgr.n

This doesn't save ready-state but that can be patched in. You'd have to adapt the code of course.

Hope this helps a bit.

Let me know if you have specific questions!
_________________
silm.pw, a player-driven Forgotten Realms NWN1 persistent world for tinkerers.
Back to top
View user's profile Send private message
metagamer



Joined: 30 Nov 2014
Posts: 20

PostPosted: Fri Apr 03, 2015 14:16    Post subject: Reply with quote

Hello and really thanks for your answers! Smile

I tried your code but still doesn't work.

I think that i misunderstood this part:
Code:

      int level = pGi(1);
      int class = pGi(2);
      int spell = pGi(3);
      int meta  = pGi(4);
      int index = pGi(5);


What are pGi?
Back to top
View user's profile Send private message Visit poster's website
elven



Joined: 28 Jul 2006
Posts: 259
Location: Germany

PostPosted: Fri Apr 03, 2015 14:17    Post subject: Reply with quote

metagamer wrote:
Hello and really thanks for your answers! :)

I tried your code but still doesn't work.

What are pGi?


As I said, you'd have to adapt it to suit your needs. This basically just shows how I use the MemorizedSlot functions since you were asking on use cases.

Those functions are from my custom database lib.

If you are familiar with SQL, those just retrieve the column results for the current row and convert them to native types.
_________________
silm.pw, a player-driven Forgotten Realms NWN1 persistent world for tinkerers.
Back to top
View user's profile Send private message
metagamer



Joined: 30 Nov 2014
Posts: 20

PostPosted: Sun Apr 05, 2015 20:54    Post subject: Reply with quote

Okok, it' s ok!
Done.

Thanks so much!
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    nwnx.org Forum Index -> Scripts and Modules All times are GMT + 2 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group