Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Dark Dreams of Furiae - a new module for NWN:EE! Buy now
Attention, new and old users! Please read the new rules of conduct for the forums, and we hope you enjoy your stay!

[Tool] Adding class- or kit-specific spells

OlvynChuruOlvynChuru Member Posts: 2,667
edited October 19 in General Modding
This tool adds a versatile WeiDU function that can add or restrict spells to specific classes and/or kits. It could be useful either for modders making spell mods or modders making kit mods.

Here are things this function can do that were difficult or impossible to do before:

- Make it so only certain classes or kits can learn the spell on character creation or level up (e.g. so a particular spell could be learned by shamans but not by druids, or could be learned by paladins but not by clerics).
- Make it so only certain classes or kits can learn the spell from a scroll (e.g. so the "Learn Spell" button only appears for bards and not for mages).
- The above works both for existing spells and for custom spells. You could restrict an existing spell to certain classes or kits (e.g. you could make the Emotion: Courage and Emotion: Hope spells from IWDEE only learnable by bards).
- Make a spell learnable by all arcane/divine casters without having to prefix it with SPWI or SPPR; this means WeiDU's ADD_SPELL function isn't necessary.
- Bypass the 50 spell per spell level limit (normally the list of spells sorcerers and shamans can learn on level up only shows the first 50 spells of each level, so if there are more than 50 spells of a certain level the ones past 50 can't be learned. This function gets around that; the new spells will be displayed regardless of how many spells there are.).
- The function works with any spellcasting class.

Limitations:

- Spells it adds to clerics and druids won't be selectable as initial spells during character creation, but they'll still appear in the priest scroll when the game starts.

Here's an example of the function in use:
LAF ADD_CLASS_SPELL STR_VAR resref=~SPWI299~ scroll=~SCRLZZ~ class_include=~{'MAGE_ALL', 'SORCERER'}~ kit_include=~{'JESTER'}~ kit_exclude=~{'DRAGON_DISCIPLE'}~ END

This makes the spell Summon Cow available to all mages and sorcerers, except the Dragon Disciple kit. It also makes the spell available to the Jester kit, but not to all bards. This means:

- A mage or a Jester can learn the spell from a scroll, but other bards can't.
- A sorcerer will be able to choose the spell on level up, unless they're a Dragon Disciple.

Function parameters:
  • resref (Resref of the spell.)
  • scroll (Resref of the scroll for the spell (optional, if you want to restrict who can learn the spell from the scroll).)
  • class_include (A character with one of these classes (from CLASS.IDS) can learn the spell. Use the class wildcards (like 'MAGE_ALL' for all mages).)
  • kit_include (A character with one of these kits can learn the spell, even if their class is not in the "class_include" list.)
  • kit_exclude (A character with one of these kits cannot learn the spell, even if their class is in the "class_include" list. NOTE: YOU DO NOT HAVE TO SPECIFY THE SPECIALIST MAGE KITS THAT CANNOT LEARN THE SPELL; THE FUNCTION WILL HANDLE THOSE AUTOMATICALLY.)

If you want to use this function in your mod, download and unzip the file at the end of this post. Look in the ClassSpellTool folder and copy its contents into your mod folder. Then in your mod's tp2 file, include this line:
INCLUDE ~%MOD_FOLDER%/ClassSpellTool.TPA~

After that, you can use the ADD_CLASS_SPELL function as shown in the example above.

Post edited by OlvynChuru on
StummvonBordwehrRik_KirtaniyaGwendolyneLuke93GrammarsaladPermidion_Stark

Comments

  • AionZAionZ Member Posts: 3,167
    I've tried to add the function to kit-specific spells, but that part doesn't seem to work. Only the class parameter does. Is that part dependent on EEex?

    OlvynChuru
  • OlvynChuruOlvynChuru Member Posts: 2,667
    @AionZ Okay, I fixed the problem. Kit-specific spells should work now. Download the zip again and try it.

  • AionZAionZ Member Posts: 3,167
    Works as intended now, thanks. I don't suppose there's a way for the kit parameter to parse a kit name instead of the number in the case of custom kits?

  • OlvynChuruOlvynChuru Member Posts: 2,667
    @AionZ Wish granted! I just released a new version in which you can do this, like:
    LAF ADD_CLASS_SPELL STR_VAR resref=~SPWI299~ scroll=~SCRLZZ~ class_include=~{'MAGE_ALL', 'SORCERER'}~ kit_include=~{'JESTER'}~ kit_exclude=~{'DRAGON_DISCIPLE'}~ END
    

    Download the zip again and try it.

  • EndarireEndarire Member Posts: 390
    edited October 17
    @OlvynChuru
    Thankee for releasing this tool to the public! Alleluia! You've done this community a great service!

    Does this tool only work on EE versions of the games? Does it work on IWD1? IWD2? PST?

    Does this tool have the ability to edit mods with new spells and strip off the SP__ prefix? (I'm looking at you, Darkest Day, Dark Side of the Sword Coast, Northern Tales of the Sword Coast, IWDification, and more!) If not, may we get it soon? I'd like to be able to play with all these spells and more in the same game!

  • AionZAionZ Member Posts: 3,167
    edited October 17
    Thanks for the update. I'm currently trying to integrate it into Shadow Magic to improve the spell selection process, but there's a few issues that still need sorting out. I'm not sure if there's an easier process but I've individually excluded every original mage spell to my kits and made the mod spells exclusive to the kits, but it seems somehow the system ends up believing the kit has no available spells at all and sets the number of allowed spells to zero:

    Edit: annoyingly enough, doesn't seem to be a problem when the sorcerer levels up post-creation.

    bzc7c0rokyjj.png

  • OlvynChuruOlvynChuru Member Posts: 2,667
    @AionZ That problem seems to have to do with the automatic spell picks. Try setting all the resrefs in SPLAUTOP.2DA to *******. From my tests just now, that should fix the problem.

    @Endarire
    Endarire wrote: »
    Does this tool only work on EE versions of the games? Does it work on IWD1? IWD2? PST?

    It's EE-only, since it requires UI modding.
    Endarire wrote: »
    Does this tool have the ability to edit mods with new spells and strip off the SP__ prefix? (I'm looking at you, Darkest Day, Dark Side of the Sword Coast, Northern Tales of the Sword Coast, IWDification, and more!) If not, may we get it soon? I'd like to be able to play with all these spells and more in the same game!

    No, it doesn't. However, once I update all the spells in my mod to use this function, you'll be much less likely to reach the 50 spells per level limit, since my spells won't count towards it.

  • EndarireEndarire Member Posts: 390
    @OlvynChuru
    This tool seems like it should be integrated into Weidu's ADD_SPELL function. I referred Wisp, the current maintainer of Weidu, to you so you two can talk more directly about this.

    Thankee!

  • OlvynChuruOlvynChuru Member Posts: 2,667
    @Endarire
    Endarire wrote: »
    This tool seems like it should be integrated into Weidu's ADD_SPELL function. I referred Wisp, the current maintainer of Weidu, to you so you two can talk more directly about this.

    Thankee!

    The ADD_CLASS_SPELL function requires certain files in order to work (like M_MEEXSP.lua). WeiDU is normally just a program by itself; it doesn't come with other files that are necessary for it to work. I'm not sure if it's a good idea.

    Gwendolyne
  • EndarireEndarire Member Posts: 390
    @OlvynChuru
    Hence the conversation with Wisp.

  • Luke93Luke93 Member, Mobile Tester Posts: 1,389
    edited October 18
    @OlvynChuru
    Thank you, it's much appreciated!

    But unfortunately, it's not working for me (BG2:EE v2.5, no EEEx...)

    For instance, if I write
    LAF ADD_CLASS_SPELL
    STR_VAR
    	resref = ~SPPR101~
    	class_include = ~{'RANGER_ALL'}~
    	kit_exclude = ~{'FERALAN', 'BEASTMASTER'}~
    END
    
    then CLERICs, DRUIDs, FERALANs and the like are able to select Bless during Character Creation. Shouldn't that restrict Bless to Rangers only (in particular TRUECLASS and STALKER)?

  • OlvynChuruOlvynChuru Member Posts: 2,667
    edited October 18
    @Luke93 The function currently can't restrict existing spells for clerics, druids, rangers and paladins, though it can still add new spells for them after character creation.

  • Luke93Luke93 Member, Mobile Tester Posts: 1,389
    OlvynChuru wrote: »
    @Luke93 The function currently can't restrict existing spells for clerics, druids, rangers and paladins, though it can still add new spells for them after character creation.

    I see. Will you able to do something about that?

    OlvynChuru
  • GrammarsaladGrammarsalad Member Posts: 2,547
    edited October 18
    Awesome!

    You're the best @OlvynChuru !!!!

    Edit: have to convert my 9th level spells to this system at the least.

    Lol, when you are super stoked but you don't want to spam

    OlvynChuru
  • OlvynChuruOlvynChuru Member Posts: 2,667
    edited October 19
    @Luke93 I fixed your issue. Priest spells should no longer be selectable on character creation if you've restricted them to other classes. Download the zip from the first post again.

    Luke93Grammarsalad
  • Luke93Luke93 Member, Mobile Tester Posts: 1,389
    edited October 19
    OlvynChuru wrote: »
    @Luke93 I fixed your issue. Priest spells should no longer be selectable on character creation if you've restricted them to other classes. Download the zip from the first post again.

    Nice!

    I've got two questions:
    1. Is it intended for ["class_include"] to have a comma followed by a blank space?
      {3, 8, 14, 15, 17, 18, }
      
    2. Suppose you want to make a custom DRUID kit that cannot memorize vanilla spells. Will you get stuck during Character Creation? After a quick test, there's no way to get past that screen, so I'm wondering if I'm missing something... I tried editing, for instance, the first column of "SPLAUTOS.2DA" by putting "*******", but still no luck...
      Put it in another way: is it possible to make a DRUID kit that can cast only, say, fifth level spells?

    Post edited by Luke93 on
  • OlvynChuruOlvynChuru Member Posts: 2,667
    @Luke93
    Luke93 wrote: »
    Is it intended for ["class_include"] to have a comma followed by a blank space?
    {3, 8, 14, 15, 17, 18, }
    

    Yes, it's intended. And ending an array with a comma like that is perfectly okay in Lua.
    Luke93 wrote: »
    Suppose you want to make a custom DRUID kit that cannot memorize vanilla spells. Will you get stuck during Character Creation? After a quick test, there's no way to get past that screen, so I'm wondering if I'm missing something... I tried editing, for instance, the first column of "SPLAUTOS.2DA" by putting "*******", but still no luck...
    Put it in another way: is it possible to make a DRUID kit that can cast only, say, fifth level spells?

    Nope, not right now. That's another issue to fix.

  • GrammarsaladGrammarsalad Member Posts: 2,547
    edited October 19
    Okay, I have a question, or maybe I'm brainstorming, here. Is there a way to associate your spell with an entry in spell.ids? I ask because I understand that ResRef is not reliable for scripting (edit: according to a half remembered post by @DavidW sometime ago).

    Of course, thinking about it, I could just create a spell to be added at whatever level, ADD_SPELL it, ensure that it has a ref above xx50, and have it cast the original spell via #146/148.

    That way, any protections, etc. that protect against the custom spell ref will also protect against the ADD_SPELL version which would be used in any scripts.

    I think that solves the issue, posting so others can use the idea or critique

  • OlvynChuruOlvynChuru Member Posts: 2,667
    @Grammarsalad
    Okay, I have a question, or maybe I'm brainstorming, here. Is there a way to associate your spell with an entry in spell.ids? I ask because I understand that ResRef is not reliable for scripting (edit: according to a half remembered post by @DavidW sometime ago).

    The issue previously with calling new spells by their resref rather than their spell.ids entry was that when spells were added with ADD_SPELL, they were assigned the next available SPWI or SPPR filename, which could vary. Depending on the game and the mods you had installed, a particular spell might've been added as SPWI435 or SPWI437. So writing something like SpellRES("SPWI435",Myself) was not reliable, since it could use the wrong spell.

    But the ADD_CLASS_SPELL function bypasses this problem. It makes the spell available without having to give it a varying SPWI or SPPR filename, so you can simply use the spell's original filename in scripts. You don't need to use WeiDU's ADD_SPELL function if you use ADD_CLASS_SPELL.

    Grammarsalad
  • AionZAionZ Member Posts: 3,167
    Is there a solution for the blank button in the 'Write Spell' slot when a scroll designated for a kit is already scribed? Minor but kind of annoying.
    vrjuyuxc59zc.png

  • EndarireEndarire Member Posts: 390
    @argent77
    Greetings, argent!

    I'd love for your mods (Wild Mage and otherwise) to use this tool to increase inter-mod compatibility. Thankee!

Sign In or Register to comment.