TFS 1.2 Attack Speed

lazarus321

Member
Joined
May 8, 2017
Messages
164
Best answers
0
Reaction score
15
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
TFS Developer
Joined
Dec 12, 2007
Messages
1,179
Best answers
15
Reaction score
553
Location
Germany
There is currently no way to do this in a default TFS 1.2 without modifications in the source code
 

Delusion

Divine Intellect
Support Team
Joined
Feb 14, 2015
Messages
5,109
Best answers
485
Reaction score
2,745
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
164
Best answers
0
Reaction score
15
@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;
}
 

Delusion

Divine Intellect
Support Team
Joined
Feb 14, 2015
Messages
5,109
Best answers
485
Reaction score
2,745
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
164
Best answers
0
Reaction score
15
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?
 

Delusion

Divine Intellect
Support Team
Joined
Feb 14, 2015
Messages
5,109
Best answers
485
Reaction score
2,745
That doesn't matter. They are two separate metatables.
 
OP
L

lazarus321

Member
Joined
May 8, 2017
Messages
164
Best answers
0
Reaction score
15
36415

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

36416
 
Last edited:

Delusion

Divine Intellect
Support Team
Joined
Feb 14, 2015
Messages
5,109
Best answers
485
Reaction score
2,745
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
164
Best answers
0
Reaction score
15
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
164
Best answers
0
Reaction score
15
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?
 

Delusion

Divine Intellect
Support Team
Joined
Feb 14, 2015
Messages
5,109
Best answers
485
Reaction score
2,745
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
164
Best answers
0
Reaction score
15
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