Jump to content

Home

Removing Visual Effects


Silveredge9

Recommended Posts

void main() {

object oAdin=GetObjectByTag("droid_mand1");
object oAdin1=GetObjectByTag("droid_mand2");
object oAdin2=GetObjectByTag("droid_mand3");


effect efVisual = EffectVisualEffect(8001, 0);


effect eEffect = EffectVisualEffect(8002);
effect eEffect2 = EffectVisualEffect(8000);

DelayCommand(0.5, RemoveEffect(oAdin, eEffect));
DelayCommand(0.5, RemoveEffect(oAdin, eEffect2));
DelayCommand(0.5, RemoveEffect(oAdin1, eEffect));
DelayCommand(0.5, RemoveEffect(oAdin1, eEffect2));
DelayCommand(0.5, RemoveEffect(oAdin2, eEffect));
DelayCommand(0.5, RemoveEffect(oAdin2, eEffect2));

DelayCommand(0.5, AssignCommand (oAdin,ApplyEffectToObject(1, efVisual, GetObjectByTag("droid_mand1"), 5.0)));
DelayCommand(0.5, AssignCommand (oAdin1,ApplyEffectToObject(1, efVisual, GetObjectByTag("droid_mand2"), 5.0)));
DelayCommand(0.5, AssignCommand (oAdin2,ApplyEffectToObject(1, efVisual, GetObjectByTag("droid_mand3"), 5.0)));

}

I'm using the above code to remove the stealth field visual effect, but it doesn't work. :/

 

I'm wondering where the problem is? Any help would be appreciated. :)

Link to comment
Share on other sites

(snip)

I'm using the above code to remove the stealth field visual effect, but it doesn't work. :/

I'm wondering where the problem is? Any help would be appreciated. :)

 

You are not removing the actual effect from the creature. You declare a new effect, which you do not apply to anything, and then try to remove it. You will have to remove the effect that is already applied to the object instead of declaring a new one.

 

For non-visual effects you can most of the time do this by iterating through the effects on an object with the GetFirstEffect() and GetNextEffect() functions until you find the effect you want to remove and then call RemoveEffect() on that one.

 

If you want to flush out all scripted effects from an object regardless of type you can use the ClearAllEffects() function.

 

For visual effects, which I get the impression you are after here, you can use the RemoveEffectByID() function instead. Like:

 

void ApplyAndRemove(effect efVisual, object oTarget) {
   RemoveEffectByID(oTarget, 8000);
   RemoveEffectByID(oTarget, 8002);
   ApplyEffectToObject(DURATION_TYPE_TEMPORARY, efVisual, oTarget, 5.0);
}

void main() {
   effect efVisual = EffectVisualEffect(8001);

   DelayCommand(0.5, ApplyAndRemove(efVisual, GetObjectByTag("droid_mand1")));
   DelayCommand(0.5, ApplyAndRemove(efVisual, GetObjectByTag("droid_mand2")));
   DelayCommand(0.5, ApplyAndRemove(efVisual, GetObjectByTag("droid_mand3")));
}

Link to comment
Share on other sites

You are not removing the actual effect from the creature. You declare a new effect, which you do not apply to anything, and then try to remove it. You will have to remove the effect that is already applied to the object instead of declaring a new one.

 

For non-visual effects you can most of the time do this by iterating through the effects on an object with the GetFirstEffect() and GetNextEffect() functions until you find the effect you want to remove and then call RemoveEffect() on that one.

 

If you want to flush out all scripted effects from an object regardless of type you can use the ClearAllEffects() function.

 

For visual effects, which I get the impression you are after here, you can use the RemoveEffectByID() function instead. Like:

 

void ApplyAndRemove(effect efVisual, object oTarget) {
   RemoveEffectByID(oTarget, 8000);
   RemoveEffectByID(oTarget, 8002);
   ApplyEffectToObject(DURATION_TYPE_TEMPORARY, efVisual, oTarget, 5.0);
}

void main() {
   effect efVisual = EffectVisualEffect(8001);

   DelayCommand(0.5, ApplyAndRemove(efVisual, GetObjectByTag("droid_mand1")));
   DelayCommand(0.5, ApplyAndRemove(efVisual, GetObjectByTag("droid_mand2")));
   DelayCommand(0.5, ApplyAndRemove(efVisual, GetObjectByTag("droid_mand3")));
}

 

The effect I apply to the NPC's is the visual effect that occurs when you deactivate a stealth field. Which works perfectly.

 

It's just that you can't see it because the invisibility stealth effect that has been declared on the NPC's in a previous script has not been deactivated. I just need a script that removes this effect permanently, effect VFX_DUR_DISTORTION/8000 and effect VFX_DUR_STEALTH_FIELD/8002

Link to comment
Share on other sites

It's just that you can't see it because the invisibility stealth effect that has been declared on the NPC's in a previous script has not been deactivated. I just need a script that removes this effect permanently, effect VFX_DUR_DISTORTION/8000 and effect VFX_DUR_STEALTH_FIELD/8002

 

Eh, does the script I posted above not work? It should do what you describe. If not: try delaying applying the "decloak" effect by a tenth of a second or so so the invisibility effect is gone when it is applied.

 

If they still stay invisible check that your NPC does not have the "WillNotRender" flag set. If they do you'll have to deactivate that as well.

Link to comment
Share on other sites

The script itself doesn't compile in KOTOR TOOL, the error given is -

Error: Undeclaired Identifiyer "RemoveEffectByID"

In both of the instances in which it is used, lines 2 and 3. :/

 

That script function only exists in The Sith Lords (which I default to if someone does not mention which game their question relates to). Thus make sure you set the script compiler to compile for TSL, not KotOR1. :)

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...