applying visual effects, howto

For toolset tutorials as well as question and answers.
Locked
User avatar
peterdin
Orc Champion
Posts: 456
Joined: Sat Jul 09, 2005 3:40 pm
Location: GMT+1

applying visual effects, howto

Post by peterdin »

I'd like to share with you the problems I had with applying visual effects.
There's some neat effects in the toolset but firing them in loops is not easily possible. (at least not that I am aware of)
I have been playing around with the EffectNWN2SpecialEffectFile method.
Assembling a script and tying it to a placeables hearbeat method will work.
But:
- if you test from the toolset when your mod is in a directory it will NOT work! You must save your mod as a .mod not as directory. (this took me a couple of hours to find out :wall: );
- the placeable must have static switch of and useable switched on. Otherwise heartbeat method will not be called (wasnt aware of that)
but if you do it like follows:

Code: Select all

void main ()
{	
	object oTarget;
	PrettyMessage("in lava geyser script");
	oTarget = GetTarget(TARGET_OBJECT_SELF);
	PrettyMessage (GetName(oTarget));
	location loc = GetLocation(oTarget);
            effect ef = EffectNWN2SpecialEffectFile("camb_fx_geyser_expl_fir_sm");
	// following will give about 50% change for a delayed effect on the lava
	int iTime = Random (12000);
	if (iTime  < 5500)
	{
		float time = IntToFloat(iTime)/1000;
		DelayCommand(time, ApplyEffectToObject(DURATION_TYPE_INSTANT, ef, oTarget));

	}
}
it'll look like (the bursts)


anyone else any other suggestions?
A.K.A Pee Dee

past PC: Maha Tari, aka. Alinia Mountain curiousity killed the cat

All those moments, lost in time.
Like tears in the rain.
Time to die.
User avatar
Teric neDhalir
Githyanki
Posts: 1495
Joined: Mon Jan 05, 2004 10:04 pm
Location: Manchester UK

Re: applying visual effects, howto

Post by Teric neDhalir »

I've never tried to have a new-fangled special effect work in that way, but I'm fairly sure I've seen something on NWVault that claimed to do the same sort of thing...
Looks cool anyway and I'll probably steal the code at some point in the future :)
User avatar
peterdin
Orc Champion
Posts: 456
Joined: Sat Jul 09, 2005 3:40 pm
Location: GMT+1

Re: applying visual effects, howto

Post by peterdin »

it's not so much about adding new effect but rather using the existing ones.
When you look into the zipped effects there's a truck load of effects there.
But when you look into the toolset there's only a limited set of effects there.

You can easily make a (custom) special effect by using the file name (without .sef) in the special effect in the toolset.

But when it is a fire & forget effect then there's no way in the toolset to trigger at timed interval, as you can do with sounds effects.

There's also not the possibility to add visual effects to sounds, while you can add sounds to visual effects :?

So I was looking for a way to fire existing effects at a timed interval and then I came up with this.

Would be interesting though to make an inivisible placeable that takes the name of the effect and timing as a parameter.
Then you could easily add a placed, timed effect to your area.
If there's interest I could provide it and add to the base resources so it would be available to everyone.
interest?
A.K.A Pee Dee

past PC: Maha Tari, aka. Alinia Mountain curiousity killed the cat

All those moments, lost in time.
Like tears in the rain.
Time to die.
User avatar
Teric neDhalir
Githyanki
Posts: 1495
Joined: Mon Jan 05, 2004 10:04 pm
Location: Manchester UK

Re: applying visual effects, howto

Post by Teric neDhalir »

peterdin wrote: Would be interesting though to make an inivisible placeable that takes the name of the effect and timing as a parameter.
Then you could easily add a placed, timed effect to your area.
If there's interest I could provide it and add to the base resources so it would be available to everyone.
interest?
Yep, I'd buy that :)
User avatar
Teric neDhalir
Githyanki
Posts: 1495
Joined: Mon Jan 05, 2004 10:04 pm
Location: Manchester UK

Re: applying visual effects, howto

Post by Teric neDhalir »

Peter,
I had a play with this and I'm slightly confused, as your code as posted doesn't compile.
I assume PrettyMessage() is a debugging function you've not included in your code, and

Code: Select all

oTarget = GetTarget(TARGET_OBJECT_SELF);
should be

Code: Select all

object oTarget = OBJECT_SELF;
??
Anyways, with a bit of tidying up it does, indeed, work as you suggest. Thanks for that.

Only thing I'm not sure about is running it from the Heartbeat. You might put a big delay in the script between firings of the effect but it's still being set off every 6 seconds from the heartbeat, which could cause things to not work as you intended. I would think a better way is to wrap up the timing code inside a function and then call that with a randomised delay. Not quite sure how you would fire it in the first place, though. Or maybe set a switch in the script so that the delayed firing loop is started on the first heartbeat and on all following ones nothing happens.

Just thinking out loud...
Teric
User avatar
peterdin
Orc Champion
Posts: 456
Joined: Sat Jul 09, 2005 3:40 pm
Location: GMT+1

Re: applying visual effects, howto

Post by peterdin »

see below
make an Ipoint placeable
and copy the code below in a script
ty this script to the heartbeat of the Ipoint
This script changes the heartbeat time every time it has fired.
It will fire automatically the first time after 6 seconds.

define following variables to the Ipoint placeable
string sfx_name
int interval
int interval_variation

and give them appropriate values
e.g. to have gas explosions the sfx_name is : camb_fx_geyser_expl_fir_sm
You can have a look in the zipped sfx files for the effects.
didnt test very much but I guess any .sef file will do.

Code: Select all

#include "ginc_debug"
#include "ginc_param_const"
	
void main ()
{	
	object oTarget = GetTarget(TARGET_OBJECT_SELF);
	int interval = GetLocalInt(oTarget,"interval");
	int variation = Random(GetLocalInt(oTarget,"interval_variation"));
	// this will get a value of 1 or 2
	int upordown = Random(3);

	if (upordown == 1)interval += variation;
	// we dont want our int to become negative, so check
	else if (interval > variation) interval -= variation;
	
	string sfx_name = GetLocalString(oTarget, "sfx_name");
	// we now change the heartbeat time so it fires with new time
	SetCustomHeartbeat(oTarget,interval);
	// and dont forget to apply the effect	
	effect ef = EffectNWN2SpecialEffectFile(sfx_name);
	// todo: apply variation to the position
	ApplyEffectToObject(DURATION_TYPE_INSTANT, ef, oTarget);
}
A.K.A Pee Dee

past PC: Maha Tari, aka. Alinia Mountain curiousity killed the cat

All those moments, lost in time.
Like tears in the rain.
Time to die.
Locked