Oblis Posted October 26, 2012 Share Posted October 26, 2012 Hello,I want to make a short script that will add spells from a a certain spell school to an actor.For example: I would like to add all the spells from the school "Restoration" to an actor with class Healer.Using sctipt of course...How can this be done? Link to comment Share on other sites More sharing options...
Hickory Posted October 26, 2012 Share Posted October 26, 2012 That's a LOT of spells. Have you even considered this? The restoration school spells range not only on spell type/effect, but also each type ranges from novice to master. :ohmy: Link to comment Share on other sites More sharing options...
DocRob Posted October 26, 2012 Share Posted October 26, 2012 Hello,I want to make a short script that will add spells from a a certain spell school to an actor.For example: I would like to add all the spells from the school "Restoration" to an actor with class Healer.Using sctipt of course...How can this be done? As Hickory said, that is a LOT of spells, and that's without including any custom ones you might make and add. The script itself is easy but it won't be short by any means (at least, none I understand). I assume you want to add them to an NPC and not the player, so I whipped this up (forgive me if you already know this): scn HealerAddSpells ref actor Begin GameMode if (actor.GetisClass "Healer"==1) actor.AddSpell StandardRestoreHealth1Novice actor.AddSpell StandardRestoreFatigue1Novice else return endif StopQuest AAAStartScriptend Basically you just keep adding the spells from the Restoration school to the script, attach it to a Quest form in the CS, and go (there are probably more elegant ways, to write it, but it works). If you don't want to see "Spell Added" spam and are running OBSE, add NS to the end of AddSpell. Hope that helps. Link to comment Share on other sites More sharing options...
Hickory Posted October 26, 2012 Share Posted October 26, 2012 The script itself is easy but it won't be short by any means (at least, none I understand). I assume you want to add them to an NPC and not the player, so I whipped this up (forgive me if you already know this): scn HealerAddSpells ref actor Begin GameMode if (actor.GetisClass "Healer"==1) actor.AddSpell StandardRestoreHealth1Novice actor.AddSpell StandardRestoreFatigue1Novice else return endif StopQuest AAAStartScriptend Basically you just keep adding the spells from the Restoration school to the script, attach it to a Quest form in the CS, and go (there are probably more elegant ways, to write it, but it works). If you don't want to see "Spell Added" spam and are running OBSE, add NS to the end of AddSpell. Hope that helps. Since you brought up the 'elegant' subject... if I may? There is no point using a 'Return' statement at the end of a function -- it's already too late. It's good optimisation practice to catch things early, so that the script doesn't evaluate unnecessary code. In this case, your example would (could) become: ScriptName HealerAddSpells Ref actor Begin GameMode If ( actor.GetIsClass "Healer" != 1 ) Return Else actor.AddSpell StandardRestoreHealth1Novice actor.AddSpell StandardRestoreFatigue1Novice ; and the spells go on and on... Endif StopQuest AAAStartScript End Link to comment Share on other sites More sharing options...
Oblis Posted October 26, 2012 Author Share Posted October 26, 2012 Thanks for the reply guysThe script you give me is "handmade" job.I was thinking for something more automatic... like using a leveledlist for example... Thanks Link to comment Share on other sites More sharing options...
Hickory Posted October 26, 2012 Share Posted October 26, 2012 Thanks for the reply guysThe script you give me is "handmade" job.I was thinking for something more automatic... like using a leveledlist for example... Thanks Automatic in what sense? Also, you have not even said what actor/s -- is it player, one actor, many actors? People are not psychic, you know. You want help... supply details. Link to comment Share on other sites More sharing options...
Oblis Posted October 26, 2012 Author Share Posted October 26, 2012 Ok! Grab the spells from the list (or from a leveledspell list), check their school and add them to the actor (if restoration).So I will not be forced to type a thousand lines for each class or spell school. Link to comment Share on other sites More sharing options...
Hickory Posted October 26, 2012 Share Posted October 26, 2012 :wallbash: Link to comment Share on other sites More sharing options...
DocRob Posted October 27, 2012 Share Posted October 27, 2012 Since you brought up the 'elegant' subject... if I may? There is no point using a 'Return' statement at the end of a function -- it's already too late. It's good optimisation practice to catch things early, so that the script doesn't evaluate unnecessary code. In this case, your example would (could) become: ScriptName HealerAddSpells Ref actor Begin GameMode If ( actor.GetIsClass "Healer" != 1 ) Return Else actor.AddSpell StandardRestoreHealth1Novice actor.AddSpell StandardRestoreFatigue1Novice ; and the spells go on and on... Endif StopQuest AAAStartScript End Hickory--thanks for that fix. :smile: I'm still kind of ham-handed with my scripts so it's nice to be shown ways to do things more cleanly and tightly--the CS WIki hasn't exactly been chock full of such tips, so it's pretty much a "Oh, I hope this works" followed by "Okay, it worked, now how can I make it more efficient? I have NO clue" kind of thing for me, where what should be obvious, ain't.. :laugh: Oblis: You might not be totally out of luck: http://cs.elderscrolls.com/index.php/GetSpellSchool Though how to write up the script for it, that's a bit beyond me at the moment (I'm still about 50% utter noob). Sorry I can't be of more help there. Link to comment Share on other sites More sharing options...
Maskar Posted October 27, 2012 Share Posted October 27, 2012 (edited) You simply run through (while loop) whatever leveled list you want to use and add the spells from it to your (n)pc. Just use functions like GetNumLevItems, GetNthLevItem and of course AddSpellNS. If the objects themselves are also leveled lists you could use GetObjectType to figure that out and go through those list(s) also. Edited October 27, 2012 by Maskar Link to comment Share on other sites More sharing options...
Recommended Posts