• 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++ [OTX 3.8] Walk on fields

ralke

(҂ ͠❛ ෴ ͡❛)ᕤ
Joined
Dec 17, 2011
Messages
871
Solutions
19
Reaction score
409
Location
Santiago - Chile
Hi! I've been struggling with walk on fields for OTX 3.8, applied this commit Fix monsters walking over fields. (#2207) · otland/[email protected] (https://github.com/otland/forgottenserver/commit/18fbfdc33a65c5cba9d5a02bcc8116dfd10362b0) with some minor changes here (monster.h):

Code:
uint64_t getLostExperience() const override {
            return skillLoss ? mType->info.experience : 0;
        }
        uint16_t getLookCorpse() const override {
            return mType->info.lookcorpse;
        }
        void dropLoot(Container* corpse, Creature* lastHitCreature) override;
        uint32_t getDamageImmunities() const override {
            return mType->info.damageImmunities;
        }
        uint32_t getConditionImmunities() const override {
            return mType->info.conditionImmunities;
        }
        void getPathSearchParams(const Creature* creature, FindPathParams& fpp) const override;
        bool useCacheMap() const override {
            return !randomStepping;
        }

and here (tile.cpp):

Code:
   MagicField* field = getFieldItem();
            if (!field || field->isBlocking() || field->getDamage() == 0) {
                return RETURNVALUE_NOERROR;
            }

            CombatType_t combatType = field->getCombatType();

            //There is 3 options for a monster to enter a magic field
            //1) Monster is immune
            if (!monster->isImmune(combatType)) {
                //1) Monster is able to walk over field type
                //2) Being attacked while random stepping will make it ignore field damages
                if (hasBitSet(FLAG_IGNOREFIELDDAMAGE, flags)) {
                    if (!(monster->canWalkOnFieldType(combatType) || monster->isIgnoringFieldDamage())) {
                        return RETURNVALUE_NOTPOSSIBLE;
                    }
                }
                else {
                    return RETURNVALUE_NOTPOSSIBLE;
                }
            }

            return RETURNVALUE_NOERROR;
        }

The trouble is that the monster delays too much to enter fields after being attacked, someone can help me fixing this?
Here is a video showing the issue.


Regards!
Post automatically merged:

For now I've just changed the firefield ticks, just realized that the monster start attacking after being burned for the first time
Code:
<attribute key="ticks" value="5000" />

But I still want to see if I can make the monster attack at the moment it got damaged. Or with a minium delay after that
 
Last edited:
Solution

Ok, I thought I had solved this before. But this is the real solution, the monster really had a delay.
Go to creature.cpp and search hasFollowPath then edit with this

Code:
 if (hasFollowPath) {
            isUpdatingPath = true;
            g_dispatcher.addTask(createTask(std::bind(&Game::updateCreatureWalk, &g_game, getID())));
        }

The solution was found here TFS 1.X+ - Weird monster/npc walk...
OP
ralke

ralke

(҂ ͠❛ ෴ ͡❛)ᕤ
Joined
Dec 17, 2011
Messages
871
Solutions
19
Reaction score
409
Location
Santiago - Chile

Ok, I thought I had solved this before. But this is the real solution, the monster really had a delay.
Go to creature.cpp and search hasFollowPath then edit with this

Code:
 if (hasFollowPath) {
            isUpdatingPath = true;
            g_dispatcher.addTask(createTask(std::bind(&Game::updateCreatureWalk, &g_game, getID())));
        }

The solution was found here TFS 1.X+ - Weird monster/npc walk behavior (https://otland.net/threads/weird-monster-npc-walk-behavior.261695/#post-2531223) but is important to set isUpdatingPath = true; in order to make field system work. Added an explaining video, dont forget to add the commit from the spoiler too!


Regards!
 
Last edited:
Solution
Top