Author Topic: Adding Custom Innate Abilities to an NPC  (Read 9326 times)

Offline Bons

  • Global Moderator
  • Planewalker
  • *****
  • Posts: 1237
  • Gender: Female
  • Glad Corvis Isn't Dead Club
Adding Custom Innate Abilities to an NPC
« on: July 02, 2005, 11:49:24 PM »
Adding Innate Abilities to a NPC

For this Tutorial, you need DLTCEP & WeiDU.

A.   Create your NPC. This tutorial assumes you know how to do that. If not, see Ghreyfain’s “A Beginner's Guide to NPC Creation with WeiDU” for more information. My example NPC is Shemp, a Jester:
(http://bons.50megs.com/shemp1.jpg)

B.   I have decided that I want to give Shemp “Chaos” as an innate ability, only I am going to call it “Pratfall.” (This will add to the depth of roleplaying, I am sure.) Unfortunately, there is no “Chaos” innate in the game already. I shall have to make one. I’ll use the wizard spell “Chaos” [SPWI508.SPL] as my starting point.

C.   I will need to make some adjustments by opening the spell in DLTCEP and:
      1.   In General Properties, change the spell type to 4-Innate, and Level to 1.
(http://bons.50megs.com/shemp3.jpg)
      2.   I will also need to alter the name of the spell, but I will do that upon install in my tp2.
      3.   In Extended Effects, I need to change the Location to 4-Innate for each Extended Header. Since “Chaos” has four extended headers, I’ll be adjusting from 2-Spell to 4-Innate four times total.
(http://bons.50megs.com/shemp2.jpg)
      4.   Last but not least, save the edited spell. I will use the name SHEMP.SPL for this tutorial. Sidenote: save the spell file to your override folder. I've had trouble with DLTCEP adding an external spell file.

D.   Now I am going to assign the new innate ability to Shemp.
      1.   Open the CRE in DLTCEP. Go to the Items & Spells tab.
      2.   We need to add an Innate spell slot to our CRE if they don't have one already. In the ‘Memorized Spells And Innates’ section of the screen, adjust the Spell Level & Type to ‘1’ and ‘Innate.’ Click the ‘Add level slot’ button. If you look at the Level Slot drop down list now, you will see an Innate slot has been added.
(http://bons.50megs.com/shemp4.jpg)
      3.   With ‘Innate Level 1’ chosen in the Level Slot field, type in the name of the Innate spell in the Resource field (In this case, I type SHEMP.). Make sure the 'Memorized?' box is checked. Click the ‘New Spell’ button. The number of memorizable spells should increase by one. This has added the spell to the CRE’s innates.
      4.   Save the CRE.

E.   The last step involves adding the new Innate Ability’s name. In my tp2, I would have something like this to add the spell for my mod:

Code: [Select]
COPY ~Shemp\spells\shemp.spl~ ~override\shemp.spl~
SAY NAME1 ~Pratfall~

F.   Bask in the joy of knowing your NPC has a nifty new innate ability!
« Last Edit: July 22, 2005, 07:10:31 PM by Bons »
Newt had always suspected that people who regularly used the word "community" were using it in a very specific sense that excluded him and everyone he knew.

             --Neil Gaiman, Terry Pratchett, "Good Omens"

Offline Bons

  • Global Moderator
  • Planewalker
  • *****
  • Posts: 1237
  • Gender: Female
  • Glad Corvis Isn't Dead Club
Re: Adding Custom Innate Abilities to an NPC
« Reply #1 on: July 22, 2005, 09:50:05 PM »
I've been experimenting with performing adding an innate ability, only making WeiDU do everything on install. This code in my tp2 accomplishes the same tasks as covered in the above tutorial:
Code: [Select]
// Make the innate version of the new spell

COPY_EXISTING ~SPWI508.SPL~ ~override/SHEMP.SPL~
     SAY NAME1 ~Pratfall~
     WRITE_SHORT 0x001c  4 // Change Type of spell to Innate
     WRITE_LONG 0x0034  1 // Change level to 1
     READ_LONG   0x0064  "header_offset" //Extended header offset
     READ_SHORT   0x0068  "header_count" //Extended header count
     WHILE (0 < "%header_count%") BEGIN  // We want to loop through each extended header and make the desired change
         WRITE_SHORT (("%header_offset%" + 0x02) + (("%header_count%" - 1) * 0x28)) 4 // Changes Ability Icon Location to 4-Innate
         SET "header_count" = ("%header_count%" - 1) //Go to next header
     END

// Add Innate Ability to CRE
COPY ~Shemp/cre/shemp.cre~ ~override/shemp.cre~
    SAY NAME1 ~Shemp~
    SAY NAME2 ~Shemp~

    //Add innate spell slot.

    READ_LONG 0x02a8 "level_slots_offset" //Existing memorized slot offset
    READ_LONG 0x02ac "num_level_slots" //Existing memorized slot count
    READ_LONG 0x02b0 "mem_offset" //Memorized spells offset
    READ_LONG 0x02b4 "mem_count" //Memorized spells count
    READ_LONG ~0x02b8~ "item_slots_offset" //Start of inventory locations
    READ_LONG ~0x02bc~ "item_offset"   //Start of actual item descriptions
    READ_LONG ~0x02c0~ "num_items" //Number of items on the CRE
    READ_LONG ~0x02c4~ "eff_offset" //Start of effect descriptions
    READ_LONG ~0x02c8~ "num_eff" //Number of CRE effects
    WRITE_LONG 0x02b0 ("%mem_offset%" + 16)
    WRITE_LONG 0x02b8 ("%item_slots_offset%" + 16)
    WRITE_LONG 0x02bc ("%item_offset%" + 16)
    WRITE_LONG 0x02c4 ("%eff_offset%" + 16)
    WRITE_LONG 0x02ac ("%num_level_slots%" + 1) //Increase count of slots by 1
    INSERT_BYTES ("%level_slots_offset%" + "%num_level_slots%" * 16) 16 //Insert bytes for new slot
    WRITE_SHORT ("%level_slots_offset%" + "%num_level_slots%" * 16)0 // Level of spell-1
    WRITE_SHORT ("%level_slots_offset%" + "%num_level_slots%" * 16 + 2)1 //Number memorizable
    WRITE_SHORT ("%level_slots_offset%" + "%num_level_slots%" * 16 + 4)1 //Number memorizable
    WRITE_SHORT ("%level_slots_offset%" + "%num_level_slots%" * 16 + 6)2 // 2=Innate Spell Type
    WRITE_SHORT ("%level_slots_offset%" + "%num_level_slots%" * 16 + 8) ("%mem_count%") // Point to the first memorized spell of this type and level
    WRITE_SHORT ("%level_slots_offset%" + "%num_level_slots%" * 16 + 12)1//Number of spells of this level and type.
   
   // End of adding the new slot.

   // Now let's add the new memorized spell.

    READ_LONG 0x02b0 "mem_offset" //Memorized spells offset
    READ_LONG 0x02b4 "mem_count" //Memorized spells count
    READ_LONG ~0x02b8~ "item_slots_offset" //Start of inventory locations
    READ_LONG ~0x02bc~ "item_offset"   //Start of actual item descriptions
    READ_LONG ~0x02c0~ "num_items" //Number of items on the CRE
    READ_LONG ~0x02c4~ "eff_offset" //Start of effect descriptions
    READ_LONG ~0x02c8~ "num_eff" //Number of CRE effects
    WRITE_LONG 0x02b8 ("%item_slots_offset%" + 12)
    WRITE_LONG 0x02bc ("%item_offset%" + 12)
    WRITE_LONG 0x02c4 ("%eff_offset%" + 12)
    WRITE_LONG 0x02b4 ("mem_count" + 1) //Increase count of memorized spells by 1
    INSERT_BYTES ("%mem_offset%" + "%mem_count%" * 12) 12 //Insert bytes for new memorized spell
    WRITE_ASCII ("%mem_offset%" + "%mem_count%" * 12) "SHEMP" // File name of added innate spell
    WRITE_SHORT ("%mem_offset%" + "%mem_count%" * 12 + 8) 1 // 1 = Spell Memorized, 0 = Not Memorized
« Last Edit: July 23, 2005, 09:55:17 AM by Bons »
Newt had always suspected that people who regularly used the word "community" were using it in a very specific sense that excluded him and everyone he knew.

             --Neil Gaiman, Terry Pratchett, "Good Omens"

Offline Idobek

  • Dust Bunny
  • Planewalker
  • *****
  • Posts: 431
  • Gender: Male
Re: Adding Custom Innate Abilities to an NPC
« Reply #2 on: July 23, 2005, 08:39:39 AM »
Thanks Bons. I was doing something similar a couple of days ago (removal of memorized spells, not adding), looking at this made me realise that I have assumed the memorization info table is in the correct (ie sequential) spell type and spell level order, I shouldn't do this.

I don't think this code is going to do exactly what you want. You need to add the innate to both the memorized spells table and the known spells table (otherwise once it has been cast it won't be re-memorized).
The Gibberlings Three Forums

<SimDing0> Did you know G3 has secret forum rules?
<CamDawg> Yep. They're generally of the nature 'don't annoy Idobek.'

Offline Bons

  • Global Moderator
  • Planewalker
  • *****
  • Posts: 1237
  • Gender: Female
  • Glad Corvis Isn't Dead Club
Re: Adding Custom Innate Abilities to an NPC
« Reply #3 on: July 23, 2005, 10:24:54 AM »
I don't think this code is going to do exactly what you want. You need to add the innate to both the memorized spells table and the known spells table (otherwise once it has been cast it won't be re-memorized).

We'd talked about ADD_KNOWN_SPELL when I started messing with the tp2 code, so I made sure to test whether adding to the known spells table was required. It's not necessary to know a spell for it to function as an innate ability. An innate, as long as it is included among the memorized spells, will recharge upon rest. Adding a priest or wizard type spell in the known spells table, on the other hand, is required for proper functionality within the spellbook.

Thanks to Idobek, I trimmed out the unnecessary dialogue references in the above code.

Newt had always suspected that people who regularly used the word "community" were using it in a very specific sense that excluded him and everyone he knew.

             --Neil Gaiman, Terry Pratchett, "Good Omens"

 

With Quick-Reply you can write a post when viewing a topic without loading a new page. You can still use bulletin board code and smileys as you would in a normal post.

Warning: this topic has not been posted in for at least 120 days.
Unless you're sure you want to reply, please consider starting a new topic.

Name: Email:
Verification:
Type the letters shown in the picture
Listen to the letters / Request another image
Type the letters shown in the picture:
What color is grass?:
What is the seventh word in this sentence?:
What is five minus two (use the full word)?: