Friday, January 2, 2009

Siege FX Tutorial #2

Siege FX Tutorial #1


The Stack

By: Aaron 'Jomdom' Ransley
Created: 1/6/2003

Introduction

In this tutorial, we will be discussing the Stack. As always, any code will be in red and in a different font. I will try to keep code from within a text-heavy paragraph to a minimum, and save it for its own paragraph.

Lingo

- Stack: The stack is the device that Siege FX uses to store effect data. I can’t think of any way to explain better than Icemage once did.

You can think of this like a stack of plates - as we create effects, we put each effect onto the stack, the same way you would put plates that have been dried in a stack.” - Icemage

The Stack

As Icemage said, “...as we create effects, we put each effect onto the stack…”

Let me elaborate. Say we create an orbiter, one of the 22 base effects. It would automatically be entered into the stack (if it doesn’t have any errors that is). Here is an example:

[effect_script*]

{

name =orbs;

script =[[

sfx create orbiter #TARGET

"color0(1,1,1)scale(.25)radius(0)";

set $orb1 #PEEK;

sfx start #POP;

sfx create orbiter #TARGET

"color0(1,1,1)scale(.25)radius(0)";

set $orb2 #PEEK;

sfx start #POP;

sfx create orbiter #TARGET

"color0(1,1,1)scale(.25)radius(0)";

set $orb3 #PEEK;

sfx start #POP;

sfx create orbiter #TARGET

"color0(1,1,1)scale(.25)radius(0)";

set $orb4 #PEEK;

sfx start #POP;

]];

}

“Eh?” you say? No kidding.

Alright, first off, understand that this effect doesn’t actually do anything, and if it did, it wouldn’t consist of anything more than creating 4 white orbiters at its target, directly on top of each other.

So, lets break it down.

You see that after I create the orbiter, define it’s location of creation, and it’s parameters, I go on to say:

set $orb1 #PEEK;

sfx start #POP;

Let’s break this down further… By writing:

set $orb1 #PEEK;

I tell the Siege FX engine to create a variable (something to contain the effect for quick referencing) out of whatever is on top of the stack. It effectively peeks at the top of the stack to check what’s there… Since we just created an orbiter, it is currently king of the stack. While we are talking about variables, I might as well mention that whenever you define a variable, it should be structured like so:

set ;

This means that if you want to create a variable to store a color, you can do this:

set $green .3,1,.3;

And it will store that color value inside the variable for later use in the script.

Getting back on track... Next we have this line:

sfx start #POP;

This is telling the Siege FX engine to ‘start’ what ever is on top of the stack, but ‘pop’ it off so it’s not on the stack anymore. If we then tried to use another command to look for the effect, you wouldn’t find it, because someone knocked it off the stack, and made a huge mess! Some people!

Here is an example of an invalid way of using the #POP and #PEEK commands.

set $orb1 #POP;
sfx start #PEEK;

We create a variable by using the data from the top of the stack, currently the data from the last effect we created, but ‘pop’ it off at the end, because we are supposedly done using it… Wrong.

The next line tries to start whatever is currently in the stack, but there is nothing there! Jeepers! It must be because someone made a mistake and knocked the effect off the stack too soon.

Slick Stack Slingin

Think your hot stuff? Try this on for size:

[effect_script*]

{

name =technicolor_orbs;

script =[[

set $color4 .5,.5,.5;

set $color3 0,1,0;

set $color2 0,0,1;

set $color1 1,0,0;

sfx create orbiter #TARGET

"color0($color4)scale(2)radius(0)";

sfx create orbiter #TARGET

"color0($color3)scale(2)radius(0)";

sfx create orbiter #TARGET

"color0($color2)scale(2)radius(0)";

sfx create orbiter #TARGET

"color0($color1)scale(2)radius(0)";

set $orb3 #POP;

set $orb2 #POP;

sfx start $orb2;

sfx start $orb3;

]];

}

What color will the pile of orbs be when the script is complete? If you can figure that out, you’re done with the tutorial. If you can’t, just keep decoding it, because everything here has been covered so far.

See you next time!

Resources

These are various resources I find very useful.

· Dungeon Siege's Main Site (Take a look around. Contains various mod resources, as well as the Dungeon Siege Toolkit)

· Game-Editing.net Dungeon Siege Forums (If you plan of modifying Dungeon Siege, this is the place to be. Make sure to make use of the search function.)

· Siege FX Siege University Course (Contains a list of the 22 base effects, a list of all possible parameters for those 22 base effects, and more. A great resource indeed.)

· Dungeon Siege Cosmetics (Home of this tutorial.)

· Jomdom's E-Mail (Feel free to e-mail me with any questions you have about this tutorial.)

In the Future

Expect more and more advanced tutorials in the future. Enough said J

Credits

· Icemage - You have really helped me with the more advanced aspects of Siege FX. I thank you, Icemage.

· Gas Powered Games - You make a killer effects engine! Great job, can't wait for Dungeon Siege 2's version of Siege FX.

0 comments:

Search

My Blog List