Difference between revisions of "Scripting Tutorial: Spell Tome"

From the Oblivion ConstructionSet Wiki
Jump to navigation Jump to search
imported>Grosie
m
imported>Grosie
Line 1: Line 1:
{{Unfinished}}
{{Unfinished}}


'''Spell Tome'''
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 when the book is first read). You will create a book, put some text into it, and add a script to it to give the player a spell.
With that in mind, let's get started!
 
==Starting off==
Open the TES:CS and load Oblivion.esm (and optionally whatever previous .esp file you want to add spell tomes to). If you are planning on creating a new plugin data file, go ahead and save it now, call it something like "SpellTomeTutorial". doing this now will avoid any possible crashes when trying to create a new data file later on after you have put in all the hard work putting this together.
 
==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)
Click OK, and when asked if you want to create a new form, choose yes.
 
==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.
Whichever mthod you choose, you need the editor ID for the spell. In this tutorial, I am going to use 'StandardFrostDamageTarget1Novice'
 
==The Script==
We now need to create the script that we will attach to our book to add the spell. So go ahead and open the scripting window and create a new script. Type this into the window and hit save ('''NOT THE COMPILE ALL BUTTON!''') I will explain how it works in a moment.
<pre>
scn aaaSpellTomeScript
 
short doonce
short buttonpressed
int button
 
begin onActivate
  if doonce == 0
      MessageBox "Would you like to learn the Spell of Frost Damage?", "Yes please", "No way, maybe later"
      set doonce to 1
      set buttonpressed to 1
  else
      Message "You have already learn what you can from this Tome"
  endif
end
 
begin GameMode
  if buttonpressed == 1
      set button to GetButtonPressed
      if button == 0
      set doonce to 0
      set buttonpressed to 0
      Message "Ok - Maybe you can learn later"
      elseif button == 1
        set buttonpressed to 0
        player.AddSpell StandardFrostDamageTarget1Novice
        Message "Use this knowledge wisely"
      endif
  endif
end</pre>
 
NB: The MessageBox Part should all be on one line - wiki formatting however prevents this.


''This article is currently being written, please do not change it yet!''
''This article is currently being written, please do not change it yet!''

Revision as of 11:39, 18 May 2009


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.

With that in mind, let's get started!

Starting off

Open the TES:CS and load Oblivion.esm (and optionally whatever previous .esp file you want to add spell tomes to). If you are planning on creating a new plugin data file, go ahead and save it now, call it something like "SpellTomeTutorial". doing this now will avoid any possible crashes when trying to create a new data file later on after you have put in all the hard work putting this together.

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) Click OK, and when asked if you want to create a new form, choose yes.

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. Whichever mthod you choose, you need the editor ID for the spell. In this tutorial, I am going to use 'StandardFrostDamageTarget1Novice'

The Script

We now need to create the script that we will attach to our book to add the spell. So go ahead and open the scripting window and create a new script. Type this into the window and hit save (NOT THE COMPILE ALL BUTTON!) I will explain how it works in a moment.

scn aaaSpellTomeScript

short doonce
short buttonpressed
int button

begin onActivate
   if doonce == 0
      MessageBox "Would you like to learn the Spell of Frost Damage?", "Yes please", "No way, maybe later"
      set doonce to 1
      set buttonpressed to 1
   else
      Message "You have already learn what you can from this Tome"
   endif
end

begin GameMode
   if buttonpressed == 1
      set button to GetButtonPressed
      if button == 0
      set doonce to 0
      set buttonpressed to 0
      Message "Ok - Maybe you can learn later"
      elseif button == 1
         set buttonpressed to 0
         player.AddSpell StandardFrostDamageTarget1Novice
         Message "Use this knowledge wisely"
      endif
   endif
end
NB: The MessageBox Part should all be on one line - wiki formatting however prevents this.

This article is currently being written, please do not change it yet!