Jump to content


Photo

[COMPLETE] Learn Spell Mod


  • Please log in to reply
13 replies to this topic

#1 Ascension64

Ascension64
  • Modder
  • 5983 posts

Posted 30 January 2011 - 03:04 AM

Original request

I'm writing a spellbook component for tb#tweaks, and have a few requests for effect 147 (Learn Spell):

Bug: The party is granted XP when 'learning' via effect 147 a spell you already knew (this is impossible with normal scrolls, but will happen if you use apply effect 147 with an item like the attached one).

If possible, I'd also like if effect 147 enforced spell school restrictions and didn't work on Sorcerors (either by default or by setting a parameter). Again, you can use the attached item on, respectively, a Enchanter or a Sorceror to see if they learn Magic Missile.


I've brought the opcode partially in line with GemRB at the moment (need a few clarificatios, still). Here is what we have so far.

-----920 Learn Spell Mod [M]
Adds a number of flags to parameter 2 of the learn spell opcode as described below

Description
#147 (0x093) Spell: Learn Spell [147]
Parameter #1 Low: Irrelevant
Parameter #1 High: Flags
Parameter #2: Irrelevant
Description:
The targeted creature(s) tries to learn the spell specified by the resource key.
Learning is successful when 1D100 <= the INT-dependent LEARN_SPELL value in INTBON.2DA.
The LEARN_SPELL value is modified for mage specialists, with +15 for same school spells, and -15 for non-same

school spells.

The 'Flags' field modifies the behaviour of the effect in the following manners:
Bit 0: Learning the spell never gives experience (including scrolls from the inventory screen)
Bit 1: No effect (reserved for GemRB)
Bit 2: Learning is always successful (including scrolls from the inventory screen)
Bit 3: No effect (reserved for GemRB)
Bit 4: If the spell is already learnt, no experience is given (excludes inventory screen)
Bit 5: Learning the spell obeys mage school exclusions (excludes inventory screen)
Bit 6: The spell cannot be learnt by sorcerer class (excludes inventory screen)
Bit 7: Learning fails if the target has already learnt the maximum number of spells as per INTMOD.2DA for the spell's level (excludes inventory screen)

Options:
-0: disabled
-1: enabled


Edited by Ascension64, 25 February 2011 - 01:21 AM.

--------------
Retired Modder
Note: I do not respond to profile comments/personal messages in regards to troubleshooting my modifications. Please post on the public forums instead.

Baldur's Gate Trilogy-WeiDU and Mods
Throne of Bhaal Extender (TobEx)

Contributions: (NWN2) A Deathstalker (voice acting) - (IWD2) IWD2 NPC Project (soundset editing) - (Misc) SHS PC Soundsets (voice acting)
Legacy: (BG/Tutu/BGT) Beregost Crash Fixer 1.9 (18 Jul 10) - (BG2) Enable conversations with charmed/dominated creatures (18 Jul 10) - (BG2) Experience Corrections (18 Jul 10) - (Misc) Platform Conversion Utility RC2 (13 Feb 10)


#2 the bigg

the bigg

    2083 is a prime number.

  • Modder
  • 3331 posts

Posted 30 January 2011 - 04:28 AM

Thank you. Do you need clarifications from me or from Avenger?

Italian users: help test the Stivan NPC!

Author or Co-Author: WeiDU - Widescreen - Generalized Biffing - Refinements - TB#Tweaks - IWD2Tweaks - TB#Characters - Traify Tool - Some mods that I won't mention in public
Maintainer: Semi-Multi Clerics - Nalia Mod - Nvidia Fix
Code dumps: Detect custom secondary types - Stutter Investigator

If possible, send diffs, translations and other contributions using Git.


#3 Galactygon

Galactygon

    Modding since 2002

  • Member
  • 938 posts

Posted 30 January 2011 - 07:40 AM

I like this stuff.

Bit 5: Learning the spell obeys mage school exclusions (use other than from the inventory screen)
Bit 6: The spell cannot be learnt by sorcerer class (even from the inventory screen)

You might as well handle unused param1 as a usability bitfield (there's enough space) instead. There are bound to be future modder requests like alignment restrictions, bard restrictions, etc.

I'm looking for a way to restrict certain spells to specialist mages, except there is no way I can prevent bards from learning them. Someone else might think it's a good idea to restrict learning Cacofiend to evil conjurers.

The LEARN_SPELL value is modified for mage specialists, with +15 for same school spells, and -15 for non-same school spells.

Implementing this would open a can of worms in terms of "how to externalize this". I have a concept for externalizing this, but I'm figuring you have far too much on your plate already. I admit my guilt.

-Galactygon
Posted Image

#4 the bigg

the bigg

    2083 is a prime number.

  • Modder
  • 3331 posts

Posted 30 January 2011 - 07:53 AM

Param1 is non-zero for most existing scrolls, actually. If the spell is learned from a 'standard' scroll, you can use unusabilities to make it unlearnable by certain categories, btw.

Implementing this would open a can of worms in terms of "how to externalize this". I have a concept for externalizing this, but I'm figuring you have far too much on your plate already. I admit my guilt.

The hard part is decompiling the effect. Once that is done, altering the meaning of parameters, externalising parameters, etc. takes five minutes.

Edited by the bigg, 30 January 2011 - 07:53 AM.

Italian users: help test the Stivan NPC!

Author or Co-Author: WeiDU - Widescreen - Generalized Biffing - Refinements - TB#Tweaks - IWD2Tweaks - TB#Characters - Traify Tool - Some mods that I won't mention in public
Maintainer: Semi-Multi Clerics - Nalia Mod - Nvidia Fix
Code dumps: Detect custom secondary types - Stutter Investigator

If possible, send diffs, translations and other contributions using Git.


#5 Galactygon

Galactygon

    Modding since 2002

  • Member
  • 938 posts

Posted 30 January 2011 - 09:04 AM

Param1 is non-zero for most existing scrolls, actually. If the spell is learned from a 'standard' scroll, you can use unusabilities to make it unlearnable by certain categories, btw.


Then it might be better to handle unusabilities in the .spl at 0x001e. Bits 15-29 are unused, they can be used for bards/sorcerers/whatnot. Then there's no reason for keeping bit 6:

Bit 6: The spell cannot be learnt by sorcerer class (even from the inventory screen)


And Bit 5 can be changed to forcing to opcode to obey mage unusability flags in the .spl.

Bit 5: Learning the spell obeys mage unusability (use other than from the inventory screen) (was: mage school exclusions)


-Galactygon
Posted Image

#6 the bigg

the bigg

    2083 is a prime number.

  • Modder
  • 3331 posts

Posted 30 January 2011 - 09:11 AM

I still need bit 6 in the effect, since I'd like Sorcerors to learn 'standard' spells at level up but not by using the spellbooks I'm adding (although I have no problem with a Bard or Sorceror bit being added to the SPL format).

Italian users: help test the Stivan NPC!

Author or Co-Author: WeiDU - Widescreen - Generalized Biffing - Refinements - TB#Tweaks - IWD2Tweaks - TB#Characters - Traify Tool - Some mods that I won't mention in public
Maintainer: Semi-Multi Clerics - Nalia Mod - Nvidia Fix
Code dumps: Detect custom secondary types - Stutter Investigator

If possible, send diffs, translations and other contributions using Git.


#7 Galactygon

Galactygon

    Modding since 2002

  • Member
  • 938 posts

Posted 30 January 2011 - 10:02 AM

Can't this be solved by using .effs to block undesired classes? The only limitation comes up (this has been tested) with learning spells from scrolls, where they are hardcoded to use one feature block with opcode 147.

I'm curious about your Spell Book mod, by the way.

-Galactygon
Posted Image

#8 the bigg

the bigg

    2083 is a prime number.

  • Modder
  • 3331 posts

Posted 30 January 2011 - 10:23 AM

I suppose I could use EFF files to skip Sorcerors (thus not needing bit 6), but I'd need to create an EFF for every spell and then call that 7 times (Bard, M, FM, CM, TM, FMT, FMC) for every spell in the spellbook.

The Spell Book mod would scan all mage creatures, and add to each of them a spellbook, which contains (say, 50%) of the spells the mage has memorized, and can be read (and destroyed) to learn them (at, say, 33% success rate). This solves one objection that some people raised in the SCSII forum: namely, every mage of the appropriate level knows Remove Magic, Protection from Magic Weapons, or Spell Trigger, while the relevant scrolls are hard to find for your party.

Italian users: help test the Stivan NPC!

Author or Co-Author: WeiDU - Widescreen - Generalized Biffing - Refinements - TB#Tweaks - IWD2Tweaks - TB#Characters - Traify Tool - Some mods that I won't mention in public
Maintainer: Semi-Multi Clerics - Nalia Mod - Nvidia Fix
Code dumps: Detect custom secondary types - Stutter Investigator

If possible, send diffs, translations and other contributions using Git.


#9 Galactygon

Galactygon

    Modding since 2002

  • Member
  • 938 posts

Posted 30 January 2011 - 11:04 AM

I suppose I could use EFF files to skip Sorcerors (thus not needing bit 6), but I'd need to create an EFF for every spell and then call that 7 times (Bard, M, FM, CM, TM, FMT, FMC) for every spell in the spellbook.

Alternatively, you could place a protection from opcode 147 embedded in an external .eff file with a duration of 0 at the beginning of the effects list.

The Spell Book mod would scan all mage creatures, and add to each of them a spellbook, which contains (say, 50%) of the spells the mage has memorized, and can be read (and destroyed) to learn them (at, say, 33% success rate). This solves one objection that some people raised in the SCSII forum: namely, every mage of the appropriate level knows Remove Magic, Protection from Magic Weapons, or Spell Trigger, while the relevant scrolls are hard to find for your party.

I'm itching for something like this.

-Galactygon
Posted Image

#10 the bigg

the bigg

    2083 is a prime number.

  • Modder
  • 3331 posts

Posted 30 January 2011 - 11:48 AM

Alternatively, you could place a protection from opcode 147 embedded in an external .eff file with a duration of 0 at the beginning of the effects list.

That would work, thank you very much.

Italian users: help test the Stivan NPC!

Author or Co-Author: WeiDU - Widescreen - Generalized Biffing - Refinements - TB#Tweaks - IWD2Tweaks - TB#Characters - Traify Tool - Some mods that I won't mention in public
Maintainer: Semi-Multi Clerics - Nalia Mod - Nvidia Fix
Code dumps: Detect custom secondary types - Stutter Investigator

If possible, send diffs, translations and other contributions using Git.


#11 Ascension64

Ascension64
  • Modder
  • 5983 posts

Posted 30 January 2011 - 10:38 PM

Thank you. Do you need clarifications from me or from Avenger?

From GemRB team.


The LEARN_SPELL value is modified for mage specialists, with +15 for same school spells, and -15 for non-same school spells.

Implementing this would open a can of worms in terms of "how to externalize this". I have a concept for externalizing this, but I'm figuring you have far too much on your plate already. I admit my guilt.

This is not implementing. This is straight from reversing the procedure.


The rest of the stuff, I'll read a bit a later when I stop my brain overloading...

Edited by Ascension64, 30 January 2011 - 10:39 PM.

--------------
Retired Modder
Note: I do not respond to profile comments/personal messages in regards to troubleshooting my modifications. Please post on the public forums instead.

Baldur's Gate Trilogy-WeiDU and Mods
Throne of Bhaal Extender (TobEx)

Contributions: (NWN2) A Deathstalker (voice acting) - (IWD2) IWD2 NPC Project (soundset editing) - (Misc) SHS PC Soundsets (voice acting)
Legacy: (BG/Tutu/BGT) Beregost Crash Fixer 1.9 (18 Jul 10) - (BG2) Enable conversations with charmed/dominated creatures (18 Jul 10) - (BG2) Experience Corrections (18 Jul 10) - (Misc) Platform Conversion Utility RC2 (13 Feb 10)


#12 Ascension64

Ascension64
  • Modder
  • 5983 posts

Posted 31 January 2011 - 01:25 AM

A point of clarification: stuff you put in the Learn Spell opcode becomes effect-specific (hence scroll-specific). If you start putting stuff in the .SPL file, they become spell-specific, which is a superset of being effect-specific). Hence, in the latter you lose the ability to customise a hypothetical scenario where only the Scroll of Non-Bard's Magic Missile prevents learning of Magic Missile, but bard's can still learn Magic Missile off the vanilla Scroll of Magic Missile.

If we are worried about clutter in param1, then a bit in param2 can be used to activate param1. Hopefully, there isn't clutter in param2...

Re: alignment restrictions, bard restrictions etc. This is fallible - it would be more wise to restrict the use of the entire scroll to alignment/bard etc. via the .ITM itself. It wouldn't make sense for a bard to be able to cast from the Scroll of Non-Bard's Magic Missile but be unable to learn Magic Missile from it.

the bigg's request is fairly specific, because he is looking to use Learn Spell opcode outside of the normal scroll environment. So if you want to make a Supercharge Me spell that adds SPWI101-110 to all Conjurers only, SPWI111-120 to all enchanters only, and SPWI121-130 to all Sorcerers only, then perhaps we can add some unusability flags.

--------------
Retired Modder
Note: I do not respond to profile comments/personal messages in regards to troubleshooting my modifications. Please post on the public forums instead.

Baldur's Gate Trilogy-WeiDU and Mods
Throne of Bhaal Extender (TobEx)

Contributions: (NWN2) A Deathstalker (voice acting) - (IWD2) IWD2 NPC Project (soundset editing) - (Misc) SHS PC Soundsets (voice acting)
Legacy: (BG/Tutu/BGT) Beregost Crash Fixer 1.9 (18 Jul 10) - (BG2) Enable conversations with charmed/dominated creatures (18 Jul 10) - (BG2) Experience Corrections (18 Jul 10) - (Misc) Platform Conversion Utility RC2 (13 Feb 10)


#13 Ascension64

Ascension64
  • Modder
  • 5983 posts

Posted 25 February 2011 - 01:21 AM

Added bit 7 to obey MAX_SPELLS_PER_LEVEL in INTMOD.2DA.

--------------
Retired Modder
Note: I do not respond to profile comments/personal messages in regards to troubleshooting my modifications. Please post on the public forums instead.

Baldur's Gate Trilogy-WeiDU and Mods
Throne of Bhaal Extender (TobEx)

Contributions: (NWN2) A Deathstalker (voice acting) - (IWD2) IWD2 NPC Project (soundset editing) - (Misc) SHS PC Soundsets (voice acting)
Legacy: (BG/Tutu/BGT) Beregost Crash Fixer 1.9 (18 Jul 10) - (BG2) Enable conversations with charmed/dominated creatures (18 Jul 10) - (BG2) Experience Corrections (18 Jul 10) - (Misc) Platform Conversion Utility RC2 (13 Feb 10)


#14 the bigg

the bigg

    2083 is a prime number.

  • Modder
  • 3331 posts

Posted 25 February 2011 - 01:34 AM

Thanks!

Italian users: help test the Stivan NPC!

Author or Co-Author: WeiDU - Widescreen - Generalized Biffing - Refinements - TB#Tweaks - IWD2Tweaks - TB#Characters - Traify Tool - Some mods that I won't mention in public
Maintainer: Semi-Multi Clerics - Nalia Mod - Nvidia Fix
Code dumps: Detect custom secondary types - Stutter Investigator

If possible, send diffs, translations and other contributions using Git.