• 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++ attack speed attribute on crossbows and bows

dragon1155

Member
Joined
Mar 5, 2010
Messages
131
Reaction score
5
Hey guys, I'm having trouble getting the attack speed attribute to work with crossbows and bows. I tried a workaround I found in another discussion, but strangely, it only works when the attack speed attribute is applied to the ammunition, completely ignoring the attribute applied to the distance weapon.
player.cpp:
C++:
void Player::doAttacking(uint32_t)
{
    Item* item = getWeapon(false);
    uint32_t attackSpeed = (item && item->getAttackSpeed() != 0) ? item->getAttackSpeed() : getAttackSpeed();


    if(!lastAttack)
        lastAttack = OTSYS_TIME() - attackSpeed - 1;
    else if((OTSYS_TIME() - lastAttack) < attackSpeed)
        return;


    if(hasCondition(CONDITION_PACIFIED) && !hasCustomFlag(PlayerCustomFlag_IgnorePacification))
    {
        lastAttack = OTSYS_TIME();
        return;
    }


    if(const Weapon* _weapon = g_weapons->getWeapon(item))
    {
so, I think this line is for regular weapons (not including distance weapons that use ammunition):
player.cpp:
C++:
uint32_t Player::getAttackSpeed() const
{
    return ((weapon && weapon->getAttackSpeed() != 0) ? weapon->getAttackSpeed() : (vocation->getAttackSpeed() / std::max((size_t)1, getWeapons().size())));
}
interestingly, the attack speed value set for vocation in vocations.xml works well with all weapon types. Im not familiar with C++ at all, so i would really appreciate any suggestions and tips on what to do. TFS 0.4
 
void Player::doAttacking(uint32_t)
{
Item* item = getWeapon(false);
uint32_t attackSpeed = (item && item->getAttackSpeed() != 0) ? item->getAttackSpeed() : getAttackSpeed();


if(!lastAttack)
lastAttack = OTSYS_TIME() - attackSpeed - 1;
else if((OTSYS_TIME() - lastAttack) < attackSpeed)
return;

if(const Weapon* _weapon = g_weapons->getWeapon(item))
{
Post automatically merged:

void Player::doAttacking(uint32_t)

{

Item* item = getWeapon(false);

uint32_t attackSpeed = (item && item->getAttackSpeed() != 0) ? item->getAttackSpeed() : getAttackSpeed();





if(!lastAttack)

lastAttack = OTSYS_TIME() - attackSpeed - 1;

else if((OTSYS_TIME() - lastAttack) < attackSpeed)

return;



if(const Weapon* _weapon = g_weapons->getWeapon(item))

{
 
void Player::doAttacking(uint32_t)
{
Item* item = getWeapon(false);
uint32_t attackSpeed = (item && item->getAttackSpeed() != 0) ? item->getAttackSpeed() : getAttackSpeed();


if(!lastAttack)
lastAttack = OTSYS_TIME() - attackSpeed - 1;
else if((OTSYS_TIME() - lastAttack) < attackSpeed)
return;

if(const Weapon* _weapon = g_weapons->getWeapon(item))
{
Post automatically merged:
hey, thanks for looking into this. unfortunately, after compiling this code nothings changed :(
 
bump
@edit: i know i can fix this in lua (script for every distance weapon using ammo) - that works, but honestly, Im not totally happy with that solution :/
 
Last edited:
Back
Top