subtledoctor Posted February 13, 2022 Posted February 13, 2022 (edited) I may have a solution for this that would satisfy all parties, which has been hiding in plain sight for a while now. My mod that allows sorcerers to switch out one of their known spells every level or so replaces the vanilla spell-learning system with a version using Kjeron's "Spell Learning UI" system. Originally I used this to let non-sorcerers pick spells like sorcerers; then because the spell-switching mod removes a known spell and needs the sorcerer to be able to immediately choose a replacement, that mod moves sorcerers themselves over to the new system. It only just occurred to me that, once all sorcerers and pseudo-sorcerers are using this system, it is fairly trivially easy to add more spells to it. I've written up a simple function that adds new spells, and it seems to work great. All that needs to be done for wider adoption would be to standardize some of the filenames and a suffix letter, which currently can be flexibly defined when the function is called. (If an arbitrary number of spell mods are to all use the system together, that flexibility must be removed and they all must agree on identical variable names.) Then spell mods could do something like this (just pseudocode to get the idea across): ACTION_IF !(FILE_EXISTS_IN_GAME ~spwi350.spl~) BEGIN ADD_SPELL ~%MOD_FOLDER%/spells/nu_spl.spl~ [etc.] END ACTION_IF (FILE_EXISTS_IN_GAME ~spwi350.spl~) BEGIN OUTER_SET new_sorc_spells_needed = 1 COPY ~%MOD_FOLDER%/spells/nu_spl.spl~ ~override~ SPRINT $my_mod_new_spells(~nu_spl~)~1~ // everything below could besiacally be cut-and-pasted, just needs to run once at the end of the mod ACTION_IF (new_sorc_spells_needed = 1) BEGIN ACTION_IF !(FILE_EXISTS_IN_GAME ~D5_SPLSRCKN.2da~) BEGIN COPY_EXISTING ~SPLSRCKN.2da~ ~override/d5_splsrckn.2da~ END INCLUDE ~%MOD_FOLDER%/lib/sorcerer_functions.tpa~ LAF add_sorcerer_spells STR_VAR new_list = ~my_mod_new_spells~ spl_list = ~d5slist~ END ACTION_IF (FILE_EXISTS_IN_GAME ~d5__sorc_learning.d5~) BEGIN LAF sorcerer_spell_learning STR_VAR menu_suffix = ~w~ spl_list = ~d5slist~ spl_tbl = ~D5_SPLSRCKN~ itm_name = ~d5slist~ spl_clon_list = ~d5ssorc~ END END COPY ~%MOD_FOLDER%/lib/semi_spont/splsrckn_0.2da~ ~override/splsrckn.2da~ ACTION_IF !(FILE_EXISTS_IN_GAME ~d5slis1.spl~) BEGIN COPY ~%MOD_FOLDER%/lib/d5_base.spl~ ~override/d5slis1.spl~ LPF ADD_SPELL_EFFECT INT_VAR opcode = 143 target = 1 parameter1 = 14 timing = 9 STR_VAR resource = ~d5slist~ END LPF ADD_SPELL_EFFECT INT_VAR opcode = 172 target = 1 timing = 1 STR_VAR resource = ~d5slis1~ END END ACTION_IF !(FILE_EXISTS_IN_GAME ~d5slis2.spl~) BEGIN COPY ~%MOD_FOLDER%/lib/d5_base.spl~ ~override/d5slis1.spl~ LPF ADD_SPELL_EFFECT INT_VAR opcode = 146 parameter1 = 0 parameter2 = 1 STR_VAR resource = ~d5slis1~ END END ACTION_IF !(FILE_EXISTS_IN_GAME ~d5slis3.spl~) BEGIN COPY_EXISTING ~d5slis2.spl~ ~override/d5slis3.spl~ LPF ALTER_EFFECT INT_VAR match_opcode = 146 opcode = 326 parameter1 = 19 parameter2 = 105 STR_VAR match_resource = ~d5slis1~ END END APPEND ~clabma01.2da~ ~LEARNSPLS AP_D5SLIS3 **** **** **** **** **** **** **** **** **** **** **** **** **** **** **** **** **** **** **** **** **** **** **** **** **** **** **** **** **** **** **** **** **** **** **** **** **** **** **** **** **** **** **** **** **** **** **** **** **** ~ UNLESS ~AP_D5SLIS3~ COPY_EXISTING ~kitlist.2da~ ~override~ COUNT_2DA_ROWS 9 rows FOR (row = 3 ; row < rows ; ++row) BEGIN READ_2DA_ENTRY %row% 5 9 modclab READ_2DA_ENTRY %row% 8 9 modclass PATCH_IF (%modclass% = 19) BEGIN INNER_ACTION BEGIN APPEND ~%modclab%.2da~ ~LEARNSPLS AP_D5SLIS2 **** **** **** **** **** **** **** **** **** **** **** **** **** **** **** **** **** **** **** **** **** **** **** **** **** **** **** **** **** **** **** **** **** **** **** **** **** **** **** **** **** **** **** **** **** **** **** **** **** ~ UNLESS ~AP_D5SLIS2~ END END END BUT_ONLY END That would switch all sorcerers over to the new spell-learning system; and the new system would encompass all normal sorcerer-valid spells plus any spells added by this mod in the my_mod_new_spells array, plus any new spells added by other mods using the same code. The big, big caveat is that the new spell-learning system is markedly different from the vanilla one. Instead of happening at every level-up, you must trigger it manually by an innate ability, or by an item ability from an invisible item in the 4th ammo slot, or by an item that you can use from a quickslot and then stash somewhere else. Et cetera. Because it uses Kjeron's spell-learning UI, it looks like the spellbook screen instead of the CharGen spell selection screen. A benefit of this over OvynChuru's method is that any mod coming in later that needs to find all sorcerer-valid spells in the game can do so quite easily: ACTION_IF (FILE_EXISTS_IN_GAME ~d5slist.2da~) BEGIN COPY_EXISTING ~d5slist.2da~ ~override~ COUNT_2DA_COLS cols READ_2DA_ENTRIES_NOW ~r2en_slist~ cols FOR (row = 0; row < r2en_slist; ++row) BEGIN READ_2DA_ENTRY_FORMER ~r2en_slist~ row 1 this_spell PATCH_IF (FILE_EXISTS_IN_GAME ~%this_spell%.spl~) BEGIN SPRINT $sorcerer_valid_spells(~%this_spell%~) ~1~ END END BUT_ONLY END So, to me, the question is whether it is worth developing this from a simple proof-of-concept test mod to a set of functions that multiple mods agree to use. And is the trade-off of the rather stark UI difference worth it? Edited February 15, 2022 by subtledoctor Quote
Endarire Posted February 13, 2022 Posted February 13, 2022 This seems very worthwhile to allow all these mods and more to add spells to a modded install! Quote
Endarire Posted February 18, 2022 Posted February 18, 2022 (edited) I am still interested in this! <does a Bardic cheerleading dance> Edited February 18, 2022 by Endarire Quote
Recommended Posts
Join the conversation
You are posting as a guest. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.