I have this code for an NPC pacing an area. I want it so that when he reaches location 1 or 2, he waits for a few seconds before walking again. I tried to do this using timers, but failed miserably.
function room_RepExec()
{
if (!cDog.Moving) //only check if the NPC isn't moving
{
if (characterLocation==1)
{
cDog.Walk(111, 183, eNoBlock, eAnywhere);
characterLocation=2;
}
else
if (characterLocation==2)
{
cDog.Walk(13, 181, eNoBlock, eAnywhere);
characterLocation=1;
}
}
}
Based on the code you have now, it should be working fine except for the waiting part.
// room script
int dogDelay = 100; // change this to whatever wait duration you want
function room_RepExec()
{
if (dogDelay) dogDelay--;
else if (!cDog.Moving)
{
if (characterLocation == 1)
{
cDog.Walk(111, 183, eNoBlock, eAnywhere);
characterLocation = 2;
}
else if (characterLocation == 2) // unless there's more than 2 locations, this is redundant and could just be 'else'
{
cDog.Walk(13, 181, eNoBlock, eAnywhere);
characterLocation = 1;
}
dogDelay = 100; // again, change this as appropriate
}
}