• 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
136
Reaction score
8
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:
There is upgrade system for tfs0.4 that changes attack speed for xboww and bows if thats distro ur using and it works so maybe check that lua code

I rewrote the old upgrade system that boosts/gives weapon attack speed, but unfortunately, any attack speed attribute doesnt work for bows and crossbows. I'd have to create a script for each weapon, defining which ammo to use and the animation for the corresponding ammo, then it starts working. i thought it would be easy because previously the attribute completely ignored any changes related to dist weapons, but after changing to whats in my first post, the attribute started working on ammo. Im starting to suspect that doing this through the source might be very difficult because I found the same problem in several threads, but none were fully solved :l
 
I rewrote the old upgrade system that boosts/gives weapon attack speed, but unfortunately, any attack speed attribute doesnt work for bows and crossbows. I'd have to create a script for each weapon, defining which ammo to use and the animation for the corresponding ammo, then it starts working. i thought it would be easy because previously the attribute completely ignored any changes related to dist weapons, but after changing to whats in my first post, the attribute started working on ammo. Im starting to suspect that doing this through the source might be very difficult because I found the same problem in several threads, but none were fully solved :l
Meh so just make one script with table like
Weapon ammolist no?
 
Meh so just make one script with table like
Weapon ammolist no?
I know how to do it, but that solution seems gross to me, because I thought that by doing it through the source, and knowing how to assign the ammunition attribute, you could sum up the attack speed of the ammunition and the weapon it's used on. similarly, i can do the same with critical hit chance. its like having a broken car - you can call a taxi - youll do what you wanted, but the problem still remains. xD
 
I know how to do it, but that solution seems gross to me, because I thought that by doing it through the source, and knowing how to assign the ammunition attribute, you could sum up the attack speed of the ammunition and the weapon it's used on. similarly, i can do the same with critical hit chance. its like having a broken car - you can call a taxi - youll do what you wanted, but the problem still remains. xD
But youre not a programmer(neither am I btw) so you cant do it and I would not expect anyone on forum to care the only way is to unfortunately pay someone for such solution im not advocating sale but this is the peak of open tibia we have if you cant do it pay someone to do it cuz for free they will only Laugh at you such as they laughed at me.
 
But youre not a programmer(neither am I btw) so you cant do it and I would not expect anyone on forum to care the only way is to unfortunately pay someone for such solution im not advocating sale but this is the peak of open tibia we have if you cant do it pay someone to do it cuz for free they will only Laugh at you such as they laughed at me.
well, back in the day, people did actually laugh, and there were legit reasons for it. but if someone in 2024 wants to mock someone or demand payment on an OPEN tibia forum whos showing even a hint of willingness to learn or do anything, thats the wrong forum; they should head over to tibia srs business.com and, by strict criteria, grant official permission to open an SMS shop in the game to whoevers the closest thing to Bill Gates.
 
Last edited:
No one cares about TFS 0.x anymore because it's already dead. The features are terrible, among other things. Most people use TFS 1.x+ because it's more up-to-date and there are always scripts or codes available out there. The solution is to hire someone who cares and work with TFS 0.x. I suggest you abandon the TFS 0.4 base and go for Nekiro TFS 1.5 8.6 and be happy. :)
 
No one cares about TFS 0.x anymore because it's already dead. The features are terrible, among other things. Most people use TFS 1.x+ because it's more up-to-date and there are always scripts or codes available out there. The solution is to hire someone who cares and work with TFS 0.x. I suggest you abandon the TFS 0.4 base and go for Nekiro TFS 1.5 8.6 and be happy. :)

Im aware that 0.X is currently a minority, but it's definitely not dead. In the case of 1.X, you simply get solutions to trivial things faster (similarly to 0.X), or you get payment offers for solutions/scripts quicker. just spend 2 hours on the forum, and youll see that its a fact, not an opinion. :D
 
Are you having issues with attack speed attribute while shooting with a bow or crossbow while running? Or when using runes or potions and the attack speed attribute stops working properly? I believe you might need to make some changes in the player.cpp file to fix this.

Search for: Player.cpp
C++:
if((!_weapon->hasExhaustion() || !hasCondition(CONDITION_EXHAUST, EXHAUST_COMBAT)) && _weapon->useWeapon(this, item, attackedCreature))
Change by:
C++:
if(!_weapon->hasExhaustion() && _weapon->useWeapon(this, item, attackedCreature))

Use rune while running.

In player.cpp, remove this line.
C++:
setNextAction(OTSYS_TIME() + getStepDuration(dir));

In the weapons.xml, for the item you want to allow the simultaneous use of a rune while running and shooting with increased attack speed, please include the following changes.

example:

swing="true"

XML:
<distance id="7368" level="80" event="function" value="default"/> <!-- Assassin Star -->

for
XML:
<distance id="7368" level="80" swing="true" event="function" value="default"/> <!-- Assassin Star -->
I believe these changes should work, but I'm not sure. You'll have to test them to find out. I know that it should allow you to use runes and potions while running and attacking with a bow or crossbow at the same time. As for the attack speed attribute, I'm not certain. It's important to make the changes and test them to see the results.
 
Back
Top