Jump to content

Special Effects


galelyan

Recommended Posts

You have scripting functions called Play and Stop (though you can also just use Play and give it a set duration), that are called by an EffectShader and take an ObjectReference. EffectShaders can apply membrane effects (for example, the glowing white outline when the player heals themselves) and particle effects (for example, the flames surrounding something you just set on fire). Particles can be manipulated in a bunch of ways, and making a fountain that spews flame is very viable with them. EffectShaders are complicated, so I'm going to make you study making it look good on your own time. Feel free to ask again if you're having trouble with them, but this post will be long enough for now.

 

Anyway, a script to apply them would look something like this:

 

 

EffectShader Property MyFireFountainShader  Auto
{The EffectShader we want to play.}


Event OnLoad() ;This Event runs whenever the calling object (in this case, the fountain) is loaded into the game.  

   MyFireFountainShader.Play(self, -5) ;'self' is a special variable that will return whatever called the script, so we don't need to make a special variable for the fountain.
                                       ;-5 is the duration.  If set to a negative, the EffectShader will run until we tell it to stop.
EndEvent


Event OnUnload() ;Runs whenever the calling object is unloaded.  We use this for cleanup.

    MyFireFountainShader.Stop(self) ;I don't know how this works in Skyrim, but in Oblivion EffectShaders can pile up on top of one-another.
                                    ;If it gets played multiple times without being stopped, the EffectShader gets more cluttered. 
                                    ;Thus, we need to make sure we stop it before we tell it to play a second time (next time it's loaded).
EndEvent

 

 

Now, let's talk about that Property variable we declared. If you're already familiar with the basics of Papyrus scripting, feel free to skip to a five-line break.

By default, scripts in Papyrus only know about whatever they're attached to. If you want to tell the script about anything else, you need to declare it at the beginning of the script as a Property. So, to break down that Property...

EffectShader Property MyFireFountainShader  Auto
{The EffectShader we want to play.}

EffectShader: The type of thing the variable is.

Property: Turning the variable into a property that can hold things outside the script. If we just say "EffectShader MyFireFountainShader", it could only be used internally (pretty useless for an EffectShader, but it can be important when dealing with simpler variables).

MyFireFountainShader: The Property's name. You could technically name this whatever, but giving it the same name as our EffectShader makes a future step easier.

Auto: Defines the Property "automatically", as in outside scripting functions. This bit isn't important for now. Suffice to say, you need to put it at the end for properties and you don't need to for variables.

{The EffectShader we want to play.}: When someone mouses over this Property in the Property list, this is what they'll see. It's not necessary, and it doesn't work for non-Property variables (I think).

 

To put all that together, let's discuss making a new script and attaching it to the game. Once again, feel free to skip this if you already know basic Papyrus scripting.

 

Step 1: Open up the object you want to attach the script to. If the fountain (or, if you want to get fancy, something invisible denoting the exact fountainhead we want the flames to spew from) is a Static, or something that shares use with non-firey fountains we don't want to mess with, double-click the Reference in the Render Window, scroll to the right through the tabs until you find Scripts. If you have more than one fountain, you'll need to do this whole thing separately for every one. If it's a unique Activator, we can just script the Base (accessible through the Object Window or by clicking Edit Base while editing a reference).

 

Step 2: There should be an 'add' button next to the already-present list of scripts. Click it and select [New Script]. Give it whatever name you want (I named it MyFireFountainScript), and a basic description for anyone who mouses over it. Its extension should default to ObjectReference, which is what we want, but if it doesn't type ObjectReference in the extension text box.

 

Step 3: We should be back to the script list. Right-click on our new script and select "Edit Source", bringing up a huge text field. Note that it's already given us a 'scriptname' function and some squiggly brackets with our description inside. Paste the stuff from that earlier code-box below, and click File/Save. If you've done everything right, it should compile with no problems. Close the script editor.

 

Step 4: We're back at the script list. Highlight our script and click the Properties button. This should bring up a list of 1 property; MyFireFountainShader. If our EffectShader is also named MyFireFountainShader, we can just click 'Auto-Fill All' and the Creation Kit will slide in the matchingly-named EffectShader. If not, highlight the property, click Edit Value and select your EffectShader from a list.

 

And that's that. After the jump, we get down to the lightning altar.

 

 

 

 

 

The other way of doing pretty visual effects is just to cast spells at stuff. This is done through the Cast function, which takes a source and a target and is called by a spell. After wading through a full-on scripting primer with a brand new type of Object, this will feel delightfully simple.

Step 1: Find a nice, invisible Activator we can make shoot lightning. XMarkerActivator will serve for our purposes. Open it up and change its ID to something else like MyLightningSource, click OK and tell it, yes, we want to make a new Form.

Step 2: Place MyLightningSources all around the altar you want to attract the lightning. Make sure the altar has a specific Reference Editor ID, so we can point at it in a Property.

Step 3: Give MyLightningSource a new script, extending an ObjectReference as before (I called it MyLightningSourceScript). Paste the following into it.

 

 

ObjectReference Property MyLightningAltar  Auto
{The altar we'll be shooting lightning at.}

SPELL Property LightningBolt  Auto
{The vanilla Lightning Bolt spell.  Feel free to replace it with one of your own.}

Event OnLoad() ;We've dealt with this before.

    RegisterForUpdate(0.5) ;This will send an Update event to the object the script is attached to.  In this case, because we gave it 0.5, it will send one every half-second.

EndEvent


Event OnUpdate() ;Because we registered it for an update above, this event will occur every half-second.

    LightningBolt.Cast(self, MyLightningAltar) ;Casts a lightning bolt from the LightningSource (self) to the Altar.

EndEvent


Event OnUnload() ;Cleanup.  Update Registers stack, so if we don't unregister it will start casting a LOT of lightning bolts later.

    UnregisterForUpdate() ;Until we register again, this object will no longer receive Update events.

EndEvent

 

 

Step 4: Set up the Properties just like before, and we're done. If you want to be fancy, you can even use the same script to shoot different spells at different things by changing what MyLightningAltar and LightningBolt refer to (though, since we're declaring it in a Base, the source would need to be a new base). If so, you might want to give the Properties more politically correct names like Target and Spell. That's the power of Properties!

 

 

DISCLAIMER: I only tested this insofar as making sure all the scripts compile. Results are not guaranteed.

Edited by LoginToDownload
Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...