Dynamically Adding Spells to Merchants

Revision as of 23:49, 17 April 2006 by imported>KyneTarse
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Here's a simple but effective way to get custom spells into merchants' inventories without directly modifying the NPC. This method will prevent conflicts that arise from multiple mods adding spells or items to the same merchant.

First, create an activator to place in the NPC's cell. You can place your activator outside the playable area of the cell, or you can choose a model without a visible mesh (meshes\magiceffects\null.nif works well). When placing the activator, make note of the actor's specific Reference ID in the cell dialog. This is the reference you'll need to use in the script. Also, take note of the NPC's starting cell - it may be better to place the activator in a different cell. For example, some of the mages in the Bruma Mages' Guild start in the basement, which is behind a door with a hard lock. In these instances, it would be better to add the activator to the Mage Guild's entrance - the spells will still be added if the NPC is in a different cell.

Once you have your activator placed in the cell, attach a customized script similar to the following:

Begin OnLoad
     NPCRef.AddSpell <SpellID1>
     NPCRef.AddSpell <SpellID2>
     ...
End

This script will cause the spells to be added to the specified NPC(s) each time the activator is loaded. If you load a mod that further changes the NPC in question, the spells will still be available the next time the cell is reloaded.