• 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++ TFS 1.2 Is it possible to fix the spell emote spam

Tbol

Well-Known Member
Joined
Apr 7, 2019
Messages
531
Reaction score
56
I will try to explain what i mean but basically when you cast a spell orange text appears above your head right? So if you cast it like a lot of time it stacks up and it looks just nasty so i will provide image what i mean
Is it possible to make it so it send only like max 3 not that much as in image
 

Attachments

Solution
I needed this too, it should work for you too, you'll have to adjust the numbers because I have different cooldowns,
first go to enums.h
add CONDITION_EMOTESPELLEXHAUST to the bottom of ConditionType_t table:
Code:
    CONDITION_EXHAUST_COMBAT = 1 << 23, // unused
    CONDITION_EXHAUST_HEAL = 1 << 24, // unused
    CONDITION_PACIFIED = 1 << 25,
    CONDITION_SPELLCOOLDOWN = 1 << 26,
    CONDITION_SPELLGROUPCOOLDOWN = 1 << 27,
    CONDITION_EMOTESPELLEXHAUST = 1 << 28,
add to conditions.cpp:
by case CONDITION_MUTED add case CONDITION_EMOTESPELLEXHAUST:
Code:
        case CONDITION_EXHAUST_COMBAT:
        case CONDITION_EXHAUST_BUFF:
        case CONDITION_EXHAUST_HEAL:
        case CONDITION_MUTED:
        case...
Does it affect performance in any way?
Not in the way it should concern anyone.
If you are curious about performance, go ahead and run your server along with Visual Studio's debugger, it has a lot of features that are quite user friendly and will let you know about your server's memory and CPU usage.
 
@Sarah Wesker @4Nathu4 would it be more efficient if I saved the condition, so it didn't call it? for example:
Code:
        if (!player->hasCondition(CONDITION_EMOTESPELLEXHAUST)) {
            Condition* condition = Condition::createCondition(CONDITIONID_DEFAULT, CONDITION_EMOTESPELLEXHAUST, 4000, 0);
            player->addCondition(condition);
            return internalCreatureSay(player, TALKTYPE_MONSTER_SAY, words, false);
        } else {
            if (player->getCondition(CONDITION_EMOTESPELLEXHAUST)->getTicks() >= 4000) {
                return true;
            }
            else {
                player->getCondition(CONDITION_EMOTESPELLEXHAUST)->setTicks(std::min(7000, 2500 + player->getCondition(CONDITION_EMOTESPELLEXHAUST)->getTicks()));
                return internalCreatureSay(player, TALKTYPE_MONSTER_SAY, words, false);
            }
        }
change it to?:
Code:
        if (!player->hasCondition(CONDITION_EMOTESPELLEXHAUST)) {
            Condition* condition = Condition::createCondition(CONDITIONID_DEFAULT, CONDITION_EMOTESPELLEXHAUST, 4000, 0);
            player->addCondition(condition);
            return internalCreatureSay(player, TALKTYPE_MONSTER_SAY, words, false);
        } else {
            Condition* condition = player->getCondition(CONDITION_EMOTESPELLEXHAUST);
            int32_t conditionTicks = condition->getTicks();
            if (conditionTicks >= 4000) {
                return true;
            }
            else {
                condition->setTicks(std::min(7000, 2500 + conditionTicks));
                return internalCreatureSay(player, TALKTYPE_MONSTER_SAY, words, false);
            }
        }
I imagine the difference would be extremely minute as you guys are saying if there is a difference, but I always wondered.
 
would it be more efficient if I saved the condition, so it didn't call it? for example:
Code:
        if (!player->hasCondition(CONDITION_EMOTESPELLEXHAUST)) {
            Condition* condition = Condition::createCondition(CONDITIONID_DEFAULT, CONDITION_EMOTESPELLEXHAUST, 4000, 0);
            player->addCondition(condition);
            return internalCreatureSay(player, TALKTYPE_MONSTER_SAY, words, false);
        } else {
            if (player->getCondition(CONDITION_EMOTESPELLEXHAUST)->getTicks() >= 4000) {
                return true;
            }
            else {
                player->getCondition(CONDITION_EMOTESPELLEXHAUST)->setTicks(std::min(7000, 2500 + player->getCondition(CONDITION_EMOTESPELLEXHAUST)->getTicks()));
                return internalCreatureSay(player, TALKTYPE_MONSTER_SAY, words, false);
            }
        }
change it to?:
Code:
        if (!player->hasCondition(CONDITION_EMOTESPELLEXHAUST)) {
            Condition* condition = Condition::createCondition(CONDITIONID_DEFAULT, CONDITION_EMOTESPELLEXHAUST, 4000, 0);
            player->addCondition(condition);
            return internalCreatureSay(player, TALKTYPE_MONSTER_SAY, words, false);
        } else {
            Condition* condition = player->getCondition(CONDITION_EMOTESPELLEXHAUST);
            int32_t conditionTicks = condition->getTicks();
            if (conditionTicks >= 4000) {
                return true;
            }
            else {
                condition->setTicks(std::min(7000, 2500 + conditionTicks));
                return internalCreatureSay(player, TALKTYPE_MONSTER_SAY, words, false);
            }
        }
I imagine the difference would be extremely minute as you guys are saying if there is a difference, but I always wondered.
If I'm not wrong it doesn't matter from a performance perspective, because the compiler will link it to the same adress anyway - but in case I'm wrong the later example is better, since accessing the conditionTicks and the pointer from the stack should be faster than calling the methods that will return aforementioned, thus if you are having multiple calls that should return the same things, it's better to place it on the stack so you call the method only once and later just access the value from there.

Also, it's way easier to read it that way.
 
Back
Top