In the course of the Cleric Remix mod, this issue is coming up repeatedly, and frankly, I got tired of making the same changes over and over. Another potential issue is that if another mod wants to alter the spell you're modifying, you could end up with an innate and mage version of a spell that do different damage, save penalties, etc. since the innate version is based on the modder's install, while the player's version is based off another mod.
The ideal solution is to use a COPY_EXISTING command and patch as you go along. The following example is one I used to change the mage spell Chain Lightning SPWI615.spl into an innate ability named C!TLCHNL.spl for the Cleric Remix mod.
WRITE_SHORT 0x1C 4 // sets spell type to innate (4)
WRITE_LONG 0x34 1
READ_LONG 0x64 "offset_abil"
READ_SHORT 0x68 "num_abil"
READ_ASCII ("%offset_abil%" + 0x04) "bam" // reads the bam filename from ability
WRITE_EVALUATED_ASCII 0x3A "%bam%" // writes the bam filename from abilities to spell icon
SAY NAME1 ~blah~
SAY NAME2 ~blah~
SAY UNIDENTIFIED_DESC ~blah~
SAY DESC ~blah~
WHILE (0 < "%num_abil%")
WRITE_SHORT (("%offset_abil%" + 0x02) + (("%num_abil%" - 1) * 0x28)) 4 // changes ability icon location to innate (4)
SET "num_abil" = ("%num_abil%" - 1)
This could also be used in reverse, or to change wizard to priest spells, etc. by altering the number 4 (in bold) in the two WRITE_SHORT commands. If you wanted to alter the name and description of the spell, all of the normal SAY commands can be used with the COPY_EXISTING command. The SAY commands in this example are in gray and are entirely optional as you would only need them if you wanted to change the name and/or description of the spell.
The section in green is the meat of the routine. First, you read in the number of abilities and where they begin in the file. Then, you create a loop using WHILE that goes through and patches every ability with the icon location of innate (4). You need the number of abilities and their offset to determine how many times WHILE will loop and the exact offset to patch.
The section in purple is used to change the BAM of the spell icon and is also an optional component. By convention, every spell has three icons, named xxxxA.bam, xxxxB.bam, and xxxxC.bam. The A version is used on scrolls, the B version is what shows up in your spellbook, and the C version is displayed on the bottom bar of the game screen when selecting your spell from the "Cast Spell" or "Special Abilities" button. In this example, we're using the fact that the 'Abilities' headers of spells always use the B version of the icon, and copying the name over to the general spell. Please not that this section is specific to changing spells into innates; do not use this block if you're changing a spell into a wizard or priest spell.
edit: Thanks for the cleaner code, Idobek!
Edited by CamDawg, 17 July 2004 - 04:48 PM.