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

C++ Summon follow distance

Itutorial

Board Moderator
Staff member
Board Moderator
Joined
Dec 23, 2014
Messages
2,476
Solutions
69
Reaction score
1,136
TFS 1.3

I need to find where summons follow distance is located. I am creating a summoning vocation and this is the last change needed for it to be complete.
 
Solution
TFS 1.3

I need to find where summons follow distance is located. I am creating a summoning vocation and this is the last change needed for it to be complete.
Here you go :)
monster.cpp
void Monster::getPathSearchParams(const Creature* creature, FindPathParams& fpp) const
C++:
if (isSummon()) {
        if (getMaster() == creature) {
            fpp.maxTargetDist = 2;
You mean max follow distance? the 30 sqm? if so its here
creature.cpp
C++:
        if (!summons.empty()) {
            //check if any of our summons is out of range (+/- 2 floors or 30 tiles away)
            std::forward_list<Creature*> despawnList;
            for (Creature* summon : summons) {
                const Position& pos = summon->getPosition();
                if (Position::getDistanceZ(newPos, pos) > 2 || (std::max<int32_t>(Position::getDistanceX(newPos, pos), Position::getDistanceY(newPos, pos)) > 30)) {
                    despawnList.push_front(summon);
                }
            }

            for (Creature* despawnCreature : despawnList) {
                g_game.removeCreature(despawnCreature, true);
            }
        }

        if (newTile->getZone() != oldTile->getZone()) {
            onChangeZone(getZone());
        }
 
No, this has come up before. That code is to despawn a summon only.

Monsters will stay 1sqm to attack you but summons stay 2sqm away at all times. I have looked everywhere for the part for the sources. This isn't the first time this issue has come up either. Its crucial as the summoner class can use his summons to block himself from an opponent.
Post automatically merged:

I know its somewhere in here....

Code:
void Creature::goToFollowCreature()
{
    if (followCreature) {
        FindPathParams fpp;
        getPathSearchParams(followCreature, fpp);

        Monster* monster = getMonster();
        if (monster && !monster->getMaster() && (monster->isFleeing() || fpp.maxTargetDist > 1)) {
            Direction dir = DIRECTION_NONE;

            if (monster->isFleeing()) {
                monster->getDistanceStep(followCreature->getPosition(), dir, true);
            } else { //maxTargetDist > 1
                if (!monster->getDistanceStep(followCreature->getPosition(), dir)) {
                    // if we can't get anything then let the A* calculate
                    listWalkDir.clear();
                    if (getPathTo(followCreature->getPosition(), listWalkDir, fpp)) {
                        hasFollowPath = true;
                        startAutoWalk(listWalkDir);
                    } else {
                        if (followCreature->getPosition().z != getPosition().z) {
                            g_game.internalTeleport(monster, followCreature->getPosition());
                            monster->getDistanceStep(followCreature->getPosition(), dir);
                        } else {
                        hasFollowPath = false;
                        }
                    }
                    return;
                }
            }

            if (dir != DIRECTION_NONE) {
                listWalkDir.clear();
                listWalkDir.push_front(dir);

                hasFollowPath = true;
                startAutoWalk(listWalkDir);
            }
        } else {
            listWalkDir.clear();
            if (getPathTo(followCreature->getPosition(), listWalkDir, fpp)) {
                hasFollowPath = true;
                startAutoWalk(listWalkDir);
            } else {
                hasFollowPath = false;
            }
        }
    }

    onFollowCreatureComplete(followCreature);
}
 
Last edited:
TFS 1.3

I need to find where summons follow distance is located. I am creating a summoning vocation and this is the last change needed for it to be complete.
Here you go :)
monster.cpp
void Monster::getPathSearchParams(const Creature* creature, FindPathParams& fpp) const
C++:
if (isSummon()) {
        if (getMaster() == creature) {
            fpp.maxTargetDist = 2;
 
Solution
Back
Top