First, an overview of how DR creates the sphere system. As we found through several frustrating releases, removing spells from divine casters is unreliable at best. The engine automatically puts spells of the name sppr[1-7][0-9][0-9] into divine spellbooks if the spell is of the correct type, defined by the two bytes at 0x20 in the spell files. DR removes this automatic granting of spells by changing the type of all spells of the name sppr[1-7][0-9][0-9] to invalid for all divine casters. The spells are added manually via the kit's ability tables, aka the CLAB 2da files. Adding to the spellbook through script or spells resulted in the cleric receiving experience points for 'learning' the spell.
So, all of the CLAB files for DR are stuffed with entries like GA_SPPR101 and whatnot. The spellbook portion of these CLAB files are now built on the fly, in a fashion that third-party mods can use. As DR also imposes sphere restrictions upon HLAs, we also have tools for building HLA tables on the fly. Note that all of the code you see here should follow the ADD_KIT command.
The first step is to detect DR of versions > 3. A simple ACTION_IF:
// if DR > v3 is installed prior to my mod ACTION_IF ((FILE_EXISTS_IN_GAME ~cdnegpp.spl~) AND (FILE_EXISTS ~Divine_Remix/lib/macro_reindex_clab.tph~)) THEN BEGIN INCLUDE ~Divine_Remix/lib/extra_regexp_vars.tph~ // code for here follows END
The include is required; it sets up extra variables we can use to match special characters such as newlines and tabs in the various macros.
All of the code needed to build CLABs has been farmed out to included files and macroes. To use the code, you first need to figure out what macros are needed and include them from the DR folder:
INCLUDE ~Divine_Remix/lib/macro_extend_clab_to_level_50.tph~If your CLAB file does not extend to level 50, this macro will extend it. I recommend you do this manually, with or without planning on integrating with DR. Using CLABs that go to level 50 on a normal install has no effect, but extending them to 50 will greatly assist XP cap removers.
INCLUDE ~Divine_Remix/lib/macro_remove_blank_lines_from_eof.tph~As the name suggests, this will remove any blank lines or returns from the end of the file. This is a necessary clean-up step prior to adding HLAs or spells.
INCLUDE ~Divine_Remix/lib/macro_reindex_clab.tph~All of the code added to CLAB files will have an invalid first entry (i.e. instead of ABILITY1 it'll just be an xx). This macro, when run at the end, will make the first entries run properly from ABILITY1 to ABILITY99 (or wherever). This is a required finishing step.
INCLUDE ~Divine_Remix/lib/macro_spell_remove_evil.tph~ INCLUDE ~Divine_Remix/lib/macro_spell_remove_neutral.tph~ INCLUDE ~Divine_Remix/lib/macro_spell_remove_good.tph~DR imposes an additional restriction on spells based upon your deity's alignment. A good-aligned deity no longer grants spells unusable by good characters, i.e. Selune does not grant Unholy Blight or Unholy Word, even to her CN followers. Conversely, a LN Authlin of Iyachtu Xvim can not use Holy Smite or Holy Word. If you wish for your kit to impose these additional restrictions as well, include and use these macros. The macros should be launched just after adding the spells. Good deities should use the _good macro, neutral deities _neutral, and evil deities _evil.
INCLUDE ~Divine_Remix/lib/macro_add_cleric_spells.tph~ INCLUDE ~Divine_Remix/lib/macro_add_druid_spells.tph~ INCLUDE ~Divine_Remix/lib/macro_add_paladin_spells.tph~ INCLUDE ~Divine_Remix/lib/macro_add_ranger_spells.tph~These four macros provide the spells appropriate for the trueclass version of these classes. If you wish to customize the sphere selection for your kit, this is addressed in the next post. If you want the default selection for your class, use these macros.
INCLUDE ~Divine_Remix/lib/macro_shift_paladin_spells.tph~ INCLUDE ~Divine_Remix/lib/macro_shift_ranger_spells.tph~
These two macros remove the addition of higher level spells for rangers and paladins, and shift them over so that they don't start accumulating until higher levels. In other words, this macro will trim a paladin down to just spells of level 1-4 and move them so that level 1 spells get added to the spellbook starting at character level 9.
So, to actually use these, we first must include any macro we want. Let's use this for an example ranger kit with default ranger spell selection. (Let's assume we've already extended the CLAB to level 50 manually). First we include the needed macros from the DR folder:
INCLUDE ~Divine_Remix/lib/macro_remove_blank_lines_from_eof.tph~ INCLUDE ~Divine_Remix/lib/macro_reindex_clab.tph~ INCLUDE ~Divine_Remix/lib/macro_add_ranger_spells.tph~ INCLUDE ~Divine_Remix/lib/macro_shift_ranger_spells.tph~ INCLUDE ~Divine_Remix/lib/macro_spell_remove_good.tph~
Next, we would copy our existing CLAB and run these macros on it:
COPY_EXISTING ~myranger.2da~ ~override~ LAUNCH_PATCH_MACRO ~remove_blank_lines_from_eof~ // purge lines LAUNCH_PATCH_MACRO ~add_ranger_spells~ // add generic ranger spells LAUNCH_PATCH_MACRO ~spell_remove_good~ // removes evil, neutral-only spells LAUNCH_PATCH_MACRO ~shift_ranger_spells~ // shift generic ranger spells LAUNCH_PATCH_MACRO ~reindex_clab~ // re-index lines BUT_ONLY_IF_IT_CHANGES
So, putting it all together:
// your ADD_KIT command somewhere up here // if DR > v3 is installed prior to my mod ACTION_IF ((FILE_EXISTS_IN_GAME ~cdnegpp.spl~) AND (FILE_EXISTS ~Divine_Remix/lib/macro_reindex_clab.tph~)) THEN BEGIN INCLUDE ~Divine_Remix/lib/extra_regexp_vars.tph~ INCLUDE ~Divine_Remix/lib/macro_remove_blank_lines_from_eof.tph~ INCLUDE ~Divine_Remix/lib/macro_reindex_clab.tph~ INCLUDE ~Divine_Remix/lib/macro_add_ranger_spells.tph~ INCLUDE ~Divine_Remix/lib/macro_shift_ranger_spells.tph~ INCLUDE ~Divine_Remix/lib/macro_spell_remove_good.tph~ COPY_EXISTING ~myranger.2da~ ~override~ LAUNCH_PATCH_MACRO ~remove_blank_lines_from_eof~ // purge lines LAUNCH_PATCH_MACRO ~add_ranger_spells~ // add generic ranger spells LAUNCH_PATCH_MACRO ~spell_remove_good~ // removes evil, neutral-only spells LAUNCH_PATCH_MACRO ~shift_ranger_spells~ // shift ranger spells LAUNCH_PATCH_MACRO ~reindex_clab~ // re-index lines BUT_ONLY_IF_IT_CHANGES END
Similarly, the code for adding generic spells to druids, clerics, and paladins is also fairly straightforward:
// if DR > v3 is installed prior to my mod ACTION_IF ((FILE_EXISTS_IN_GAME ~cdnegpp.spl~) AND (FILE_EXISTS ~Divine_Remix/lib/macro_reindex_clab.tph~)) THEN BEGIN INCLUDE ~Divine_Remix/lib/extra_regexp_vars.tph~ INCLUDE ~Divine_Remix/lib/macro_remove_blank_lines_from_eof.tph~ INCLUDE ~Divine_Remix/lib/macro_reindex_clab.tph~ INCLUDE ~Divine_Remix/lib/macro_add_druid_spells.tph~ COPY_EXISTING ~mydruid.2da~ ~override~ LAUNCH_PATCH_MACRO ~remove_blank_lines_from_eof~ // purge lines LAUNCH_PATCH_MACRO ~add_druid_spells~ // add generic druid spells LAUNCH_PATCH_MACRO ~reindex_clab~ // re-index lines BUT_ONLY_IF_IT_CHANGES END // if DR > v3 is installed prior to my mod ACTION_IF ((FILE_EXISTS_IN_GAME ~cdnegpp.spl~) AND (FILE_EXISTS ~Divine_Remix/lib/macro_reindex_clab.tph~)) THEN BEGIN INCLUDE ~Divine_Remix/lib/extra_regexp_vars.tph~ INCLUDE ~Divine_Remix/lib/macro_remove_blank_lines_from_eof.tph~ INCLUDE ~Divine_Remix/lib/macro_reindex_clab.tph~ INCLUDE ~Divine_Remix/lib/macro_add_cleric_spells.tph~ // INCLUDE ~Divine_Remix/lib/macro_spell_remove_good.tph~ // optional--include good, evil, or neutral as appropriate COPY_EXISTING ~mydruid.2da~ ~override~ LAUNCH_PATCH_MACRO ~remove_blank_lines_from_eof~ // purge lines LAUNCH_PATCH_MACRO ~add_cleric_spells~ // add generic cleric spells // LAUNCH_PATCH_MACRO ~spell_remove_good~ // optional--include good, evil, or neutral as appropriate LAUNCH_PATCH_MACRO ~reindex_clab~ // re-index lines BUT_ONLY_IF_IT_CHANGES END // if DR > v3 is installed prior to my mod ACTION_IF ((FILE_EXISTS_IN_GAME ~cdnegpp.spl~) AND (FILE_EXISTS ~Divine_Remix/lib/macro_reindex_clab.tph~)) THEN BEGIN INCLUDE ~Divine_Remix/lib/extra_regexp_vars.tph~ INCLUDE ~Divine_Remix/lib/macro_remove_blank_lines_from_eof.tph~ INCLUDE ~Divine_Remix/lib/macro_reindex_clab.tph~ INCLUDE ~Divine_Remix/lib/macro_add_paladin_spells.tph~ INCLUDE ~Divine_Remix/lib/macro_shift_paladin_spells.tph~ INCLUDE ~Divine_Remix/lib/macro_spell_remove_good.tph~ COPY_EXISTING ~mypally.2da~ ~override~ LAUNCH_PATCH_MACRO ~remove_blank_lines_from_eof~ // purge lines LAUNCH_PATCH_MACRO ~add_paladin_spells~ // add generic paladin spells LAUNCH_PATCH_MACRO ~spell_remove_good~ // removes evil, neutral-only spells LAUNCH_PATCH_MACRO ~shift_paladin_spells~ // shift paladin spells LAUNCH_PATCH_MACRO ~reindex_clab~ // re-index lines BUT_ONLY_IF_IT_CHANGES END
One additional note: druid remix also open up druids to NG, LN, CN, and NE alignments. If you want your kit to reflect the expanded choices when DR is installed the following will help you. When you use ADD_KIT mykitname, WeiDU creates a variable named %mykitname% which this code must use. Substitute it as appropriate, but note that it is case sensitive--mykitname is not the same as MyKitName or MYKITNAME.
// your ADD_KIT mykitname goes here
// if DR > v3 is installed prior to my mod
ACTION_IF ((FILE_EXISTS_IN_GAME ~cdnegpp.spl~) AND (FILE_EXISTS ~Divine_Remix/lib/macro_reindex_clab.tph~)) THEN BEGIN
// change my kit to use expanded DR druid alignments
COPY_EXISTING ~alignmnt.2da~ ~override~
SET_2DA_ENTRY ("%mykitname%" + 19) 2 10 ~1~ // LN
SET_2DA_ENTRY ("%mykitname%" + 19) 4 10 ~1~ // NG
SET_2DA_ENTRY ("%mykitname%" + 19) 6 10 ~1~ // NE
SET_2DA_ENTRY ("%mykitname%" + 19) 8 10 ~1~ // CN
BUT_ONLY_IF_IT_CHANGES
END
If you only want your kit to open up to some of these alignments, delete the lines as needed.
Edited by CamDawg, 13 October 2006 - 09:12 AM.














