The loop is working, but not as you expect. After the script finishes, the NPC will try three times to move to oWayd. After six seconds, he will be given three more commands to move to oWayc. After 14 seconds, he will be given three commands to move to oWayb.
The correct way to do this depends on whether you want him to pause at each waypoint or to continue the circuit uninterrupted.
To do the loop uninterrupted:
void main()
{
object oBoy = GetObjectByTag("Michan");
object oWayb = GetWaypointByTag("WpKidPlay01");
object oWayc = GetWaypointByTag("WpKidPlay02");
object oWayd = GetWaypointByTag("WpKidPlay03");
int nLoop;
for (nLoop = 1; nLoop < 5; nLoop ++)
{
AssignCommand(oBoy, ActionMoveToObject(oWayd, TRUE));
AssignCommand(oBoy, ActionMoveToObject(oWayc, TRUE));
AssignCommand(oBoy, ActionMoveToObject(oWayb, TRUE));
}
}
To wait at each waypoint:
void main()
{
object oBoy = GetObjectByTag("Michan");
object oWayb = GetWaypointByTag("WpKidPlay01");
object oWayc = GetWaypointByTag("WpKidPlay02");
object oWayd = GetWaypointByTag("WpKidPlay03");
int nLoop;
for (nLoop = 1; nLoop < 5; nLoop ++)
{
AssignCommand(oBoy, ActionMoveToObject(oWayd, TRUE));
AssignCommand(oBoy, ActionWait(6.0));
AssignCommand(oBoy, ActionMoveToObject(oWayc, TRUE));
AssignCommand(oBoy, ActionWait(6.0));
AssignCommand(oBoy, ActionMoveToObject(oWayb, TRUE));
AssignCommand(oBoy, ActionWait(6.0));
}
}
Modifié par Squatting Monk, 30 septembre 2013 - 01:48 .