Note: LucasForums Archive Project
The content here was reconstructed by scraping the Wayback Machine in an effort to restore some of what was lost when LF went down. The LucasForums Archive Project claims no ownership over the content or assets that were archived on archive.org.

This project is meant for research purposes only.

Apply effect after action is complete

Page: 1 of 1
 JoFlashStudios
04-25-2011, 10:59 PM
#1
I'm trying to figure out how to fire an effect (or several effects) after an action is complete. Specifically, I'm trying to get the character 'clone' to walk to the main character and explode. The issue I'm having is that I don't know how to delay/block the execution/effects until the action is complete. As a result, the explosion effects occur immediately, before the clone has run over to the main character.

The code I have is as follows:


void main()
{
object clone;
int i = 0;
while (TRUE)
{
clone = GetObjectByTag("copies", i);
if (GetIsObjectValid(clone) && GetIsInConversation(clone) == 1)
{
break;
}
i++;
}
object oTarget = GetPartyMemberByIndex(0);
ActionMoveToObject(oTarget, TRUE, 0.0);
ApplyEffectAtLocation(2, EffectVisualEffect(1039), GetLocation(clone), 0.0);
ApplyEffectAtLocation(2, EffectVisualEffect(3003), GetLocation(clone), 0.0);
ApplyEffectToObject(2, EffectVisualEffect(1009), clone, 0.0);
}


Is there some way to register an effect (or something else) to a character's action queue that isn't returned by a call to an 'action<doSomething>()' method?
 Fallen Guardian
04-26-2011, 12:29 AM
#2
Well, I don't know if there is anyway around using the action<dosomething> method, but you can just use this: ActionPauseConversation();
ActionWait(5.0);
ActionResumeConversation();

This should cause it to wait until the clone reaches the PC.
 JoFlashStudios
04-26-2011, 1:12 PM
#3
Thanks for your reply Fallen Guardian. The issue with that method is that eventually I plan to change this script to make the clone run to someone other than the main character, and I can't know if it will take half a second or fifteen seconds to get there.

I found a solution however. It turns out that in my limited understanding of NWscript, I thought that the actions used by ActionDoCommand() were a data type. In reality, they're more like dynamically declared C# delegates that you can add to a creature's task queue. This allows me to do the following, where Detonate() contains the logic to apply vfx and do damage to surrounding creatures:


ActionMoveToObject(oTarget, TRUE, 0.0);
ActionDoCommand(Detonate(clone));
ActionDoCommand(DestroyObject(clone, 0.0, 1, 0.0));


The Detonate() and DestroyObject() actions will be run once the ActionMoveToObject() command is complete.
 Nick Vader
05-03-2011, 9:09 AM
#4
ActionMoveToObject(oTarget, TRUE, 0.0);

Exactly! This script will first move the object to the target and, regardless of time, will then continue with your other actions in the script.
Page: 1 of 1