TFS 1.2 Attack Speed

lazarus321

Member
Joined
May 8, 2017
Messages
140
Reaction score
14
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:

Evil Hero

Legacy Member
Joined
Dec 12, 2007
Messages
1,136
Reaction score
495
Location
Germany
There is currently no way to do this in a default TFS 1.2 without modifications in the source code
 

Stigma

Veteran OT User
Joined
Feb 14, 2015
Messages
4,506
Reaction score
2,059
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
 
OP
L

lazarus321

Member
Joined
May 8, 2017
Messages
140
Reaction score
14
@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;
}
 

Stigma

Veteran OT User
Joined
Feb 14, 2015
Messages
4,506
Reaction score
2,059
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;
}
 
OP
L

lazarus321

Member
Joined
May 8, 2017
Messages
140
Reaction score
14
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?
 

Stigma

Veteran OT User
Joined
Feb 14, 2015
Messages
4,506
Reaction score
2,059
That doesn't matter. They are two separate metatables.
 
OP
L

lazarus321

Member
Joined
May 8, 2017
Messages
140
Reaction score
14
36415

can i erase this step in player.h? i think is this error. sorry my english is bad.

36416
 
Last edited:

Stigma

Veteran OT User
Joined
Feb 14, 2015
Messages
4,506
Reaction score
2,059
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
 
OP
L

lazarus321

Member
Joined
May 8, 2017
Messages
140
Reaction score
14
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

OP
L

lazarus321

Member
Joined
May 8, 2017
Messages
140
Reaction score
14
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?
 

Stigma

Veteran OT User
Joined
Feb 14, 2015
Messages
4,506
Reaction score
2,059
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;
}
 
OP
L

lazarus321

Member
Joined
May 8, 2017
Messages
140
Reaction score
14
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:
Top