Skip to content

Learning spell script ?

AstoriasAstorias Member Posts: 4
Hello Modders ! This is a question from a newbie in NWN modding/scripting (don't hurt me lol)

I'm working on a custom spellcaster class (2da parts are ok !) and i would like to know if there is a function (or anything else) that "mimic" the learn spell action from a spell scroll, I mean adding a spell in a spell book ? I searched for days on nwn wikis, lexicon, forums and Aurora scripts without any result...

I would like this custom class to learn custom spells only by scripted event (conversation for exemple).

I think i can handle this via event scripts that create a custom spell scroll to be learned, but it implies to create these custom scrolls in every module I import my hak :/

Thanks for your support !

Comments

  • TerrorbleTerrorble Member Posts: 175
    Hmm, not something I've attempted to work with before, and I don't see any functions that mimic learning a spell scroll either. Creating scrolls based on what's known seems to be the only thing that comes to my mind as well.
  • AstoriasAstorias Member Posts: 4
    Aaarg... Thanks Terrorble !

    I'll go for a scroll creation script then... to avoid any module changes (create custom spell scroll inside modules), I'll try to script a blank scroll creation then add the custom spell property on it...

    Thx !
  • MelkiorMelkior Member Posts: 191
    It's probably possible to do this by using custom 2DA files and custom scripting, but it's not a beginner level customisation.
  • AstoriasAstorias Member Posts: 4
    Thanks Melkior !

    When you say it's not a beginner level customisation, you're speaking about the solution that directly add a spell in spellbook, or the scripted scroll creation to be manually learned in game (through radial menu) ?
  • AstoriasAstorias Member Posts: 4
    I managed to do it (scroll modification script) !

    I did multiple tests by removing/adding custom spellcasting properties with multiple 2da custom configurations (classes, spells, iprp_spells) on in-game spellscrolls and for those who are interested, here is how it seems to work.

    The learn spell action in radius menu appears only if three (at least ?) conditions are met (whaterver the spell, prerequisites, etc..) :

    1) the PC must have at least 1 lvl in a class that has the LearnScroll value at 1 in the classes.2da (obviouslsy)

    2) the item from wich the spell may be learned must have its Base Type Name at "Scroll" (whatever the Item Name, Tag or Blueprint ResRef)

    3) a Cast Spell property (from iprp_spells.2da, customed or not) must be on the item


    The learning part is dissociated with the three conditions above. When the PC tries to learn the spell, the game engine does :

    1) retrieve the SpellIndex value of the concerned Cast Spell property in the iprp_spells.2da

    2) find the concerned spell row in spells.2da

    3) proceed to the prerequisits check :
    - if the "class lvl" (bard, druid wiz_sorc, custom column, etc..) is OK, the spell is learnt.
    - if the "class lvl" is present, but too low (lvl 6 spell with a wizard lvl 3 for example), the system tells you're too low lvl (something like this)
    - if the "class lvl" of the spell is " **** ", the system tells you can only learn arcane spell (whatever the value 0 or 1 of Arcane in the classes.2da)

    If you change in the iprp_spells.2da the spell index of a cast spell property (magic missile cast spell property with the time stop spell index for example), the scroll appearance will remain "Magic Missile", but spell cast icon (from scroll) or the learning atempt will concern the time stop spell (a lvl 1 wizard will not be able to learn this "magic missile" spell.... until lvl reaching lvl 17)

    Working now on the whole scroll creation from script
Sign In or Register to comment.