Difference between revisions of "Scripting Tutorial: Spell Tome"

2,371 bytes added ,  15:00, 6 February 2011
no edit summary
imported>Darkness X
imported>IronSpine
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 SPLRestorationCast
  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 :)
----


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