Jump to content

Home

Syntax error and adding a delay


Canderis

Recommended Posts

I have a script for k1 and I get an error when I compile it. I would also like to make it so it happens after 2 seconds.

 

void main() { 
object oNPC1 = GetObjectByTag("offmand01"); 
object oNPC2 = GetObjectByTag("offmand02");
location lLoc1 = Location(Vector(69.36, -2.8, 0.0), 4.71); 
location lLoc2 = Location(Vector(63.78, -2.8, 0.0), 1.57); 
AssignCommand(oNPC1, ClearAllActions()); 
AssignCommand(oNPC2, ClearAllActions());
AssignCommand(oNPC1,ChangeFaction(1));
AssignCommand(oNPC2,ChangeFaction(1));
AssignCommand(oNPC1,ActionMoveToLocation(lLoc1)); 
AssignCommand(oNPC2,ActionMoveToLocation(lLoc2)); 
AssignCommand(oNPC1, ActionDoCommand( SetFacing(GetFacingFromLocation(lLoc1)) )); 
AssignCommand(oNPC2, ActionDoCommand( SetFacing(GetFacingFromLocation(lLoc2)) )); 
AssignCommand(oNPC1, ActionPlayAnimation(ANIMATION_FIREFORGET_SALUTE));
AssignCommand(oNPC2, ActionPlayAnimation(ANIMATION_FIREFORGET_SALUTE)); 
}

Link to comment
Share on other sites

You can delay the script by using this script.

 

void main() {
DelayCommand(0.3, AddAnActionHere());
}

 

And try this code, it compiled for me, and it essentially does the same thing. I wasn't sure where you wanted the delay, so just throw the aforementioned code in there.

 

void main() { 
object oNPC1 = GetObjectByTag("offmand01"); 
object oNPC2 = GetObjectByTag("offmand02");
location lLoc1 = Location(Vector(69.36, -2.8, 0.0), 4.71); 
location lLoc2 = Location(Vector(63.78, -2.8, 0.0), 1.57); 
AssignCommand(oNPC1, ClearAllActions()); 
AssignCommand(oNPC2, ClearAllActions());
ChangeToStandardFaction(oNPC1, 1);
ChangeToStandardFaction(oNPC2, 1);
AssignCommand(oNPC1,ActionMoveToLocation(lLoc1)); 
AssignCommand(oNPC2,ActionMoveToLocation(lLoc2)); 
AssignCommand(oNPC1, ActionDoCommand( SetFacing(GetFacingFromLocation(lLoc1)) )); 
AssignCommand(oNPC2, ActionDoCommand( SetFacing(GetFacingFromLocation(lLoc2)) )); 
AssignCommand(oNPC1, ActionPlayAnimation(ANIMATION_FIREFORGET_SALUTE));
AssignCommand(oNPC2, ActionPlayAnimation(ANIMATION_FIREFORGET_SALUTE)); 
}

Link to comment
Share on other sites

void main() { 
object oNPC1 = GetObjectByTag("offmand01"); 
object oNPC2 = GetObjectByTag("offmand02");
location lLoc1 = Location(Vector(69.36, -2.8, 0.0), 4.71); 
location lLoc2 = Location(Vector(63.78, -2.8, 0.0), 1.57); 
AssignCommand(oNPC1, ClearAllActions()); 
AssignCommand(oNPC2, ClearAllActions());
ChangeToStandardFaction(oNPC1, 1);
ChangeToStandardFaction(oNPC2, 1);
AssignCommand(oNPC1,ActionMoveToLocation(lLoc1)); 
AssignCommand(oNPC2,ActionMoveToLocation(lLoc2)); 
AssignCommand(oNPC1, ActionDoCommand( SetFacing(GetFacingFromLocation(lLoc1)) )); 
AssignCommand(oNPC2, ActionDoCommand( SetFacing(GetFacingFromLocation(lLoc2)) )); 
AssignCommand(oNPC1, ActionPlayAnimation(ANIMATION_FIREFORGET_SALUTE));
AssignCommand(oNPC2, ActionPlayAnimation(ANIMATION_FIREFORGET_SALUTE));

DelayCommand(0.3, ActionResumeConversation());
}

 

That should work, presuming this is all carrying out in a conversation. If not, I'll have to think of another way to implement that delay.

 

If it compiles, try it in-game and make sure it accomplishes everything you had in mind.

Link to comment
Share on other sites

I'm pretty sure that you can't link actions together like you can with effects, so you would need to use DelayCommand() for each of the actions you want to delay.

 

void main() { 
object oNPC1 = GetObjectByTag("offmand01"); 
object oNPC2 = GetObjectByTag("offmand02");
location lLoc1 = Location(Vector(69.36, -2.8, 0.0), 4.71); 
location lLoc2 = Location(Vector(63.78, -2.8, 0.0), 1.57); 
DelayCommand( 2.0, AssignCommand(oNPC1, ClearAllActions()) ); 
DelayCommand( 2.0, AssignCommand(oNPC2, ClearAllActions()) );
DelayCommand( 2.0, ChangeToStandardFaction(oNPC1, 1) );
DelayCommand( 2.0, ChangeToStandardFaction(oNPC2, 1) );
DelayCommand( 2.0, AssignCommand(oNPC1,ActionMoveToLocation(lLoc1)) ); 
DelayCommand( 2.0, AssignCommand(oNPC2,ActionMoveToLocation(lLoc2)) ); 
DelayCommand( 2.0, AssignCommand(oNPC1, ActionDoCommand( SetFacing(GetFacingFromLocation(lLoc1)) )) ); 
DelayCommand( 2.0, AssignCommand(oNPC2, ActionDoCommand( SetFacing(GetFacingFromLocation(lLoc2)) )) ); 
DelayCommand( 2.0, AssignCommand(oNPC1, ActionPlayAnimation(ANIMATION_FIREFORGET_SALUTE)) );
DelayCommand( 2.0, AssignCommand(oNPC2, ActionPlayAnimation(ANIMATION_FIREFORGET_SALUTE)) );

}

 

That will delay all of the actions by 2 seconds from the moment the script was triggered. Pop the script name into the OnOpen field of the door in question.

 

BTW, congrats on reaching 1000 posts. :)

 

- Star Admiral

Link to comment
Share on other sites

Archived

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

×
×
  • Create New...