Jump to content

DOWNLOAD MODS

Are you looking for something shiny for your load order? We have many exclusive mods and resources you won't find anywhere else. Start your search now...

LEARN MODDING

Ready to try your hand at making your own mod creations? Visit the Enclave, the original ES/FO modding school, and learn the tricks of the trade from veteran modders...

JOIN THE ALLIANCE

Membership is free and registering unlocks image galleries, project hosting, live chat, unlimited downloads, & more...

[TUTORIAL] Adding Spells via Items!


Zabre
 Share

Recommended Posts

Hi all! This is first tutorial, so go lightly on me! :read:

Today, I will be teaching a very useful, very easy script. The goal of this lesson is to teach you how to add a spell (or any other item) by picking up an item. Before attempting this tutorial, you should have basic knowledge of scripting. If you are brand-new to scripting, please check out WillieSea's Scripting class!

To start off, fire up the CS, and load Oblivion.ESM.

Since this script depends on an object, we need to make an object. For this tutorial, I will be using a Crystal Ball.

Locate the item "CrystalBall01" (found in Items>MiscItem>Clutter>MagesGuild), Right click it, and select edit. Change the ID to something you can remember, i chose "aavLemBall." Once you have the ID changed, click OK and when the CS prompts you to create a new form, click yes.

Now we need to create a new spell. If you are doing scripting already, you should know how to create a basic spell, so go ahead and make one. For reference, I called my spell "aavLemSpell"

;)Smarty Says: When making any new objects, for any mod, use a prefix for the ID. For example, I use "aavLem" on ANY item, spell, script, etc., on anything I make in the CS. Another way is to use something that relates to your mod, for example, WillieSea's Ancient Towers mod. All the items/spells/scripts he made all start with "ancient." This makes it easier to find the stuff that you added to the game, when you load your mod.

Once you have your object made, and your spell made, we can actually get onto the script!! :)

Open up the script editor. Now give your script a name, and remember, Prefixes!!


scn aavLemBallScript

Now, we want our script to run when the player receives an item. So for that we would use:

scn aavLemBallScript


Begin OnAdd player

Once we attach this script to our object, this script will run every time the player picks up the item. :PSmarty Says: Remember, the script will run EACH time the player picks up the item. So if you do not want the "OnAdd" part to run twice, make the item unique, and one of a kind. :clap:WillieSea says: Now we have our foundation, let's add the actual script. The 'Begin OnAdd' will allow us to check if the player is obtaining, or dropping the item. The 'if' will only ensure the player has the appropriate item before it will 'execute' the code contained within the 'if' structure.

scn aavLemBallScript


Begin OnAdd player


     if (player.GetItemCount aavLemBall == 1)

The game will now add the spell, because the player has the ball in his inventory. To add the spell, you use "player.addspell XXXXX"
 

scn aavLemBallScript


Begin OnAdd player


     if (player.GetItemCount aavLemBall == 1)

          player.addspell "aavLemSpell"

          ;You might even want to throw in a message.

          message "You have learned a new Spell"

     endif

end OnAdd

That wraps up the part of the script that adds the spell. To take away the spell, you just reverse the script!

scn aavLemBallScript


Begin OnAdd player


     if (player.GetItemCount aavLemBall == 1)

          player.addspell "aavLemSpell"

          ;You might even want to throw in a message.

          message "You have learned a new Spell"

     endif

end OnAdd


Begin OnDrop player


     if (player.GetItemCount aavLemBall == 0)

          player.removespell "aavLemSpell"

          message "You have forgotten a spell"

     endif

end OnDrop

:scary: WillieSea sais: Since the script is placed on the crystal ball, there is no need to check in the script if the player has the crystal ball or not. The same effect can be accomplished by using this script:

scn aavLemBallScript


Begin OnAdd player


          player.addspell "aavLemSpell"

          ;You might even want to throw in a message.

          message "You have learned a new Spell"

end OnAdd


Begin OnDrop player


          player.removespell "aavLemSpell"

          message "You have forgotten a spell"

end OnDrop

Save it, and the script is now complete!! :pints:

All that is left to do, is attach your script to the object. To do that, locate your object (The crystal ball, in my case) in the Object Window, and edit it. In the "script" drop-down menu, select your script, and click OK.

Add a way for the player to obtain the object, and you are done!

I hope my bad grammar made sense, and I also hope you are 1% smarter from reading this. Thank-you :D

Edited by Lemon
Link to comment
Share on other sites

Ok,fine...now I`ve gotta go through WillieSea`s tuts too. This is a very good tut Lemon.Short and to the point.You`re grammar is no problem and the subject is emminently applicable to some of the stuff I`ve been making,therefore,very useful.Thank You for this. ;)

Link to comment
Share on other sites

Since the script is placed on the crystal ball, there is no need to check in the script if the player has the crystal ball or not.

scn aavLemBallScript

Begin OnAdd player
player.addspell "aavLemSpell"
;You might even want to throw in a message.
message "You have learned a new Spell"
end

Begin OnDrop player
player.removespell "aavLemSpell"
message "You have forgotten a spell"
end[/code]

Link to comment
Share on other sites

Ok,fine...now I`ve gotta go through WillieSea`s tuts too. This is a very good tut Lemon.Short and to the point.You`re grammar is no problem and the subject is emminently applicable to some of the stuff I`ve been making,therefore,very useful.Thank You for this. :P

Thanks Don! Your words have inspired me to make more tutorials. :scary:

Looks great Lemon, I've sent a copy to the Tutorials section for you too: :clap:

Thanks, Rider. :pints:

-SNIP-

I have updated the tutorial with this information. Thanks Professor ;)

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...