• 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.2 Attack Speed

lazarus321

Member
Joined
May 8, 2017
Messages
209
Reaction score
20
Hi guys,

We have this function vocation:getAttackSpeed() to get the value, and to add a different value how would it be?

Ex, Player have attackspeed="2000" i'd like to put attackspeed="1500" for 10 seconds for a spell.
 
Last edited:
Lua:
function onCastSpell(creature, variant)
    local player = Player(creature)
    if not player then
        return false
    end
    local ms = player:getVocation():getAttackSpeed()
    player:setAttackSpeed(1500)
    addEvent(function(cid, ms)
        local player = Player(cid)
        if not player then
            return
        end
        player:setAttackSpeed(ms)
    end, player:getId(), ms)
    return true
end
 
@Stigma i get this error in the player.ccp.

C++:
Severity    Code    Description    Project    File    Line    Suppression State
Error    C2084    function 'uint32_t Player::getAttackSpeed(void) const' already has a body    theforgottenserver    C:\OT\Original\Servidores\Reino\src\player.cpp    1764

i have this function for DualWielding maybe having trouble interfering.

C++:
uint32_t Player::getAttackSpeed() const {
    uint32_t ret = vocation->getAttackSpeed();
     if (isDualWielding()) {
        double multiplier = 100.0 / static_cast<double>(g_config.getNumber(ConfigManager::DUAL_WIELDING_SPEED_RATE));
        ret = static_cast<uint32_t>(std::ceil(static_cast<double>(ret) * multiplier));
    }
     return ret;
}
 
C++:
uint32_t Player::getAttackSpeed() const {
    if (attackSpeed > 0) {
        return attackSpeed;
    }
    uint32_t ret = vocation->getAttackSpeed();
     if (isDualWielding()) {
        double multiplier = 100.0 / static_cast<double>(g_config.getNumber(ConfigManager::DUAL_WIELDING_SPEED_RATE));
        ret = static_cast<uint32_t>(std::ceil(static_cast<double>(ret) * multiplier));
    }
     return ret;
}
 
uint32_t Player::getAttackSpeed() const { if (attackSpeed > 0) { return attackSpeed; } uint32_t ret = vocation->getAttackSpeed(); if (isDualWielding()) { double multiplier = 100.0 / static_cast<double>(g_config.getNumber(ConfigManager::DUAL_WIELDING_SPEED_RATE)); ret = static_cast<uint32_t>(std::ceil(static_cast<double>(ret) * multiplier)); } return ret; }
same error can be another thing?
 
I already told you to replace the existing one, not create a new one.
"already has a body" means it has already been defined in player.h, look for it and replace it
 
Sorry, I'm a layman. I replace everything according to your script. Thank you for your patience in trying to help me.
I replace 3 files player.h, luascript.h and luascript.ccp. This is giving error in player.ccp file. Can you check it for me? follow my files.
 

Attachments

So i understand this function is duplicated in the following file player.ccp,

C++:
uint32_t Player::getAttackSpeed() const {
    uint32_t ret = vocation->getAttackSpeed();
     if (isDualWielding()) {
        double multiplier = 100.0 / static_cast<double>(g_config.getNumber(ConfigManager::DUAL_WIELDING_SPEED_RATE));
        ret = static_cast<uint32_t>(std::ceil(static_cast<double>(ret) * multiplier));
    }
     return ret;
}

with file player.h

C++:
        void setAttackSpeed(uint32_t speed) {
            attackSpeed = speed;
        }
        uint32_t getAttackSpeed() const {
            if (attackSpeed > 0) {
                return attackSpeed;
            }
            return vocation->getAttackSpeed();
        }

but how would I rewrite this function in the player.ccp file without duplicity?
 
So i understand this function is duplicated in the following file player.ccp,

C++:
uint32_t Player::getAttackSpeed() const {
    uint32_t ret = vocation->getAttackSpeed();
     if (isDualWielding()) {
        double multiplier = 100.0 / static_cast<double>(g_config.getNumber(ConfigManager::DUAL_WIELDING_SPEED_RATE));
        ret = static_cast<uint32_t>(std::ceil(static_cast<double>(ret) * multiplier));
    }
     return ret;
}

with file player.h

C++:
        void setAttackSpeed(uint32_t speed) {
            attackSpeed = speed;
        }
        uint32_t getAttackSpeed() const {
            if (attackSpeed > 0) {
                return attackSpeed;
            }
            return vocation->getAttackSpeed();
        }

but how would I rewrite this function in the player.ccp file without duplicity?
Remove the player.cpp function, replace the player.h function with this:
C++:
uint32_t getAttackSpeed() const {
    if (attackSpeed > 0) {
        return attackSpeed;
    }
    uint32_t ret = vocation->getAttackSpeed();
     if (isDualWielding()) {
        double multiplier = 100.0 / static_cast<double>(g_config.getNumber(ConfigManager::DUAL_WIELDING_SPEED_RATE));
        ret = static_cast<uint32_t>(std::ceil(static_cast<double>(ret) * multiplier));
    }
     return ret;
}
 
i got 156 errors

36486

if i erase this function in player.cpp and your scrit work perfect, but my atk speed for dualWielding not work.
I think if we rewrite this function could work.
 
Last edited:
Back
Top