• 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.5 monster that use beam/wave do not use them if they are melee attacking in front of player

Felipe93

Ghost Member
Joined
Mar 21, 2015
Messages
1,990
Solutions
9
Reaction score
333
Location
Chile
Hello as the title says I noticed that the monsters that are in front of a player attacking it does not use waves or beams at all. is there a way to change this?
example a dragon if it's close to a player wont use beam or waves
im using tfs 1.5 downgraded by nekiro
Post automatically merged:

solved had to made changes in doattacking and canuseattack in monster.cpp
 
Last edited:
Post the changes maybe it helps someone else using same downgrade.
do attacking
Lua:
const Position& myPos = getPosition();
    const Position& targetPos = attackedCreature->getPosition();

    for (const spellBlock_t& spellBlock : mType->info.attackSpells) {
        if (isMelee && isFleeing())
            continue;
        bool inRange = false;

        if (attackedCreature == nullptr) {
            break;
        }

        if (canUseSpell(myPos, targetPos, spellBlock, interval, inRange, resetTicks)) {
            if (spellBlock.chance >= static_cast<uint32_t>(uniform_random(1, 100))) {
                if (updateLook) {
                    updateLookDirection();
                    updateLook = false;
                }

                minCombatValue = spellBlock.minCombatValue;
                maxCombatValue = spellBlock.maxCombatValue;
                /*spellBlock.spell->castSpell(this, attackedCreature);

                if (spellBlock.isMelee) {
                    lastMeleeAttack = OTSYS_TIME();*/
                if (isMelee || OTSYS_TIME() > (lastMeleeAttack + interval)) {
                    spellBlock.spell->castSpell(this, attackedCreature);
                    if (isMelee) {
                        extraMeleeAttack = false;
                        lastMeleeAttack = OTSYS_TIME();
                }
            }
        }

        //if (!inRange && spellBlock.isMelee) {
            //melee swing out of reach
            //lastMeleeAttack = 0;
            if (inRange) {
                outOfRange = false;
            }
            else if (isMelee && OTSYS_TIME() > (lastMeleeAttack + interval)) {
                //melee swing out of reach
                extraMeleeAttack = true;
                //resetTicks = true;
                //g_game.addAnimatedText(getPosition(), TEXTCOLOR_WHITE_EXP, "Extra melee");
        }
    }
    }
    //if (attacked && interval > 100) attackTicks += (interval - 100);

    if (updateLook) {
        updateLookDirection();
    }

    if (resetTicks) {
        attackTicks = 0;
    }
}

and
can canusespells in monster.cpp
Code:
    /*inRange = true;

    if (sb.isMelee) {
        if (isFleeing() || (OTSYS_TIME() - lastMeleeAttack) < sb.speed) {
            return false;
        }
    } else {
        if (sb.speed > attackTicks) {
            resetTicks = false;
            return false;
        }

        if (attackTicks % sb.speed >= interval) {
            //already used this spell for this round
            return false;
        }
    }*/
    inRange = true;

    //if (sb.isMelee) {
        //if (isFleeing() || (OTSYS_TIME() - lastMeleeAttack) < sb.speed) {
            //return false;
        //}

    if (!sb.isMelee || !extraMeleeAttack) {
        if (sb.speed > attackTicks) {
            resetTicks = false;
            return false;
        }

        if (attackTicks % sb.speed >= interval) {
            //already used this spell for this round
            return false;
        }
    }


    if (sb.range != 0 && std::max<uint32_t>(Position::getDistanceX(pos, targetPos), Position::getDistanceY(pos, targetPos)) > sb.range) {
        inRange = false;
        return false;
    }
    return true;
    }

still buggy for fleeing monster, could syou guys points me out where should i look for fleeing monsters / runonhealth in order to add this code? (extra melee attack)
so when they are being chased or running away will attack / cast spells faster. Where should i look to fix this? @M0ustafa @Gesior.pl
also moster do not try to be in front of monsters the almost always stay diagonal to player i added this TFS A* Algorithm :D (https://otland.net/threads/tfs-a-algorithm-d.282100/)
where should i check ? i want that monsters try or intend to be in front of players
 
Last edited:
Back
Top