• 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!

TFS 1.X+ Ordering Summon on PZ

light123

New Member
Joined
Sep 10, 2008
Messages
1
Reaction score
0
Hello, I'm currently doing some tests on TFS 1.2

I was able to manage summon to follow player, including on pz.
Now, I'm getting some trouble on ordering the summon.

I've added a C++ function on luascript.cpp and I'm having some false results on creature->getPathTo(position, dirList, fpp)

New function to order
C++:
int32_t LuaScriptInterface::luaCreatureMoveTo(lua_State* L) // LightFP
{
    //creature:moveTo(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, 0);
    fpp.fullPathSearch = getBoolean(L, 5, fpp.fullPathSearch);
    fpp.clearSight = getBoolean(L, 6, fpp.clearSight);
    fpp.maxSearchDist = getNumber<int32_t>(L, 7, 150);

    std::vector<Direction> dirList;
    if (creature->getPathTo(position, dirList, fpp)) {
        if (creature->getMaster() != 0){
            std::cout << "TRUE - luaCreatureMoveTo.getPathTo" << std::endl;
        }
        creature->hasFollowPath = true;
        creature->isWalking = true;
        creature->startAutoWalk(dirList);
        pushBoolean(L, true);
    } else {
        std::cout << "FALSE - luaCreatureMoveTo.getPathTo" << std::endl;
        pushBoolean(L, false);
    }
    return 1;
}

I was trying to debug and noticed that my problem is on getPathMatching from map.cpp.

Debug added on getPathMatching
C++:
    while (fpp.maxSearchDist != 0 || nodes.getClosedNodes() < 100) {
        AStarNode* n = nodes.getBestNode();
        if (!n) {
            if (found) {
                break;
            }
            if (creature.getMaster() != 0){
                std::cout << "FALSE - maxSearchDist - map.getPathMatching - " << nodes.getBestNode() << "|" << nodes.getClosedNodes() << std::endl;
            }  
            return false;
        }
    .
    .
    .
    }


Seems I'm only able to order the summon on pz, if the player has already walked thru the sqm. I'm getting the results from nodes.getClosedNodes() and it's increasing as the player start to walk on pz, otherwise it returns 1.

Debug on console
FALSE - maxSearchDist - map.getPathMatching - 0|1
FALSE - luaCreatureMoveTo.getPathTo


Did someone has any clue on how to solve that or some sample how I can create the order for the summon?

Sorry if I missed something.
Thank you!
 
Last edited:
Back
Top