PDA

View Full Version : Syntax error and adding a delay


Canderis
06-14-2009, 07:54 PM
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));
}

JediMaster76
06-14-2009, 08:44 PM
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));
}

Canderis
06-14-2009, 08:48 PM
Thanks it compiled! I need the whole thing to delay for 2 seconds after it was triggered.

JediMaster76
06-14-2009, 08:55 PM
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.

Canderis
06-14-2009, 08:57 PM
Nope this doesn't happen during a dialog but when you open a door.

Star Admiral
06-14-2009, 09:48 PM
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

Canderis
06-14-2009, 09:52 PM
Thanks guys! All is happy in my world.