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

Solved Monster Walk Field

Shackal

Alien Project
Joined
Feb 7, 2009
Messages
211
Reaction score
17
Location
Brazil
Good afternoon everyone!

I have this bug fixed in my distro 8.6 and am trying to solve at TFS 1.2.

Follow code in TFS 1.2:
tile.cpp
Code:
if (field && !field->isBlocking()) {
                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 "strong" enough to handle the damage
                    //2) Monster is already afflicated by this type of condition
                    if (hasBitSet(FLAG_IGNOREFIELDDAMAGE, flags)) {
                        if (!(monster->canPushItems() || monster->hasCondition(Combat::DamageToConditionType(combatType)))) {
                            return RETURNVALUE_NOTPOSSIBLE;
                        }
                    } else {
                        return RETURNVALUE_NOTPOSSIBLE;
                    }
                }
            }


Follow code in otx 8.6:

tile.cpp
Code:
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))
                return RET_NOERROR;

            //1) Monster is "strong" enough to handle the damage
            //2) Monster is already afflicated by this type of condition
            if(!hasBitSet(FLAG_IGNOREFIELDDAMAGE, flags))
                return RET_NOTPOSSIBLE;

            return !monster->hasCondition(Combat::DamageToConditionType(combatType), -1, false) &&
                (!monster->canPushItems() || !monster->hasRecentBattle()) ? RET_NOTPOSSIBLE : RET_NOERROR;
ps: It seems to me, a new variable was added, hasRecentBattle.

monster.h
Code:
bool hasRecentBattle() const {return lastDamage && (uint64_t)OTSYS_TIME() < (lastDamage + 30000);}

monster.cpp

Code:
void Monster::changeHealth(int32_t healthChange)
{
    //In case a player with ignore flag set attacks the monster
    setIdle(false);
    if(!hasRecentBattle())
    {
        lastDamage = OTSYS_TIME();
        updateMapCache();
    }

    Creature::changeHealth(healthChange);
}

Does anyone have any idea how to solve?

Thank you in advance!
 
Try to replace:
Code:
if (!(monster->canPushItems() || monster->hasCondition(Combat::DamageToConditionType(combatType)))) {

to:
Code:
if (!(monster->canPushItems() || monster->hasRecentBattle()) && !monster->hasCondition(Combat::DamageToConditionType(combatType))) {

And add all other functions, to their respective file.
 
Hello @darkjav !

But hasRecentBattle is not declared in tfs 1.2

Code:
/src/tile.cpp: In member function ‘virtual ReturnValue Tile::queryAdd(int32_t, const Thing&, uint32_t, uint32_t, Creature*) const’:
/src/tile.cpp:548:49: error: ‘const class Monster’ has no member named ‘hasRecentBattle’
       if (!(monster->canPushItems() || monster->hasRecentBattle()) && !monster->hasCondition(Combat::DamageToConditionType(combatType))) {
                                                 ^
CMakeFiles/tfs.dir/build.make:1756: recipe for target 'CMakeFiles/tfs.dir/src/tile.cpp.o' failed
make[2]: *** [CMakeFiles/tfs.dir/src/tile.cpp.o] Error 1
CMakeFiles/Makefile2:60: recipe for target 'CMakeFiles/tfs.dir/all' failed
make[1]: *** [CMakeFiles/tfs.dir/all] Error 2
Makefile:76: recipe for target 'all' failed
make: *** [all] Error 2
 
Last edited:
Hello @darkjav !

But hasRecentBattle is not declared in tfs 1.2

Code:
/src/tile.cpp: In member function ‘virtual ReturnValue Tile::queryAdd(int32_t, const Thing&, uint32_t, uint32_t, Creature*) const’:
/src/tile.cpp:548:49: error: ‘const class Monster’ has no member named ‘hasRecentBattle’
       if (!(monster->canPushItems() || monster->hasRecentBattle()) && !monster->hasCondition(Combat::DamageToConditionType(combatType))) {
                                                 ^
CMakeFiles/tfs.dir/build.make:1756: recipe for target 'CMakeFiles/tfs.dir/src/tile.cpp.o' failed
make[2]: *** [CMakeFiles/tfs.dir/src/tile.cpp.o] Error 1
CMakeFiles/Makefile2:60: recipe for target 'CMakeFiles/tfs.dir/all' failed
make[1]: *** [CMakeFiles/tfs.dir/all] Error 2
Makefile:76: recipe for target 'all' failed
make: *** [all] Error 2
you have to declare it
 
I am trying, but it is so hard.
Code:
/sources/src/monsters.cpp:1235:55: error: no ‘void Monsters::combatChangeHealth(int32_t)’ member function declared in class ‘Monsters’
 void Monsters::combatChangeHealth(int32_t healthChange)
                                                       ^
CMakeFiles/tfs.dir/build.make:997: recipe for target 'CMakeFiles/tfs.dir/src/monsters.cpp.o' failed
make[2]: *** [CMakeFiles/tfs.dir/src/monsters.cpp.o] Error 1
CMakeFiles/Makefile2:60: recipe for target 'CMakeFiles/tfs.dir/all' failed
make[1]: *** [CMakeFiles/tfs.dir/all] Error 2
Makefile:76: recipe for target 'all' failed
make: *** [all] Error 2
vps:/sources/build#

Now is compiled, but when arrived in 100% return it:


Yeah!! Compiled, but it do not work:
Code:
if (!(monster->canPushItems() || monster->hasRecentBattle()) && !monster->hasCondition(Combat::DamageToConditionType(combatType))) {
 
Last edited by a moderator:
What is actually the bug? This hadRecentBattle shit was removed from TFS because it was wrong. Monster avoiding or not the field has nothing to do with it.
 
Thanks for the feedback @Peonso . I'm trying to make a grim reaper just pass over an energy field if it is attacked for example.
My distro by default, the grim reaper goes over the fire if there is no other way he could get to me.

sorry my bad english
 
Thanks for the feedback @Peonso . I'm trying to make a grim reaper just pass over an energy field if it is attacked for example.
My distro by default, the grim reaper goes over the fire if there is no other way he could get to me.

sorry my bad english
Manda em português. Essa descrição do Grim Reaper passando pelo fire field é o comportamento correto. Tu quer que ele seja trapado, e so atravesse se for atacado, ai tu ta adicionando um bug.
 
Solved!!
Code:
if (!monster->hasCondition(Combat::DamageToConditionType(combatType)) && (!monster->canPushItems() || !monster->hasRecentBattle())) {
 
Good afternoon everyone!

I have this bug fixed in my distro 8.6 and am trying to solve at TFS 1.2.

Follow code in TFS 1.2:
tile.cpp
Code:
if (field && !field->isBlocking()) {
                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 "strong" enough to handle the damage
                    //2) Monster is already afflicated by this type of condition
                    if (hasBitSet(FLAG_IGNOREFIELDDAMAGE, flags)) {
                        if (!(monster->canPushItems() || monster->hasCondition(Combat::DamageToConditionType(combatType)))) {
                            return RETURNVALUE_NOTPOSSIBLE;
                        }
                    } else {
                        return RETURNVALUE_NOTPOSSIBLE;
                    }
                }
            }


Follow code in otx 8.6:

tile.cpp
Code:
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))
                return RET_NOERROR;

            //1) Monster is "strong" enough to handle the damage
            //2) Monster is already afflicated by this type of condition
            if(!hasBitSet(FLAG_IGNOREFIELDDAMAGE, flags))
                return RET_NOTPOSSIBLE;

            return !monster->hasCondition(Combat::DamageToConditionType(combatType), -1, false) &&
                (!monster->canPushItems() || !monster->hasRecentBattle()) ? RET_NOTPOSSIBLE : RET_NOERROR;
ps: It seems to me, a new variable was added, hasRecentBattle.

monster.h
Code:
bool hasRecentBattle() const {return lastDamage && (uint64_t)OTSYS_TIME() < (lastDamage + 30000);}

monster.cpp

Code:
void Monster::changeHealth(int32_t healthChange)
{
    //In case a player with ignore flag set attacks the monster
    setIdle(false);
    if(!hasRecentBattle())
    {
        lastDamage = OTSYS_TIME();
        updateMapCache();
    }

    Creature::changeHealth(healthChange);
}

Does anyone have any idea how to solve?

Thank you in advance!
thank u man for scripts! srry for bad english...
 
Back
Top