• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

creatureMoveTo

Marcelo Druida

Intermediate OT User
Joined
Nov 17, 2014
Messages
429
Solutions
1
Reaction score
135
Location
Brazil
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

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
 
Back
Top