@PCS
Good start. I see that you have this;
if ai_start_x[e] == nil then <<---========= Eliminate this line -- let's do it regardless.
ai_start_x[e] = g_Entity[e]['x']
ai_start_z[e] = g_Entity[e]['z']
ai_start_y[e] = g_Entity[e]['y'] -- keep this active also
Put those in the init part of the script. You want to make them
be sure they get a value assigned. You may have to assign that
more than once-- it's kinda hard to explain...
We just want to place the NPC down when reset whether it moves
or not: (Keep it simple)
eliminate this part:
-------mod for check if ai has move from start point
tDistX = g_Entity[e]['x'] - ai_start_x[e];
tDistZ = g_Entity[e]['z'] - ai_start_z[e];
DistToStart = math.sqrt(math.abs(tDistX*tDistX)+math.abs(tDistZ*tDistZ))
if DistToStart > 0 then
npc_moved = 1
else
npc_moved = 0
end----------------------------------------
You'll need the CollisionOff before the move, and like AmenMoses said,
you'll need to include the 'y' coordinate.
======>>CollisionOff(e) - or this might have to call the object #? Amen knows.
PositionObject(EntObjNo,ai_start_x[e],ai_start_z[e]) -- ( this does nothing )
CollisionOn(e)- or this might have to call the object #? Amen knows.
That should get you closer- not tested.