Difference between revisions of "Scripting Tutorial: Spell Tome"

2,253 bytes added ,  15:24, 6 February 2011
imported>Vladimort
imported>IronSpine
 
(4 intermediate revisions by 3 users not shown)
Line 2: Line 2:


With that in mind, let's get started!
With that in mind, let's get started!
{{Tools|req0=[[The Elder Scrolls Construction Set|Construction Set]]}}


==Starting off==
==Starting off==
Line 125: Line 126:
begin onActivate
begin onActivate
   Activate
   Activate
   if doonce == 0 ;has the player already learnt the spell?
  begin onActivate
      ;ask the player if they would like the spell
   if doonce == 0
       MessageBox "Would you like to learn the Spell of Frost Damage?", "Yes please", "No way, maybe later"
       MessageBox "Would you like to learn the Spell of Frost Damage?", "Yes please", "No way, maybe later"
       set doonce to 1 ;Don't ask them again
       set doonce to 1
       set buttonpressed to 1 ;tell the script to check what the player answered
       set buttonpressed to 1
   else
   else
      ;Tell the player that they have got the spell already.
       Message "You have already learned what you can from this Tome"
       Message "You have already learned what you can from this Tome"
   endif
   endif
Line 140: Line 140:
===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 can 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.
----
==IronSpine Supplemental - If the script doesn't work?==
I precisely followed the instructions of this tutorial, however (for me) the script never triggered. This was not resolved regardless of mode or other minor changes I made trying to figure out why it didn't.
I examined the script of a DLC Tome for comparison. Using that as a template along with the information here I immediately had a successful custom Tome of Alliance with custom spell, in my case a powerful multi-effect spell to cast on friendly NPC for 5min of prolonged assistance in battle.
Use the content of the tutorial and if your script doesn't seem to execute (as mine did not), use the following as a template and see if it starts working.
<pre>
scn AMLLSpellTomeOfAlliance
short buttonPressed
short isDone
Begin OnEquip Player
If isDone == 0
  MessageBox "(OnEquip Block) - Would you learn the ways of the Alliance?", "I would.", "No, I would not."
EndIf
End
Begin OnActivate
Activate
If isActionRef Player == 1 && isDone == 0
  MessageBox "(OnActivate Block) - Would you learn the ways of the Alliance?", "I would.", "No, I would not."
EndIf
End
Begin MenuMode
Set buttonPressed to GetButtonPressed
If buttonPressed > -1
  If buttonPressed == 0
  ;Add to SpellBook.
  Player.AddSpell AMLLAlliedDefenderMinorSpell
  PlaySound SPLAlterationCast
  Set isDone to 1
  EndIf
EndIf
End</pre>
In my case (and perhaps yours) it's '''OnEquip''' that triggers, not '''OnActivate'''. This is confirmed by the block prefix I added so I could see which is actually being triggered.
Based on my testing, this executes as wanted. Once Yes is selected, subsequent reading of the Tome is just that. Reading. Also, dropping the Tome and picking it back up just yeilds a standard auto read, with take option, and back in inventory just normal reading.
Note the scripts don't appear case-sensitive generally so it's up to you, but for easier reading out of habbit I use Pascal Casing due to my background.
Thanks to the original author of this article for the general knowledge. Tomes open up a hugely interesting way to add true custom spells to the game in a way that feels right and perfectly fits in with the mechanics. Instead of simply using a code to get the object you can of course go stuff it into a bookshelf, chest or anything else and "go get it properly" in-game ''':)'''
- IronSpine
----


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