Jump to content

Home

Apply effect after action is complete


Recommended Posts

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?

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

Archived

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

×
×
  • Create New...