Jump to content

Home

Script not working when in dialog


Canderis

Recommended Posts


void main() {



object oNPC1=GetFirstPC();
AssignCommand (oNPC1,ClearAllActions());
float x1=141.6;
float y1=-181.4;
float z=0.0;                        

int bRun=FALSE;

vector vExit1=Vector(x1,y1,z);

location lExit1=Location(vExit1,0.0f);

ActionDoCommand(SetCommandable(TRUE,oNPC1));

AssignCommand (oNPC1,ActionForceMoveToLocation(lExit1,bRun));

AssignCommand(oNPC1, SetFacingPoint(GetPosition(GetObjectByTag("n_shol"))));


       SendMessageToPC(GetFirstPC(),"I Fired1");
}

 

So I have this script and when fired, it works perfectly. I fired it from a door's onOpen field. Now, i put this script in a dialog. The dialog is now triggered from this door's onOpen field. The script does fire in this dialog, but no longer does the player walk forward as intended. Nothing happens. The player was in the same exact locations both times. Any suggestions?

Link to comment
Share on other sites

Just to be on the safe side, I'd take the location declaration and stick it into the command to move, rather than keeping it separate. Also, it'd probably be better to just use SetCommandable, rather than assigning it as an action - there's really no need to have it assigned. Third, I'd put all the assigned commands right after each other, and keep the set commandable above them (doesn't make a difference probably, but it also makes it easier to read). And lastly, I'd take out the bRun stuff. You set it to false and ForceMoveToLocation will make them walk by default if you don't specify they should/shouldn't.

 

Basically this script:

 

void main() 
{

object oNPC1=GetFirstPC();


SetCommandable(TRUE,oNPC1);

AssignCommand (oNPC1,ClearAllActions());
AssignCommand (oNPC1,ActionForceMoveToLocation(Location(Vector(141.6, 181.4, 0.0), 0.0)));
AssignCommand(oNPC1, SetFacingPoint(GetPosition(GetObjectByTag("n_shol"))));


       SendMessageToPC(GetFirstPC(),"I Fired1");
}

 

Though if you ever need to use bRun to make a creature run, and you want to use the style of ActionForceMoveToLocation I posted, you can do one of the following:

 

int bRun = TRUE;

AssignCommand(oNPC, ActionForceMoveToLocation (Location(Vector(141.6, 181.4, 0.0), 0.0), bRun));

 

or

 

AssignCommand(oNPC, ActionForceMoveToLocation (Location(Vector(141.6, 181.4, 0.0), 0.0), TRUE));

Link to comment
Share on other sites

As in the dialogue froze on the node and didn't continue or the game froze?

 

The dialog froze on the node. It froze between the node that fired it and the next one. And when I fire the script from the door's script it freezes from the same dialog node.

Link to comment
Share on other sites

Huh, maybe for some reason the conversation is being paused. Try running the script with ActionPauseConversation and ActionResumeConversation thrown in, like this:

 

void main() 
{

object oNPC1=GetFirstPC();

ActionPauseConversation();

SetCommandable(TRUE,oNPC1);

AssignCommand (oNPC1,ClearAllActions());
AssignCommand (oNPC1,ActionForceMoveToLocation(Location(Vector(141.6, 181.4, 0.0), 0.0)));
AssignCommand(oNPC1, SetFacingPoint(GetPosition(GetObjectByTag("n_shol"))));


       SendMessageToPC(GetFirstPC(),"I Fired1");

ActionResumeConversation();

}

Link to comment
Share on other sites

Archived

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

×
×
  • Create New...