Modifying Spells in your adventure

Our adventure has pretty much the same set of spells that is in "Return of Kra'an". Recall that in "Return of Kra'an", CALEB is a fighter class, and fighter classes don't know any spells except for NEAR FOE at spell level 2. In this chapter, we are going to give the fighter class (and hence, CALEB) more spells. First we will modify an existing spell to give him access, and then create a new spell just for the fighter class. The overall procedure for this change is the same as before, and we'll just be modifying two files again: spells.txt and heroes.txt.

1) Give CALEB the disbelieve spell at spell level 1

Open up the file DB2ACK/Adventures/MyAdventure/lists/spells.txt in a text editor. Expand the window so that you can see as much of a row in your window as possible. Each non-comment row in this file represents a different spell in "My Adventure". For a detailed explanation of the meaning of each field in the rows, see the documentationon spells.

Search for the spell "DISBELIEVE". With the two rows of comments, it should look like this:

#X  "12345678901234567890123456"   cure_insanity   255   255  255 255   255  7          [combat]   
##  "NAME"                         SpellType      value fire magic SP  spec rang verb          [no_combat]  0  1  2  3  4  5  6  7  8  9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
31  "DISBELIEVE"                   disbelieve       0    0     0   4    0    1   casts   combat      -      -  -  -  1  -  -  -  1  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -

We are interested in the long array of 32 dashes and numbers at the end of the row. Each position in that list represents whether or not a certain character class (such as fighter, dwarf, archer, wizard, etc) has the ability to cast the spell, and if so, at what spell level they can cast it. Note that at the top of spells.txt, there are some comments which state that the fighter class is character class #1, and at his class's position in the list, there is a '-' character meaning that class cannot cast the given spell.

To give the fighter class the ability to cast the spell, change that '-' character to a '0'. Spell levels are actually numbered 0-3 in this list to represetnt spell levels 1-4. After this one character change, the line should read:

#X  "12345678901234567890123456"   cure_insanity   255   255  255 255   255  7          [combat]   
##  "NAME"                         SpellType      value fire magic SP  spec rang verb          [no_combat]  0  1  2  3  4  5  6  7  8  9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
31  "DISBELIEVE"                   disbelieve       0    0     0   4    0    1   casts   combat      -      -  1  -  1  -  -  -  1  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -
2. Create a new spell that gives fighters the ability to do a magic punch.

Remember that for all of these lists, new items must be added to the end in order to preserve the order of existing items. So scroll to the end of the spells.txt file, and add the following line (you may want to cut and paste to ensure that there are no typos):

#X  "12345678901234567890123456"   cure_insanity   255   255  255 255   255  7          [combat]   
##  "NAME"                         SpellType      value fire magic SP  spec rang verb          [no_combat]  0  1  2  3  4  5  6  7  8  9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
158  "SUPER PUNCH"                  attack           6    0     3   1    0    1   casts   combat     -      -  0  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -

Again, for a complete description of the fields above, refer to the documentation. But basically, this spell is of type "attack" meaning it will attack a monster, and it is only accessible to fighter classes at spell level 1 because only character class #1 has a '0', while the rest are '-'. Also note that this spell costs 1 SP, has a range of 1 (10'), and does 6 physical + 3 magic damage. Also note the word "combat", indicating that this spell is available in combat mode, and note that in the "non-combat" field, there is a '-' meaning that the spell cannot be cast in non-combat mode.

There are approximately 2 dozen types of spells in addition to the "attack" spell that we added above. To create a new spell of a given type, it is always helpful to study one of the existing examples that are available in spells.txt first.

When finished with your edits, save your changes and exit the text editor.

3) Compile with mkpdbs, delete your old save game, and install the new version of MyAdventure.pdb on your Palm, as before.

4) Run your adventure on the Palm, and get into a fight

In order to see the two combat spells we gave to CALEB's character class, we'll have to view his spells during combat. In the North-West corner of the SAMPLE 1 map is a "monster pen" that you can wander around in, looking for trouble. Note that at spell level one, you can only see the SUPER PUNCH spell that we gave him because the DISBELIEVE spell is not available to him until spell level 2, and CALEB doesn't get those spells until he reaches character level 5.



Of course one way to use spells in your adventure is to just set the character classes that can use the spell right there on the spell's row as we have done here. Beyond the scope of this tutorial, you should read the relevant sections of the documentation to see how the spell number (the first number on the row) can be referenced by items in objects.txt, monsters.txt, characters.txt and maps to give certain spells to magic items, monsters, elementals, and traps.

Congratulations! You now know how to go about modifying spells in your adventure. Modifying monsters and character class attributes is not much different than modifying the spells, characters, and objects, as we have already done. So in the next section, we will begin modifications to the maps in My Adventure.