Code: Select all
object GetNextPatrolWaypoint(object oCreature, string sWPName){
int iDelPos = FindSubString(sWPName, "|");
string sWPRoot = GetSubString(sWPName, 0, iDelPos);
int iWPCount = StringToInt(GetSubString(sWPName, iDelPos + 1, GetStringLength(sWPName) - iDelPos)) + 1;
object oNextWP = GetNearestObjectByTag(sWPRoot + "_" + IntToString(iWPCount), oCreature);
if (!GetIsObjectValid(oNextWP)){
oNextWP = GetNearestObjectByTag(sWPRoot + "_1");
}
return oNextWP;
}
void CheckStuck(object oCreature)
{
int iCurrentAction = GetLocalInt(oCreature, "CurrentAction");
int iTimeOut = GetLocalInt(oCreature, "ActionStartTime");
int iCurrentTime = StringToInt(IntToString(GetTimeHour()) + IntToString(GetTimeMinute()) + IntToString(GetTimeSecond()));
object oCurrentWaypoint = GetLocalObject(oCreature, "CurrentWaypoint");
if (iCurrentAction = 1 && (iCurrentTime > iTimeOut)){
object oNextWaypoint = GetNextPatrolWaypoint(oCreature, GetName(oCurrentWaypoint));
if (GetIsObjectValid(oNextWaypoint)){
ClearAllActions();
ActionJumpToObject(oNextWaypoint);
}
}
}
void main()
{
}