• 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++ Another solution for the same problem

roriscrave

Advanced OT User
Joined
Dec 7, 2011
Messages
1,188
Solutions
34
Reaction score
200
In this topic, they give some solution for spam spells problem:

but I didn't really like the solution adopted, because if the player uses "exori 'and then" exori hur", "exana morth" both spells will release, but the "exori hur" and "exana mort" will not appear in orange (because of delay), what makes game looked bugged.

is it possible a solution, when spam, show only 3 spells in orange? (3 last spells casted)?

1609905127097.png
1609904530469.png
 
Last edited:
With the following changes, each spell has its own cooldown, only regarding the text obviously!

game.cpp
C++:
bool Game::playerSaySpell(Player* player, SpeakClasses type, const std::string& text)
{
    std::string words = text;

    TalkActionResult_t result = g_talkActions->playerSaySpell(player, type, words);
    if (result == TALKACTION_BREAK) {
        return true;
    }

    InstantSpell* instantSpell;
    result = g_spells->playerSaySpell(player, words, instantSpell);
    if (result == TALKACTION_BREAK) {
        if (instantSpell) {
            int64_t milliseconds = 0;
            const int8_t& spellId = instantSpell->getId();
            player->getStorageValue(spellId, milliseconds);
            int64_t now = OTSYS_TIME();
            if (milliseconds <= now) {
                player->setStorageValue(spellId, now + 3000);
            }
            else {
                // Dont show spell emote
                return true;
            }
        }
        if (!g_config.getBoolean(ConfigManager::EMOTE_SPELLS)) {
            return internalCreatureSay(player, TALKTYPE_SAY, words, false);
        } else {
            return internalCreatureSay(player, TALKTYPE_MONSTER_SAY, words, false);
        }

    } else if (result == TALKACTION_FAILED) {
        return true;
    }

    return false;
}

spells.cpp
C++:
// Found:
TalkActionResult_t Spells::playerSaySpell(Player* player, std::string& words)

// Replace:
TalkActionResult_t Spells::playerSaySpell(Player* player, std::string& words, InstantSpell*& instantSpell)

spells.h
C++:
// Found:
TalkActionResult_t playerSaySpell(Player* player, std::string& words);

// Replace:
TalkActionResult_t playerSaySpell(Player* player, std::string& words, InstantSpell*& spell);
 
Back
Top