• 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.3 compile error

kimokimo

Kimo
Joined
Jan 25, 2011
Messages
821
Solutions
6
Reaction score
156
GitHub
karimadnan
I added a small edit to function combatHealth in game.cpp

Code:
        if (targetPlayer = dynamic_cast<Player*> (target)) {
            std::string value;
            double damageReduction = 0;
            uint32_t storage[33];
            sprintf(storage, "%d", g_config.getNumber(ConfigManager::DAMAGE_REDUCTION_STORAGE));
            targetPlayer->getStorage(storage, value);
            if (atoi(value.c_str()) < 0) {
                actualDamage = initialDamage;
            } else {
                damageReduction = atof(value.c_str());
                actualDamage = initialDamage * (1 - (damageReduction / 100));
            }

#ifdef __CUSTOM_DEBUG__
            std::cout << "Player named " << targetPlayer->getName() << " has a damage reductin of " << damageReduction << "%.\n";
            std::cout << "Incoming damage: " << initialDamage << ", actual damage dealt: " << actualDamage << "\n";
#endif
        }

here's what happened
 
Solution
It's getStorageValue, not getStorage. You're using so much weird shit that you don't need to be doing, like using dynamic_cast and a raw int array for storage key, just use this:
C++:
        if (Player* targetPlayer = target->getPlayer()) {
            int32_t value;
            double damageReduction = 0;
            uint32_t storage = g_config.getNumber(ConfigManager::DAMAGE_REDUCTION_STORAGE);
            targetPlayer->getStorage(storage, value);
            if (value < 0) {
                actualDamage = initialDamage;
            } else {
                damageReduction = value;
                actualDamage = initialDamage * (1 - (damageReduction / 100));
            }

#ifdef __CUSTOM_DEBUG__
            std::cout << "Player named...
It's getStorageValue, not getStorage. You're using so much weird shit that you don't need to be doing, like using dynamic_cast and a raw int array for storage key, just use this:
C++:
        if (Player* targetPlayer = target->getPlayer()) {
            int32_t value;
            double damageReduction = 0;
            uint32_t storage = g_config.getNumber(ConfigManager::DAMAGE_REDUCTION_STORAGE);
            targetPlayer->getStorage(storage, value);
            if (value < 0) {
                actualDamage = initialDamage;
            } else {
                damageReduction = value;
                actualDamage = initialDamage * (1 - (damageReduction / 100));
            }

#ifdef __CUSTOM_DEBUG__
            std::cout << "Player named " << targetPlayer->getName() << " has a damage reduction of " << damageReduction << "%.\n";
            std::cout << "Incoming damage: " << initialDamage << ", actual damage dealt: " << actualDamage << "\n";
#endif
        }

Storage values are no longer strings as well for future reference.
 
Solution
Back
Top