• 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.X+ tfs 1.4 attackspeed on item

Mjmackan

Mapper ~ Writer
Joined
Jul 18, 2009
Messages
1,444
Solutions
16
Reaction score
180
Location
Sweden
Hello!

I've seen this new attribute you can add onto items in the new tfs 1.4 aka: attackspeed.
However its not shown looking on the item, i tried to add it to data/lib/core/item.lua but it warns for nil value, how come?
And what does this do in sources? (item.cpp):
C++:
            uint32_t attackSpeed = item ? item->getAttackSpeed() : it.attackSpeed;
            if (attackSpeed) {
                if (begin) {
                    begin = false;
                    s << " (";
                } else {
                    s << ", ";
                }

                s << "Atk Spd:" << (attackSpeed / 1000.) << "s";
            }
 
Solution
how you tried adding it to core/item.lua? you just need to use itemType:getAttackSpeed()
I added this after speed:
LUA:
        if abilities.attackSpeed ~= 0 then
            begin = addSeparator(ss, begin)
            ss:append('speed %s%d', showpos(abilities.attackSpeed), math.abs(abilities.attackSpeed / 2))
        end

Removing luaitemdesc it works but only for weapons, thats probably the intention of it aswell as it sets your characters attack speed.

A little side question: Would it be much adjusting in sources to make it work on all equipments and make it as a buff instead where it lowers ur atk speed instead of setting it? So when i put 100 it lowers your attack speed with 100ms.
Edit: adding in source...
i tried to add it to data/lib/core/item.lua
this only works if you have "luaItemDesc" set to true in config.lua, otherwise all other item descriptions are taken from source

and have you registered the item you added attackspeed on movements.xml? IIRC only items registered there can show attributes., at least that is how it used to work
 
this only works if you have "luaItemDesc" set to true in config.lua, otherwise all other item descriptions are taken from source

and have you registered the item you added attackspeed on movements.xml? IIRC only items registered there can show attributes., at least that is how it used to work
So if I'd rather use sources, I'll set that to false? Makes sense now when reading it.. hehe
luaItemDesc is set to true & the item is added to movements.xml. Speed & crit is showing properly but not attack speed.

asdsd.png
alo.png
 
how you tried adding it to core/item.lua? you just need to use itemType:getAttackSpeed()
I added this after speed:
LUA:
        if abilities.attackSpeed ~= 0 then
            begin = addSeparator(ss, begin)
            ss:append('speed %s%d', showpos(abilities.attackSpeed), math.abs(abilities.attackSpeed / 2))
        end

Removing luaitemdesc it works but only for weapons, thats probably the intention of it aswell as it sets your characters attack speed.

A little side question: Would it be much adjusting in sources to make it work on all equipments and make it as a buff instead where it lowers ur atk speed instead of setting it? So when i put 100 it lowers your attack speed with 100ms.
Edit: adding in source vocation->getAttackSpeed() - weapon->getAttackSpeed() changes the function to what i wanted.


Guess this part of source is guilty for the weapon only criteria: (and maybe the set part aswell?)
C++:
uint32_t Player::getAttackSpeed() const
{
    const Item* weapon = getWeapon(true);
    if (!weapon || weapon->getAttackSpeed() == 0) {
        return vocation->getAttackSpeed();
    }

    return weapon->getAttackSpeed();
}
okok.png


Edit: Using it:getAttackSpeed() instead of abilities.attackSpeed made it work.
 
Last edited:
Solution
Back
Top