Difference between revisions of "Scripting Tutorial: Spell Tome"

m
spelling and internal links
imported>Grosie
imported>Qazaaq
m (spelling and internal links)
Line 1: Line 1:
This tutorial will tell you how to create a Spell Tome (or a book that will add a spell to the player's inventory when the book is read). You will create a book, put some text into it, and add a script to it to give the player a spell. If you don't already know how to script anything, or are entirely new to the TES:CS then I suggest that you go and read another tutorial first, then come back here when you know the basic interface. An excellent tutorial for learning the scripting interface is [[Scripting Tutorial: My First Script]].
This tutorial will tell you how to create a Spell Tome (or a book that will add a spell to the player's inventory when the book is read). You will create a book, put some text into it, and add a script to it to give the player a spell. If you don't already know how to script anything, or are entirely new to the [[The Elder Scrolls Construction Set|TES:CS]] then I suggest that you go and read another tutorial first, then come back here when you know the basic interface. An excellent tutorial for learning the scripting interface is [[Scripting Tutorial: My First Script]].


With that in mind, let's get started!
With that in mind, let's get started!
Line 7: Line 7:


==Creating the Tome (Book)==
==Creating the Tome (Book)==
Open the Object window and expand the 'Items' > 'Book' > 'Clutter' categories and click on 'Book'. Now select one of the books in the list (eg 'Book1CheapGuideAnvil'), 'right-click on it, and choose edit. Change the EditorID to something like 'aaaSpellTome' (So that it is easy to find a the top of the books list) and change the name to whatever you want. Also, while you are here, clear any text that is in the box on the right, and make sure that the book has no enchantment, teachings or script (at the moment)
Open the [[Object Window]] and expand the 'Items' > 'Book' > 'Clutter' categories and click on 'Book'. Now select one of the books in the list (eg 'Book1CheapGuideAnvil'), 'right-click on it, and choose edit. Change the [[EditorID]] to something like 'aaaSpellTome' (So that it is easy to find a the top of the books list) and change the name to whatever you want. Also, while you are here, clear any text that is in the box on the right, and make sure that the book has no [[enchantment]], teachings or [[:Category:Scripting|script]] (at the moment).
Click OK, and when asked if you want to create a new form, choose yes.
Click OK, and when asked if you want to create a new form, choose yes.


==The Spell==
==The Spell==
You cannot create a spell tome without a spell. At this point you can either choose to use an existing spell that came with Oblivion or create a new one. I'm not going to tell you how to create a new spell here, but there are many resources to tell you how.
You cannot create a spell tome without a [[spell]]. At this point you can either choose to use an existing spell that came with Oblivion or create a new one. I'm not going to tell you how to create a new spell here, but there are many resources to tell you how.
Whichever mthod you choose, you need the editor ID for the spell. In this tutorial, I am going to use 'StandardFrostDamageTarget1Novice'
Whichever method you choose, you need the editor ID for the spell. In this tutorial, I am going to use 'StandardFrostDamageTarget1Novice'.


==The Script==
==The Script==
Line 104: Line 104:


==Testing==
==Testing==
First you must make sure that your Mod is saved, then you need the FormID of your new Spell Tome.Once you have done this, open up the oblivion splash screen and click on datafiles. Make sure that your file is checked and close the window.
First you must make sure that your Mod is saved, then you need the [[FormID]] of your new Spell Tome. Once you have done this, open up the oblivion splash screen and click on datafiles. Make sure that your file is checked and close the window.


Once in game, open up the console and type:
Once in game, open up the console and type:
  player.addItem [YOURFORMID] 1
  player.addItem [YOURFORMID] 1
replacing [YOURFORMID] with the form ID that you found earlier. Open the book and view the results
replacing [YOURFORMID] with the form ID that you found earlier. Open the book and view the results.


==Extra==
==Extra==
===Problems===
===Problems===
The GameMode block will not execute when the menus are opened. The best way around it would be to automatically give the player the spell (as the OnAvtivate block does run in menus), however, I wanted to show how to use a message box in this context.
The [[GameMode]] block will not execute when the menus are opened. The best way around it would be to automatically give the player the spell (as the [[OnActivate]] block does run in menus), however, I wanted to show how to use a [[MessageBox]] in this context.


The Script doesn't take into account whether the player has the spell already or not, this could be changed by instead of using the 'doonce' variable, checking if the player has the spell.
The script doesn't take into account whether the player has the spell already or not, this could be changed by instead of using the 'doonce' variable, checking if the player has the spell.


===Homework===
===Homework===
A similar method can be used on a scroll, using a scripted enchantment instead. This also has the benefit of ensuring that the addition acn only be made once.
A similar method can be used on a scroll, using a scripted enchantment instead. This also has the benefit of ensuring that the addition can only be made once.


[[Category:Tutorials]]
[[Category:Tutorials]]
[[Category:Scripting Tutorials]]
[[Category:Scripting Tutorials]]
Anonymous user