Marcelo Druida
Intermediate OT User
Hello!
Im working on a function that make creatures walk to the destination position.
It works fine with players and NPCs but not with monsters
i made numerous attempts to fix it but unsucessful
please help me
Im working on a function that make creatures walk to the destination position.
It works fine with players and NPCs but not with monsters
Code:
int32_t LuaScriptInterface::luaMoveCreatureTo(lua_State* L)
{
//creature:moveCreatureTo(pos)
Creature* creature = getUserdata<Creature>(L, 1);
if (!creature) {
lua_pushnil(L);
return 1;
}
const Position& position = getPosition(L, 2);
FindPathParams fpp;
fpp.minTargetDist = getNumber<int32_t>(L, 3, 0);
fpp.maxTargetDist = getNumber<int32_t>(L, 4, 1);
fpp.fullPathSearch = getBoolean(L, 5, fpp.fullPathSearch);
fpp.clearSight = getBoolean(L, 6, fpp.clearSight);
fpp.maxSearchDist = getNumber<int32_t>(L, 7, 150);
std::forward_list<Direction> dirList;
if (creature->getPathTo(position, dirList, fpp)) {
creature->hasFollowPath = true;
creature->startAutoWalk(dirList);
pushBoolean(L, true);
}
else { pushBoolean(L, false); }
return 1;
}
i made numerous attempts to fix it but unsucessful
please help me