Can you spawn in a visual effect through a script, like fire, for instance? I think I ought to be possible 'cause when you cast a spell you see fire…but maybe that is not at all the same thing as spawning in a fire at a waypoint? When checking ginc_object it seems that that only covers placeables and creatures…
Yes, the spells scripts often fire off a visual effect. You could always use the location of the waypoint to place the effect. Not every effect works for a location though; some require an object.
You can spawn placed effects using the CreateObject() function, passing OBJECT_TYPE_PLACED_EFFECT as first parameter.
The following generic script spawns placeables or placeables effects :
// spawn objects, pass OBJECT_TYPE_xx as first parameter
// eg OBJECT_TYPE_PLACED_EFFECT = 1024, OBJECT_TYPE_PLACEABLE = 64, ...
void main(int nType, string sTemplate, string sWP)
{
int n = 0;
object oWP = GetObjectByTag(sWP);
while (GetIsObjectValid(oWP))
{
CreateObject(nType, sTemplate, GetLocation(oWP));
n++;
oWP = GetObjectByTag(sWP, n);
}
}
for instance from a conversation calling vk_spawn_objects(1024, “fx_b_furnace_active”, “spawn_fire”)
spawns a fire effect on every waypoint tagged “spawn_fire”.
Ah, neat! Thanks guys! I’ll try that script you suggested here @Claudius33.
I’ve tried this now, and though it works, I can’t seem to remove the fire effect for some reason.
I first use Claudius33’s script above. I spawn the fire effect to the waypoint “spawn_fire”. Then when trying to remove the effect I run this script from a conversation (my guess is that the script is wrong somehow):
void main()
{
object oTarget = GetObjectByTag("spawn_fire");
effect eSearch = GetFirstEffect(oTarget);
while (GetIsEffectValid(eSearch))
{
if(GetEffectSpellId(eSearch) == 1024) //your custom spell id
{
RemoveEffect(oTarget, eSearch);
}
eSearch = GetNextEffect(oTarget);
}
}
Could it be that I must use the sTemplate for removing the effect, like fx_b_furnace_active? Ok, I’ll try that.
Edit: Nope, didn’t work either.
I solved it.
It was far easier than I thought. Apparently you could just use destroy object.
void main()
{
object oTarget = GetObjectByTag("fx_b_furnace_active");
DestroyObject(oTarget);
}
I’m not sure why this was so easy, when I’ve used the other kind of script before. Maybe it’s because in the other instance the effect was attached to a creature…
If you want a more generic one with a timer, this one was given to me by Tchos back in the day.
//////////////////////////////////////////////////////////////////////////////
//
// ga_vfx
// by Tchos
//
// Applies a VFX .sef at a location (for waypoints).
//
//////////////////////////////////////////////////////////////////////////////
void main(string sFX, string sObjectTag, int iDurType=0, float fDuration=0.0f)
{
object oFXloc = GetObjectByTag(sObjectTag);
if ((oFXloc == OBJECT_INVALID) || (sObjectTag == "")) { oFXloc = OBJECT_SELF; }
location lFXloc = GetLocation(oFXloc);
effect eFX = EffectNWN2SpecialEffectFile(sFX);
ApplyEffectAtLocation(iDurType, eFX, lFXloc, fDuration);
}
/*
DURATION_TYPE_INSTANT = 0;
DURATION_TYPE_TEMPORARY = 1;
DURATION_TYPE_PERMANENT = 2;
*/