JoFlashStudios Posted April 26, 2011 Share Posted April 26, 2011 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 More sharing options...
Fallen Guardian Posted April 26, 2011 Share Posted April 26, 2011 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. Link to comment Share on other sites More sharing options...
JoFlashStudios Posted April 26, 2011 Author Share Posted April 26, 2011 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 More sharing options...
Nick Vader Posted May 3, 2011 Share Posted May 3, 2011 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. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.