• 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++ Pets Walking Through Walls

Phemus

Member
Joined
Jun 16, 2012
Messages
149
Solutions
2
Reaction score
12
I am currently working on a pet system where pets/summons can walk through protection zone. However, when I edited the source code in tile.cpp, my pet/summon walks through PZ but it also walks through the walls.

I am using OTX 2 (0.4), 8.60

Screenshot 2021-12-31 001613.png

C++:
if(const Monster* monster = creature->getMonster())
        {
            if(hasFlag(TILESTATE_PROTECTIONZONE) && !monster->isPlayerSummon())
                return RET_NOTPOSSIBLE;

            if(floorChange() || positionChange())
                return RET_NOTPOSSIBLE;

            if(monster->canPushCreatures() && !monster->isSummon())
            {
                if(creatures && !creatures->empty())
                {
                    Creature* tmp = NULL;
                    for(uint32_t i = 0; i < creatures->size(); ++i)
                    {
                        tmp = creatures->at(i);
                        if(creature->canWalkthrough(tmp))
                            continue;

                        if (!tmp->getMonster() || !tmp->isPushable() ||
                            (tmp->getMonster()->isSummon() &&
                                tmp->getMonster()->isPlayerSummon()))
                            return RET_NOTPOSSIBLE;
                    }
                }
            }
            else if(creatures && !creatures->empty())
            {
                for(CreatureVector::const_iterator cit = creatures->begin(); cit != creatures->end(); ++cit)
                {
                    if(!creature->canWalkthrough(*cit))
                        return RET_NOTENOUGHROOM; //NOTPOSSIBLE
                }
            }

Also how can I make it so my pet/summon can always be on frame. For example, if I walk and its more than 8 SQM, my pet gets teleported to my current location even if I change floors. In other words, so it can always be with me.

Thank you.
 
Back
Top