• 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.X+ Spell execute cooldown

Lopaskurwa

Well-Known Member
Joined
Oct 6, 2017
Messages
912
Solutions
2
Reaction score
50
Hey got a question for example lets say you get target by bunch of monsters so you spam heal spell but when you spamming the heal you cant use any spells how can i make sure that even if the player spams heal he can still cast the spell. And yes heal and spell uses seperate groups one is group group="healing" and another is group="attack" so i assume its src feature that donesnt allow to execute two spells at the same time or something like that
 
Is your healing item is an action item or a spell item?

Because if it is a spell item(which means it is added in the spells folder not in acitons) i will be acted as a spell and will interfere with the spell exhaust.
 
Is your healing item is an action item or a spell item?

Because if it is a spell item(which means it is added in the spells folder not in acitons) i will be acted as a spell and will interfere with the spell exhaust.
yes its spell. Isnt it possible somehow to make so it wont interfere? Because i find it a bit annoying when it interfers and ruins the immersion because i have more spells that are used for escapes but you cant use them because it spams heal
 
Solutions to Allow Simultaneous Healing and Other Spells

Modify the Spell Exhaust System (Recommended)
The most robust solution is to modify the spell exhaust system in the source code to handle different spell groups independently:

Edit spells.cpp (or similar file in your server's source):

Modify the exhaust check to consider spell groups

Add logic to allow spells from different groups to bypass each other's exhaust
C++:
// Example modification (conceptual)
bool Player::canCastSpell(const Spell* spell) const {
    if (spell->getGroup() != "healing" && hasCondition(CONDITION_EXHAUST, EXHAUST_SPELL)) {
        return false;
    }
    // Additional checks...
    return true;
}
 
Solutions to Allow Simultaneous Healing and Other Spells

Modify the Spell Exhaust System (Recommended)
The most robust solution is to modify the spell exhaust system in the source code to handle different spell groups independently:

Edit spells.cpp (or similar file in your server's source):

Modify the exhaust check to consider spell groups

Add logic to allow spells from different groups to bypass each other's exhaust
C++:
// Example modification (conceptual)
bool Player::canCastSpell(const Spell* spell) const {
    if (spell->getGroup() != "healing" && hasCondition(CONDITION_EXHAUST, EXHAUST_SPELL)) {
        return false;
    }
    // Additional checks...
    return true;
}
Dont ahve canCastSDpell only
C++:
bool CombatSpell::castSpell(Creature* creature)
{
    if (scripted) {
        LuaVariant var;
        var.type = VARIANT_POSITION;

        if (needDirection) {
            var.pos = Spells::getCasterPosition(creature, creature->getDirection());
        } else {
            var.pos = creature->getPosition();
        }

        return executeCastSpell(creature, var);
    }

    Position pos;
    if (needDirection) {
        pos = Spells::getCasterPosition(creature, creature->getDirection());
    } else {
        pos = creature->getPosition();
    }

    combat->doCombat(creature, pos);
    return true;
}

bool CombatSpell::castSpell(Creature* creature, Creature* target)
{
    if (scripted) {
        LuaVariant var;

        if (combat->hasArea()) {
            var.type = VARIANT_POSITION;

            if (needTarget) {
                var.pos = target->getPosition();
            } else if (needDirection) {
                var.pos = Spells::getCasterPosition(creature, creature->getDirection());
            } else {
                var.pos = creature->getPosition();
            }
        } else {
            var.type = VARIANT_NUMBER;
            var.number = target->getID();
        }
        return executeCastSpell(creature, var);
    }

    if (combat->hasArea()) {
        if (needTarget) {
            combat->doCombat(creature, target->getPosition());
        } else {
            return castSpell(creature);
        }
    } else {
        combat->doCombat(creature, target);
    }
    return true;
}

bool CombatSpell::executeCastSpell(Creature* creature, const LuaVariant& var)
{
    //onCastSpell(creature, var)
    if (!scriptInterface->reserveScriptEnv()) {
        std::cout << "[Error - CombatSpell::executeCastSpell] Call stack overflow" << std::endl;
        return false;
    }

    ScriptEnvironment* env = scriptInterface->getScriptEnv();
    env->setScriptId(scriptId, scriptInterface);

    lua_State* L = scriptInterface->getLuaState();

    scriptInterface->pushFunction(scriptId);

    LuaScriptInterface::pushUserdata<Creature>(L, creature);
    LuaScriptInterface::setCreatureMetatable(L, -1, creature);

    LuaScriptInterface::pushVariant(L, var);

    return scriptInterface->callFunction(2);
}
 
Back
Top