Jump to content

Adding special abilities to a kit


Guest Yuruilan

Recommended Posts

Guest Yuruilan

:)

 

I'm totally new to both modding and this site (Thanks for the wonderful tutorial, first off!). What I'd like to do is create a kit with some special abilities. I went through the tutorial, which I managed to follow (I think!). The problem comes when I wish to add abilities to a class. This is the idea I wish to use:

 

Basically a shadow warrior - thief with weapon spec. in katana, scimitar, dart, and single weapon fighting. Not able to use other missile weapons. That much was no problem.

 

Moving on from HERE is the difficulty... what the heck do I do now? I'd like to add some abilities, such as blur, mirror image, shadow door, and summon invisible stalker. The limitations would be 20 points max in thieving abilities, and the weapon prof losses above. I saw that the Wushi Ninja was very similar, and so I thought to look it over for ideas on how to go about modding, but I became utterly lost from "Copy_existing..." on!

 

If someone could give me an idea of how to add one of these abilities (for example, adding blur at 3rd level as an innate ability) I could probably (hopefully!) figure out the rest. It's that first one that kills.

 

Thanks in advance!

Link to comment

Hey Yurilian, welcome to G3. :)

 

For a first time modder, you may want to make spells in an editor and just copy them with your mod instead of altering spells on the fly like the Wushi Ninja kit. I'm not sure what level of experience you're at, so I'm going to take this from a low level and try to explain everything.

 

What differentiates an innate ability from a wizard or priest spell are just a handful of values in the spell file. The Wushi Ninja kit just takes mage spells and clones them into innates with the following:

 

// Adding abilities for the Wushi Ninja Kit
COPY_EXISTING ~SPWI217.spl~ ~override/C!WNAGN.spl~ // aganazzar's scorcher innate
             ~SPWI201.spl~ ~override/C!WNBLR.spl~ // blur innate
             ~SPPR103.spl~ ~override/C!WNCLW.spl~ // cure light wounds innate
             ~SPWI112.spl~ ~override/C!WNMGM.spl~ // magic missile innate
             ~SPWI212.spl~ ~override/C!WNMIG.spl~ // mirror image innate
             ~SPWI115.spl~ ~override/C!WNSHG.spl~ // shocking grasp innate
             ~SPWI513.spl~ ~override/C!WNBRC.spl~ // breach innate
             ~SPWI522.spl~ ~override/C!WNMST.spl~ // minor spell turning innate
             ~SPWI505.spl~ ~override/C!WNSHD.spl~ // shadow door innate
 READ_LONG   0x64 "offset_abil"            // reads offset of first ability
 READ_SHORT  0x68 "num_abil"               // reads total number of abilities
 READ_ASCII ("%offset_abil%" + 0x04) "bam" // reads the bam filename from ability
 WRITE_SHORT 0x1C 4                        // sets spell type to innate (4)
 WRITE_LONG  0x34 1                        // sets spell level to 1 to avoid scripting issues
 WRITE_LONG  0x3A 0                        // nulls icon field pt 1
 WRITE_LONG  0x3E 0                        // nulls icon field pt 2
 WRITE_EVALUATED_ASCII 0x3A "%bam%"        // writes the bam filename from abilities to spell icon
 WHILE (0 < "%num_abil%") BEGIN            // loops once for every ability
   WRITE_SHORT (("%offset_abil%" + 0x02) + (("%num_abil%" - 1) * 0x28)) 4 // changes ability icon location to innate (4)
   WRITE_SHORT (("%offset_abil%" + 0x02) + (("%num_abil%" - 1) * 0x28)) 4 // changes ability icon location to innate (4)
   SET "num_abil" = ("%num_abil%" - 1)
 END

 

Open Magic Missile (SPWI112.spl) with Near Infinity and select Show Hex Offsets under Options--it'll make the rest of this easier. The difference between a mage and innate spell is in two areas: Spell Type, at 0x1c and a second field in each ability in the spell. Spell Type allows you to choose between Special, Wizard, Cleric, Innate, and Unknown. We set this to innate with

 

WRITE_SHORT 0x1C 4                        // sets spell type to innate (4)

 

One other change we make here is to set the level to one--innate abilities can sometimes cause the engine problems if they're not set to level 1, so we add this patch:

 

  WRITE_LONG  0x34 1                        // sets spell level to 1 to avoid scripting issues

 

The next part we need to change is in the abilities. If you double-click on any of the abilities, you'll notice there's an 'Ability Icon Location' field which has the options of Spell Slots, Innate Slots, and three Unknowns. We need to change these to innates, but in this case it's a bit more complicated. The biggest problem is that anything in a spell file after 0x72 may not be in the same location, depending on mods and other changes in a player's game.

 

Unlike the spell type, which is always at offset 0x1c, this field will change. So we read in data from other parts of the file to determine where it is, how many abilities we need to patch, and then loop through each one and patch them. First we need to read in data that will help us:

 

  READ_LONG   0x64 "offset_abil"            // reads offset of first ability
 READ_SHORT  0x68 "num_abil"               // reads total number of abilities

 

offset_abil is the offset of where the abilities start in the file and this value is always at 0x64. num_abil is the total number of abilities; we ned this info to figure out how many abilities we need to patch. With this information, we start looping through the abilities and patching the spell slot info:

 

  WHILE (0 < "%num_abil%") BEGIN            // loops once for every ability
   WRITE_SHORT (("%offset_abil%" + 0x02) + (("%num_abil%" - 1) * 0x28)) 4 // changes ability icon location to innate (4)
   SET "num_abil" = ("%num_abil%" - 1)
 END

 

For some reason, the Wushi Ninja has two identical WRITE_SHORT lines in this patch--I've ommitted the second as it's redundant. The basic idea behind a WHILE loop is that you give it a logical test--in this case, if num_abil is greater than zero--and as long as that logical test is true, it will keep repeating. So we start the loop based on the number of abilities, and reduce that number by one on every pass with

 

SET "num_abil" = ("%num_abil%" - 1)

 

This means the WHILE loop will execute once for every ability; i.e. four abilities means this loop runs four times. If we don't reduce the value on each pass, the logical test (num_abil > 0) will always be true and this will loop infinitely.

 

On each pass, we patch the Spell Slot field with:

 

WRITE_SHORT (("%offset_abil%" + 0x02) + (("%num_abil%" - 1) * 0x28)) 4 // changes ability icon location to innate (4)

 

This calculation is what gives us the correct value for the spell slot field on each ability. offset_abil is the location of where abilities start, and the Spell Slot field is 0x02 from the start of an ability, so ("%offset_abil%" + 0x02) will hit the Spell Slot field. The (("%num_abil%" - 1) * 0x28)) is a bit more complicated--if this was not included, the loop would only patch the first ability, no matter how many times it runs. The second part moves the location of the patch 0x28 (the length of one ability) on every loop, ensuring that every ability gets patched. The Spell Slot field gets patched to a value of 4 for innate slots.

 

The rest of the patch is mroe or less cosmetic:

 

  READ_ASCII ("%offset_abil%" + 0x04) "bam" // reads the bam filename from ability
 WRITE_LONG  0x3A 0                        // nulls icon field pt 1
 WRITE_LONG  0x3E 0                        // nulls icon field pt 2
 WRITE_EVALUATED_ASCII 0x3A "%bam%"        // writes the bam filename from abilities to spell icon

 

Spells have three BAMs: fooA.bam, which is the spell icon on a scroll, fooB.bam, which is the spell icon on a black stone (used for the menu at the bottom of the screen), and fooC.bam, which is an icon on a clear background for the pages of your spellbook. The abilities in a spell file, whether mage, cleric, or innate, always use the 'b' version of a spell's icon. However, the icon listed at 0x3a is another matter--innates use the B version here, whereas mage and cleric spells use the C version. The four lines above basically erases the current icon listed with

 

  WRITE_LONG  0x3A 0                        // nulls icon field pt 1
 WRITE_LONG  0x3E 0                        // nulls icon field pt 2

 

reads in the B version of the icon from the first ability

 

  READ_ASCII ("%offset_abil%" + 0x04) "bam" // reads the bam filename from ability

 

and then writes it to the spell icon field at 0x3a.

 

  WRITE_EVALUATED_ASCII 0x3A "%bam%"        // writes the bam filename from abilities to spell icon

 

It's worth noting that the first step in this is now obsolete; I can erase the old value when I write in the new one by using this instead:

 

  READ_ASCII ("%offset_abil%" + 0x04) "bam" // reads the bam filename from ability
 WRITE_EVALUATED_ASCII 0x3A "%bam%" #8     // writes the bam filename from abilities to spell icon

 

The #8 tells WeiDU to overwrite 8 characters, whether or not the new value is actually eight characters long.

Link to comment
Guest Guest

From the Tutorial King himself! Thanks a lot for going through this!

 

Okay, just to confirm I have this (pardon the EXTREMELY newb questions... I'm not a lvl 1 in the D&D sense, but in the MMO sense, where small puppies and questionable cheeses threaten my life and sanity)

 

Alright, I assume firstly that, by editor, you're referring to WeiDU. I have both it and Near Infinity, though admittedly WeiDU is more than a little daunting. But, being as I'm terminally conceited, I'm sure it'll be a snap.

 

Let me see if I've got all this correct: Here's an example (to show just how terrible this is likely to turn out, allow me to ask my first question (which ought to send tremors of fear along your spine... where do I write the code? Would a text editor suffice, and I just save the resulting chaos as a .tp2 file, along with the original defining stuffs (class, race, etc.)? Or can I actually use NI and just edit the values directly, saving it as a new file?))

 

 // Adding abilities for the shadow warrior kit

COPY_EXISTING 
    ~SPW112.spl~ ~override/C!SWMGM.spl~ // C!SWMGM.spl will be the edited version of magic missile, correct?  Assuming that SWMGM.spl is my personal creation of the spell...
 WRITE_SHORT 0x1c 4 // sets spell to innate
 WRITE_LONG 0x34 1 // sets spell to lvl 1 to avoid problems
 READ_LONG   0x64 "offset_abil" // starting point for the first ability
 READ_SHORT 0x68 "num_abil" // reads the total number of abilities
 READ_ASCII ("%offset_abil%" + 0x04) "bam" // reads the bam filename from ability
  WRITE_LONG  0x3A 0                        // nulls icon field pt 1
  WRITE_LONG  0x3E 0                        // nulls icon field pt 2
  WRITE_EVALUATED_ASCII 0x3A "%bam%"        // writes the bam filename from abilities to spell icon    
   WHILE (0 < "%num_abil%") BEGIN            // loops once for every ability
      WRITE_SHORT (("%offset_abil%" + 0x02) + (("%num_abil%" - 1) * 0x28)) 4 // changes ability icon location to innate (4)
      SET "num_abil" = ("%num_abil%" - 1)
   END

 

Just a couple of questions: First off, is the while...end mini-program something that can work for all spells and abilities equally (when making them innate), or will the values change (the num_abil, since you mentioned that the offset_abil value remains the same throughout)? In other words, can I cut and paste that bit over and over (please... please? :) )? Question two... now that I've got that up and running... how do I put it into the class itself at the proper level? For example, if I wanted to make my magic missile ability a 1st level innate, how to I assign it to the 1st level?

 

Thanks TONNES for the help so far!

Link to comment
Let me see if I've got all this correct:  Here's an example (to show just how terrible this is likely to turn out, allow me to ask my first question (which ought to send tremors of fear along your spine... where do I write the code?  Would a text editor suffice, and I just save the resulting chaos as a .tp2 file, along with the original defining stuffs (class, race, etc.)?  Or can I actually use NI and just edit the values directly, saving it as a new file?))

This is tp2 code, so you would add it to the same tp2 file as ADD_KIT. A tp2 is just a text file with the extension changed. And yeah, you could just do all this editing with NI or DLTCEP and then just copy your new spell file instead of doing this on the fly. ;)

 

COPY_EXISTING 
    ~SPW112.spl~ ~override/C!SWMGM.spl~ // C!SWMGM.spl will be the edited version of magic missile, correct?  Assuming that SWMGM.spl is my personal creation of the spell...

 

C!SWMGM.spl will be the filename of the new spell. I should probably go ahead and ask that you register a prefix instead of using mine. :)

 

Just a couple of questions:  First off, is the while...end mini-program something that can work for all spells and abilities equally (when making them innate), or will the values change (the num_abil, since you mentioned that the offset_abil value remains the same throughout)?  In other words, can I cut and paste that bit over and over (please... please? :D )?

num_abil is read from the spell file you're patching, so this is a completely generic patch. You can use it to convert any spell file to an innate with the only change needed being in the filenames. You'll see this patch repeatedly throughout SPC, and often it's converting multiple spells in one go--the code in my first post is converting nine spells, some priest, some mage.

 

Question two... now that I've got that up and running... how do I put it into the class itself at the proper level?  For example, if I wanted to make my magic missile ability a 1st level innate, how to I assign it to the 1st level?

Your kit's CLAB file is what determines when the kit gets abilities. If you want to gain the ability at level one, just add GA_filename (you don't need the .spl) in column 1 in your CLAB file. If you want them to get more than one, add another GA_filename in column 1. To add it at another level, add GA_filename to the column that corresponds to the level, etc., etc.

 

Thanks TONNES for the help so far!

Glad to help. :)

Link to comment
Guest Yuruilan

C!SWMGM.spl will be the filename of the new spell. I should probably go ahead and ask that you register a prefix instead of using mine. :)

 

WHOOPS! Sorry, didn't realize that was what the C! was... right, I'll stop. :)

 

num_abil is read from the spell file you're patching, so this is a completely generic patch. You can use it to convert any spell file to an innate with the only change needed being in the filenames. You'll see this patch repeatedly throughout SPC, and often it's converting multiple spells in one go--the code in my first post is converting nine spells, some priest, some mage.

 

Your kit's CLAB file is what determines when the kit gets abilities. If you want to gain the ability at level one, just add GA_filename (you don't need the .spl) in column 1 in your CLAB file. If you want them to get more than one, add another GA_filename in column 1. To add it at another level, add GA_filename to the column that corresponds to the level, etc., etc.

 

Ah HA! Right, I'll look into that one. I assume that's a file I'll have to create and copy in as well. Will peruse the various CLAB files I find and figure out what's what (and ply the forum with questions once I've done it!)

 

This has to be one of the most helpful forums I've found so far on just about any topic... let alone a game that's what... 5 years old? Still the best RPG ever, though.

Link to comment
Guest Yuruilan

Okay, I've got a problem. I'm trying to install the thing using weidu-mac... but it claims there's not Chitin.key file in the directory (which there is... I'm staring at the stupid thing now!). I've weidu in my BG-SOA directory, and the file name I want to install is Kakunin.tp2.

 

Any ideas?

 

I'm assuming to install the thing, I type Weidu-mac kakunin.tp2, right?

 

Sorry if I sound like a complete fool... I was coding back in the days of the Apple IIc, but gave it up about 10 years ago... and everything's changed.

 

I miss Basic!

Link to comment

This is from memory, so this is my advice until one of the OS X folks comes along to correct me. :)

 

If you install the WeiDU package from the Spa & Grill, WeiDU-Mac lives in some obscure /usr/local/random/Unixy/path directory. So when you invoke it directly with WeiDU-mac foo.tp2, it runs in that directory instead of where your tp2 (and BG2) lives. There are directions somewhere at S&G that explains how to get around this, but I can't remember where they are atm.

 

G3 mods use a .command file that basically says 'use the copy of WeiDU that's right here' and 'run in this directory.' You may want to just grab a .command file from one of the G3 mods and edit it.

Link to comment
Guest Yuruilan

Okay, what I did was grab a copy of your sweet G3Tweaks pack and edited the Setup-G3Tweaks.command file to look like this:

 

command_path=${0%/*}
cd "$command_path"
./Setup-K

 

Where setup-K = setup-k is the Weidu file name and k.tp2 is the tp2 file I wish to get installed. I stuck this in textedit, and made sure it was turned to plain text, not rich text. I saved it as a unicode 16 file. :) Now it tells me the thing's not an executable file! I don't know if I'm retarded or what, but it seems utterly incapable of working for me...

 

One perhaps HUGE problem is that I created the .tp2 in textedit. Should I have used BBEdit, and if so, what file type should I have saved it as? When I tried BBEdit out, it saved it as a BBEdit file... :) If it is the case that I shouldn't have used textedit, should I rewrite the file in BBEdit and save it as... something or other type file? Is saving it as a <filename>.tp2 enough using BBEdit (Lite)? Sorry for all the simp questions!

Link to comment
Guest Yuruilan

Last question (eh heh... :) )

 

IF I find I'm far too incapable of doing all this on the fly using Weidu, is it possible to use Near Infinity to do the same stuff, and if so, how to I add the appropriate files, like the new .spl files, .2da files, etc (or can you point me to a Near Infinity tutorial that would save you lots of time and frustration no doubt? :) )

 

Ever thankful!

Link to comment

Sounds like a permission issue (yay, *nix!). You need to identify the command file as executable--if you're comfortable with the OS X shell, navigate to the file and use

 

chmod 755 foo.command

 

If 755 doesn't work, try 777.

 

I think you may be able to also change permissions by right-clicking thie file (or for the hardcore OMG NO TWO-BUTTON MICE Macophiles, command-click with your single button) and going to Get Info or something. I think.

 

Dammit, where's devSin when you need him? Maybe I should summon him by mentioning an obscure WeiDU reference, like BLSL or something.

Link to comment

I've read the thread, but didn't comment. I'm pretty terrible when it comes to user-level advice.

 

Okay, I've got a problem. I'm trying to install the thing using weidu-mac... but it claims there's not Chitin.key file in the directory (which there is... I'm staring at the stupid thing now!). I've weidu in my BG-SOA directory, and the file name I want to install is Kakunin.tp2.
This is almost certainly an issue where you're not actually working in the directory you think you're in. WeiDU needs to be run while the Baldur's Gate II folder is the current working directory (WeiDU itself can be anywhere).
cd /Applications/Baldur\'s\ Gate\ II
./weidu myMod.tp2

The first command changes the current working directory to the directory specified. You can type it in manually, or simply type "cd " and then drag and drop the Baldur's Gate II folder onto the Terminal application. The path you specify will be wherever BG2 happens to be on your system. After doing that, hit return, and the prompt should be something like

ComputerName:/Path/To/BG2 userName$

Then, you just have to run WeiDU (if it's in the search path, you can just type weidu myMod.tp2, where "weidu" is the name of the WeiDU application on your system; if it's in the BG2 folder, type ./weidu myMod.tp2).

 

Now it tells me the thing's not an executable file!
As Cam suggested, you need to set your access permissions. You should just be able to open Terminal, type "chmod a+x " and then drag and drop the .command file onto the Terminal window and hit return. You can then double-click the command file to launch a new Terminal session (make sure the .command file is in the BG2 folder).

 

One perhaps HUGE problem is that I created the .tp2 in textedit.
It depends. Your TP2 cannot be RTF or anything other than plain-text. You cannot save in an encoding that isn't byte-for-byte compatible with US-ASCII. For a TP2, you would save the document as text/plain, MacRoman (you cannot use UTF-16, as the byte-order mark will confuse WeiDU; you could use UTF-8 as long as you don't use any characters not defined in the ASCII character set and save the file with no BOM). To be safe, just use BBEdit or TextWrangler (free) to write your TP2s, and make sure to save the file with Unix line-breaks and use Western (Mac OS Roman) as the encoding.

 

IF I find I'm far too incapable of doing all this on the fly using Weidu, is it possible to use Near Infinity to do the same stuff, and if so, how to I add the appropriate files, like the new .spl files, .2da files, etc
I'll let others cover NearInfinity and how to link certain files together using resource references; as far as Mac-specific stuff goes, make sure you have two files in the main BG2 folder: "baldur.exe" and "BGConfig.exe" -- just create these files (or copy and rename an existing file). They don't have to actually contain anything (0 byte files are OK), they just allow NearInfinity to figure out which game you have. If you're running Mac OS X v10.4 Tiger, you'll want to download the Java 1.5 update from the Apple website and use the latest beta version of NearInfinity (otherwise, stick with the released version).

 

Anyway, once you get all your files set up, they just go into the override folder (that's all it takes to have them available to the game). It takes a little more magic to actually get them in the game (you can use the CLUAConsole, scripts, patches to CREs or AREs, etc.), but that's all common stuff that other people can talk about.

Link to comment
Guest Yuruilan

Well, I went about it the LOOONG way: I edited an already working mod to use my stats instead, and added the rest of the info directly, through NI. Thank god it works! Thanks for all the help; I'll try to package the sucker once I'm a bit more comfortable with scripting and once I see if it's balanced or not.

Link to comment

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...