//RWT-OEI 05/31/05
//This function creates a Special Effects File effect that can
//then be applied to an object or a location
//For effects that just need a single location (or source object),
//such as particle emitters, the source loc or object comes from
//using AttachEffectToObject and AttachEffectToLocation
//For Point-to-Point effects, like beams and lightning, oTarget
//is the target object for the other end of the effect. If oTarget
//is OBJECT_INVALID, then the position located in vTargetPosition
//is used instead. 
effect EffectNWN2SpecialEffectFile( string sFileName, object oTarget=OBJECT_INVALID, vector vTargetPosition=[0.0,0.0,0.0]  );

An extremely useful function for applying visual effects without making edits to your 2das. This function will apply any file with the .sef extension (including custom visual effects) which can then be applied as normal using ApplyEffectToObject or ApplyEffectAtLocation. When applying the effect to either an object or a location it is better (although not necessary) to use one or the other and keep the second or third parameter at its default setting, depending on what you're applying your effect to. For effects applied to a location, keep in mind that you need to enter a vector into the third parameter, not a location. Use GetPositionFromLocation to find the vector of your location.

Also you do not need to include the .sef in sFileName. Simply the name of the file will suffice.

It is important to note that you cannot use this function to apply visual effects to items or to valid objects when the .sef has no associated part to the object that you're attempting to apply the effect to.

For instance, let's say you make an item called "baton". You have an animation set up to twirl the baton and throw it around in the air and you think it might be neat to have a trail effect attached to it. If you attempt:

effect eTrail = EffectNWN2SpecialEffectFile("fx_weapontr_standard", oBaton);
ApplyEffectToObject(DURATION_TYPE_TEMPORARY, eTrail, oPC, 6.0f);

Nothing will happen because, while fx_weapontr_standard.sef is a valid file for this function, if you were to go into the Visual Effects Editor in the toolset, open this file and click on the single blank event under the effects tree, and look under the locations tab in the event's properties, you will see that both attachment points are labeled ATTACH_INVALID. This means that even when the effect file is applied to a valid object the script doesn't use the effect because there is nowhere to place it.

Which leads me to my next point. If you were to set FirstAttachment to ITEM_HOOK_1, select Save As, rename the file, place it into your override folder, and rewrite your script as:

effect eTrail = EffectNWN2SpecialEffectFile("fx_my_trail_effect", oPC);
ApplyEffectToObject(DURATION_TYPE_TEMPORARY, eTrail, oPC, 6.0f);

When you called your baton throwing animation the trail effect now follows the hand it was assigned to rather than the baton because the visual effects editor redirects the attachment point from ITEM_HOOK_1 to ATTACH_HAND_R. Why it does this is unknown, but for the present there is no known way to attach a tail effect to an item.

Ad blocker interference detected!

Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers

Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.